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)  

Fl_Button Class Reference

Buttons generate callbacks when they are clicked by the user. More...

#include <Fl_Button.H>

Inheritance diagram for Fl_Button:
Collaboration diagram for Fl_Button:

List of all members.

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_Trackerkey_release_tracker = 0

Detailed Description

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.

Todo:
Refactor the doxygen comments for Fl_Button type() documentation.

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.
Todo:
Refactor the doxygen comments for Fl_Button when() documentation.

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.


Constructor & Destructor Documentation

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.

Parameters:
[in]X,Y,W,Hposition and size of the widget
[in]Lwidget 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.


Member Function Documentation

int Fl_Button::clear ( ) [inline]

Same as value(0).

See also:
value(int v)

Definition at line 122 of file Fl_Button.H.

References value.

Referenced by align_cb().

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().

Parameters:
[in]bdown 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.

Parameters:
[in]eventthe kind of event received
Return values:
0if the event was not used or understood
1if the event was used and can be deleted
See also:
Fl_Event

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]
int Fl_Button::set ( ) [inline]

Same as value(1).

See also:
value(int v)

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).

Parameters:
[in]sbitwise OR of key and shift flags

Definition at line 151 of file Fl_Button.H.

void Fl_Button::simulate_key_action ( ) [protected]
char Fl_Button::value ( ) const [inline]

Member Data Documentation

Definition at line 93 of file Fl_Button.H.

Referenced by key_release_timeout(), and simulate_key_action().


The documentation for this class was generated from the following files: