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
This commit is contained in:
Vadim Zeitlin
2009-10-05 22:57:50 +00:00
parent 3996b21a7f
commit ff6893d2c2
2 changed files with 14 additions and 0 deletions

View File

@@ -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 );

View File

@@ -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 ; }