// 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
/////////////////////////////////////////////////////////////////////////////
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();