Rework idle handling so that NSApplication does not need to be subclassed or posed as.
Copyright Software 2000 Ltd. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@46013 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -15,19 +15,50 @@
|
||||
// ========================================================================
|
||||
// wxNSApplicationDelegate
|
||||
// ========================================================================
|
||||
/*!
|
||||
@class wxNSApplicationDelegate
|
||||
@discussion Implements an NSApplication delegate which can respond to messages sent by Cocoa to change Cocoa's behavior.
|
||||
|
||||
wxCocoa will set a singleton instance of this class as the NSApplication delegate upon startup unless wxWidgets is running
|
||||
in a "plugin" manner in which case it would not be appropriate to do this.
|
||||
|
||||
Although Cocoa will send notifications to the delegate it is also possible to register a different object to listen for
|
||||
them. Because we want to support the plugin case, we use a separate notification observer object when we can.
|
||||
*/
|
||||
@interface wxNSApplicationDelegate : NSObject
|
||||
{
|
||||
}
|
||||
|
||||
// Delegate methods
|
||||
- (BOOL)applicationShouldTerminateAfterLastWindowClosed:(NSApplication *)theApplication;
|
||||
@end // interface wxNSApplicationDelegate : NSObject
|
||||
|
||||
// ========================================================================
|
||||
// wxNSApplicationObserver
|
||||
// ========================================================================
|
||||
/*!
|
||||
@class wxNSApplicationObserver
|
||||
@discussion Observes most notifications sent by the NSApplication singleton.
|
||||
|
||||
wxCocoa will create a singleton instance of this class upon startup and register it with the default notification center to
|
||||
listen for several events sent by the NSApplication singleton.
|
||||
|
||||
Because there can be any number of notification observers, this method allows wxCocoa to function properly even when it is
|
||||
running as a plugin of some other (most likely not wxWidgets) application.
|
||||
*/
|
||||
@interface wxNSApplicationObserver : NSObject
|
||||
{
|
||||
}
|
||||
|
||||
// Methods defined as (but not used here) as NSApplication delegate methods.
|
||||
- (void)applicationWillBecomeActive:(NSNotification *)notification;
|
||||
- (void)applicationDidBecomeActive:(NSNotification *)notification;
|
||||
- (void)applicationWillResignActive:(NSNotification *)notification;
|
||||
- (void)applicationDidResignActive:(NSNotification *)notification;
|
||||
- (void)applicationWillUpdate:(NSNotification *)notification;
|
||||
|
||||
// Other notifications
|
||||
- (void)controlTintChanged:(NSNotification *)notification;
|
||||
@end // interface wxNSApplicationDelegate : NSObject
|
||||
@end // interface wxNSApplicationObserver : NSObject
|
||||
|
||||
#endif //ndef _WX_COCOA_NSAPPLICATION_H__
|
||||
|
@@ -12,6 +12,11 @@
|
||||
#ifndef _WX_COCOA_APP_H_
|
||||
#define _WX_COCOA_APP_H_
|
||||
|
||||
typedef struct __CFRunLoopObserver * CFRunLoopObserverRef;
|
||||
typedef const struct __CFString * CFStringRef;
|
||||
|
||||
#include "wx/mac/corefoundation/cfref.h"
|
||||
|
||||
// ========================================================================
|
||||
// wxApp
|
||||
// ========================================================================
|
||||
@@ -26,7 +31,7 @@ class WXDLLEXPORT wxApp: public wxAppBase
|
||||
// ------------------------------------------------------------------------
|
||||
public:
|
||||
wxApp();
|
||||
virtual ~wxApp() {}
|
||||
virtual ~wxApp();
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
// Cocoa specifics
|
||||
@@ -37,10 +42,14 @@ public:
|
||||
virtual void CocoaDelegate_applicationDidBecomeActive();
|
||||
virtual void CocoaDelegate_applicationWillResignActive();
|
||||
virtual void CocoaDelegate_applicationDidResignActive();
|
||||
virtual void CocoaDelegate_applicationWillUpdate();
|
||||
virtual void CF_ObserveMainRunLoopBeforeWaiting(CFRunLoopObserverRef observer, int activity);
|
||||
protected:
|
||||
WX_NSApplication m_cocoaApp;
|
||||
struct objc_object *m_cocoaAppDelegate;
|
||||
WX_NSThread m_cocoaMainThread;
|
||||
wxCFRef<CFRunLoopObserverRef> m_cfRunLoopIdleObserver;
|
||||
wxCFRef<CFStringRef> m_cfObservedRunLoopMode;
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
// Implementation
|
||||
|
Reference in New Issue
Block a user