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

FXButton.h

00001 /********************************************************************************
00002 *                                                                               *
00003 *                           B u t t o n   W i d g e t                           *
00004 *                                                                               *
00005 *********************************************************************************
00006 * Copyright (C) 1997,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: FXButton.h,v 1.30 2002/01/18 22:42:51 jeroen Exp $                       *
00023 ********************************************************************************/
00024 #ifndef FXBUTTON_H
00025 #define FXBUTTON_H
00026 
00027 #ifndef FXLABEL_H
00028 #include "FXLabel.h"
00029 #endif
00030 
00031 
00032 
00033 /// Button state bits
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 */
00058 class FXAPI FXButton : public FXLabel {
00059   FXDECLARE(FXButton)
00060 protected:
00061   FXuchar  state;
00062 protected:
00063   FXButton();
00064 private:
00065   FXButton(const FXButton&);
00066   FXButton& operator=(const FXButton&);
00067 public:
00068   long onPaint(FXObject*,FXSelector,void*);
00069   long onUpdate(FXObject*,FXSelector,void*);
00070   long onEnter(FXObject*,FXSelector,void*);
00071   long onLeave(FXObject*,FXSelector,void*);
00072   long onFocusIn(FXObject*,FXSelector,void*);
00073   long onFocusOut(FXObject*,FXSelector,void*);
00074   long onUngrabbed(FXObject*,FXSelector,void*);
00075   long onLeftBtnPress(FXObject*,FXSelector,void*);
00076   long onLeftBtnRelease(FXObject*,FXSelector,void*);
00077   long onKeyPress(FXObject*,FXSelector,void*);
00078   long onKeyRelease(FXObject*,FXSelector,void*);
00079   long onHotKeyPress(FXObject*,FXSelector,void*);
00080   long onHotKeyRelease(FXObject*,FXSelector,void*);
00081   long onCheck(FXObject*,FXSelector,void*);
00082   long onUncheck(FXObject*,FXSelector,void*);
00083   long onCmdSetValue(FXObject*,FXSelector,void*);
00084   long onCmdSetIntValue(FXObject*,FXSelector,void*);
00085   long onCmdGetIntValue(FXObject*,FXSelector,void*);
00086 public:
00087 
00088   /// Construct button with text and icon
00089   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);
00090 
00091   /// Returns true because a button can receive focus
00092   virtual FXbool canFocus() const;
00093 
00094   /// Move the focus to this window
00095   virtual void setFocus();
00096 
00097   /// Remove the focus from this window
00098   virtual void killFocus();
00099 
00100   /// Set as default button
00101   virtual void setDefault(FXbool enable=TRUE);
00102 
00103   /// Set the button state
00104   void setState(FXuint s);
00105 
00106   /// Get the button state
00107   FXuint getState() const { return state; }
00108 
00109   /// Set the button style flags
00110   void setButtonStyle(FXuint style);
00111 
00112   /// Get the button style flags
00113   FXuint getButtonStyle() const;
00114 
00115   };
00116 
00117 
00118 #endif