FLTK 1.3.2
Fl_Button.H
1 //
2 // "$Id: Fl_Button.H 8864 2011-07-19 04:49:30Z greg.ercolano $"
3 //
4 // Button header file for the Fast Light Tool Kit (FLTK).
5 //
6 // Copyright 1998-2010 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 
75 class FL_EXPORT Fl_Button : public Fl_Widget {
76 
77  int shortcut_;
78  char value_;
79  char oldval;
80  uchar down_box_;
81 
82 protected:
83 
84  static Fl_Widget_Tracker *key_release_tracker;
85  static void key_release_timeout(void*);
86  void simulate_key_action();
87 
88  virtual void draw();
89 
90 public:
91 
92  virtual int handle(int);
93 
94  Fl_Button(int X, int Y, int W, int H, const char *L = 0);
95 
96  int value(int v);
97 
101  char value() const {return value_;}
102 
107  int set() {return value(1);}
108 
113  int clear() {return value(0);}
114 
115  void setonly(); // this should only be called on FL_RADIO_BUTTONs
121  int shortcut() const {return shortcut_;}
122 
142  void shortcut(int s) {shortcut_ = s;}
143 
148  Fl_Boxtype down_box() const {return (Fl_Boxtype)down_box_;}
149 
155  void down_box(Fl_Boxtype b) {down_box_ = b;}
156 
158  void shortcut(const char *s) {shortcut(fl_old_shortcut(s));}
159 
161  Fl_Color down_color() const {return selection_color();}
162 
164  void down_color(unsigned c) {selection_color(c);}
165 };
166 
167 #endif
168 
169 //
170 // End of "$Id: Fl_Button.H 8864 2011-07-19 04:49:30Z greg.ercolano $".
171 //
Fl_Widget is the base class for all widgets in FLTK.
Definition: Fl_Widget.H:100
Fl_Color selection_color() const
Gets the selection color.
Definition: Fl_Widget.H:384
virtual int handle(int event)
Handles the specified event.
Definition: Fl_Widget.cxx:97
FL_EXPORT unsigned int fl_old_shortcut(const char *s)
Emulation of XForms named shortcuts.
Definition: fl_shortcut.cxx:275
virtual void draw()=0
Draws the widget.
Fl_Boxtype
Definition: Enumerations.H:469
Fl_Color down_color() const
(for backwards compatibility)
Definition: Fl_Button.H:164
Fl_Widget, Fl_Label classes .
This class should be used to control safe widget deletion.
Definition: Fl.H:1157
unsigned int Fl_Color
an FLTK color value
Definition: Enumerations.H:774
Buttons generate callbacks when they are clicked by the user.
Definition: Fl_Button.H:78
unsigned char uchar
unsigned char
Definition: fl_types.h:30
unsigned int Fl_Shortcut
24-bit Unicode character + 8-bit indicator for keyboard flags
Definition: fl_types.h:46