libyui
|
#include <YMenuWidget.h>
Abstract base class for widgets that handle menus, e.g. YMenuButton or YMenuBar.
Constructor.
'label' is only passed through to the inherited class. For a menu button, this would be the label on the button; a menu bar does not have a label.
|
virtual |
Destructor.
Support for the Rest API for UI testing:
Activate the item selected in the tree. This can be used in tests to simulate user input.
Derived classes are required to implement this.
Add one item. This widget assumes ownership of the item object and will delete it in its destructor.
This reimplementation will assign an index to the item that is unique for all items in this MenuButton. That index can be used later with findMenuItem() to find the item by that index.
Reimplemented from YSelectionWidget.
Reimplemented from YSelectionWidget.
Reimplemented in YMenuButton.
|
virtual |
Add multiple items. For some UIs, this can be more efficient than calling addItem() multiple times. This function also automatically calls resolveShortcutConflicts() and rebuildMenuTree() at the end.
Derived classes can overwrite this function, but they should call this base class function at the end of the new implementation.
Reimplemented from YSelectionWidget.
Reimplemented from YSelectionWidget.
|
protected |
Assign a unique index to all items from iterator 'begin' to iterator 'end'.
|
virtual |
YMenuItem * YMenuWidget::findItem | ( | std::vector< std::string > & | path | ) | const |
Support for the Rest API for UI testing:
Return the item in the tree which matches a path of labels. This returns 0 if there is no such item or if it is not a leaf menu item.
'path' specifies the user-visible labels (i.e. the translated texts) of each menu level ( ["File", "Export", "As XML"] ).
|
protected |
Recursively looks for the first item in the tree of the menu items using depth first search. Return nullptr if item which matches full path is not found. Path is a vector of strings, where next element is a child item, so in case one needs to select File->Export->As PDF, for instance, Vector will look like [ "File", "Export", "As PDF" ].
Recursively find the first menu item with the specified index. Returns 0 if there is no such item.
|
protected |
Recursively find the first menu item with the specified index from iterator 'begin' to iterator 'end'.
Returns 0 if there is no such item.
Alias for findMenuItem(). Reimplemented to ensure consistent behaviour with YSelectionWidget::itemAt().
Rebuild the displayed menu tree from the internally stored YMenuItems.
The application should call this (once) after all items have been added with addItem(). YMenuButton::addItems() calls this automatically.
Derived classes are required to implement this.
void YMenuWidget::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 rebuildMenuTree() (see above). YMenuWidget::addItems() calls this automatically.
|
protected |
Resolve keyboard shortcut conflicts between iterators 'begin' and 'end'.
Enable or disable an item. This default implementation only updates the item's 'enabled' field.
Derived classes should overwrite this method and either update the item's 'enabled' field in their implementation or call this default implementation.
Show or hide an item. This default implementation only updates the item's 'visible' field.
Derived classes should overwrite this method and either update the item's 'visible' field in their implementation or call this default implementation.
Returns a descriptive name of this widget class for logging, debugging etc.
Reimplemented from YSelectionWidget.
Reimplemented in YMenuBar, and YMenuButton.