X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/aa61d3525370a9b9fa8c797d9b7f89d96994db5f..12bb29f5432174ecbd65549bda832d70d34a98ae:/src/msw/wince/checklst.cpp diff --git a/src/msw/wince/checklst.cpp b/src/msw/wince/checklst.cpp index b0044c8443..067969cbe1 100644 --- a/src/msw/wince/checklst.cpp +++ b/src/msw/wince/checklst.cpp @@ -21,25 +21,21 @@ #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 // ============================================================================ -IMPLEMENT_DYNAMIC_CLASS(wxCheckListBox, wxControl) - // ---------------------------------------------------------------------------- // implementation of wxCheckListBox class // ---------------------------------------------------------------------------- @@ -118,7 +114,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,13 +150,13 @@ void wxCheckListBox::OnSize(wxSizeEvent& event) // 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") ); + wxCHECK_RET( IsValid( n ), wxT("invalid index in wxCheckListBox::Delete") ); if ( !ListView_DeleteItem(GetHwnd(), n) ) { - wxLogLastError(_T("ListView_DeleteItem")); + wxLogLastError(wxT("ListView_DeleteItem")); } m_itemsClientData.RemoveAt(n); } @@ -171,7 +167,7 @@ void wxCheckListBox::Delete(unsigned int n) bool wxCheckListBox::IsChecked(unsigned int uiIndex) const { wxCHECK_MSG( IsValid( uiIndex ), false, - _T("invalid index in wxCheckListBox::IsChecked") ); + wxT("invalid index in wxCheckListBox::IsChecked") ); return (ListView_GetCheckState(((HWND)GetHWND()), uiIndex) != 0); } @@ -179,7 +175,7 @@ bool wxCheckListBox::IsChecked(unsigned int uiIndex) const void wxCheckListBox::Check(unsigned int uiIndex, bool bCheck) { wxCHECK_RET( IsValid( uiIndex ), - _T("invalid index in wxCheckListBox::Check") ); + wxT("invalid index in wxCheckListBox::Check") ); ListView_SetCheckState(((HWND)GetHWND()), uiIndex, bCheck) } @@ -187,20 +183,17 @@ void wxCheckListBox::Check(unsigned int uiIndex, bool bCheck) // 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(), wxT("logic error in DoClear()") ); } unsigned int wxCheckListBox::GetCount() const @@ -239,7 +232,7 @@ wxString wxCheckListBox::GetString(unsigned int n) const const int bufSize = 513; wxChar buf[bufSize]; ListView_GetItemText( (HWND)GetHWND(), n, 0, buf, bufSize - 1 ); - buf[bufSize-1] = _T('\0'); + buf[bufSize-1] = wxT('\0'); wxString str(buf); return str; } @@ -253,51 +246,42 @@ bool wxCheckListBox::IsSelected(int n) const void wxCheckListBox::SetString(unsigned int n, const wxString& s) { wxCHECK_RET( IsValid( n ), - _T("invalid index in wxCheckListBox::SetString") ); + wxT("invalid index in wxCheckListBox::SetString") ); wxChar *buf = new wxChar[s.length()+1]; wxStrcpy(buf, s.c_str()); ListView_SetItemText( (HWND)GetHWND(), n, 0, buf ); 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, wxT("Item not added") ); + SetString( n, items[i] ); + m_itemsClientData.Insert(NULL, n); + + AssignNewItemClientData(n, clientData, i, type); } + + return n; } void wxCheckListBox::DoSetFirstItem(int n) @@ -306,7 +290,7 @@ void wxCheckListBox::DoSetFirstItem(int n) if(pos == n) return; POINT ppt; BOOL ret = ListView_GetItemPosition( (HWND)GetHWND(), n, &ppt ); - wxCHECK_RET( ret == TRUE, _T("Broken DoSetFirstItem") ); + wxCHECK_RET( ret == TRUE, wxT("Broken DoSetFirstItem") ); ListView_Scroll( (HWND)GetHWND(), 0, 0 ); ListView_Scroll( (HWND)GetHWND(), 0, ppt.y ); } @@ -316,23 +300,6 @@ void wxCheckListBox::DoSetItemClientData(unsigned int n, void* clientData) 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); @@ -376,14 +343,14 @@ bool wxCheckListBox::MSWOnNotify(int idCtrl, WXLPARAM lParam, WXLPARAM *result) // Check image changed if ((stOld & LVIS_STATEIMAGEMASK) != (stNew & LVIS_STATEIMAGEMASK)) { - event.SetEventType(wxEVT_COMMAND_CHECKLISTBOX_TOGGLED); + event.SetEventType(wxEVT_CHECKLISTBOX); event.SetInt(IsChecked(iItem)); (void) GetEventHandler()->ProcessEvent(event); } if ( (stNew & LVIS_SELECTED) != (stOld & LVIS_SELECTED) ) { - eventType = wxEVT_COMMAND_LISTBOX_SELECTED; + eventType = wxEVT_LISTBOX; event.SetExtraLong( (stNew & LVIS_SELECTED) != 0 ); // is a selection event.SetInt(iItem);