]> git.saurik.com Git - wxWidgets.git/commitdiff
Patch #1203934: enable best size caching for MSW widgets
authorRobin Dunn <robin@alldunn.com>
Wed, 18 May 2005 02:23:01 +0000 (02:23 +0000)
committerRobin Dunn <robin@alldunn.com>
Wed, 18 May 2005 02:23:01 +0000 (02:23 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@34120 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

15 files changed:
src/msw/bmpbuttn.cpp
src/msw/button.cpp
src/msw/checkbox.cpp
src/msw/checklst.cpp
src/msw/choice.cpp
src/msw/datectrl.cpp
src/msw/listbox.cpp
src/msw/radiobox.cpp
src/msw/radiobut.cpp
src/msw/scrolbar.cpp
src/msw/statbmp.cpp
src/msw/statbox.cpp
src/msw/stattext.cpp
src/msw/tbar95.cpp
src/msw/tglbtn.cpp

index e1be21611f2270c55b891b3106919f67fcb30a17..05d6d3807aaf9c73ccd8419d1c57e45f1e39432a 100644 (file)
@@ -494,8 +494,10 @@ wxSize wxBitmapButton::DoGetBestSize() const
 {
     if ( m_bmpNormal.Ok() )
     {
-        return wxSize(m_bmpNormal.GetWidth() + 2*m_marginX,
+        wxSize best(m_bmpNormal.GetWidth() + 2*m_marginX,
                       m_bmpNormal.GetHeight() + 2*m_marginY);
+        CacheBestSize(best);
+        return best;
     }
 
     // no idea what our best size should be, defer to the base class
index b50d0c6bd88b9339ea7215f6be9a2c7cd99422bd..b9ac7363752d50a993e083be98e8056f419bec10 100644 (file)
@@ -241,7 +241,9 @@ wxSize wxButton::DoGetBestSize() const
         return sz;
     }
 
-    return wxSize(wBtn, hBtn);
+    wxSize best(wBtn, hBtn);
+    CacheBestSize(best);
+    return best;
 }
 
 /* static */
index 3955dba0642fbd6d5884d4719ccf8207a120b291..709a7491fb965a80c9ea798fc71b5d8d80d4847f 100644 (file)
@@ -198,7 +198,9 @@ wxSize wxCheckBox::DoGetBestSize() const
     hCheckbox += 1;
 #endif
 
-    return wxSize(wCheckbox, hCheckbox);
+    wxSize best(wCheckbox, hCheckbox);
+    CacheBestSize(best);
+    return best;
 }
 
 void wxCheckBox::SetValue(bool val)
index 8327c328af838180554257b13350c24412a96cd6..602bab2372753c70e1b949eac935bfa7935d82d9 100644 (file)
@@ -548,6 +548,7 @@ wxSize wxCheckListBox::DoGetBestSize() const
 {
     wxSize best = wxListBox::DoGetBestSize();
     best.x += wxOwnerDrawn::GetDefaultMarginWidth();  // add room for the checkbox
+    CacheBestSize(best);
     return best;
 }
 
index 2a83571ecbdf1133557ea9a89eee4aa512fe39ef..859e700b714188f143a645e3e73c5b341510ece5 100644 (file)
@@ -236,6 +236,7 @@ int wxChoice::DoAppend(const wxString& item)
             UpdateVisibleHeight();
     }
 
+    InvalidateBestSize();
     return n;
 }
 
@@ -255,6 +256,7 @@ int wxChoice::DoInsert(const wxString& item, int pos)
             UpdateVisibleHeight();
     }
 
+    InvalidateBestSize();
     return n;
 }
 
@@ -271,6 +273,8 @@ void wxChoice::Delete(int n)
 
     if ( !IsFrozen() )
         UpdateVisibleHeight();
+
+    InvalidateBestSize();
 }
 
 void wxChoice::Clear()
@@ -281,6 +285,8 @@ void wxChoice::Clear()
 
     if ( !IsFrozen() )
         UpdateVisibleHeight();
+
+    InvalidateBestSize();
 }
 
 void wxChoice::Free()
@@ -383,6 +389,8 @@ void wxChoice::SetString(int n, const wxString& s)
         DoSetItemClientData(n, data);
     }
     //else: it's already NULL by default
