X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/232806507ba60bd768605f0d7e8ae8e27dc17e8b..22d6efa851642c6a69174278fc50f712f41e2271:/src/gtk/menu.cpp diff --git a/src/gtk/menu.cpp b/src/gtk/menu.cpp index 48ac17d030..1fec1d74fc 100644 --- a/src/gtk/menu.cpp +++ b/src/gtk/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. */ @@ -212,10 +222,13 @@ void wxMenuBar::Append( wxMenu *menu, const wxString &title ) /* local buffer in multibyte form */ wxString buf; - buf << '/' << str.mb_str(); + buf << _T('/') << str.c_str(); + char *cbuf = new char[buf.Length()]; + strcpy(cbuf, buf.mbc_str()); + GtkItemFactoryEntry entry; - entry.path = (gchar *)buf.c_str(); // const_cast + entry.path = (gchar *)cbuf; // const_cast entry.accelerator = (gchar*) NULL; entry.callback = (GtkItemFactoryCallback) NULL; entry.callback_action = 0; @@ -498,15 +511,6 @@ static void gtk_menu_hilight_callback( GtkWidget *widget, wxMenu *menu ) wxMenuEvent event( wxEVT_MENU_HIGHLIGHT, id ); event.SetEventObject( menu ); -/* wxMSW doesn't call callback here either - - if (menu->m_callback) - { - (void) (*(menu->m_callback)) (*menu, event); - return; - } -*/ - if (menu->GetEventHandler()->ProcessEvent(event)) return; @@ -632,18 +636,11 @@ bool wxMenuItem::IsChecked() const IMPLEMENT_DYNAMIC_CLASS(wxMenu,wxEvtHandler) -wxMenu::wxMenu( const wxString& title, const wxFunction func, long style ) -{ - Init(title, func, style); -} - -wxMenu::wxMenu(long style) -{ - Init(wxEmptyString, (wxFunction) NULL, style); -} - void -wxMenu::Init( const wxString& title, const wxFunction func, long style ) +wxMenu::Init( const wxString& title, + long style, + const wxFunction func + ) { m_title = title; m_items.DeleteContents( TRUE ); @@ -659,6 +656,7 @@ wxMenu::Init( const wxString& title, const wxFunction func, long style ) #endif m_callback = func; + m_eventHandler = this; m_clientData = (void*) NULL; @@ -691,7 +689,9 @@ wxMenu::Init( const wxString& title, const wxFunction func, long style ) 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 )