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

FXButton.h
Go to the documentation of this file.
1 /********************************************************************************
2 * *
3 * B u t t o n W i d g e t *
4 * *
5 *********************************************************************************
6 * Copyright (C) 1997,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: FXButton.h,v 1.38 2006/01/22 17:57:59 fox Exp $ *
23 ********************************************************************************/
24 #ifndef FXBUTTON_H
25 #define FXBUTTON_H
26 
27 #ifndef FXLABEL_H
28 #include "FXLabel.h"
29 #endif
30 
31 namespace FX {
32 
33 
34 /// Button state bits
35 enum {
36  STATE_UP = 0, /// Button is up
37  STATE_DOWN = 1, /// Button is down
38  STATE_ENGAGED = 2, /// Button is engaged
39  STATE_UNCHECKED = STATE_UP, /// Same as STATE_UP (used for check buttons or radio buttons)
40  STATE_CHECKED = STATE_ENGAGED /// Same as STATE_ENGAGED (used for check buttons or radio buttons)
41  };
42 
43 
44 /// Button flags
45 enum {
46  BUTTON_AUTOGRAY = 0x00800000, /// Automatically gray out when not updated
47  BUTTON_AUTOHIDE = 0x01000000, /// Automatically hide button when not updated
48  BUTTON_TOOLBAR = 0x02000000, /// Toolbar style button [flat look]
49  BUTTON_DEFAULT = 0x04000000, /// May become default button when receiving focus
50  BUTTON_INITIAL = 0x08000000, /// This button is the initial default button
52  };
53 
54 
55 /**
56 * A button provides a push button, with optional icon and/or text label.
57 * When pressed, the button widget sends a SEL_COMMAND to its target.
58 * Passing the BUTTON_TOOLBAR style option gives buttons a "flat" look, and
59 * causes the edge of the button to be raised when the cursor moves over it.
60 * Passing BUTTON_DEFAULT allows the button to become the default button in
61 * a dialog, when the focus moves to it. The default widget in a dialog
62 * is the widget which will accept the RETURN key when it is pressed.
63 * The BUTTON_INITIAL flag makes the button the default widget when the
64 * focus moves to a widget which can not itself be a default widget.
65 * There should be only a single button in the dialog which is the
66 * initial default; typically this is the OK or CLOSE button.
67 * The option BUTTON_AUTOGRAY (BUTTON_AUTOHIDE) causes the button to be grayed
68 * out (hidden) if its handler does not respond to the SEL_UPDATE message.
69 * This is useful when messages are delegated, for example when using a
70 * multiple document interface, where the ultimaye destination of a message
71 * can be changed.
72 */
73 class FXAPI FXButton : public FXLabel {
75 protected:
76  FXuchar state;
77 protected:
78  FXButton();
79 private:
80  FXButton(const FXButton&);
81  FXButton& operator=(const FXButton&);
82 public:
83  long onPaint(FXObject*,FXSelector,void*);
84  long onUpdate(FXObject*,FXSelector,void*);
85  long onEnter(FXObject*,FXSelector,void*);
86  long onLeave(FXObject*,FXSelector,void*);
87  long onFocusIn(FXObject*,FXSelector,void*);
88  long onFocusOut(FXObject*,FXSelector,void*);
89  long onUngrabbed(FXObject*,FXSelector,void*);
90  long onLeftBtnPress(FXObject*,FXSelector,void*);
91  long onLeftBtnRelease(FXObject*,FXSelector,void*);
92  long onKeyPress(FXObject*,FXSelector,void*);
93  long onKeyRelease(FXObject*,FXSelector,void*);
94  long onHotKeyPress(FXObject*,FXSelector,void*);
95  long onHotKeyRelease(FXObject*,FXSelector,void*);
96  long onCheck(FXObject*,FXSelector,void*);
97  long onUncheck(FXObject*,FXSelector,void*);
98  long onCmdSetValue(FXObject*,FXSelector,void*);
99  long onCmdSetIntValue(FXObject*,FXSelector,void*);
100  long onCmdGetIntValue(FXObject*,FXSelector,void*);
101 public:
102 
103  /// Construct button with text and icon
105 
106  /// Returns true because a button can receive focus
107  virtual bool canFocus() const;
108 
109  /// Move the focus to this window
110  virtual void setFocus();
111 
112  /// Remove the focus from this window
113  virtual void killFocus();
114 
115  /// Set as default button
116  virtual void setDefault(FXbool enable=TRUE);
117 
118  /// Set the button state
119  void setState(FXuint s);
120 
121  /// Get the button state
122  FXuint getState() const { return state; }
123 
124  /// Set the button style flags
125  void setButtonStyle(FXuint style);
126 
127  /// Get the button style flags
128  FXuint getButtonStyle() const;
129 
130  };
131 
132 }
133 
134 #endif
Same as STATE_UP (used for check buttons or radio buttons)
Definition: FXButton.h:42
Button is up.
Definition: FXButton.h:39
Automatically gray out when not updated.
Definition: FXButton.h:53
Button is engaged.
Definition: FXButton.h:41
#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
Same as STATE_ENGAGED (used for check buttons or radio buttons)
Definition: FXButton.h:43
This button is the initial default button.
Definition: FXButton.h:57
Definition: FXFrame.h:56
FXuint FXSelector
Association key.
Definition: FXObject.h:53
A button provides a push button, with optional icon and/or text label.
Definition: FXButton.h:85
#define FXAPI
Definition: fxdefs.h:122
FXuchar FXbool
Definition: fxdefs.h:393
Definition: FXButton.h:58
Base composite.
Definition: FXComposite.h:35
#define NULL
Definition: fxdefs.h:41
Button is down.
Definition: FXButton.h:40
Automatically hide button when not updated.
Definition: FXButton.h:54
Toolbar style button [flat look].
Definition: FXButton.h:55
int FXint
Definition: fxdefs.h:397
An Icon is an image with two additional server-side resources: a shape bitmap, which is used to mask ...
Definition: FXIcon.h:45
May become default button when receiving focus.
Definition: FXButton.h:56
Raised border.
Definition: FXWindow.h:77
Object is the base class for all objects in FOX; in order to receive messages from the user interface...
Definition: FXObject.h:166
unsigned char FXuchar
Definition: fxdefs.h:392
Thick border.
Definition: FXWindow.h:78
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