]> git.saurik.com Git - wxWidgets.git/commitdiff
* Added delegate notifications for Become/Resign Main
authorDavid Elliott <dfe@tgwbd.org>
Thu, 4 Sep 2003 20:59:30 +0000 (20:59 +0000)
committerDavid Elliott <dfe@tgwbd.org>
Thu, 4 Sep 2003 20:59:30 +0000 (20:59 +0000)
* Added canBecomeMainWindow

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@23384 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

include/wx/cocoa/NSWindow.h
src/cocoa/NSWindow.mm

index 8f73ba32678c9dd5a2a287944d306d15e5532733..06d7aebf6c78171f0834da116e265630cfa49d6e 100644 (file)
@@ -25,9 +25,13 @@ public:
     void AssociateNSWindow(WX_NSWindow cocoaNSWindow);
     void DisassociateNSWindow(WX_NSWindow cocoaNSWindow);
     virtual void Cocoa_close(void) = 0;
+    virtual bool Cocoa_canBecomeMainWindow(bool &canBecome)
+    {   return false; }
     virtual bool CocoaDelegate_windowShouldClose(void) = 0;
     virtual void CocoaDelegate_windowDidBecomeKey(void) { }
     virtual void CocoaDelegate_windowDidResignKey(void) { }
+    virtual void CocoaDelegate_windowDidBecomeMain(void) { }
+    virtual void CocoaDelegate_windowDidResignMain(void) { }
 protected:
     static struct objc_object *sm_cocoaDelegate;
 };
index 45cf2bfa0a3606b731619baaa514aaa904a4b844..e3c1446d78fb30189148e7b817a5ebf77220d254 100644 (file)
@@ -39,6 +39,8 @@
 
 - (void)windowDidBecomeKey: (NSNotification *)notification;
 - (void)windowDidResignKey: (NSNotification *)notification;
+- (void)windowDidBecomeMain: (NSNotification *)notification;
+- (void)windowDidResignMain: (NSNotification *)notification;
 - (BOOL)windowShouldClose: (id)sender;
 @end //interface wxNSWindowDelegate
 
     win->CocoaDelegate_windowDidResignKey();
 }
 
+- (void)windowDidBecomeMain: (NSNotification *)notification
+{
+    wxCocoaNSWindow *win = wxCocoaNSWindow::GetFromCocoa([notification object]);
+    wxCHECK_RET(win,"notificationDidBecomeMain received but no wxWindow exists");
+    win->CocoaDelegate_windowDidBecomeMain();
+}
+
+- (void)windowDidResignMain: (NSNotification *)notification
+{
+    wxCocoaNSWindow *win = wxCocoaNSWindow::GetFromCocoa([notification object]);
+    wxCHECK_RET(win,"notificationDidResignMain received but no wxWindow exists");
+    win->CocoaDelegate_windowDidResignMain();
+}
+
 - (BOOL)windowShouldClose: (id)sender
 {
     wxLogDebug("windowShouldClose");
@@ -108,6 +124,7 @@ void wxCocoaNSWindow::DisassociateNSWindow(WX_NSWindow cocoaNSWindow)
 }
 
 - (void)close;
+- (BOOL)canBecomeMainWindow;
 @end // wxPoserNSwindow
 
 WX_IMPLEMENT_POSER(wxPoserNSWindow);
@@ -122,5 +139,14 @@ WX_IMPLEMENT_POSER(wxPoserNSWindow);
     [super close];
 }
 
+- (BOOL)canBecomeMainWindow
+{
+    bool canBecome = false;
+    wxCocoaNSWindow *tlw = wxCocoaNSWindow::GetFromCocoa(self);
+    if(!tlw || !tlw->Cocoa_canBecomeMainWindow(canBecome))
+        canBecome = [super canBecomeMainWindow];
+    return canBecome;
+}
+
 @end // implementation wxPoserNSWindow