]> git.saurik.com Git - wxWidgets.git/blobdiff - src/osx/nonownedwnd_osx.cpp
Improve mouse handling code in wxAuiToolBar.
[wxWidgets.git] / src / osx / nonownedwnd_osx.cpp
index 5ed8b5993fc4f30ab834ac02a5790b28d1a3328e..c5c7419c20e30fee21bf65f5b3be3b995aae98ef 100644 (file)
@@ -3,7 +3,7 @@
 // Purpose:     implementation of wxNonOwnedWindow
 // Author:      Stefan Csomor
 // Created:     2008-03-24
-// RCS-ID:      $Id: nonownedwnd.cpp 50329 2007-11-29 17:00:58Z VS $
+// RCS-ID:      $Id$
 // Copyright:   (c) Stefan Csomor 2008
 // Licence:     wxWindows licence
 /////////////////////////////////////////////////////////////////////////////
@@ -149,17 +149,39 @@ bool wxNonOwnedWindow::Create(wxWindow *parent,
 
 bool wxNonOwnedWindow::Create(wxWindow *parent, WXWindow nativeWindow)
 {
-    m_nowpeer = wxNonOwnedWindowImpl::CreateNonOwnedWindow(this, parent, nativeWindow );
+    if ( parent )
+        parent->AddChild(this);
+    
+    SubclassWin(nativeWindow);
+    
+    return true;
+}
+
+void wxNonOwnedWindow::SubclassWin(WXWindow nativeWindow)
+{
+    wxASSERT_MSG( !m_isNativeWindowWrapper, wxT("subclassing window twice?") );
+    wxASSERT_MSG( m_nowpeer == NULL, wxT("window already was created") );
+
+    m_nowpeer = wxNonOwnedWindowImpl::CreateNonOwnedWindow(this, GetParent(), nativeWindow );
     m_isNativeWindowWrapper = true;
     wxNonOwnedWindowImpl::Associate( m_nowpeer->GetWXWindow() , m_nowpeer ) ;
     m_peer = wxWidgetImpl::CreateContentView(this);
+}
 
-    if ( parent )
-        parent->AddChild(this);
+void wxNonOwnedWindow::UnsubclassWin()
+{
+    wxASSERT_MSG( m_isNativeWindowWrapper, wxT("window was not subclassed") );
+
+    if ( GetParent() )
+        GetParent()->RemoveChild(this);
     
-    return true;
+    wxNonOwnedWindowImpl::RemoveAssociations(m_nowpeer) ;    
+    wxDELETE(m_nowpeer);
+    wxDELETE(m_peer);
+    m_isNativeWindowWrapper = false;
 }
 
+
 wxNonOwnedWindow::~wxNonOwnedWindow()
 {
     SendDestroyEvent();