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
This commit is contained in:
Robin Dunn
2004-01-16 01:48:53 +00:00
parent 3dfafdb9e6
commit 852b118501
4 changed files with 58 additions and 12 deletions

View File

@@ -290,6 +290,7 @@ void wxApp::MacNewFile()
{ kEventClassMenu, kEventMenuOpening }, { kEventClassMenu, kEventMenuOpening },
{ kEventClassMenu, kEventMenuClosed }, { kEventClassMenu, kEventMenuClosed },
{ kEventClassMenu, kEventMenuTargetItem },
{ kEventClassApplication , kEventAppActivated } , { kEventClassApplication , kEventAppActivated } ,
{ kEventClassApplication , kEventAppDeactivated } , { kEventClassApplication , kEventAppDeactivated } ,
@@ -308,8 +309,9 @@ void wxApp::MacNewFile()
static pascal OSStatus static pascal OSStatus
MenuEventHandler( EventHandlerCallRef handler , EventRef event , void *data ) MenuEventHandler( EventHandlerCallRef handler , EventRef event , void *data )
{ {
// FIXME: this doesn't work for multiple windows wxMenuBar* mbar = wxMenuBar::MacGetInstalledMenuBar();
wxWindow *win = wxTheApp->GetTopWindow(); wxFrame* win = mbar->GetFrame();
if ( win ) if ( win )
{ {
// VZ: we could find the menu from its handle here by examining all // 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); &menuRef);
#endif // 0 #endif // 0
wxMenuEvent wxevent(GetEventKind(event) == kEventMenuOpening wxEventType type=0;
? wxEVT_MENU_OPEN MenuCommand cmd=0;
: wxEVT_MENU_CLOSE); 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); wxevent.SetEventObject(win);
(void)win->GetEventHandler()->ProcessEvent(wxevent); (void)win->GetEventHandler()->ProcessEvent(wxevent);

View File

@@ -290,6 +290,7 @@ void wxApp::MacNewFile()
{ kEventClassMenu, kEventMenuOpening }, { kEventClassMenu, kEventMenuOpening },
{ kEventClassMenu, kEventMenuClosed }, { kEventClassMenu, kEventMenuClosed },
{ kEventClassMenu, kEventMenuTargetItem },
{ kEventClassApplication , kEventAppActivated } , { kEventClassApplication , kEventAppActivated } ,
{ kEventClassApplication , kEventAppDeactivated } , { kEventClassApplication , kEventAppDeactivated } ,
@@ -308,8 +309,9 @@ void wxApp::MacNewFile()
static pascal OSStatus static pascal OSStatus
MenuEventHandler( EventHandlerCallRef handler , EventRef event , void *data ) MenuEventHandler( EventHandlerCallRef handler , EventRef event , void *data )
{ {
// FIXME: this doesn't work for multiple windows wxMenuBar* mbar = wxMenuBar::MacGetInstalledMenuBar();
wxWindow *win = wxTheApp->GetTopWindow(); wxFrame* win = mbar->GetFrame();
if ( win ) if ( win )
{ {
// VZ: we could find the menu from its handle here by examining all // 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); &menuRef);
#endif // 0 #endif // 0
wxMenuEvent wxevent(GetEventKind(event) == kEventMenuOpening wxEventType type=0;
? wxEVT_MENU_OPEN MenuCommand cmd=0;
: wxEVT_MENU_CLOSE); 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); wxevent.SetEventObject(win);
(void)win->GetEventHandler()->ProcessEvent(wxevent); (void)win->GetEventHandler()->ProcessEvent(wxevent);

View File

@@ -72,7 +72,7 @@ void wxStatusBarMac::DrawFieldText(wxDC& dc, int i)
dc.GetTextExtent(text, &x, &y); dc.GetTextExtent(text, &x, &y);
int xpos = rect.x + leftMargin + 1 ; int xpos = rect.x + leftMargin + 1 ;
int ypos = 2 ; int ypos = 1 ;
dc.SetClippingRegion(rect.x, 0, rect.width, m_height); 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.y=0;
rect.height = m_height ; rect.height = m_height ;
Refresh( TRUE , &rect ) ; Refresh( TRUE , &rect ) ;
Update();
} }
void wxStatusBarMac::OnPaint(wxPaintEvent& WXUNUSED(event) ) void wxStatusBarMac::OnPaint(wxPaintEvent& WXUNUSED(event) )

View File

@@ -72,7 +72,7 @@ void wxStatusBarMac::DrawFieldText(wxDC& dc, int i)
dc.GetTextExtent(text, &x, &y); dc.GetTextExtent(text, &x, &y);
int xpos = rect.x + leftMargin + 1 ; int xpos = rect.x + leftMargin + 1 ;
int ypos = 2 ; int ypos = 1 ;
dc.SetClippingRegion(rect.x, 0, rect.width, m_height); 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.y=0;
rect.height = m_height ; rect.height = m_height ;
Refresh( TRUE , &rect ) ; Refresh( TRUE , &rect ) ;
Update();
} }
void wxStatusBarMac::OnPaint(wxPaintEvent& WXUNUSED(event) ) void wxStatusBarMac::OnPaint(wxPaintEvent& WXUNUSED(event) )