+
+    InvalidateBestSize();
 }
 
 wxString wxChoice::GetString(int n) const
index 4b6c8c6e61ec9d6179b43f632145882bacb828cf..7f00c820f5910f082519d1015b7ddc759522c4a7 100644 (file)
@@ -180,7 +180,9 @@ wxSize wxDatePickerCtrl::DoGetBestSize() const
 {
     const int y = GetCharHeight();
 
-    return wxSize(DEFAULT_ITEM_WIDTH, EDIT_HEIGHT_FROM_CHAR_HEIGHT(y));
+    wxSize best(DEFAULT_ITEM_WIDTH, EDIT_HEIGHT_FROM_CHAR_HEIGHT(y));
+    CacheBestSize(best);
+    return best;
 }
 
 // ----------------------------------------------------------------------------
index eafc7c1909a611022b5c1d88e1e781f933bb0858..c799cf3479f025848aab58b9bece27e74b1389f0 100644 (file)
@@ -279,12 +279,12 @@ void wxListBox::Delete(int N)
     m_noItems--;
 
     SetHorizontalExtent(wxEmptyString);
+
+    InvalidateBestSize();
 }
 
 int wxListBox::DoAppend(const wxString& item)
 {
-    InvalidateBestSize();
-
     int index = ListBox_AddString(GetHwnd(), item);
     m_noItems++;
 
@@ -300,6 +300,7 @@ int wxListBox::DoAppend(const wxString& item)
 
     SetHorizontalExtent(item);
 
+    InvalidateBestSize();
     return index;
 }
 
@@ -347,6 +348,8 @@ void wxListBox::DoSetItems(const wxArrayString& choices, void** clientData)
         // show the listbox back if we hid it
         ShowWindow(GetHwnd(), SW_SHOW);
     }
+
+    InvalidateBestSize();
 }
 
 int wxListBox::FindString(const wxString& s) const
@@ -366,6 +369,8 @@ void wxListBox::Clear()
 
     m_noItems = 0;
     SetHorizontalExtent();
+
+    InvalidateBestSize();
 }
 
 void wxListBox::Free()
@@ -520,8 +525,6 @@ wxListBox::DoInsertItems(const wxArrayString& items, int pos)
     wxCHECK_RET( pos >= 0 && pos <= m_noItems,
                  wxT("invalid index in wxListBox::InsertItems") );
 
-    InvalidateBestSize();
-
     int nItems = items.GetCount();
     for ( int i = 0; i < nItems; i++ )
     {
@@ -545,6 +548,8 @@ wxListBox::DoInsertItems(const wxArrayString& items, int pos)
     m_noItems += nItems;
 
     SetHorizontalExtent();
+
+    InvalidateBestSize();
 }
 
 void wxListBox::SetString(int N, const wxString& s)
@@ -591,6 +596,8 @@ void wxListBox::SetString(int N, const wxString& s)
     // we may have lost the selection
     if ( wasSelected )
         Select(N);
+
+    InvalidateBestSize();
 }
 
 int wxListBox::GetCount() const
@@ -691,7 +698,9 @@ wxSize wxListBox::DoGetBestSize() const
     int hListbox = EDIT_HEIGHT_FROM_CHAR_HEIGHT(cy)*
                     wxMin(wxMax(m_noItems, 3), 10);
 
-    return wxSize(wListbox, hListbox);
+    wxSize best(wListbox, hListbox);
+    CacheBestSize(best);
+    return best;
 }
 
 // ----------------------------------------------------------------------------
index 21fb1fd4f4ffddc4844c978138116bec23368949..b5cdc6eedab07162709edab585b412b5c5a85148 100644 (file)
@@ -374,6 +374,8 @@ void wxRadioBox::SetString(int item, const wxString& label)
     m_radioHeight[item] = wxDefaultCoord;
 
     ::SetWindowText((*m_radioButtons)[item], label.c_str());
+
+    InvalidateBestSize();
 }
 
 void wxRadioBox::SetSelection(int N)
@@ -428,7 +430,10 @@ bool wxRadioBox::Show(int item, bool show)
 
     BOOL ret = ::ShowWindow((*m_radioButtons)[item], show ? SW_SHOW : SW_HIDE);
 
