|
fltk 1.3.0rc3
About: FLTK (Fast Light Tool Kit) is a cross-platform C++ GUI toolkit for UNIX/Linux (X11), Microsoft Windows, and MacOS X. Release candidate.
SfR Fresh Dox: fltk-1.3.0rc3-source.tar.gz ("inofficial" and yet experimental doxygen-generated source code documentation) ![]() |
Buttons generate callbacks when they are clicked by the user. More...
#include <Fl_Button.H>


Public Member Functions | |
| virtual int | handle (int) |
| Fl_Button (int X, int Y, int W, int H, const char *L=0) | |
| int | value (int v) |
| char | value () const |
| int | set () |
| int | clear () |
| void | setonly () |
| int | shortcut () const |
| void | shortcut (int s) |
| Fl_Boxtype | down_box () const |
| void | down_box (Fl_Boxtype b) |
| void | shortcut (const char *s) |
| (for backwards compatibility) | |
| Fl_Color | down_color () const |
| (for backwards compatibility) | |
| void | down_color (unsigned c) |
| (for backwards compatibility) | |
Protected Member Functions | |
| void | simulate_key_action () |
| virtual void | draw () |
Static Protected Member Functions | |
| static void | key_release_timeout (void *) |
Static Protected Attributes | |
| static Fl_Widget_Tracker * | key_release_tracker = 0 |
Buttons generate callbacks when they are clicked by the user.
You control exactly when and how by changing the values for type() and when(). Buttons can also generate callbacks in response to FL_SHORTCUT events. The button can either have an explicit shortcut(int s) 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 FL_KEYBOARD event.
For an Fl_Button object, the type() call returns one of:
FL_NORMAL_BUTTON (0): value() remains unchanged after button press. FL_TOGGLE_BUTTON: value() is inverted after button press. FL_RADIO_BUTTON: value() is set to 1 after button press, and all other buttons in the current group with type() == FL_RADIO_BUTTON are set to zero.For an Fl_Button object, the following when() values are useful, the default being FL_WHEN_RELEASE:
0: The callback is not done, instead changed() is turned on. FL_WHEN_RELEASE: The callback is done after the user successfully clicks the button, or when a shortcut is typed. FL_WHEN_CHANGED: The callback is done each time the value() changes (when the user pushes and releases the button, and as the mouse is dragged around in and out of the button). Definition at line 84 of file Fl_Button.H.
| Fl_Button::Fl_Button | ( | int | X, |
| int | Y, | ||
| int | W, | ||
| int | H, | ||
| const char * | L = 0 |
||
| ) |
The constructor creates the button using the given position, size and label.
| [in] | X,Y,W,H | position and size of the widget |
| [in] | L | widget label, default is no label |
Definition at line 207 of file Fl_Button.cxx.
References Fl_Widget::box(), down_box(), FL_NO_BOX, FL_UP_BOX, Fl_Widget::set_flag(), and Fl_Widget::SHORTCUT_LABEL.
| int Fl_Button::clear | ( | ) | [inline] |
Same as value(0).
Definition at line 122 of file Fl_Button.H.
References value.
Referenced by align_cb().
| Fl_Boxtype Fl_Button::down_box | ( | ) | const [inline] |
Returns the current down box type, which is drawn when value() is non-zero.
| Fl_Boxtype |
Definition at line 157 of file Fl_Button.H.
Referenced by Fl_Widget_Type::copy_properties(), Fl_Return_Button::draw(), Fl_Light_Button::draw(), draw(), Fl_Button(), Fl_Check_Button::Fl_Check_Button(), Fl_File_Chooser::Fl_File_Chooser(), Fl_Round_Button::Fl_Round_Button(), make_layout_window(), make_print_panel(), make_project_window(), make_settings_window(), make_shell_window(), Fl_Widget_Type::write_properties(), and Fl_Widget_Type::write_widget_code().
| void Fl_Button::down_box | ( | Fl_Boxtype | b | ) | [inline] |
Sets the down box type. The default value of 0 causes FLTK to figure out the correct matching down version of box().
| [in] | b | down box type |
Definition at line 164 of file Fl_Button.H.
References b.
| void Fl_Button::down_color | ( | unsigned | c | ) | [inline] |
(for backwards compatibility)
Definition at line 173 of file Fl_Button.H.
References Fl_Widget::selection_color().
| Fl_Color Fl_Button::down_color | ( | ) | const [inline] |
(for backwards compatibility)
Definition at line 170 of file Fl_Button.H.
References Fl_Widget::selection_color().
| void Fl_Button::draw | ( | ) | [protected, virtual] |
Draws the widget. Never call this function directly. FLTK will schedule redrawing whenever needed. If your widget must be redrawn as soon as possible, call redraw() instead.
Override this function to draw your own widgets.
If you ever need to call another widget's draw method from within your own draw() method, e.g. for an embedded scrollbar, you can do it (because draw() is virtual) like this:
Fl_Widget *s = &scroll; // scroll is an embedded Fl_Scrollbar s->draw(); // calls Fl_Scrollbar::draw()
Implements Fl_Widget.
Reimplemented in Fl_Light_Button, Fl_Return_Button, and Shortcut_Button.
Definition at line 75 of file Fl_Button.cxx.
References Fl_Widget::box(), Fl_Widget::color(), down_box(), Fl_Widget::draw_backdrop(), Fl_Widget::draw_box(), Fl_Widget::draw_focus(), Fl_Widget::draw_label(), fl_contrast(), fl_down(), FL_HIDDEN_BUTTON, FL_NORMAL_LABEL, Fl::focus(), Fl_Widget::labelcolor(), Fl_Widget::labeltype(), Fl_Widget::selection_color(), Fl_Widget::type(), and value().
| int Fl_Button::handle | ( | int | event | ) | [virtual] |
Handles the specified event. You normally don't call this method directly, but instead let FLTK do it when the user interacts with the widget.
When implemented in a widget, this function must return 0 if the widget does not use the event or 1 otherwise.
Most of the time, you want to call the inherited handle() method in your overridden method so that you don't short-circuit events that you don't handle. In this last case you should return the callee retval.
| [in] | event | the kind of event received |
| 0 | if the event was not used or understood |
| 1 | if the event was used and can be deleted |
Reimplemented from Fl_Widget.
Reimplemented in Fl_Light_Button, Fl_Repeat_Button, Fl_Return_Button, and Shortcut_Button.
Definition at line 89 of file Fl_Button.cxx.
References Fl_Widget::box(), Fl_Widget::clear_changed(), Fl_Widget::damage(), Fl_Widget_Tracker::deleted(), Fl_Widget::do_callback(), Fl::event_inside(), Fl::event_key(), Fl::event_state(), FL_ALT, FL_CTRL, FL_DAMAGE_ALL, FL_DRAG, FL_ENTER, FL_FOCUS, FL_KEYBOARD, FL_LEAVE, FL_META, FL_NO_BOX, FL_PUSH, FL_RADIO_BUTTON, FL_RELEASE, FL_SHIFT, FL_SHORTCUT, FL_TOGGLE_BUTTON, FL_UNFOCUS, FL_WHEN_CHANGED, FL_WHEN_NOT_CHANGED, FL_WHEN_RELEASE, Fl::focus(), Fl_Widget::h(), Fl_Widget::redraw(), Fl_Widget::set_changed(), setonly(), shortcut(), simulate_key_action(), Fl_Widget::test_shortcut(), Fl::test_shortcut(), Fl_Widget::type(), value(), Fl::visible_focus(), Fl_Widget::w(), Fl_Widget::when(), Fl_Widget::window(), Fl_Widget::x(), and Fl_Widget::y().
| void Fl_Button::key_release_timeout | ( | void * | d | ) | [static, protected] |
Definition at line 187 of file Fl_Button.cxx.
References key_release_tracker, Fl_Widget::redraw(), value(), and Fl_Widget_Tracker::widget().
Referenced by simulate_key_action().
| int Fl_Button::set | ( | ) | [inline] |
Same as value(1).
Definition at line 116 of file Fl_Button.H.
References value.
| void Fl_Button::setonly | ( | ) |
Turns on this button and turns off all other radio buttons in the group (calling value(1) or set() does not do this).
Definition at line 65 of file Fl_Button.cxx.
References Fl_Group::array(), Fl_Group::children(), FL_RADIO_BUTTON, i, Fl_Widget::parent(), Fl_Widget::type(), and value().
Referenced by default_widget_size_cb(), handle(), print_menu_cb(), print_update_status(), show_grid_cb(), and Fl_PostScript_Printer::start_job().
| void Fl_Button::shortcut | ( | const char * | s | ) | [inline] |
(for backwards compatibility)
Definition at line 167 of file Fl_Button.H.
References fl_old_shortcut(), and shortcut().
Referenced by shortcut().
| void Fl_Button::shortcut | ( | int | s | ) | [inline] |
Sets the shortcut key to s. Setting this overrides the use of '&' in the label(). The value is a bitwise OR of a key and a set of shift flags, for example: FL_ALT | 'a', or FL_ALT | (FL_F + 10), or just 'a'. A value of 0 disables the shortcut.
The key can be any value returned by Fl::event_key(), but will usually be an ASCII letter. Use a lower-case letter unless you require the shift key to be held down.
The shift flags can be any set of values accepted by Fl::event_state(). If the bit is on, that shift key must be pushed. Meta, Alt, Ctrl, and Shift must be off if they are not in the shift flags (zero for the other bits indicates a "don't care" setting).
| [in] | s | bitwise OR of key and shift flags |
Definition at line 151 of file Fl_Button.H.
| int Fl_Button::shortcut | ( | ) | const [inline] |
Returns the current shortcut key for the button.
| int |
Definition at line 130 of file Fl_Button.H.
Referenced by Fl_Widget_Type::copy_properties(), Fl_File_Chooser::Fl_File_Chooser(), Fl_Help_Dialog::Fl_Help_Dialog(), handle(), make_class_panel(), make_code_panel(), make_codeblock_panel(), make_comment_panel(), make_data_panel(), make_decl_panel(), make_declblock_panel(), make_function_panel(), shortcut_in_cb(), and Fl_Widget_Type::write_properties().
| void Fl_Button::simulate_key_action | ( | ) | [protected] |
Definition at line 175 of file Fl_Button.cxx.
References Fl::add_timeout(), key_release_timeout(), key_release_tracker, Fl_Widget::redraw(), Fl::remove_timeout(), and value().
Referenced by Fl_Return_Button::handle(), and handle().
| int Fl_Button::value | ( | int | v | ) |
Sets the current value of the button. A non-zero value sets the button to 1 (ON), and zero sets it to 0 (OFF).
| [in] | v | button value. |
Definition at line 47 of file Fl_Button.cxx.
References Fl_Widget::box(), Fl_Widget::clear_changed(), Fl_Widget::redraw(), and Fl_Widget::redraw_label().
Referenced by active_cb(), align_cb(), border_cb(), Fl_Widget_Type::copy_properties(), exit_cb(), Fl_File_Chooser::Fl_File_Chooser(), guides_cb(), hotspot_cb(), include_H_from_C_button_cb(), key_release_timeout(), live_mode_cb(), main(), make_print_panel(), make_settings_window(), make_shell_window(), modal_cb(), non_modal_cb(), Fl_Class_Type::open(), Fl_Comment_Type::open(), Fl_Function_Type::open(), position_window(), Fl_File_Chooser::preview(), print_cb(), Fl_File_Chooser::rescan_keep_filename(), resizable_cb(), set_modflag(), Fl_Native_File_Chooser::show(), show_grid_cb(), show_project_cb(), Fl_PostScript_Printer::start_job(), toggle_sourceview_cb(), update_sourceview_position(), use_FL_COMMAND_button_cb(), visible_cb(), wc_relative_cb(), when_button_cb(), write_cb(), Fl_Widget_Type::write_properties(), write_strings_cb(), and Fl_Widget_Type::write_widget_code().
| char Fl_Button::value | ( | ) | const [inline] |
Returns the current value of the button (0 or 1).
Definition at line 110 of file Fl_Button.H.
Referenced by Fl_Return_Button::draw(), Fl_Light_Button::draw(), draw(), Shortcut_Button::draw(), Fl_Repeat_Button::handle(), handle(), Shortcut_Button::handle(), setonly(), and simulate_key_action().
Fl_Widget_Tracker * Fl_Button::key_release_tracker = 0 [static, protected] |
Definition at line 93 of file Fl_Button.H.
Referenced by key_release_timeout(), and simulate_key_action().