SUMO - Simulation of Urban MObility
MFXCheckableButton.cpp
Go to the documentation of this file.
00001 /****************************************************************************/
00007 // missing_desc
00008 /****************************************************************************/
00009 // SUMO, Simulation of Urban MObility; see http://sumo.sourceforge.net/
00010 // Copyright (C) 2001-2012 DLR (http://www.dlr.de/) and contributors
00011 /****************************************************************************/
00012 //
00013 //   This file is part of SUMO.
00014 //   SUMO is free software: you can redistribute it and/or modify
00015 //   it under the terms of the GNU General Public License as published by
00016 //   the Free Software Foundation, either version 3 of the License, or
00017 //   (at your option) any later version.
00018 //
00019 /****************************************************************************/
00020 
00021 
00022 // ===========================================================================
00023 // included modules
00024 // ===========================================================================
00025 #ifdef _MSC_VER
00026 #include <windows_config.h>
00027 #else
00028 #include <config.h>
00029 #endif
00030 
00031 #include "MFXCheckableButton.h"
00032 
00033 #ifdef CHECK_MEMORY_LEAKS
00034 #include <foreign/nvwa/debug_new.h>
00035 #endif // CHECK_MEMORY_LEAKS
00036 
00037 
00038 FXDEFMAP(MFXCheckableButton) MFXCheckableButtonMap[] = {
00039     FXMAPFUNC(SEL_PAINT, 0, MFXCheckableButton::onPaint),
00040     FXMAPFUNC(SEL_UPDATE, 0, MFXCheckableButton::onUpdate),
00041 };
00042 
00043 
00044 // Object implementation
00045 FXIMPLEMENT(MFXCheckableButton, FXButton, MFXCheckableButtonMap, ARRAYNUMBER(MFXCheckableButtonMap))
00046 
00047 MFXCheckableButton::MFXCheckableButton(bool amChecked, FXComposite* p,
00048                                        const FXString& text, FXIcon* ic,
00049                                        FXObject* tgt, FXSelector sel,
00050                                        FXuint opts,
00051                                        FXint x, FXint y, FXint w, FXint h,
00052                                        FXint pl, FXint pr, FXint pt, FXint pb)
00053     : FXButton(p, text, ic, tgt, sel, opts, x, y, w, h, pl, pr, pt, pb),
00054       myAmChecked(amChecked), myAmInitialised(false) {
00055     border = 0;
00056 }
00057 
00058 
00059 MFXCheckableButton::~MFXCheckableButton() {}
00060 
00061 
00062 bool
00063 MFXCheckableButton::amChecked() const {
00064     return myAmChecked;
00065 }
00066 
00067 
00068 void
00069 MFXCheckableButton::setChecked(bool val) {
00070     myAmChecked = val;
00071 }
00072 
00073 
00074 long
00075 MFXCheckableButton::onPaint(FXObject* sender, FXSelector sel, void* data) {
00076     if (!myAmInitialised) {
00077         buildColors();
00078     }
00079     setColors();
00080     return FXButton::onPaint(sender, sel, data);
00081 }
00082 
00083 
00084 long
00085 MFXCheckableButton::onUpdate(FXObject* sender, FXSelector sel, void* data) {
00086     if (!myAmInitialised) {
00087         buildColors();
00088     }
00089     setColors();
00090     long ret = FXButton::onUpdate(sender, sel, data);
00091     return ret;
00092 }
00093 
00094 
00095 void
00096 MFXCheckableButton::buildColors() {
00097     myBackColor = backColor;
00098     myDarkColor = makeShadowColor(myBackColor);
00099     myHiliteColor = hiliteColor;
00100     myShadowColor = shadowColor;
00101     myAmInitialised = true;
00102 }
00103 
00104 
00105 void
00106 MFXCheckableButton::setColors() {
00107     options &= (0xffffffff - (FRAME_SUNKEN | FRAME_SUNKEN | FRAME_THICK));
00108     if (myAmChecked) {
00109         backColor = myShadowColor;
00110         hiliteColor = myDarkColor;
00111         shadowColor = myHiliteColor;
00112         if (state == STATE_ENGAGED) {
00113             options |= FRAME_SUNKEN | FRAME_THICK;
00114         } else {
00115             options |= FRAME_SUNKEN;
00116         }
00117     } else {
00118         backColor = myBackColor;
00119         hiliteColor = myHiliteColor;
00120         shadowColor = myShadowColor;
00121         if (state == STATE_ENGAGED) {
00122             options |= FRAME_RAISED | FRAME_THICK;
00123         } else {
00124             options |= FRAME_RAISED;
00125         }
00126     }
00127 }
00128 
00129 
00130 
00131 /****************************************************************************/
00132 
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Friends Defines