X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/debe6624c1e9d4bf3243381153d1e173c849bcd8..11bc0805dec30cdc07c17cc13d075520efd4e17a:/src/msw/listbox.cpp diff --git a/src/msw/listbox.cpp b/src/msw/listbox.cpp index 0ffc6ec3c8..f15ecf02e9 100644 --- a/src/msw/listbox.cpp +++ b/src/msw/listbox.cpp @@ -67,7 +67,7 @@ wxListBoxItem::wxListBoxItem(const wxString& str) : wxOwnerDrawn(str, FALSE) SetMarginWidth(0); } -wxOwnerDrawn *wxListBox::CreateItem(uint n) +wxOwnerDrawn *wxListBox::CreateItem(size_t n) { return new wxListBoxItem(); } @@ -224,14 +224,14 @@ bool wxListBox::Create(wxWindow *parent, wxWindowID id, // Subclass again to catch messages SubclassWin((WXHWND)wx_list); - uint ui; - for (ui = 0; ui < (uint)n; ui++) { + size_t ui; + for (ui = 0; ui < (size_t)n; ui++) { SendMessage(wx_list, LB_ADDSTRING, 0, (LPARAM)(const char *)choices[ui]); } #if USE_OWNER_DRAWN if ( m_windowStyle & wxLB_OWNERDRAW ) { - for (ui = 0; ui < (uint)n; ui++) { + for (ui = 0; ui < (size_t)n; ui++) { // create new item which will process WM_{DRAW|MEASURE}ITEM messages wxOwnerDrawn *pNewItem = CreateItem(ui); pNewItem->SetName(choices[ui]); @@ -256,7 +256,7 @@ bool wxListBox::Create(wxWindow *parent, wxWindowID id, wxListBox::~wxListBox(void) { #if USE_OWNER_DRAWN - uint uiCount = m_aItems.Count(); + size_t uiCount = m_aItems.Count(); while ( uiCount-- != 0 ) { delete m_aItems[uiCount]; } @@ -340,14 +340,14 @@ void wxListBox::Set(int n, const wxString *choices, char** clientData) #if USE_OWNER_DRAWN if ( m_windowStyle & wxLB_OWNERDRAW ) { // first delete old items - uint ui = m_aItems.Count(); + size_t ui = m_aItems.Count(); while ( ui-- != 0 ) { delete m_aItems[ui]; } m_aItems.Empty(); // then create new ones - for (ui = 0; ui < (uint)n; ui++) { + for (ui = 0; ui < (size_t)n; ui++) { wxOwnerDrawn *pNewItem = CreateItem(ui); pNewItem->SetName(choices[ui]); m_aItems.Add(pNewItem); @@ -484,6 +484,8 @@ void wxListBox::SetSize(int x, int y, int width, int height, int sizeFlags) if (y == -1 || (sizeFlags & wxSIZE_ALLOW_MINUS_ONE)) y1 = currentY; + AdjustForParentClientOrigin(x1, y1, sizeFlags); + // If we're prepared to use the existing size, then... if (width == -1 && height == -1 && ((sizeFlags & wxSIZE_AUTO) != wxSIZE_AUTO)) { @@ -539,7 +541,7 @@ void wxListBox::SetHorizontalExtent(const wxString& s) HDC dc = GetWindowDC(hwnd); HFONT oldFont = 0; if (GetFont() && GetFont()->GetResourceHandle()) - oldFont = ::SelectObject(dc, (HFONT) GetFont()->GetResourceHandle()); + oldFont = (HFONT) ::SelectObject(dc, (HFONT) GetFont()->GetResourceHandle()); GetTextMetrics(dc, &lpTextMetric); SIZE extentXY; @@ -560,7 +562,7 @@ void wxListBox::SetHorizontalExtent(const wxString& s) HDC dc = GetWindowDC(hwnd); HFONT oldFont = 0; if (GetFont() && GetFont()->GetResourceHandle()) - oldFont = ::SelectObject(dc, (HFONT) GetFont()->GetResourceHandle()); + oldFont = (HFONT) ::SelectObject(dc, (HFONT) GetFont()->GetResourceHandle()); GetTextMetrics(dc, &lpTextMetric); int i; @@ -593,9 +595,9 @@ wxListBox::InsertItems(int nItems, const wxString items[], int pos) #if USE_OWNER_DRAWN if ( m_windowStyle & wxLB_OWNERDRAW ) { for ( i = 0; i < nItems; i++ ) { - wxOwnerDrawn *pNewItem = CreateItem((uint)(pos + i)); + wxOwnerDrawn *pNewItem = CreateItem((size_t)(pos + i)); pNewItem->SetName(items[i]); - m_aItems.Insert(pNewItem, (uint)(pos + i)); + m_aItems.Insert(pNewItem, (size_t)(pos + i)); ListBox_SetItemData(hwnd, i, pNewItem); } } @@ -606,7 +608,9 @@ wxListBox::InsertItems(int nItems, const wxString items[], int pos) void wxListBox::SetString(int N, const wxString& s) { - int sel = GetSelection(); + int sel = -1; + if (!(m_windowStyle & wxLB_MULTIPLE) && !(m_windowStyle & wxLB_EXTENDED)) + sel = GetSelection(); char *oldData = (char *)wxListBox::GetClientData(N);