]> git.saurik.com Git - wxWidgets.git/commitdiff
Defer SetHorizontalExtent to idle, also fixes (wxListBox::Delete ignores Freeze/Thaw...
authorRobert Roebling <robert@roebling.de>
Sun, 25 May 2008 20:54:30 +0000 (20:54 +0000)
committerRobert Roebling <robert@roebling.de>
Sun, 25 May 2008 20:54:30 +0000 (20:54 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@53743 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

include/wx/msw/listbox.h
src/msw/listbox.cpp

index afb1dd3aba2bff655b0197e5592c707875dcab65..2d77f86c1a8263a7dc9607ed6c644c7915042bc2 100644 (file)
@@ -147,11 +147,13 @@ protected:
     virtual void* DoGetItemClientData(unsigned int n) const;
     virtual int DoListHitTest(const wxPoint& point) const;
 
+    bool m_updateHorizontalExtent;
+    virtual void OnInternalIdle();
+
     // free memory (common part of Clear() and dtor)
     void Free();
 
     unsigned int m_noItems;
-    int m_selected;
 
     virtual wxSize DoGetBestSize() const;
 
index aa082d4cdfbe799c638f43dad5d897b45c3580cd..9252783bed0406b208a24047ddfa1aea529f7294 100644 (file)
@@ -145,7 +145,7 @@ wxOwnerDrawn *wxListBox::CreateLboxItem(size_t WXUNUSED(n))
 wxListBox::wxListBox()
 {
     m_noItems = 0;
-    m_selected = 0;
+    m_updateHorizontalExtent = false;
 }
 
 bool wxListBox::Create(wxWindow *parent,
@@ -158,7 +158,7 @@ bool wxListBox::Create(wxWindow *parent,
                        const wxString& name)
 {
     m_noItems = 0;
-    m_selected = 0;
+    m_updateHorizontalExtent = false;
 
     // initialize base class fields
     if ( !CreateControl(parent, id, pos, size, style, validator, name) )
@@ -245,6 +245,17 @@ WXDWORD wxListBox::MSWGetStyle(long style, WXDWORD *exstyle) const
     return msStyle;
 }
 
+void wxListBox::OnInternalIdle()
+{
+    wxWindow::OnInternalIdle();
+    
+    if (m_updateHorizontalExtent)
+    {
+        SetHorizontalExtent(wxEmptyString);
+        m_updateHorizontalExtent = false;
+    }
+}
+
 // ----------------------------------------------------------------------------
 // implementation of wxListBoxBase methods
 // ----------------------------------------------------------------------------
@@ -265,7 +276,8 @@ void wxListBox::DoDeleteOneItem(unsigned int n)
     SendMessage(GetHwnd(), LB_DELETESTRING, n, 0);
     m_noItems--;
 
-    SetHorizontalExtent(wxEmptyString);
+    // SetHorizontalExtent(wxEmptyString); can be slow
+    m_updateHorizontalExtent = true;
 
     UpdateOldSelections();
 }
@@ -290,7 +302,7 @@ void wxListBox::DoClear()
     ListBox_ResetContent(GetHwnd());
 
     m_noItems = 0;
-    SetHorizontalExtent();
+    m_updateHorizontalExtent = true;
 
     UpdateOldSelections();
 }
@@ -468,7 +480,7 @@ int wxListBox::DoInsertItems(const wxArrayStringsAdapter & items,
         AssignNewItemClientData(n, clientData, i, type);
     }
 
-    SetHorizontalExtent();
+    m_updateHorizontalExtent = true;
 
     UpdateOldSelections();
 
@@ -530,7 +542,7 @@ void wxListBox::SetString(unsigned int n, const wxString& s)
     if ( wasSelected )
         Select(n);
 
-    SetHorizontalExtent();
+    m_updateHorizontalExtent = true;
 }
 
 unsigned int wxListBox::GetCount() const