FLTK 1.4.0
Fl_Button.H
1 //
2 // Button header file for the Fast Light Tool Kit (FLTK).
3 //
4 // Copyright 1998-2014 by Bill Spitzak and others.
5 //
6 // This library is free software. Distribution and use rights are outlined in
7 // the file "COPYING" which should have been included with this file. If this
8 // file is missing or damaged, see the license at:
9 //
10 // https://www.fltk.org/COPYING.php
11 //
12 // Please see the following page on how to report bugs and issues:
13 //
14 // https://www.fltk.org/bugs.php
15 //
16 
17 /* \file
18  Fl_Button widget . */
19 
20 #ifndef Fl_Button_H
21 #define Fl_Button_H
22 
23 #ifndef Fl_Widget_H
24 #include "Fl_Widget.H"
25 #endif
26 
27 // values for type()
28 #define FL_NORMAL_BUTTON 0
30 #define FL_TOGGLE_BUTTON 1
31 #define FL_RADIO_BUTTON (FL_RESERVED_TYPE+2)
34 #define FL_HIDDEN_BUTTON 3
35 
36 extern FL_EXPORT Fl_Shortcut fl_old_shortcut(const char*);
37 
38 class Fl_Widget_Tracker;
39 
74 class FL_EXPORT Fl_Button : public Fl_Widget {
75 
76  int shortcut_;
77  char value_;
78  char oldval;
79  uchar down_box_;
80 
81 protected:
82 
83  static Fl_Widget_Tracker *key_release_tracker;
84  static void key_release_timeout(void*);
85  void simulate_key_action();
86 
87  virtual void draw();
88 
89 public:
90 
91  virtual int handle(int);
92 
93  Fl_Button(int X, int Y, int W, int H, const char *L = 0);
94 
95  int value(int v);
96 
100  char value() const {return value_;}
101 
106  int set() {return value(1);}
107 
112  int clear() {return value(0);}
113 
114  void setonly(); // this should only be called on FL_RADIO_BUTTONs
115 
120  int shortcut() const {return shortcut_;}
121 
141  void shortcut(int s) {shortcut_ = s;}
142 
147  Fl_Boxtype down_box() const {return (Fl_Boxtype)down_box_;}
148 
158  void down_box(Fl_Boxtype b) {down_box_ = b;}
159 
161  void shortcut(const char *s) {shortcut(fl_old_shortcut(s));}
162 
164  Fl_Color down_color() const {return selection_color();}
165 
167  void down_color(unsigned c) {selection_color(c);}
168 };
169 
170 #endif
unsigned int Fl_Color
An FLTK color value; see also Colors
Definition: Enumerations.H:1042
Fl_Boxtype
FLTK standard box types.
Definition: Enumerations.H:598
Fl_Widget, Fl_Label classes .
Buttons generate callbacks when they are clicked by the user.
Definition: Fl_Button.H:74
int clear()
Same as value(0).
Definition: Fl_Button.H:112
void shortcut(const char *s)
(for backwards compatibility)
Definition: Fl_Button.H:161
Fl_Color down_color() const
(for backwards compatibility)
Definition: Fl_Button.H:164
void down_box(Fl_Boxtype b)
Sets the down box type.
Definition: Fl_Button.H:158
int set()
Same as value(1).
Definition: Fl_Button.H:106
char value() const
Returns the current value of the button (0 or 1).
Definition: Fl_Button.H:100
void shortcut(int s)
Sets the shortcut key to s.
Definition: Fl_Button.H:141
int shortcut() const
Returns the current shortcut key for the button.
Definition: Fl_Button.H:120
Fl_Boxtype down_box() const
Returns the current down box type, which is drawn when value() is non-zero.
Definition: Fl_Button.H:147
void down_color(unsigned c)
(for backwards compatibility)
Definition: Fl_Button.H:167
This class should be used to control safe widget deletion.
Definition: Fl.H:1432
Fl_Widget is the base class for all widgets in FLTK.
Definition: Fl_Widget.H:85
virtual void draw()=0
Draws the widget.
virtual int handle(int event)
Handles the specified event.
Definition: Fl_Widget.cxx:102
Fl_Color selection_color() const
Gets the selection color.
Definition: Fl_Widget.H:402
unsigned int Fl_Shortcut
16-bit Unicode character + 8-bit indicator for keyboard flags.
Definition: fl_types.h:53
unsigned char uchar
unsigned char
Definition: fl_types.h:28
FL_EXPORT unsigned int fl_old_shortcut(const char *s)
Emulation of XForms named shortcuts.
Definition: fl_shortcut.cxx:273