X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/84f7327f47d5895c8fcc056217945f1863f63fc6..99d800190a04a2deaf769017a5fae04a4ae50378:/src/msw/listbox.cpp diff --git a/src/msw/listbox.cpp b/src/msw/listbox.cpp index 84e7896bdf..5f27c25a6e 100644 --- a/src/msw/listbox.cpp +++ b/src/msw/listbox.cpp @@ -43,10 +43,6 @@ #include "wx/ownerdrw.h" #endif -#ifdef __GNUWIN32_OLD__ - #include "wx/msw/gnuwin32/extra.h" -#endif - #if wxUSE_EXTENDED_RTTI WX_DEFINE_FLAGS( wxListBoxStyle ) @@ -390,7 +386,7 @@ void wxListBox::Free() } } -void wxListBox::SetSelection(int N, bool select) +void wxListBox::DoSetSelection(int N, bool select) { wxCHECK_RET( N == wxNOT_FOUND || (N >= 0 && N < m_noItems), @@ -507,13 +503,13 @@ int wxListBox::GetSelection() const wxString wxListBox::GetString(int N) const { wxCHECK_MSG( N >= 0 && N < m_noItems, wxEmptyString, - wxT("invalid index in wxListBox::GetClientData") ); + wxT("invalid index in wxListBox::GetString") ); int len = ListBox_GetTextLen(GetHwnd(), N); // +1 for terminating NUL wxString result; - ListBox_GetText(GetHwnd(), N, wxStringBuffer(result, len + 1)); + ListBox_GetText(GetHwnd(), N, (wxChar*)wxStringBuffer(result, len + 1)); return result; } @@ -616,12 +612,12 @@ void wxListBox::SetHorizontalExtent(const wxString& s) return; TEXTMETRIC lpTextMetric; - if ( !s.IsEmpty() ) + if ( !s.empty() ) { int existingExtent = (int)SendMessage(GetHwnd(), LB_GETHORIZONTALEXTENT, 0, 0L); HDC dc = GetWindowDC(GetHwnd()); HFONT oldFont = 0; - if (GetFont().Ok() && GetFont().GetResourceHandle()) + if (GetFont().Ok() && GetFont().GetResourceHandle() != 0) oldFont = (HFONT) ::SelectObject(dc, (HFONT) GetFont().GetResourceHandle()); GetTextMetrics(dc, &lpTextMetric); @@ -641,19 +637,16 @@ void wxListBox::SetHorizontalExtent(const wxString& s) int largestExtent = 0; HDC dc = GetWindowDC(GetHwnd()); HFONT oldFont = 0; - if (GetFont().Ok() && GetFont().GetResourceHandle()) + if (GetFont().Ok() && GetFont().GetResourceHandle() != 0) oldFont = (HFONT) ::SelectObject(dc, (HFONT) GetFont().GetResourceHandle()); GetTextMetrics(dc, &lpTextMetric); - // FIXME: buffer overflow!! - wxChar buf[1024]; for (int i = 0; i < m_noItems; i++) { - int len = (int)SendMessage(GetHwnd(), LB_GETTEXT, i, (LPARAM)buf); - buf[len] = 0; + wxString str = GetString(i); SIZE extentXY; - ::GetTextExtentPoint(dc, buf, len, &extentXY); + ::GetTextExtentPoint(dc, str.c_str(), str.length(), &extentXY); int extentX = (int)(extentXY.cx + lpTextMetric.tmAveCharWidth); if (extentX > largestExtent) largestExtent = extentX; @@ -690,6 +683,9 @@ wxSize wxListBox::DoGetBestSize() const wListbox += 3*cx; + // Add room for the scrollbar + wListbox += wxSystemSettings::GetMetric(wxSYS_VSCROLL_X); + // don't make the listbox too tall (limit height to 10 items) but don't // make it too small neither int hListbox = EDIT_HEIGHT_FROM_CHAR_HEIGHT(cy)* @@ -735,7 +731,7 @@ bool wxListBox::MSWCommand(WXUINT param, WXWORD WXUNUSED(id)) event.SetExtraLong( HasMultipleSelection() ? IsSelected(n) : true ); } - event.m_commandInt = n; + event.SetInt(n); return GetEventHandler()->ProcessEvent(event); }