]> git.saurik.com Git - wxWidgets.git/commitdiff
implemented wxMenuBar ctor taking array of menus/titles for all ports; added optional...
authorVadim Zeitlin <vadim@wxwidgets.org>
Thu, 17 Mar 2005 23:45:24 +0000 (23:45 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Thu, 17 Mar 2005 23:45:24 +0000 (23:45 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@32880 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

21 files changed:
docs/latex/wx/menu.tex
include/wx/cocoa/menu.h
include/wx/gtk/menu.h
include/wx/gtk1/menu.h
include/wx/mac/carbon/menu.h
include/wx/mac/classic/menu.h
include/wx/motif/menu.h
include/wx/msw/menu.h
include/wx/os2/menu.h
include/wx/palmos/menu.h
include/wx/univ/menu.h
src/cocoa/menu.mm
src/gtk/menu.cpp
src/gtk1/menu.cpp
src/mac/carbon/menu.cpp
src/mac/classic/menu.cpp
src/motif/menu.cpp
src/msw/menu.cpp
src/os2/menu.cpp
src/palmos/menu.cpp
src/univ/menu.cpp

index 6e0f65b9a97369f13a26eb100867751862468044..72c93feb33edc483694148d1568a407389ac5b94 100644 (file)
@@ -702,7 +702,7 @@ menu shortcuts may cease to work.
 
 Default constructor.
 
-\func{}{wxMenuBar}{\param{int}{ n}, \param{wxMenu*}{ menus[]}, \param{const wxString }{titles[]}}
+\func{}{wxMenuBar}{\param{size\_t}{ n}, \param{wxMenu*}{ menus[]}, \param{const wxString }{titles[]}, \param{long }{style = 0}}
 
 Construct a menu bar from arrays of menus and titles.
 
@@ -718,10 +718,10 @@ menu bar.}
 \docparam{style}{If {\tt wxMB\_DOCKABLE} the menu bar can be detached (wxGTK only).}
 
 \pythonnote{Only the default constructor is supported in wxPython.
-Use wxMenuBar.Append instead.}
+Use \helpref{wxMenuBar::Append}{wxmenubarappend} instead.}
 
 \perlnote{wxPerl only supports the first constructor: 
-use {\tt Append} instead.}
+use \helpref{wxMenuBar::Append}{wxmenubarappend} instead.}
 
 \membersection{wxMenuBar::\destruct{wxMenuBar}}\label{wxmenubardtor}
 
index e05cd49d7041b023f3929d04fbac28da850ef773..965008536e729fc6c804d69360b0cf69e4448b44 100644 (file)
@@ -78,6 +78,7 @@ class WXDLLEXPORT wxMenuBar : public wxMenuBarBase, public wxCocoaNSMenu
 public:
     // ctors and dtor
     wxMenuBar(long style = 0) { Create(style); }
+    wxMenuBar(size_t n, wxMenu *menus[], const wxString titles[], long style = 0)
     bool Create(long style = 0);
     virtual ~wxMenuBar();
 
index a154a64e21491990b5e7c896e3c4a558982c44e6..e28b4477e7f26fb06a5d5e7458cd31f4705ebbe7 100644 (file)
@@ -24,7 +24,7 @@ public:
     // ctors
     wxMenuBar();
     wxMenuBar(long style);
-    wxMenuBar(int n, wxMenu *menus[], const wxString titles[]);
+    wxMenuBar(size_t n, wxMenu *menus[], const wxString titles[], long style = 0);
     virtual ~wxMenuBar();
 
     // implement base class (pure) virtuals
@@ -56,6 +56,8 @@ public:
     wxWindow        *m_invokingWindow;
 
 private:
+    void Init(size_t n, wxMenu *menus[], const wxString titles[], long style);
+
     DECLARE_DYNAMIC_CLASS(wxMenuBar)
 };
 
index a154a64e21491990b5e7c896e3c4a558982c44e6..e28b4477e7f26fb06a5d5e7458cd31f4705ebbe7 100644 (file)
@@ -24,7 +24,7 @@ public:
     // ctors
     wxMenuBar();
     wxMenuBar(long style);
-    wxMenuBar(int n, wxMenu *menus[], const wxString titles[]);
+    wxMenuBar(size_t n, wxMenu *menus[], const wxString titles[], long style = 0);
     virtual ~wxMenuBar();
 
     // implement base class (pure) virtuals
