gtk_pizza_set_size( GTK_PIZZA(m_mainWidget),
menu_bar->m_widget,
0, 0, m_width, wxMENU_HEIGHT );
- menu_bar->SetInvokingWindow(active_child_frame);
+ menu_bar->Attach(active_child_frame);
}
}
m_justInserted = false;
gtk_pizza_set_size( GTK_PIZZA(m_mainWidget),
menu_bar->m_widget,
0, 0, m_width, wxMENU_HEIGHT );
- menu_bar->SetInvokingWindow( child_frame );
+
+ // Attach() asserts if we call it for an already
+ // attached menu bar so don't do it if we're already
+ // associated with this frame (it would be nice to get
+ // rid of this check and ensure that this doesn't
+ // happen...)
+ if ( menu_bar->GetFrame() != child_frame )
+ menu_bar->Attach( child_frame );
}
visible_child_menu = true;
}
{
if (menu_bar->Show(false))
{
- menu_bar->UnsetInvokingWindow( child_frame );
+ menu_bar->Detach();
}
}
}
if (visible_child_menu)
{
m_frameMenuBar->Show( false );
- m_frameMenuBar->UnsetInvokingWindow( this );
+ m_frameMenuBar->Detach();
}
else
{
m_frameMenuBar->Show( true );
- m_frameMenuBar->SetInvokingWindow( this );
+ m_frameMenuBar->Attach( this );
m_frameMenuBar->m_width = m_width;
m_frameMenuBar->m_height = wxMENU_HEIGHT;
if (handler && handler->ProcessEvent(event))
return;
- wxWindow *win = menu->GetInvokingWindow();
+ wxWindow *win = menu->GetWindow();
if (win)
win->HandleWindowEvent( event );
}
// the parent window is known after wxFrame::SetMenu()
m_needParent = false;
m_style = style;
- m_invokingWindow = NULL;
if (!PreCreation( NULL, wxDefaultPosition, wxDefaultSize ) ||
!CreateBase( NULL, -1, wxDefaultPosition, wxDefaultSize, style, wxDefaultValidator, wxT("menubar") ))
{
}
-static void wxMenubarUnsetInvokingWindow( wxMenu *menu, wxWindow *win )
+static void DetachFromFrame( wxMenu *menu, wxWindow *win )
{
- menu->SetInvokingWindow( NULL );
-
wxWindow *top_frame = win;
while (top_frame->GetParent() && !(top_frame->IsTopLevel()))
top_frame = top_frame->GetParent();
{
wxMenuItem *menuitem = node->GetData();
if (menuitem->IsSubMenu())
- wxMenubarUnsetInvokingWindow( menuitem->GetSubMenu(), win );
+ DetachFromFrame( menuitem->GetSubMenu(), win );
node = node->GetNext();
}
}
-static void wxMenubarSetInvokingWindow( wxMenu *menu, wxWindow *win )
+static void AttachToFrame( wxMenu *menu, wxWindow *win )
{
- menu->SetInvokingWindow( win );
-
wxWindow *top_frame = win;
while (top_frame->GetParent() && !(top_frame->IsTopLevel()))
top_frame = top_frame->GetParent();
{
wxMenuItem *menuitem = node->GetData();
if (menuitem->IsSubMenu())
- wxMenubarSetInvokingWindow( menuitem->GetSubMenu(), win );
+ AttachToFrame( menuitem->GetSubMenu(), win );
node = node->GetNext();
}
}
-void wxMenuBar::SetInvokingWindow( wxWindow *win )
+void wxMenuBar::Attach( wxFrame *win )
{
- m_invokingWindow = win;
+ wxMenuBarBase::Attach(win);
+
wxWindow *top_frame = win;
while (top_frame->GetParent() && !(top_frame->IsTopLevel()))
top_frame = top_frame->GetParent();
while (node)
{
wxMenu *menu = node->GetData();
- wxMenubarSetInvokingWindow( menu, win );
+ AttachToFrame( menu, win );
node = node->GetNext();
}
}
-void wxMenuBar::UnsetInvokingWindow( wxWindow *win )
+void wxMenuBar::Detach()
{
- m_invokingWindow = NULL;
- wxWindow *top_frame = win;
+ wxWindow *top_frame = m_menuBarFrame;
while (top_frame->GetParent() && !(top_frame->IsTopLevel()))
top_frame = top_frame->GetParent();
while (node)
{
wxMenu *menu = node->GetData();
- wxMenubarUnsetInvokingWindow( menu, win );
+ DetachFromFrame( menu, top_frame );
node = node->GetNext();
}
+
+ wxMenuBarBase::Detach();
}
bool wxMenuBar::Append( wxMenu *menu, const wxString &title )
GTK_SIGNAL_FUNC(gtk_menu_open_callback),
(gpointer)menu );
- // m_invokingWindow is set after wxFrame::SetMenuBar(). This call enables
- // addings menu later on.
- if (m_invokingWindow)
+ if (m_menuBarFrame)
{
- wxMenubarSetInvokingWindow( menu, m_invokingWindow );
+ AttachToFrame( menu, m_menuBarFrame );
// OPTIMISE ME: we should probably cache this, or pass it
// directly, but for now this is a minimal
// see (and refactor :) similar code in Remove
// below.
- wxFrame *frame = wxDynamicCast( m_invokingWindow, wxFrame );
-
- if( frame )
- frame->UpdateMenuBarSize();
+ m_menuBarFrame->UpdateMenuBarSize();
}
return true;
gtk_widget_destroy( menu->m_owner );
menu->m_owner = NULL;
- if (m_invokingWindow)
+ if (m_menuBarFrame)
{
// OPTIMISE ME: see comment in GtkAppend
- wxFrame *frame = wxDynamicCast( m_invokingWindow, wxFrame );
-
- if( frame )
- frame->UpdateMenuBarSize();
+ m_menuBarFrame->UpdateMenuBarSize();
}
return menu;
int id = menu->FindMenuIdByMenuItem(widget);
/* should find it for normal (not popup) menu */
- wxASSERT_MSG( (id != -1) || (menu->GetInvokingWindow() != NULL),
+ wxASSERT_MSG( (id != -1) || (menu->GetWindow() != NULL),
wxT("menu item not found in gtk_menu_clicked_callback") );
if (!menu->IsEnabled(id))
// FIXME: why do we have to call wxFrame::GetEventHandler() directly here?
// normally wxMenu::SendEvent() should be enough, if it doesn't work
- // in wxGTK then we have a bug in wxMenu::GetInvokingWindow() which
+ // in wxGTK then we have a bug in wxMenu::GetWindow() which
// should be fixed instead of working around it here...
if (frame)
{
if (handler && handler->ProcessEvent(event))
return;
- wxWindow *win = menu->GetInvokingWindow();
+ wxWindow *win = menu->GetWindow();
if (win) win->HandleWindowEvent( event );
}
}
if (handler && handler->ProcessEvent(event))
return;
- wxWindow *win = menu->GetInvokingWindow();
+ wxWindow *win = menu->GetWindow();
if (win)
win->HandleWindowEvent( event );
}
gtk_menu_item_set_submenu( GTK_MENU_ITEM(menuItem), mitem->GetSubMenu()->m_menu );
gtk_widget_show( mitem->GetSubMenu()->m_menu );
-
- // if adding a submenu to a menu already existing in the menu bar, we
- // must set invoking window to allow processing events from this
- // submenu
- if ( m_invokingWindow )
- wxMenubarSetInvokingWindow(mitem->GetSubMenu(), m_invokingWindow);
}
else
{