don't use the client data for storing wxOwnerDrawn in wxCheckListbox implementation as we already store them in internal array anyhow, this allows the user to use his own client data with wxCheckListbox (#10290)

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@57543 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2008-12-25 13:10:55 +00:00
parent 9f2968ad0b
commit e4de7a7759
6 changed files with 5 additions and 75 deletions

View File

@@ -460,6 +460,7 @@ wxMSW:
- Fixed infinite loop in wxThread::Wait() in console applications. - Fixed infinite loop in wxThread::Wait() in console applications.
- Return the restored window size from GetSize() when window is minimized. - Return the restored window size from GetSize() when window is minimized.
- wxCheckListBox now looks more native, especially under XP (Marcin Malich). - 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 - Allow tooltips longer than 64 (up to 128) characters in wxTaskBarIcon
- Fix centering wxFileDialog and allow positioning it. - Fix centering wxFileDialog and allow positioning it.
- Allow centering wxMessageDialog on its parent window (troelsk). - Allow centering wxMessageDialog on its parent window (troelsk).

View File

@@ -72,10 +72,6 @@ protected:
virtual wxOwnerDrawn* CreateItem(size_t n); virtual wxOwnerDrawn* CreateItem(size_t n);
virtual long OS2OnMeasure(WXMEASUREITEMSTRUCT* pItem); 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 // Pressing space or clicking the check box toggles the item
// //

View File

@@ -15,11 +15,6 @@
When using this class under Windows wxWidgets must be compiled with When using this class under Windows wxWidgets must be compiled with
wxUSE_OWNER_DRAWN set to 1. 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} @beginEventTable{wxCommandEvent}
@event{EVT_CHECKLISTBOX(id, func)} @event{EVT_CHECKLISTBOX(id, func)}
Process a wxEVT_COMMAND_CHECKLISTBOX_TOGGLED event, when an item in Process a wxEVT_COMMAND_CHECKLISTBOX_TOGGLED event, when an item in

View File

@@ -356,15 +356,6 @@ void wxListBox::DoSetItemClientData(unsigned int n, void *clientData)
wxCHECK_RET( IsValid(n), wxCHECK_RET( IsValid(n),
wxT("invalid index in wxListBox::SetClientData") ); 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 ) if ( ListBox_SetItemData(GetHwnd(), n, clientData) == LB_ERR )
wxLogDebug(wxT("LB_SETITEMDATA failed")); wxLogDebug(wxT("LB_SETITEMDATA failed"));
} }
@@ -474,8 +465,6 @@ int wxListBox::DoInsertItems(const wxArrayStringsAdapter & items,
pNewItem->SetName(items[i]); pNewItem->SetName(items[i]);
pNewItem->SetFont(GetFont()); pNewItem->SetFont(GetFont());
m_aItems.Insert(pNewItem, n); m_aItems.Insert(pNewItem, n);
ListBox_SetItemData(GetHwnd(), n, pNewItem);
} }
#endif // wxUSE_OWNER_DRAWN #endif // wxUSE_OWNER_DRAWN
AssignNewItemClientData(n, clientData, i, type); AssignNewItemClientData(n, clientData, i, type);
@@ -533,9 +522,6 @@ void wxListBox::SetString(unsigned int n, const wxString& s)
{ {
// update item's text // update item's text
m_aItems[n]->SetName(s); m_aItems[n]->SetName(s);
// reassign the item's data
ListBox_SetItemData(GetHwnd(), n, m_aItems[n]);
} }
#endif //USE_OWNER_DRAWN #endif //USE_OWNER_DRAWN
@@ -747,17 +733,12 @@ bool wxListBox::MSWOnDraw(WXDRAWITEMSTRUCT *item)
wxCHECK( ((m_windowStyle & wxLB_OWNERDRAW) == wxLB_OWNERDRAW), false ); wxCHECK( ((m_windowStyle & wxLB_OWNERDRAW) == wxLB_OWNERDRAW), false );
DRAWITEMSTRUCT *pStruct = (DRAWITEMSTRUCT *)item; DRAWITEMSTRUCT *pStruct = (DRAWITEMSTRUCT *)item;
UINT itemID = pStruct->itemID;
// the item may be -1 for an empty listbox // the item may be -1 for an empty listbox
if ( itemID == (UINT)-1 ) if ( pStruct->itemID == (UINT)-1 )
return false; return false;
LRESULT data = ListBox_GetItemData(GetHwnd(), pStruct->itemID); wxListBoxItem *pItem = (wxListBoxItem *)m_aItems[pStruct->itemID];
wxCHECK( data && (data != LB_ERR), false );
wxListBoxItem *pItem = (wxListBoxItem *)data;
wxDCTemp dc((WXHDC)pStruct->hDC); wxDCTemp dc((WXHDC)pStruct->hDC);
wxPoint pt1(pStruct->rcItem.left, pStruct->rcItem.top); wxPoint pt1(pStruct->rcItem.left, pStruct->rcItem.top);

