diff --git a/docs/changes.txt b/docs/changes.txt index 4583557777..f08a7c08c3 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -460,6 +460,7 @@ wxMSW: - Fixed infinite loop in wxThread::Wait() in console applications. - Return the restored window size from GetSize() when window is minimized. - wxCheckListBox now looks more native, especially under XP (Marcin Malich). +- wxCheckListBox now also supports use of client data (Marcin Malich). - Allow tooltips longer than 64 (up to 128) characters in wxTaskBarIcon - Fix centering wxFileDialog and allow positioning it. - Allow centering wxMessageDialog on its parent window (troelsk). diff --git a/include/wx/os2/checklst.h b/include/wx/os2/checklst.h index 4ead4b063a..3c8773e99d 100644 --- a/include/wx/os2/checklst.h +++ b/include/wx/os2/checklst.h @@ -72,10 +72,6 @@ protected: virtual wxOwnerDrawn* CreateItem(size_t n); virtual long OS2OnMeasure(WXMEASUREITEMSTRUCT* pItem); - virtual int DoInsertItems(const wxArrayStringsAdapter & items, - unsigned int pos, - void **clientData, wxClientDataType type); - // // Pressing space or clicking the check box toggles the item // diff --git a/interface/wx/checklst.h b/interface/wx/checklst.h index 14d726d9c7..40901ece48 100644 --- a/interface/wx/checklst.h +++ b/interface/wx/checklst.h @@ -15,11 +15,6 @@ When using this class under Windows wxWidgets must be compiled with wxUSE_OWNER_DRAWN set to 1. - Only the new functions for this class are documented; see also wxListBox. - - Please note that wxCheckListBox uses client data in its implementation, - and therefore this is not available to the application. - @beginEventTable{wxCommandEvent} @event{EVT_CHECKLISTBOX(id, func)} Process a wxEVT_COMMAND_CHECKLISTBOX_TOGGLED event, when an item in diff --git a/src/msw/listbox.cpp b/src/msw/listbox.cpp index 1c7c0b5785..82b06b1432 100644 --- a/src/msw/listbox.cpp +++ b/src/msw/listbox.cpp @@ -356,15 +356,6 @@ void wxListBox::DoSetItemClientData(unsigned int n, void *clientData) wxCHECK_RET( IsValid(n), wxT("invalid index in wxListBox::SetClientData") ); -#if wxUSE_OWNER_DRAWN - if ( m_windowStyle & wxLB_OWNERDRAW ) - { - // client data must be pointer to wxOwnerDrawn, otherwise we would crash - // in OnMeasure/OnDraw. - wxFAIL_MSG(wxT("Can't use client data with owner-drawn listboxes")); - } -#endif // wxUSE_OWNER_DRAWN - if ( ListBox_SetItemData(GetHwnd(), n, clientData) == LB_ERR ) wxLogDebug(wxT("LB_SETITEMDATA failed")); } @@ -474,8 +465,6 @@ int wxListBox::DoInsertItems(const wxArrayStringsAdapter & items, pNewItem->SetName(items[i]); pNewItem->SetFont(GetFont()); m_aItems.Insert(pNewItem, n); - - ListBox_SetItemData(GetHwnd(), n, pNewItem); } #endif // wxUSE_OWNER_DRAWN AssignNewItemClientData(n, clientData, i, type); @@ -533,9 +522,6 @@ void wxListBox::SetString(unsigned int n, const wxString& s) { // update item's text m_aItems[n]->SetName(s); - - // reassign the item's data - ListBox_SetItemData(GetHwnd(), n, m_aItems[n]); } #endif //USE_OWNER_DRAWN @@ -747,17 +733,12 @@ bool wxListBox::MSWOnDraw(WXDRAWITEMSTRUCT *item) wxCHECK( ((m_windowStyle & wxLB_OWNERDRAW) == wxLB_OWNERDRAW), false ); DRAWITEMSTRUCT *pStruct = (DRAWITEMSTRUCT *)item; - UINT itemID = pStruct->itemID; // the item may be -1 for an empty listbox - if ( itemID == (UINT)-1 ) + if ( pStruct->itemID == (UINT)-1 ) return false; - LRESULT data = ListBox_GetItemData(GetHwnd(), pStruct->itemID); - - wxCHECK( data && (data != LB_ERR), false ); - - wxListBoxItem *pItem = (wxListBoxItem *)data; + wxListBoxItem *pItem = (wxListBoxItem *)m_aItems[pStruct->itemID]; wxDCTemp dc((WXHDC)pStruct->hDC); wxPoint pt1(pStruct->rcItem.left, pStruct->rcItem.top); diff --git a/src/os2/checklst.cpp b/src/os2/checklst.cpp index bda47bb7d1..f0a3ac723b 100644 --- a/src/os2/checklst.cpp +++ b/src/os2/checklst.cpp @@ -287,29 +287,6 @@ void wxCheckListBox::Delete(unsigned int n) m_aItems.RemoveAt(n); } // end of wxCheckListBox::Delete -int wxCheckListBox::DoInsertItems(const wxArrayStringsAdapter& items, - unsigned int pos, - void **clientData, - wxClientDataType type) -{ - // pos is validated in wxListBox - int result = wxListBox::DoInsertItems( items, pos, clientData, type ); - unsigned int n = items.GetCount(); - for (unsigned int i = 0; i < n; i++) - { - wxOwnerDrawn* pNewItem = CreateItem((size_t)(pos + i)); - - pNewItem->SetName(items[i]); - m_aItems.Insert(pNewItem, (size_t)(pos + i)); - ::WinSendMsg( (HWND)GetHWND(), - LM_SETITEMHANDLE, - (MPARAM)(i + pos), - MPFROMP(pNewItem) - ); - } - return result; -} // end of wxCheckListBox::DoInsertItems - bool wxCheckListBox::SetFont ( const wxFont& rFont ) { for (unsigned int i = 0; i < m_aItems.GetCount(); i++) diff --git a/src/os2/listbox.cpp b/src/os2/listbox.cpp index e45ad8414b..688ccfbf51 100644 --- a/src/os2/listbox.cpp +++ b/src/os2/listbox.cpp @@ -308,7 +308,6 @@ int wxListBox::DoInsertItems(const wxArrayStringsAdapter & items, pNewItem->SetName(items[i]); m_aItems.Insert(pNewItem, n); - ::WinSendMsg(GetHwnd(), LM_SETITEMHANDLE, (MPARAM)n, MPFROMP(pNewItem)); pNewItem->SetFont(GetFont()); } #endif @@ -385,17 +384,6 @@ void wxListBox::DoSetItemClientData(unsigned int n, void* pClientData) wxCHECK_RET( IsValid(n), wxT("invalid index in wxListBox::SetClientData") ); -#if wxUSE_OWNER_DRAWN - if ( m_windowStyle & wxLB_OWNERDRAW ) - { - // - // Client data must be pointer to wxOwnerDrawn, otherwise we would crash - // in OnMeasure/OnDraw. - // - wxFAIL_MSG(wxT("Can't use client data with owner-drawn listboxes")); - } -#endif // wxUSE_OWNER_DRAWN - ::WinSendMsg(GetHwnd(), LM_SETITEMHANDLE, MPFROMLONG(n), MPFROMP(pClientData)); } // end of wxListBox::DoSetItemClientData @@ -714,7 +702,6 @@ bool wxListBox::OS2OnDraw ( ) { POWNERITEM pDrawStruct = (POWNERITEM)pItem; - LONG lItemID = pDrawStruct->idItem; int eAction = 0; int eStatus = 0; @@ -727,17 +714,10 @@ bool wxListBox::OS2OnDraw ( // // The item may be -1 for an empty listbox // - if (lItemID == -1L) + if (pDrawStruct->idItem == -1L) return false; - wxListBoxItem* pData = (wxListBoxItem*)PVOIDFROMMR( ::WinSendMsg( GetHwnd() - ,LM_QUERYITEMHANDLE - ,MPFROMLONG(pDrawStruct->idItem) - ,(MPARAM)0 - ) - ); - - wxCHECK(pData, false ); + wxListBoxItem* pData = (wxListBoxItem*)m_aItems[pDrawStruct->idItem]; wxClientDC vDc(this); wxPMDCImpl *impl = (wxPMDCImpl*) vDc.GetImpl();