implemented wxMenuBar ctor taking array of menus/titles for all ports; added optional flags argument to it (patch 1162726)

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@32880 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2005-03-17 23:45:24 +00:00
parent e71693c340
commit 294ea16de3
21 changed files with 71 additions and 63 deletions

View File

@@ -702,7 +702,7 @@ menu shortcuts may cease to work.
Default constructor. 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. 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).} \docparam{style}{If {\tt wxMB\_DOCKABLE} the menu bar can be detached (wxGTK only).}
\pythonnote{Only the default constructor is supported in wxPython. \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: \perlnote{wxPerl only supports the first constructor:
use {\tt Append} instead.} use \helpref{wxMenuBar::Append}{wxmenubarappend} instead.}
\membersection{wxMenuBar::\destruct{wxMenuBar}}\label{wxmenubardtor} \membersection{wxMenuBar::\destruct{wxMenuBar}}\label{wxmenubardtor}

View File

@@ -78,6 +78,7 @@ class WXDLLEXPORT wxMenuBar : public wxMenuBarBase, public wxCocoaNSMenu
public: public:
// ctors and dtor // ctors and dtor
wxMenuBar(long style = 0) { Create(style); } wxMenuBar(long style = 0) { Create(style); }
wxMenuBar(size_t n, wxMenu *menus[], const wxString titles[], long style = 0)
bool Create(long style = 0); bool Create(long style = 0);
virtual ~wxMenuBar(); virtual ~wxMenuBar();

View File

@@ -24,7 +24,7 @@ public:
// ctors // ctors
wxMenuBar(); wxMenuBar();
wxMenuBar(long style); 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(); virtual ~wxMenuBar();
// implement base class (pure) virtuals // implement base class (pure) virtuals
@@ -56,6 +56,8 @@ public:
wxWindow *m_invokingWindow; wxWindow *m_invokingWindow;
private: private:
void Init(size_t n, wxMenu *menus[], const wxString titles[], long style);
DECLARE_DYNAMIC_CLASS(wxMenuBar) DECLARE_DYNAMIC_CLASS(wxMenuBar)
}; };

View File

@@ -24,7 +24,7 @@ public:
// ctors // ctors
wxMenuBar(); wxMenuBar();
wxMenuBar(long style); 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(); virtual ~wxMenuBar();
// implement base class (pure) virtuals // implement base class (pure) virtuals
@@ -56,6 +56,8 @@ public:
wxWindow *m_invokingWindow; wxWindow *m_invokingWindow;
private: private:
void Init(size_t n, wxMenu *menus[], const wxString titles[], long style);
DECLARE_DYNAMIC_CLASS(wxMenuBar) DECLARE_DYNAMIC_CLASS(wxMenuBar)
}; };

View File

@@ -108,7 +108,7 @@ public:
// unused under MSW // unused under MSW
wxMenuBar(long style); wxMenuBar(long style);
// menubar takes ownership of the menus arrays but copies the titles // 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(); virtual ~wxMenuBar();
// menubar construction // menubar construction

View File

@@ -108,7 +108,7 @@ public:
// unused under MSW // unused under MSW
wxMenuBar(long style); wxMenuBar(long style);
// menubar takes ownership of the menus arrays but copies the titles // 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(); virtual ~wxMenuBar();
// menubar construction // menubar construction

View File

@@ -117,8 +117,8 @@ class wxMenuBar : public wxMenuBarBase
public: public:
wxMenuBar() { Init(); } wxMenuBar() { Init(); }
wxMenuBar(long WXUNUSED(style)) { Init(); } wxMenuBar(long WXUNUSED(style)) { Init(); }
wxMenuBar(int n, wxMenu *menus[], const wxString titles[]); wxMenuBar(size_t n, wxMenu *menus[], const wxString titles[], long style = 0);
wxMenuBar(int n, wxMenu *menus[], const wxArrayString& titles); wxMenuBar(size_t n, wxMenu *menus[], const wxArrayString& titles, long style = 0);
virtual ~wxMenuBar(); virtual ~wxMenuBar();
// implement base class (pure) virtuals // implement base class (pure) virtuals

View File

@@ -165,7 +165,7 @@ public:
// unused under MSW // unused under MSW
wxMenuBar(long style); wxMenuBar(long style);
// menubar takes ownership of the menus arrays but copies the titles // 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(); virtual ~wxMenuBar();
// menubar construction // menubar construction

View File

@@ -194,6 +194,7 @@ public:
wxMenuBar( int n wxMenuBar( int n
,wxMenu* vMenus[] ,wxMenu* vMenus[]
,const wxString sTitles[] ,const wxString sTitles[]
,long lStyle = 0
); );
virtual ~wxMenuBar(); virtual ~wxMenuBar();

View File

