fltk::CycleButton Class Reference

Inherits fltk::Menu.

List of all members.

Public Member Functions

int handle (int)

Static Public Attributes

static NamedStyledefault_style = &::style

Protected Member Functions

void draw ()

Detailed Description

This widget lets the user select one of a set of choices by clicking on it. Each click cycles to the next choice. Holding down any shift key or using the middle or right mouse button cycles backwards.

Notice that the number of items can be 2. In this case this widget serves the common purpose of a "toggle" button that shows the current on/off state by changing it's label.

This is a subclass of Menu. The possible states are defined by using Menu::add() or other methods that define the menu items. You can also put a different callback on each item. Or you can replace this widget's callback with your own and use value() to get the index of the current setting. Items that are not visible() or are not active() are skipped by the cycling.

If you set buttonbox() to NO_BOX then you must define your items to draw identical-sized and fully opaque images, so that drawing one completely obscures any other one. This was done to avoid blinking when drawing "artistic" user interfaces where all the entire button is an image.

Member Function Documentation

void CycleButton::draw ( void  ) [protected, virtual]

Fltk calls this virtual function to draw the widget, after setting up the graphics (current window, xy translation, etc) so that any drawing functions will go into this widget.

User code should not call this! You probably want to call redraw().

The default version calls draw_box() and draw_label(), thus drawing the box() to fill the widget and putting the label() and image() inside it to fill it, unless the align() flags are set to put it outside.

Information on how to write your own version is here.

Reimplemented from fltk::Group.

int CycleButton::handle ( int  event) [virtual]

Calls send() on some or all of the children widgets.

Reimplemented from fltk::Group.

Member Data Documentation

NamedStyle * CycleButton::default_style = &::style [static]

This style is assigned to Menu subclasses.

Because of the need to be compatable with Windows, which has a somewhat inconsistent appearance, the default is different than Widget::default_style, and the usage of the fields is somewhat unusual:

  • The color(), textfont(), textsize(), textcolor() are used to draw each Item in the menu, unless the items set their own preferences. box() defaults to FLAT_BOX and color() defaults to GRAY75 to replicate Windows.
  • The popup menu window itself uses the box() that is stored in MenuWindow::default_style. It is not possible (or at least not easy) to make different popups have different borders.
  • However that box is colored by color(). Thus you can make the color different for each popup menu. This will only be visible if the items have transparent boxes.
  • The leading() is used to space apart the menu items. It defaults to 4 to replicate Windows.
  • buttonbox(), buttoncolor(), labelfont(), labelsize() and labelcolor() are not used. They can be used to draw the actual widget.

The Browser subclass sets the style back to Widget::default_style, so that they appear more like a text editor (ie they put the color and leading back to normal).

Reimplemented from fltk::Menu.

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