![]() |
Main Page Class Hierarchy Alphabetical List Compound List File List Compound Members
![]() |
00001 /******************************************************************************** 00002 * * 00003 * T o g g l e 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: FXToggleButton.h,v 1.19 2002/01/18 22:42:55 jeroen Exp $ * 00023 ********************************************************************************/ 00024 #ifndef FXTOGGLEBUTTON_H 00025 #define FXTOGGLEBUTTON_H 00026 00027 #ifndef FXLABEL_H 00028 #include "FXLabel.h" 00029 #endif 00030 00031 00032 00033 /// Toggle button flags 00034 enum { 00035 TOGGLEBUTTON_AUTOGRAY = 0x00800000, /// Automatically gray out when not updated 00036 TOGGLEBUTTON_AUTOHIDE = 0x01000000, /// Automatically hide toggle button when not updated 00037 TOGGLEBUTTON_TOOLBAR = 0x02000000, /// Toolbar style toggle button [flat look] 00038 TOGGLEBUTTON_NORMAL = FRAME_RAISED|FRAME_THICK|JUSTIFY_NORMAL|ICON_BEFORE_TEXT 00039 }; 00040 00041 00042 /** 00043 * The toggle button provides a two-state button, which toggles between the 00044 * on and the off state each time it is pressed. For each state, the toggle 00045 * button has a unique icon and text label. 00046 * When pressed, the button widget sends a SEL_COMMAND to its target, with the 00047 * message data set to the current state of the toggle button, of the type FXbool. 00048 */ 00049 class FXAPI FXToggleButton : public FXLabel { 00050 FXDECLARE(FXToggleButton) 00051 protected: 00052 FXString altlabel; 00053 FXIcon *alticon; 00054 FXHotKey althotkey; 00055 FXint althotoff; 00056 FXString alttip; 00057 FXString althelp; 00058 FXbool state; 00059 FXbool down; 00060 protected: 00061 FXToggleButton(); 00062 void press(FXbool dn); 00063 private: 00064 FXToggleButton(const FXToggleButton&); 00065 FXToggleButton& operator=(const FXToggleButton&); 00066 public: 00067 long onPaint(FXObject*,FXSelector,void*); 00068 long onUpdate(FXObject*,FXSelector,void*); 00069 long onEnter(FXObject*,FXSelector,void*); 00070 long onLeave(FXObject*,FXSelector,void*); 00071 long onFocusIn(FXObject*,FXSelector,void*); 00072 long onFocusOut(FXObject*,FXSelector,void*); 00073 long onUngrabbed(FXObject*,FXSelector,void*); 00074 long onLeftBtnPress(FXObject*,FXSelector,void*); 00075 long onLeftBtnRelease(FXObject*,FXSelector,void*); 00076 long onKeyPress(FXObject*,FXSelector,void*); 00077 long onKeyRelease(FXObject*,FXSelector,void*); 00078 long onHotKeyPress(FXObject*,FXSelector,void*); 00079 long onHotKeyRelease(FXObject*,FXSelector,void*); 00080 long onCheck(FXObject*,FXSelector,void*); 00081 long onUncheck(FXObject*,FXSelector,void*); 00082 long onQueryHelp(FXObject*,FXSelector,void*); 00083 long onQueryTip(FXObject*,FXSelector,void*); 00084 long onCmdSetValue(FXObject*,FXSelector,void*); 00085 long onCmdSetIntValue(FXObject*,FXSelector,void*); 00086 long onCmdGetIntValue(FXObject*,FXSelector,void*); 00087 public: 00088 00089 /// Construct toggle button with two text labels, and two icons, one for each state 00090 FXToggleButton(FXComposite* p,const FXString& text1,const FXString& text2,FXIcon* icon1=NULL,FXIcon* icon2=NULL,FXObject* tgt=NULL,FXSelector sel=0,FXuint opts=TOGGLEBUTTON_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); 00091 00092 /// Create server-side resources 00093 virtual void create(); 00094 00095 /// Detach server-side resources 00096 virtual void detach(); 00097 00098 /// Returns true because a toggle button can receive focus 00099 virtual FXbool canFocus() const; 00100 00101 /// Get default width 00102 virtual FXint getDefaultWidth(); 00103 00104 /// Get default height 00105 virtual FXint getDefaultHeight(); 00106 00107 /// Change alternate text shown when toggled 00108 void setAltText(const FXString& text); 00109 00110 /// Return alternate text 00111 FXString getAltText() const { return altlabel; } 00112 00113 /// Change alternate icon shown when toggled 00114 void setAltIcon(FXIcon* ic); 00115 00116 /// Return alternate icon 00117 FXIcon* getAltIcon() const { return alticon; } 00118 00119 /// Change toggled state 00120 void setState(FXbool s=TRUE); 00121 00122 /// return toggled state 00123 FXbool getState() const { return state; } 00124 00125 /// Change alternate help text shown when toggled 00126 void setAltHelpText(const FXString& text); 00127 00128 /// Return alternate help text 00129 FXString getAltHelpText() const { return althelp; } 00130 00131 /// Change alternate tip text shown when toggled 00132 void setAltTipText(const FXString& text); 00133 00134 /// Return alternate tip text 00135 FXString getAltTipText() const { return alttip; } 00136 00137 /// Set the toggle button style flags 00138 void setToggleStyle(FXuint style); 00139 00140 /// Get the toggle button style flags 00141 FXuint getToggleStyle() const; 00142 00143 /// Save toggle button to a stream 00144 virtual void save(FXStream& store) const; 00145 00146 /// Load toggle button from a stream 00147 virtual void load(FXStream& store); 00148 00149 /// Destructor 00150 virtual ~FXToggleButton(); 00151 }; 00152 00153 00154 #endif