Notation used in Ruby API documentation
Module: lay
Description: An abstraction for the application menus
The abstract menu is a class that stores a main menu and several popup menus in a generic form such that they can be manipulated and converted into GUI objects.
Each item can be associated with a Action, which delivers a title, enabled/disable state etc. The Action is either provided when new entries are inserted or created upon initialisation.
The abstract menu class provides methods to manipulate the menu structure (the state of the menu items, their title and shortcut key is provided and manipulated through the Action object).
Menu items and submenus are referred to by a "path". The path is a string with this interpretation:
"" | is the root |
"[<path>.]<name>" | is an element of the submenu given by <path>. If <path> is omitted, this refers to an element in the root |
"[<path>.]end" | refers to the item past the last item of the submenu given by <path> or root |
"[<path>.]begin" | refers to the first item of the submenu given by <path> or root |
"[<path>.]#<n>" | refers to the nth item of the submenu given by <path> or root (n is an integer number) |
Menu items can be put into groups. The path strings of each group can be obtained with the "group" method. An item is put into a group by appending ":<group-name>" to the item's name. This specification can be used several times.
Detached menus (i.e. for use in context menus) can be created as virtual top-level submenus with a name of the form "@<name>". A special detached menu is "@toolbar" which represents the tool bar of the main window. Menus are closely related to the Action class. Actions are used to represent selectable items inside menus, provide the title and other configuration settings. Actions also link the menu items with code. See the Action class description for further details.
[const] | AbstractMenu ptr | _const_cast | Returns a non-const reference to self. | |
void | _create | Ensures the C++ object is created | ||
void | _destroy | Explicitly destroys the object | ||
[const] | bool | _destroyed? | Returns a value indicating whether the object was already destroyed | |
[const] | bool | _is_const_object? | Returns a value indicating whether the reference is a const reference | |
void | _manage | Marks the object as managed by the script side. | ||
void | _unmanage | Marks the object as no longer owned by the script side. | ||
Action ptr | action | (string path) | Gets the reference to a Action object associated with the given path | |
void | clear_menu | (string path) | Deletes the children of the item given by the path | |
void | delete_item | (string path) | Deletes the item given by the path | |
[const] | string[] | group | (string group) | Gets the group members |
void | insert_item | (string path, string name, const Action ptr action) | Inserts a new item before the one given by the path | |
void | insert_menu | (string path, string name, string title) | Inserts a new submenu before the item given by the path | |
void | insert_menu | (string path, string name, Action ptr action) | Inserts a new submenu before the item given by the path | |
void | insert_separator | (string path, string name) | Inserts a new separator before the item given by the path | |
[const] | bool | is_menu? | (string path) | Returns true if the item is a menu |
[const] | bool | is_separator? | (string path) | Returns true if the item is a separator |
[const] | bool | is_valid? | (string path) | Returns true if the path is a valid one |
[const] | string[] | items | (string path) | Gets the subitems for a given submenu |
string | pack_key_binding | (map<string,string> path_to_keys) | Serializes a key binding definition into a single string | |
string | pack_menu_items_hidden | (map<string,bool> path_to_visibility) | Serializes a menu item visibility definition into a single string | |
map<string,string> | unpack_key_binding | (string s) | Deserializes a key binding definition | |
map<string,bool> | unpack_menu_items_hidden | (string s) | Deserializes a menu item visibility definition |
void | create | Use of this method is deprecated. Use _create instead | ||
void | destroy | Use of this method is deprecated. Use _destroy instead | ||
[const] | bool | destroyed? | Use of this method is deprecated. Use _destroyed? instead | |
[const] | bool | is_const_object? | Use of this method is deprecated. Use _is_const_object? instead |
_const_cast | Signature: [const] AbstractMenu ptr _const_cast Description: Returns a non-const reference to self. Basically, this method allows turning a const object reference to a non-const one. This method is provided as last resort to remove the constness from an object. Usually there is a good reason for a const object reference, so using this method may have undesired side effects. This method has been introduced in version 0.29.6. | ||||||
_create | Signature: void _create Description: Ensures the C++ object is created Use this method to ensure the C++ object is created, for example to ensure that resources are allocated. Usually C++ objects are created on demand and not necessarily when the script object is created. | ||||||
_destroy | Signature: void _destroy Description: Explicitly destroys the object Explicitly destroys the object on C++ side if it was owned by the script interpreter. Subsequent access to this object will throw an exception. If the object is not owned by the script, this method will do nothing. | ||||||
_destroyed? | Signature: [const] bool _destroyed? Description: Returns a value indicating whether the object was already destroyed This method returns true, if the object was destroyed, either explicitly or by the C++ side. The latter may happen, if the object is owned by a C++ object which got destroyed itself. | ||||||
_is_const_object? | Signature: [const] bool _is_const_object? Description: Returns a value indicating whether the reference is a const reference This method returns true, if self is a const reference. In that case, only const methods may be called on self. | ||||||
_manage | Signature: void _manage Description: Marks the object as managed by the script side. After calling this method on an object, the script side will be responsible for the management of the object. This method may be called if an object is returned from a C++ function and the object is known not to be owned by any C++ instance. If necessary, the script side may delete the object if the script's reference is no longer required. Usually it's not required to call this method. It has been introduced in version 0.24. | ||||||
_unmanage | Signature: void _unmanage Description: Marks the object as no longer owned by the script side. Calling this method will make this object no longer owned by the script's memory management. Instead, the object must be managed in some other way. Usually this method may be called if it is known that some C++ object holds and manages this object. Technically speaking, this method will turn the script's reference into a weak reference. After the script engine decides to delete the reference, the object itself will still exist. If the object is not managed otherwise, memory leaks will occur. Usually it's not required to call this method. It has been introduced in version 0.24. | ||||||
action | Signature: Action ptr action (string path) Description: Gets the reference to a Action object associated with the given path
| ||||||
clear_menu | Signature: void clear_menu (string path) Description: Deletes the children of the item given by the path
This method has been introduced in version 0.28. | ||||||
create | Signature: void create Description: Ensures the C++ object is created Use of this method is deprecated. Use _create instead Use this method to ensure the C++ object is created, for example to ensure that resources are allocated. Usually C++ objects are created on demand and not necessarily when the script object is created. | ||||||
delete_item | Signature: void delete_item (string path) Description: Deletes the item given by the path
This method will also delete all children of the given item. To clear the children only, use clear_menu. | ||||||
destroy | Signature: void destroy Description: Explicitly destroys the object Use of this method is deprecated. Use _destroy instead Explicitly destroys the object on C++ side if it was owned by the script interpreter. Subsequent access to this object will throw an exception. If the object is not owned by the script, this method will do nothing. | ||||||
destroyed? | Signature: [const] bool destroyed? Description: Returns a value indicating whether the object was already destroyed Use of this method is deprecated. Use _destroyed? instead This method returns true, if the object was destroyed, either explicitly or by the C++ side. The latter may happen, if the object is owned by a C++ object which got destroyed itself. | ||||||
group | Signature: [const] string[] group (string group) Description: Gets the group members
| ||||||
insert_item | Signature: void insert_item (string path, string name, const Action ptr action) Description: Inserts a new item before the one given by the path
The Action object passed as the third parameter references the handler which both implements the action to perform and the menu item's appearance such as title, icon and keyboard shortcut. | ||||||
insert_menu | (1) Signature: void insert_menu (string path, string name, string title) Description: Inserts a new submenu before the item given by the path
The title string optionally encodes the key shortcut and icon resource in the form <text>["("<shortcut>")"]["<"<icon-resource>">"]. | ||||||
(2) Signature: void insert_menu (string path, string name, Action ptr action) Description: Inserts a new submenu before the item given by the path
This method variant has been added in version 0.28. | |||||||
insert_separator | Signature: void insert_separator (string path, string name) Description: Inserts a new separator before the item given by the path
| ||||||
is_const_object? | Signature: [const] bool is_const_object? Description: Returns a value indicating whether the reference is a const reference Use of this method is deprecated. Use _is_const_object? instead This method returns true, if self is a const reference. In that case, only const methods may be called on self. | ||||||
is_menu? | Signature: [const] bool is_menu? (string path) Description: Returns true if the item is a menu
| ||||||
is_separator? | Signature: [const] bool is_separator? (string path) Description: Returns true if the item is a separator
This method has been introduced in version 0.19. | ||||||
is_valid? | Signature: [const] bool is_valid? (string path) Description: Returns true if the path is a valid one
| ||||||
items | Signature: [const] string[] items (string path) Description: Gets the subitems for a given submenu
| ||||||
pack_key_binding | Signature: [static] string pack_key_binding (map<string,string> path_to_keys) Description: Serializes a key binding definition into a single string The serialized format is used by the 'key-bindings' config key. This method will take an array of path/key definitions (including the Action#NoKeyBound option) and convert it to a single string suitable for assigning to the config key. This method has been introduced in version 0.26. | ||||||
pack_menu_items_hidden | Signature: [static] string pack_menu_items_hidden (map<string,bool> path_to_visibility) Description: Serializes a menu item visibility definition into a single string The serialized format is used by the 'menu-items-hidden' config key. This method will take an array of path/visibility flag definitions and convert it to a single string suitable for assigning to the config key. This method has been introduced in version 0.26. | ||||||
unpack_key_binding | Signature: [static] map<string,string> unpack_key_binding (string s) Description: Deserializes a key binding definition This method is the reverse of pack_key_binding. This method has been introduced in version 0.26. | ||||||
unpack_menu_items_hidden | Signature: [static] map<string,bool> unpack_menu_items_hidden (string s) Description: Deserializes a menu item visibility definition This method is the reverse of pack_menu_items_hidden. This method has been introduced in version 0.26. |