X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/1ecffbff714ff707ded9266bf27c3347946cbcd9..a8d9809fc0d3ac6a285bddeb6de44d334e38e011:/src/gtk1/menu.cpp diff --git a/src/gtk1/menu.cpp b/src/gtk1/menu.cpp index 10656f39f4..e1d680563e 100644 --- a/src/gtk1/menu.cpp +++ b/src/gtk1/menu.cpp @@ -39,7 +39,12 @@ wxMenuBar::wxMenuBar( long style ) m_needParent = FALSE; m_style = style; - PreCreation( (wxWindow *) NULL, -1, wxDefaultPosition, wxDefaultSize, style, "menu" ); + if (!PreCreation( (wxWindow*) NULL, wxDefaultPosition, wxDefaultSize ) || + !CreateBase( (wxWindow*) NULL, -1, wxDefaultPosition, wxDefaultSize, style, wxDefaultValidator, _T("menubar") )) + { + wxFAIL_MSG( _T("wxMenuBar creation failed") ); + return; + } m_menus.DeleteContents( TRUE ); @@ -72,8 +77,13 @@ wxMenuBar::wxMenuBar() m_needParent = FALSE; m_style = 0; - PreCreation( (wxWindow *) NULL, -1, wxDefaultPosition, wxDefaultSize, 0, "menu" ); - + if (!PreCreation( (wxWindow*) NULL, wxDefaultPosition, wxDefaultSize ) || + !CreateBase( (wxWindow*) NULL, -1, wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, _T("menubar") )) + { + wxFAIL_MSG( _T("wxMenuBar creation failed") ); + return; + } + m_menus.DeleteContents( TRUE ); /* GTK 1.2.0 doesn't have gtk_item_factory_get_item(), but GTK 1.2.1 has. */ @@ -214,7 +224,7 @@ void wxMenuBar::Append( wxMenu *menu, const wxString &title ) wxString buf; buf << _T('/') << str.c_str(); - char *cbuf = new char[buf.Length()]; + char *cbuf = new char[buf.Length()+1]; strcpy(cbuf, buf.mbc_str()); GtkItemFactoryEntry entry; @@ -628,11 +638,9 @@ IMPLEMENT_DYNAMIC_CLASS(wxMenu,wxEvtHandler) void wxMenu::Init( const wxString& title, - long style -#ifdef WXWIN_COMPATIBILITY - , const wxFunction func -#endif - ) + long style, + const wxFunction func + ) { m_title = title; m_items.DeleteContents( TRUE ); @@ -647,9 +655,7 @@ wxMenu::Init( const wxString& title, m_menu = gtk_menu_new(); // Do not show! #endif -#ifdef WXWIN_COMPATIBILITY m_callback = func; -#endif m_eventHandler = this; m_clientData = (void*) NULL; @@ -683,7 +689,9 @@ wxMenu::Init( const wxString& title, wxMenu::~wxMenu() { - /* how do we delete an item-factory ? */ + /* how do we delete an item-factory ? */ + gtk_widget_destroy( m_menu ); + } void wxMenu::SetTitle( const wxString& title ) @@ -724,6 +732,7 @@ void wxMenu::AppendSeparator() m_items.Append( mitem ); } +#if (GTK_MINOR_VERSION > 0) static char* GetHotKey( const wxString &hotkey, char *hotbuf ) { if (hotkey.IsEmpty()) return (char*) NULL; @@ -761,6 +770,7 @@ static char* GetHotKey( const wxString &hotkey, char *hotbuf ) } return (char*) NULL; } +#endif void wxMenu::Append( int id, const wxString &item, const wxString &helpStr, bool checkable ) {