X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/2cef71bc23a9cd0ec543e451848fb9e88ace36e9..b9efe021b554fa3967d1442cf758435c5cd5ae8f:/src/msw/listbox.cpp diff --git a/src/msw/listbox.cpp b/src/msw/listbox.cpp index 5f27c25a6e..ffe24da141 100644 --- a/src/msw/listbox.cpp +++ b/src/msw/listbox.cpp @@ -174,6 +174,10 @@ bool wxListBox::Create(wxWindow *parent, return false; } + // Necessary to prevent scroll problems within a notebook with Windows + // effects enabled + SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW)); + // initialize the contents for ( int i = 0; i < n; i++ ) { @@ -279,12 +283,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 +304,7 @@ int wxListBox::DoAppend(const wxString& item) SetHorizontalExtent(item); + InvalidateBestSize(); return index; } @@ -347,6 +352,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 +373,8 @@ void wxListBox::Clear() m_noItems = 0; SetHorizontalExtent(); + + InvalidateBestSize(); } void wxListBox::Free() @@ -520,8 +529,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 +552,8 @@ wxListBox::DoInsertItems(const wxArrayString& items, int pos) m_noItems += nItems; SetHorizontalExtent(); + + InvalidateBestSize(); } void wxListBox::SetString(int N, const wxString& s) @@ -591,6 +600,8 @@ void wxListBox::SetString(int N, const wxString& s) // we may have lost the selection if ( wasSelected ) Select(N); + + InvalidateBestSize(); } int wxListBox::GetCount() const @@ -622,7 +633,7 @@ void wxListBox::SetHorizontalExtent(const wxString& s) GetTextMetrics(dc, &lpTextMetric); SIZE extentXY; - ::GetTextExtentPoint(dc, (LPTSTR) (const wxChar *)s, s.Length(), &extentXY); + ::GetTextExtentPoint32(dc, (LPTSTR) (const wxChar *)s, s.Length(), &extentXY); int extentX = (int)(extentXY.cx + lpTextMetric.tmAveCharWidth); if (oldFont) @@ -646,7 +657,7 @@ void wxListBox::SetHorizontalExtent(const wxString& s) { wxString str = GetString(i); SIZE extentXY; - ::GetTextExtentPoint(dc, str.c_str(), str.length(), &extentXY); + ::GetTextExtentPoint32(dc, str.c_str(), str.length(), &extentXY); int extentX = (int)(extentXY.cx + lpTextMetric.tmAveCharWidth); if (extentX > largestExtent) largestExtent = extentX; @@ -691,7 +702,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; } // ----------------------------------------------------------------------------