diff --git a/docs/changes.txt b/docs/changes.txt index 052f9eea10..1e438a84f8 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -109,6 +109,7 @@ All (GUI): - Allow status bar children in XRC (Edmunt Pienkowski) - Fix memory leak in wxWizard when not using sizers for the page layout +- Added wxListCtrl::SetItemPtrData() wxMSW: diff --git a/docs/latex/wx/listctrl.tex b/docs/latex/wx/listctrl.tex index a3ef301c66..8f031edd97 100644 --- a/docs/latex/wx/listctrl.tex +++ b/docs/latex/wx/listctrl.tex @@ -943,6 +943,9 @@ from $0$ to {\it count}. Associates application-defined data with this item. +Notice that this function cannot be used to associate pointers with the control +items, use \helpref{SetItemPtrData}{wxlistctrlsetitemptrdata} instead. + \membersection{wxListCtrl::SetItemFont}\label{wxlistctrlsetitemfont} @@ -981,6 +984,18 @@ The image is an index into the image list associated with the list control. Sets the position of the item, in icon or small icon view. Windows only. +\membersection{wxListCtrl::SetItemPtrData}\label{wxlistctrlsetitemptrdata} + +\func{bool}{SetItemPtrData}{\param{long }{item}, \param{wxUIntPtr }{data}} + +Associates application-defined data with this item. The \arg{data} parameter may +be either an integer or a pointer cast to the \texttt{wxUIntPtr} type which is +guaranteed to be large enough to be able to contain all integer types and +pointers. + +\newsince{2.8.4} + + \membersection{wxListCtrl::SetItemState}\label{wxlistctrlsetitemstate} \func{bool}{SetItemState}{\param{long }{item}, \param{long }{state}, \param{long }{stateMask}} diff --git a/include/wx/generic/listctrl.h b/include/wx/generic/listctrl.h index 19e874c53e..d0c9055bc9 100644 --- a/include/wx/generic/listctrl.h +++ b/include/wx/generic/listctrl.h @@ -77,7 +77,10 @@ public: wxString GetItemText( long item ) const; void SetItemText( long item, const wxString& str ); wxUIntPtr GetItemData( long item ) const; - bool SetItemData( long item, long data ); +#if wxABI_VERSION >= 20804 + bool SetItemPtrData(long item, wxUIntPtr data); +#endif // wxABI 2.8.4+ + bool SetItemData(long item, long data); bool GetItemRect( long item, wxRect& rect, int code = wxLIST_RECT_BOUNDS ) const; bool GetItemPosition( long item, wxPoint& pos ) const; bool SetItemPosition( long item, const wxPoint& pos ); // not supported in wxGLC diff --git a/include/wx/mac/carbon/listctrl.h b/include/wx/mac/carbon/listctrl.h index 8e2efb0c6b..067cda6f73 100644 --- a/include/wx/mac/carbon/listctrl.h +++ b/include/wx/mac/carbon/listctrl.h @@ -122,7 +122,10 @@ class WXDLLEXPORT wxListCtrl: public wxControl long GetItemData(long item) const ; // Sets the item data - bool SetItemData(long item, long data) ; +#if wxABI_VERSION >= 20804 + bool SetItemPtrData(long item, wxUIntPtr data); +#endif // wxABI 2.8.4+ + bool SetItemData(long item, long data); // Gets the item rectangle bool GetItemRect(long item, wxRect& rect, int code = wxLIST_RECT_BOUNDS) const ; diff --git a/include/wx/msw/listctrl.h b/include/wx/msw/listctrl.h index 97f61eb113..1ddd207981 100644 --- a/include/wx/msw/listctrl.h +++ b/include/wx/msw/listctrl.h @@ -163,7 +163,10 @@ public: wxUIntPtr GetItemData(long item) const ; // Sets the item data - bool SetItemData(long item, long data) ; +#if wxABI_VERSION >= 20804 + bool SetItemPtrData(long item, wxUIntPtr data); +#endif // wxABI 2.8.4+ + bool SetItemData(long item, long data); // Gets the item rectangle bool GetItemRect(long item, wxRect& rect, int code = wxLIST_RECT_BOUNDS) const ; diff --git a/src/generic/listctrl.cpp b/src/generic/listctrl.cpp index 97c78dfd42..b741b5a7b5 100644 --- a/src/generic/listctrl.cpp +++ b/src/generic/listctrl.cpp @@ -5177,7 +5177,7 @@ wxUIntPtr wxGenericListCtrl::GetItemData( long item ) const return info.m_data; } -bool wxGenericListCtrl::SetItemData( long item, long data ) +bool wxGenericListCtrl::SetItemPtrData( long item, wxUIntPtr data ) { wxListItem info; info.m_mask = wxLIST_MASK_DATA; @@ -5187,6 +5187,11 @@ bool wxGenericListCtrl::SetItemData( long item, long data ) return true; } +bool wxGenericListCtrl::SetItemData(long item, long data) +{ + return SetItemPtrData(item, data); +} + wxRect wxGenericListCtrl::GetViewRect() const { return m_mainWin->GetViewRect(); diff --git a/src/mac/carbon/listctrl_mac.cpp b/src/mac/carbon/listctrl_mac.cpp index 4e80407df1..9e7bf0fab1 100644 --- a/src/mac/carbon/listctrl_mac.cpp +++ b/src/mac/carbon/listctrl_mac.cpp @@ -1326,7 +1326,7 @@ long wxListCtrl::GetItemData(long item) const } // Sets the item data -bool wxListCtrl::SetItemData(long item, long data) +bool wxListCtrl::SetItemPtrData(long item, wxUIntPtr data) { if (m_genericImpl) return m_genericImpl->SetItemData(item, data); @@ -1340,6 +1340,11 @@ bool wxListCtrl::SetItemData(long item, long data) return SetItem(info); } +bool wxListCtrl::SetItemData(long item, long data) +{ + return SetItemPtrData(item, data); +} + wxRect wxListCtrl::GetViewRect() const { wxASSERT_MSG( !HasFlag(wxLC_REPORT | wxLC_LIST), diff --git a/src/msw/listctrl.cpp b/src/msw/listctrl.cpp index 9037c43b71..31d7e45cee 100644 --- a/src/msw/listctrl.cpp +++ b/src/msw/listctrl.cpp @@ -948,7 +948,7 @@ wxUIntPtr wxListCtrl::GetItemData(long item) const } // Sets the item data -bool wxListCtrl::SetItemData(long item, long data) +bool wxListCtrl::SetItemPtrData(long item, wxUIntPtr data) { wxListItem info; @@ -959,6 +959,11 @@ bool wxListCtrl::SetItemData(long item, long data) return SetItem(info); } +bool wxListCtrl::SetItemData(long item, long data) +{ + return SetItemPtrData(item, data); +} + wxRect wxListCtrl::GetViewRect() const { wxASSERT_MSG( !HasFlag(wxLC_REPORT | wxLC_LIST), diff --git a/version-script.in b/version-script.in index 6f51b00728..87ba41f5af 100644 --- a/version-script.in +++ b/version-script.in @@ -27,6 +27,7 @@ # public symbols added in 2.8.4 (please keep in alphabetical order): @WX_VERSION_TAG@.4 { global: + *wxListCtrl*SetItemPtrData*; # wxString::To/From8BitData() *wxString*To8BitData*; *wxString*From8BitData*;