FLTK 1.3.8
Fl_Button.H
1 //
2 // "$Id$"
3 //
4 // Button header file for the Fast Light Tool Kit (FLTK).
5 //
6 // Copyright 1998-2014 by Bill Spitzak and others.
7 //
8 // This library is free software. Distribution and use rights are outlined in
9 // the file "COPYING" which should have been included with this file. If this
10 // file is missing or damaged, see the license at:
11 //
12 // http://www.fltk.org/COPYING.php
13 //
14 // Please report all bugs and problems on the following page:
15 //
16 // http://www.fltk.org/str.php
17 //
18 
19 /* \file
20  Fl_Button widget . */
21 
22 #ifndef Fl_Button_H
23 #define Fl_Button_H
24 
25 #ifndef Fl_Widget_H
26 #include "Fl_Widget.H"
27 #endif
28 
29 // values for type()
30 #define FL_NORMAL_BUTTON 0
32 #define FL_TOGGLE_BUTTON 1
33 #define FL_RADIO_BUTTON (FL_RESERVED_TYPE+2)
36 #define FL_HIDDEN_BUTTON 3
37 
38 extern FL_EXPORT Fl_Shortcut fl_old_shortcut(const char*);
39 
40 class Fl_Widget_Tracker;
41 
76 class FL_EXPORT Fl_Button : public Fl_Widget {
77 
78  int shortcut_;
79  char value_;
80  char oldval;
81  uchar down_box_;
82 
83 protected:
84 
85  static Fl_Widget_Tracker *key_release_tracker;
86  static void key_release_timeout(void*);
87  void simulate_key_action();
88 
89  virtual void draw();
90 
91 public:
92 
93  virtual int handle(int);
94 
95  Fl_Button(int X, int Y, int W, int H, const char *L = 0);
96 
97  int value(int v);
98 
102  char value() const {return value_;}
103 
108  int set() {return value(1);}
109 
114  int clear() {return value(0);}
115 
116  void setonly(); // this should only be called on FL_RADIO_BUTTONs
117 
122  int shortcut() const {return shortcut_;}
123 
143  void shortcut(int s) {shortcut_ = s;}
144 
149  Fl_Boxtype down_box() const {return (Fl_Boxtype)down_box_;}
150 
160  void down_box(Fl_Boxtype b) {down_box_ = b;}
161 
163  void shortcut(const char *s) {shortcut(fl_old_shortcut(s));}
164 
166  Fl_Color down_color() const {return selection_color();}
167 
169  void down_color(unsigned c) {selection_color(c);}
170 };
171 
172 #endif
173 
174 //
175 // End of "$Id$".
176 //
unsigned int Fl_Color
An FLTK color value; see also Colors
Definition: Enumerations.H:932
Fl_Boxtype
Definition: Enumerations.H:601
Fl_Widget, Fl_Label classes .
Buttons generate callbacks when they are clicked by the user.
Definition: Fl_Button.H:76
int clear()
Same as value(0).
Definition: Fl_Button.H:114
void shortcut(const char *s)
(for backwards compatibility)
Definition: Fl_Button.H:163
Fl_Color down_color() const
(for backwards compatibility)
Definition: Fl_Button.H:166
void down_box(Fl_Boxtype b)
Sets the down box type.
Definition: Fl_Button.H:160
int set()
Same as value(1).
Definition: Fl_Button.H:108
char value() const
Returns the current value of the button (0 or 1).
Definition: Fl_Button.H:102
void shortcut(int s)
Sets the shortcut key to s.
Definition: Fl_Button.H:143
int shortcut() const
Returns the current shortcut key for the button.
Definition: Fl_Button.H:122
Fl_Boxtype down_box() const
Returns the current down box type, which is drawn when value() is non-zero.
Definition: Fl_Button.H:149
void down_color(unsigned c)
(for backwards compatibility)
Definition: Fl_Button.H:169
This class should be used to control safe widget deletion.
Definition: Fl.H:1371
Fl_Widget is the base class for all widgets in FLTK.
Definition: Fl_Widget.H:101
virtual void draw()=0
Draws the widget.
virtual int handle(int event)
Handles the specified event.
Definition: Fl_Widget.cxx:112
Fl_Color selection_color() const
Gets the selection color.
Definition: Fl_Widget.H:396
unsigned int Fl_Shortcut
24-bit Unicode character + 8-bit indicator for keyboard flags
Definition: fl_types.h:46
unsigned char uchar
unsigned char
Definition: fl_types.h:30
FL_EXPORT unsigned int fl_old_shortcut(const char *s)
Emulation of XForms named shortcuts.
Definition: fl_shortcut.cxx:396