]> git.saurik.com Git - wxWidgets.git/commitdiff
Applied patch [ 1845819 ] wxMSW Top level window freeze fix for trunk
authorRobin Dunn <robin@alldunn.com>
Thu, 13 Dec 2007 20:56:15 +0000 (20:56 +0000)
committerRobin Dunn <robin@alldunn.com>
Thu, 13 Dec 2007 20:56:15 +0000 (20:56 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@50681 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

include/wx/msw/toplevel.h
include/wx/msw/window.h
src/msw/toplevel.cpp

index 82379ad36dc429355942422e9292af44262d1229..3938b96e62b8f114d41c56b5e3edfc46baa5a170 100644 (file)
@@ -75,6 +75,12 @@ public:
     virtual bool SetTransparent(wxByte alpha);
     virtual bool CanSetTransparent();
 
+    //Top level windows have different freeze semantics on Windows
+    virtual void Freeze();
+    virtual void Thaw();
+
+    virtual void AddChild( wxWindowBase *child );
+
 
     // implementation from now on
     // --------------------------
index 86bd78cda3c10e20eb0076604f2f3f54e6b403be..dd35d7fd8800f1afc9dff8fb957a6f04f11b743a 100644 (file)
@@ -555,8 +555,7 @@ private:
     bool HandleNotify(int idCtrl, WXLPARAM lParam, WXLPARAM *result);
 
 
-    // number of calls to Freeze() minus number of calls to Thaw()
-    unsigned int m_frozenness;
+    
 
     // current defer window position operation handle (may be NULL)
     WXHANDLE m_hDWP;
@@ -568,6 +567,10 @@ protected:
     wxPoint     m_pendingPosition;
     wxSize      m_pendingSize;
 
+    // number of calls to Freeze() minus number of calls to Thaw()
+    // protected so that wxTopLevelWindowMSW can access it
+    unsigned int m_frozenness;
+
 private:
 #ifdef __POCKETPC__
     bool        m_contextMenuEnabled;
index 7c9fd6c588e77e13f2aae6bf25dc0aaf6677af6c..57e85c391357ed0d9c361e90be360b9243569892 100644 (file)
@@ -1170,6 +1170,60 @@ bool wxTopLevelWindowMSW::CanSetTransparent()
     return (os_type == wxOS_WINDOWS_NT && ver_major >= 5);
 }
 
+
+void wxTopLevelWindowMSW::Freeze()
+{
+    if ( !m_frozenness++) {
+        if (IsShown()) {
+            for ( wxWindowList::compatibility_iterator node = GetChildren().GetFirst();
+                node;
+                node = node->GetNext() )
+            {
+                wxWindow *child = node->GetData();
+                if ( child->IsTopLevel() )
+                    continue;
+                else
+                    child->Freeze();
+            }
+        }
+    }
+}
+
+void wxTopLevelWindowMSW::Thaw()
+{
+    wxASSERT_MSG( m_frozenness > 0, _T("Thaw() without matching Freeze()") );
+    if ( --m_frozenness == 0 )
+    {
+        if ( IsShown() ) {
+            for ( wxWindowList::compatibility_iterator node = GetChildren().GetFirst();
+                node;
+                node = node->GetNext() )
+            {
+                wxWindow *child = node->GetData();
+                if ( child->IsTopLevel() )
+                    continue;
+                else
+                    child->Thaw();
+            }
+        }
+    }
+}
+
+
+void wxTopLevelWindowMSW::AddChild(wxWindowBase *child )
+{
+    //adding a child while frozen will assert when thawn,
+    // so freeze it
+    if (child && !child->IsTopLevel() && IsFrozen()) {
+        //need to match our current freeze level
+        for (unsigned int ii=0;ii< m_frozenness;ii++) {
+            child->Freeze();
+        }
+    }
+    wxTopLevelWindowBase::AddChild(child);
+}
+
+
 // ----------------------------------------------------------------------------
 // wxTopLevelWindow event handling
 // ----------------------------------------------------------------------------