NCBI C++ ToolKit
tooltip.cpp
Go to the documentation of this file.

Go to the SVN repository for this file.

1 /* $Id: tooltip.cpp 46649 2021-08-18 17:05:14Z evgeniev $
2  * ===========================================================================
3  *
4  * PUBLIC DOMAIN NOTICE
5  * National Center for Biotechnology Information
6  *
7  * This software/database is a "United States Government Work" under the
8  * terms of the United States Copyright Act. It was written as part of
9  * the author's official duties as a United States Government employee and
10  * thus cannot be copyrighted. This software/database is freely available
11  * to the public for use. The National Library of Medicine and the U.S.
12  * Government have not placed any restriction on its use or reproduction.
13  *
14  * Although all reasonable efforts have been taken to ensure the accuracy
15  * and reliability of the software and data, the NLM and the U.S.
16  * Government do not and cannot warrant the performance or results that
17  * may be obtained by using this software or data. The NLM and the U.S.
18  * Government disclaim all warranties, express or implied, including
19  * warranties of performance, merchantability or fitness for any particular
20  * purpose.
21  *
22  * Please cite the author in any work or product based on this material.
23  *
24  * ===========================================================================
25  *
26  * Authors: Dmitry Rudnev
27  *
28  * File Description:
29  *
30  */
31 
32 #include <ncbi_pch.hpp>
33 
34 #include <gui/objutils/tooltip.hpp>
35 #include <gui/objutils/utils.hpp>
36 #include <math.h>
37 
39 
41 {
42  switch(eFormatter)
43  {
50  }
51  NCBI_ASSERT(false, "Unknown tooltip formatter type!");
52  return null;
53 }
54 
55 static void s_AddPubmedLinksRow(const string& pmids, bool& isGoToPresent, bool isBulletColPresent, ITooltipFormatter* pFormatter)
56 {
57  const string pmURL("/pubmed/");
58  string pmlinks;
59  if (!pmids.empty()) {
60  vector<string> tokens;
61  NStr::Split(pmids, ",", tokens);
62  bool bFirst = true;
63  ITERATE(vector<string>, pmidIter, tokens) {
64  string pmid = *pmidIter;
66  // check that the string looks like a valid PubmedID (integer > 0)
67  int ipmid = NStr::StringToInt(pmid, NStr::fConvErr_NoThrow);
68  if(ipmid > 0) {
69  if (bFirst) {
70  bFirst = false;
71  pmlinks = pFormatter->CreateNcbiLink(pmid, pmURL+pmid);
72  }
73  else {
74  pmlinks += ", " + pFormatter->CreateNcbiLink(pmid, pmURL+pmid);
75  }
76  }
77  }
78  if(!pmlinks.empty()) {
79  pFormatter->StartRow();
80  if(isBulletColPresent) {
81  pFormatter->AddBulletCol();
82  }
83  pFormatter->AddTagCol("PubMed:");
84  pFormatter->AddValueCol(pmlinks);
85  pFormatter->FinishRow();
86  }
87  }
88 }
89 
90 
91 static void s_MaybeAddGoToRow(bool& isGoToPresent, bool isBulletColPresent, ITooltipFormatter* pFormatter)
92 {
93  if(isGoToPresent)
94  return;
95  pFormatter->StartRow();
96  if(isBulletColPresent)
97  pFormatter->AddBulletCol();
98  pFormatter->AddTagCol("Go to:");
99  pFormatter->FinishRow();
100 
101  isGoToPresent = true;
102 }
103 
104 
105 
107 {
109 }
110 
112 {
114 }
115 
117 {
118  m_sTooltipText += "<tr class=\"sv-bintrack\">";
119 }
120 
121 void CCSSTableTooltipFormatter::AddBulletCol(const string& sBulletSrc)
122 {
123  m_sTooltipText += "<td class=\"sv-bintrack-bullet\">";
124  if (!sBulletSrc.empty())
125  m_sTooltipText += "<img class=\"sv-bintrack\" src=\"" + sBulletSrc + "\"/>";
126  m_sTooltipText += "</td>";
127 }
128 
129 
130 void CCSSTableTooltipFormatter::AddTagCol(const string& sContents, const string& sBulletSrc)
131 {
132  m_sTooltipText += "<td class=\"sv-bintrack-tag\">";
133  if (!sBulletSrc.empty())
134  m_sTooltipText += "<img class=\"sv-bintrack\" src=\"" + sBulletSrc + "\"/>&nbsp;";
135  m_sTooltipText += m_TrustedData ? sContents : NStr::HtmlEncode(sContents);
136  m_sTooltipText += "</td>";
137 }
138 
139 void CCSSTableTooltipFormatter::AddValueCol(const string& sContents, unsigned width, bool isNoWrap)
140 {
141  string styleAttr;
142  if (isNoWrap || width) {
143  styleAttr = " style=\"";
144  styleAttr += isNoWrap ? "white-space:nowrap;" : "";
145  styleAttr += "\"";
146  }
147  m_sTooltipText += string("<td class=\"sv-bintrack-value\"") +
148  styleAttr +
149  string(">") +
150  sContents +
151  "</td>";
152 }
153 
155 {
156  m_sTooltipText += "</tr>";
157 }
158 
160 {
161  m_sTooltipText += "<tr class=\"sv-bintrack\"><td class=\"sv-bintrack\" colspan=\"" + NStr::UIntToString(colspan) + "\"><hr></td></tr>";
162 }
163 
164 void CCSSTableTooltipFormatter::AddRow(const string& sContents, unsigned colspan)
165 {
166  m_sTooltipText += "<tr class=\"sv-bintrack\"><td class=\"sv-bintrack-tag\" colspan=\"" + NStr::UIntToString(colspan) + "\">" + (m_TrustedData ? sContents : NStr::HtmlEncode(sContents)) + "</td></tr>";
167 }
168 
169 void CCSSTableTooltipFormatter::AddRow(const string& sTag, const string& sValue, unsigned valueColWidth, bool)
170 {
171  m_sTooltipText += "<tr class=\"sv-bintrack\"><td class=\"sv-bintrack-tag\">";
172  m_sTooltipText += sTag;
173  m_sTooltipText += "</td><td class=\"sv-bintrack-value\"";
174  m_sTooltipText += ">";
175  m_sTooltipText += m_TrustedData ? sValue : NStr::HtmlEncode(sValue);
176  m_sTooltipText += "</td></tr>";
177 }
178 
179 void CCSSTableTooltipFormatter::AddLinkRow(const string& sTag, const string& sValue, unsigned valueColWidth)
180 {
181  m_sLinksText += "<tr class=\"sv-bintrack\"><td class=\"sv-bintrack-tag\">";
182  m_sLinksText += sTag;
183  m_sLinksText += "</td><td class=\"sv-bintrack-value\"";
184  m_sLinksText += ">";
185  m_sLinksText += sValue;
186  m_sLinksText += "</td></tr>";
187 }
188 
189 void CCSSTableTooltipFormatter::AddLinkRow(const string& sTag, const string& sText, const string& sUrl, unsigned valueColWidth)
190 {
191  m_sLinksText += "<tr class=\"sv-bintrack\"><td class=\"sv-bintrack-tag\">";
192  m_sLinksText += sTag;
193  m_sLinksText += "</td><td class=\"sv-bintrack-value\"";
194  m_sLinksText += "><a target=\"_blank\" href=\"";
195  m_sLinksText += sUrl;
196  m_sLinksText += "\">";
197  m_sLinksText += sText;
198  m_sLinksText += "</a></td></tr>";
199 }
200 
202 {
203  m_sLinksText += "<tr class=\"sv-bintrack\"><td class=\"sv-bintrack-tag\" align=\"right\" valign=\"top\" style=\"white-space: nowrap\">[<i>" + sTitle + "</i>]</td><td class=\"sv-bintrack\" colspan=\"0\"/></tr>";
204 }
205 
206 void CCSSTableTooltipFormatter::AddSectionRow(const string& sContents)
207 {
208  m_sTooltipText += "<tr class=\"sv-bintrack\"><td class=\"sv-bintrack-value\" align=\"right\" valign=\"top\" style=\"white-space: nowrap\">[<i>" + sContents + "</i>]</td><td class=\"sv-bintrack\" colspan=\"0\"/></tr>";
209 }
210 
212 {
213  if (IsEmpty())
214  return "";
215  string sWholeTooltip;
216  if (!m_sTooltipText.empty()) {
217  sWholeTooltip += "<table class=\"sv-bintrack\" style=\"border-spacing:2px\">" + m_sTooltipText + "</table>";
218  }
219  if (!m_sLinksText.empty()) {
220  if (!m_sTooltipText.empty())
221  sWholeTooltip += "<br/>&nbsp";
222  sWholeTooltip += "<table class=\"sv-bintrack\" style=\"border-spacing:2px\">" + m_sLinksText + "</table>";
223  m_sLinksText.clear();
224  }
225  m_sTooltipText.clear();
226  return sWholeTooltip;
227 }
228 
230 {
231  return m_sTooltipText.empty();
232 }
233 
234 void CCSSTableTooltipFormatter::AddPubmedLinksRow(const string& pmids, bool& isGoToPresent, bool isBulletColPresent)
235 {
236  s_AddPubmedLinksRow(pmids, isGoToPresent, isBulletColPresent, this);
237 }
238 
239 void CCSSTableTooltipFormatter::MaybeAddGoToRow(bool& isGoToPresent, bool isBulletColPresent)
240 {
241  s_MaybeAddGoToRow(isGoToPresent, isBulletColPresent, this);
242 }
243 
244 string CCSSTableTooltipFormatter::CreateLink(const string& sText, const string& sUrl) const
245 {
246  return "<a class=\"sv-bintrack\" href=\"" + sUrl + "\" target=\"_blank\">"+ (m_TrustedData ? sText : NStr::HtmlEncode(sText)) + "</a>";
247 }
248 
249 string CCSSTableTooltipFormatter::CreateNcbiLink(const string& sText, const string& sUrl) const
250 {
251  return CreateLink(sText, sUrl);
252 }
253 
255 {
256  const CCSSTableTooltipFormatter* pCSSTableFormatter = dynamic_cast<const CCSSTableTooltipFormatter*>(&tooltip);
257  if (!pCSSTableFormatter)
258  return;
259 
260  m_sTooltipText += pCSSTableFormatter->m_sTooltipText;
261  m_sLinksText += pCSSTableFormatter->m_sLinksText;
262 }
263 
265 {
267 }
268 
270 {
272 }
273 
275 {
276  m_sTooltipText += "<tr>";
277 }
278 
279 void CHtmlTooltipFormatter::AddBulletCol(const string& sBulletSrc)
280 {
281  m_sTooltipText += "<td valign=\"top\" align=\"right\" nowrap>";
282  if(!sBulletSrc.empty()) {
283  m_sTooltipText += "<img src=\"" + CSeqUtils::GetNcbiBaseUrl() + sBulletSrc +"\"/>&nbsp;";
284  }
285  m_sTooltipText += "</td>";
286 }
287 
288 
289 void CHtmlTooltipFormatter::AddTagCol(const string& sContents, const string& sBulletSrc)
290 {
291  m_sTooltipText += "<td valign=\"top\" align=\"right\" nowrap>";
292  if (!sBulletSrc.empty())
293  m_sTooltipText += "<img src=\"" + CSeqUtils::GetNcbiBaseUrl() + sBulletSrc + "\"/>&nbsp;";
294  m_sTooltipText += "<span style=\"font-weight:bold\">" + (m_TrustedData ? sContents : NStr::HtmlEncode(sContents)) + "</span></td>";
295 }
296 
297 void CHtmlTooltipFormatter::AddValueCol(const string& sContents, unsigned width, bool isNoWrap)
298 {
299  string widthAttr;
300  if (width) {
301  widthAttr = " width=\"" + NStr::UIntToString(width) + "\"";
302  }
303  m_sTooltipText += string("<td valign=\"top\"") +
304  string(isNoWrap ? " nowrap" : "") +
305  widthAttr +
306  string(">") +
307  sContents +
308  "</td>";
309 }
310 
312 {
313  m_sTooltipText += "</tr>";
314 }
315 
317 {
318  m_sTooltipText += "<tr><td colspan=\"" + NStr::UIntToString(colspan) + "\"><hr></td></tr>";
319 }
320 
321 void CHtmlTooltipFormatter::AddRow(const string& sContents, unsigned colspan)
322 {
323  m_sTooltipText += "<tr><td colspan=\"" + NStr::UIntToString(colspan) + "\">" + (m_TrustedData ? sContents : NStr::HtmlEncode(sContents)) + "</td></tr>";
324 }
325 
326 void CHtmlTooltipFormatter::AddRow(const string& sTag, const string& sValue, unsigned valueColWidth, bool noSpaceInsert)
327 {
328  string spacedValue(sValue);
329  if(!noSpaceInsert) {
330  x_InsertSpaces(spacedValue);
331  }
332  m_sTooltipText += "<tr><td align=\"right\" valign=\"top\" nowrap><span style=\"font-weight:bold\">";
333  m_sTooltipText += sTag;
334  m_sTooltipText += "</span></td><td";
335  if (valueColWidth)
336  m_sTooltipText += " width=\"" + NStr::UIntToString(valueColWidth) + "\">";
337  else
338  m_sTooltipText += ">";
339  m_sTooltipText += m_TrustedData ? spacedValue : NStr::HtmlEncode(spacedValue);
340  m_sTooltipText += "</td></tr>";
341 }
342 
343 void CHtmlTooltipFormatter::AddLinkRow(const string& sTag, const string& sValue, unsigned valueColWidth)
344 {
345  m_sLinksText += "<tr><td align=\"right\" valign=\"top\" nowrap><span style=\"font-weight:bold\">";
346  m_sLinksText += sTag;
347  m_sLinksText += "</span></td><td ";
348  if (valueColWidth)
349  m_sLinksText += " width=\"" + NStr::UIntToString(valueColWidth) + "\">";
350  else
351  m_sLinksText += ">";
352  m_sLinksText += sValue;
353  m_sLinksText += "</td></tr>";
354 }
355 
356 void CHtmlTooltipFormatter::AddLinkRow(const string& sTag, const string& sText, const string& sUrl, unsigned valueColWidth)
357 {
358  m_sLinksText += "<tr><td align=\"right\" valign=\"top\" nowrap><span style=\"font-weight:bold\">";
359  m_sLinksText += sTag;
360  m_sLinksText += "</span></td><td";
361  if (valueColWidth)
362  m_sLinksText += " width=\"" + NStr::UIntToString(valueColWidth) + "\"><a href=\"";
363  else
364  m_sLinksText += "><a href=\"";
365  m_sLinksText += sUrl;
366  m_sLinksText += "\">";
367  m_sLinksText += sText;
368  m_sLinksText += "</a></td></tr>";
369 }
370 
371 void CHtmlTooltipFormatter::AddLinksTitle(const string& sTitle)
372 {
373  m_sLinksText += "<tr><td align=\"right\" valign=\"top\" nowrap>[<i>" + sTitle + "</i>]</td><td colspan=\"0\"/></tr>";
374 }
375 
376 void CHtmlTooltipFormatter::AddSectionRow(const string& sContents)
377 {
378  m_sTooltipText += "<tr><td align=\"right\" valign=\"top\" nowrap>[<i>" + sContents + "</i>]</td><td colspan=\"0\"/></tr>";
379 }
380 
382 {
383  if (IsEmpty())
384  return "";
385  string sWholeTooltip;
386  if (!m_sTooltipText.empty()) {
387  sWholeTooltip += "<table margin=\"0\" padding=\"0\" border=\"0\" cellpadding=\"0\" cellspacing=\"2\">" + m_sTooltipText + "</table>";
388  }
389  if (!m_sLinksText.empty()) {
390  if (!m_sTooltipText.empty())
391  sWholeTooltip += "<br/>&nbsp";
392  sWholeTooltip += "<table margin=\"0\" padding=\"0\" border=\"0\" cellpadding=\"0\" cellspacing=\"2\">" + m_sLinksText + "</table>";
393  m_sLinksText.clear();
394  }
395  m_sTooltipText.clear();
396  return sWholeTooltip;
397 }
398 
400 {
401  return m_sTooltipText.empty();
402 }
403 
404 void CHtmlTooltipFormatter::AddPubmedLinksRow(const string& pmids, bool& isGoToPresent, bool isBulletColPresent)
405 {
406  s_AddPubmedLinksRow(pmids, isGoToPresent, isBulletColPresent, this);
407 }
408 
409 void CHtmlTooltipFormatter::MaybeAddGoToRow(bool& isGoToPresent, bool isBulletColPresent)
410 {
411  s_MaybeAddGoToRow(isGoToPresent, isBulletColPresent, this);
412 }
413 
414 string CHtmlTooltipFormatter::CreateLink(const string& sText, const string& sUrl) const
415 {
416  string sSpacedText(sText);
417  x_InsertSpaces(sSpacedText);
418  return "<a href=\"" + sUrl + "\" target=\"_blank\">" + (m_TrustedData ? sSpacedText : NStr::HtmlEncode(sSpacedText)) + "</a>";
419 }
420 
421 string CHtmlTooltipFormatter::CreateNcbiLink(const string& sText, const string& sUrl) const
422 {
424  ? sUrl : CSeqUtils::GetNcbiBaseUrl() + sUrl);
425 }
426 
427 string CHtmlTooltipFormatter::CreateGenomicLink(const string& sText, const string& sUrl) const
428 {
429  string sUpdateURL = NStr::Replace(sUrl, "/projects/sviewer/", "");
430  return CreateLink(sText, string("$GENOMIC_LINK$") + sUpdateURL);
431 }
432 
434 {
435  const CHtmlTooltipFormatter* pHtmlFormatter = dynamic_cast<const CHtmlTooltipFormatter*>(&tooltip);
436  if (!pHtmlFormatter)
437  return;
438 
439  m_sTooltipText += pHtmlFormatter->m_sTooltipText;
440  m_sLinksText += pHtmlFormatter->m_sLinksText;
441 }
442 
443 inline void CHtmlTooltipFormatter::x_FindAllOccurences(const string &input, char search, vector<size_t> &occurences) const
444 {
445  size_t pos = input.find(search);
446  while (string::npos != pos) {
447  occurences.push_back(pos);
448  pos = input.find(search, pos + 1);
449  }
450 }
451 
452 unsigned CHtmlTooltipFormatter::x_InsertSpaces(string &input, size_t start, size_t end, size_t fragment_length) const
453 {
454  size_t length = (end < input.length() ? end : input.length() - 1) - start + 1;
455  unsigned fragments = (unsigned)round(length / (double)fragment_length);
456  unsigned insertions(0);
457  for (unsigned i = 1; i <= fragments; ++i) {
458  size_t pos = start + i*fragment_length + insertions;
459  if (pos > input.length())
460  break;
461 
462  input.insert(pos, 1, ' ');
463  insertions++;
464  }
465  return insertions;
466 }
467 
468 void CHtmlTooltipFormatter::x_InsertSpaces(string &input, size_t fragment_length) const
469 {
470  if (input.length() <= fragment_length)
471  return;
472 
473  vector<size_t> spaces;
474  x_FindAllOccurences(input, ' ', spaces);
475  x_FindAllOccurences(input, '\t', spaces);
476  x_FindAllOccurences(input, '\n', spaces);
477 
478  if (spaces.empty()) {
479  x_InsertSpaces(input, 0, input.length() - 1, fragment_length);
480  }
481  else {
482  std::sort(spaces.begin(), spaces.end());
483  spaces.push_back(input.length() - 1);
484  unsigned i = 0;
485  size_t start = 0;
486  size_t end = 0;
487  unsigned insertions = 0;
488  do {
489  start = end + insertions;
490  end = spaces[i++] + insertions;
491  if ((end - start + 1) > fragment_length)
492  insertions += x_InsertSpaces(input, start + insertions, end + insertions, fragment_length);
493  }
494  while (i < spaces.size());
495  }
496 }
497 
499 {
501 }
502 
504 {
506 }
507 
508 
510 {
511 }
512 
513 void CTextTooltipFormatter::AddBulletCol(const string& sBulletSrc)
514 {
515  m_sTooltipText += sBulletSrc.empty() ? " " : " * ";
516 }
517 
518 
519 void CTextTooltipFormatter::AddTagCol(const string& sContents, const string& sBulletSrc)
520 {
521  if (!sBulletSrc.empty())
522  m_sTooltipText += " * ";
523  m_sTooltipText += sContents + " ";
524 }
525 
526 void CTextTooltipFormatter::AddValueCol(const string& sContents, unsigned /*width*/, bool /* isNoWrap */)
527 {
528  m_sTooltipText += sContents;
529 }
530 
532 {
533  m_sTooltipText += "\n";
534 }
535 
537 {
538  m_sTooltipText += "\n-----------------------\n";
539 }
540 
541 void CTextTooltipFormatter::AddRow(const string& sContents, unsigned)
542 {
543  m_sTooltipText += sContents + "\n";
544 }
545 
546 void CTextTooltipFormatter::AddRow(const string& sTag, const string& sValue, unsigned, bool)
547 {
548  m_sTooltipText += sTag;
549  m_sTooltipText += "\t";
550  m_sTooltipText += sValue;
551 }
552 
553 void CTextTooltipFormatter::AddLinkRow(const string& sTag, const string& sValue, unsigned valueColWidth)
554 {
555  m_sLinksText += sTag;
556  m_sLinksText += "\t";
557  m_sLinksText += sValue;
558 }
559 
560 void CTextTooltipFormatter::AddLinkRow(const string& sTag, const string& sText, const string& sUrl, unsigned valueColWidth)
561 {
562  m_sLinksText += sTag;
563  m_sLinksText += "\t";
564  m_sLinksText += CreateLink(sText, sUrl);
565 }
566 
567 void CTextTooltipFormatter::AddLinksTitle(const string& sTitle)
568 {
569  m_sLinksText += sTitle + "\n";
570 }
571 
572 void CTextTooltipFormatter::AddSectionRow(const string& sContents)
573 {
574  m_sTooltipText += sContents + "\n";
575 }
576 
578 {
579  string sWholeTooltip(m_sTooltipText);
580  if (!m_sLinksText.empty()) {
581  sWholeTooltip += "\n";
582  sWholeTooltip += m_sLinksText;
583  m_sLinksText.clear();
584  }
585  m_sTooltipText.clear();
586  return sWholeTooltip;
587 }
588 
590 {
591  return m_sTooltipText.empty();
592 }
593 
594 
595 void CTextTooltipFormatter::AddPubmedLinksRow(const string& pmids, bool& isGoToPresent, bool isBulletColPresent)
596 {
597  s_AddPubmedLinksRow(pmids, isGoToPresent, isBulletColPresent, this);
598 }
599 
600 string CTextTooltipFormatter::CreateLink(const string& sText, const string& sUrl) const
601 {
602  return sText;
603 }
604 
605 string CTextTooltipFormatter::CreateNcbiLink(const string& sText, const string& sUrl) const
606 {
608  ? sUrl : CSeqUtils::GetNcbiBaseUrl() + sUrl);
609 }
610 
611 void CTextTooltipFormatter::MaybeAddGoToRow(bool& isGoToPresent, bool isBulletColPresent)
612 {
613  s_MaybeAddGoToRow(isGoToPresent, isBulletColPresent, this);
614 }
615 
617 {
618  const CTextTooltipFormatter* pTextFormatter = dynamic_cast<const CTextTooltipFormatter*>(&tooltip);
619  if (!pTextFormatter)
620  return;
621 
622  m_sTooltipText += pTextFormatter->m_sTooltipText;
623  m_sLinksText += pTextFormatter->m_sLinksText;
624 }
625 
T round(const T &v)
tooltips using html tables with css classes from projects/sviewer/css/style.css and generated NCBI UR...
Definition: tooltip.hpp:241
tooltips using html tables with html attibute formatting and generate NCBI URLs are absolute (recomme...
Definition: tooltip.hpp:283
tooltips using plain text formatting
Definition: tooltip.hpp:328
primitive interface to arrange tabular data in the tooltips
Definition: tooltip.hpp:55
#define ITERATE(Type, Var, Cont)
ITERATE macro to sequence through container elements.
Definition: ncbimisc.hpp:815
string
Definition: cgiapp.hpp:687
#define NCBI_ASSERT(expr, mess)
Definition: ncbidbg.hpp:130
static string GetNcbiBaseUrl()
Definition: utils.cpp:971
virtual void FinishRow()=0
finish the row (i.e. no other contents will be added to it)
virtual void AddValueCol(const string &sContents="", unsigned width=200, bool isNoWrap=false)
adds a value column to the row
Definition: tooltip.cpp:139
virtual void AddDividerRow(unsigned colspan=2)
add a horizontal divider between sections of the table
Definition: tooltip.cpp:316
virtual void Append(const ITooltipFormatter &tooltip)
appends another formatter to this one
Definition: tooltip.cpp:433
virtual string CreateNcbiLink(const string &sText, const string &sUrl) const
construct the HTML code for a link from the displayed text label and supplied NCBI URL path
Definition: tooltip.cpp:249
virtual string Render()
returns the formatted tooltip text and resets the formatter for reuse
Definition: tooltip.cpp:577
static CIRef< ITooltipFormatter > CreateTooltipFormatter()
Definition: tooltip.cpp:498
ETooltipFormatters
supported types of formatters
Definition: tooltip.hpp:58
virtual string Render()
returns the formatted tooltip text and resets the formatter for reuse
Definition: tooltip.cpp:211
virtual void AddTagCol(const string &sContents="", const string &sBulletSrc="")
adds a tag column to the row
Definition: tooltip.cpp:130
virtual void AddPubmedLinksRow(const string &pmids, bool &isGoToPresent, bool isBulletColPresent)
add a row containing all links to specified Pubmed IDs
Definition: tooltip.cpp:234
virtual void AddRow(const string &sContents="", unsigned colspan=2)
add a row with a cell, spanning across all columns
Definition: tooltip.cpp:541
virtual void AddLinkRow(const string &sTag, const string &sValue, unsigned valueColWidth=200)
add a row with two columns
Definition: tooltip.cpp:343
void x_FindAllOccurences(const string &input, char search, vector< size_t > &occurences) const
Definition: tooltip.cpp:443
virtual void AddDividerRow(unsigned colspan=2)
add a horizontal divider between sections of the table
Definition: tooltip.cpp:159
virtual void Append(const ITooltipFormatter &tooltip)
appends another formatter to this one
Definition: tooltip.cpp:616
virtual void AddValueCol(const string &sContents="", unsigned width=200, bool isNoWrap=false)=0
adds a value column to the row
virtual string CreateNcbiLink(const string &sText, const string &sUrl) const
construct the HTML code for a link from the displayed text label and supplied NCBI URL path
Definition: tooltip.cpp:605
virtual void AddBulletCol(const string &sBulletSrc="")
add a cell with an image
Definition: tooltip.cpp:513
virtual void MaybeAddGoToRow(bool &isGoToPresent, bool isBulletColPresent)
conditionally add a Go To row
Definition: tooltip.cpp:611
static CIRef< ITooltipFormatter > CreateTooltipFormatter(ETooltipFormatters)
factory for requested tooltip formatter creation
Definition: tooltip.cpp:40
virtual void AddLinkRow(const string &sTag, const string &sValue, unsigned valueColWidth=200)
add a row with two columns
Definition: tooltip.cpp:179
virtual void MaybeAddGoToRow(bool &isGoToPresent, bool isBulletColPresent)
conditionally add a Go To row
Definition: tooltip.cpp:409
virtual void AddTagCol(const string &sContents="", const string &sBulletSrc="")=0
adds a tag column to the row
unsigned x_InsertSpaces(string &input, size_t start, size_t end, size_t fragment_length=65) const
Definition: tooltip.cpp:452
virtual void AddLinksTitle(const string &sTitle)
add a row with the links title
Definition: tooltip.cpp:201
virtual void AddSectionRow(const string &sContents)
add a section row
Definition: tooltip.cpp:206
virtual string CreateNcbiLink(const string &sText, const string &sUrl) const
construct the HTML code for a link from the displayed text label and supplied NCBI URL path
Definition: tooltip.cpp:421
virtual string CreateGenomicLink(const string &sText, const string &sUrl) const
Definition: tooltip.cpp:427
virtual string Render()
returns the formatted tooltip text and resets the formatter for reuse
Definition: tooltip.cpp:381
virtual void FinishRow()
finish the row (i.e. no other contents will be added to it)
Definition: tooltip.cpp:154
virtual void FinishRow()
finish the row (i.e. no other contents will be added to it)
Definition: tooltip.cpp:531
virtual void AddTagCol(const string &sContents="", const string &sBulletSrc="")
adds a tag column to the row
Definition: tooltip.cpp:519
virtual void AddBulletCol(const string &sBulletSrc="")=0
add a cell with an image
virtual void AddTagCol(const string &sContents="", const string &sBulletSrc="")
adds a tag column to the row
Definition: tooltip.cpp:289
static CIRef< ITooltipFormatter > CreateTooltipFormatter()
Definition: tooltip.cpp:264
virtual void FinishRow()
finish the row (i.e. no other contents will be added to it)
Definition: tooltip.cpp:311
virtual CIRef< ITooltipFormatter > CreateInstance()
creates another instance of the same tooltip formatter
Definition: tooltip.cpp:269
virtual bool IsEmpty() const
Indicates if the tooltip is empty.
Definition: tooltip.cpp:589
virtual void AddPubmedLinksRow(const string &pmids, bool &isGoToPresent, bool isBulletColPresent)
add a row containing all links to specified Pubmed IDs
Definition: tooltip.cpp:404
virtual void StartRow()
start a new table row
Definition: tooltip.cpp:509
virtual void StartRow()
start a new table row
Definition: tooltip.cpp:274
virtual void AddLinkRow(const string &sTag, const string &sValue, unsigned valueColWidth=200)
add a row with two columns
Definition: tooltip.cpp:553
virtual bool IsEmpty() const
Indicates if the tooltip is empty.
Definition: tooltip.cpp:399
virtual CIRef< ITooltipFormatter > CreateInstance()
creates another instance of the same tooltip formatter
Definition: tooltip.cpp:503
virtual void AddRow(const string &sContents="", unsigned colspan=2)
add a row with a cell, spanning across all columns
Definition: tooltip.cpp:321
virtual void AddRow(const string &sContents="", unsigned colspan=2)
add a row with a cell, spanning across all columns
Definition: tooltip.cpp:164
virtual CIRef< ITooltipFormatter > CreateInstance()
creates another instance of the same tooltip formatter
Definition: tooltip.cpp:111
virtual void AddSectionRow(const string &sContents)
add a section row
Definition: tooltip.cpp:572
virtual void AddValueCol(const string &sContents="", unsigned width=200, bool isNoWrap=false)
adds a value column to the row
Definition: tooltip.cpp:297
virtual string CreateLink(const string &sText, const string &sUrl) const
construct the HTML code for a link from the displayed text label and supplied URL
Definition: tooltip.cpp:244
virtual void AddSectionRow(const string &sContents)
add a section row
Definition: tooltip.cpp:376
virtual void StartRow()=0
start a new table row
virtual void MaybeAddGoToRow(bool &isGoToPresent, bool isBulletColPresent)
conditionally add a Go To row
Definition: tooltip.cpp:239
virtual void Append(const ITooltipFormatter &tooltip)
appends another formatter to this one
Definition: tooltip.cpp:254
virtual void AddLinksTitle(const string &sTitle)
add a row with the links title
Definition: tooltip.cpp:371
virtual string CreateLink(const string &sText, const string &sUrl) const
construct the HTML code for a link from the displayed text label and supplied URL
Definition: tooltip.cpp:414
virtual void AddPubmedLinksRow(const string &pmids, bool &isGoToPresent, bool isBulletColPresent)
add a row containing all links to specified Pubmed IDs
Definition: tooltip.cpp:595
static CIRef< ITooltipFormatter > CreateTooltipFormatter()
Definition: tooltip.cpp:106
virtual string CreateLink(const string &sText, const string &sUrl) const
construct the HTML code for a link from the displayed text label and supplied URL
Definition: tooltip.cpp:600
virtual string CreateNcbiLink(const string &sText, const string &sUrl) const =0
construct the HTML code for a link from the displayed text label and supplied NCBI URL path
virtual void AddValueCol(const string &sContents="", unsigned width=200, bool isNoWrap=false)
adds a value column to the row
Definition: tooltip.cpp:526
virtual void StartRow()
start a new table row
Definition: tooltip.cpp:116
virtual void AddBulletCol(const string &sBulletSrc="")
add a cell with an image
Definition: tooltip.cpp:279
virtual bool IsEmpty() const
Indicates if the tooltip is empty.
Definition: tooltip.cpp:229
virtual void AddDividerRow(unsigned colspan=2)
add a horizontal divider between sections of the table
Definition: tooltip.cpp:536
virtual void AddLinksTitle(const string &sTitle)
add a row with the links title
Definition: tooltip.cpp:567
virtual void AddBulletCol(const string &sBulletSrc="")
add a cell with an image
Definition: tooltip.cpp:121
@ eTooltipFormatter_CSSTable
generated table is CSS based, generated NCBI URLs are paths (recommended for SViewer)
Definition: tooltip.hpp:59
@ eTooltipFormatter_Html
generated table is HTML attributes (no CSS) based, generate NCBI URLs are absolute (recommended for G...
Definition: tooltip.hpp:60
@ eTooltipFormatter_Text
plain text formatted
Definition: tooltip.hpp:61
#define END_NCBI_SCOPE
End previously defined NCBI scope.
Definition: ncbistl.hpp:103
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
Definition: ncbistl.hpp:100
static int StringToInt(const CTempString str, TStringToNumFlags flags=0, int base=10)
Convert string to int.
Definition: ncbistr.cpp:630
static list< string > & Split(const CTempString str, const CTempString delim, list< string > &arr, TSplitFlags flags=0, vector< SIZE_TYPE > *token_pos=NULL)
Split a string using specified delimiters.
Definition: ncbistr.cpp:3452
static string HtmlEncode(const CTempString str, THtmlEncode flags=fHtmlEnc_EncodeAll)
Encode a string for HTML.
Definition: ncbistr.cpp:4113
static void TruncateSpacesInPlace(string &str, ETrunc where=eTrunc_Both)
Truncate whitespace in a string (in-place)
Definition: ncbistr.cpp:3192
static string & Replace(const string &src, const string &search, const string &replace, string &dst, SIZE_TYPE start_pos=0, SIZE_TYPE max_replace=0, SIZE_TYPE *num_replace=0)
Replace occurrences of a substring within a string.
Definition: ncbistr.cpp:3305
static string UIntToString(unsigned int value, TNumToStringFlags flags=0, int base=10)
Convert UInt to string.
Definition: ncbistr.hpp:5111
static bool StartsWith(const CTempString str, const CTempString start, ECase use_case=eCase)
Check if a string starts with a specified prefix value.
Definition: ncbistr.hpp:5414
@ fConvErr_NoThrow
Do not throw an exception on error.
Definition: ncbistr.hpp:285
static int input()
int i
constexpr auto sort(_Init &&init)
static void s_AddPubmedLinksRow(const string &pmids, bool &isGoToPresent, bool isBulletColPresent, ITooltipFormatter *pFormatter)
Definition: tooltip.cpp:55
static void s_MaybeAddGoToRow(bool &isGoToPresent, bool isBulletColPresent, ITooltipFormatter *pFormatter)
Definition: tooltip.cpp:91
Modified on Wed Sep 04 15:01:47 2024 by modify_doxy.py rev. 669887