Add support for Mac dock icon bouncing. I used a cross-platform enum so that we can (ideally) craft a cross-platform API for 3.0.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_8_BRANCH@53370 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Kevin Ollivier
2008-04-26 05:43:41 +00:00
parent cf62ab93e6
commit 24e71cb379
3 changed files with 38 additions and 2 deletions

View File

@@ -2316,6 +2316,17 @@ enum wxUpdateUI
wxUPDATE_UI_FROMIDLE = 0x0002 /* Invoked from On(Internal)Idle */ wxUPDATE_UI_FROMIDLE = 0x0002 /* Invoked from On(Internal)Idle */
}; };
/* ---------------------------------------------------------------------------- */
/* Notification Event flags - used for dock icon bouncing, etc. */
/* ---------------------------------------------------------------------------- */
enum wxNotificationOptions
{
wxNOTIFY_NONE = 0x0000,
wxNOTIFY_ONCE = 0x0001,
wxNOTIFY_REPEAT = 0x0002
};
/* ---------------------------------------------------------------------------- */ /* ---------------------------------------------------------------------------- */
/* miscellaneous */ /* miscellaneous */
/* ---------------------------------------------------------------------------- */ /* ---------------------------------------------------------------------------- */

View File

@@ -74,6 +74,8 @@ public:
WXEVENTHANDLERREF MacGetCurrentEventHandlerCallRef() { return m_macCurrentEventHandlerCallRef ; } WXEVENTHANDLERREF MacGetCurrentEventHandlerCallRef() { return m_macCurrentEventHandlerCallRef ; }
void MacSetCurrentEvent( WXEVENTREF event , WXEVENTHANDLERCALLREF handler ) void MacSetCurrentEvent( WXEVENTREF event , WXEVENTHANDLERCALLREF handler )
{ m_macCurrentEvent = event ; m_macCurrentEventHandlerCallRef = handler ; } { m_macCurrentEvent = event ; m_macCurrentEventHandlerCallRef = handler ; }
void MacRequestUserAttention(wxNotificationOptions options);
// adding a CFType object to be released only at the end of the current event cycle (increases the // adding a CFType object to be released only at the end of the current event cycle (increases the
// refcount of the object passed), needed in case we are in the middle of an event concering an object // refcount of the object passed), needed in case we are in the middle of an event concering an object
@@ -101,6 +103,7 @@ public:
static long s_macPreferencesMenuItemId ; static long s_macPreferencesMenuItemId ;
static long s_macExitMenuItemId ; static long s_macExitMenuItemId ;
static wxString s_macHelpMenuTitleName ; static wxString s_macHelpMenuTitleName ;
static void* s_macNotificationRecord ;
WXEVENTREF MacGetCurrentEvent() { return m_macCurrentEvent ; } WXEVENTREF MacGetCurrentEvent() { return m_macCurrentEvent ; }
void MacHandleOneEvent( WXEVENTREF ev ) ; void MacHandleOneEvent( WXEVENTREF ev ) ;

View File

@@ -98,6 +98,8 @@ wxString wxApp::s_macHelpMenuTitleName = wxT("&Help") ;
bool wxApp::sm_isEmbedded = false; // Normally we're not a plugin bool wxApp::sm_isEmbedded = false; // Normally we're not a plugin
void* wxApp::s_macNotificationRecord = NULL;
//---------------------------------------------------------------------- //----------------------------------------------------------------------
// Core Apple Event Support // Core Apple Event Support
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@@ -300,7 +302,18 @@ void wxApp::MacPrintFile(const wxString & fileName )
#endif //docview #endif //docview
} }
void wxApp::MacRequestUserAttention(wxNotificationOptions options)
{
NMRec nmRec = {0};
nmRec.qType = nmType;
nmRec.nmMark = 1;
NMInstall(&nmRec);
if (options == wxNOTIFY_ONCE)
NMRemove (&nmRec);
else // save the reference and remove it on app activation
wxApp::s_macNotificationRecord = &nmRec;
}
void wxApp::MacNewFile() void wxApp::MacNewFile()
{ {
@@ -613,8 +626,17 @@ static pascal OSStatus wxMacAppApplicationEventHandler( EventHandlerCallRef hand
switch ( GetEventKind( event ) ) switch ( GetEventKind( event ) )
{ {
case kEventAppActivated : case kEventAppActivated :
if ( wxTheApp ) if ( wxTheApp ) {
wxTheApp->SetActive( true , NULL ) ; wxTheApp->SetActive( true , NULL ) ;
// If MacRequestUserAttention is set to repeat, then we need
// to shut down the notification upon app activation. This
// should happen automatically, but let's add the handler
// just in case.
if (wxApp::s_macNotificationRecord) {
NMRemove((NMRec*)wxApp::s_macNotificationRecord);
wxApp::s_macNotificationRecord = NULL;
}
}
result = noErr ; result = noErr ;
break ; break ;