Eclipse SUMO - Simulation of Urban MObility
MFXCheckableButton.cpp
Go to the documentation of this file.
1/****************************************************************************/
2// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo
3// Copyright (C) 2004-2022 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 "MFXCheckableButton.h"
23
24
25FXDEFMAP(MFXCheckableButton) MFXCheckableButtonMap[] = {
26 FXMAPFUNC(SEL_PAINT, 0, MFXCheckableButton::onPaint),
27 FXMAPFUNC(SEL_UPDATE, 0, MFXCheckableButton::onUpdate),
28 FXMAPFUNC(SEL_ENTER, 0, MFXCheckableButton::onEnter),
29 FXMAPFUNC(SEL_LEAVE, 0, MFXCheckableButton::onLeave),
30 FXMAPFUNC(SEL_MOTION, 0, MFXCheckableButton::onMotion),
31};
32
33
34// Object implementation
35FXIMPLEMENT(MFXCheckableButton, FXButton, MFXCheckableButtonMap, ARRAYNUMBER(MFXCheckableButtonMap))
36
37MFXCheckableButton::MFXCheckableButton(bool amChecked, FXComposite* p, MFXStaticToolTip* staticToolTip,
38 const FXString& text, FXIcon* ic, FXObject* tgt, FXSelector sel,
39 FXuint opts, FXint x, FXint y, FXint w, FXint h,
40 FXint pl, FXint pr, FXint pt, FXint pb) :
41 FXButton(p, text, ic, tgt, sel, opts, x, y, w, h, pl, pr, pt, pb),
42 myAmChecked(amChecked), myAmInitialised(false),
43 myStaticToolTip(staticToolTip) {
44 border = 0;
45}
46
47
49
50
51bool
53 return myAmChecked;
54}
55
56
57void
59 myAmChecked = val;
60}
61
62
63long
64MFXCheckableButton::onPaint(FXObject* sender, FXSelector sel, void* ptr) {
65 if (!myAmInitialised) {
67 }
68 setColors();
69 return FXButton::onPaint(sender, sel, ptr);
70}
71
72
73long
74MFXCheckableButton::onUpdate(FXObject* sender, FXSelector sel, void* ptr) {
75 if (!myAmInitialised) {
77 }
78 setColors();
79 long ret = FXButton::onUpdate(sender, sel, ptr);
80 return ret;
81}
82
83
84long
85MFXCheckableButton::onEnter(FXObject* sender, FXSelector sel, void* ptr) {
86 // show tip show
88 return FXButton::onEnter(sender, sel, ptr);
89}
90
91
92long
93MFXCheckableButton::onLeave(FXObject* sender, FXSelector sel, void* ptr) {
94 // hide static toolTip
96 return FXButton::onLeave(sender, sel, ptr);
97}
98
99
100long
101MFXCheckableButton::onMotion(FXObject* sender, FXSelector sel, void* ptr) {
102 // update static toolTip
103 myStaticToolTip->onUpdate(sender, sel, ptr);
104 return FXButton::onMotion(sender, sel, ptr);
105}
106
107
108void
110 myBackColor = backColor;
111 myDarkColor = makeShadowColor(myBackColor);
112 myHiliteColor = hiliteColor;
113 myShadowColor = shadowColor;
114 myAmInitialised = true;
115}
116
117
118void
120 options &= (0xffffffff - (FRAME_SUNKEN | FRAME_SUNKEN | FRAME_THICK));
121 if (myAmChecked) {
122 backColor = myShadowColor;
123 hiliteColor = myDarkColor;
124 shadowColor = myHiliteColor;
125 if (state == STATE_ENGAGED) {
126 options |= FRAME_SUNKEN | FRAME_THICK;
127 } else {
128 options |= FRAME_SUNKEN;
129 }
130 } else {
131 backColor = myBackColor;
132 hiliteColor = myHiliteColor;
133 shadowColor = myShadowColor;
134 if (state == STATE_ENGAGED) {
135 options |= FRAME_RAISED | FRAME_THICK;
136 } else {
137 options |= FRAME_RAISED;
138 }
139 }
140}
141
142
143/****************************************************************************/
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.
long onMotion(FXObject *, FXSelector, void *)
called when mouse motion in MFXCheckableButton
void setChecked(bool val)
check or uncheck this 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