From 852b1185013697d59e115df16873e85fd2d741ec Mon Sep 17 00:00:00 2001 From: Robin Dunn Date: Fri, 16 Jan 2004 01:48:53 +0000 Subject: [PATCH] Send menu highlight events and fix statusbar to update immediatly when status text is changed git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@25204 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/mac/app.cpp | 32 +++++++++++++++++++++++++++----- src/mac/carbon/app.cpp | 32 +++++++++++++++++++++++++++----- src/mac/carbon/statbrma.cpp | 3 ++- src/mac/statbrma.cpp | 3 ++- 4 files changed, 58 insertions(+), 12 deletions(-) diff --git a/src/mac/app.cpp b/src/mac/app.cpp index 465ef52384..cfc97e1c3e 100644 --- a/src/mac/app.cpp +++ b/src/mac/app.cpp @@ -290,6 +290,7 @@ void wxApp::MacNewFile() { kEventClassMenu, kEventMenuOpening }, { kEventClassMenu, kEventMenuClosed }, + { kEventClassMenu, kEventMenuTargetItem }, { kEventClassApplication , kEventAppActivated } , { kEventClassApplication , kEventAppDeactivated } , @@ -308,8 +309,9 @@ void wxApp::MacNewFile() static pascal OSStatus MenuEventHandler( EventHandlerCallRef handler , EventRef event , void *data ) { - // FIXME: this doesn't work for multiple windows - wxWindow *win = wxTheApp->GetTopWindow(); + wxMenuBar* mbar = wxMenuBar::MacGetInstalledMenuBar(); + wxFrame* win = mbar->GetFrame(); + if ( win ) { // VZ: we could find the menu from its handle here by examining all @@ -325,9 +327,29 @@ MenuEventHandler( EventHandlerCallRef handler , EventRef event , void *data ) &menuRef); #endif // 0 - wxMenuEvent wxevent(GetEventKind(event) == kEventMenuOpening - ? wxEVT_MENU_OPEN - : wxEVT_MENU_CLOSE); + wxEventType type=0; + MenuCommand cmd=0; + switch (GetEventKind(event)) + { + case kEventMenuOpening: + type = wxEVT_MENU_OPEN; + break; + case kEventMenuClosed: + type = wxEVT_MENU_CLOSE; + break; + case kEventMenuTargetItem: + type = wxEVT_MENU_HIGHLIGHT; + GetEventParameter(event, kEventParamMenuCommand, + typeMenuCommand, NULL, + sizeof(cmd), NULL, &cmd); + if (cmd == 0) return eventNotHandledErr; + break; + default: + wxFAIL_MSG(wxT("Unexpected menu event kind")); + break; + } + + wxMenuEvent wxevent(type, cmd); wxevent.SetEventObject(win); (void)win->GetEventHandler()->ProcessEvent(wxevent); diff --git a/src/mac/carbon/app.cpp b/src/mac/carbon/app.cpp index 465ef52384..cfc97e1c3e 100644 --- a/src/mac/carbon/app.cpp +++ b/src/mac/carbon/app.cpp @@ -290,6 +290,7 @@ void wxApp::MacNewFile() { kEventClassMenu, kEventMenuOpening }, { kEventClassMenu, kEventMenuClosed }, + { kEventClassMenu, kEventMenuTargetItem }, { kEventClassApplication , kEventAppActivated } , { kEventClassApplication , kEventAppDeactivated } , @@ -308,8 +309,9 @@ void wxApp::MacNewFile() static pascal OSStatus MenuEventHandler( EventHandlerCallRef handler , EventRef event , void *data ) { - // FIXME: this doesn't work for multiple windows - wxWindow *win = wxTheApp->GetTopWindow(); + wxMenuBar* mbar = wxMenuBar::MacGetInstalledMenuBar(); + wxFrame* win = mbar->GetFrame(); + if ( win ) { // VZ: we could find the menu from its handle here by examining all @@ -325,9 +327,29 @@ MenuEventHandler( EventHandlerCallRef handler , EventRef event , void *data ) &menuRef); #endif // 0 - wxMenuEvent wxevent(GetEventKind(event) == kEventMenuOpening - ? wxEVT_MENU_OPEN - : wxEVT_MENU_CLOSE); + wxEventType type=0; + MenuCommand cmd=0; + switch (GetEventKind(event)) + { + case kEventMenuOpening: + type = wxEVT_MENU_OPEN; + break; + case kEventMenuClosed: + type = wxEVT_MENU_CLOSE; + break; + case kEventMenuTargetItem: + type = wxEVT_MENU_HIGHLIGHT; + GetEventParameter(event, kEventParamMenuCommand, + typeMenuCommand, NULL, + sizeof(cmd), NULL, &cmd); + if (cmd == 0) return eventNotHandledErr; + break; + default: + wxFAIL_MSG(wxT("Unexpected menu event kind")); + break; + } + + wxMenuEvent wxevent(type, cmd); wxevent.SetEventObject(win); (void)win->GetEventHandler()->ProcessEvent(wxevent); diff --git a/src/mac/carbon/statbrma.cpp b/src/mac/carbon/statbrma.cpp index e39e83bb81..dcd60b8588 100644 --- a/src/mac/carbon/statbrma.cpp +++ b/src/mac/carbon/statbrma.cpp @@ -72,7 +72,7 @@ void wxStatusBarMac::DrawFieldText(wxDC& dc, int i) dc.GetTextExtent(text, &x, &y); int xpos = rect.x + leftMargin + 1 ; - int ypos = 2 ; + int ypos = 1 ; dc.SetClippingRegion(rect.x, 0, rect.width, m_height); @@ -97,6 +97,7 @@ void wxStatusBarMac::SetStatusText(const wxString& text, int number) rect.y=0; rect.height = m_height ; Refresh( TRUE , &rect ) ; + Update(); } void wxStatusBarMac::OnPaint(wxPaintEvent& WXUNUSED(event) ) diff --git a/src/mac/statbrma.cpp b/src/mac/statbrma.cpp index e39e83bb81..dcd60b8588 100644 --- a/src/mac/statbrma.cpp +++ b/src/mac/statbrma.cpp @@ -72,7 +72,7 @@ void wxStatusBarMac::DrawFieldText(wxDC& dc, int i) dc.GetTextExtent(text, &x, &y); int xpos = rect.x + leftMargin + 1 ; - int ypos = 2 ; + int ypos = 1 ; dc.SetClippingRegion(rect.x, 0, rect.width, m_height); @@ -97,6 +97,7 @@ void wxStatusBarMac::SetStatusText(const wxString& text, int number) rect.y=0; rect.height = m_height ; Refresh( TRUE , &rect ) ; + Update(); } void wxStatusBarMac::OnPaint(wxPaintEvent& WXUNUSED(event) ) -- 2.45.2