Eclipse SUMO - Simulation of Urban MObility
Loading...
Searching...
No Matches
MFXCheckableButton.cpp
Go to the documentation of this file.
1/****************************************************************************/
2// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3// Copyright (C) 2004-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// missing_desc
19/****************************************************************************/
20#include <config.h>
21
22#include "MFXStaticToolTip.h"
23#include "MFXCheckableButton.h"
24
25// ===========================================================================
26// FOX callback mapping
27// ===========================================================================
28
29FXDEFMAP(MFXCheckableButton) MFXCheckableButtonMap[] = {
30 FXMAPFUNC(SEL_PAINT, 0, MFXCheckableButton::onPaint),
31 FXMAPFUNC(SEL_UPDATE, 0, MFXCheckableButton::onUpdate),
32 FXMAPFUNC(SEL_ENTER, 0, MFXCheckableButton::onEnter),
33 FXMAPFUNC(SEL_LEAVE, 0, MFXCheckableButton::onLeave),
34 FXMAPFUNC(SEL_MOTION, 0, MFXCheckableButton::onMotion),
35};
36
37// ===========================================================================
38// method definitions
39// ===========================================================================
40
41FXIMPLEMENT(MFXCheckableButton, FXButton, MFXCheckableButtonMap, ARRAYNUMBER(MFXCheckableButtonMap))
42
43MFXCheckableButton::MFXCheckableButton(bool amChecked, FXComposite* p, MFXStaticToolTip* staticToolTip,
44 const std::string& text, FXIcon* ic, FXObject* tgt, FXSelector sel,
45 FXuint opts, 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 myAmChecked(amChecked), myAmInitialised(false),
49 myStaticToolTip(staticToolTip) {
50 border = 0;
51}
52
53
55
56
57bool
61
62
63void
64MFXCheckableButton::setChecked(bool val, const bool inform) {
65 myAmChecked = val;
66 if (inform) {
67 if (myAmChecked) {
68 FXButton::onCheck(nullptr, 0, nullptr);
69 } else {
70 FXButton::onUncheck(nullptr, 0, nullptr);
71 }
72 }
73}
74
75
76long
77MFXCheckableButton::onPaint(FXObject* sender, FXSelector sel, void* ptr) {
78 if (!myAmInitialised) {
80 }
81 setColors();
82 return FXButton::onPaint(sender, sel, ptr);
83}
84
85
86long
87MFXCheckableButton::onUpdate(FXObject* sender, FXSelector sel, void* ptr) {
88 if (!myAmInitialised) {
90 }
91 setColors();
92 return FXButton::onUpdate(sender, sel, ptr);
93}
94
95
96long
97MFXCheckableButton::onEnter(FXObject* sender, FXSelector sel, void* ptr) {
98 // show tip show
100 return FXButton::onEnter(sender, sel, ptr);
101}
102
103
104long
105MFXCheckableButton::onLeave(FXObject* sender, FXSelector sel, void* ptr) {
106 // hide static toolTip
108 return FXButton::onLeave(sender, sel, ptr);
109}
110
111
112long
113MFXCheckableButton::onMotion(FXObject* sender, FXSelector sel, void* ptr) {
114 // update static toolTip
115 myStaticToolTip->onUpdate(sender, sel, ptr);
116 return FXButton::onMotion(sender, sel, ptr);
117}
118
119
120void
122 myBackColor = backColor;
123 myDarkColor = makeShadowColor(myBackColor);
124 myHiliteColor = hiliteColor;
125 myShadowColor = shadowColor;
126 myAmInitialised = true;
127}
128
129
130void
132 options &= (0xffffffff - (FRAME_SUNKEN | FRAME_SUNKEN | FRAME_THICK));
133 if (myAmChecked) {
134 backColor = myShadowColor;
135 hiliteColor = myDarkColor;
136 shadowColor = myHiliteColor;
137 if (state == STATE_ENGAGED) {
138 options |= FRAME_SUNKEN | FRAME_THICK;
139 } else {
140 options |= FRAME_SUNKEN;
141 }
142 } else {
143 backColor = myBackColor;
144 hiliteColor = myHiliteColor;
145 shadowColor = myShadowColor;
146 if (state == STATE_ENGAGED) {
147 options |= FRAME_RAISED | FRAME_THICK;
148 } else {
149 options |= FRAME_RAISED;
150 }
151 }
152}
153
154/****************************************************************************/
FXDEFMAP(MFXCheckableButton) MFXCheckableButtonMap[]
void buildColors()
build color of this MFXCheckableButton
long onUpdate(FXObject *, FXSelector, void *)
called when this MFXCheckableButton is updated
FXColor myBackColor
colors of this MFXCheckableButton
void setColors()
set colors of this MFXCheckableButton
long onLeave(FXObject *, FXSelector, void *)
called when mouse leaves in MFXCheckableButton
bool amChecked() const
check if this MFXCheckableButton is checked
~MFXCheckableButton()
destructor (Called automatically)
long onPaint(FXObject *, FXSelector, void *)
bool myAmInitialised
check if this MFXCheckableButton is initialised
bool myAmChecked
FOX need this.
void setChecked(bool val, const bool inform=false)
check or uncheck this MFXCheckableButton
long onMotion(FXObject *, FXSelector, void *)
called when mouse motion in MFXCheckableButton
MFXStaticToolTip * myStaticToolTip
static tool tip
long onEnter(FXObject *, FXSelector, void *)
called when mouse enter in MFXCheckableButton
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
void hideStaticToolTip()
hide static toolTip
Definition json.hpp:4471