@@ -56,6 +56,8 @@ public:
     wxWindow        *m_invokingWindow;
 
 private:
+    void Init(size_t n, wxMenu *menus[], const wxString titles[], long style);
+
     DECLARE_DYNAMIC_CLASS(wxMenuBar)
 };
 
index 5718b3950bac10380e378caa1ee0a7f42c097629..112c6c19e1bf7a0da833384d3851e113a2bc0731 100644 (file)
@@ -108,7 +108,7 @@ public:
         // 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[]);
+    wxMenuBar(size_t n, wxMenu *menus[], const wxString titles[], long style = 0);
     virtual ~wxMenuBar();
 
     // menubar construction
index 854a70d107e077a37dd73e69d9159caed9f7e649..bc0a50125ebca70cc44531a8d4e6a6f49a498815 100644 (file)
@@ -108,7 +108,7 @@ public:
         // 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[]);
+    wxMenuBar(size_t n, wxMenu *menus[], const wxString titles[], long style = 0);
     virtual ~wxMenuBar();
 
     // menubar construction
index 85cb814dc51ad18e9409655551e437121ccbe526..b4f94426d16a6118082c68de7d16a01d54ce40fa 100644 (file)
@@ -117,8 +117,8 @@ class wxMenuBar : public wxMenuBarBase
 public:
     wxMenuBar() { Init(); }
     wxMenuBar(long WXUNUSED(style)) { Init(); }
-    wxMenuBar(int n, wxMenu *menus[], const wxString titles[]);
-    wxMenuBar(int n, wxMenu *menus[], const wxArrayString& titles);
+    wxMenuBar(size_t n, wxMenu *menus[], const wxString titles[], long style = 0);
+    wxMenuBar(size_t n, wxMenu *menus[], const wxArrayString& titles, long style = 0);
     virtual ~wxMenuBar();
     
     // implement base class (pure) virtuals
index 9fff22c1fab38f4da8726a318edf0609bb9c088b..f049ba8f41c28f92455c52d8787bcad57e1924c9 100644 (file)
@@ -165,7 +165,7 @@ public:
         // 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[]);
+    wxMenuBar(size_t n, wxMenu *menus[], const wxString titles[], long style = 0);
     virtual ~wxMenuBar();
 
     // menubar construction
index b088026c217d61bd3bcfbb1e0e3250747bd3ef12..0505afc347b39601298c639c28b2e2deb22a811f 100644 (file)
@@ -194,6 +194,7 @@ public:
     wxMenuBar( int            n
               ,wxMenu*        vMenus[]
               ,const wxString sTitles[]
+              ,long           lStyle = 0
              );
     virtual ~wxMenuBar();
 
index 77ab82badcc5906716ae7f24f63be0d139f8d038..bca5475b47dd528cb09f32add1b5b2fee543a81a 100644 (file)
@@ -146,7 +146,7 @@ public:
 
     wxMenuBar(long style);
         // menubar takes ownership of the menus arrays but copies the titles
-    wxMenuBar(int n, wxMenu *menus[], const wxString titles[]);
+    wxMenuBar(size_t n, wxMenu *menus[], const wxString titles[], long style = 0);
     virtual ~wxMenuBar();
 
     // menubar construction
index 6447a0c36a558747b3ccc12e3efbffbf67b6130d..ba7d0418b769f0c9c824c1f74bc526d696132cfd 100644 (file)
@@ -147,6 +147,7 @@ class WXDLLEXPORT wxMenuBar : public wxMenuBarBase
 public:
     // ctors and dtor
     wxMenuBar(long WXUNUSED(style) = 0) { Init(); }
+    wxMenuBar(size_t n, wxMenu *menus[], const wxString titles[], long style = 0)
     virtual ~wxMenuBar();
 
     // implement base class virtuals
index 529f422350d674e6dccfd96c166c16bad1ba2644..c39d49cb0b0cc38273659a7faed0351926cfab38 100644 (file)
@@ -128,6 +128,14 @@ bool wxMenuBar::Create(long style)
     return true;
 }
 
