FLTK 1.4.0
Loading...
Searching...
No Matches
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
36extern FL_EXPORT Fl_Shortcut fl_old_shortcut(const char*);
37
39
76class FL_EXPORT Fl_Button : public Fl_Widget {
77
78 int shortcut_;
79 char value_;
80 char oldval;
81 uchar down_box_;
82 uchar compact_;
83
84protected:
85
86 static Fl_Widget_Tracker *key_release_tracker;
87 static void key_release_timeout(void*);
88 void simulate_key_action();
89
90 void draw() FL_OVERRIDE;
91
92public:
93
94 int handle(int) FL_OVERRIDE;
95
96 Fl_Button(int X, int Y, int W, int H, const char *L = 0);
97
98 int value(int v);
99
103 char value() const {return value_;}
104
109 int set() {return value(1);}
110
115 int clear() {return value(0);}
116
117 void setonly(); // this should only be called on FL_RADIO_BUTTONs
118
123 int shortcut() const {return shortcut_;}
124
144 void shortcut(int s) {shortcut_ = s;}
145
150 Fl_Boxtype down_box() const {return (Fl_Boxtype)down_box_;}
151
161 void down_box(Fl_Boxtype b) {down_box_ = b;}
162
164 void shortcut(const char *s) {shortcut(fl_old_shortcut(s));}
165
168
170 void down_color(unsigned c) {selection_color(c);}
171
172 // handle flag for compact buttons, documentation in source code
173 void compact(uchar v);
174
178 uchar compact() { return compact_; }
179};
180
181#endif
unsigned int Fl_Color
An FLTK color value; see also Colors
Definition Enumerations.H:1101
Fl_Boxtype
FLTK standard box types.
Definition Enumerations.H:626
Fl_Widget and Fl_Label classes.
Buttons generate callbacks when they are clicked by the user.
Definition Fl_Button.H:76
uchar compact()
Return true if buttons are rendered as compact buttons.
Definition Fl_Button.H:178
int clear()
Same as value(0).
Definition Fl_Button.H:115
void shortcut(const char *s)
(for backwards compatibility)
Definition Fl_Button.H:164
Fl_Color down_color() const
(for backwards compatibility)
Definition Fl_Button.H:167
void down_box(Fl_Boxtype b)
Sets the down box type.
Definition Fl_Button.H:161
int set()
Same as value(1).
Definition Fl_Button.H:109
char value() const
Returns the current value of the button (0 or 1).
Definition Fl_Button.H:103
void shortcut(int s)
Sets the shortcut key to s.
Definition Fl_Button.H:144
int shortcut() const
Returns the current shortcut key for the button.
Definition Fl_Button.H:123
Fl_Boxtype down_box() const
Returns the current down box type, which is drawn when value() is non-zero.
Definition Fl_Button.H:150
void down_color(unsigned c)
(for backwards compatibility)
Definition Fl_Button.H:170
This class should be used to control safe widget deletion.
Definition Fl.H:1549
Fl_Widget is the base class for all widgets in FLTK.
Definition Fl_Widget.H:104
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:465
#define FL_OVERRIDE
This macro makes it safe to use the C++11 keyword override with older compilers.
Definition fl_attr.h:46
unsigned int Fl_Shortcut
16-bit Unicode character + 8-bit indicator for keyboard flags.
Definition fl_types.h:55
unsigned char uchar
unsigned char
Definition fl_types.h:30