X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/8228b8932abaedadbf9568bb3a1eef3ae25fb2a3..0a4090e635a3765e62181ecf039914c2c27df63c:/src/msw/wince/checklst.cpp diff --git a/src/msw/wince/checklst.cpp b/src/msw/wince/checklst.cpp index 0c4a31c527..334f86fd51 100644 --- a/src/msw/wince/checklst.cpp +++ b/src/msw/wince/checklst.cpp @@ -21,18 +21,16 @@ #include "wx/wxprec.h" #ifdef __BORLANDC__ -#pragma hdrstop + #pragma hdrstop #endif #if wxUSE_CHECKLISTBOX -#ifndef WX_PRECOMP -#endif - #include "wx/checklst.h" -// include "properly" -#include "wx/msw/wrapcctl.h" +#ifndef WX_PRECOMP + #include "wx/msw/wrapcctl.h" // include "properly" +#endif // ============================================================================ // implementation @@ -118,7 +116,7 @@ bool wxCheckListBox::Create(wxWindow *parent, wxWindowID id, m_itemsClientData.SetCount(n); // now we can compute our best size correctly, so do it if necessary - SetBestSize(size); + SetInitialSize(size); return true; } @@ -154,7 +152,7 @@ void wxCheckListBox::OnSize(wxSizeEvent& event) // misc overloaded methods // ----------------------- -void wxCheckListBox::Delete(int n) +void wxCheckListBox::DoDeleteOneItem(unsigned int n) { wxCHECK_RET( IsValid( n ), _T("invalid index in wxCheckListBox::Delete") ); @@ -168,7 +166,7 @@ void wxCheckListBox::Delete(int n) // check items // ----------- -bool wxCheckListBox::IsChecked(size_t uiIndex) const +bool wxCheckListBox::IsChecked(unsigned int uiIndex) const { wxCHECK_MSG( IsValid( uiIndex ), false, _T("invalid index in wxCheckListBox::IsChecked") ); @@ -176,7 +174,7 @@ bool wxCheckListBox::IsChecked(size_t uiIndex) const return (ListView_GetCheckState(((HWND)GetHWND()), uiIndex) != 0); } -void wxCheckListBox::Check(size_t uiIndex, bool bCheck) +void wxCheckListBox::Check(unsigned int uiIndex, bool bCheck) { wxCHECK_RET( IsValid( uiIndex ), _T("invalid index in wxCheckListBox::Check") ); @@ -187,31 +185,28 @@ void wxCheckListBox::Check(size_t uiIndex, bool bCheck) // interface derived from wxListBox and lower classes // -------------------------------------------------- -void wxCheckListBox::Clear() +void wxCheckListBox::DoClear() { - int n = (int)GetCount(); + 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()") ); } -size_t wxCheckListBox::GetCount() const +unsigned int wxCheckListBox::GetCount() const { - return (size_t)ListView_GetItemCount( (HWND)GetHWND() ); + return (unsigned int)ListView_GetItemCount( (HWND)GetHWND() ); } int wxCheckListBox::GetSelection() const { int i; - for (i = 0; (size_t)i < GetCount(); i++) + for (i = 0; (unsigned int)i < GetCount(); i++) { int selState = ListView_GetItemState(GetHwnd(), i, LVIS_SELECTED); if (selState == LVIS_SELECTED) @@ -224,7 +219,7 @@ int wxCheckListBox::GetSelection() const int wxCheckListBox::GetSelections(wxArrayInt& aSelections) const { int i; - for (i = 0; (size_t)i < GetCount(); i++) + for (i = 0; (unsigned int)i < GetCount(); i++) { int selState = ListView_GetItemState(GetHwnd(), i, LVIS_SELECTED); if (selState == LVIS_SELECTED) @@ -234,7 +229,7 @@ int wxCheckListBox::GetSelections(wxArrayInt& aSelections) const return aSelections.GetCount(); } -wxString wxCheckListBox::GetString(int n) const +wxString wxCheckListBox::GetString(unsigned int n) const { const int bufSize = 513; wxChar buf[bufSize]; @@ -250,7 +245,7 @@ bool wxCheckListBox::IsSelected(int n) const return (selState == LVIS_SELECTED); } -void wxCheckListBox::SetString(int n, const wxString& s) +void wxCheckListBox::SetString(unsigned int n, const wxString& s) { wxCHECK_RET( IsValid( n ), _T("invalid index in wxCheckListBox::SetString") ); @@ -260,44 +255,35 @@ void wxCheckListBox::SetString(int n, const wxString& s) 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(int n) const +void* wxCheckListBox::DoGetItemClientData(unsigned int n) const { return m_itemsClientData.Item(n); } -wxClientData* wxCheckListBox::DoGetItemClientObject(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, int pos) -{ - wxCHECK_RET( IsValidInsert( pos ), - wxT("invalid index in wxListBox::InsertItems") ); + ListView_SetItemCount( GetHwnd(), GetCount() + count ); - for( size_t 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) @@ -311,28 +297,11 @@ void wxCheckListBox::DoSetFirstItem(int n) ListView_Scroll( (HWND)GetHWND(), 0, ppt.y ); } -void wxCheckListBox::DoSetItemClientData(int n, void* clientData) +void wxCheckListBox::DoSetItemClientData(unsigned int n, void* clientData) { m_itemsClientData.Item(n) = clientData; } -void wxCheckListBox::DoSetItemClientObject(int n, wxClientData* clientData) -{ - DoSetItemClientData(n, clientData); -} - -void wxCheckListBox::DoSetItems(const wxArrayString& items, void **clientData) -{ - ListView_SetItemCount( GetHwnd(), GetCount() + items.GetCount() ); - - for( size_t 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);