]> git.saurik.com Git - wxWidgets.git/blobdiff - include/wx/msw/menu.h
operator >> wxString eat word by default. \n Add wxTextInputStream::Get/SetStringSepa...
[wxWidgets.git] / include / wx / msw / menu.h
index 0548776b675d3ee116d68fd7e578ad06826eaab6..84746929c6247685b0b9fd399db3da1e0aed7259 100644 (file)
@@ -22,7 +22,7 @@
 #include "wx/string.h"
 
 #if wxUSE_ACCEL
-#include "wx/accel.h"
+    #include "wx/accel.h"
 #endif // wxUSE_ACCEL
 
 class WXDLLEXPORT wxMenuItem;
@@ -32,6 +32,8 @@ class WXDLLEXPORT wxFrame;
 
 WXDLLEXPORT_DATA(extern const wxChar*) wxEmptyString;
 
+WX_DEFINE_ARRAY(wxAcceleratorEntry *, wxAcceleratorArray);
+
 // ----------------------------------------------------------------------------
 // Menu
 // ----------------------------------------------------------------------------
@@ -50,7 +52,7 @@ public:
 
     wxMenu( long WXUNUSED(style) )
     {
-       Init( wxEmptyString );
+        Init( wxEmptyString );
     }
 
     wxMenu(const wxString& title = wxEmptyString, long WXUNUSED(style) = 0)
@@ -126,7 +128,6 @@ public:
 
     bool ProcessCommand(wxCommandEvent& event);
 
-    virtual void SetParent(wxEvtHandler *parent) { m_parent = parent; }
     void SetEventHandler(wxEvtHandler *handler) { m_eventHandler = handler; }
     wxEvtHandler *GetEventHandler() const { return m_eventHandler; }
 
@@ -147,7 +148,7 @@ public:
     void Detach();
 
 #if wxUSE_ACCEL
-    size_t GetAccelCount() const { return m_accelKeyCodes.GetCount(); }
+    size_t GetAccelCount() const { return m_accels.GetCount(); }
     size_t CopyAccels(wxAcceleratorEntry *accels) const;
 #endif // wxUSE_ACCEL
 
@@ -180,14 +181,13 @@ private:
     wxMenu *          m_topLevelMenu;
     wxMenuBar *       m_menuBar;
     wxList            m_menuItems;
-    wxEvtHandler *    m_parent;
     wxEvtHandler *    m_eventHandler;
     wxWindow         *m_pInvokingWindow;
     void*             m_clientData;
 
 #if wxUSE_ACCEL
-    // the accelerators data
-    wxArrayInt        m_accelKeyCodes, m_accelFlags, m_accelIds;
+    // the accelerators for our menu items
+    wxAcceleratorArray m_accels;
 #endif // wxUSE_ACCEL
 };
 
@@ -195,10 +195,8 @@ private:
 // Menu Bar (a la Windows)
 // ----------------------------------------------------------------------------
 
-class WXDLLEXPORT wxMenuBar : public wxEvtHandler
+class WXDLLEXPORT wxMenuBar : public wxMenuBarBase
 {
-    DECLARE_DYNAMIC_CLASS(wxMenuBar)
-
 public:
     // ctors & dtor
         // default constructor
@@ -210,62 +208,33 @@ public:
     virtual ~wxMenuBar();
 
     // menubar construction
-    WXHMENU Create();
-    void Append(wxMenu *menu, const wxString& title);
-    virtual void Delete(wxMenu *menu, int index = 0); /* Menu not destroyed */
-
-    // state control
-    // NB: must only be used AFTER menu has been attached to frame,
-    //     otherwise use individual menus to enable/disable items
-        // enable the item
-    void Enable(int id, bool enable);
-        // TRUE if item enabled
-    bool IsEnabled(int id) const;
-        //
-    void EnableTop(int pos, bool enable);
-
-        // works only with checkable items
-    void Check(int id, bool check);
-        // TRUE if checked
-    bool IsChecked(int id) const;
+    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);
 
-    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 ;
-
-    void SetLabelTop(int pos, const wxString& label) ;
-    wxString GetLabelTop(int pos) const ;
-
-    // notifications: return FALSE to prevent the menu from being
-    // appended/deleted
-    virtual bool OnAppend(wxMenu *menu, const wxChar *title);
-    virtual bool OnDelete(wxMenu *menu, int index);
-
-    // item search
-        // by menu and item names, returns wxNOT_FOUND if not found
     virtual int FindMenuItem(const wxString& menuString,
                              const wxString& itemString) const;
-        // returns NULL if not found
-    wxMenuItem* FindItem(int id) const { return FindItemForId(id); }
-        // returns NULL if not found, fills menuForItem if !NULL
-    wxMenuItem *FindItemForId(int itemId, wxMenu **menuForItem = NULL) const;
+    virtual wxMenuItem* FindItem( int id, wxMenu **menu = NULL ) const;
 
-    // submenus access
-    int GetMenuCount() const { return m_menuCount; }
-    wxMenu *GetMenu(int i) const { return m_menus[i]; }
+    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
+#ifdef WXWIN_COMPATIBILITY
     void SetEventHandler(wxEvtHandler *handler) { m_eventHandler = handler; }
     wxEvtHandler *GetEventHandler() { return m_eventHandler; }
 
-#ifdef WXWIN_COMPATIBILITY
-    // compatibility: these functions are deprecated
     bool Enabled(int id) const { return IsEnabled(id); }
     bool Checked(int id) const { return IsChecked(id); }
 #endif // WXWIN_COMPATIBILITY
 
-    // IMPLEMENTATION
+    // 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
@@ -281,18 +250,20 @@ public:
         // get the menu handle
     WXHMENU GetHMenu() const { return m_hMenu; }
 
-protected:
-    // common part of all ctors
-    void Init();
-
     // if the menubar is modified, the display is not updated automatically,
     // call this function to update it (m_menuBarFrame should be !NULL)
     void Refresh();
 
+protected:
+    // common part of all ctors
+    void Init();
+
+#ifdef WXWIN_COMPATIBILITY
     wxEvtHandler *m_eventHandler;
-    int           m_menuCount;
-    wxMenu      **m_menus;
-    wxString     *m_titles;
+#endif // WXWIN_COMPATIBILITY
+
+    wxArrayString m_titles;
+
     wxFrame      *m_menuBarFrame;
     WXHMENU       m_hMenu;
 
@@ -300,6 +271,9 @@ protected:
     // the accelerator table for all accelerators in all our menus
     wxAcceleratorTable m_accelTable;
 #endif // wxUSE_ACCEL
+
+private:
+    DECLARE_DYNAMIC_CLASS(wxMenuBar)
 };
 
 #endif // _WX_MENU_H_