Context menu¶
These interfaces are used to implement context menu items for panels and toolbars.
Node¶
-
class menu_node_t : public pfc::refcounted_object_root¶
Menu item interface class.
Remark
Remember, its derived from pfc::refcounted_object_root. So instantiate like:
uie::mode_node_ptr = new menu_node_impl;
Note
Do not derive directly from this; instead derive from either menu_node_command_t, menu_node_popup_t or menu_node_separator_t
Subclassed by uie::menu_hook_impl, uie::menu_node_command_t, uie::menu_node_popup_t, uie::menu_node_separator_t
Public Types
Public Functions
-
virtual type_t get_type() const = 0¶
Retrieves the type of the menu item.
- Returns:
Type of the menu item.
-
virtual t_size get_children_count() const = 0¶
Retrieves the number of child items.
- Pre:
May only return a non-zero value if your item is of type type_popup.
- Returns:
Number of child items.
-
virtual void get_child(t_size index, menu_node_ptr &p_out) const = 0¶
Retrieves child item.
- Parameters:
index – [in] Index of the child item to retrieve
p_out – [out] Receives pointer to the child item
-
virtual bool get_display_data(pfc::string_base &p_out, unsigned &p_state) const = 0¶
Gets display data.
- Parameters:
p_out – [out] Receives display text, utf-8 encoded. Valid only if flag_separator is not specified
p_state – [out] Receives display state, combination of state_t flags.
- Returns:
true iff the item should be displayed
-
virtual bool get_description(pfc::string_base &p_out) const = 0¶
Gets item description.
- Parameters:
p_out – [out] Receives item description, utf-8 encoded.
- Returns:
true iff the item has a description and p_out was set to it
-
virtual void execute() = 0¶
Executes the command. Applicable only for type_command items.
-
virtual type_t get_type() const = 0¶
-
class menu_node_command_t : public uie::menu_node_t¶
Base class for command menu items.
Subclassed by uie::menu_node_configure, uie::simple_command_menu_node
Public Functions
-
inline virtual type_t get_type() const override¶
Retrieves the type of the menu item.
- Returns:
Type of the menu item.
-
inline virtual t_size get_children_count() const override¶
Retrieves the number of child items.
- Pre:
May only return a non-zero value if your item is of type type_popup.
- Returns:
Number of child items.
-
inline virtual void get_child(t_size index, menu_node_ptr &p_out) const override¶
Retrieves child item.
- Parameters:
index – [in] Index of the child item to retrieve
p_out – [out] Receives pointer to the child item
-
inline virtual type_t get_type() const override¶
-
class menu_node_popup_t : public uie::menu_node_t¶
Base class for popup menu items.
Public Functions
-
inline virtual type_t get_type() const override¶
Retrieves the type of the menu item.
- Returns:
Type of the menu item.
-
inline virtual void execute() override¶
Executes the command. Applicable only for type_command items.
-
inline virtual bool get_description(pfc::string_base &p_out) const override¶
Gets item description.
- Parameters:
p_out – [out] Receives item description, utf-8 encoded.
- Returns:
true iff the item has a description and p_out was set to it
-
inline virtual type_t get_type() const override¶
-
class menu_node_separator_t : public uie::menu_node_t¶
Implements menu_node_t as a separator item.
Public Functions
-
inline virtual type_t get_type() const override¶
Retrieves the type of the menu item.
- Returns:
Type of the menu item.
-
inline virtual void execute() override¶
Executes the command. Applicable only for type_command items.
-
inline virtual bool get_description(pfc::string_base &p_out) const override¶
Gets item description.
- Parameters:
p_out – [out] Receives item description, utf-8 encoded.
- Returns:
true iff the item has a description and p_out was set to it
-
inline virtual t_size get_children_count() const override¶
Retrieves the number of child items.
- Pre:
May only return a non-zero value if your item is of type type_popup.
- Returns:
Number of child items.
-
inline virtual bool get_display_data(pfc::string_base &p_out, unsigned &p_displayflags) const override¶
Gets display data.
- Parameters:
p_out – [out] Receives display text, utf-8 encoded. Valid only if flag_separator is not specified
p_state – [out] Receives display state, combination of state_t flags.
- Returns:
true iff the item should be displayed
-
inline virtual void get_child(t_size index, menu_node_ptr &p_out) const override¶
Retrieves child item.
- Parameters:
index – [in] Index of the child item to retrieve
p_out – [out] Receives pointer to the child item
-
inline virtual type_t get_type() const override¶
-
class simple_command_menu_node : public uie::menu_node_command_t¶
Helper class to instantiate simple command menu nodes.
Public Functions
-
inline simple_command_menu_node(const char *display_name, const char *description, uint32_t display_flags, std::function<void()> on_execute)¶
-
inline virtual bool get_display_data(pfc::string_base &p_out, unsigned &p_displayflags) const override¶
Gets display data.
- Parameters:
p_out – [out] Receives display text, utf-8 encoded. Valid only if flag_separator is not specified
p_state – [out] Receives display state, combination of state_t flags.
- Returns:
true iff the item should be displayed
-
inline virtual bool get_description(pfc::string_base &p_out) const override¶
Gets item description.
- Parameters:
p_out – [out] Receives item description, utf-8 encoded.
- Returns:
true iff the item has a description and p_out was set to it
-
inline virtual void execute() override¶
Executes the command. Applicable only for type_command items.
-
inline simple_command_menu_node(const char *display_name, const char *description, uint32_t display_flags, std::function<void()> on_execute)¶
-
class menu_node_configure : public uie::menu_node_command_t¶
Standard implementation of uie::menu_node_command_t, for an “Options” menu item.
Public Functions
-
inline virtual bool get_display_data(pfc::string_base &p_out, unsigned &p_displayflags) const override¶
Gets display data.
- Parameters:
p_out – [out] Receives display text, utf-8 encoded. Valid only if flag_separator is not specified
p_state – [out] Receives display state, combination of state_t flags.
- Returns:
true iff the item should be displayed
-
inline virtual bool get_description(pfc::string_base &p_out) const override¶
Gets item description.
- Parameters:
p_out – [out] Receives item description, utf-8 encoded.
- Returns:
true iff the item has a description and p_out was set to it
-
inline virtual void execute() override¶
Executes the command. Applicable only for type_command items.
-
inline virtual bool get_display_data(pfc::string_base &p_out, unsigned &p_displayflags) const override¶
Node receiver¶
-
class menu_hook_t¶
Class that collects menu_node_t objects.
Subclassed by uie::menu_hook_impl
Public Functions
-
virtual void add_node(const menu_node_ptr &p_node) = 0¶
-
virtual void add_node(const menu_node_ptr &p_node) = 0¶
-
class menu_hook_impl : public uie::menu_hook_t, public uie::menu_node_t¶
Standard implementation of menu_hook_t, also exposes menu_node_t interface.
Remark
Remember, its derived from pfc::refcounted_object_root. So instantiate like:
pfc::refcounted_ptr_t<uie::menu_hook_impl> = new uie::menu_hook_impl;
Public Functions
-
virtual void add_node(const menu_node_ptr &p_node) override¶
-
virtual t_size get_children_count() const override¶
Retrieves the number of child items.
- Pre:
May only return a non-zero value if your item is of type type_popup.
- Returns:
Number of child items.
-
virtual void get_child(t_size p_index, menu_node_ptr &p_out) const override¶
Retrieves child item.
- Parameters:
index – [in] Index of the child item to retrieve
p_out – [out] Receives pointer to the child item
-
virtual type_t get_type() const override¶
Retrieves the type of the menu item.
- Returns:
Type of the menu item.
-
virtual bool get_display_data(pfc::string_base &p_out, unsigned &p_displayflags) const override¶
Gets display data.
- Parameters:
p_out – [out] Receives display text, utf-8 encoded. Valid only if flag_separator is not specified
p_state – [out] Receives display state, combination of state_t flags.
- Returns:
true iff the item should be displayed
-
virtual bool get_description(pfc::string_base &p_out) const override¶
Gets item description.
- Parameters:
p_out – [out] Receives item description, utf-8 encoded.
- Returns:
true iff the item has a description and p_out was set to it
-
virtual void execute() override¶
Executes the command. Applicable only for type_command items.
-
void win32_build_menu(HMENU menu, unsigned base_id, unsigned max_id)¶
-
void execute_by_id(unsigned id_exec)¶
-
virtual void add_node(const menu_node_ptr &p_node) override¶