+wxMenuBar::wxMenuBar(size_t n, wxMenu *menus[], const wxString titles[], long WXUNUSED(style))
+{
+    Create(style);
+
+    for(size_t i = 0; i < n; ++i )
+        Append(menus[i], titles[i]);
+}
+
 wxMenuBar::~wxMenuBar()
 {
     [m_cocoaNSMenu release];
index 82956da0a6f9d497f1d18f8a0cee4a1ca96d4cb3..7922dd438b03a2c416f4221e38aa74aa151a6ff3 100644 (file)
@@ -170,7 +170,7 @@ static void gtk_menu_open_callback( GtkWidget *widget, wxMenu *menu )
 
 IMPLEMENT_DYNAMIC_CLASS(wxMenuBar,wxWindow)
 
-wxMenuBar::wxMenuBar( long style )
+void wxMenuBar::Init(size_t n, wxMenu *menus[], const wxString titles[], long style)
 {
     // the parent window is known after wxFrame::SetMenu()
     m_needParent = FALSE;
@@ -203,32 +203,24 @@ wxMenuBar::wxMenuBar( long style )
     PostCreation();
 
     ApplyWidgetStyle();
+
+    for (size_t i = 0; i < n; ++i )
+        Append(menus[i], titles[i]);
 }
 
-wxMenuBar::wxMenuBar()
+wxMenuBar::wxMenuBar(size_t n, wxMenu *menus[], const wxString titles[], long style)
 {
-    // the parent window is known after wxFrame::SetMenu()
-    m_needParent = FALSE;
-    m_style = 0;
-    m_invokingWindow = (wxWindow*) NULL;
-
-    if (!PreCreation( (wxWindow*) NULL, wxDefaultPosition, wxDefaultSize ) ||
-        !CreateBase( (wxWindow*) NULL, -1, wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, wxT("menubar") ))
-    {
-        wxFAIL_MSG( wxT("wxMenuBar creation failed") );
-        return;
-    }
-
-    m_menubar = gtk_menu_bar_new();
-#ifndef __WXGTK20__
-    m_accel = gtk_accel_group_new();
-#endif
-
-    m_widget = GTK_WIDGET(m_menubar);
+    Init(n, menus, titles, style);
+}
 
-    PostCreation();
+wxMenuBar::wxMenuBar(long style)
+{
+    Init(0, NULL, NULL, style);
+}
 
-    ApplyWidgetStyle();
+wxMenuBar::wxMenuBar()
+{
+    Init(0, NULL, NULL, 0);
 }
 
 wxMenuBar::~wxMenuBar()
index 82956da0a6f9d497f1d18f8a0cee4a1ca96d4cb3..7922dd438b03a2c416f4221e38aa74aa151a6ff3 100644 (file)
@@ -170,7 +170,7 @@ static void gtk_menu_open_callback( GtkWidget *widget, wxMenu *menu )
 
 IMPLEMENT_DYNAMIC_CLASS(wxMenuBar,wxWindow)
 
-wxMenuBar::wxMenuBar( long style )
+void wxMenuBar::Init(size_t n, wxMenu *menus[], const wxString titles[], long style)
 {
     // the parent window is known after wxFrame::SetMenu()
     m_needParent = FALSE;
@@ -203,32 +203,24 @@ wxMenuBar::wxMenuBar( long style )
     PostCreation();
 
     ApplyWidgetStyle();
+
+    for (size_t i = 0; i < n; ++i )
+        Append(menus[i], titles[i]);
 }
 
-wxMenuBar::wxMenuBar()
+wxMenuBar::wxMenuBar(size_t n, wxMenu *menus[], const wxString titles[], long style)
 {
-    // the parent window is known after wxFrame::SetMenu()
-    m_needParent = FALSE;
-    m_style = 0;
-    m_invokingWindow = (wxWindow*) NULL;
-
-    if (!PreCreation( (wxWindow*) NULL, wxDefaultPosition, wxDefaultSize ) ||
-        !CreateBase( (wxWindow*) NULL, -1, wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, wxT("menubar") ))
-    {
-        wxFAIL_MSG( wxT("wxMenuBar creation failed") );
-        return;
-    }
-
-    m_menubar = gtk_menu_bar_new();
-#ifndef __WXGTK20__
-    m_accel = gtk_accel_group_new();
-#endif
-
-    m_widget = GTK_WIDGET(m_menubar);
+    Init(n, menus, titles, style);
+}
 
-    PostCreation();
+wxMenuBar::wxMenuBar(long style)
+{
+    Init(0, NULL, NULL, style);
+}
 
-    ApplyWidgetStyle();
+wxMenuBar::wxMenuBar()
+{
+    Init(0, NULL, NULL, 0);
 }
 
 wxMenuBar::~wxMenuBar()
index 4761918b3369352a34fd089e68fb608b3b74ee48..11cb225d9b07f855d1f8b738b7bf276ab87ba997 100644 (file)
@@ -589,7 +589,7 @@ wxMenuBar::wxMenuBar( long WXUNUSED(style) )
 }
 
 
