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

FXRadioButton.h

00001 /********************************************************************************
00002 *                                                                               *
00003 *                  R a d i o   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: FXRadioButton.h,v 1.18 2002/01/18 22:42:54 jeroen Exp $                  *
00023 ********************************************************************************/
00024 #ifndef FXRADIOBUTTON_H
00025 #define FXRADIOBUTTON_H
00026 
00027 #ifndef FXLABEL_H
00028 #include "FXLabel.h"
00029 #endif
00030 
00031 
00032 /// RadioButton flags
00033 enum {
00034   RADIOBUTTON_AUTOGRAY = 0x00800000,  /// Automatically gray out when not updated
00035   RADIOBUTTON_AUTOHIDE = 0x01000000,  /// Automatically hide when not updated
00036   RADIOBUTTON_NORMAL   = JUSTIFY_NORMAL|ICON_BEFORE_TEXT
00037   };
00038 
00039 
00040 
00041 /**
00042 * A radio button is a tri-state button.  Normally, it is either
00043 * TRUE or FALSE; a third state MAYBE may be set to indicate that no selection
00044 * has been made yet by the user, or that the state is ambiguous.
00045 * When pressed, the radio button sets its state to TRUE and sends a SEL_COMMAND
00046 * to its target, and the message data set to the state of the radio button,
00047 * of the type FXbool.
00048 * If the radio button is contained inside a group box, the other radio buttons
00049 * in the group box will be set to FALSE and will send a message as well.
00050 */
00051 class FXAPI FXRadioButton : public FXLabel {
00052   FXDECLARE(FXRadioButton)
00053 protected:
00054   FXbool   check;
00055   FXbool   oldcheck;
00056   FXColor  radioColor;
00057 protected:
00058   FXRadioButton();
00059 private:
00060   FXRadioButton(const FXRadioButton&);
00061   FXRadioButton &operator=(const FXRadioButton&);
00062 public:
00063   long onPaint(FXObject*,FXSelector,void*);
00064   long onUpdate(FXObject*,FXSelector,void*);
00065   long onEnter(FXObject*,FXSelector,void*);
00066   long onLeave(FXObject*,FXSelector,void*);
00067   long onFocusIn(FXObject*,FXSelector,void*);
00068   long onFocusOut(FXObject*,FXSelector,void*);
00069   long onUngrabbed(FXObject*,FXSelector,void*);
00070   long onLeftBtnPress(FXObject*,FXSelector,void*);
00071   long onLeftBtnRelease(FXObject*,FXSelector,void*);
00072   long onKeyPress(FXObject*,FXSelector,void*);
00073   long onKeyRelease(FXObject*,FXSelector,void*);
00074   long onHotKeyPress(FXObject*,FXSelector,void*);
00075   long onHotKeyRelease(FXObject*,FXSelector,void*);
00076   long onUncheckRadio(FXObject*,FXSelector,void*);
00077   long onCheck(FXObject*,FXSelector,void*);
00078   long onUncheck(FXObject*,FXSelector,void*);
00079   long onUnknown(FXObject*,FXSelector,void*);
00080   long onCmdSetValue(FXObject*,FXSelector,void*);
00081   long onCmdSetIntValue(FXObject*,FXSelector,void*);
00082   long onCmdGetIntValue(FXObject*,FXSelector,void*);
00083 public:
00084 
00085   /// Construct new radio button
00086   FXRadioButton(FXComposite* p,const FXString& text,FXObject* tgt=NULL,FXSelector sel=0,FXuint opts=RADIOBUTTON_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);
00087 
00088   /// Returns true because a radio button can receive focus
00089   virtual FXbool canFocus() const;
00090 
00091   /// Get default width
00092   virtual FXint getDefaultWidth();
00093 
00094   /// Get default height
00095   virtual FXint getDefaultHeight();
00096 
00097   /// Set radio button state (TRUE, FALSE or MAYBE)
00098   void setCheck(FXbool s=TRUE);
00099 
00100   /// Get radio button state (TRUE, FALSE or MAYBE)
00101   FXbool getCheck() const { return check; }
00102 
00103   /// Change radio button style
00104   void setRadioButtonStyle(FXuint style);
00105 
00106   /// Return current radio button style
00107   FXuint getRadioButtonStyle() const;
00108 
00109   /// Get the radio background color
00110   FXColor getRadioColor() const { return radioColor; }
00111 
00112   /// Set the radio background color
00113   void setRadioColor(FXColor clr);
00114 
00115   /// Save radio button to a stream
00116   virtual void save(FXStream& store) const;
00117 
00118   /// Load radio button from a stream
00119   virtual void load(FXStream& store);
00120   };
00121 
00122 
00123 #endif