Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
eclipse
GitHub Repository: eclipse/sumo
Path: blob/main/src/utils/foxtools/MFXMenuButtonTooltip.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 MFXMenuButtonTooltip.cpp
15
/// @author Pablo Alvarez Lopez
16
/// @date 2022-07-27
17
///
18
// MenuButton similar to FXMenuButton but with the possibility of showing tooltips
19
/****************************************************************************/
20
#include <config.h>
21
22
#include <utils/gui/windows/GUIAppEnum.h>
23
24
#include "MFXStaticToolTip.h"
25
#include "MFXMenuButtonTooltip.h"
26
27
// ===========================================================================
28
// FOX callback mapping
29
// ===========================================================================
30
31
FXDEFMAP(MFXMenuButtonTooltip) MFXMenuButtonTooltipMap[] = {
32
FXMAPFUNC(SEL_ENTER, 0, MFXMenuButtonTooltip::onEnter),
33
FXMAPFUNC(SEL_LEAVE, 0, MFXMenuButtonTooltip::onLeave),
34
FXMAPFUNC(SEL_MOTION, 0, MFXMenuButtonTooltip::onMotion),
35
FXMAPFUNC(SEL_LEFTBUTTONPRESS, 0, MFXMenuButtonTooltip::onLeftBtnPress),
36
FXMAPFUNC(SEL_KEYPRESS, 0, MFXMenuButtonTooltip::onKeyPress),
37
FXMAPFUNC(SEL_COMMAND, FXWindow::ID_POST, MFXMenuButtonTooltip::onCmdPost),
38
};
39
40
// Object implementation
41
FXIMPLEMENT(MFXMenuButtonTooltip, FXMenuButton, MFXMenuButtonTooltipMap, ARRAYNUMBER(MFXMenuButtonTooltipMap))
42
43
// ===========================================================================
44
// method definitions
45
// ===========================================================================
46
47
MFXMenuButtonTooltip::MFXMenuButtonTooltip(FXComposite* p, MFXStaticToolTip* staticToolTip, const std::string& text, FXIcon* ic,
48
FXPopup* pup, FXObject* optionalTarget, FXuint opts,
49
FXint x, FXint y, FXint w, FXint h, FXint pl, FXint pr, FXint pt, FXint pb) :
50
FXMenuButton(p, text.c_str(), ic, pup, opts, x, y, w, h, pl, pr, pt, pb),
51
myStaticToolTip(staticToolTip),
52
myOptionalTarget(optionalTarget) {
53
}
54
55
56
MFXMenuButtonTooltip::~MFXMenuButtonTooltip() {}
57
58
59
long
60
MFXMenuButtonTooltip::onEnter(FXObject* sender, FXSelector sel, void* ptr) {
61
// show tip show
62
myStaticToolTip->showStaticToolTip(getTipText());
63
return FXMenuButton::onEnter(sender, sel, ptr);
64
}
65
66
67
long
68
MFXMenuButtonTooltip::onLeave(FXObject* sender, FXSelector sel, void* ptr) {
69
// hide static toolTip
70
myStaticToolTip->hideStaticToolTip();
71
return FXMenuButton::onLeave(sender, sel, ptr);
72
}
73
74
75
long
76
MFXMenuButtonTooltip::onMotion(FXObject* sender, FXSelector sel, void* ptr) {
77
// update static tooltip
78
myStaticToolTip->onUpdate(sender, sel, ptr);
79
return FXMenuButton::onMotion(sender, sel, ptr);
80
}
81
82
83
long
84
MFXMenuButtonTooltip::onLeftBtnPress(FXObject* sender, FXSelector sel, void* ptr) {
85
// inform optional target
86
if (myOptionalTarget) {
87
myOptionalTarget->tryHandle(this, FXSEL(MID_MBTTIP_FOCUS, message), nullptr);
88
}
89
// continue handling onLeftBtnPress
90
return FXMenuButton::onLeftBtnPress(sender, sel, ptr);
91
}
92
93
long
94
MFXMenuButtonTooltip::onKeyPress(FXObject* sender, FXSelector sel, void* ptr) {
95
// inform optional target
96
if (myOptionalTarget) {
97
myOptionalTarget->tryHandle(this, FXSEL(MID_MBTTIP_FOCUS, message), nullptr);
98
}
99
// continue handling onKeyPress
100
return FXMenuButton::onKeyPress(sender, sel, ptr);
101
}
102
103
104
long
105
MFXMenuButtonTooltip::onCmdPost(FXObject* sender, FXSelector sel, void* ptr) {
106
// inform optional target
107
if (myOptionalTarget) {
108
myOptionalTarget->tryHandle(this, FXSEL(MID_MBTTIP_SELECTED, message), nullptr);
109
}
110
// continue handling onCheck
111
return FXMenuButton::onCmdPost(sender, sel, ptr);
112
}
113
114
/****************************************************************************/
115
116