+class WXDLLEXPORT wxMenuBase : public wxEvtHandler
+{
+public:
+ // create a menu
+ static wxMenu *New(const wxString& title = wxEmptyString, long style = 0);
+
+ // ctors
+ wxMenuBase(const wxString& title, long style = 0) : m_title(title)
+ { Init(style); }
+ wxMenuBase(long style = 0)
+ { Init(style); }
+
+ // dtor deletes all the menu items we own
+ virtual ~wxMenuBase();
+
+ // menu construction
+ // -----------------
+
+ // append a normal item to the menu
+ void Append(int id,
+ const wxString& text,
+ const wxString& help = wxEmptyString,
+ bool isCheckable = FALSE)
+ {
+ DoAppend(wxMenuItem::New((wxMenu *)this, id, text, help, isCheckable));
+ }
+
+ // append a separator to the menu
+ void AppendSeparator() { Append(wxID_SEPARATOR, wxEmptyString); }
+
+ // append a submenu
+ void Append(int id,
+ const wxString& text,
+ wxMenu *submenu,
+ const wxString& help = wxEmptyString)
+ {
+ DoAppend(wxMenuItem::New((wxMenu *)this, id, text, help, FALSE, submenu));
+ }
+
+ // the most generic form of Append() - append anything
+ void Append(wxMenuItem *item) { DoAppend(item); }
+
+ // insert a break in the menu (only works when appending the items, not
+ // inserting them)
+ virtual void Break() { }
+
+ // insert an item before given position
+ bool Insert(size_t pos, wxMenuItem *item);
+ void Insert(size_t pos,
+ int id,
+ const wxString& text,
+ const wxString& help = wxEmptyString,
+ bool isCheckable = FALSE)
+ {
+ Insert(pos, wxMenuItem::New((wxMenu *)this, id, text, help, isCheckable));
+ }
+
+ // insert a separator
+ void InsertSeparator(size_t pos)
+ {
+ Insert(pos, wxMenuItem::New((wxMenu *)this));
+ }
+
+ // insert a submenu
+ void Insert(size_t pos,
+ int id,
+ const wxString& text,
+ wxMenu *submenu,
+ const wxString& help = wxEmptyString)
+ {
+ Insert(pos, wxMenuItem::New((wxMenu *)this, id, text, help, FALSE, submenu));
+ }
+
+ // prepend an item to the menu
+ void Prepend(wxMenuItem *item)
+ {
+ Insert(0u, item);
+ }
+
+ void Prepend(int id,
+ const wxString& text,
+ const wxString& help = wxEmptyString,
+ bool isCheckable = FALSE)
+ {
+ Insert(0u, id, text, help, isCheckable);
+ }
+
+ // insert a separator
+ void PrependSeparator()
+ {
+ InsertSeparator(0u);
+ }
+
+ // insert a submenu
+ void Prepend(int id,
+ const wxString& text,
+ wxMenu *submenu,
+ const wxString& help = wxEmptyString)
+ {
+ Insert(0u, id, text, submenu, help);
+ }
+
+ // detach an item from the menu, but don't delete it so that it can be
+ // added back later (but if it's not, the caller is responsible for
+ // deleting it!)
+ wxMenuItem *Remove(int id) { return Remove(FindChildItem(id)); }
+ wxMenuItem *Remove(wxMenuItem *item);
+
+ // delete an item from the menu (submenus are not destroyed by this
+ // function, see Destroy)
+ bool Delete(int id) { return Delete(FindChildItem(id)); }
+ bool Delete(wxMenuItem *item);
+
+ // delete the item from menu and destroy it (if it's a submenu)
+ bool Destroy(int id) { return Destroy(FindChildItem(id)); }
+ bool Destroy(wxMenuItem *item);
+
+ // menu items access
+ // -----------------
+
+ // get the items
+ size_t GetMenuItemCount() const { return m_items.GetCount(); }
+
+ const wxMenuItemList& GetMenuItems() const { return m_items; }
+ wxMenuItemList& GetMenuItems() { return m_items; }
+
+ // search
+ virtual int FindItem(const wxString& item) const;
+ wxMenuItem* FindItem(int id, wxMenu **menu = NULL) const;
+
+ // get/set items attributes
+ void Enable(int id, bool enable);
+ bool IsEnabled(int id) const;
+
+ void Check(int id, bool check);
+ bool IsChecked(int id) const;
+
+ void SetLabel(int id, const wxString& label);
+ wxString GetLabel(int id) const;
+
+ virtual void SetHelpString(int id, const wxString& helpString);
+ virtual wxString GetHelpString(int id) const;
+
+ // misc accessors
+ // --------------
+
+ // the title
+ virtual void SetTitle(const wxString& title) { m_title = title; }
+ const wxString GetTitle() const { return m_title; }
+
+ // client data
+ void SetClientData(void* clientData) { m_clientData = clientData; }
+ void* GetClientData() const { return m_clientData; }
+
+ // event handler
+ void SetEventHandler(wxEvtHandler *handler) { m_eventHandler = handler; }
+ wxEvtHandler *GetEventHandler() const { return m_eventHandler; }
+
+ // invoking window
+ void SetInvokingWindow(wxWindow *win) { m_invokingWindow = win; }
+ wxWindow *GetInvokingWindow() const { return m_invokingWindow; }
+
+ // style
+ long GetStyle() const { return m_style; }