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

FXToggleButton.h
Go to the documentation of this file.
1 /********************************************************************************
2 * *
3 * T o g g l e 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: FXToggleButton.h,v 1.30 2006/01/22 17:58:11 fox Exp $ *
23 ********************************************************************************/
24 #ifndef FXTOGGLEBUTTON_H
25 #define FXTOGGLEBUTTON_H
26 
27 #ifndef FXLABEL_H
28 #include "FXLabel.h"
29 #endif
30 
31 namespace FX {
32 
33 
34 /// Toggle button flags
35 enum {
36  TOGGLEBUTTON_AUTOGRAY = 0x00800000, /// Automatically gray out when not updated
37  TOGGLEBUTTON_AUTOHIDE = 0x01000000, /// Automatically hide toggle button when not updated
38  TOGGLEBUTTON_TOOLBAR = 0x02000000, /// Toolbar style toggle button [flat look]
39  TOGGLEBUTTON_KEEPSTATE= 0x04000000, /// Draw button according to state
41  };
42 
43 
44 /**
45 * The toggle button provides a two-state button, which toggles between the
46 * on and the off state each time it is pressed. For each state, the toggle
47 * button has a unique icon and text label.
48 * When pressed, the button widget sends a SEL_COMMAND to its target, with the
49 * message data set to the current state of the toggle button, of the type FXbool.
50 */
51 class FXAPI FXToggleButton : public FXLabel {
53 protected:
54  FXString altlabel;
55  FXIcon *alticon;
56  FXHotKey althotkey;
57  FXint althotoff;
58  FXString alttip;
59  FXString althelp;
60  FXbool state;
61  FXbool down;
62 protected:
64  void press(FXbool dn);
65 private:
67  FXToggleButton& operator=(const FXToggleButton&);
68 public:
69  long onPaint(FXObject*,FXSelector,void*);
70  long onUpdate(FXObject*,FXSelector,void*);
71  long onEnter(FXObject*,FXSelector,void*);
72  long onLeave(FXObject*,FXSelector,void*);
73  long onFocusIn(FXObject*,FXSelector,void*);
74  long onFocusOut(FXObject*,FXSelector,void*);
75  long onUngrabbed(FXObject*,FXSelector,void*);
76  long onLeftBtnPress(FXObject*,FXSelector,void*);
77  long onLeftBtnRelease(FXObject*,FXSelector,void*);
78  long onKeyPress(FXObject*,FXSelector,void*);
79  long onKeyRelease(FXObject*,FXSelector,void*);
80  long onHotKeyPress(FXObject*,FXSelector,void*);
81  long onHotKeyRelease(FXObject*,FXSelector,void*);
82  long onCheck(FXObject*,FXSelector,void*);
83  long onUncheck(FXObject*,FXSelector,void*);
84  long onQueryHelp(FXObject*,FXSelector,void*);
85  long onQueryTip(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 toggle button with two text labels, and two icons, one for each state
93 
94  /// Create server-side resources
95  virtual void create();
96 
97  /// Detach server-side resources
98  virtual void detach();
99 
100  /// Returns true because a toggle button can receive focus
101  virtual bool canFocus() const;
102 
103  /// Get default width
104  virtual FXint getDefaultWidth();
106  /// Get default height
107  virtual FXint getDefaultHeight();
108 
109  /// Change alternate text shown when toggled
110  void setAltText(const FXString& text);
112  /// Return alternate text
113  FXString getAltText() const { return altlabel; }
114 
115  /// Change alternate icon shown when toggled
116  void setAltIcon(FXIcon* ic);
118  /// Return alternate icon
119  FXIcon* getAltIcon() const { return alticon; }
120 
121  /// Change toggled state
122  void setState(FXbool s=TRUE,FXbool notify=FALSE);
124  /// return toggled state
125  FXbool getState() const { return state; }
126 
127  /// Change alternate help text shown when toggled
128  void setAltHelpText(const FXString& text);
130  /// Return alternate help text
131  FXString getAltHelpText() const { return althelp; }
132 
133  /// Change alternate tip text shown when toggled
134  void setAltTipText(const FXString& text);
135 
136  /// Return alternate tip text
137  FXString getAltTipText() const { return alttip; }
138 
139  /// Set the toggle button style flags
140  void setToggleStyle(FXuint style);
141 
142  /// Get the toggle button style flags
143  FXuint getToggleStyle() const;
144 
145  /// Save toggle button to a stream
146  virtual void save(FXStream& store) const;
147 
148  /// Load toggle button from a stream
149  virtual void load(FXStream& store);
150 
151  /// Destructor
152  virtual ~FXToggleButton();
153  };
154 
155 }
156 
157 #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
FXuint FXHotKey
Definition: fxdefs.h:457
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
Toolbar style toggle button [flat look].
Definition: FXToggleButton.h:41
The toggle button provides a two-state button, which toggles between the on and the off state each ti...
Definition: FXToggleButton.h:58
Automatically gray out when not updated.
Definition: FXToggleButton.h:39
Definition: FX4Splitter.h:31
int FXint
Definition: fxdefs.h:397
Automatically hide toggle button when not updated.
Definition: FXToggleButton.h:40
An Icon is an image with two additional server-side resources: a shape bitmap, which is used to mask ...
Definition: FXIcon.h:45
Draw button according to state.
Definition: FXToggleButton.h:42
Raised border.
Definition: FXWindow.h:77
#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
Thick border.
Definition: FXWindow.h:78
Definition: FXToggleButton.h:43
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