Inherits fltk::Widget.
Inherited by BButton, fltk::CheckButton, fltk::HighlightButton, fltk::RepeatButton, fltk::ReturnButton, and fltk::ToggleButton.
Public Types | |
enum | { HIDDEN = 3 } |
Public Member Functions | |
Button (int, int, int, int, const char *=0) | |
void | draw (int glyph_width) const |
virtual void | draw () |
int | handle (int event, const Rectangle &) |
int | handle (int) |
bool | value () const |
bool | value (bool v) |
Static Public Attributes | |
static NamedStyle * | default_style = &::style |
Buttons generate callbacks when they are clicked by the user. You control exactly when and how by changing the values for when():
Buttons can also generate callbacks in response to fltk::SHORTCUT events. The button can either have an explicit shortcut() value or a letter shortcut can be indicated in the label() with an '&' character before it. For the label shortcut it does not matter if Alt is held down, but if you have an input field in the same window, the user will have to hold down the Alt key so that the input field does not eat the event first as an fltk::KEY event.
anonymous enum |
Button::Button | ( | int | x, |
int | y, | ||
int | w, | ||
int | h, | ||
const char * | l = 0 |
||
) |
void Button::draw | ( | void | ) | [virtual] |
The virtual draw() function makes sure the button isn't hidden, then calls Button::draw(int glyph_width) with a width of 0
Reimplemented from fltk::Widget.
Reimplemented in fltk::CheckButton, and fltk::ReturnButton.
void Button::draw | ( | int | glyph_width | ) | const |
This function provides a mess of back-compatabilty and Windows emulation to subclasses of Button to draw with. It will draw the button according to the current state of being pushed and it's state().
glyph_width | If non-zero is passed for glyph_width then the glyph() is drawn in that space on the left (or on the right if negative), and it assummes the glyph indicates the state(), so the box is only used to indicate the pushed state. |
int Button::handle | ( | int | event, |
const Rectangle & | rectangle | ||
) |
The Button's own handle function. See Widget::handle
event | The event to handle |
rectangle | The rectangle this event occurred within. You can change this value, or inspect it in a subclass, to determine what you want your button to do if the user clicks on different sections |
int Button::handle | ( | int | event | ) | [virtual] |
Wrapper around Button::handle(int event, const Rectangle& rectangle)
event | The event that this button has received |
Reimplemented from fltk::Widget.
Reimplemented in fltk::RepeatButton.
bool Button::value | ( | ) | const [inline] |
The current value. The ToggleButton subclass provides the ability for the user to change this value permanently, otherwise it is just temporary while the user is holding the button down.
This is the same as Widget::state().
bool Button::value | ( | bool | v | ) | [inline] |
Changes the value() and redraws the button. This is the same function as Widget::state(). See also Widget::set(), Widget::clear(), and Widget::setonly().
v | The new value for the button; true for pushed down, false for not pushed down. If you pass "true" as the value, a normal button will draw pushed-in, until the user clicks it and releases it. |
NamedStyle * Button::default_style = &::style [static] |
This sets the Button's default style to one with no revert function It thus inherits its style from the "default" style and from Group::default_style
Reimplemented from fltk::Widget.
Reimplemented in fltk::CheckButton, fltk::HighlightButton, fltk::LightButton, fltk::RadioButton, and fltk::ReturnButton.