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,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: FXButton.h,v 1.34 2004/02/08 17:17:33 fox Exp $                          *
00023 ********************************************************************************/
00024 #ifndef FXBUTTON_H
00025 #define FXBUTTON_H
00026 
00027 #ifndef FXLABEL_H
00028 #include "FXLabel.h"
00029 #endif
00030 
00031 namespace FX {
00032 
00033 
00034 /// Button state bits
00035 enum {
00036   STATE_UP        = 0,      /// Button is up
00037   STATE_DOWN      = 1,      /// Button is down
00038   STATE_ENGAGED   = 2,      /// Button is engaged
00039   STATE_UNCHECKED = STATE_UP,   /// Same as STATE_UP (used for check buttons or radio buttons)
00040   STATE_CHECKED   = STATE_ENGAGED /// Same as STATE_ENGAGED (used for check buttons or radio buttons)
00041   };
00042 
00043 
00044 /// Button flags
00045 enum {
00046   BUTTON_AUTOGRAY  = 0x00800000,  /// Automatically gray out when not updated
00047   BUTTON_AUTOHIDE  = 0x01000000,  /// Automatically hide button when not updated
00048   BUTTON_TOOLBAR   = 0x02000000,  /// Toolbar style button [flat look]
00049   BUTTON_DEFAULT   = 0x04000000,  /// May become default button when receiving focus
00050   BUTTON_INITIAL   = 0x08000000,  /// This button is the initial default button
00051   BUTTON_NORMAL    = (FRAME_RAISED|FRAME_THICK|JUSTIFY_NORMAL|ICON_BEFORE_TEXT)
00052   };
00053 
00054 
00055 /**
00056 * A button provides a push button, with optional icon and/or text label.
00057 * When pressed, the button widget sends a SEL_COMMAND to its target.
00058 */
00059 class FXAPI FXButton : public FXLabel {
00060   FXDECLARE(FXButton)
00061 protected:
00062   FXuchar  state;
00063 protected:
00064   FXButton();
00065 private:
00066   FXButton(const FXButton&);
00067   FXButton& operator=(const FXButton&);
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 onCmdSetValue(FXObject*,FXSelector,void*);
00085   long onCmdSetIntValue(FXObject*,FXSelector,void*);
00086   long onCmdGetIntValue(FXObject*,FXSelector,void*);
00087 public:
00088 
00089   /// Construct button with text and icon
00090   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);
00091 
00092   /// Returns true because a button can receive focus
00093   virtual FXbool canFocus() const;
00094 
00095   /// Move the focus to this window
00096   virtual void setFocus();
00097 
00098   /// Remove the focus from this window
00099   virtual void killFocus();
00100 
00101   /// Set as default button
00102   virtual void setDefault(FXbool enable=TRUE);
00103 
00104   /// Set the button state
00105   void setState(FXuint s);
00106 
00107   /// Get the button state
00108   FXuint getState() const { return state; }
00109 
00110   /// Set the button style flags
00111   void setButtonStyle(FXuint style);
00112 
00113   /// Get the button style flags
00114   FXuint getButtonStyle() const;
00115 
00116   };
00117 
00118 }
00119 
00120 #endif

Copyright © 1997-2004 Jeroen van der Zijp