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