wex  v20.04.0
Public Types | Public Member Functions | List of all members
wex::menu_item Class Reference

Offers a single menu item. More...

#include <wex/menu-item.h>

Public Types

enum  type_t {
  CHECK, EDIT, EDIT_INVERT, EXIT,
  HISTORY, MENU, PANES, PRINT,
  RADIO, SEPARATOR, SUBMENU, TOOLS,
  VCS
}
 The item types supported. More...
 

Public Member Functions

 menu_item (type_t=SEPARATOR)
 Default constructor, for a SEPARATOR.
 
 menu_item (int id, const std::string &name=std::string(), const std::string &help=std::string(), const wxArtID &art=std::string(), std::function< void(wxCommandEvent &)> action=nullptr, std::function< void(wxUpdateUIEvent &)> ui=nullptr)
 Constructor for a normal MENU item. More...
 
 menu_item (int id, const std::string &name, type_t type, std::function< void(wxCommandEvent &)> action=nullptr, std::function< void(wxUpdateUIEvent &)> ui=nullptr, const std::string &help=std::string())
 Constructor for a checkable item. More...
 
 menu_item (menu *submenu, const std::string &name, const std::string &help=std::string(), int id=wxID_ANY)
 Constructor for a SUBMENU item. More...
 
 menu_item (const path &p, bool show_modal=true)
 Constructor for a VCS submenu item. More...
 
 menu_item (int id, file_history &history, std::function< void(wxUpdateUIEvent &)> ui=nullptr)
 Constructor for HISTORY menu item. More...
 
 menu_item (const managed_frame *frame)
 Constructor for PANES menu items. More...
 
void append (wex::menu *menu) const
 Appends this item(s) to menu.
 
auto id () const
 Returns menu item id.
 
auto & name () const
 Returns menu item name.
 
auto type () const
 Returns menu item type.
 

Detailed Description

Offers a single menu item.

Member Enumeration Documentation

◆ type_t

The item types supported.

Enumerator
CHECK 

a check menu item

EDIT 

edit menu items

EDIT_INVERT 

edit invert menu items

EXIT 

exit menu item

HISTORY 

file_history menu items

MENU 

a normal menu item

PANES 

toggle panes from managaed frame menu items

PRINT 

print menu items

RADIO 

a radio menu item

SEPARATOR 

a separator menu item If previous item was a separator, it ignores this one.

If no items have yet been appended, it ignores this one.

SUBMENU 

a submenu item

TOOLS 

tools menu items

VCS 

vcs menu items

Constructor & Destructor Documentation

◆ menu_item() [1/6]

wex::menu_item::menu_item ( int  id,
const std::string &  name = std::string(),
const std::string &  help = std::string(),
const wxArtID &  art = std::string(),
std::function< void(wxCommandEvent &)>  action = nullptr,
std::function< void(wxUpdateUIEvent &)>  ui = nullptr 
)

Constructor for a normal MENU item.

Parameters
idmenu item id
namemenu name or text
helpmenu help text
artmenu artid
actioncallback for menu action
uicallback for menu update action

◆ menu_item() [2/6]

wex::menu_item::menu_item ( int  id,
const std::string &  name,
type_t  type,
std::function< void(wxCommandEvent &)>  action = nullptr,
std::function< void(wxUpdateUIEvent &)>  ui = nullptr,
const std::string &  help = std::string() 
)

Constructor for a checkable item.

Parameters
idmenu item id
namemenu name or text
typeConstructor for a CHECK or RADIO item.
actioncallback for menu event action
uicallback for menu update action
helpmenu help text

◆ menu_item() [3/6]

wex::menu_item::menu_item ( menu submenu,
const std::string &  name,
const std::string &  help = std::string(),
int  id = wxID_ANY 
)

Constructor for a SUBMENU item.

Parameters
submenumenu submenu
namemenu name or text
helpmenu help text
idmenu item id

◆ menu_item() [4/6]

wex::menu_item::menu_item ( const path p,
bool  show_modal = true 
)

Constructor for a VCS submenu item.

Parameters
pif a filename is specified the menu is built as a submenu, otherwise as menu items.
show_modalshows modal dialog if necessary

◆ menu_item() [5/6]

wex::menu_item::menu_item ( int  id,
file_history history,
std::function< void(wxUpdateUIEvent &)>  ui = nullptr 
)

Constructor for HISTORY menu item.

Parameters
idmenu item id
historyobject for maintaining / retrieving history
uicallback for menu update action

◆ menu_item() [6/6]

wex::menu_item::menu_item ( const managed_frame frame)

Constructor for PANES menu items.

Parameters
frameframe to supply toggled panes