]> git.saurik.com Git - wxWidgets.git/blobdiff - src/osx/nonownedwnd_osx.cpp
Fix another line somehow missing from the wxGraphicsBitmap forward port.
[wxWidgets.git] / src / osx / nonownedwnd_osx.cpp
index 7b8f08cedd59ace147a2ba038d9ccf585199f046..017107215f22521e3e247c280e9dc01380018a69 100644 (file)
@@ -159,38 +159,56 @@ wxNonOwnedWindow::~wxNonOwnedWindow()
     DestroyChildren();
 
     delete m_nowpeer;
+    m_nowpeer = NULL;
 
     // avoid dangling refs
     if ( s_macDeactivateWindow == this )
         s_macDeactivateWindow = NULL;
 }
 
+bool wxNonOwnedWindow::Destroy()
+{
+    WillBeDestroyed();
+    
+    return wxWindow::Destroy();
+}
+
+void wxNonOwnedWindow::WillBeDestroyed()
+{
+    if ( m_nowpeer )
+        m_nowpeer->WillBeDestroyed();
+}
+
 // ----------------------------------------------------------------------------
 // wxNonOwnedWindow misc
 // ----------------------------------------------------------------------------
 
-bool wxNonOwnedWindow::ShowWithEffect(wxShowEffect effect,
-                                unsigned timeout )
+bool wxNonOwnedWindow::OSXShowWithEffect(bool show,
+                                         wxShowEffect effect,
+                                         unsigned timeout)
 {
-    if ( !wxWindow::Show(true) )
+    // 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);
-
+    if ( effect == wxSHOW_EFFECT_NONE ||
+            !m_nowpeer || !m_nowpeer->ShowWithEffect(show, effect, timeout) )
+        return Show(show);
 
-    return m_nowpeer->ShowWithEffect(true, effect, timeout);
-}
-
-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
@@ -213,6 +231,17 @@ bool wxNonOwnedWindow::SetBackgroundColour(const wxColour& 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()
 {
@@ -395,8 +424,13 @@ void wxNonOwnedWindow::DoGetClientSize( int *width, int *height ) const
         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)