Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members

FXToggleButton.h

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,2004 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.26 2004/02/08 17:17:34 fox Exp $ * 00023 ********************************************************************************/ 00024 #ifndef FXTOGGLEBUTTON_H 00025 #define FXTOGGLEBUTTON_H 00026 00027 #ifndef FXLABEL_H 00028 #include "FXLabel.h" 00029 #endif 00030 00031 namespace FX { 00032 00033 00034 /// Toggle button flags 00035 enum { 00036 TOGGLEBUTTON_AUTOGRAY = 0x00800000, /// Automatically gray out when not updated 00037 TOGGLEBUTTON_AUTOHIDE = 0x01000000, /// Automatically hide toggle button when not updated 00038 TOGGLEBUTTON_TOOLBAR = 0x02000000, /// Toolbar style toggle button [flat look] 00039 TOGGLEBUTTON_KEEPSTATE= 0x04000000, /// Draw button according to state 00040 TOGGLEBUTTON_NORMAL = FRAME_RAISED|FRAME_THICK|JUSTIFY_NORMAL|ICON_BEFORE_TEXT 00041 }; 00042 00043 00044 /** 00045 * The toggle button provides a two-state button, which toggles between the 00046 * on and the off state each time it is pressed. For each state, the toggle 00047 * button has a unique icon and text label. 00048 * When pressed, the button widget sends a SEL_COMMAND to its target, with the 00049 * message data set to the current state of the toggle button, of the type FXbool. 00050 */ 00051 class FXAPI FXToggleButton : public FXLabel { 00052 FXDECLARE(FXToggleButton) 00053 protected: 00054 FXString altlabel; 00055 FXIcon *alticon; 00056 FXHotKey althotkey; 00057 FXint althotoff; 00058 FXString alttip; 00059 FXString althelp; 00060 FXbool state; 00061 FXbool down; 00062 protected: 00063 FXToggleButton(); 00064 void press(FXbool dn); 00065 private: 00066 FXToggleButton(const FXToggleButton&); 00067 FXToggleButton& operator=(const FXToggleButton&); 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 onQueryHelp(FXObject*,FXSelector,void*); 00085 long onQueryTip(FXObject*,FXSelector,void*); 00086 long onCmdSetValue(FXObject*,FXSelector,void*); 00087 long onCmdSetIntValue(FXObject*,FXSelector,void*); 00088 long onCmdGetIntValue(FXObject*,FXSelector,void*); 00089 public: 00090 00091 /// Construct toggle button with two text labels, and two icons, one for each state 00092 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); 00093 00094 /// Create server-side resources 00095 virtual void create(); 00096 00097 /// Detach server-side resources 00098 virtual void detach(); 00099 00100 /// Returns true because a toggle button can receive focus 00101 virtual FXbool canFocus() const; 00102 00103 /// Get default width 00104 virtual FXint getDefaultWidth(); 00105 00106 /// Get default height 00107 virtual FXint getDefaultHeight(); 00108 00109 /// Change alternate text shown when toggled 00110 void setAltText(const FXString& text); 00111 00112 /// Return alternate text 00113 FXString getAltText() const { return altlabel; } 00114 00115 /// Change alternate icon shown when toggled 00116 void setAltIcon(FXIcon* ic); 00117 00118 /// Return alternate icon 00119 FXIcon* getAltIcon() const { return alticon; } 00120 00121 /// Change toggled state 00122 void setState(FXbool s=TRUE); 00123 00124 /// return toggled state 00125 FXbool getState() const { return state; } 00126 00127 /// Change alternate help text shown when toggled 00128 void setAltHelpText(const FXString& text); 00129 00130 /// Return alternate help text 00131 FXString getAltHelpText() const { return althelp; } 00132 00133 /// Change alternate tip text shown when toggled 00134 void setAltTipText(const FXString& text); 00135 00136 /// Return alternate tip text 00137 FXString getAltTipText() const { return alttip; } 00138 00139 /// Set the toggle button style flags 00140 void setToggleStyle(FXuint style); 00141 00142 /// Get the toggle button style flags 00143 FXuint getToggleStyle() const; 00144 00145 /// Save toggle button to a stream 00146 virtual void save(FXStream& store) const; 00147 00148 /// Load toggle button from a stream 00149 virtual void load(FXStream& store); 00150 00151 /// Destructor 00152 virtual ~FXToggleButton(); 00153 }; 00154 00155 } 00156 00157 #endif

Copyright © 1997-2004 Jeroen van der Zijp