From ff6893d2c2c05cf0c4e81f00cfdd6466b15b9c93 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Mon, 5 Oct 2009 22:57:50 +0000 Subject: [PATCH] Added a virtual wxWindow::OSXGetViewOrWindow() method. This can be used to retrieve either an NSView for child windows or NSWindow for non-owned ones without resorting to dynamic casts. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@62303 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/osx/nonownedwnd.h | 5 +++++ include/wx/osx/window.h | 9 +++++++++ 2 files changed, 14 insertions(+) diff --git a/include/wx/osx/nonownedwnd.h b/include/wx/osx/nonownedwnd.h index 6df0dbe286..b7b73e4e71 100644 --- a/include/wx/osx/nonownedwnd.h +++ b/include/wx/osx/nonownedwnd.h @@ -97,6 +97,11 @@ public: wxNonOwnedWindowImpl* GetNonOwnedPeer() const { return m_nowpeer; } +#if wxOSX_USE_COCOA_OR_IPHONE + // override the base class method to return an NSWindow instead of NSView + virtual void *OSXGetViewOrWindow() const { return GetWXWindow(); } +#endif // Cocoa + // osx specific event handling common for all osx-ports virtual void HandleActivated( double timestampsec, bool didActivate ); diff --git a/include/wx/osx/window.h b/include/wx/osx/window.h index 7afe50d61a..c7398555c9 100644 --- a/include/wx/osx/window.h +++ b/include/wx/osx/window.h @@ -237,6 +237,15 @@ public: // the 'true' OS level control for this wxWindow wxOSXWidgetImpl* GetPeer() const { return m_peer ; } +#if wxOSX_USE_COCOA_OR_IPHONE + // the NSView or NSWindow of this window: can be used for both child and + // non-owned windows + // + // this is useful for a few Cocoa function which can work with either views + // or windows indiscriminately, e.g. for setting NSViewAnimationTargetKey + virtual void *OSXGetViewOrWindow() const { return GetHandle(); } +#endif // Cocoa + void * MacGetCGContextRef() { return m_cgContextRef ; } void MacSetCGContextRef(void * cg) { m_cgContextRef = cg ; } -- 2.45.2