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

FXRadioButton.h
Go to the documentation of this file.
1 /********************************************************************************
2 * *
3 * R a d i o B u t t o n W i d g e t *
4 * *
5 *********************************************************************************
6 * Copyright (C) 1998,2006 by Jeroen van der Zijp. All Rights Reserved. *
7 *********************************************************************************
8 * This library is free software; you can redistribute it and/or *
9 * modify it under the terms of the GNU Lesser General Public *
10 * License as published by the Free Software Foundation; either *
11 * version 2.1 of the License, or (at your option) any later version. *
12 * *
13 * This library is distributed in the hope that it will be useful, *
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
16 * Lesser General Public License for more details. *
17 * *
18 * You should have received a copy of the GNU Lesser General Public *
19 * License along with this library; if not, write to the Free Software *
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
21 *********************************************************************************
22 * $Id: FXRadioButton.h,v 1.29 2006/01/22 17:58:08 fox Exp $ *
23 ********************************************************************************/
24 #ifndef FXRADIOBUTTON_H
25 #define FXRADIOBUTTON_H
26 
27 #ifndef FXLABEL_H
28 #include "FXLabel.h"
29 #endif
30 
31 namespace FX {
32 
33 
34 /// RadioButton flags
35 enum {
36  RADIOBUTTON_AUTOGRAY = 0x00800000, /// Automatically gray out when not updated
37  RADIOBUTTON_AUTOHIDE = 0x01000000, /// Automatically hide when not updated
39  };
40 
41 
42 
43 /**
44 * A radio button is a tri-state button. Normally, it is either
45 * TRUE or FALSE; a third state MAYBE may be set to indicate that no selection
46 * has been made yet by the user, or that the state is ambiguous.
47 * When pressed, the radio button sets its state to TRUE and sends a SEL_COMMAND
48 * to its target, and the message data set to the state of the radio button,
49 * of the type FXbool.
50 * A group of radio buttons can be made mutually exclusive by linking them
51 * to a common data target. Alternatively, an application can implement a
52 * common SEL_UPDATED handler to check and uncheck radio buttons as appropriate.
53 */
54 class FXAPI FXRadioButton : public FXLabel {
56 protected:
57  FXColor radioColor; // Color of radio ball
58  FXColor diskColor; // Color of radio disk
59  FXbool check; // Radio state
60  FXbool oldcheck; // Old radio state
61 protected:
62  FXRadioButton();
63 private:
65  FXRadioButton &operator=(const FXRadioButton&);
66 public:
67  long onPaint(FXObject*,FXSelector,void*);
68  long onUpdate(FXObject*,FXSelector,void*);
69  long onEnter(FXObject*,FXSelector,void*);
70  long onLeave(FXObject*,FXSelector,void*);
71  long onFocusIn(FXObject*,FXSelector,void*);
72  long onFocusOut(FXObject*,FXSelector,void*);
73  long onUngrabbed(FXObject*,FXSelector,void*);
74  long onLeftBtnPress(FXObject*,FXSelector,void*);
75  long onLeftBtnRelease(FXObject*,FXSelector,void*);
76  long onKeyPress(FXObject*,FXSelector,void*);
77  long onKeyRelease(FXObject*,FXSelector,void*);
78  long onHotKeyPress(FXObject*,FXSelector,void*);
79  long onHotKeyRelease(FXObject*,FXSelector,void*);
80  long onCheck(FXObject*,FXSelector,void*);
81  long onUncheck(FXObject*,FXSelector,void*);
82  long onUnknown(FXObject*,FXSelector,void*);
83  long onCmdSetValue(FXObject*,FXSelector,void*);
84  long onCmdSetIntValue(FXObject*,FXSelector,void*);
85  long onCmdGetIntValue(FXObject*,FXSelector,void*);
86 public:
87 
88  /// Construct new radio button
90 
91  /// Returns true because a radio button can receive focus
92  virtual bool canFocus() const;
93 
94  /// Get default width
95  virtual FXint getDefaultWidth();
96 
97  /// Get default height
98  virtual FXint getDefaultHeight();
99 
100  /// Set radio button state (TRUE, FALSE or MAYBE)
101  void setCheck(FXbool s=TRUE,FXbool notify=FALSE);
102 
103  /// Get radio button state (TRUE, FALSE or MAYBE)
104  FXbool getCheck() const { return check; }
105 
106  /// Change radio button style
107  void setRadioButtonStyle(FXuint style);
108 
109  /// Return current radio button style
110  FXuint getRadioButtonStyle() const;
111 
112  /// Get the radio ball color
113  FXColor getRadioColor() const { return radioColor; }
114 
115  /// Set the radio ball color
116  void setRadioColor(FXColor clr);
117 
118  /// Get the radio disk color
119  FXColor getDiskColor() const { return diskColor; }
120 
121  /// Set the radio disk color
122  void setDiskColor(FXColor clr);
123 
124  /// Save radio button to a stream
125  virtual void save(FXStream& store) const;
126 
127  /// Load radio button from a stream
128  virtual void load(FXStream& store);
129  };
130 
131 }
132 
133 #endif
Automatically gray out when not updated.
Definition: FXRadioButton.h:39
#define TRUE
Definition: fxdefs.h:32
A label widget can be used to place a text and/or icon for explanation purposes.
Definition: FXLabel.h:79
unsigned int FXuint
Definition: fxdefs.h:396
Definition: FXFrame.h:56
FXuint FXSelector
Association key.
Definition: FXObject.h:53
#define FXAPI
Definition: fxdefs.h:122
FXuchar FXbool
Definition: fxdefs.h:393
Base composite.
Definition: FXComposite.h:35
#define NULL
Definition: fxdefs.h:41
FXuint FXColor
Definition: fxdefs.h:454
Definition: FXRadioButton.h:41
A stream is a way to serialize data and objects into a byte stream.
Definition: FXStream.h:99
Definition: FX4Splitter.h:31
int FXint
Definition: fxdefs.h:397
#define FALSE
Definition: fxdefs.h:35
Object is the base class for all objects in FOX; in order to receive messages from the user interface...
Definition: FXObject.h:166
Automatically hide when not updated.
Definition: FXRadioButton.h:40
A radio button is a tri-state button.
Definition: FXRadioButton.h:61
Icon appears before text (to its left)
Definition: FXLabel.h:41
Default justification is centered text.
Definition: FXFrame.h:39
#define FXDECLARE(classname)
Macro to set up class declaration.
Definition: FXObject.h:92
FXString provides essential string manipulation capabilities.
Definition: FXString.h:33

Copyright © 1997-2005 Jeroen van der Zijp