-wxMenuBar::wxMenuBar(int count, wxMenu *menus[], const wxString titles[])
+wxMenuBar::wxMenuBar(size_t count, wxMenu *menus[], const wxString titles[], long WXUNUSED(style))
 {
     Init();
 
index d846775cd679b1b4b41ee4cc1255a37aaa19005d..57dfedd102fd3e3b4497855b80e98296a86dbe65 100644 (file)
@@ -463,7 +463,7 @@ wxMenuBar::wxMenuBar( long WXUNUSED(style) )
 }
 
 
-wxMenuBar::wxMenuBar(int count, wxMenu *menus[], const wxString titles[])
+wxMenuBar::wxMenuBar(size_t count, wxMenu *menus[], const wxString titles[], long WXUNUSED(style))
 {
     Init();
 
index 271a0f5632113ddc07f25dc539a532d8ebde8c63..8868823110204faeb08a35d472218cb9f60515bf 100644 (file)
@@ -209,7 +209,7 @@ void wxMenuBar::Init()
     m_font = wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT);
 }
 
-wxMenuBar::wxMenuBar(int n, wxMenu *menus[], const wxArrayString& titles)
+wxMenuBar::wxMenuBar(size_t n, wxMenu *menus[], const wxArrayString& titles, long WXUNUSED(style))
 {
     wxASSERT( size_t(n) == titles.GetCount() );
 
@@ -220,7 +220,7 @@ wxMenuBar::wxMenuBar(int n, wxMenu *menus[], const wxArrayString& titles)
         m_menus.Append(menus[i]);
 }
 
-wxMenuBar::wxMenuBar(int n, wxMenu *menus[], const wxString titles[])
+wxMenuBar::wxMenuBar(size_t n, wxMenu *menus[], const wxString titles[], long WXUNUSED(style))
 {
     Init();
 
index 3f6cb15334e92d63e3b7b8730bcf3cb78052ffa3..d92e189b2445dad939836a7bb17ce7284864b9d5 100644 (file)
@@ -697,7 +697,7 @@ wxMenuBar::wxMenuBar( long WXUNUSED(style) )
     Init();
 }
 
-wxMenuBar::wxMenuBar(int count, wxMenu *menus[], const wxString titles[])
+wxMenuBar::wxMenuBar(size_t count, wxMenu *menus[], const wxString titles[], long WXUNUSED(style))
 {
     Init();
 
index ccb4be42512ae2669bbadb1fb340756d15e2052f..59307fbdc3dff3b655a6469e83c2ad36ddfda621 100644 (file)
@@ -697,6 +697,7 @@ wxMenuBar::wxMenuBar(
   int                               nCount
 , wxMenu*                           vMenus[]
 , const wxString                    sTitles[]
+, long                              WXUNUSED(lStyle)
 )
 {
     Init();
index de25c0492b4979c2ee8b8ae30733b5d227e3dce2..74c9861d410576bdc362456de86441b2dfc10bca 100644 (file)
@@ -332,7 +332,7 @@ wxMenuBar::wxMenuBar( long WXUNUSED(style) )
 {
 }
 
-wxMenuBar::wxMenuBar(int count, wxMenu *menus[], const wxString titles[])
+wxMenuBar::wxMenuBar(size_t count, wxMenu *menus[], const wxString titles[], long WXUNUSED(style))
 {
 }
 
index acad3b9451276cb869189fcce037349254d73ecd..8e3957ddf7677f603a95f49075076ef17a89def2 100644 (file)
@@ -1678,6 +1678,14 @@ void wxMenuBar::Init()
     m_shouldShowMenu = false;
 }
 
+wxMenuBar::wxMenuBar(size_t n, wxMenu *menus[], const wxString titles[], long WXUNUSED(style))
+{
+    Init();
+
+    for (size_t i = 0; i < n; ++i )
+        Append(menus[i], titles[i]);
+}
+
 void wxMenuBar::Attach(wxFrame *frame)
 {
     // maybe you really wanted to call Detach()?