From 1987af7e9f5685198b0c19e2326eebf7e56b7834 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Tue, 2 Nov 1999 15:21:40 +0000 Subject: [PATCH] wxGTK compiles (and seems to work) again after wxMenu changes git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@4300 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/gtk/menu.h | 2 +- include/wx/gtk1/menu.h | 2 +- include/wx/menu.h | 10 +++--- samples/menu/Makefile.in | 21 +++++++++++ samples/menu/menu.cpp | 6 ++-- src/common/menucmn.cpp | 2 +- src/gtk/frame.cpp | 4 +-- src/gtk/menu.cpp | 78 +++++++++++++++++++++------------------- src/gtk/window.cpp | 7 ++-- src/gtk1/frame.cpp | 4 +-- src/gtk1/menu.cpp | 78 +++++++++++++++++++++------------------- src/gtk1/window.cpp | 7 ++-- 12 files changed, 126 insertions(+), 95 deletions(-) create mode 100644 samples/menu/Makefile.in diff --git a/include/wx/gtk/menu.h b/include/wx/gtk/menu.h index 07f1575111..13d2f6b343 100644 --- a/include/wx/gtk/menu.h +++ b/include/wx/gtk/menu.h @@ -77,7 +77,7 @@ public: // TODO: virtual void SetTitle(const wxString& title); -#ifdef WXWIN_COMPATIBILITY +#if WXWIN_COMPATIBILITY wxMenu(const wxString& title, const wxFunction func) : wxMenuBase(title) { diff --git a/include/wx/gtk1/menu.h b/include/wx/gtk1/menu.h index 07f1575111..13d2f6b343 100644 --- a/include/wx/gtk1/menu.h +++ b/include/wx/gtk1/menu.h @@ -77,7 +77,7 @@ public: // TODO: virtual void SetTitle(const wxString& title); -#ifdef WXWIN_COMPATIBILITY +#if WXWIN_COMPATIBILITY wxMenu(const wxString& title, const wxFunction func) : wxMenuBase(title) { diff --git a/include/wx/menu.h b/include/wx/menu.h index 440747fe17..599326cb18 100644 --- a/include/wx/menu.h +++ b/include/wx/menu.h @@ -182,6 +182,11 @@ public: wxFunction m_callback; #endif // WXWIN_COMPATIBILITY + // unlike FindItem(), this function doesn't recurse but only looks through + // our direct children and also may return the index of the found child if + // pos != NULL + wxMenuItem *FindChildItem(int id, size_t *pos = NULL) const; + protected: // virtuals to override in derived classes // --------------------------------------- @@ -199,11 +204,6 @@ protected: // common part of all ctors void Init(long style); - // unlike FindItem(), this function doesn't recurse but only looks through - // our direct children and also may return the index of the found child if - // pos != NULL - wxMenuItem *FindChildItem(int id, size_t *pos = NULL) const; - protected: wxMenuBar *m_menuBar; // menubar we belong to or NULL wxMenu *m_menuParent; // parent menu or NULL diff --git a/samples/menu/Makefile.in b/samples/menu/Makefile.in new file mode 100644 index 0000000000..75b8753d7a --- /dev/null +++ b/samples/menu/Makefile.in @@ -0,0 +1,21 @@ +# +# File: makefile.unx +# Author: Julian Smart +# Created: 1998 +# Updated: +# Copyright: (c) 1998 Julian Smart +# +# "%W% %G%" +# +# Makefile for minimal example (UNIX). + +top_srcdir = @top_srcdir@ +top_builddir = ../.. +program_dir = samples/menu + +PROGRAM=menu + +OBJECTS=$(PROGRAM).o + +include ../../src/makeprog.env + diff --git a/samples/menu/menu.cpp b/samples/menu/menu.cpp index 2e44aa4747..7fa2267150 100644 --- a/samples/menu/menu.cpp +++ b/samples/menu/menu.cpp @@ -313,7 +313,7 @@ void MyFrame::OnDeleteMenu(wxCommandEvent& WXUNUSED(event)) void MyFrame::OnAppendMenu(wxCommandEvent& WXUNUSED(event)) { - static s_count = 0; + static int s_count = 0; wxString title; title.Printf("Dummy menu &%d", ++s_count); @@ -354,7 +354,7 @@ void MyFrame::OnGetLabelMenu(wxCommandEvent& WXUNUSED(event)) size_t count = mbar->GetMenuCount(); wxLogMessage("The label of the last menu item is '%s'", - mbar->GetLabelTop(count - 1)); + mbar->GetLabelTop(count - 1).c_str()); } void MyFrame::OnSetLabelMenu(wxCommandEvent& WXUNUSED(event)) @@ -448,7 +448,7 @@ void MyFrame::OnGetLabelMenuItem(wxCommandEvent& WXUNUSED(event)) if ( item ) { wxLogMessage("The label of the last menu item is '%s'", - item->GetLabel()); + item->GetLabel().c_str()); } } diff --git a/src/common/menucmn.cpp b/src/common/menucmn.cpp index b5e8cd4266..33ccd66f39 100644 --- a/src/common/menucmn.cpp +++ b/src/common/menucmn.cpp @@ -310,7 +310,7 @@ wxMenuItem *wxMenuBase::FindChildItem(int id, size_t *ppos) const if ( ppos ) { - *ppos = item ? pos : wxNOT_FOUND; + *ppos = item ? pos : (size_t)wxNOT_FOUND; } return item; diff --git a/src/gtk/frame.cpp b/src/gtk/frame.cpp index 928f7fa900..2deb4641ea 100644 --- a/src/gtk/frame.cpp +++ b/src/gtk/frame.cpp @@ -1070,10 +1070,10 @@ void wxFrame::Command( int id ) wxMenuBar *bar = GetMenuBar(); if (!bar) return; - wxMenuItem *item = bar->FindItemForId(id) ; + wxMenuItem *item = bar->FindItem(id) ; if (item && item->IsCheckable()) { - bar->Check(id,!bar->Checked(id)) ; + bar->Check(id, !bar->IsChecked(id)) ; } wxEvtHandler* evtHandler = GetEventHandler(); diff --git a/src/gtk/menu.cpp b/src/gtk/menu.cpp index b1906645a9..5ebd301230 100644 --- a/src/gtk/menu.cpp +++ b/src/gtk/menu.cpp @@ -128,13 +128,13 @@ static void wxMenubarUnsetInvokingWindow( wxMenu *menu, wxWindow *win ) gtk_accel_group_detach( menu->m_accel, GTK_OBJECT(top_frame->m_widget) ); #endif - wxNode *node = menu->GetItems().First(); + wxMenuItemList::Node *node = menu->GetMenuItems().GetFirst(); while (node) { - wxMenuItem *menuitem = (wxMenuItem*)node->Data(); + wxMenuItem *menuitem = node->GetData(); if (menuitem->IsSubMenu()) wxMenubarUnsetInvokingWindow( menuitem->GetSubMenu(), win ); - node = node->Next(); + node = node->GetNext(); } } @@ -151,13 +151,13 @@ static void wxMenubarSetInvokingWindow( wxMenu *menu, wxWindow *win ) gtk_accel_group_attach( menu->m_accel, GTK_OBJECT(top_frame->m_widget) ); #endif - wxNode *node = menu->GetItems().First(); + wxMenuItemList::Node *node = menu->GetMenuItems().GetFirst(); while (node) { - wxMenuItem *menuitem = (wxMenuItem*)node->Data(); + wxMenuItem *menuitem = node->GetData(); if (menuitem->IsSubMenu()) wxMenubarSetInvokingWindow( menuitem->GetSubMenu(), win ); - node = node->Next(); + node = node->GetNext(); } } @@ -173,12 +173,12 @@ void wxMenuBar::SetInvokingWindow( wxWindow *win ) gtk_accel_group_attach( m_accel, GTK_OBJECT(top_frame->m_widget) ); #endif - wxNode *node = m_menus.First(); + wxMenuList::Node *node = m_menus.GetFirst(); while (node) { - wxMenu *menu = (wxMenu*)node->Data(); + wxMenu *menu = node->GetData(); wxMenubarSetInvokingWindow( menu, win ); - node = node->Next(); + node = node->GetNext(); } } @@ -194,12 +194,12 @@ void wxMenuBar::UnsetInvokingWindow( wxWindow *win ) gtk_accel_group_detach( m_accel, GTK_OBJECT(top_frame->m_widget) ); #endif - wxNode *node = m_menus.First(); + wxMenuList::Node *node = m_menus.GetFirst(); while (node) { - wxMenu *menu = (wxMenu*)node->Data(); + wxMenu *menu = node->GetData(); wxMenubarUnsetInvokingWindow( menu, win ); - node = node->Next(); + node = node->GetNext(); } } @@ -330,14 +330,14 @@ static int FindMenuItemRecursive( const wxMenu *menu, const wxString &menuString return res; } - wxNode *node = ((wxMenu *)menu)->GetItems().First(); // const_cast + wxMenuItemList::Node *node = menu->GetMenuItems().GetFirst(); while (node) { - wxMenuItem *item = (wxMenuItem*)node->Data(); + wxMenuItem *item = node->GetData(); if (item->IsSubMenu()) return FindMenuItemRecursive(item->GetSubMenu(), menuString, itemString); - node = node->Next(); + node = node->GetNext(); } return wxNOT_FOUND; @@ -345,15 +345,17 @@ static int FindMenuItemRecursive( const wxMenu *menu, const wxString &menuString int wxMenuBar::FindMenuItem( const wxString &menuString, const wxString &itemString ) const { - wxNode *node = m_menus.First(); + wxMenuList::Node *node = m_menus.GetFirst(); while (node) { - wxMenu *menu = (wxMenu*)node->Data(); + wxMenu *menu = node->GetData(); int res = FindMenuItemRecursive( menu, menuString, itemString); - if (res != -1) return res; - node = node->Next(); + if (res != -1) + return res; + node = node->GetNext(); } - return -1; + + return wxNOT_FOUND; } // Find a wxMenuItem using its id. Recurses down into sub-menus @@ -361,15 +363,15 @@ static wxMenuItem* FindMenuItemByIdRecursive(const wxMenu* menu, int id) { wxMenuItem* result = menu->FindChildItem(id); - wxNode *node = ((wxMenu *)menu)->GetItems().First(); // const_cast + wxMenuItemList::Node *node = menu->GetMenuItems().GetFirst(); while ( node && result == NULL ) { - wxMenuItem *item = (wxMenuItem*)node->Data(); + wxMenuItem *item = node->GetData(); if (item->IsSubMenu()) { result = FindMenuItemByIdRecursive( item->GetSubMenu(), id ); } - node = node->Next(); + node = node->GetNext(); } return result; @@ -378,12 +380,12 @@ static wxMenuItem* FindMenuItemByIdRecursive(const wxMenu* menu, int id) wxMenuItem* wxMenuBar::FindItem( int id, wxMenu **menuForItem ) const { wxMenuItem* result = 0; - wxNode *node = m_menus.First(); + wxMenuList::Node *node = m_menus.GetFirst(); while (node && result == 0) { - wxMenu *menu = (wxMenu*)node->Data(); + wxMenu *menu = node->GetData(); result = FindMenuItemByIdRecursive( menu, id ); - node = node->Next(); + node = node->GetNext(); } if ( menuForItem ) @@ -467,11 +469,13 @@ static void gtk_menu_clicked_callback( GtkWidget *widget, wxMenu *menu ) event.SetEventObject( menu ); event.SetInt(id ); +#if WXWIN_COMPATIBILITY if (menu->GetCallback()) { (void) (*(menu->GetCallback())) (*menu, event); return; } +#endif // WXWIN_COMPATIBILITY if (menu->GetEventHandler()->ProcessEvent(event)) return; @@ -607,7 +611,7 @@ void wxMenuItem::SetText( const wxString& str ) gtk_label_set( label, m_text.mb_str()); /* reparse key accel */ - guint accel_key = gtk_label_parse_uline (GTK_LABEL(label), m_text.mb_str() ); + (void)gtk_label_parse_uline (GTK_LABEL(label), m_text.mb_str() ); gtk_accel_label_refetch( GTK_ACCEL_LABEL(label) ); } } @@ -653,7 +657,7 @@ void wxMenuItem::DoSetText( const wxString& str ) wxAcceleratorEntry *wxMenuItem::GetAccel() const { - if ( !item.GetHotKey() ) + if ( !GetHotKey() ) { // nothing return (wxAcceleratorEntry *)NULL; @@ -661,7 +665,7 @@ wxAcceleratorEntry *wxMenuItem::GetAccel() const // as wxGetAccelFromString() looks for TAB, insert a dummy one here wxString label; - label << wxT('\t') << item.GetHotKey(); + label << wxT('\t') << GetHotKey(); return wxGetAccelFromString(label); } @@ -760,7 +764,7 @@ wxMenu::~wxMenu() // the menu items are deleted by the base class dtor } -virtual bool wxMenu::DoAppend(wxMenuItem *mitem) +bool wxMenu::DoAppend(wxMenuItem *mitem) { GtkWidget *menuItem; @@ -802,12 +806,12 @@ virtual bool wxMenu::DoAppend(wxMenuItem *mitem) gtk_item_factory_create_item( m_factory, &entry, (gpointer) this, 2 ); /* what is 2 ? */ wxString path( mitem->GetFactoryPath() ); - GtkWidget *menuItem = gtk_item_factory_get_item( m_factory, path.mb_str() ); + menuItem = gtk_item_factory_get_item( m_factory, path.mb_str() ); #else // GTK+ 1.0 - GtkWidget *menuItem = gtk_menu_item_new_with_label(mitem->GetText().mbc_str()); + menuItem = gtk_menu_item_new_with_label(mitem->GetText().mbc_str()); #endif // GTK 1.2/1.0 - gtk_menu_item_set_submenu( GTK_MENU_ITEM(menuItem), subMenu->m_menu ); + gtk_menu_item_set_submenu( GTK_MENU_ITEM(menuItem), mitem->GetSubMenu()->m_menu ); } else // a normal item { @@ -824,7 +828,7 @@ virtual bool wxMenu::DoAppend(wxMenuItem *mitem) entry.path = buf; entry.callback = (GtkItemFactoryCallback) gtk_menu_clicked_callback; entry.callback_action = 0; - if (checkable) + if ( mitem->IsCheckable() ) entry.item_type = ""; else entry.item_type = ""; @@ -843,10 +847,10 @@ virtual bool wxMenu::DoAppend(wxMenuItem *mitem) gtk_item_factory_create_item( m_factory, &entry, (gpointer) this, 2 ); /* what is 2 ? */ wxString path( mitem->GetFactoryPath() ); - GtkWidget *menuItem = gtk_item_factory_get_widget( m_factory, path.mb_str() ); + menuItem = gtk_item_factory_get_widget( m_factory, path.mb_str() ); #else // GTK+ 1.0 - GtkWidget *menuItem = checkable ? gtk_check_menu_item_new_with_label( mitem->GetText().mb_str() ) - : gtk_menu_item_new_with_label( mitem->GetText().mb_str() ); + menuItem = checkable ? gtk_check_menu_item_new_with_label( mitem->GetText().mb_str() ) + : gtk_menu_item_new_with_label( mitem->GetText().mb_str() ); gtk_signal_connect( GTK_OBJECT(menuItem), "activate", GTK_SIGNAL_FUNC(gtk_menu_clicked_callback), diff --git a/src/gtk/window.cpp b/src/gtk/window.cpp index 5cc4b89019..b254ab8d78 100644 --- a/src/gtk/window.cpp +++ b/src/gtk/window.cpp @@ -2815,15 +2815,16 @@ static void gtk_pop_hide_callback( GtkWidget *WXUNUSED(widget), bool* is_waiting static void SetInvokingWindow( wxMenu *menu, wxWindow *win ) { menu->SetInvokingWindow( win ); - wxNode *node = menu->GetItems().First(); + wxMenuItemList::Node *node = menu->GetMenuItems().GetFirst(); while (node) { - wxMenuItem *menuitem = (wxMenuItem*)node->Data(); + wxMenuItem *menuitem = node->GetData(); if (menuitem->IsSubMenu()) { SetInvokingWindow( menuitem->GetSubMenu(), win ); } - node = node->Next(); + + node = node->GetNext(); } } diff --git a/src/gtk1/frame.cpp b/src/gtk1/frame.cpp index 928f7fa900..2deb4641ea 100644 --- a/src/gtk1/frame.cpp +++ b/src/gtk1/frame.cpp @@ -1070,10 +1070,10 @@ void wxFrame::Command( int id ) wxMenuBar *bar = GetMenuBar(); if (!bar) return; - wxMenuItem *item = bar->FindItemForId(id) ; + wxMenuItem *item = bar->FindItem(id) ; if (item && item->IsCheckable()) { - bar->Check(id,!bar->Checked(id)) ; + bar->Check(id, !bar->IsChecked(id)) ; } wxEvtHandler* evtHandler = GetEventHandler(); diff --git a/src/gtk1/menu.cpp b/src/gtk1/menu.cpp index b1906645a9..5ebd301230 100644 --- a/src/gtk1/menu.cpp +++ b/src/gtk1/menu.cpp @@ -128,13 +128,13 @@ static void wxMenubarUnsetInvokingWindow( wxMenu *menu, wxWindow *win ) gtk_accel_group_detach( menu->m_accel, GTK_OBJECT(top_frame->m_widget) ); #endif - wxNode *node = menu->GetItems().First(); + wxMenuItemList::Node *node = menu->GetMenuItems().GetFirst(); while (node) { - wxMenuItem *menuitem = (wxMenuItem*)node->Data(); + wxMenuItem *menuitem = node->GetData(); if (menuitem->IsSubMenu()) wxMenubarUnsetInvokingWindow( menuitem->GetSubMenu(), win ); - node = node->Next(); + node = node->GetNext(); } } @@ -151,13 +151,13 @@ static void wxMenubarSetInvokingWindow( wxMenu *menu, wxWindow *win ) gtk_accel_group_attach( menu->m_accel, GTK_OBJECT(top_frame->m_widget) ); #endif - wxNode *node = menu->GetItems().First(); + wxMenuItemList::Node *node = menu->GetMenuItems().GetFirst(); while (node) { - wxMenuItem *menuitem = (wxMenuItem*)node->Data(); + wxMenuItem *menuitem = node->GetData(); if (menuitem->IsSubMenu()) wxMenubarSetInvokingWindow( menuitem->GetSubMenu(), win ); - node = node->Next(); + node = node->GetNext(); } } @@ -173,12 +173,12 @@ void wxMenuBar::SetInvokingWindow( wxWindow *win ) gtk_accel_group_attach( m_accel, GTK_OBJECT(top_frame->m_widget) ); #endif - wxNode *node = m_menus.First(); + wxMenuList::Node *node = m_menus.GetFirst(); while (node) { - wxMenu *menu = (wxMenu*)node->Data(); + wxMenu *menu = node->GetData(); wxMenubarSetInvokingWindow( menu, win ); - node = node->Next(); + node = node->GetNext(); } } @@ -194,12 +194,12 @@ void wxMenuBar::UnsetInvokingWindow( wxWindow *win ) gtk_accel_group_detach( m_accel, GTK_OBJECT(top_frame->m_widget) ); #endif - wxNode *node = m_menus.First(); + wxMenuList::Node *node = m_menus.GetFirst(); while (node) { - wxMenu *menu = (wxMenu*)node->Data(); + wxMenu *menu = node->GetData(); wxMenubarUnsetInvokingWindow( menu, win ); - node = node->Next(); + node = node->GetNext(); } } @@ -330,14 +330,14 @@ static int FindMenuItemRecursive( const wxMenu *menu, const wxString &menuString return res; } - wxNode *node = ((wxMenu *)menu)->GetItems().First(); // const_cast + wxMenuItemList::Node *node = menu->GetMenuItems().GetFirst(); while (node) { - wxMenuItem *item = (wxMenuItem*)node->Data(); + wxMenuItem *item = node->GetData(); if (item->IsSubMenu()) return FindMenuItemRecursive(item->GetSubMenu(), menuString, itemString); - node = node->Next(); + node = node->GetNext(); } return wxNOT_FOUND; @@ -345,15 +345,17 @@ static int FindMenuItemRecursive( const wxMenu *menu, const wxString &menuString int wxMenuBar::FindMenuItem( const wxString &menuString, const wxString &itemString ) const { - wxNode *node = m_menus.First(); + wxMenuList::Node *node = m_menus.GetFirst(); while (node) { - wxMenu *menu = (wxMenu*)node->Data(); + wxMenu *menu = node->GetData(); int res = FindMenuItemRecursive( menu, menuString, itemString); - if (res != -1) return res; - node = node->Next(); + if (res != -1) + return res; + node = node->GetNext(); } - return -1; + + return wxNOT_FOUND; } // Find a wxMenuItem using its id. Recurses down into sub-menus @@ -361,15 +363,15 @@ static wxMenuItem* FindMenuItemByIdRecursive(const wxMenu* menu, int id) { wxMenuItem* result = menu->FindChildItem(id); - wxNode *node = ((wxMenu *)menu)->GetItems().First(); // const_cast + wxMenuItemList::Node *node = menu->GetMenuItems().GetFirst(); while ( node && result == NULL ) { - wxMenuItem *item = (wxMenuItem*)node->Data(); + wxMenuItem *item = node->GetData(); if (item->IsSubMenu()) { result = FindMenuItemByIdRecursive( item->GetSubMenu(), id ); } - node = node->Next(); + node = node->GetNext(); } return result; @@ -378,12 +380,12 @@ static wxMenuItem* FindMenuItemByIdRecursive(const wxMenu* menu, int id) wxMenuItem* wxMenuBar::FindItem( int id, wxMenu **menuForItem ) const { wxMenuItem* result = 0; - wxNode *node = m_menus.First(); + wxMenuList::Node *node = m_menus.GetFirst(); while (node && result == 0) { - wxMenu *menu = (wxMenu*)node->Data(); + wxMenu *menu = node->GetData(); result = FindMenuItemByIdRecursive( menu, id ); - node = node->Next(); + node = node->GetNext(); } if ( menuForItem ) @@ -467,11 +469,13 @@ static void gtk_menu_clicked_callback( GtkWidget *widget, wxMenu *menu ) event.SetEventObject( menu ); event.SetInt(id ); +#if WXWIN_COMPATIBILITY if (menu->GetCallback()) { (void) (*(menu->GetCallback())) (*menu, event); return; } +#endif // WXWIN_COMPATIBILITY if (menu->GetEventHandler()->ProcessEvent(event)) return; @@ -607,7 +611,7 @@ void wxMenuItem::SetText( const wxString& str ) gtk_label_set( label, m_text.mb_str()); /* reparse key accel */ - guint accel_key = gtk_label_parse_uline (GTK_LABEL(label), m_text.mb_str() ); + (void)gtk_label_parse_uline (GTK_LABEL(label), m_text.mb_str() ); gtk_accel_label_refetch( GTK_ACCEL_LABEL(label) ); } } @@ -653,7 +657,7 @@ void wxMenuItem::DoSetText( const wxString& str ) wxAcceleratorEntry *wxMenuItem::GetAccel() const { - if ( !item.GetHotKey() ) + if ( !GetHotKey() ) { // nothing return (wxAcceleratorEntry *)NULL; @@ -661,7 +665,7 @@ wxAcceleratorEntry *wxMenuItem::GetAccel() const // as wxGetAccelFromString() looks for TAB, insert a dummy one here wxString label; - label << wxT('\t') << item.GetHotKey(); + label << wxT('\t') << GetHotKey(); return wxGetAccelFromString(label); } @@ -760,7 +764,7 @@ wxMenu::~wxMenu() // the menu items are deleted by the base class dtor } -virtual bool wxMenu::DoAppend(wxMenuItem *mitem) +bool wxMenu::DoAppend(wxMenuItem *mitem) { GtkWidget *menuItem; @@ -802,12 +806,12 @@ virtual bool wxMenu::DoAppend(wxMenuItem *mitem) gtk_item_factory_create_item( m_factory, &entry, (gpointer) this, 2 ); /* what is 2 ? */ wxString path( mitem->GetFactoryPath() ); - GtkWidget *menuItem = gtk_item_factory_get_item( m_factory, path.mb_str() ); + menuItem = gtk_item_factory_get_item( m_factory, path.mb_str() ); #else // GTK+ 1.0 - GtkWidget *menuItem = gtk_menu_item_new_with_label(mitem->GetText().mbc_str()); + menuItem = gtk_menu_item_new_with_label(mitem->GetText().mbc_str()); #endif // GTK 1.2/1.0 - gtk_menu_item_set_submenu( GTK_MENU_ITEM(menuItem), subMenu->m_menu ); + gtk_menu_item_set_submenu( GTK_MENU_ITEM(menuItem), mitem->GetSubMenu()->m_menu ); } else // a normal item { @@ -824,7 +828,7 @@ virtual bool wxMenu::DoAppend(wxMenuItem *mitem) entry.path = buf; entry.callback = (GtkItemFactoryCallback) gtk_menu_clicked_callback; entry.callback_action = 0; - if (checkable) + if ( mitem->IsCheckable() ) entry.item_type = ""; else entry.item_type = ""; @@ -843,10 +847,10 @@ virtual bool wxMenu::DoAppend(wxMenuItem *mitem) gtk_item_factory_create_item( m_factory, &entry, (gpointer) this, 2 ); /* what is 2 ? */ wxString path( mitem->GetFactoryPath() ); - GtkWidget *menuItem = gtk_item_factory_get_widget( m_factory, path.mb_str() ); + menuItem = gtk_item_factory_get_widget( m_factory, path.mb_str() ); #else // GTK+ 1.0 - GtkWidget *menuItem = checkable ? gtk_check_menu_item_new_with_label( mitem->GetText().mb_str() ) - : gtk_menu_item_new_with_label( mitem->GetText().mb_str() ); + menuItem = checkable ? gtk_check_menu_item_new_with_label( mitem->GetText().mb_str() ) + : gtk_menu_item_new_with_label( mitem->GetText().mb_str() ); gtk_signal_connect( GTK_OBJECT(menuItem), "activate", GTK_SIGNAL_FUNC(gtk_menu_clicked_callback), diff --git a/src/gtk1/window.cpp b/src/gtk1/window.cpp index 5cc4b89019..b254ab8d78 100644 --- a/src/gtk1/window.cpp +++ b/src/gtk1/window.cpp @@ -2815,15 +2815,16 @@ static void gtk_pop_hide_callback( GtkWidget *WXUNUSED(widget), bool* is_waiting static void SetInvokingWindow( wxMenu *menu, wxWindow *win ) { menu->SetInvokingWindow( win ); - wxNode *node = menu->GetItems().First(); + wxMenuItemList::Node *node = menu->GetMenuItems().GetFirst(); while (node) { - wxMenuItem *menuitem = (wxMenuItem*)node->Data(); + wxMenuItem *menuitem = node->GetData(); if (menuitem->IsSubMenu()) { SetInvokingWindow( menuitem->GetSubMenu(), win ); } - node = node->Next(); + + node = node->GetNext(); } } -- 2.45.2