// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
-#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
- #pragma implementation "listbox.h"
-#endif
-
// For compilers that support precompilation, includes "wx.h".
#include "wx/wxprec.h"
m_noItems--;
SetHorizontalExtent(wxEmptyString);
+
+ InvalidateBestSize();
}
int wxListBox::DoAppend(const wxString& item)
{
- InvalidateBestSize();
-
int index = ListBox_AddString(GetHwnd(), item);
m_noItems++;
SetHorizontalExtent(item);
+ InvalidateBestSize();
return index;
}
// show the listbox back if we hid it
ShowWindow(GetHwnd(), SW_SHOW);
}
+
+ InvalidateBestSize();
}
-int wxListBox::FindString(const wxString& s) const
+int wxListBox::FindString(const wxString& s, bool bCase) const
{
- int pos = ListBox_FindStringExact(GetHwnd(), (WPARAM)-1, s);
+ // back to base class search for not native search type
+ if (bCase)
+ return wxItemContainerImmutable::FindString( s, bCase );
+
+ int pos = ListBox_FindStringExact(GetHwnd(), -1, s);
if (pos == LB_ERR)
return wxNOT_FOUND;
else
m_noItems = 0;
SetHorizontalExtent();
+
+ InvalidateBestSize();
}
void wxListBox::Free()
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++ )
{
m_noItems += nItems;
SetHorizontalExtent();
+
+ InvalidateBestSize();
}
void wxListBox::SetString(int N, const wxString& s)
// we may have lost the selection
if ( wasSelected )
Select(N);
+
+ InvalidateBestSize();
}
int wxListBox::GetCount() const
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)
{
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;
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;
}
// ----------------------------------------------------------------------------
HDC hdc = CreateIC(wxT("DISPLAY"), NULL, NULL, 0);
#endif
- wxDC dc;
- dc.SetHDC((WXHDC)hdc);
- dc.SetFont(GetFont());
-
- pStruct->itemHeight = dc.GetCharHeight() + 2*OWNER_DRAWN_LISTBOX_EXTRA_SPACE;
- pStruct->itemWidth = dc.GetCharWidth();
+ {
+ wxDCTemp dc((WXHDC)hdc);
+ dc.SetFont(GetFont());
- dc.SetHDC(0);
+ pStruct->itemHeight = dc.GetCharHeight() + 2*OWNER_DRAWN_LISTBOX_EXTRA_SPACE;
+ pStruct->itemWidth = dc.GetCharWidth();
+ }
+#ifdef __WXWINCE__
+ ReleaseDC(NULL, hdc);
+#else
DeleteDC(hdc);
+#endif
return true;
}