Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
eclipse
GitHub Repository: eclipse/sumo
Path: blob/main/src/utils/foxtools/MFXButtonTooltip.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 MFXButtonTooltip.cpp
15
/// @author Angelo Banse
16
/// @date 2022-06-21
17
///
18
// Button similar to FXButton but with the possibility of showing tooltips
19
/****************************************************************************/
20
#include <config.h>
21
22
#include "MFXStaticToolTip.h"
23
#include "MFXButtonTooltip.h"
24
25
// ===========================================================================
26
// FOX callback mapping
27
// ===========================================================================
28
29
FXDEFMAP(MFXButtonTooltip) MFXButtonTooltipMap[] = {
30
FXMAPFUNC(SEL_ENTER, 0, MFXButtonTooltip::onEnter),
31
FXMAPFUNC(SEL_LEAVE, 0, MFXButtonTooltip::onLeave),
32
FXMAPFUNC(SEL_MOTION, 0, MFXButtonTooltip::onMotion),
33
};
34
35
// Object implementation
36
FXIMPLEMENT(MFXButtonTooltip, FXButton, MFXButtonTooltipMap, ARRAYNUMBER(MFXButtonTooltipMap))
37
38
// ===========================================================================
39
// method definitions
40
// ===========================================================================
41
42
MFXButtonTooltip::MFXButtonTooltip(FXComposite* p, MFXStaticToolTip* staticToolTip,
43
const std::string& text, FXIcon* ic,
44
FXObject* tgt, FXSelector sel, FXuint opts,
45
FXint x, FXint y, FXint w, FXint h,
46
FXint pl, FXint pr, FXint pt, FXint pb) :
47
FXButton(p, text.c_str(), ic, tgt, sel, opts, x, y, w, h, pl, pr, pt, pb),
48
myStaticToolTip(staticToolTip) {
49
}
50
51
52
MFXButtonTooltip::~MFXButtonTooltip() {}
53
54
55
long
56
MFXButtonTooltip::onEnter(FXObject* sender, FXSelector sel, void* ptr) {
57
// show tip show
58
myStaticToolTip->showStaticToolTip(getTipText());
59
return FXButton::onEnter(sender, sel, ptr);
60
}
61
62
63
long
64
MFXButtonTooltip::onLeave(FXObject* sender, FXSelector sel, void* ptr) {
65
// hide static toolTip
66
myStaticToolTip->hideStaticToolTip();
67
return FXButton::onLeave(sender, sel, ptr);
68
}
69
70
71
long
72
MFXButtonTooltip::onMotion(FXObject* sender, FXSelector sel, void* ptr) {
73
// update static tooltip
74
myStaticToolTip->onUpdate(sender, sel, ptr);
75
return FXButton::onMotion(sender, sel, ptr);
76
}
77
78
/****************************************************************************/
79
80