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

FXCheckButton.h
Go to the documentation of this file.
1 /********************************************************************************
2 * *
3 * C h e c k 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: FXCheckButton.h,v 1.32 2006/01/22 17:57:59 fox Exp $ *
23 ********************************************************************************/
24 #ifndef FXCHECKBUTTON_H
25 #define FXCHECKBUTTON_H
26 
27 #ifndef FXLABEL_H
28 #include "FXLabel.h"
29 #endif
30 
31 namespace FX {
32 
33 
34 /// CheckButton styles
35 enum {
36  CHECKBUTTON_AUTOGRAY = 0x00800000, /// Automatically gray out when not updated
37  CHECKBUTTON_AUTOHIDE = 0x01000000, /// Automatically hide when not updated
38  CHECKBUTTON_PLUS = 0x02000000, /// Draw a + for unchecked and - for checked
40  };
41 
42 
43 /**
44 * A Check Button is a tri-state button. Normally, it is either
45 * TRUE or FALSE, and toggles between TRUE or FALSE whenever it is pressed.
46 * A third state MAYBE may be set to indicate that no selection has been made yet
47 * by the user, or that the state is ambiguous.
48 * When pressed, the Check Button sends a SEL_COMMAND to its target, and the
49 * message data represents the state of the check button.
50 * The option CHECKBUTTON_AUTOGRAY (CHECKBUTTON_AUTOHIDE) causes the button to be
51 * grayed out (hidden) if its handler does not respond to the SEL_UPDATE message.
52 * With the CHECKBUTTON_PLUS option, the Check Button will draw a + or - sign instead
53 * of a check. You can use this to make collapsable panels, by hooking up a Check
54 * Button to a layout manager via the ID_TOGGLE_SHOWN message. This will give a
55 * similar visual element as collapsing folders in a Tree List.
56 */
57 class FXAPI FXCheckButton : public FXLabel {
59 protected:
60  FXColor checkColor; // Color of check mark
61  FXColor boxColor; // Color of check box
62  FXbool check; // Check state
63  FXbool oldcheck; // Old check state
64 protected:
65  FXCheckButton();
66 private:
68  FXCheckButton &operator=(const FXCheckButton&);
69 public:
70  long onPaint(FXObject*,FXSelector,void*);
71  long onUpdate(FXObject*,FXSelector,void*);
72  long onEnter(FXObject*,FXSelector,void*);
73  long onLeave(FXObject*,FXSelector,void*);
74  long onFocusIn(FXObject*,FXSelector,void*);
75  long onFocusOut(FXObject*,FXSelector,void*);
76  long onUngrabbed(FXObject*,FXSelector,void*);
77  long onLeftBtnPress(FXObject*,FXSelector,void*);
78  long onLeftBtnRelease(FXObject*,FXSelector,void*);
79  long onKeyPress(FXObject*,FXSelector,void*);
80  long onKeyRelease(FXObject*,FXSelector,void*);
81  long onHotKeyPress(FXObject*,FXSelector,void*);
82  long onHotKeyRelease(FXObject*,FXSelector,void*);
83  long onCheck(FXObject*,FXSelector,void*);
84  long onUncheck(FXObject*,FXSelector,void*);
85  long onUnknown(FXObject*,FXSelector,void*);
86  long onCmdSetValue(FXObject*,FXSelector,void*);
87  long onCmdSetIntValue(FXObject*,FXSelector,void*);
88  long onCmdGetIntValue(FXObject*,FXSelector,void*);
89 public:
90 
91  /// Construct new check button
93 
94  /// Returns true because a check button can receive focus
95  virtual bool canFocus() const;
96 
97  /// Get default width
98  virtual FXint getDefaultWidth();
99 
100  /// Get default height
101  virtual FXint getDefaultHeight();
102 
103  /// Set check button state (TRUE, FALSE or MAYBE)
104  void setCheck(FXbool state=TRUE,FXbool notify=FALSE);
105 
106  /// Get check button state (TRUE, FALSE or MAYBE)
107  FXbool getCheck() const { return check; }
108 
109  /// Change check button style
110  void setCheckButtonStyle(FXuint style);
111 
112  /// Return current check button style
113  FXuint getCheckButtonStyle() const;
114 
115  /// Get the box background color
116  FXColor getBoxColor() const { return boxColor; }
117 
118  /// Set the box background color
119  void setBoxColor(FXColor clr);
120 
121  /// Get the box check color
122  FXColor getCheckColor() const { return checkColor; }
123 
124  /// Set the box check color
125  void setCheckColor(FXColor clr);
126 
127  /// Save check button to a stream
128  virtual void save(FXStream& store) const;
129 
130  /// Load check button from a stream
131  virtual void load(FXStream& store);
132  };
133 
134 }
135 
136 #endif
#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
A Check Button is a tri-state button.
Definition: FXCheckButton.h:64
A stream is a way to serialize data and objects into a byte stream.
Definition: FXStream.h:99
Draw a + for unchecked and - for checked.
Definition: FXCheckButton.h:41
Definition: FX4Splitter.h:31
int FXint
Definition: fxdefs.h:397
Automatically gray out when not updated.
Definition: FXCheckButton.h:39
Definition: FXCheckButton.h:42
#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
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
Automatically hide when not updated.
Definition: FXCheckButton.h:40
FXString provides essential string manipulation capabilities.
Definition: FXString.h:33

Copyright © 1997-2005 Jeroen van der Zijp