* Added delegate notifications for Become/Resign Main
* Added canBecomeMainWindow git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@23384 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -25,9 +25,13 @@ public:
|
|||||||
void AssociateNSWindow(WX_NSWindow cocoaNSWindow);
|
void AssociateNSWindow(WX_NSWindow cocoaNSWindow);
|
||||||
void DisassociateNSWindow(WX_NSWindow cocoaNSWindow);
|
void DisassociateNSWindow(WX_NSWindow cocoaNSWindow);
|
||||||
virtual void Cocoa_close(void) = 0;
|
virtual void Cocoa_close(void) = 0;
|
||||||
|
virtual bool Cocoa_canBecomeMainWindow(bool &canBecome)
|
||||||
|
{ return false; }
|
||||||
virtual bool CocoaDelegate_windowShouldClose(void) = 0;
|
virtual bool CocoaDelegate_windowShouldClose(void) = 0;
|
||||||
virtual void CocoaDelegate_windowDidBecomeKey(void) { }
|
virtual void CocoaDelegate_windowDidBecomeKey(void) { }
|
||||||
virtual void CocoaDelegate_windowDidResignKey(void) { }
|
virtual void CocoaDelegate_windowDidResignKey(void) { }
|
||||||
|
virtual void CocoaDelegate_windowDidBecomeMain(void) { }
|
||||||
|
virtual void CocoaDelegate_windowDidResignMain(void) { }
|
||||||
protected:
|
protected:
|
||||||
static struct objc_object *sm_cocoaDelegate;
|
static struct objc_object *sm_cocoaDelegate;
|
||||||
};
|
};
|
||||||
|
@@ -39,6 +39,8 @@
|
|||||||
|
|
||||||
- (void)windowDidBecomeKey: (NSNotification *)notification;
|
- (void)windowDidBecomeKey: (NSNotification *)notification;
|
||||||
- (void)windowDidResignKey: (NSNotification *)notification;
|
- (void)windowDidResignKey: (NSNotification *)notification;
|
||||||
|
- (void)windowDidBecomeMain: (NSNotification *)notification;
|
||||||
|
- (void)windowDidResignMain: (NSNotification *)notification;
|
||||||
- (BOOL)windowShouldClose: (id)sender;
|
- (BOOL)windowShouldClose: (id)sender;
|
||||||
@end //interface wxNSWindowDelegate
|
@end //interface wxNSWindowDelegate
|
||||||
|
|
||||||
@@ -58,6 +60,20 @@
|
|||||||
win->CocoaDelegate_windowDidResignKey();
|
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
|
- (BOOL)windowShouldClose: (id)sender
|
||||||
{
|
{
|
||||||
wxLogDebug("windowShouldClose");
|
wxLogDebug("windowShouldClose");
|
||||||
@@ -108,6 +124,7 @@ void wxCocoaNSWindow::DisassociateNSWindow(WX_NSWindow cocoaNSWindow)
|
|||||||
}
|
}
|
||||||
|
|
||||||
- (void)close;
|
- (void)close;
|
||||||
|
- (BOOL)canBecomeMainWindow;
|
||||||
@end // wxPoserNSwindow
|
@end // wxPoserNSwindow
|
||||||
|
|
||||||
WX_IMPLEMENT_POSER(wxPoserNSWindow);
|
WX_IMPLEMENT_POSER(wxPoserNSWindow);
|
||||||
@@ -122,5 +139,14 @@ WX_IMPLEMENT_POSER(wxPoserNSWindow);
|
|||||||
[super close];
|
[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
|
@end // implementation wxPoserNSWindow
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user