#include "wx/wxprec.h"
#ifdef __BORLANDC__
-#pragma hdrstop
+ #pragma hdrstop
#endif
#if wxUSE_CHECKLISTBOX
-#ifndef WX_PRECOMP
-#endif
-
#include "wx/checklst.h"
-// include <commctrl.h> "properly"
-#include "wx/msw/wrapcctl.h"
+#ifndef WX_PRECOMP
+ #include "wx/msw/wrapcctl.h" // include <commctrl.h> "properly"
+#endif
// ============================================================================
// implementation
m_itemsClientData.SetCount(n);
// now we can compute our best size correctly, so do it if necessary
- SetBestSize(size);
+ SetInitialSize(size);
return true;
}
// misc overloaded methods
// -----------------------
-void wxCheckListBox::Delete(unsigned int n)
+void wxCheckListBox::DoDeleteOneItem(unsigned int n)
{
wxCHECK_RET( IsValid( n ), _T("invalid index in wxCheckListBox::Delete") );
// interface derived from wxListBox and lower classes
// --------------------------------------------------
-void wxCheckListBox::Clear()
+void wxCheckListBox::DoClear()
{
unsigned int n = GetCount();
while ( n > 0 )
{
n--;
- Delete(n);
+ DoDeleteOneItem(n);
}
- m_itemsClientData.Clear();
-
- wxCHECK_RET( n == GetCount(),
- _T("broken wxCheckListBox::Clear()") );
+ wxASSERT_MSG( IsEmpty(), _T("logic error in DoClear()") );
}
unsigned int wxCheckListBox::GetCount() const
delete [] buf;
}
-int wxCheckListBox::DoAppend(const wxString& item)
-{
- int n = (int)GetCount();
- LVITEM newItem;
- wxZeroMemory(newItem);
- newItem.iItem = n;
- int ret = ListView_InsertItem( (HWND)GetHWND(), & newItem );
- wxCHECK_MSG( n == ret , -1, _T("Item not added") );
- SetString( ret , item );
- m_itemsClientData.Insert(NULL, ret);
- return ret;
-}
-
void* wxCheckListBox::DoGetItemClientData(unsigned int n) const
{
return m_itemsClientData.Item(n);
}
-wxClientData* wxCheckListBox::DoGetItemClientObject(unsigned int n) const
+int wxCheckListBox::DoInsertItems(const wxArrayStringsAdapter & items,
+ unsigned int pos,
+ void **clientData, wxClientDataType type)
{
- return (wxClientData *)DoGetItemClientData(n);
-}
+ const unsigned int count = items.GetCount();
-void wxCheckListBox::DoInsertItems(const wxArrayString& items, unsigned int pos)
-{
- wxCHECK_RET( IsValidInsert( pos ),
- wxT("invalid index in wxListBox::InsertItems") );
+ ListView_SetItemCount( GetHwnd(), GetCount() + count );
- for( unsigned int i = 0; i < items.GetCount(); i++ )
+ int n = wxNOT_FOUND;
+
+ for( unsigned int i = 0; i < count; i++ )
{
LVITEM newItem;
wxZeroMemory(newItem);
- newItem.iItem = i+pos;
- int ret = ListView_InsertItem( (HWND)GetHWND(), & newItem );
- wxASSERT_MSG( int(i+pos) == ret , _T("Item not added") );
- SetString( ret , items[i] );
- m_itemsClientData.Insert(NULL, ret);
+ newItem.iItem = pos + i;
+ n = ListView_InsertItem( (HWND)GetHWND(), & newItem );
+ wxCHECK_MSG( n != -1, -1, _T("Item not added") );
+ SetString( n, items[i] );
+ m_itemsClientData.Insert(NULL, n);
+
+ AssignNewItemClientData(n, clientData, i, type);
}
+
+ return n;
}
void wxCheckListBox::DoSetFirstItem(int n)
m_itemsClientData.Item(n) = clientData;
}
-void wxCheckListBox::DoSetItemClientObject(unsigned int n, wxClientData* clientData)
-{
- DoSetItemClientData(n, clientData);
-}
-
-void wxCheckListBox::DoSetItems(const wxArrayString& items, void **clientData)
-{
- ListView_SetItemCount( GetHwnd(), GetCount() + items.GetCount() );
-
- for( unsigned int i = 0; i < items.GetCount(); i++ )
- {
- int pos = Append(items[i]);
- if( pos >= 0 && clientData )
- DoSetItemClientData(pos, clientData[i]);
- }
-}
-
void wxCheckListBox::DoSetSelection(int n, bool select)
{
ListView_SetItemState(GetHwnd(), n, select ? LVIS_SELECTED : 0, LVIS_SELECTED);