![]() |
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,2002 by Jeroen van der Zijp. All Rights Reserved. * 00007 ********************************************************************************* 00008 * This library is free software; you can redistribute it and/or * 00009 * modify it under the terms of the GNU Lesser General Public * 00010 * License as published by the Free Software Foundation; either * 00011 * version 2.1 of the License, or (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 GNU * 00016 * Lesser General Public License for more details. * 00017 * * 00018 * You should have received a copy of the GNU Lesser General Public * 00019 * License along with this library; if not, write to the Free Software * 00020 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * 00021 ********************************************************************************* 00022 * $Id: FXCheckButton.h,v 1.22 2002/03/12 07:11:30 fox Exp $ * 00023 ********************************************************************************/ 00024 #ifndef FXCHECKBUTTON_H 00025 #define FXCHECKBUTTON_H 00026 00027 #ifndef FXLABEL_H 00028 #include "FXLabel.h" 00029 #endif 00030 00031 namespace FX { 00032 00033 00034 /// CheckButton styles 00035 enum { 00036 CHECKBUTTON_AUTOGRAY = 0x00800000, /// Automatically gray out when not updated 00037 CHECKBUTTON_AUTOHIDE = 0x01000000, /// Automatically hide when not updated 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 */ 00050 class FXAPI FXCheckButton : public FXLabel { 00051 FXDECLARE(FXCheckButton) 00052 protected: 00053 FXbool check; 00054 FXbool oldcheck; 00055 FXColor boxColor; 00056 protected: 00057 FXCheckButton(); 00058 private: 00059 FXCheckButton(const FXCheckButton&); 00060 FXCheckButton &operator=(const FXCheckButton&); 00061 public: 00062 long onPaint(FXObject*,FXSelector,void*); 00063 long onUpdate(FXObject*,FXSelector,void*); 00064 long onEnter(FXObject*,FXSelector,void*); 00065 long onLeave(FXObject*,FXSelector,void*); 00066 long onFocusIn(FXObject*,FXSelector,void*); 00067 long onFocusOut(FXObject*,FXSelector,void*); 00068 long onUngrabbed(FXObject*,FXSelector,void*); 00069 long onLeftBtnPress(FXObject*,FXSelector,void*); 00070 long onLeftBtnRelease(FXObject*,FXSelector,void*); 00071 long onKeyPress(FXObject*,FXSelector,void*); 00072 long onKeyRelease(FXObject*,FXSelector,void*); 00073 long onHotKeyPress(FXObject*,FXSelector,void*); 00074 long onHotKeyRelease(FXObject*,FXSelector,void*); 00075 long onCheck(FXObject*,FXSelector,void*); 00076 long onUncheck(FXObject*,FXSelector,void*); 00077 long onUnknown(FXObject*,FXSelector,void*); 00078 long onCmdSetValue(FXObject*,FXSelector,void*); 00079 long onCmdSetIntValue(FXObject*,FXSelector,void*); 00080 long onCmdGetIntValue(FXObject*,FXSelector,void*); 00081 public: 00082 00083 /// Construct new check button 00084 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); 00085 00086 /// Returns true because a check button can receive focus 00087 virtual FXbool canFocus() const; 00088 00089 /// Get default width 00090 virtual FXint getDefaultWidth(); 00091 00092 /// Get default height 00093 virtual FXint getDefaultHeight(); 00094 00095 /// Set check button state (TRUE, FALSE or MAYBE) 00096 void setCheck(FXbool state=TRUE); 00097 00098 /// Get check button state (TRUE, FALSE or MAYBE) 00099 FXbool getCheck() const { return check; } 00100 00101 /// Change check button style 00102 void setCheckButtonStyle(FXuint style); 00103 00104 /// Return current check button style 00105 FXuint getCheckButtonStyle() const; 00106 00107 /// Get the box background color 00108 FXColor getBoxColor() const { return boxColor; } 00109 00110 /// Set the box background color 00111 void setBoxColor(FXColor clr); 00112 00113 /// Save check button to a stream 00114 virtual void save(FXStream& store) const; 00115 00116 /// Load check button from a stream 00117 virtual void load(FXStream& store); 00118 }; 00119 00120 } 00121 00122 #endif