@@ -146,7 +146,7 @@ public:
wxMenuBar(long style); wxMenuBar(long style);
// menubar takes ownership of the menus arrays but copies the titles // 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(); virtual ~wxMenuBar();
// menubar construction // menubar construction

View File

@@ -147,6 +147,7 @@ class WXDLLEXPORT wxMenuBar : public wxMenuBarBase
public: public:
// ctors and dtor // ctors and dtor
wxMenuBar(long WXUNUSED(style) = 0) { Init(); } wxMenuBar(long WXUNUSED(style) = 0) { Init(); }
wxMenuBar(size_t n, wxMenu *menus[], const wxString titles[], long style = 0)
virtual ~wxMenuBar(); virtual ~wxMenuBar();
// implement base class virtuals // implement base class virtuals

View File

@@ -128,6 +128,14 @@ bool wxMenuBar::Create(long style)
return true; 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() wxMenuBar::~wxMenuBar()
{ {
[m_cocoaNSMenu release]; [m_cocoaNSMenu release];

View File

@@ -170,7 +170,7 @@ static void gtk_menu_open_callback( GtkWidget *widget, wxMenu *menu )
IMPLEMENT_DYNAMIC_CLASS(wxMenuBar,wxWindow) 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() // the parent window is known after wxFrame::SetMenu()
m_needParent = FALSE; m_needParent = FALSE;
@@ -203,32 +203,24 @@ wxMenuBar::wxMenuBar( long style )
PostCreation(); PostCreation();
ApplyWidgetStyle(); ApplyWidgetStyle();
for (size_t i = 0; i < n; ++i )
Append(menus[i], titles[i]);
}
wxMenuBar::wxMenuBar(size_t n, wxMenu *menus[], const wxString titles[], long style)
{
Init(n, menus, titles, style);
}
wxMenuBar::wxMenuBar(long style)
{
Init(0, NULL, NULL, style);
} }
wxMenuBar::wxMenuBar() wxMenuBar::wxMenuBar()
{ {
// the parent window is known after wxFrame::SetMenu() Init(0, NULL, NULL, 0);
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);
PostCreation();
ApplyWidgetStyle();
} }
wxMenuBar::~wxMenuBar() wxMenuBar::~wxMenuBar()

View File

@@ -170,7 +170,7 @@ static void gtk_menu_open_callback( GtkWidget *widget, wxMenu *menu )
IMPLEMENT_DYNAMIC_CLASS(wxMenuBar,wxWindow) 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() // the parent window is known after wxFrame::SetMenu()
m_needParent = FALSE; m_needParent = FALSE;
@@ -203,32 +203,24 @@ wxMenuBar::wxMenuBar( long style )
PostCreation(); PostCreation();
ApplyWidgetStyle(); ApplyWidgetStyle();
for (size_t i = 0; i < n; ++i )
Append(menus[i], titles[i]);
}
wxMenuBar::wxMenuBar(size_t n, wxMenu *menus[], const wxString titles[], long style)
{
Init(n, menus, titles, style);
}
wxMenuBar::wxMenuBar(long style)
{
Init(0, NULL, NULL, style);
} }
wxMenuBar::wxMenuBar() wxMenuBar::wxMenuBar()
{ {
// the parent window is known after wxFrame::SetMenu() Init(0, NULL, NULL, 0);
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);
PostCreation();
ApplyWidgetStyle();
} }
wxMenuBar::~wxMenuBar() wxMenuBar::~wxMenuBar()

View 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(); Init();

View 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(); Init();

View File

@@ -209,7 +209,7 @@ void wxMenuBar::Init()
m_font = wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT); 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() ); wxASSERT( size_t(n) == titles.GetCount() );
@@ -220,7 +220,7 @@ wxMenuBar::wxMenuBar(int n, wxMenu *menus[], const wxArrayString& titles)
m_menus.Append(menus[i]); 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(); Init();

View File

@@ -697,7 +697,7 @@ wxMenuBar::wxMenuBar( long WXUNUSED(style) )
Init(); Init();
} }
wxMenuBar::wxMenuBar(int count, wxMenu *menus[], const wxString titles[]) wxMenuBar::wxMenuBar(size_t count, wxMenu *menus[], const wxString titles[], long WXUNUSED(style))
{ {
Init(); Init();

View File

@@ -697,6 +697,7 @@ wxMenuBar::wxMenuBar(
int nCount int nCount
, wxMenu* vMenus[] , wxMenu* vMenus[]
, const wxString sTitles[] , const wxString sTitles[]
, long WXUNUSED(lStyle)
) )
{ {
Init(); Init();

View 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))
{ {
} }

View File

@@ -1678,6 +1678,14 @@ void wxMenuBar::Init()
m_shouldShowMenu = false; 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) void wxMenuBar::Attach(wxFrame *frame)
{ {
// maybe you really wanted to call Detach()? // maybe you really wanted to call Detach()?