]> git.saurik.com Git - wxWidgets.git/commitdiff
don't use the client data for storing wxOwnerDrawn in wxCheckListbox implementation...
authorVadim Zeitlin <vadim@wxwidgets.org>
Thu, 25 Dec 2008 13:10:55 +0000 (13:10 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Thu, 25 Dec 2008 13:10:55 +0000 (13:10 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@57543 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

docs/changes.txt
include/wx/os2/checklst.h
interface/wx/checklst.h
src/msw/listbox.cpp
src/os2/checklst.cpp
src/os2/listbox.cpp

index 45835577772c07fd9c0bd4aff326a4c4a185f19e..f08a7c08c3ae56cba3ba4f55638a0acf367634de 100644 (file)
@@ -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).
index 4ead4b063a48a1efc208846634a106632f4c7de8..3c8773e99dd21b88fd6532eed81cda89d20ebe52 100644 (file)
@@ -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
     //
index 14d726d9c74f4e142481c64f6e4705a2e4f71f2d..40901ece48be6ac6c0730b35ae235bb13fd1934e 100644 (file)
     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
index 1c7c0b5785d4f741040d5dc3b44a64d8574acd81..82b06b14324c1d5492b20ef4d2f8d8ebf1d54601 100644 (file)
@@ -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);
index bda47bb7d17cd1cdd63019974cf65bb4fa86d951..f0a3ac723bc88e2b18527d57b4a673e2849e5885 100644 (file)
@@ -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++)
index e45ad8414b5978d4ab143a7745ee8c388a58be17..688ccfbf516a66c67684e50db2193c00155e6344 100644 (file)
@@ -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();