void wxListBox::DoSetFirstItem(int N)
{
- wxCHECK_RET( N >= 0 && N < m_noItems,
+ wxCHECK_RET( IsValid(N),
wxT("invalid index in wxListBox::SetFirstItem") );
SendMessage(GetHwnd(), LB_SETTOPINDEX, (WPARAM)N, (LPARAM)0);
void wxListBox::Delete(int N)
{
- wxCHECK_RET( N >= 0 && N < m_noItems,
+ wxCHECK_RET( IsValid(N),
wxT("invalid index in wxListBox::Delete") );
// for owner drawn objects, the data is used for storing wxOwnerDrawn
ListBox_ResetContent(GetHwnd());
m_noItems = choices.GetCount();
- int i;
+ size_t i;
for (i = 0; i < m_noItems; i++)
{
ListBox_AddString(GetHwnd(), choices[i]);
WX_CLEAR_ARRAY(m_aItems);
// then create new ones
- for ( size_t ui = 0; ui < (size_t)m_noItems; ui++ ) {
+ for ( size_t ui = 0; ui < m_noItems; ui++ ) {
wxOwnerDrawn *pNewItem = CreateLboxItem(ui);
pNewItem->SetName(choices[ui]);
m_aItems.Add(pNewItem);
#endif // wxUSE_OWNER_DRAWN
if ( HasClientObjectData() )
{
- for ( size_t n = 0; n < (size_t)m_noItems; n++ )
+ for ( size_t n = 0; n < m_noItems; n++ )
{
delete GetClientObject(n);
}
void wxListBox::DoSetSelection(int N, bool select)
{
- wxCHECK_RET( N == wxNOT_FOUND ||
- (N >= 0 && N < m_noItems),
+ wxCHECK_RET( N == wxNOT_FOUND || IsValid(N),
wxT("invalid index in wxListBox::SetSelection") );
if ( HasMultipleSelection() )
bool wxListBox::IsSelected(int N) const
{
- wxCHECK_MSG( N >= 0 && N < m_noItems, false,
+ wxCHECK_MSG( IsValid(N), false,
wxT("invalid index in wxListBox::Selected") );
return SendMessage(GetHwnd(), LB_GETSEL, N, 0) == 0 ? false : true;
void *wxListBox::DoGetItemClientData(int n) const
{
- wxCHECK_MSG( n >= 0 && n < m_noItems, NULL,
+ wxCHECK_MSG( IsValid(n), NULL,
wxT("invalid index in wxListBox::GetClientData") );
return (void *)SendMessage(GetHwnd(), LB_GETITEMDATA, n, 0);
void wxListBox::DoSetItemClientData(int n, void *clientData)
{
- wxCHECK_RET( n >= 0 && n < m_noItems,
+ wxCHECK_RET( IsValid(n),
wxT("invalid index in wxListBox::SetClientData") );
#if wxUSE_OWNER_DRAWN
// Find string for position
wxString wxListBox::GetString(int N) const
{
- wxCHECK_MSG( N >= 0 && N < m_noItems, wxEmptyString,
+ wxCHECK_MSG( IsValid(N), wxEmptyString,
wxT("invalid index in wxListBox::GetString") );
int len = ListBox_GetTextLen(GetHwnd(), N);
void
wxListBox::DoInsertItems(const wxArrayString& items, int pos)
{
- wxCHECK_RET( pos >= 0 && pos <= m_noItems,
+ wxCHECK_RET( IsValidInsert(pos),
wxT("invalid index in wxListBox::InsertItems") );
int nItems = items.GetCount();
InvalidateBestSize();
}
+int wxListBox::DoListHitTest(const wxPoint& point) const
+{
+ LRESULT lRes = ::SendMessage(GetHwnd(), LB_ITEMFROMPOINT,
+ 0L, MAKELONG(point.x, point.y));
+
+ // non zero high-order word means that this item is outside of the client
+ // area, IOW the point is outside of the listbox
+ return HIWORD(lRes) ? wxNOT_FOUND : lRes;
+}
+
void wxListBox::SetString(int N, const wxString& s)
{
- wxCHECK_RET( N >= 0 && N < m_noItems,
+ wxCHECK_RET( IsValid(N),
wxT("invalid index in wxListBox::SetString") );
// remember the state of the item
SendMessage(GetHwnd(), LB_DELETESTRING, N, 0);
int newN = N;
- if ( N == m_noItems - 1 )
+ if ( N == (int)(m_noItems - 1) )
newN = -1;
ListBox_InsertString(GetHwnd(), newN, s);
InvalidateBestSize();
}
-int wxListBox::GetCount() const
+size_t wxListBox::GetCount() const
{
return m_noItems;
}
GetTextMetrics(dc, &lpTextMetric);
SIZE extentXY;
- ::GetTextExtentPoint32(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)
GetTextMetrics(dc, &lpTextMetric);
- for (int i = 0; i < m_noItems; i++)
+ for (size_t i = 0; i < m_noItems; i++)
{
wxString str = GetString(i);
SIZE extentXY;
// find the widest string
int wLine;
int wListbox = 0;
- for ( int i = 0; i < m_noItems; i++ )
+ for ( size_t i = 0; i < m_noItems; i++ )
{
wxString str(GetString(i));
GetTextExtent(str, &wLine, NULL);