#if (GTK_MINOR_VERSION > 0)
wxWindow *top_frame = win;
- while (top_frame->GetParent() && !(top_frame->GetParent()->m_isFrame))
+ while (top_frame->GetParent() && !(top_frame->IsTopLevel()))
top_frame = top_frame->GetParent();
/* support for native hot keys */
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();
}
}
#if (GTK_MINOR_VERSION > 0)
wxWindow *top_frame = win;
- while (top_frame->GetParent() && !(top_frame->GetParent()->m_isFrame))
+ while (top_frame->GetParent() && !(top_frame->IsTopLevel()))
top_frame = top_frame->GetParent();
/* support for native hot keys */
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();
}
}
m_invokingWindow = win;
#if (GTK_MINOR_VERSION > 0) && (GTK_MICRO_VERSION > 0)
wxWindow *top_frame = win;
- while (top_frame->GetParent() && !(top_frame->GetParent()->m_isFrame))
+ while (top_frame->GetParent() && !(top_frame->IsTopLevel()))
top_frame = top_frame->GetParent();
/* support for native key accelerators indicated by underscroes */
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();
}
}
m_invokingWindow = (wxWindow*) NULL;
#if (GTK_MINOR_VERSION > 0) && (GTK_MICRO_VERSION > 0)
wxWindow *top_frame = win;
- while (top_frame->GetParent() && !(top_frame->GetParent()->m_isFrame))
+ while (top_frame->GetParent() && !(top_frame->IsTopLevel()))
top_frame = top_frame->GetParent();
/* support for native key accelerators indicated by underscroes */
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();
}
}
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;
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
{
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;
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 )
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;
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) );
}
}
wxAcceleratorEntry *wxMenuItem::GetAccel() const
{
- if ( !item.GetHotKey() )
+ if ( !GetHotKey() )
{
// nothing
return (wxAcceleratorEntry *)NULL;
// as wxGetAccelFromString() looks for TAB, insert a dummy one here
wxString label;
- label << wxT('\t') << item.GetHotKey();
+ label << wxT('\t') << GetHotKey();
return wxGetAccelFromString(label);
}
wxMenu::~wxMenu()
{
+ m_items.Clear();
+
gtk_widget_destroy( m_menu );
gtk_object_unref( GTK_OBJECT(m_factory) );
-
- // the menu items are deleted by the base class dtor
}
-virtual bool wxMenu::DoAppend(wxMenuItem *mitem)
+bool wxMenu::DoAppend(wxMenuItem *mitem)
{
GtkWidget *menuItem;
entry.callback = (GtkItemFactoryCallback) 0;
entry.callback_action = 0;
entry.item_type = "<Branch>";
+ entry.accelerator = (gchar*) NULL;
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
{
entry.path = buf;
entry.callback = (GtkItemFactoryCallback) gtk_menu_clicked_callback;
entry.callback_action = 0;
- if (checkable)
+ if ( mitem->IsCheckable() )
entry.item_type = "<CheckItem>";
else
entry.item_type = "<Item>";
+ entry.accelerator = (gchar*) NULL;
#if wxUSE_ACCEL
// due to an apparent bug in GTK+, we have to use a static buffer here -
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),