X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/524c47aa3adf2af11a3069fd5da035a604f08f66..960615f41009ac62e99f833afbec10d96bd2d2f9:/src/osx/nonownedwnd_osx.cpp diff --git a/src/osx/nonownedwnd_osx.cpp b/src/osx/nonownedwnd_osx.cpp index 59905b824f..9adc5647d5 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" @@ -151,12 +152,12 @@ bool wxNonOwnedWindow::Create(wxWindow *parent, wxNonOwnedWindow::~wxNonOwnedWindow() { - m_isBeingDeleted = true; - + SendDestroyEvent(); + wxRemoveWXWindowAssociation( this ) ; - + DestroyChildren(); - + delete m_nowpeer; // avoid dangling refs @@ -168,28 +169,32 @@ wxNonOwnedWindow::~wxNonOwnedWindow() // wxNonOwnedWindow misc // ---------------------------------------------------------------------------- -bool wxNonOwnedWindow::ShowWithEffect(wxShowEffect effect, - unsigned timeout ) -{ - if ( !wxWindow::Show(true) ) +bool wxNonOwnedWindow::OSXShowWithEffect(bool show, + wxShowEffect effect, + unsigned timeout) +{ + // Cocoa code needs to manage window visibility on its own and so calls + // wxWindow::Show() as needed but if we already changed the internal + // visibility flag here, Show() would do nothing, so avoid doing it +#if wxOSX_USE_CARBON + if ( !wxWindow::Show(show) ) return false; +#endif // Carbon - // because apps expect a size event to occur at this moment - wxSizeEvent event(GetSize() , m_windowId); - event.SetEventObject(this); - HandleWindowEvent(event); - - - return m_nowpeer->ShowWithEffect(true, effect, timeout); -} + if ( effect == wxSHOW_EFFECT_NONE || + !m_nowpeer || !m_nowpeer->ShowWithEffect(show, effect, timeout) ) + return Show(show); -bool wxNonOwnedWindow::HideWithEffect(wxShowEffect effect, - unsigned timeout ) -{ - if ( !wxWindow::Show(false) ) - return false; + if ( show ) + { + // as apps expect a size event to occur when the window is shown, + // generate one when it is shown with effect too + wxSizeEvent event(GetSize(), m_windowId); + event.SetEventObject(this); + HandleWindowEvent(event); + } - return m_nowpeer->ShowWithEffect(false, effect, timeout); + return true; } wxPoint wxNonOwnedWindow::GetClientAreaOrigin() const @@ -200,17 +205,28 @@ wxPoint wxNonOwnedWindow::GetClientAreaOrigin() const } bool wxNonOwnedWindow::SetBackgroundColour(const wxColour& c ) -{ +{ if ( !wxWindow::SetBackgroundColour(c) && m_hasBgCol ) return false ; - + if ( GetBackgroundStyle() != wxBG_STYLE_CUSTOM ) { if ( m_nowpeer ) return m_nowpeer->SetBackgroundColour(c); } return true; -} +} + +void wxNonOwnedWindow::SetWindowStyleFlag(long flags) +{ + if (flags == GetWindowStyleFlag()) + return; + + wxWindow::SetWindowStyleFlag(flags); + + if (m_nowpeer) + m_nowpeer->SetWindowStyleFlag(flags); +} // Raise the window to the top of the Z order void wxNonOwnedWindow::Raise() @@ -244,7 +260,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 ; @@ -305,7 +321,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 @@ -313,7 +329,7 @@ bool wxNonOwnedWindow::Show(bool show) event.SetEventObject(this); HandleWindowEvent(event); } - + return true ; } @@ -344,12 +360,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); @@ -358,6 +377,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); @@ -369,8 +391,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) @@ -381,9 +406,17 @@ 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; + // perhaps we should do this for all ? +#ifdef __WXOSX_IPHONE__ + m_peer->GetContentArea(left, top, w, h); +#else m_nowpeer->GetContentArea(left, top, w, h); - +#endif + if (width) *width = w ; if (height) @@ -406,10 +439,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. @@ -420,7 +453,7 @@ bool wxNonOwnedWindow::SetShape(const wxRegion& region) if ( rgn.IsEmpty() ) return false ; else - return SetShape(rgn); + return DoSetShape(rgn); } return m_nowpeer->SetShape(region);