Eclipse SUMO - Simulation of Urban MObility
Loading...
Searching...
No Matches
MFXTextFieldTooltip.cpp
Go to the documentation of this file.
1
/****************************************************************************/
2
// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3
// Copyright (C) 2001-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
// TextField similar to FXTextField but with the possibility of showing tooltips
19
/****************************************************************************/
20
#include <config.h>
21
22
#include "
MFXTextFieldTooltip.h
"
23
24
25
FXDEFMAP
(
MFXTextFieldTooltip
) MFXTextFieldTooltipMap[] = {
26
FXMAPFUNC(SEL_ENTER, 0,
MFXTextFieldTooltip::onEnter
),
27
FXMAPFUNC(SEL_LEAVE, 0,
MFXTextFieldTooltip::onLeave
),
28
FXMAPFUNC(SEL_MOTION, 0,
MFXTextFieldTooltip::onMotion
),
29
};
30
31
// Object implementation
32
FXIMPLEMENT(
MFXTextFieldTooltip
, FXTextField, MFXTextFieldTooltipMap, ARRAYNUMBER(MFXTextFieldTooltipMap))
33
34
35
MFXTextFieldTooltip
::
MFXTextFieldTooltip
(FXComposite* p,
MFXStaticToolTip
* staticToolTip, FXint ncols, FXObject* tgt, FXSelector sel,
36
FXuint opts, FXint x, FXint y, FXint w, FXint h, FXint pl, FXint pr, FXint pt, FXint pb) :
37
FXTextField(p, ncols, tgt, sel, opts, x, y, w, h, pl, pr, pt, pb),
38
myStaticToolTip(staticToolTip) {
39
}
40
41
42
MFXTextFieldTooltip::~MFXTextFieldTooltip
() {}
43
44
45
void
46
MFXTextFieldTooltip::setToolTipText
(
const
FXString& toolTip) {
47
myToolTipText
= toolTip;
48
}
49
50
51
long
52
MFXTextFieldTooltip::onEnter
(FXObject* sender, FXSelector sel,
void
* ptr) {
53
// check if show toolTip text
54
if
(!
myToolTipText
.empty()) {
55
// show toolTip text
56
setTipText(
myToolTipText
);
57
// show tip show
58
myStaticToolTip
->
showStaticToolTip
(getTipText());
59
}
else
if
(font->getTextWidth(contents.text(), contents.length()) > getWidth()) {
60
// only show tip Text if contents is bigger than textField width
61
setTipText(contents);
62
// show tip show
63
myStaticToolTip
->
showStaticToolTip
(getTipText());
64
}
65
// always show help text
66
setHelpText(contents);
67
// continue with FXTextField function
68
return
FXTextField::onEnter(sender, sel, ptr);
69
}
70
71
72
long
73
MFXTextFieldTooltip::onLeave
(FXObject* sender, FXSelector sel,
void
* ptr) {
74
// hide static toolTip
75
myStaticToolTip
->
hideStaticToolTip
();
76
// continue with FXTextField function
77
return
FXTextField::onLeave(sender, sel, ptr);
78
}
79
80
81
long
82
MFXTextFieldTooltip::onMotion
(FXObject* sender, FXSelector sel,
void
* ptr) {
83
// update static tooltip
84
myStaticToolTip
->
onUpdate
(sender, sel, ptr);
85
return
FXTextField::onMotion(sender, sel, ptr);
86
}
87
88
/****************************************************************************/
FXDEFMAP
FXDEFMAP(MFXTextFieldTooltip) MFXTextFieldTooltipMap[]
MFXTextFieldTooltip.h
MFXStaticToolTip
MFXStaticToolTip (based on FXToolTip)
Definition
MFXStaticToolTip.h:27
MFXStaticToolTip::onUpdate
long onUpdate(FXObject *sender, FXSelector sel, void *ptr)
called when tooltip is updated
Definition
MFXStaticToolTip.cpp:114
MFXStaticToolTip::showStaticToolTip
void showStaticToolTip(const FXString &toolTipText)
show static toolTip
Definition
MFXStaticToolTip.cpp:79
MFXStaticToolTip::hideStaticToolTip
void hideStaticToolTip()
hide static toolTip
Definition
MFXStaticToolTip.cpp:94
MFXTextFieldTooltip
Definition
MFXTextFieldTooltip.h:29
MFXTextFieldTooltip::onLeave
long onLeave(FXObject *, FXSelector, void *)
called when mouse leaves in MFXTextFieldTooltip
Definition
MFXTextFieldTooltip.cpp:73
MFXTextFieldTooltip::onMotion
long onMotion(FXObject *, FXSelector, void *)
called when mouse motion in MFXTextFieldTooltip
Definition
MFXTextFieldTooltip.cpp:82
MFXTextFieldTooltip::myStaticToolTip
MFXStaticToolTip * myStaticToolTip
FOX needs this.
Definition
MFXTextFieldTooltip.h:63
MFXTextFieldTooltip::myToolTipText
FXString myToolTipText
toolTip text (if set, tooltip will be always show)
Definition
MFXTextFieldTooltip.h:66
MFXTextFieldTooltip::onEnter
long onEnter(FXObject *, FXSelector, void *)
Definition
MFXTextFieldTooltip.cpp:52
MFXTextFieldTooltip::~MFXTextFieldTooltip
~MFXTextFieldTooltip()
destructor (Called automatically)
Definition
MFXTextFieldTooltip.cpp:42
MFXTextFieldTooltip::setToolTipText
void setToolTipText(const FXString &toolTip)
set toolTip
Definition
MFXTextFieldTooltip.cpp:46
src
utils
foxtools
MFXTextFieldTooltip.cpp
Generated on Tue Nov 5 2024 00:10:31 for Eclipse SUMO - Simulation of Urban MObility by
1.9.8