Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
eclipse
GitHub Repository: eclipse/sumo
Path: blob/main/src/utils/foxtools/MFXCheckButtonTooltip.cpp
169678 views
1
/****************************************************************************/
2
// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3
// Copyright (C) 2001-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
/****************************************************************************/
14
/// @file MFXCheckButtonTooltip.cpp
15
/// @author Pablo Alvarez Lopez
16
/// @date May 23
17
///
18
// CheckButton similar to FXCheckButton but with the possibility of showing tooltips
19
/****************************************************************************/
20
#include <config.h>
21
22
#include "MFXStaticToolTip.h"
23
#include "MFXCheckButtonTooltip.h"
24
25
// ===========================================================================
26
// FOX callback mapping
27
// ===========================================================================
28
29
FXDEFMAP(MFXCheckButtonTooltip) MFXCheckButtonTooltipMap[] = {
30
FXMAPFUNC(SEL_ENTER, 0, MFXCheckButtonTooltip::onEnter),
31
FXMAPFUNC(SEL_LEAVE, 0, MFXCheckButtonTooltip::onLeave),
32
FXMAPFUNC(SEL_MOTION, 0, MFXCheckButtonTooltip::onMotion),
33
};
34
35
// Object implementation
36
FXIMPLEMENT(MFXCheckButtonTooltip, FXCheckButton, MFXCheckButtonTooltipMap, ARRAYNUMBER(MFXCheckButtonTooltipMap))
37
38
// ===========================================================================
39
// method definitions
40
// ===========================================================================
41
42
MFXCheckButtonTooltip::MFXCheckButtonTooltip(FXComposite* p, MFXStaticToolTip* staticToolTip, const FXString& text, FXObject* tgt,
43
FXSelector sel, FXuint opts, FXint x, FXint y, FXint w, FXint h, FXint pl, FXint pr, FXint pt, FXint pb) :
44
FXCheckButton(p, text, tgt, sel, opts, x, y, w, h, pl, pr, pt, pb),
45
myStaticToolTip(staticToolTip) {
46
}
47
48
49
MFXCheckButtonTooltip::~MFXCheckButtonTooltip() {}
50
51
52
void
53
MFXCheckButtonTooltip::setToolTipText(const FXString& toolTip) {
54
myToolTipText = toolTip;
55
}
56
57
58
long
59
MFXCheckButtonTooltip::onEnter(FXObject* sender, FXSelector sel, void* ptr) {
60
// check if show toolTip text
61
if (!myToolTipText.empty()) {
62
// show toolTip text
63
setTipText(myToolTipText);
64
// show tip show
65
myStaticToolTip->showStaticToolTip(getTipText());
66
}
67
// continue with FXCheckButton function
68
return FXCheckButton::onEnter(sender, sel, ptr);
69
}
70
71
72
long
73
MFXCheckButtonTooltip::onLeave(FXObject* sender, FXSelector sel, void* ptr) {
74
// hide static toolTip
75
myStaticToolTip->hideStaticToolTip();
76
// continue with FXCheckButton function
77
return FXCheckButton::onLeave(sender, sel, ptr);
78
}
79
80
81
long
82
MFXCheckButtonTooltip::onMotion(FXObject* sender, FXSelector sel, void* ptr) {
83
// update static tooltip
84
myStaticToolTip->onUpdate(sender, sel, ptr);
85
return FXCheckButton::onMotion(sender, sel, ptr);
86
}
87
88
/****************************************************************************/
89
90