X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/665b71b17c8eb8f2586a8c84f8d9cf0d8559bf35..9af08eb82665ca5d28b28af50f345396a3cff717:/src/msw/listbox.cpp diff --git a/src/msw/listbox.cpp b/src/msw/listbox.cpp index 35d90639e5..7b7fcc8d18 100644 --- a/src/msw/listbox.cpp +++ b/src/msw/listbox.cpp @@ -127,7 +127,7 @@ public: wxListBoxItem(const wxString& str = wxEmptyString); }; -wxListBoxItem::wxListBoxItem(const wxString& str) : wxOwnerDrawn(str, FALSE) +wxListBoxItem::wxListBoxItem(const wxString& str) : wxOwnerDrawn(str, false) { // no bitmaps/checkmarks SetMarginWidth(0); @@ -287,6 +287,8 @@ void wxListBox::Delete(int N) int wxListBox::DoAppend(const wxString& item) { + InvalidateBestSize(); + int index = ListBox_AddString(GetHwnd(), item); m_noItems++; @@ -406,10 +408,10 @@ void wxListBox::SetSelection(int N, bool select) bool wxListBox::IsSelected(int N) const { - wxCHECK_MSG( N >= 0 && N < m_noItems, FALSE, + wxCHECK_MSG( N >= 0 && N < m_noItems, false, wxT("invalid index in wxListBox::Selected") ); - return SendMessage(GetHwnd(), LB_GETSEL, N, 0) == 0 ? FALSE : TRUE; + return SendMessage(GetHwnd(), LB_GETSEL, N, 0) == 0 ? false : true; } wxClientData* wxListBox::DoGetItemClientObject(int n) const @@ -511,7 +513,7 @@ wxString wxListBox::GetString(int N) const // +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; } @@ -522,6 +524,8 @@ 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++ ) { @@ -612,7 +616,7 @@ 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()); @@ -682,7 +686,7 @@ wxSize wxListBox::DoGetBestSize() const // the listbox should be slightly larger than the widest string int cx, cy; - wxGetCharSize(GetHWND(), &cx, &cy, &GetFont()); + wxGetCharSize(GetHWND(), &cx, &cy, GetFont()); wListbox += 3*cx; @@ -712,7 +716,7 @@ bool wxListBox::MSWCommand(WXUINT param, WXWORD WXUNUSED(id)) else { // some event we're not interested in - return FALSE; + return false; } wxCommandEvent event(evtType, m_windowId); @@ -728,7 +732,7 @@ bool wxListBox::MSWCommand(WXUINT param, WXWORD WXUNUSED(id)) event.SetClientData( GetClientData(n) ); event.SetString( GetString(n) ); - event.SetExtraLong( HasMultipleSelection() ? IsSelected(n) : TRUE ); + event.SetExtraLong( HasMultipleSelection() ? IsSelected(n) : true ); } event.m_commandInt = n; @@ -757,7 +761,7 @@ bool wxListBox::MSWCommand(WXUINT param, WXWORD WXUNUSED(id)) bool wxListBox::MSWOnMeasure(WXMEASUREITEMSTRUCT *item) { // only owner-drawn control should receive this message - wxCHECK( ((m_windowStyle & wxLB_OWNERDRAW) == wxLB_OWNERDRAW), FALSE ); + wxCHECK( ((m_windowStyle & wxLB_OWNERDRAW) == wxLB_OWNERDRAW), false ); MEASUREITEMSTRUCT *pStruct = (MEASUREITEMSTRUCT *)item; @@ -769,7 +773,7 @@ bool wxListBox::MSWOnMeasure(WXMEASUREITEMSTRUCT *item) wxDC dc; dc.SetHDC((WXHDC)hdc); - dc.SetFont(wxSystemSettings::GetFont(wxSYS_ANSI_VAR_FONT)); + dc.SetFont(GetFont()); pStruct->itemHeight = dc.GetCharHeight() + 2*OWNER_DRAWN_LISTBOX_EXTRA_SPACE; pStruct->itemWidth = dc.GetCharWidth(); @@ -778,31 +782,32 @@ bool wxListBox::MSWOnMeasure(WXMEASUREITEMSTRUCT *item) DeleteDC(hdc); - return TRUE; + return true; } // forward the message to the appropriate item bool wxListBox::MSWOnDraw(WXDRAWITEMSTRUCT *item) { // only owner-drawn control should receive this message - wxCHECK( ((m_windowStyle & wxLB_OWNERDRAW) == wxLB_OWNERDRAW), FALSE ); + wxCHECK( ((m_windowStyle & wxLB_OWNERDRAW) == wxLB_OWNERDRAW), false ); DRAWITEMSTRUCT *pStruct = (DRAWITEMSTRUCT *)item; UINT itemID = pStruct->itemID; // the item may be -1 for an empty listbox if ( itemID == (UINT)-1 ) - return FALSE; + return false; long data = ListBox_GetItemData(GetHwnd(), pStruct->itemID); - wxCHECK( data && (data != LB_ERR), FALSE ); + wxCHECK( data && (data != LB_ERR), false ); wxListBoxItem *pItem = (wxListBoxItem *)data; wxDCTemp dc((WXHDC)pStruct->hDC); - wxRect rect(wxPoint(pStruct->rcItem.left, pStruct->rcItem.top), - wxPoint(pStruct->rcItem.right, pStruct->rcItem.bottom)); + wxPoint pt1(pStruct->rcItem.left, pStruct->rcItem.top); + wxPoint pt2(pStruct->rcItem.right, pStruct->rcItem.bottom); + wxRect rect(pt1, pt2); return pItem->OnDrawItem(dc, rect, (wxOwnerDrawn::wxODAction)pStruct->itemAction,