![]() |
Main Page Class Hierarchy Alphabetical List Compound List File List Compound Members
![]() |
00001 /******************************************************************************** 00002 * * 00003 * B u t t o n W i d g e t * 00004 * * 00005 ********************************************************************************* 00006 * Copyright (C) 1997,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: FXButton.h,v 1.45 2009/01/06 13:07:22 fox Exp $ * 00022 ********************************************************************************/ 00023 #ifndef FXBUTTON_H 00024 #define FXBUTTON_H 00025 00026 #ifndef FXLABEL_H 00027 #include "FXLabel.h" 00028 #endif 00029 00030 namespace FX { 00031 00032 00033 /// Button states 00034 enum { 00035 STATE_UP = 0, /// Button is up 00036 STATE_DOWN = 1, /// Button is down 00037 STATE_ENGAGED = 2, /// Button is engaged 00038 STATE_UNCHECKED = STATE_UP, /// Same as STATE_UP (used for check buttons or radio buttons) 00039 STATE_CHECKED = STATE_ENGAGED /// Same as STATE_ENGAGED (used for check buttons or radio buttons) 00040 }; 00041 00042 00043 /// Button flags 00044 enum { 00045 BUTTON_AUTOGRAY = 0x00800000, /// Automatically gray out when not updated 00046 BUTTON_AUTOHIDE = 0x01000000, /// Automatically hide button when not updated 00047 BUTTON_TOOLBAR = 0x02000000, /// Toolbar style button [flat look] 00048 BUTTON_DEFAULT = 0x04000000, /// May become default button when receiving focus 00049 BUTTON_INITIAL = 0x08000000, /// This button is the initial default button 00050 BUTTON_NORMAL = (FRAME_RAISED|FRAME_THICK|JUSTIFY_NORMAL|ICON_BEFORE_TEXT) 00051 }; 00052 00053 00054 /** 00055 * A button provides a push button, with optional icon and/or text label. 00056 * When pressed, the button widget sends a SEL_COMMAND to its target. 00057 * Passing the BUTTON_TOOLBAR style option gives buttons a "flat" look, and 00058 * causes the edge of the button to be raised when the cursor moves over it. 00059 * Passing BUTTON_DEFAULT allows the button to become the default button in 00060 * a dialog, when the focus moves to it. The default widget in a dialog 00061 * is the widget which will accept the RETURN key when it is pressed. 00062 * The BUTTON_INITIAL flag makes the button the default widget when the 00063 * focus moves to a widget which can not itself be a default widget. 00064 * There should be only a single button in the dialog which is the 00065 * initial default; typically this is the OK or CLOSE button. 00066 * The option BUTTON_AUTOGRAY (BUTTON_AUTOHIDE) causes the button to be grayed 00067 * out (hidden) if its handler does not respond to the SEL_UPDATE message. 00068 * This is useful when messages are delegated, for example when using a 00069 * multiple document interface, where the ultimaye destination of a message 00070 * can be changed. 00071 */ 00072 class FXAPI FXButton : public FXLabel { 00073 FXDECLARE(FXButton) 00074 protected: 00075 FXuchar state; 00076 protected: 00077 FXButton(); 00078 private: 00079 FXButton(const FXButton&); 00080 FXButton& operator=(const FXButton&); 00081 public: 00082 long onPaint(FXObject*,FXSelector,void*); 00083 long onUpdate(FXObject*,FXSelector,void*); 00084 long onEnter(FXObject*,FXSelector,void*); 00085 long onLeave(FXObject*,FXSelector,void*); 00086 long onFocusIn(FXObject*,FXSelector,void*); 00087 long onFocusOut(FXObject*,FXSelector,void*); 00088 long onUngrabbed(FXObject*,FXSelector,void*); 00089 long onLeftBtnPress(FXObject*,FXSelector,void*); 00090 long onLeftBtnRelease(FXObject*,FXSelector,void*); 00091 long onKeyPress(FXObject*,FXSelector,void*); 00092 long onKeyRelease(FXObject*,FXSelector,void*); 00093 long onHotKeyPress(FXObject*,FXSelector,void*); 00094 long onHotKeyRelease(FXObject*,FXSelector,void*); 00095 long onCheck(FXObject*,FXSelector,void*); 00096 long onUncheck(FXObject*,FXSelector,void*); 00097 long onCmdSetValue(FXObject*,FXSelector,void*); 00098 long onCmdSetIntValue(FXObject*,FXSelector,void*); 00099 long onCmdGetIntValue(FXObject*,FXSelector,void*); 00100 public: 00101 00102 /// Construct button with text and icon 00103 FXButton(FXComposite* p,const FXString& text,FXIcon* ic=NULL,FXObject* tgt=NULL,FXSelector sel=0,FXuint opts=BUTTON_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); 00104 00105 /// Returns true because a button can receive focus 00106 virtual FXbool canFocus() const; 00107 00108 /// Move the focus to this window 00109 virtual void setFocus(); 00110 00111 /// Remove the focus from this window 00112 virtual void killFocus(); 00113 00114 /// Set as default button 00115 virtual void setDefault(FXuchar flag=TRUE); 00116 00117 /// Set the button state 00118 void setState(FXuint s); 00119 00120 /// Get the button state 00121 FXuint getState() const { return state; } 00122 00123 /// Set the button style flags 00124 void setButtonStyle(FXuint style); 00125 00126 /// Get the button style flags 00127 FXuint getButtonStyle() const; 00128 00129 }; 00130 00131 } 00132 00133 #endif
![]() |