#include <YMenuButton.h>
Inheritance diagram for YMenuButton:

Public Member Functions | |
| YMenuButton (const YWidgetOpt &opt, YCPString label) | |
| virtual char * | widgetClass () |
| YCPValue | changeWidget (const YCPSymbol &property, const YCPValue &newvalue) |
| YCPValue | queryWidget (const YCPSymbol &property) |
| virtual void | setLabel (const YCPString &label) |
| YCPString | getLabel () |
| YMenu * | getToplevelMenu () |
| void | addMenuItem (const YCPString &item_label, const YCPValue &item_id, YMenu *parent_menu=0) |
| YMenu * | addSubMenu (const YCPString &sub_menu_label, YMenu *parent_menu=0) |
| YCPValue | indexToId (int index) |
| void | resolveShortcutConflicts () |
| virtual void | createMenu ()=0 |
| const char * | shortcutProperty () |
Protected Attributes | |
| YCPString | label |
| int | next_index |
| YMenuItemList | items |
| YMenu * | toplevel_menu |
MenuButton
This is a widget that looks very much like a PushButton, but unlike a PushButton it doesn't immediately start some action but opens a popup menu from where the user can select an item that starts an action. Any item may in turn open a submenu etc.
UserInput() returns the ID of a menu item if one was activated. It will never return the ID of the MenuButton itself.
Style guide hint: Don't overuse this widget. Use it for dialogs that provide lots of actions. Make the most frequently used actions accessible via normal PushButtons. Move less frequently used actions (e.g. "expert" actions) into one or more MenuButtons. Don't nest the popup menus too deep - the deeper the nesting, the more awkward the user interface will be.
You can (and should) provide keybord shortcuts along with the button label as well as for any menu item.
| YMenuButton::YMenuButton | ( | const YWidgetOpt & | opt, | |
| YCPString | label | |||
| ) |
Constructor
| opt | widget options | |
| label | the button label |
| virtual char* YMenuButton::widgetClass | ( | ) | [inline, virtual] |
Returns a descriptive name of this widget class for logging, debugging etc.
Reimplemented from YWidget.
| YCPValue YMenuButton::changeWidget | ( | const YCPSymbol & | property, | |
| const YCPValue & | newvalue | |||
| ) | [virtual] |
Implements the ui command changeWidget for the widget specific properties.
Reimplemented from YWidget.
Implements the ui command changeWidget for the widget specific properties.
Reimplemented from YWidget.
| void YMenuButton::setLabel | ( | const YCPString & | label | ) | [virtual] |
change the label of the push button. Overload this, but call YMenuButton::setLabel at the end of your own function.
| YCPString YMenuButton::getLabel | ( | ) |
Get the current label of the MenuButton entry. This method cannot be overidden. The value of the label cannot be changed other than by calling setLabel, i.e. not by the ui. Therefore setLabel stores the current label in label.
| YMenu* YMenuButton::getToplevelMenu | ( | ) | [inline] |
Get the MenuButton's toplevel menu.
| void YMenuButton::addMenuItem | ( | const YCPString & | item_label, | |
| const YCPValue & | item_id, | |||
| YMenu * | parent_menu = 0 | |||
| ) |
Add one menu item.
Pass 0 for 'parent_menu' to add this item to the MenuButton's toplevel menu.
Add a submenu.
Pass 0 for 'parent_menu' to add this submenu to the MenuButton's toplevel menu.
| YCPValue YMenuButton::indexToId | ( | int | index | ) |
Retrieve the corresponding application ID to an internal menu item index.
| void YMenuButton::resolveShortcutConflicts | ( | ) |
Resolve keyboard shortcut conflicts: Change shortcuts of menu items if there are duplicates in the respective menu level.
This has to be called after all items are added, but before createMenu() (see below).
| virtual void YMenuButton::createMenu | ( | ) | [pure virtual] |
Actually create the menu hierarchy in the specific UI. This is called when the complete menu hierarchy is known.
Overwrite this method.
| const char* YMenuButton::shortcutProperty | ( | ) | [inline, virtual] |
YCPString YMenuButton::label [protected] |
The button label
int YMenuButton::next_index [protected] |
The next ( free ) item ID to use
YMenuItemList YMenuButton::items [protected] |
List of all items somewhere in the menu hierarchy.
YMenu* YMenuButton::toplevel_menu [protected] |
The top level menu
1.5.0