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:
@@ -162,6 +162,11 @@ public:
|
|||||||
// attach to a frame
|
// attach to a frame
|
||||||
void Attach(wxFrame *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
|
#if wxUSE_ACCEL
|
||||||
// get the accel table for all the menus
|
// get the accel table for all the menus
|
||||||
const wxAcceleratorTable& GetAccelTable() const { return m_accelTable; }
|
const wxAcceleratorTable& GetAccelTable() const { return m_accelTable; }
|
||||||
|
@@ -2331,12 +2331,15 @@ void wxApp::MacHandleMenuSelect( int macMenuId , int macMenuItemNum )
|
|||||||
item->Check( !item->IsChecked() ) ;
|
item->Check( !item->IsChecked() ) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
menu->SendEvent( id , item->IsCheckable() ? item->IsChecked() : -1 ) ;
|
||||||
|
/*
|
||||||
wxWindow* frontwindow = wxFindWinFromMacWindow( ::FrontWindow() ) ;
|
wxWindow* frontwindow = wxFindWinFromMacWindow( ::FrontWindow() ) ;
|
||||||
wxCommandEvent event(wxEVT_COMMAND_MENU_SELECTED, id );
|
wxCommandEvent event(wxEVT_COMMAND_MENU_SELECTED, id );
|
||||||
event.m_timeStamp = ((EventRecord*) MacGetCurrentEvent())->when ;
|
event.m_timeStamp = ((EventRecord*) MacGetCurrentEvent())->when ;
|
||||||
event.SetEventObject(menu);
|
event.SetEventObject(menu);
|
||||||
event.SetInt(item->IsCheckable() ? item->IsChecked() : -1);
|
event.SetInt(item->IsCheckable() ? item->IsChecked() : -1);
|
||||||
frontwindow->GetEventHandler()->ProcessEvent(event);
|
frontwindow->GetEventHandler()->ProcessEvent(event);
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
HiliteMenu(0);
|
HiliteMenu(0);
|
||||||
}
|
}
|
||||||
|
@@ -2331,12 +2331,15 @@ void wxApp::MacHandleMenuSelect( int macMenuId , int macMenuItemNum )
|
|||||||
item->Check( !item->IsChecked() ) ;
|
item->Check( !item->IsChecked() ) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
menu->SendEvent( id , item->IsCheckable() ? item->IsChecked() : -1 ) ;
|
||||||
|
/*
|
||||||
wxWindow* frontwindow = wxFindWinFromMacWindow( ::FrontWindow() ) ;
|
wxWindow* frontwindow = wxFindWinFromMacWindow( ::FrontWindow() ) ;
|
||||||
wxCommandEvent event(wxEVT_COMMAND_MENU_SELECTED, id );
|
wxCommandEvent event(wxEVT_COMMAND_MENU_SELECTED, id );
|
||||||
event.m_timeStamp = ((EventRecord*) MacGetCurrentEvent())->when ;
|
event.m_timeStamp = ((EventRecord*) MacGetCurrentEvent())->when ;
|
||||||
event.SetEventObject(menu);
|
event.SetEventObject(menu);
|
||||||
event.SetInt(item->IsCheckable() ? item->IsChecked() : -1);
|
event.SetInt(item->IsCheckable() ? item->IsChecked() : -1);
|
||||||
frontwindow->GetEventHandler()->ProcessEvent(event);
|
frontwindow->GetEventHandler()->ProcessEvent(event);
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
HiliteMenu(0);
|
HiliteMenu(0);
|
||||||
}
|
}
|
||||||
|
@@ -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
|
void wxFrame::DoGetClientSize(int *x, int *y) const
|
||||||
{
|
{
|
||||||
wxWindow::DoGetClientSize( x , y ) ;
|
wxWindow::DoGetClientSize( x , y ) ;
|
||||||
|
@@ -864,6 +864,56 @@ bool wxMenuBar::Append(wxMenu *menu, const wxString& title)
|
|||||||
return TRUE;
|
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()
|
void wxMenuBar::Detach()
|
||||||
{
|
{
|
||||||
wxMenuBarBase::Detach() ;
|
wxMenuBarBase::Detach() ;
|
||||||
@@ -872,7 +922,6 @@ void wxMenuBar::Detach()
|
|||||||
void wxMenuBar::Attach(wxFrame *frame)
|
void wxMenuBar::Attach(wxFrame *frame)
|
||||||
{
|
{
|
||||||
wxMenuBarBase::Attach( frame ) ;
|
wxMenuBarBase::Attach( frame ) ;
|
||||||
|
|
||||||
#if wxUSE_ACCEL
|
#if wxUSE_ACCEL
|
||||||
RebuildAccelTable();
|
RebuildAccelTable();
|
||||||
#endif // wxUSE_ACCEL
|
#endif // wxUSE_ACCEL
|
||||||
|
@@ -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
|
void wxFrame::DoGetClientSize(int *x, int *y) const
|
||||||
{
|
{
|
||||||
wxWindow::DoGetClientSize( x , y ) ;
|
wxWindow::DoGetClientSize( x , y ) ;
|
||||||
|
@@ -864,6 +864,56 @@ bool wxMenuBar::Append(wxMenu *menu, const wxString& title)
|
|||||||
return TRUE;
|
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()
|
void wxMenuBar::Detach()
|
||||||
{
|
{
|
||||||
wxMenuBarBase::Detach() ;
|
wxMenuBarBase::Detach() ;
|
||||||
@@ -872,7 +922,6 @@ void wxMenuBar::Detach()
|
|||||||
void wxMenuBar::Attach(wxFrame *frame)
|
void wxMenuBar::Attach(wxFrame *frame)
|
||||||
{
|
{
|
||||||
wxMenuBarBase::Attach( frame ) ;
|
wxMenuBarBase::Attach( frame ) ;
|
||||||
|
|
||||||
#if wxUSE_ACCEL
|
#if wxUSE_ACCEL
|
||||||
RebuildAccelTable();
|
RebuildAccelTable();
|
||||||
#endif // wxUSE_ACCEL
|
#endif // wxUSE_ACCEL
|
||||||
|
Reference in New Issue
Block a user