fltk::MenuBar 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

Subclass of fltk::Menu. The top level menu items are visible and drawn in a horizontal row. Put this at the top edge of your window and you get a typical menubar.

You can call popup() on this same widget in response to a right-click in your work area and you will get the exact same menu as a vertical pop up menu.


Member Function Documentation

void MenuBar::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 MenuBar::handle ( int  event) [virtual]

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

Reimplemented from fltk::Group.


Member Data Documentation

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