-    return (ret != 0) == show;
+    bool changed = (ret != 0) == show;
+    if( changed )
+        InvalidateBestSize();
+    return changed;
 }
 
 WX_FORWARD_STD_METHODS_TO_SUBWINDOWS(wxRadioBox, wxStaticBox, m_radioButtons)
@@ -498,7 +503,9 @@ wxSize wxRadioBox::GetTotalButtonSize(const wxSize& sizeBtn) const
 
 wxSize wxRadioBox::DoGetBestSize() const
 {
-    return GetTotalButtonSize(GetMaxButtonSize());
+    wxSize best = GetTotalButtonSize(GetMaxButtonSize());
+    CacheBestSize(best);
+    return best;
 }
 
 // Restored old code.
index e88d6d7829b0dd21ea24c0dd930611c7f812909c..5bab31033748f2cb7506263589dfda2877a1916c 100644 (file)
@@ -312,7 +312,9 @@ wxSize wxRadioButton::DoGetBestSize() const
         hRadio = s_radioSize;
     }
 
-    return wxSize(wRadio, hRadio);
+    wxSize best(wRadio, hRadio);
+    CacheBestSize(best);
+    return best;
 }
 
 #endif // wxUSE_RADIOBTN
index 9c9da3082d599bcc7f709e131a36c4085b45354a..421e47578b048d800f88e57884110952e3f66a47 100644 (file)
@@ -325,7 +325,9 @@ wxSize wxScrollBar::DoGetBestSize() const
         h = wxSystemSettings::GetMetric(wxSYS_HSCROLL_Y);
     }
 
-    return wxSize(w, h);
+    wxSize best(w, h);
+    CacheBestSize(best);
+    return best;
 }
 
 WXDWORD wxScrollBar::MSWGetStyle(long style, WXDWORD *exstyle) const
index f7c3e6e2061937c9665f2fdba0431359bb0c55cf..61d7b01e76992ed7721305be9c01336335066c55 100644 (file)
@@ -208,7 +208,11 @@ void wxStaticBitmap::Free()
 wxSize wxStaticBitmap::DoGetBestSize() const
 {
     if ( ImageIsOk() )
-        return wxSize(m_image->GetWidth(), m_image->GetHeight());
+    {
+        wxSize best(m_image->GetWidth(), m_image->GetHeight());
+        CacheBestSize(best);
+        return best;
+    }
 
     // this is completely arbitrary
     return wxSize(16, 16);
index 3ccf5f6e348704ab38e7ba3792c80850735e4439..42fec06f706bf3d497b040b47268847e213b8c6f 100644 (file)
@@ -168,7 +168,9 @@ wxSize wxStaticBox::DoGetBestSize() const
     wBox += 3*cx;
     int hBox = EDIT_HEIGHT_FROM_CHAR_HEIGHT(cy);
 
-    return wxSize(wBox, hBox);
+    wxSize best(wBox, hBox);
+    CacheBestSize(best);
+    return best;
 }
 
 void wxStaticBox::GetBordersForSizer(int *borderTop, int *borderOther) const
index 124d9e471d935eddd112a910b0a6849d9f7c6360..cc4b995d2d3469654b5d54d026e62d7d2306f68a 100644 (file)
@@ -143,7 +143,9 @@ wxSize wxStaticText::DoGetBestSize() const
         widthTextMax += 2;
 #endif // __WXWINCE__
 
-    return wxSize(widthTextMax, heightTextTotal);
+    wxSize best(widthTextMax, heightTextTotal);
+    CacheBestSize(best);
+    return best;
 }
 
 void wxStaticText::DoSetSize(int x, int y, int w, int h, int sizeFlags)
index 7ea83bd343b65db73824bd93083091830e1092d1..1286461f05f30afe1b34c85cdf8d72b0ad5f63a3 100644 (file)
@@ -378,6 +378,7 @@ wxSize wxToolBar::DoGetBestSize() const
         sizeBest.y = size.cy;
     }
 
+    CacheBestSize(sizeBest);
     return sizeBest;
 }
 
index 6b91280e856ac18738c99954fad26fba785306fe..c3f1af62bc7471b2f3bd0fd54cc0d0a9408d6035 100644 (file)
@@ -135,6 +135,7 @@ wxSize wxToggleButton::DoGetBestSize() const
    wxSize sz(wBtn, hBtn);
 #endif
 
+   CacheBestSize(sz);
    return sz;
 }