From 06db67bcb00b09ff12039bfa135068bb153ed806 Mon Sep 17 00:00:00 2001 From: Robin Dunn Date: Fri, 10 Mar 2006 21:26:59 +0000 Subject: [PATCH] Applied Patch #1424869: Implement wxListCtrl::SetItemColumnImage git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@37982 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- docs/latex/wx/listctrl.tex | 11 ++++++++++- include/wx/generic/listctrl.h | 1 + include/wx/mac/carbon/listctrl.h | 1 + include/wx/mac/classic/listctrl.h | 1 + include/wx/msw/listctrl.h | 1 + include/wx/os2/listctrl.h | 4 ++++ include/wx/palmos/listctrl.h | 1 + samples/listctrl/listtest.cpp | 19 +++++++++++++++++-- samples/listctrl/listtest.h | 2 +- src/generic/listctrl.cpp | 7 +++++++ src/msw/listctrl.cpp | 7 +++++++ src/os2/listctrl.cpp | 12 +++++++++++- src/palmos/listctrl.cpp | 6 ++++++ wxPython/src/_listctrl.i | 1 + 14 files changed, 69 insertions(+), 5 deletions(-) diff --git a/docs/latex/wx/listctrl.tex b/docs/latex/wx/listctrl.tex index 061e22ebc7..1d8039bb5d 100644 --- a/docs/latex/wx/listctrl.tex +++ b/docs/latex/wx/listctrl.tex @@ -920,7 +920,8 @@ Sets the item's font. \func{bool}{SetItemImage}{\param{long }{item}, \param{int }{image}} Sets the image associated with the item. The image is an index into the -image list associated with the list control. +image list associated with the list control. In report view, this only sets +the image for the first column. \func{bool}{SetItemImage}{\param{long }{item}, \param{int }{image}, \param{int }{selImage}} @@ -929,6 +930,14 @@ image list associated with the list control. This form is deprecated: {\it selIm used. +\membersection{wxListCtrl::SetItemColumnImage}\label{wxlistctrlsetitemcolumnimage} + +\func{bool}{SetItemImage}{\param{long }{item}, \param{long }{column}\param{int }{image}} + +Sets the image associated with the item. In report view, you can specify the column. +The image is an index into the image list associated with the list control. + + \membersection{wxListCtrl::SetItemPosition}\label{wxlistctrlsetitemposition} \func{bool}{SetItemPosition}{\param{long }{item}, \param{const wxPoint\& }{pos}} diff --git a/include/wx/generic/listctrl.h b/include/wx/generic/listctrl.h index e8ca93d6db..9d80b4f308 100644 --- a/include/wx/generic/listctrl.h +++ b/include/wx/generic/listctrl.h @@ -100,6 +100,7 @@ public: int GetItemState( long item, long stateMask ) const; bool SetItemState( long item, long state, long stateMask); bool SetItemImage( long item, int image, int selImage = -1 ); + bool SetItemColumnImage( long item, long column, int image ); wxString GetItemText( long item ) const; void SetItemText( long item, const wxString& str ); wxUIntPtr GetItemData( long item ) const; diff --git a/include/wx/mac/carbon/listctrl.h b/include/wx/mac/carbon/listctrl.h index 82defacf72..a83e843e4a 100644 --- a/include/wx/mac/carbon/listctrl.h +++ b/include/wx/mac/carbon/listctrl.h @@ -223,6 +223,7 @@ class WXDLLEXPORT wxListCtrl: public wxControl // Sets the item image bool SetItemImage(long item, int image, int selImage) ; + bool SetItemColumnImage(long item, long column, int image); // Gets the item text wxString GetItemText(long item) const ; diff --git a/include/wx/mac/classic/listctrl.h b/include/wx/mac/classic/listctrl.h index 82defacf72..a83e843e4a 100644 --- a/include/wx/mac/classic/listctrl.h +++ b/include/wx/mac/classic/listctrl.h @@ -223,6 +223,7 @@ class WXDLLEXPORT wxListCtrl: public wxControl // Sets the item image bool SetItemImage(long item, int image, int selImage) ; + bool SetItemColumnImage(long item, long column, int image); // Gets the item text wxString GetItemText(long item) const ; diff --git a/include/wx/msw/listctrl.h b/include/wx/msw/listctrl.h index cb2f5cac3d..895adaea48 100644 --- a/include/wx/msw/listctrl.h +++ b/include/wx/msw/listctrl.h @@ -157,6 +157,7 @@ public: // Sets the item image bool SetItemImage(long item, int image, int selImage = -1) ; + bool SetItemColumnImage(long item, long column, int image); // Gets the item text wxString GetItemText(long item) const ; diff --git a/include/wx/os2/listctrl.h b/include/wx/os2/listctrl.h index 8aba96302b..03db69cf89 100644 --- a/include/wx/os2/listctrl.h +++ b/include/wx/os2/listctrl.h @@ -133,6 +133,10 @@ public: ,int nImage ,int lSelImage ); + bool SetItemColumnImage( long lItem + ,long lColumn + ,int nImage + ); // // Item text diff --git a/include/wx/palmos/listctrl.h b/include/wx/palmos/listctrl.h index 68f7399c83..1ad47caae0 100644 --- a/include/wx/palmos/listctrl.h +++ b/include/wx/palmos/listctrl.h @@ -154,6 +154,7 @@ public: // Sets the item image bool SetItemImage(long item, int image, int selImage) ; + bool SetItemColumnImage(long item, long column, int image); // Gets the item text wxString GetItemText(long item) const ; diff --git a/samples/listctrl/listtest.cpp b/samples/listctrl/listtest.cpp index ff643ad850..4e812cfbf6 100644 --- a/samples/listctrl/listtest.cpp +++ b/samples/listctrl/listtest.cpp @@ -491,6 +491,15 @@ void MyFrame::InitWithReportItems() m_listCtrl->SetColumnWidth( 1, wxLIST_AUTOSIZE ); m_listCtrl->SetColumnWidth( 2, wxLIST_AUTOSIZE ); + // Set images in columns + m_listCtrl->SetItemColumnImage(1, 1, 0); + + wxListItem info; + info.SetImage(0); + info.SetId(3); + info.SetColumn(2); + m_listCtrl->SetItem(info); + // test SetItemFont too m_listCtrl->SetItemFont(0, *wxITALIC_FONT); } @@ -1012,9 +1021,15 @@ wxString MyListCtrl::OnGetItemText(long item, long column) const } } -int MyListCtrl::OnGetItemImage(long WXUNUSED(item)) const +int MyListCtrl::OnGetItemColumnImage(long item, long column) const { - return 0; + if (!column) + return 0; + + if (!(item %3) && column == 1) + return 0; + + return -1; } wxListItemAttr *MyListCtrl::OnGetItemAttr(long item) const diff --git a/samples/listctrl/listtest.h b/samples/listctrl/listtest.h index 90359d0030..47942fa7ae 100644 --- a/samples/listctrl/listtest.h +++ b/samples/listctrl/listtest.h @@ -68,7 +68,7 @@ private: void LogColEvent(const wxListEvent& event, const wxChar *eventName); virtual wxString OnGetItemText(long item, long column) const; - virtual int OnGetItemImage(long item) const; + virtual int OnGetItemColumnImage(long item, long column) const; virtual wxListItemAttr *OnGetItemAttr(long item) const; wxListItemAttr m_attr; diff --git a/src/generic/listctrl.cpp b/src/generic/listctrl.cpp index 41beca006a..5a55c70613 100644 --- a/src/generic/listctrl.cpp +++ b/src/generic/listctrl.cpp @@ -4935,11 +4935,18 @@ bool wxGenericListCtrl::SetItemState( long item, long state, long stateMask ) bool wxGenericListCtrl::SetItemImage( long item, int image, int WXUNUSED(selImage) ) +{ + return SetItemColumnImage(item, 0, image); +} + +bool +wxGenericListCtrl::SetItemColumnImage( long item, long column, int image ) { wxListItem info; info.m_image = image; info.m_mask = wxLIST_MASK_IMAGE; info.m_itemId = item; + info.m_col = column; m_mainWin->SetItem( info ); return true; } diff --git a/src/msw/listctrl.cpp b/src/msw/listctrl.cpp index 3516a38973..e680736293 100644 --- a/src/msw/listctrl.cpp +++ b/src/msw/listctrl.cpp @@ -918,12 +918,19 @@ bool wxListCtrl::SetItemState(long item, long state, long stateMask) // Sets the item image bool wxListCtrl::SetItemImage(long item, int image, int WXUNUSED(selImage)) +{ + return SetItemColumnImage(item, 0, image); +} + +// Sets the item image +bool wxListCtrl::SetItemColumnImage(long item, long column, int image) { wxListItem info; info.m_mask = wxLIST_MASK_IMAGE; info.m_image = image; info.m_itemId = item; + info.m_col = column; return SetItem(info); } diff --git a/src/os2/listctrl.cpp b/src/os2/listctrl.cpp index aaa7d81587..9afea42f73 100644 --- a/src/os2/listctrl.cpp +++ b/src/os2/listctrl.cpp @@ -1543,14 +1543,24 @@ bool wxListCtrl::SetItemImage ( long lItem , int nImage , int WXUNUSED(nSelImage)) +{ + return SetItemColumnInfo(lItem, 0, nImage); +} // end of wxListCtrl::SetItemImage + +// Sets the item image +bool wxListCtrl::SetItemColumnImage ( + long lItem +, long lColumn +, int nImage { wxListItem vInfo; vInfo.m_mask = wxLIST_MASK_IMAGE; vInfo.m_image = nImage; vInfo.m_itemId = lItem; + vInfo.m_col = lColumn; return SetItem(vInfo); -} // end of wxListCtrl::SetItemImage +} // end of wxListCtrl::SetItemColumnImage // Gets the item text wxString wxListCtrl::GetItemText ( diff --git a/src/palmos/listctrl.cpp b/src/palmos/listctrl.cpp index 3d4dade775..2fcaaebea4 100644 --- a/src/palmos/listctrl.cpp +++ b/src/palmos/listctrl.cpp @@ -284,6 +284,12 @@ bool wxListCtrl::SetItemImage(long item, int image, int WXUNUSED(selImage)) return false; } +// Sets the item image +bool wxListCtrl::SetItemColumnImage(long item, long column, int image) +{ + return false; +} + // Gets the item text wxString wxListCtrl::GetItemText(long item) const { diff --git a/wxPython/src/_listctrl.i b/wxPython/src/_listctrl.i index 47e7b32322..cf45734fb4 100644 --- a/wxPython/src/_listctrl.i +++ b/wxPython/src/_listctrl.i @@ -513,6 +513,7 @@ public: // Sets the item image bool SetItemImage(long item, int image, int selImage=-1) ; + bool SetItemColumnImage( long item, long column, int image ); // Gets the item text wxString GetItemText(long item) const ; -- 2.47.2