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

Generated on Wed May 5 00:06:30 2010 for Sumo - Simulation of Urban MObility by  doxygen 1.5.6