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
This commit is contained in:
@@ -77,7 +77,7 @@ public:
|
|||||||
|
|
||||||
// TODO: virtual void SetTitle(const wxString& title);
|
// TODO: virtual void SetTitle(const wxString& title);
|
||||||
|
|
||||||
#ifdef WXWIN_COMPATIBILITY
|
#if WXWIN_COMPATIBILITY
|
||||||
wxMenu(const wxString& title, const wxFunction func)
|
wxMenu(const wxString& title, const wxFunction func)
|
||||||
: wxMenuBase(title)
|
: wxMenuBase(title)
|
||||||
{
|
{
|
||||||
|
@@ -77,7 +77,7 @@ public:
|
|||||||
|
|
||||||
// TODO: virtual void SetTitle(const wxString& title);
|
// TODO: virtual void SetTitle(const wxString& title);
|
||||||
|
|
||||||
#ifdef WXWIN_COMPATIBILITY
|
#if WXWIN_COMPATIBILITY
|
||||||
wxMenu(const wxString& title, const wxFunction func)
|
wxMenu(const wxString& title, const wxFunction func)
|
||||||
: wxMenuBase(title)
|
: wxMenuBase(title)
|
||||||
{
|
{
|
||||||
|
@@ -182,6 +182,11 @@ public:
|
|||||||
wxFunction m_callback;
|
wxFunction m_callback;
|
||||||
#endif // WXWIN_COMPATIBILITY
|
#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:
|
protected:
|
||||||
// virtuals to override in derived classes
|
// virtuals to override in derived classes
|
||||||
// ---------------------------------------
|
// ---------------------------------------
|
||||||
@@ -199,11 +204,6 @@ protected:
|
|||||||
// common part of all ctors
|
// common part of all ctors
|
||||||
void Init(long style);
|
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:
|
protected:
|
||||||
wxMenuBar *m_menuBar; // menubar we belong to or NULL
|
wxMenuBar *m_menuBar; // menubar we belong to or NULL
|
||||||
wxMenu *m_menuParent; // parent menu or NULL
|
wxMenu *m_menuParent; // parent menu or NULL
|
||||||
|
21
samples/menu/Makefile.in
Normal file
21
samples/menu/Makefile.in
Normal file
@@ -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
|
||||||
|
|
@@ -313,7 +313,7 @@ void MyFrame::OnDeleteMenu(wxCommandEvent& WXUNUSED(event))
|
|||||||
|
|
||||||
void MyFrame::OnAppendMenu(wxCommandEvent& WXUNUSED(event))
|
void MyFrame::OnAppendMenu(wxCommandEvent& WXUNUSED(event))
|
||||||
{
|
{
|
||||||
static s_count = 0;
|
static int s_count = 0;
|
||||||
|
|
||||||
wxString title;
|
wxString title;
|
||||||
title.Printf("Dummy menu &%d", ++s_count);
|
title.Printf("Dummy menu &%d", ++s_count);
|
||||||
@@ -354,7 +354,7 @@ void MyFrame::OnGetLabelMenu(wxCommandEvent& WXUNUSED(event))
|
|||||||
size_t count = mbar->GetMenuCount();
|
size_t count = mbar->GetMenuCount();
|
||||||
|
|
||||||
wxLogMessage("The label of the last menu item is '%s'",
|
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))
|
void MyFrame::OnSetLabelMenu(wxCommandEvent& WXUNUSED(event))
|
||||||
@@ -448,7 +448,7 @@ void MyFrame::OnGetLabelMenuItem(wxCommandEvent& WXUNUSED(event))
|
|||||||
if ( item )
|
if ( item )
|
||||||
{
|
{
|
||||||
wxLogMessage("The label of the last menu item is '%s'",
|
wxLogMessage("The label of the last menu item is '%s'",
|
||||||
item->GetLabel());
|
item->GetLabel().c_str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -310,7 +310,7 @@ wxMenuItem *wxMenuBase::FindChildItem(int id, size_t *ppos) const
|
|||||||
|
|
||||||
if ( ppos )
|
if ( ppos )
|
||||||
{
|
{
|
||||||
*ppos = item ? pos : wxNOT_FOUND;
|
*ppos = item ? pos : (size_t)wxNOT_FOUND;
|
||||||
}
|
}
|
||||||
|
|
||||||
return item;
|
return item;
|
||||||
|
@@ -1070,10 +1070,10 @@ void wxFrame::Command( int id )
|
|||||||
wxMenuBar *bar = GetMenuBar();
|
wxMenuBar *bar = GetMenuBar();
|
||||||
if (!bar) return;
|
if (!bar) return;
|
||||||
|
|
||||||
wxMenuItem *item = bar->FindItemForId(id) ;
|
wxMenuItem *item = bar->FindItem(id) ;
|
||||||
if (item && item->IsCheckable())
|
if (item && item->IsCheckable())
|
||||||
{
|
{
|
||||||
bar->Check(id,!bar->Checked(id)) ;
|
bar->Check(id, !bar->IsChecked(id)) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxEvtHandler* evtHandler = GetEventHandler();
|
wxEvtHandler* evtHandler = GetEventHandler();
|
||||||
|
@@ -128,13 +128,13 @@ static void wxMenubarUnsetInvokingWindow( wxMenu *menu, wxWindow *win )
|
|||||||
gtk_accel_group_detach( menu->m_accel, GTK_OBJECT(top_frame->m_widget) );
|
gtk_accel_group_detach( menu->m_accel, GTK_OBJECT(top_frame->m_widget) );
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
wxNode *node = menu->GetItems().First();
|
wxMenuItemList::Node *node = menu->GetMenuItems().GetFirst();
|
||||||
while (node)
|
while (node)
|
||||||
{
|
{
|
||||||
wxMenuItem *menuitem = (wxMenuItem*)node->Data();
|
wxMenuItem *menuitem = node->GetData();
|
||||||
if (menuitem->IsSubMenu())
|
if (menuitem->IsSubMenu())
|
||||||
wxMenubarUnsetInvokingWindow( menuitem->GetSubMenu(), win );
|
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) );
|
gtk_accel_group_attach( menu->m_accel, GTK_OBJECT(top_frame->m_widget) );
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
wxNode *node = menu->GetItems().First();
|
wxMenuItemList::Node *node = menu->GetMenuItems().GetFirst();
|
||||||
while (node)
|
while (node)
|
||||||
{
|
{
|
||||||
wxMenuItem *menuitem = (wxMenuItem*)node->Data();
|
wxMenuItem *menuitem = node->GetData();
|
||||||
if (menuitem->IsSubMenu())
|
if (menuitem->IsSubMenu())
|
||||||
wxMenubarSetInvokingWindow( menuitem->GetSubMenu(), win );
|
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) );
|
gtk_accel_group_attach( m_accel, GTK_OBJECT(top_frame->m_widget) );
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
wxNode *node = m_menus.First();
|
wxMenuList::Node *node = m_menus.GetFirst();
|
||||||
while (node)
|
while (node)
|
||||||
{
|
{
|
||||||
wxMenu *menu = (wxMenu*)node->Data();
|
wxMenu *menu = node->GetData();
|
||||||
wxMenubarSetInvokingWindow( menu, win );
|
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) );
|
gtk_accel_group_detach( m_accel, GTK_OBJECT(top_frame->m_widget) );
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
wxNode *node = m_menus.First();
|
wxMenuList::Node *node = m_menus.GetFirst();
|
||||||
while (node)
|
while (node)
|
||||||
{
|
{
|
||||||
wxMenu *menu = (wxMenu*)node->Data();
|
wxMenu *menu = node->GetData();
|
||||||
wxMenubarUnsetInvokingWindow( menu, win );
|
wxMenubarUnsetInvokingWindow( menu, win );
|
||||||
node = node->Next();
|
node = node->GetNext();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -330,14 +330,14 @@ static int FindMenuItemRecursive( const wxMenu *menu, const wxString &menuString
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxNode *node = ((wxMenu *)menu)->GetItems().First(); // const_cast
|
wxMenuItemList::Node *node = menu->GetMenuItems().GetFirst();
|
||||||
while (node)
|
while (node)
|
||||||
{
|
{
|
||||||
wxMenuItem *item = (wxMenuItem*)node->Data();
|
wxMenuItem *item = node->GetData();
|
||||||
if (item->IsSubMenu())
|
if (item->IsSubMenu())
|
||||||
return FindMenuItemRecursive(item->GetSubMenu(), menuString, itemString);
|
return FindMenuItemRecursive(item->GetSubMenu(), menuString, itemString);
|
||||||
|
|
||||||
node = node->Next();
|
node = node->GetNext();
|
||||||
}
|
}
|
||||||
|
|
||||||
return wxNOT_FOUND;
|
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
|
int wxMenuBar::FindMenuItem( const wxString &menuString, const wxString &itemString ) const
|
||||||
{
|
{
|
||||||
wxNode *node = m_menus.First();
|
wxMenuList::Node *node = m_menus.GetFirst();
|
||||||
while (node)
|
while (node)
|
||||||
{
|
{
|
||||||
wxMenu *menu = (wxMenu*)node->Data();
|
wxMenu *menu = node->GetData();
|
||||||
int res = FindMenuItemRecursive( menu, menuString, itemString);
|
int res = FindMenuItemRecursive( menu, menuString, itemString);
|
||||||
if (res != -1) return res;
|
if (res != -1)
|
||||||
node = node->Next();
|
return res;
|
||||||
|
node = node->GetNext();
|
||||||
}
|
}
|
||||||
return -1;
|
|
||||||
|
return wxNOT_FOUND;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Find a wxMenuItem using its id. Recurses down into sub-menus
|
// 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);
|
wxMenuItem* result = menu->FindChildItem(id);
|
||||||
|
|
||||||
wxNode *node = ((wxMenu *)menu)->GetItems().First(); // const_cast
|
wxMenuItemList::Node *node = menu->GetMenuItems().GetFirst();
|
||||||
while ( node && result == NULL )
|
while ( node && result == NULL )
|
||||||
{
|
{
|
||||||
wxMenuItem *item = (wxMenuItem*)node->Data();
|
wxMenuItem *item = node->GetData();
|
||||||
if (item->IsSubMenu())
|
if (item->IsSubMenu())
|
||||||
{
|
{
|
||||||
result = FindMenuItemByIdRecursive( item->GetSubMenu(), id );
|
result = FindMenuItemByIdRecursive( item->GetSubMenu(), id );
|
||||||
}
|
}
|
||||||
node = node->Next();
|
node = node->GetNext();
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
@@ -378,12 +380,12 @@ static wxMenuItem* FindMenuItemByIdRecursive(const wxMenu* menu, int id)
|
|||||||
wxMenuItem* wxMenuBar::FindItem( int id, wxMenu **menuForItem ) const
|
wxMenuItem* wxMenuBar::FindItem( int id, wxMenu **menuForItem ) const
|
||||||
{
|
{
|
||||||
wxMenuItem* result = 0;
|
wxMenuItem* result = 0;
|
||||||
wxNode *node = m_menus.First();
|
wxMenuList::Node *node = m_menus.GetFirst();
|
||||||
while (node && result == 0)
|
while (node && result == 0)
|
||||||
{
|
{
|
||||||
wxMenu *menu = (wxMenu*)node->Data();
|
wxMenu *menu = node->GetData();
|
||||||
result = FindMenuItemByIdRecursive( menu, id );
|
result = FindMenuItemByIdRecursive( menu, id );
|
||||||
node = node->Next();
|
node = node->GetNext();
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( menuForItem )
|
if ( menuForItem )
|
||||||
@@ -467,11 +469,13 @@ static void gtk_menu_clicked_callback( GtkWidget *widget, wxMenu *menu )
|
|||||||
event.SetEventObject( menu );
|
event.SetEventObject( menu );
|
||||||
event.SetInt(id );
|
event.SetInt(id );
|
||||||
|
|
||||||
|
#if WXWIN_COMPATIBILITY
|
||||||
if (menu->GetCallback())
|
if (menu->GetCallback())
|
||||||
{
|
{
|
||||||
(void) (*(menu->GetCallback())) (*menu, event);
|
(void) (*(menu->GetCallback())) (*menu, event);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
#endif // WXWIN_COMPATIBILITY
|
||||||
|
|
||||||
if (menu->GetEventHandler()->ProcessEvent(event))
|
if (menu->GetEventHandler()->ProcessEvent(event))
|
||||||
return;
|
return;
|
||||||
@@ -607,7 +611,7 @@ void wxMenuItem::SetText( const wxString& str )
|
|||||||
gtk_label_set( label, m_text.mb_str());
|
gtk_label_set( label, m_text.mb_str());
|
||||||
|
|
||||||
/* reparse key accel */
|
/* 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) );
|
gtk_accel_label_refetch( GTK_ACCEL_LABEL(label) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -653,7 +657,7 @@ void wxMenuItem::DoSetText( const wxString& str )
|
|||||||
|
|
||||||
wxAcceleratorEntry *wxMenuItem::GetAccel() const
|
wxAcceleratorEntry *wxMenuItem::GetAccel() const
|
||||||
{
|
{
|
||||||
if ( !item.GetHotKey() )
|
if ( !GetHotKey() )
|
||||||
{
|
{
|
||||||
// nothing
|
// nothing
|
||||||
return (wxAcceleratorEntry *)NULL;
|
return (wxAcceleratorEntry *)NULL;
|
||||||
@@ -661,7 +665,7 @@ wxAcceleratorEntry *wxMenuItem::GetAccel() const
|
|||||||
|
|
||||||
// as wxGetAccelFromString() looks for TAB, insert a dummy one here
|
// as wxGetAccelFromString() looks for TAB, insert a dummy one here
|
||||||
wxString label;
|
wxString label;
|
||||||
label << wxT('\t') << item.GetHotKey();
|
label << wxT('\t') << GetHotKey();
|
||||||
|
|
||||||
return wxGetAccelFromString(label);
|
return wxGetAccelFromString(label);
|
||||||
}
|
}
|
||||||
@@ -760,7 +764,7 @@ wxMenu::~wxMenu()
|
|||||||
// the menu items are deleted by the base class dtor
|
// the menu items are deleted by the base class dtor
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual bool wxMenu::DoAppend(wxMenuItem *mitem)
|
bool wxMenu::DoAppend(wxMenuItem *mitem)
|
||||||
{
|
{
|
||||||
GtkWidget *menuItem;
|
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 ? */
|
gtk_item_factory_create_item( m_factory, &entry, (gpointer) this, 2 ); /* what is 2 ? */
|
||||||
|
|
||||||
wxString path( mitem->GetFactoryPath() );
|
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
|
#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
|
#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
|
else // a normal item
|
||||||
{
|
{
|
||||||
@@ -824,7 +828,7 @@ virtual bool wxMenu::DoAppend(wxMenuItem *mitem)
|
|||||||
entry.path = buf;
|
entry.path = buf;
|
||||||
entry.callback = (GtkItemFactoryCallback) gtk_menu_clicked_callback;
|
entry.callback = (GtkItemFactoryCallback) gtk_menu_clicked_callback;
|
||||||
entry.callback_action = 0;
|
entry.callback_action = 0;
|
||||||
if (checkable)
|
if ( mitem->IsCheckable() )
|
||||||
entry.item_type = "<CheckItem>";
|
entry.item_type = "<CheckItem>";
|
||||||
else
|
else
|
||||||
entry.item_type = "<Item>";
|
entry.item_type = "<Item>";
|
||||||
@@ -843,9 +847,9 @@ virtual bool wxMenu::DoAppend(wxMenuItem *mitem)
|
|||||||
gtk_item_factory_create_item( m_factory, &entry, (gpointer) this, 2 ); /* what is 2 ? */
|
gtk_item_factory_create_item( m_factory, &entry, (gpointer) this, 2 ); /* what is 2 ? */
|
||||||
|
|
||||||
wxString path( mitem->GetFactoryPath() );
|
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
|
#else // GTK+ 1.0
|
||||||
GtkWidget *menuItem = checkable ? gtk_check_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_menu_item_new_with_label( mitem->GetText().mb_str() );
|
||||||
|
|
||||||
gtk_signal_connect( GTK_OBJECT(menuItem), "activate",
|
gtk_signal_connect( GTK_OBJECT(menuItem), "activate",
|
||||||
|
@@ -2815,15 +2815,16 @@ static void gtk_pop_hide_callback( GtkWidget *WXUNUSED(widget), bool* is_waiting
|
|||||||
static void SetInvokingWindow( wxMenu *menu, wxWindow *win )
|
static void SetInvokingWindow( wxMenu *menu, wxWindow *win )
|
||||||
{
|
{
|
||||||
menu->SetInvokingWindow( win );
|
menu->SetInvokingWindow( win );
|
||||||
wxNode *node = menu->GetItems().First();
|
wxMenuItemList::Node *node = menu->GetMenuItems().GetFirst();
|
||||||
while (node)
|
while (node)
|
||||||
{
|
{
|
||||||
wxMenuItem *menuitem = (wxMenuItem*)node->Data();
|
wxMenuItem *menuitem = node->GetData();
|
||||||
if (menuitem->IsSubMenu())
|
if (menuitem->IsSubMenu())
|
||||||
{
|
{
|
||||||
SetInvokingWindow( menuitem->GetSubMenu(), win );
|
SetInvokingWindow( menuitem->GetSubMenu(), win );
|
||||||
}
|
}
|
||||||
node = node->Next();
|
|
||||||
|
node = node->GetNext();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -1070,10 +1070,10 @@ void wxFrame::Command( int id )
|
|||||||
wxMenuBar *bar = GetMenuBar();
|
wxMenuBar *bar = GetMenuBar();
|
||||||
if (!bar) return;
|
if (!bar) return;
|
||||||
|
|
||||||
wxMenuItem *item = bar->FindItemForId(id) ;
|
wxMenuItem *item = bar->FindItem(id) ;
|
||||||
if (item && item->IsCheckable())
|
if (item && item->IsCheckable())
|
||||||
{
|
{
|
||||||
bar->Check(id,!bar->Checked(id)) ;
|
bar->Check(id, !bar->IsChecked(id)) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxEvtHandler* evtHandler = GetEventHandler();
|
wxEvtHandler* evtHandler = GetEventHandler();
|
||||||
|
@@ -128,13 +128,13 @@ static void wxMenubarUnsetInvokingWindow( wxMenu *menu, wxWindow *win )
|
|||||||
gtk_accel_group_detach( menu->m_accel, GTK_OBJECT(top_frame->m_widget) );
|
gtk_accel_group_detach( menu->m_accel, GTK_OBJECT(top_frame->m_widget) );
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
wxNode *node = menu->GetItems().First();
|
wxMenuItemList::Node *node = menu->GetMenuItems().GetFirst();
|
||||||
while (node)
|
while (node)
|
||||||
{
|
{
|
||||||
wxMenuItem *menuitem = (wxMenuItem*)node->Data();
|
wxMenuItem *menuitem = node->GetData();
|
||||||
if (menuitem->IsSubMenu())
|
if (menuitem->IsSubMenu())
|
||||||
wxMenubarUnsetInvokingWindow( menuitem->GetSubMenu(), win );
|
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) );
|
gtk_accel_group_attach( menu->m_accel, GTK_OBJECT(top_frame->m_widget) );
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
wxNode *node = menu->GetItems().First();
|
wxMenuItemList::Node *node = menu->GetMenuItems().GetFirst();
|
||||||
while (node)
|
while (node)
|
||||||
{
|
{
|
||||||
wxMenuItem *menuitem = (wxMenuItem*)node->Data();
|
wxMenuItem *menuitem = node->GetData();
|
||||||
if (menuitem->IsSubMenu())
|
if (menuitem->IsSubMenu())
|
||||||
wxMenubarSetInvokingWindow( menuitem->GetSubMenu(), win );
|
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) );
|
gtk_accel_group_attach( m_accel, GTK_OBJECT(top_frame->m_widget) );
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
wxNode *node = m_menus.First();
|
wxMenuList::Node *node = m_menus.GetFirst();
|
||||||
while (node)
|
while (node)
|
||||||
{
|
{
|
||||||
wxMenu *menu = (wxMenu*)node->Data();
|
wxMenu *menu = node->GetData();
|
||||||
wxMenubarSetInvokingWindow( menu, win );
|
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) );
|
gtk_accel_group_detach( m_accel, GTK_OBJECT(top_frame->m_widget) );
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
wxNode *node = m_menus.First();
|
wxMenuList::Node *node = m_menus.GetFirst();
|
||||||
while (node)
|
while (node)
|
||||||
{
|
{
|
||||||
wxMenu *menu = (wxMenu*)node->Data();
|
wxMenu *menu = node->GetData();
|
||||||
wxMenubarUnsetInvokingWindow( menu, win );
|
wxMenubarUnsetInvokingWindow( menu, win );
|
||||||
node = node->Next();
|
node = node->GetNext();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -330,14 +330,14 @@ static int FindMenuItemRecursive( const wxMenu *menu, const wxString &menuString
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxNode *node = ((wxMenu *)menu)->GetItems().First(); // const_cast
|
wxMenuItemList::Node *node = menu->GetMenuItems().GetFirst();
|
||||||
while (node)
|
while (node)
|
||||||
{
|
{
|
||||||
wxMenuItem *item = (wxMenuItem*)node->Data();
|
wxMenuItem *item = node->GetData();
|
||||||
if (item->IsSubMenu())
|
if (item->IsSubMenu())
|
||||||
return FindMenuItemRecursive(item->GetSubMenu(), menuString, itemString);
|
return FindMenuItemRecursive(item->GetSubMenu(), menuString, itemString);
|
||||||
|
|
||||||
node = node->Next();
|
node = node->GetNext();
|
||||||
}
|
}
|
||||||
|
|
||||||
return wxNOT_FOUND;
|
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
|
int wxMenuBar::FindMenuItem( const wxString &menuString, const wxString &itemString ) const
|
||||||
{
|
{
|
||||||
wxNode *node = m_menus.First();
|
wxMenuList::Node *node = m_menus.GetFirst();
|
||||||
while (node)
|
while (node)
|
||||||
{
|
{
|
||||||
wxMenu *menu = (wxMenu*)node->Data();
|
wxMenu *menu = node->GetData();
|
||||||
int res = FindMenuItemRecursive( menu, menuString, itemString);
|
int res = FindMenuItemRecursive( menu, menuString, itemString);
|
||||||
if (res != -1) return res;
|
if (res != -1)
|
||||||
node = node->Next();
|
return res;
|
||||||
|
node = node->GetNext();
|
||||||
}
|
}
|
||||||
return -1;
|
|
||||||
|
return wxNOT_FOUND;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Find a wxMenuItem using its id. Recurses down into sub-menus
|
// 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);
|
wxMenuItem* result = menu->FindChildItem(id);
|
||||||
|
|
||||||
wxNode *node = ((wxMenu *)menu)->GetItems().First(); // const_cast
|
wxMenuItemList::Node *node = menu->GetMenuItems().GetFirst();
|
||||||
while ( node && result == NULL )
|
while ( node && result == NULL )
|
||||||
{
|
{
|
||||||
wxMenuItem *item = (wxMenuItem*)node->Data();
|
wxMenuItem *item = node->GetData();
|
||||||
if (item->IsSubMenu())
|
if (item->IsSubMenu())
|
||||||
{
|
{
|
||||||
result = FindMenuItemByIdRecursive( item->GetSubMenu(), id );
|
result = FindMenuItemByIdRecursive( item->GetSubMenu(), id );
|
||||||
}
|
}
|
||||||
node = node->Next();
|
node = node->GetNext();
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
@@ -378,12 +380,12 @@ static wxMenuItem* FindMenuItemByIdRecursive(const wxMenu* menu, int id)
|
|||||||
wxMenuItem* wxMenuBar::FindItem( int id, wxMenu **menuForItem ) const
|
wxMenuItem* wxMenuBar::FindItem( int id, wxMenu **menuForItem ) const
|
||||||
{
|
{
|
||||||
wxMenuItem* result = 0;
|
wxMenuItem* result = 0;
|
||||||
wxNode *node = m_menus.First();
|
wxMenuList::Node *node = m_menus.GetFirst();
|
||||||
while (node && result == 0)
|
while (node && result == 0)
|
||||||
{
|
{
|
||||||
wxMenu *menu = (wxMenu*)node->Data();
|
wxMenu *menu = node->GetData();
|
||||||
result = FindMenuItemByIdRecursive( menu, id );
|
result = FindMenuItemByIdRecursive( menu, id );
|
||||||
node = node->Next();
|
node = node->GetNext();
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( menuForItem )
|
if ( menuForItem )
|
||||||
@@ -467,11 +469,13 @@ static void gtk_menu_clicked_callback( GtkWidget *widget, wxMenu *menu )
|
|||||||
event.SetEventObject( menu );
|
event.SetEventObject( menu );
|
||||||
event.SetInt(id );
|
event.SetInt(id );
|
||||||
|
|
||||||
|
#if WXWIN_COMPATIBILITY
|
||||||
if (menu->GetCallback())
|
if (menu->GetCallback())
|
||||||
{
|
{
|
||||||
(void) (*(menu->GetCallback())) (*menu, event);
|
(void) (*(menu->GetCallback())) (*menu, event);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
#endif // WXWIN_COMPATIBILITY
|
||||||
|
|
||||||
if (menu->GetEventHandler()->ProcessEvent(event))
|
if (menu->GetEventHandler()->ProcessEvent(event))
|
||||||
return;
|
return;
|
||||||
@@ -607,7 +611,7 @@ void wxMenuItem::SetText( const wxString& str )
|
|||||||
gtk_label_set( label, m_text.mb_str());
|
gtk_label_set( label, m_text.mb_str());
|
||||||
|
|
||||||
/* reparse key accel */
|
/* 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) );
|
gtk_accel_label_refetch( GTK_ACCEL_LABEL(label) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -653,7 +657,7 @@ void wxMenuItem::DoSetText( const wxString& str )
|
|||||||
|
|
||||||
wxAcceleratorEntry *wxMenuItem::GetAccel() const
|
wxAcceleratorEntry *wxMenuItem::GetAccel() const
|
||||||
{
|
{
|
||||||
if ( !item.GetHotKey() )
|
if ( !GetHotKey() )
|
||||||
{
|
{
|
||||||
// nothing
|
// nothing
|
||||||
return (wxAcceleratorEntry *)NULL;
|
return (wxAcceleratorEntry *)NULL;
|
||||||
@@ -661,7 +665,7 @@ wxAcceleratorEntry *wxMenuItem::GetAccel() const
|
|||||||
|
|
||||||
// as wxGetAccelFromString() looks for TAB, insert a dummy one here
|
// as wxGetAccelFromString() looks for TAB, insert a dummy one here
|
||||||
wxString label;
|
wxString label;
|
||||||
label << wxT('\t') << item.GetHotKey();
|
label << wxT('\t') << GetHotKey();
|
||||||
|
|
||||||
return wxGetAccelFromString(label);
|
return wxGetAccelFromString(label);
|
||||||
}
|
}
|
||||||
@@ -760,7 +764,7 @@ wxMenu::~wxMenu()
|
|||||||
// the menu items are deleted by the base class dtor
|
// the menu items are deleted by the base class dtor
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual bool wxMenu::DoAppend(wxMenuItem *mitem)
|
bool wxMenu::DoAppend(wxMenuItem *mitem)
|
||||||
{
|
{
|
||||||
GtkWidget *menuItem;
|
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 ? */
|
gtk_item_factory_create_item( m_factory, &entry, (gpointer) this, 2 ); /* what is 2 ? */
|
||||||
|
|
||||||
wxString path( mitem->GetFactoryPath() );
|
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
|
#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
|
#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
|
else // a normal item
|
||||||
{
|
{
|
||||||
@@ -824,7 +828,7 @@ virtual bool wxMenu::DoAppend(wxMenuItem *mitem)
|
|||||||
entry.path = buf;
|
entry.path = buf;
|
||||||
entry.callback = (GtkItemFactoryCallback) gtk_menu_clicked_callback;
|
entry.callback = (GtkItemFactoryCallback) gtk_menu_clicked_callback;
|
||||||
entry.callback_action = 0;
|
entry.callback_action = 0;
|
||||||
if (checkable)
|
if ( mitem->IsCheckable() )
|
||||||
entry.item_type = "<CheckItem>";
|
entry.item_type = "<CheckItem>";
|
||||||
else
|
else
|
||||||
entry.item_type = "<Item>";
|
entry.item_type = "<Item>";
|
||||||
@@ -843,9 +847,9 @@ virtual bool wxMenu::DoAppend(wxMenuItem *mitem)
|
|||||||
gtk_item_factory_create_item( m_factory, &entry, (gpointer) this, 2 ); /* what is 2 ? */
|
gtk_item_factory_create_item( m_factory, &entry, (gpointer) this, 2 ); /* what is 2 ? */
|
||||||
|
|
||||||
wxString path( mitem->GetFactoryPath() );
|
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
|
#else // GTK+ 1.0
|
||||||
GtkWidget *menuItem = checkable ? gtk_check_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_menu_item_new_with_label( mitem->GetText().mb_str() );
|
||||||
|
|
||||||
gtk_signal_connect( GTK_OBJECT(menuItem), "activate",
|
gtk_signal_connect( GTK_OBJECT(menuItem), "activate",
|
||||||
|
@@ -2815,15 +2815,16 @@ static void gtk_pop_hide_callback( GtkWidget *WXUNUSED(widget), bool* is_waiting
|
|||||||
static void SetInvokingWindow( wxMenu *menu, wxWindow *win )
|
static void SetInvokingWindow( wxMenu *menu, wxWindow *win )
|
||||||
{
|
{
|
||||||
menu->SetInvokingWindow( win );
|
menu->SetInvokingWindow( win );
|
||||||
wxNode *node = menu->GetItems().First();
|
wxMenuItemList::Node *node = menu->GetMenuItems().GetFirst();
|
||||||
while (node)
|
while (node)
|
||||||
{
|
{
|
||||||
wxMenuItem *menuitem = (wxMenuItem*)node->Data();
|
wxMenuItem *menuitem = node->GetData();
|
||||||
if (menuitem->IsSubMenu())
|
if (menuitem->IsSubMenu())
|
||||||
{
|
{
|
||||||
SetInvokingWindow( menuitem->GetSubMenu(), win );
|
SetInvokingWindow( menuitem->GetSubMenu(), win );
|
||||||
}
|
}
|
||||||
node = node->Next();
|
|
||||||
|
node = node->GetNext();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user