menu handling added (gtk-way)

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_4_BRANCH@17881 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Stefan Csomor
2002-11-17 00:11:13 +00:00
parent 414ea21e24
commit 1354418055
7 changed files with 153 additions and 4 deletions

View File

@@ -162,6 +162,11 @@ public:
// attach to a frame
void Attach(wxFrame *frame);
// clear the invoking window for all menus and submenus
void UnsetInvokingWindow() ;
// set the invoking window for all menus and submenus
void SetInvokingWindow( wxFrame* frame ) ;
#if wxUSE_ACCEL
// get the accel table for all the menus
const wxAcceleratorTable& GetAccelTable() const { return m_accelTable; }

View File

@@ -2330,13 +2330,16 @@ void wxApp::MacHandleMenuSelect( int macMenuId , int macMenuItemNum )
{
item->Check( !item->IsChecked() ) ;
}
menu->SendEvent( id , item->IsCheckable() ? item->IsChecked() : -1 ) ;
/*
wxWindow* frontwindow = wxFindWinFromMacWindow( ::FrontWindow() ) ;
wxCommandEvent event(wxEVT_COMMAND_MENU_SELECTED, id );
event.m_timeStamp = ((EventRecord*) MacGetCurrentEvent())->when ;
event.SetEventObject(menu);
event.SetInt(item->IsCheckable() ? item->IsChecked() : -1);
frontwindow->GetEventHandler()->ProcessEvent(event);
*/
}
HiliteMenu(0);
}

View File

@@ -2330,13 +2330,16 @@ void wxApp::MacHandleMenuSelect( int macMenuId , int macMenuItemNum )
{
item->Check( !item->IsChecked() ) ;
}
menu->SendEvent( id , item->IsCheckable() ? item->IsChecked() : -1 ) ;
/*
wxWindow* frontwindow = wxFindWinFromMacWindow( ::FrontWindow() ) ;
wxCommandEvent event(wxEVT_COMMAND_MENU_SELECTED, id );
event.m_timeStamp = ((EventRecord*) MacGetCurrentEvent())->when ;
event.SetEventObject(menu);
event.SetInt(item->IsCheckable() ? item->IsChecked() : -1);
frontwindow->GetEventHandler()->ProcessEvent(event);
*/
}
HiliteMenu(0);
}

View File

@@ -240,6 +240,26 @@ void wxFrame::OnActivate(wxActivateEvent& event)
}
}
void wxFrame::DetachMenuBar()
{
if ( m_frameMenuBar )
{
m_frameMenuBar->UnsetInvokingWindow();
}
wxFrameBase::DetachMenuBar();
}
void wxFrame::AttachMenuBar( wxMenuBar *menuBar )
{
wxFrameBase::AttachMenuBar(menuBar);
if (m_frameMenuBar)
{
m_frameMenuBar->SetInvokingWindow( this );
}
}
void wxFrame::DoGetClientSize(int *x, int *y) const
{
wxWindow::DoGetClientSize( x , y ) ;

View File

@@ -864,6 +864,56 @@ bool wxMenuBar::Append(wxMenu *menu, const wxString& title)
return TRUE;
}
static void wxMenubarUnsetInvokingWindow( wxMenu *menu )
{
menu->SetInvokingWindow( (wxWindow*) NULL );
wxMenuItemList::Node *node = menu->GetMenuItems().GetFirst();
while (node)
{
wxMenuItem *menuitem = node->GetData();
if (menuitem->IsSubMenu())
wxMenubarUnsetInvokingWindow( menuitem->GetSubMenu() );
node = node->GetNext();
}
}
static void wxMenubarSetInvokingWindow( wxMenu *menu, wxWindow *win )
{
menu->SetInvokingWindow( win );
wxMenuItemList::Node *node = menu->GetMenuItems().GetFirst();
while (node)
{
wxMenuItem *menuitem = node->GetData();
if (menuitem->IsSubMenu())
wxMenubarSetInvokingWindow( menuitem->GetSubMenu() , win );
node = node->GetNext();
}
}
void wxMenuBar::UnsetInvokingWindow()
{
wxMenuList::Node *node = m_menus.GetFirst();
while (node)
{
wxMenu *menu = node->GetData();
wxMenubarUnsetInvokingWindow( menu );
node = node->GetNext();
}
}
void wxMenuBar::SetInvokingWindow(wxFrame *frame)
{
wxMenuList::Node *node = m_menus.GetFirst();
while (node)
{
wxMenu *menu = node->GetData();
wxMenubarSetInvokingWindow( menu, frame );
node = node->GetNext();
}
}
void wxMenuBar::Detach()
{
wxMenuBarBase::Detach() ;
@@ -872,7 +922,6 @@ void wxMenuBar::Detach()
void wxMenuBar::Attach(wxFrame *frame)
{
wxMenuBarBase::Attach( frame ) ;
#if wxUSE_ACCEL
RebuildAccelTable();
#endif // wxUSE_ACCEL

View File

@@ -240,6 +240,26 @@ void wxFrame::OnActivate(wxActivateEvent& event)
}
}
void wxFrame::DetachMenuBar()
{
if ( m_frameMenuBar )
{
m_frameMenuBar->UnsetInvokingWindow();
}
wxFrameBase::DetachMenuBar();
}
void wxFrame::AttachMenuBar( wxMenuBar *menuBar )
{
wxFrameBase::AttachMenuBar(menuBar);
if (m_frameMenuBar)
{
m_frameMenuBar->SetInvokingWindow( this );
}
}
void wxFrame::DoGetClientSize(int *x, int *y) const
{
wxWindow::DoGetClientSize( x , y ) ;

View File

@@ -864,6 +864,56 @@ bool wxMenuBar::Append(wxMenu *menu, const wxString& title)
return TRUE;
}
static void wxMenubarUnsetInvokingWindow( wxMenu *menu )
{
menu->SetInvokingWindow( (wxWindow*) NULL );
wxMenuItemList::Node *node = menu->GetMenuItems().GetFirst();
while (node)
{
wxMenuItem *menuitem = node->GetData();
if (menuitem->IsSubMenu())
wxMenubarUnsetInvokingWindow( menuitem->GetSubMenu() );
node = node->GetNext();
}
}
static void wxMenubarSetInvokingWindow( wxMenu *menu, wxWindow *win )
{
menu->SetInvokingWindow( win );
wxMenuItemList::Node *node = menu->GetMenuItems().GetFirst();
while (node)
{
wxMenuItem *menuitem = node->GetData();
if (menuitem->IsSubMenu())
wxMenubarSetInvokingWindow( menuitem->GetSubMenu() , win );
node = node->GetNext();
}
}
void wxMenuBar::UnsetInvokingWindow()
{
wxMenuList::Node *node = m_menus.GetFirst();
while (node)
{
wxMenu *menu = node->GetData();
wxMenubarUnsetInvokingWindow( menu );
node = node->GetNext();
}
}
void wxMenuBar::SetInvokingWindow(wxFrame *frame)
{
wxMenuList::Node *node = m_menus.GetFirst();
while (node)
{
wxMenu *menu = node->GetData();
wxMenubarSetInvokingWindow( menu, frame );
node = node->GetNext();
}
}
void wxMenuBar::Detach()
{
wxMenuBarBase::Detach() ;
@@ -872,7 +922,6 @@ void wxMenuBar::Detach()
void wxMenuBar::Attach(wxFrame *frame)
{
wxMenuBarBase::Attach( frame ) ;
#if wxUSE_ACCEL
RebuildAccelTable();
#endif // wxUSE_ACCEL