fltk::PopupMenu Class Reference

Inherits fltk::Menu.

List of all members.

Public Member Functions

int handle (int)
int popup ()

Static Public Attributes

static NamedStyledefault_style = &::style

Protected Member Functions

void draw ()

Detailed Description

This subclass pops up a menu in response to a user click. The menu is popped up positioned so that the mouse is pointing at the last-selected item, even if it in a nested submenu (To turn off this behaivor do value(-1) after each item is selected)

menu_button.gif

Normally any mouse button will pop up a menu and it is lined up above the button, or below it when there is no previous selected value as shown in the picture.

However a PopupMenu can also have type() set to POPUP1, POPUP2, POPUP12, POPUP3, POPUP13, POPUP23, or POPUP123. It then becomes invisible and ignores all mouse buttons other than the ones named in the popup type. You can then resize it to cover another widget (or many widgets) so that pressing that button pops up the menu.

The menu will also pop up in response to shortcuts indicated by the shortcut() or by putting '&x' in the label().

Typing the fltk::Widget::shortcut() of any menu items will cause it to be picked. The callback will be done but there will be no visible effect to the widget.


Member Function Documentation

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

The little down-arrow indicator can be replaced by setting a new glyph() function and making it draw whatever you want. If you don't want any glyph at all it is probably easiest to subclass and replace draw() with your own function.

Reimplemented from fltk::Group.

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

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

Reimplemented from fltk::Group.

int PopupMenu::popup ( )

Wrapper for Menu::popup(). For NORMAL PopupMenu this places the menu over the widget. For POPUP ones it uses the mouse position and sets the "title" to the label() if it is not null.


Member Data Documentation

NamedStyle * PopupMenu::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: