X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/3ccc5735bfb404f46639d417c613ff77f413c612..267ba369d605996cf6f9673aad528bfcf662f942:/src/osx/nonownedwnd_osx.cpp diff --git a/src/osx/nonownedwnd_osx.cpp b/src/osx/nonownedwnd_osx.cpp index f586fcbaee..7b8f08cedd 100644 --- a/src/osx/nonownedwnd_osx.cpp +++ b/src/osx/nonownedwnd_osx.cpp @@ -13,6 +13,7 @@ #ifndef WX_PRECOMP #include "wx/app.h" + #include "wx/log.h" #endif // WX_PRECOMP #include "wx/hashmap.h" @@ -132,23 +133,9 @@ bool wxNonOwnedWindow::Create(wxWindow *parent, int w = WidthDefault(size.x); int h = HeightDefault(size.y); - // temporary define, TODO -#if wxOSX_USE_CARBON - m_nowpeer = new wxNonOwnedWindowCarbonImpl( this ); -#elif wxOSX_USE_COCOA - m_nowpeer = new wxNonOwnedWindowCocoaImpl( this ); -#elif wxOSX_USE_IPHONE - m_nowpeer = new wxNonOwnedWindowIPhoneImpl( this ); -#endif - - m_nowpeer->Create( parent, wxPoint(x,y) , wxSize(w,h) , style , GetExtraStyle(), name ) ; + m_nowpeer = wxNonOwnedWindowImpl::CreateNonOwnedWindow(this, parent, wxPoint(x,y) , wxSize(w,h) , style , GetExtraStyle(), name ); wxAssociateWindowWithWXWindow( m_nowpeer->GetWXWindow() , this ) ; -#if wxOSX_USE_CARBON - // temporary cast, TODO - m_peer = (wxMacControl*) wxWidgetImpl::CreateContentView(this); -#else m_peer = wxWidgetImpl::CreateContentView(this); -#endif DoSetWindowVariant( m_windowVariant ) ; @@ -165,9 +152,13 @@ bool wxNonOwnedWindow::Create(wxWindow *parent, wxNonOwnedWindow::~wxNonOwnedWindow() { + SendDestroyEvent(); + wxRemoveWXWindowAssociation( this ) ; - if ( m_nowpeer ) - m_nowpeer->Destroy(); + + DestroyChildren(); + + delete m_nowpeer; // avoid dangling refs if ( s_macDeactivateWindow == this ) @@ -180,7 +171,7 @@ wxNonOwnedWindow::~wxNonOwnedWindow() bool wxNonOwnedWindow::ShowWithEffect(wxShowEffect effect, unsigned timeout ) -{ +{ if ( !wxWindow::Show(true) ) return false; @@ -190,16 +181,16 @@ bool wxNonOwnedWindow::ShowWithEffect(wxShowEffect effect, HandleWindowEvent(event); - return m_nowpeer->ShowWithEffect(true, effect, timeout); + return m_nowpeer->ShowWithEffect(true, effect, timeout); } bool wxNonOwnedWindow::HideWithEffect(wxShowEffect effect, unsigned timeout ) -{ +{ if ( !wxWindow::Show(false) ) return false; - return m_nowpeer->ShowWithEffect(false, effect, timeout); + return m_nowpeer->ShowWithEffect(false, effect, timeout); } wxPoint wxNonOwnedWindow::GetClientAreaOrigin() const @@ -210,16 +201,17 @@ wxPoint wxNonOwnedWindow::GetClientAreaOrigin() const } bool wxNonOwnedWindow::SetBackgroundColour(const wxColour& c ) -{ +{ if ( !wxWindow::SetBackgroundColour(c) && m_hasBgCol ) return false ; - + if ( GetBackgroundStyle() != wxBG_STYLE_CUSTOM ) { - return m_nowpeer->SetBackgroundColour(c); + if ( m_nowpeer ) + return m_nowpeer->SetBackgroundColour(c); } return true; -} +} // Raise the window to the top of the Z order void wxNonOwnedWindow::Raise() @@ -253,7 +245,7 @@ void wxNonOwnedWindow::HandleResized( double timestampsec ) wxWindowMac::MacSuperChangedPosition() ; // like this only children will be notified } -void wxNonOwnedWindow::HandleResizing( double timestampsec, wxRect* rect ) +void wxNonOwnedWindow::HandleResizing( double WXUNUSED(timestampsec), wxRect* rect ) { wxRect r = *rect ; @@ -314,7 +306,7 @@ bool wxNonOwnedWindow::Show(bool show) if ( m_nowpeer ) m_nowpeer->Show(show); - + if ( show ) { // because apps expect a size event to occur at this moment @@ -322,7 +314,7 @@ bool wxNonOwnedWindow::Show(bool show) event.SetEventObject(this); HandleWindowEvent(event); } - + return true ; } @@ -353,12 +345,15 @@ bool wxNonOwnedWindow::SetBackgroundStyle(wxBackgroundStyle style) { if ( !wxWindow::SetBackgroundStyle(style) ) return false ; - - return m_nowpeer->SetBackgroundStyle(style); + + return m_nowpeer ? m_nowpeer->SetBackgroundStyle(style) : true; } void wxNonOwnedWindow::DoMoveWindow(int x, int y, int width, int height) { + if ( m_nowpeer == NULL ) + return; + m_cachedClippedRectValid = false ; m_nowpeer->MoveWindow(x, y, width, height); @@ -367,6 +362,9 @@ void wxNonOwnedWindow::DoMoveWindow(int x, int y, int width, int height) void wxNonOwnedWindow::DoGetPosition( int *x, int *y ) const { + if ( m_nowpeer == NULL ) + return; + int x1,y1 ; m_nowpeer->GetPosition(x1, y1); @@ -378,8 +376,11 @@ void wxNonOwnedWindow::DoGetPosition( int *x, int *y ) const void wxNonOwnedWindow::DoGetSize( int *width, int *height ) const { + if ( m_nowpeer == NULL ) + return; + int w,h; - + m_nowpeer->GetSize(w, h); if (width) @@ -390,6 +391,9 @@ void wxNonOwnedWindow::DoGetSize( int *width, int *height ) const void wxNonOwnedWindow::DoGetClientSize( int *width, int *height ) const { + if ( m_nowpeer == NULL ) + return; + int left, top, w, h; m_nowpeer->GetContentArea(left, top, w, h); @@ -415,10 +419,10 @@ WXWindow wxNonOwnedWindow::GetWXWindow() const // --------------------------------------------------------------------------- -bool wxNonOwnedWindow::SetShape(const wxRegion& region) +bool wxNonOwnedWindow::DoSetShape(const wxRegion& region) { wxCHECK_MSG( HasFlag(wxFRAME_SHAPED), false, - _T("Shaped windows must be created with the wxFRAME_SHAPED style.")); + wxT("Shaped windows must be created with the wxFRAME_SHAPED style.")); // The empty region signifies that the shape // should be removed from the window. @@ -429,7 +433,7 @@ bool wxNonOwnedWindow::SetShape(const wxRegion& region) if ( rgn.IsEmpty() ) return false ; else - return SetShape(rgn); + return DoSetShape(rgn); } return m_nowpeer->SetShape(region);