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

FXRadioButton.h

Go to the documentation of this file.
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,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: FXRadioButton.h,v 1.36 2009/01/06 13:07:26 fox Exp $                     *
00022 ********************************************************************************/
00023 #ifndef FXRADIOBUTTON_H
00024 #define FXRADIOBUTTON_H
00025 
00026 #ifndef FXLABEL_H
00027 #include "FXLabel.h"
00028 #endif
00029 
00030 namespace FX {
00031 
00032 
00033 /// RadioButton flags
00034 enum {
00035   RADIOBUTTON_AUTOGRAY = 0x00800000,  /// Automatically gray out when not updated
00036   RADIOBUTTON_AUTOHIDE = 0x01000000,  /// Automatically hide when not updated
00037   RADIOBUTTON_NORMAL   = JUSTIFY_NORMAL|ICON_BEFORE_TEXT
00038   };
00039 
00040 
00041 
00042 /**
00043 * A radio button is a tri-state button.  Normally, it is either
00044 * TRUE or FALSE; a third state MAYBE may be set to indicate that no selection
00045 * has been made yet by the user, or that the state is ambiguous.
00046 * When pressed, the radio button sets its state to TRUE and sends a SEL_COMMAND
00047 * to its target, and the message data set to the state of the radio button,
00048 * of the type FXbool.
00049 * A group of radio buttons can be made mutually exclusive by linking them
00050 * to a common data target.  Alternatively, an application can implement a
00051 * common SEL_UPDATED handler to check and uncheck radio buttons as appropriate.
00052 */
00053 class FXAPI FXRadioButton : public FXLabel {
00054   FXDECLARE(FXRadioButton)
00055 protected:
00056   FXColor  radioColor;  // Color of radio ball
00057   FXColor  diskColor;   // Color of radio disk
00058   FXuchar  check;       // Radio state
00059   FXuchar  oldcheck;    // Old radio state
00060 protected:
00061   FXRadioButton();
00062 private:
00063   FXRadioButton(const FXRadioButton&);
00064   FXRadioButton &operator=(const FXRadioButton&);
00065 public:
00066   long onPaint(FXObject*,FXSelector,void*);
00067   long onUpdate(FXObject*,FXSelector,void*);
00068   long onEnter(FXObject*,FXSelector,void*);
00069   long onLeave(FXObject*,FXSelector,void*);
00070   long onFocusIn(FXObject*,FXSelector,void*);
00071   long onFocusOut(FXObject*,FXSelector,void*);
00072   long onUngrabbed(FXObject*,FXSelector,void*);
00073   long onLeftBtnPress(FXObject*,FXSelector,void*);
00074   long onLeftBtnRelease(FXObject*,FXSelector,void*);
00075   long onKeyPress(FXObject*,FXSelector,void*);
00076   long onKeyRelease(FXObject*,FXSelector,void*);
00077   long onHotKeyPress(FXObject*,FXSelector,void*);
00078   long onHotKeyRelease(FXObject*,FXSelector,void*);
00079   long onCheck(FXObject*,FXSelector,void*);
00080   long onUncheck(FXObject*,FXSelector,void*);
00081   long onUnknown(FXObject*,FXSelector,void*);
00082   long onCmdSetValue(FXObject*,FXSelector,void*);
00083   long onCmdSetIntValue(FXObject*,FXSelector,void*);
00084   long onCmdGetIntValue(FXObject*,FXSelector,void*);
00085 public:
00086 
00087   /// Construct new radio button
00088   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);
00089 
00090   /// Returns true because a radio button can receive focus
00091   virtual FXbool canFocus() const;
00092 
00093   /// Get default width
00094   virtual FXint getDefaultWidth();
00095 
00096   /// Get default height
00097   virtual FXint getDefaultHeight();
00098 
00099   /// Set radio button state (TRUE, FALSE or MAYBE)
00100   void setCheck(FXuchar s=TRUE,FXbool notify=false);
00101 
00102   /// Get radio button state (TRUE, FALSE or MAYBE)
00103   FXuchar getCheck() const { return check; }
00104 
00105   /// Change radio button style
00106   void setRadioButtonStyle(FXuint style);
00107 
00108   /// Return current radio button style
00109   FXuint getRadioButtonStyle() const;
00110 
00111   /// Get the radio ball color
00112   FXColor getRadioColor() const { return radioColor; }
00113 
00114   /// Set the radio ball color
00115   void setRadioColor(FXColor clr);
00116 
00117   /// Get the radio disk color
00118   FXColor getDiskColor() const { return diskColor; }
00119 
00120   /// Set the radio disk color
00121   void setDiskColor(FXColor clr);
00122 
00123   /// Save radio button to a stream
00124   virtual void save(FXStream& store) const;
00125 
00126   /// Load radio button from a stream
00127   virtual void load(FXStream& store);
00128   };
00129 
00130 }
00131 
00132 #endif

Copyright © 1997-2009 Jeroen van der Zijp