SUMO - Simulation of Urban MObility
MFXCheckableButton.cpp
Go to the documentation of this file.
1 /****************************************************************************/
7 // missing_desc
8 /****************************************************************************/
9 // SUMO, Simulation of Urban MObility; see http://sumo.dlr.de/
10 // Copyright (C) 2004-2017 DLR (http://www.dlr.de/) and contributors
11 /****************************************************************************/
12 //
13 // This file is part of SUMO.
14 // SUMO is free software: you can redistribute it and/or modify
15 // it under the terms of the GNU General Public License as published by
16 // the Free Software Foundation, either version 3 of the License, or
17 // (at your option) any later version.
18 //
19 /****************************************************************************/
20 
21 
22 // ===========================================================================
23 // included modules
24 // ===========================================================================
25 #ifdef _MSC_VER
26 #include <windows_config.h>
27 #else
28 #include <config.h>
29 #endif
30 
31 #include "MFXCheckableButton.h"
32 
33 
34 FXDEFMAP(MFXCheckableButton) MFXCheckableButtonMap[] = {
35  FXMAPFUNC(SEL_PAINT, 0, MFXCheckableButton::onPaint),
36  FXMAPFUNC(SEL_UPDATE, 0, MFXCheckableButton::onUpdate),
37 };
38 
39 
40 // Object implementation
41 FXIMPLEMENT(MFXCheckableButton, FXButton, MFXCheckableButtonMap, ARRAYNUMBER(MFXCheckableButtonMap))
42 
43 MFXCheckableButton::MFXCheckableButton(bool amChecked, FXComposite* p,
44  const FXString& text, FXIcon* ic,
45  FXObject* tgt, FXSelector sel,
46  FXuint opts,
47  FXint x, FXint y, FXint w, FXint h,
48  FXint pl, FXint pr, FXint pt, FXint pb)
49  : FXButton(p, text, ic, tgt, sel, opts, x, y, w, h, pl, pr, pt, pb),
50  myAmChecked(amChecked), myAmInitialised(false) {
51  border = 0;
52 }
53 
54 
56 
57 
58 bool
60  return myAmChecked;
61 }
62 
63 
64 void
66  myAmChecked = val;
67 }
68 
69 
70 long
71 MFXCheckableButton::onPaint(FXObject* sender, FXSelector sel, void* data) {
72  if (!myAmInitialised) {
73  buildColors();
74  }
75  setColors();
76  return FXButton::onPaint(sender, sel, data);
77 }
78 
79 
80 long
81 MFXCheckableButton::onUpdate(FXObject* sender, FXSelector sel, void* data) {
82  if (!myAmInitialised) {
83  buildColors();
84  }
85  setColors();
86  long ret = FXButton::onUpdate(sender, sel, data);
87  return ret;
88 }
89 
90 
91 void
93  myBackColor = backColor;
94  myDarkColor = makeShadowColor(myBackColor);
95  myHiliteColor = hiliteColor;
96  myShadowColor = shadowColor;
97  myAmInitialised = true;
98 }
99 
100 
101 void
103  options &= (0xffffffff - (FRAME_SUNKEN | FRAME_SUNKEN | FRAME_THICK));
104  if (myAmChecked) {
105  backColor = myShadowColor;
106  hiliteColor = myDarkColor;
107  shadowColor = myHiliteColor;
108  if (state == STATE_ENGAGED) {
109  options |= FRAME_SUNKEN | FRAME_THICK;
110  } else {
111  options |= FRAME_SUNKEN;
112  }
113  } else {
114  backColor = myBackColor;
115  hiliteColor = myHiliteColor;
116  shadowColor = myShadowColor;
117  if (state == STATE_ENGAGED) {
118  options |= FRAME_RAISED | FRAME_THICK;
119  } else {
120  options |= FRAME_RAISED;
121  }
122  }
123 }
124 
125 
126 
127 /****************************************************************************/
128 
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