- DECLARE_DYNAMIC_CLASS(wxMenuBar)
-
- wxMenuBar();
- wxMenuBar(int n, wxMenu *menus[], const wxString titles[]);
- ~wxMenuBar();
-
- void Append(wxMenu *menu, const wxString& title);
- // Must only be used AFTER menu has been attached to frame,
- // otherwise use individual menus to enable/disable items
- void Enable(int Id, bool Flag);
- bool Enabled(int Id) const ;
- inline bool IsEnabled(int Id) const { return Enabled(Id); };
- void EnableTop(int pos, bool Flag);
- void Check(int id, bool Flag);
- bool Checked(int id) const ;
- inline bool IsChecked(int Id) const { return Checked(Id); };
- void SetLabel(int id, const wxString& label) ;
- wxString GetLabel(int id) const ;
- void SetLabelTop(int pos, const wxString& label) ;
- wxString GetLabelTop(int pos) const ;
- virtual void Delete(wxMenu *menu, int index = 0); /* Menu not destroyed */
- virtual bool OnAppend(wxMenu *menu, const char *title);
- virtual bool OnDelete(wxMenu *menu, int index);
-
- virtual void SetHelpString(int Id, const wxString& helpString);
- virtual wxString GetHelpString(int Id) const ;
-
- virtual int FindMenuItem(const wxString& menuString, const wxString& itemString) const ;
-
- // Find wxMenuItem for item ID, and return item's
- // menu too if itemMenu is non-NULL.
- wxMenuItem *FindItemForId(int itemId, wxMenu **menuForItem = NULL) const ;
-
- inline void SetEventHandler(wxEvtHandler *handler) { m_eventHandler = handler; }
- inline wxEvtHandler *GetEventHandler() { return m_eventHandler; }
-
- inline int GetMenuCount() const { return m_menuCount; }
- inline wxMenu* GetMenu(int i) const { return m_menus[i]; }
-
- public:
- wxEvtHandler * m_eventHandler;
- int m_menuCount;
- wxMenu ** m_menus;
- wxString * m_titles;
- wxFrame * m_menuBarFrame;
-/* TODO: data that represents the actual menubar when created.
- */
+public:
+ // ctors & dtor
+ // default constructor
+ wxMenuBar();
+ // unused under MSW
+ wxMenuBar(long style);
+ // menubar takes ownership of the menus arrays but copies the titles
+ wxMenuBar(int n, wxMenu *menus[], const wxString titles[]);
+ virtual ~wxMenuBar();
+
+ // menubar construction
+ virtual bool Append( wxMenu *menu, const wxString &title );
+ virtual bool Insert(size_t pos, wxMenu *menu, const wxString& title);
+ virtual wxMenu *Replace(size_t pos, wxMenu *menu, const wxString& title);
+ virtual wxMenu *Remove(size_t pos);
+
+ virtual int FindMenuItem(const wxString& menuString,
+ const wxString& itemString) const;
+ virtual wxMenuItem* FindItem( int id, wxMenu **menu = NULL ) const;
+
+ virtual void EnableTop( size_t pos, bool flag );
+ virtual void SetLabelTop( size_t pos, const wxString& label );
+ virtual wxString GetLabelTop( size_t pos ) const;
+
+ // compatibility: these functions are deprecated
+#if WXWIN_COMPATIBILITY
+ void SetEventHandler(wxEvtHandler *handler) { m_eventHandler = handler; }
+ wxEvtHandler *GetEventHandler() { return m_eventHandler; }
+
+ bool Enabled(int id) const { return IsEnabled(id); }
+ bool Checked(int id) const { return IsChecked(id); }
+#endif // WXWIN_COMPATIBILITY
+
+ // implementation from now on
+ WXHMENU Create();
+ int FindMenu(const wxString& title);
+ void Detach();
+
+ // returns TRUE if we're attached to a frame
+ bool IsAttached() const { return m_menuBarFrame != NULL; }
+ // get the frame we live in
+ wxFrame *GetFrame() const { return m_menuBarFrame; }
+ // attach to a frame
+ void Attach(wxFrame *frame);
+
+#if wxUSE_ACCEL
+ // get the accel table for all the menus
+ const wxAcceleratorTable& GetAccelTable() const { return m_accelTable; }
+
+ // update the accel table (must be called after adding/deletign a menu)
+ void RebuildAccelTable();
+#endif // wxUSE_ACCEL
+
+ // if the menubar is modified, the display is not updated automatically,
+ // call this function to update it (m_menuBarFrame should be !NULL)
+ void Refresh();
+
+ void MacInstallMenuBar() ;
+ void MacMenuSelect(wxEvtHandler* handler, long when , int macMenuId, int macMenuItemNum) ;
+ static wxMenuBar* MacGetInstalledMenuBar() { return s_macInstalledMenuBar ; }
+
+protected:
+ // common part of all ctors
+ void Init();
+
+#if WXWIN_COMPATIBILITY
+ wxEvtHandler *m_eventHandler;
+#endif // WXWIN_COMPATIBILITY
+
+ wxArrayString m_titles;
+
+ wxFrame *m_menuBarFrame;
+
+#if wxUSE_ACCEL
+ // the accelerator table for all accelerators in all our menus
+ wxAcceleratorTable m_accelTable;
+#endif // wxUSE_ACCEL
+
+private:
+ static wxMenuBar* s_macInstalledMenuBar ;
+
+ DECLARE_DYNAMIC_CLASS(wxMenuBar)