Eclipse SUMO - Simulation of Urban MObility
MFXStaticToolTip.cpp
Go to the documentation of this file.
1 /****************************************************************************/
2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3 // Copyright (C) 2006-2024 German Aerospace Center (DLR) and others.
4 // This program and the accompanying materials are made available under the
5 // terms of the Eclipse Public License 2.0 which is available at
6 // https://www.eclipse.org/legal/epl-2.0/
7 // This Source Code may also be made available under the following Secondary
8 // Licenses when the conditions for such availability set forth in the Eclipse
9 // Public License 2.0 are satisfied: GNU General Public License, version 2
10 // or later which is available at
11 // https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html
12 // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
13 /****************************************************************************/
18 //
19 /****************************************************************************/
20 
21 /* =========================================================================
22 * included modules
23 * ======================================================================= */
24 #include <config.h>
25 
29 
30 #include "MFXStaticToolTip.h"
31 
32 
33 // ===========================================================================
34 // FOX callback mapping
35 // ===========================================================================
36 
37 FXDEFMAP(MFXStaticToolTip) MFXStaticToolTipMap[] = {
38  FXMAPFUNC(SEL_PAINT, 0, MFXStaticToolTip::onPaint),
39  FXMAPFUNC(SEL_UPDATE, 0, MFXStaticToolTip::onUpdate),
40 };
41 
42 // Object implementation
43 FXIMPLEMENT(MFXStaticToolTip, FXToolTip, MFXStaticToolTipMap, ARRAYNUMBER(MFXStaticToolTipMap))
44 
45 // ===========================================================================
46 // method definitions
47 // ===========================================================================
48 
50  FXToolTip(app) {
51  // set empty test
52  setText("");
53  // start hide
54  hide();
55 }
56 
57 
59 
60 
61 void
63  if (value) {
64  myEnableStaticTooltip = true;
65  } else {
66  myEnableStaticTooltip = false;
68  }
69 }
70 
71 
72 bool
74  return myEnableStaticTooltip;
75 }
76 
77 
78 void
79 MFXStaticToolTip::showStaticToolTip(const FXString& toolTipText) {
80  if (!myEnableStaticTooltip || toolTipText.empty()) {
82  } else {
83  // set tip text
84  setText(toolTipText);
85  // update before show (for position)
86  onUpdate(nullptr, 0, nullptr);
87  // show StaticToolTip
88  show();
89  }
90 }
91 
92 
93 void
95  // clear text
96  setText("");
97  // hide staticTooltip
98  hide();
99 }
100 
101 
102 long
103 MFXStaticToolTip::onPaint(FXObject* sender, FXSelector sel, void* obj) {
104  // draw tooltip using myToolTippedObject
105  if (!label.empty() && myEnableStaticTooltip) {
106  return FXToolTip::onPaint(sender, sel, obj);
107  } else {
108  return 0;
109  }
110 }
111 
112 
113 long
114 MFXStaticToolTip::onUpdate(FXObject* sender, FXSelector sel, void* ptr) {
115  // Regular GUI update
116  FXWindow::onUpdate(sender, sel, ptr);
117  // Ask the help source for a new status text first
118  if (label.empty()) {
119  popped = FALSE;
120  hide();
121  } else {
122  popped = TRUE;
123  FXint x, y;
124  FXuint state;
125  getRoot()->getCursorPosition(x, y, state);
126  place(x, y);
127  }
128  return 1;
129 }
130 
131 
133  FXToolTip() {
134 }
FXDEFMAP(MFXStaticToolTip) MFXStaticToolTipMap[]
MFXStaticToolTip (based on FXToolTip)
long onUpdate(FXObject *sender, FXSelector sel, void *ptr)
called when tooltip is updated
void showStaticToolTip(const FXString &toolTipText)
show static toolTip
bool myEnableStaticTooltip
flag for enable/disable static tooltip
long onPaint(FXObject *obj, FXSelector sel, void *ptr)
void enableStaticToolTip(const bool value)
enable/disable static tooltip
~MFXStaticToolTip()
destructor
void hideStaticToolTip()
hide static toolTip
MFXStaticToolTip()
FOX need this.
bool isStaticToolTipEnabled() const
check staticToolTip is enabled