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-2018 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 /****************************************************************************/
15 // missing_desc
16 /****************************************************************************/
17 
18 
19 // ===========================================================================
20 // included modules
21 // ===========================================================================
22 #include <config.h>
23 
24 #include "MFXCheckableButton.h"
25 
26 
27 FXDEFMAP(MFXCheckableButton) MFXCheckableButtonMap[] = {
28  FXMAPFUNC(SEL_PAINT, 0, MFXCheckableButton::onPaint),
29  FXMAPFUNC(SEL_UPDATE, 0, MFXCheckableButton::onUpdate),
30 };
31 
32 
33 // Object implementation
34 FXIMPLEMENT(MFXCheckableButton, FXButton, MFXCheckableButtonMap, ARRAYNUMBER(MFXCheckableButtonMap))
35 
36 MFXCheckableButton::MFXCheckableButton(bool amChecked, FXComposite* p,
37  const FXString& text, FXIcon* ic,
38  FXObject* tgt, FXSelector sel,
39  FXuint opts,
40  FXint x, FXint y, FXint w, FXint h,
41  FXint pl, FXint pr, FXint pt, FXint pb)
42  : FXButton(p, text, ic, tgt, sel, opts, x, y, w, h, pl, pr, pt, pb),
43  myAmChecked(amChecked), myAmInitialised(false) {
44  border = 0;
45 }
46 
47 
49 
50 
51 bool
53  return myAmChecked;
54 }
55 
56 
57 void
59  myAmChecked = val;
60 }
61 
62 
63 long
64 MFXCheckableButton::onPaint(FXObject* sender, FXSelector sel, void* data) {
65  if (!myAmInitialised) {
66  buildColors();
67  }
68  setColors();
69  return FXButton::onPaint(sender, sel, data);
70 }
71 
72 
73 long
74 MFXCheckableButton::onUpdate(FXObject* sender, FXSelector sel, void* data) {
75  if (!myAmInitialised) {
76  buildColors();
77  }
78  setColors();
79  long ret = FXButton::onUpdate(sender, sel, data);
80  return ret;
81 }
82 
83 
84 void
86  myBackColor = backColor;
87  myDarkColor = makeShadowColor(myBackColor);
88  myHiliteColor = hiliteColor;
89  myShadowColor = shadowColor;
90  myAmInitialised = true;
91 }
92 
93 
94 void
96  options &= (0xffffffff - (FRAME_SUNKEN | FRAME_SUNKEN | FRAME_THICK));
97  if (myAmChecked) {
98  backColor = myShadowColor;
99  hiliteColor = myDarkColor;
100  shadowColor = myHiliteColor;
101  if (state == STATE_ENGAGED) {
102  options |= FRAME_SUNKEN | FRAME_THICK;
103  } else {
104  options |= FRAME_SUNKEN;
105  }
106  } else {
107  backColor = myBackColor;
108  hiliteColor = myHiliteColor;
109  shadowColor = myShadowColor;
110  if (state == STATE_ENGAGED) {
111  options |= FRAME_RAISED | FRAME_THICK;
112  } else {
113  options |= FRAME_RAISED;
114  }
115  }
116 }
117 
118 
119 
120 /****************************************************************************/
121 
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