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-2019 German Aerospace Center (DLR) and others.
4 // This program and the accompanying materials
5 // are made available under the terms of the Eclipse Public License v2.0
6 // which accompanies this distribution, and is available at
7 // http://www.eclipse.org/legal/epl-v20.html
8 // SPDX-License-Identifier: EPL-2.0
9 /****************************************************************************/
14 // missing_desc
15 /****************************************************************************/
16 
17 
18 // ===========================================================================
19 // included modules
20 // ===========================================================================
21 #include <config.h>
22 
23 #include "MFXCheckableButton.h"
24 
25 
26 FXDEFMAP(MFXCheckableButton) MFXCheckableButtonMap[] = {
27  FXMAPFUNC(SEL_PAINT, 0, MFXCheckableButton::onPaint),
28  FXMAPFUNC(SEL_UPDATE, 0, MFXCheckableButton::onUpdate),
29 };
30 
31 
32 // Object implementation
33 FXIMPLEMENT(MFXCheckableButton, FXButton, MFXCheckableButtonMap, ARRAYNUMBER(MFXCheckableButtonMap))
34 
35 MFXCheckableButton::MFXCheckableButton(bool amChecked, FXComposite* p,
36  const FXString& text, FXIcon* ic,
37  FXObject* tgt, FXSelector sel,
38  FXuint opts,
39  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  border = 0;
44 }
45 
46 
48 
49 
50 bool
52  return myAmChecked;
53 }
54 
55 
56 void
58  myAmChecked = val;
59 }
60 
61 
62 long
63 MFXCheckableButton::onPaint(FXObject* sender, FXSelector sel, void* data) {
64  if (!myAmInitialised) {
65  buildColors();
66  }
67  setColors();
68  return FXButton::onPaint(sender, sel, data);
69 }
70 
71 
72 long
73 MFXCheckableButton::onUpdate(FXObject* sender, FXSelector sel, void* data) {
74  if (!myAmInitialised) {
75  buildColors();
76  }
77  setColors();
78  long ret = FXButton::onUpdate(sender, sel, data);
79  return ret;
80 }
81 
82 
83 void
85  myBackColor = backColor;
86  myDarkColor = makeShadowColor(myBackColor);
87  myHiliteColor = hiliteColor;
88  myShadowColor = shadowColor;
89  myAmInitialised = true;
90 }
91 
92 
93 void
95  options &= (0xffffffff - (FRAME_SUNKEN | FRAME_SUNKEN | FRAME_THICK));
96  if (myAmChecked) {
97  backColor = myShadowColor;
98  hiliteColor = myDarkColor;
99  shadowColor = myHiliteColor;
100  if (state == STATE_ENGAGED) {
101  options |= FRAME_SUNKEN | FRAME_THICK;
102  } else {
103  options |= FRAME_SUNKEN;
104  }
105  } else {
106  backColor = myBackColor;
107  hiliteColor = myHiliteColor;
108  shadowColor = myShadowColor;
109  if (state == STATE_ENGAGED) {
110  options |= FRAME_RAISED | FRAME_THICK;
111  } else {
112  options |= FRAME_RAISED;
113  }
114  }
115 }
116 
117 
118 
119 /****************************************************************************/
120 
MFXCheckableButton::buildColors
void buildColors()
build color of this MFXCheckableButton
Definition: MFXCheckableButton.cpp:84
MFXCheckableButton::onUpdate
long onUpdate(FXObject *, FXSelector, void *)
called when this MFXCheckableButton is updated
Definition: MFXCheckableButton.cpp:73
MFXCheckableButton::amChecked
bool amChecked() const
check if this MFXCheckableButton is checked
Definition: MFXCheckableButton.cpp:51
MFXCheckableButton::myAmChecked
bool myAmChecked
flag to indicate if this MFXCheckableButton is checked
Definition: MFXCheckableButton.h:72
MFXCheckableButton::setChecked
void setChecked(bool val)
check or uncheck this MFXCheckableButton
Definition: MFXCheckableButton.cpp:57
MFXCheckableButton::myHiliteColor
FXColor myHiliteColor
Definition: MFXCheckableButton.h:75
MFXCheckableButton::myDarkColor
FXColor myDarkColor
Definition: MFXCheckableButton.h:75
MFXCheckableButton::myAmInitialised
bool myAmInitialised
check if this MFXCheckableButton is initialised
Definition: MFXCheckableButton.h:81
MFXCheckableButton::~MFXCheckableButton
~MFXCheckableButton()
destructor (Called automatically)
Definition: MFXCheckableButton.cpp:47
MFXCheckableButton::setColors
void setColors()
set colors of this MFXCheckableButton
Definition: MFXCheckableButton.cpp:94
MFXCheckableButton::myBackColor
FXColor myBackColor
colors of this MFXCheckableButton
Definition: MFXCheckableButton.h:75
MFXCheckableButton
Definition: MFXCheckableButton.h:30
config.h
MFXCheckableButton::onPaint
long onPaint(FXObject *, FXSelector, void *)
Definition: MFXCheckableButton.cpp:63
MFXCheckableButton::myShadowColor
FXColor myShadowColor
Definition: MFXCheckableButton.h:75
FXDEFMAP
FXDEFMAP(MFXCheckableButton) MFXCheckableButtonMap[]
MFXCheckableButton.h