View File

@@ -287,29 +287,6 @@ void wxCheckListBox::Delete(unsigned int n)
m_aItems.RemoveAt(n); m_aItems.RemoveAt(n);
} // end of wxCheckListBox::Delete } // 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 ) bool wxCheckListBox::SetFont ( const wxFont& rFont )
{ {
for (unsigned int i = 0; i < m_aItems.GetCount(); i++) for (unsigned int i = 0; i < m_aItems.GetCount(); i++)

View File

@@ -308,7 +308,6 @@ int wxListBox::DoInsertItems(const wxArrayStringsAdapter & items,
pNewItem->SetName(items[i]); pNewItem->SetName(items[i]);
m_aItems.Insert(pNewItem, n); m_aItems.Insert(pNewItem, n);
::WinSendMsg(GetHwnd(), LM_SETITEMHANDLE, (MPARAM)n, MPFROMP(pNewItem));
pNewItem->SetFont(GetFont()); pNewItem->SetFont(GetFont());
} }
#endif #endif
@@ -385,17 +384,6 @@ void wxListBox::DoSetItemClientData(unsigned int n, void* pClientData)
wxCHECK_RET( IsValid(n), wxCHECK_RET( IsValid(n),
wxT("invalid index in wxListBox::SetClientData") ); 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)); ::WinSendMsg(GetHwnd(), LM_SETITEMHANDLE, MPFROMLONG(n), MPFROMP(pClientData));
} // end of wxListBox::DoSetItemClientData } // end of wxListBox::DoSetItemClientData
@@ -714,7 +702,6 @@ bool wxListBox::OS2OnDraw (
) )
{ {
POWNERITEM pDrawStruct = (POWNERITEM)pItem; POWNERITEM pDrawStruct = (POWNERITEM)pItem;
LONG lItemID = pDrawStruct->idItem;
int eAction = 0; int eAction = 0;
int eStatus = 0; int eStatus = 0;
@@ -727,17 +714,10 @@ bool wxListBox::OS2OnDraw (
// //
// The item may be -1 for an empty listbox // The item may be -1 for an empty listbox
// //
if (lItemID == -1L) if (pDrawStruct->idItem == -1L)
return false; return false;
wxListBoxItem* pData = (wxListBoxItem*)PVOIDFROMMR( ::WinSendMsg( GetHwnd() wxListBoxItem* pData = (wxListBoxItem*)m_aItems[pDrawStruct->idItem];
,LM_QUERYITEMHANDLE
,MPFROMLONG(pDrawStruct->idItem)
,(MPARAM)0
)
);
wxCHECK(pData, false );
wxClientDC vDc(this); wxClientDC vDc(this);
wxPMDCImpl *impl = (wxPMDCImpl*) vDc.GetImpl(); wxPMDCImpl *impl = (wxPMDCImpl*) vDc.GetImpl();