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-sim.org/
10 // Copyright (C) 2004-2014 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 #ifdef CHECK_MEMORY_LEAKS
34 #include <foreign/nvwa/debug_new.h>
35 #endif // CHECK_MEMORY_LEAKS
36 
37 
38 FXDEFMAP(MFXCheckableButton) MFXCheckableButtonMap[] = {
39  FXMAPFUNC(SEL_PAINT, 0, MFXCheckableButton::onPaint),
40  FXMAPFUNC(SEL_UPDATE, 0, MFXCheckableButton::onUpdate),
41 };
42 
43 
44 // Object implementation
45 FXIMPLEMENT(MFXCheckableButton, FXButton, MFXCheckableButtonMap, ARRAYNUMBER(MFXCheckableButtonMap))
46 
47 MFXCheckableButton::MFXCheckableButton(bool amChecked, FXComposite* p,
48  const FXString& text, FXIcon* ic,
49  FXObject* tgt, FXSelector sel,
50  FXuint opts,
51  FXint x, FXint y, FXint w, FXint h,
52  FXint pl, FXint pr, FXint pt, FXint pb)
53  : FXButton(p, text, ic, tgt, sel, opts, x, y, w, h, pl, pr, pt, pb),
54  myAmChecked(amChecked), myAmInitialised(false) {
55  border = 0;
56 }
57 
58 
60 
61 
62 bool
64  return myAmChecked;
65 }
66 
67 
68 void
70  myAmChecked = val;
71 }
72 
73 
74 long
75 MFXCheckableButton::onPaint(FXObject* sender, FXSelector sel, void* data) {
76  if (!myAmInitialised) {
77  buildColors();
78  }
79  setColors();
80  return FXButton::onPaint(sender, sel, data);
81 }
82 
83 
84 long
85 MFXCheckableButton::onUpdate(FXObject* sender, FXSelector sel, void* data) {
86  if (!myAmInitialised) {
87  buildColors();
88  }
89  setColors();
90  long ret = FXButton::onUpdate(sender, sel, data);
91  return ret;
92 }
93 
94 
95 void
97  myBackColor = backColor;
98  myDarkColor = makeShadowColor(myBackColor);
99  myHiliteColor = hiliteColor;
100  myShadowColor = shadowColor;
101  myAmInitialised = true;
102 }
103 
104 
105 void
107  options &= (0xffffffff - (FRAME_SUNKEN | FRAME_SUNKEN | FRAME_THICK));
108  if (myAmChecked) {
109  backColor = myShadowColor;
110  hiliteColor = myDarkColor;
111  shadowColor = myHiliteColor;
112  if (state == STATE_ENGAGED) {
113  options |= FRAME_SUNKEN | FRAME_THICK;
114  } else {
115  options |= FRAME_SUNKEN;
116  }
117  } else {
118  backColor = myBackColor;
119  hiliteColor = myHiliteColor;
120  shadowColor = myShadowColor;
121  if (state == STATE_ENGAGED) {
122  options |= FRAME_RAISED | FRAME_THICK;
123  } else {
124  options |= FRAME_RAISED;
125  }
126  }
127 }
128 
129 
130 
131 /****************************************************************************/
132 
long onUpdate(FXObject *, FXSelector, void *)
void setChecked(bool val)
long onPaint(FXObject *, FXSelector, void *)
FXDEFMAP(MFXCheckableButton) MFXCheckableButtonMap[]