Eclipse SUMO - Simulation of Urban MObility
Loading...
Searching...
No Matches
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-2025 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// FOX callback mapping
34// ===========================================================================
35
36FXDEFMAP(MFXStaticToolTip) MFXStaticToolTipMap[] = {
37 FXMAPFUNC(SEL_PAINT, 0, MFXStaticToolTip::onPaint),
38 FXMAPFUNC(SEL_UPDATE, 0, MFXStaticToolTip::onUpdate),
39};
40
41// Object implementation
42FXIMPLEMENT(MFXStaticToolTip, FXToolTip, MFXStaticToolTipMap, ARRAYNUMBER(MFXStaticToolTipMap))
43
44// ===========================================================================
45// method definitions
46// ===========================================================================
47
49 FXToolTip(app) {
50 // set empty test
51 setText("");
52 // start hide
53 hide();
54}
55
56
58
59
60void
62 if (value) {
64 } else {
67 }
68}
69
70
71bool
75
76
77void
78MFXStaticToolTip::showStaticToolTip(const FXString& toolTipText) {
79 if (!myEnableStaticTooltip || toolTipText.empty()) {
81 } else {
82 // set tip text
83 setText(toolTipText);
84 // update before show (for position)
85 onUpdate(nullptr, 0, nullptr);
86 // show StaticToolTip
87 show();
88 }
89}
90
91
92void
94 // clear text
95 setText("");
96 // hide staticTooltip
97 hide();
98}
99
100
101long
102MFXStaticToolTip::onPaint(FXObject* sender, FXSelector sel, void* obj) {
103 // draw tooltip using myToolTippedObject
104 if (!label.empty() && myEnableStaticTooltip) {
105 return FXToolTip::onPaint(sender, sel, obj);
106 } else {
107 return 0;
108 }
109}
110
111
112long
113MFXStaticToolTip::onUpdate(FXObject* sender, FXSelector sel, void* ptr) {
114 // Regular GUI update
115 FXWindow::onUpdate(sender, sel, ptr);
116 // Ask the help source for a new status text first
117 if (label.empty()) {
118 popped = FALSE;
119 hide();
120 } else {
121 popped = TRUE;
122 FXint x, y;
123 FXuint state;
124 getRoot()->getCursorPosition(x, y, state);
125 place(x, y);
126 }
127 return 1;
128}
129
130
132 FXToolTip() {
133}
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