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-2020 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 
25 FXDEFMAP(MFXCheckableButton) MFXCheckableButtonMap[] = {
26  FXMAPFUNC(SEL_PAINT, 0, MFXCheckableButton::onPaint),
27  FXMAPFUNC(SEL_UPDATE, 0, MFXCheckableButton::onUpdate),
28 };
29 
30 
31 // Object implementation
32 FXIMPLEMENT(MFXCheckableButton, FXButton, MFXCheckableButtonMap, ARRAYNUMBER(MFXCheckableButtonMap))
33 
34 MFXCheckableButton::MFXCheckableButton(bool amChecked, FXComposite* p,
35  const FXString& text, FXIcon* ic,
36  FXObject* tgt, FXSelector sel,
37  FXuint opts,
38  FXint x, FXint y, FXint w, FXint h,
39  FXint pl, FXint pr, FXint pt, FXint pb) :
40  FXButton(p, text, ic, tgt, sel, opts, x, y, w, h, pl, pr, pt, pb),
41  myAmChecked(amChecked), myAmInitialised(false) {
42  border = 0;
43 }
44 
45 
47 
48 
49 bool
51  return myAmChecked;
52 }
53 
54 
55 void
57  myAmChecked = val;
58 }
59 
60 
61 long
62 MFXCheckableButton::onPaint(FXObject* sender, FXSelector sel, void* data) {
63  if (!myAmInitialised) {
64  buildColors();
65  }
66  setColors();
67  return FXButton::onPaint(sender, sel, data);
68 }
69 
70 
71 long
72 MFXCheckableButton::onUpdate(FXObject* sender, FXSelector sel, void* data) {
73  if (!myAmInitialised) {
74  buildColors();
75  }
76  setColors();
77  long ret = FXButton::onUpdate(sender, sel, data);
78  return ret;
79 }
80 
81 
82 void
84  myBackColor = backColor;
85  myDarkColor = makeShadowColor(myBackColor);
86  myHiliteColor = hiliteColor;
87  myShadowColor = shadowColor;
88  myAmInitialised = true;
89 }
90 
91 
92 void
94  options &= (0xffffffff - (FRAME_SUNKEN | FRAME_SUNKEN | FRAME_THICK));
95  if (myAmChecked) {
96  backColor = myShadowColor;
97  hiliteColor = myDarkColor;
98  shadowColor = myHiliteColor;
99  if (state == STATE_ENGAGED) {
100  options |= FRAME_SUNKEN | FRAME_THICK;
101  } else {
102  options |= FRAME_SUNKEN;
103  }
104  } else {
105  backColor = myBackColor;
106  hiliteColor = myHiliteColor;
107  shadowColor = myShadowColor;
108  if (state == STATE_ENGAGED) {
109  options |= FRAME_RAISED | FRAME_THICK;
110  } else {
111  options |= FRAME_RAISED;
112  }
113  }
114 }
115 
116 
117 /****************************************************************************/
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
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
flag to indicate if this MFXCheckableButton is checked
void setChecked(bool val)
check or uncheck this MFXCheckableButton