Patch #1203934: enable best size caching for MSW widgets

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@34120 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Robin Dunn
2005-05-18 02:23:01 +00:00
parent 3de6964a9f
commit 31582e4e11
15 changed files with 63 additions and 16 deletions

View 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

View File

@@ -241,7 +241,9 @@ wxSize wxButton::DoGetBestSize() const
return sz;
}
return wxSize(wBtn, hBtn);
wxSize best(wBtn, hBtn);
CacheBestSize(best);
return best;
}
/* static */

View 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)

View 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;
}

View 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

View 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;
}
// ----------------------------------------------------------------------------

View 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;
}
// ----------------------------------------------------------------------------

View 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.

View 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

View 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

View 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);

View 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

View 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)

View File

@@ -378,6 +378,7 @@ wxSize wxToolBar::DoGetBestSize() const
sizeBest.y = size.cy;
}
CacheBestSize(sizeBest);
return sizeBest;
}

View File

@@ -135,6 +135,7 @@ wxSize wxToggleButton::DoGetBestSize() const
wxSize sz(wBtn, hBtn);
#endif
CacheBestSize(sz);
return sz;
}