![]() |
Main Page Class Hierarchy Alphabetical List Compound List File List Compound Members
![]() |
00001 /******************************************************************************** 00002 * * 00003 * C h e c k B u t t o n W i d g e t * 00004 * * 00005 ********************************************************************************* 00006 * Copyright (C) 1998,2009 by Jeroen van der Zijp. All Rights Reserved. * 00007 ********************************************************************************* 00008 * This library is free software; you can redistribute it and/or modify * 00009 * it under the terms of the GNU Lesser General Public License as published by * 00010 * the Free Software Foundation; either version 3 of the License, or * 00011 * (at your option) any later version. * 00012 * * 00013 * This library is distributed in the hope that it will be useful, * 00014 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 00015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 00016 * GNU Lesser General Public License for more details. * 00017 * * 00018 * You should have received a copy of the GNU Lesser General Public License * 00019 * along with this program. If not, see <http://www.gnu.org/licenses/> * 00020 ********************************************************************************* 00021 * $Id: FXCheckButton.h,v 1.39 2009/01/06 13:07:22 fox Exp $ * 00022 ********************************************************************************/ 00023 #ifndef FXCHECKBUTTON_H 00024 #define FXCHECKBUTTON_H 00025 00026 #ifndef FXLABEL_H 00027 #include "FXLabel.h" 00028 #endif 00029 00030 namespace FX { 00031 00032 00033 /// CheckButton styles 00034 enum { 00035 CHECKBUTTON_AUTOGRAY = 0x00800000, /// Automatically gray out when not updated 00036 CHECKBUTTON_AUTOHIDE = 0x01000000, /// Automatically hide when not updated 00037 CHECKBUTTON_PLUS = 0x02000000, /// Draw a + for unchecked and - for checked 00038 CHECKBUTTON_NORMAL = JUSTIFY_NORMAL|ICON_BEFORE_TEXT 00039 }; 00040 00041 00042 /** 00043 * A Check Button is a tri-state button. Normally, it is either 00044 * TRUE or FALSE, and toggles between TRUE or FALSE whenever it is pressed. 00045 * A third state MAYBE may be set to indicate that no selection has been made yet 00046 * by the user, or that the state is ambiguous. 00047 * When pressed, the Check Button sends a SEL_COMMAND to its target, and the 00048 * message data represents the state of the check button. 00049 * The option CHECKBUTTON_AUTOGRAY (CHECKBUTTON_AUTOHIDE) causes the button to be 00050 * grayed out (hidden) if its handler does not respond to the SEL_UPDATE message. 00051 * With the CHECKBUTTON_PLUS option, the Check Button will draw a + or - sign instead 00052 * of a check. You can use this to make collapsable panels, by hooking up a Check 00053 * Button to a layout manager via the ID_TOGGLE_SHOWN message. This will give a 00054 * similar visual element as collapsing folders in a Tree List. 00055 */ 00056 class FXAPI FXCheckButton : public FXLabel { 00057 FXDECLARE(FXCheckButton) 00058 protected: 00059 FXColor checkColor; // Color of check mark 00060 FXColor boxColor; // Color of check box 00061 FXuchar check; // Check state 00062 FXuchar oldcheck; // Old check state 00063 protected: 00064 FXCheckButton(); 00065 private: 00066 FXCheckButton(const FXCheckButton&); 00067 FXCheckButton &operator=(const FXCheckButton&); 00068 public: 00069 long onPaint(FXObject*,FXSelector,void*); 00070 long onUpdate(FXObject*,FXSelector,void*); 00071 long onEnter(FXObject*,FXSelector,void*); 00072 long onLeave(FXObject*,FXSelector,void*); 00073 long onFocusIn(FXObject*,FXSelector,void*); 00074 long onFocusOut(FXObject*,FXSelector,void*); 00075 long onUngrabbed(FXObject*,FXSelector,void*); 00076 long onLeftBtnPress(FXObject*,FXSelector,void*); 00077 long onLeftBtnRelease(FXObject*,FXSelector,void*); 00078 long onKeyPress(FXObject*,FXSelector,void*); 00079 long onKeyRelease(FXObject*,FXSelector,void*); 00080 long onHotKeyPress(FXObject*,FXSelector,void*); 00081 long onHotKeyRelease(FXObject*,FXSelector,void*); 00082 long onCheck(FXObject*,FXSelector,void*); 00083 long onUncheck(FXObject*,FXSelector,void*); 00084 long onUnknown(FXObject*,FXSelector,void*); 00085 long onCmdSetValue(FXObject*,FXSelector,void*); 00086 long onCmdSetIntValue(FXObject*,FXSelector,void*); 00087 long onCmdGetIntValue(FXObject*,FXSelector,void*); 00088 public: 00089 00090 /// Construct new check button 00091 FXCheckButton(FXComposite* p,const FXString& text,FXObject* tgt=NULL,FXSelector sel=0,FXuint opts=CHECKBUTTON_NORMAL,FXint x=0,FXint y=0,FXint w=0,FXint h=0,FXint pl=DEFAULT_PAD,FXint pr=DEFAULT_PAD,FXint pt=DEFAULT_PAD,FXint pb=DEFAULT_PAD); 00092 00093 /// Returns true because a check button can receive focus 00094 virtual FXbool canFocus() const; 00095 00096 /// Get default width 00097 virtual FXint getDefaultWidth(); 00098 00099 /// Get default height 00100 virtual FXint getDefaultHeight(); 00101 00102 /// Set check button state (TRUE, FALSE or MAYBE) 00103 void setCheck(FXuchar state=TRUE,FXbool notify=false); 00104 00105 /// Get check button state (TRUE, FALSE or MAYBE) 00106 FXuchar getCheck() const { return check; } 00107 00108 /// Change check button style 00109 void setCheckButtonStyle(FXuint style); 00110 00111 /// Return current check button style 00112 FXuint getCheckButtonStyle() const; 00113 00114 /// Get the box background color 00115 FXColor getBoxColor() const { return boxColor; } 00116 00117 /// Set the box background color 00118 void setBoxColor(FXColor clr); 00119 00120 /// Get the box check color 00121 FXColor getCheckColor() const { return checkColor; } 00122 00123 /// Set the box check color 00124 void setCheckColor(FXColor clr); 00125 00126 /// Save check button to a stream 00127 virtual void save(FXStream& store) const; 00128 00129 /// Load check button from a stream 00130 virtual void load(FXStream& store); 00131 }; 00132 00133 } 00134 00135 #endif
![]() |