Index: docs/latex/wx/listctrl.tex =================================================================== RCS file: /pack/cvsroots/wxwidgets/wxWidgets/docs/latex/wx/listctrl.tex,v retrieving revision 1.64.2.7 diff -u -4 -r1.64.2.7 listctrl.tex --- docs/latex/wx/listctrl.tex 2006/03/10 21:37:37 1.64.2.7 +++ docs/latex/wx/listctrl.tex 2006/04/04 03:06:50 @@ -22,9 +22,9 @@ itself only when needed which allows to have controls with millions of items without consuming much memory. To use virtual list control you must use \helpref{SetItemCount}{wxlistctrlsetitemcount} first and overload at least \helpref{OnGetItemText}{wxlistctrlongetitemtext} (and optionally -\helpref{OnGetItemImage}{wxlistctrlongetitemimage} and +\helpref{OnGetItemImage}{wxlistctrlongetitemimage} or \helpref{OnGetItemColumnImage}{wxlistctrlongetitemcolumnimage} and \helpref{OnGetItemAttr}{wxlistctrlongetitemattr}) to return the information about the items when the control requests it. Virtual list control can be used as a normal one except that no operations which can take time proportional to the number of items in the control happen -- this is required to allow having a @@ -671,8 +671,9 @@ \wxheading{See also} \helpref{OnGetItemImage}{wxlistctrlongetitemimage},\\ +\helpref{OnGetItemColumnImage}{wxlistctrlongetitemcolumnimage},\\ \helpref{OnGetItemText}{wxlistctrlongetitemtext} \membersection{wxListCtrl::OnGetItemImage}\label{wxlistctrlongetitemimage} @@ -691,11 +692,28 @@ \wxheading{See also} \helpref{OnGetItemText}{wxlistctrlongetitemtext},\\ +\helpref{OnGetItemColumnImage}{wxlistctrlongetitemcolumnimage},\\ \helpref{OnGetItemAttr}{wxlistctrlongetitemattr} +\membersection{wxListCtrl::OnGetItemColumnImage}\label{wxlistctrlongetitemcolumnimage} +\constfunc{virtual int}{OnGetItemColumnImage}{\param{long }{item}, \param{long }{column}} + +Overload this function in the derived class for a control with +{\tt wxLC\_VIRTUAL} and {\tt wxLC\_REPORT} styles in order to specify the image +index for the given line and column. + +The base class version always calls OnGetItemImage for the first column, else +it returns $-1$. + +\wxheading{See also} + +\helpref{OnGetItemText}{wxlistctrlongetitemtext},\\ +\helpref{OnGetItemImage}{wxlistctrlongetitemimage},\\ +\helpref{OnGetItemAttr}{wxlistctrlongetitemattr} + \membersection{wxListCtrl::OnGetItemText}\label{wxlistctrlongetitemtext} \constfunc{virtual wxString}{OnGetItemText}{\param{long }{item}, \param{long }{column}} @@ -706,8 +724,9 @@ \wxheading{See also} \helpref{SetItemCount}{wxlistctrlsetitemcount},\\ \helpref{OnGetItemImage}{wxlistctrlongetitemimage},\\ +\helpref{OnGetItemColumnImage}{wxlistctrlongetitemcolumnimage},\\ \helpref{OnGetItemAttr}{wxlistctrlongetitemattr} \membersection{wxListCtrl::RefreshItem}\label{wxlistctrlrefreshitem} Index: include/wx/generic/listctrl.h =================================================================== RCS file: /pack/cvsroots/wxwidgets/wxWidgets/include/wx/generic/listctrl.h,v retrieving revision 1.100.2.6 diff -u -4 -r1.100.2.6 listctrl.h --- include/wx/generic/listctrl.h 2006/03/10 21:37:36 1.100.2.6 +++ include/wx/generic/listctrl.h 2006/04/04 03:06:50 @@ -65,8 +65,12 @@ //----------------------------------------------------------------------------- // wxListCtrl //----------------------------------------------------------------------------- +// For wxPython patch... +#define wxHAVE_OnGetItemColumnImage + + class WXDLLEXPORT wxGenericListCtrl: public wxControl { public: wxGenericListCtrl(); @@ -240,10 +244,15 @@ protected: // return the text for the given column of the given item virtual wxString OnGetItemText(long item, long column) const; - // return the icon for the given item + // return the icon for the given item. In report view, OnGetItemImage will + // only be called for the first column. See OnGetItemColumnImage for + // details. virtual int OnGetItemImage(long item) const; + + // return the icon for the given item and column. + virtual int OnGetItemColumnImage(long item, long column) const; // return the attribute for the item (may return NULL if none) virtual wxListItemAttr *OnGetItemAttr(long item) const; Index: include/wx/msw/listctrl.h =================================================================== RCS file: /pack/cvsroots/wxwidgets/wxWidgets/include/wx/msw/listctrl.h,v retrieving revision 1.55.2.3 diff -u -4 -r1.55.2.3 listctrl.h --- include/wx/msw/listctrl.h 2006/03/10 21:37:30 1.55.2.3 +++ include/wx/msw/listctrl.h 2006/04/04 03:06:50 @@ -22,9 +22,12 @@ #include "wx/event.h" #include "wx/hash.h" #include "wx/textctrl.h" +// For wxPython patch... +#define wxHAVE_OnGetItemColumnImage + class WXDLLEXPORT wxImageList; /* The wxListCtrl can show lists of items in four different modes: @@ -415,10 +418,15 @@ // return the text for the given column of the given item virtual wxString OnGetItemText(long item, long column) const; - // return the icon for the given item + // return the icon for the given item. In report view, OnGetItemImage will + // only be called for the first column. See OnGetItemColumnImage for + // details. virtual int OnGetItemImage(long item) const; + + // return the icon for the given item and column. + virtual int OnGetItemColumnImage(long item, long column) const; // return the attribute for the item (may return NULL if none) virtual wxListItemAttr *OnGetItemAttr(long item) const; Index: src/generic/listctrl.cpp =================================================================== RCS file: /pack/cvsroots/wxwidgets/wxWidgets/src/generic/listctrl.cpp,v retrieving revision 1.378.2.9 diff -u -4 -r1.378.2.9 listctrl.cpp --- src/generic/listctrl.cpp 2006/04/02 13:39:01 1.378.2.9 +++ src/generic/listctrl.cpp 2006/04/04 03:06:50 @@ -359,8 +359,11 @@ // wxListCtrl API void SetImage( int image ) { SetImage(0, image); } int GetImage() const { return GetImage(0); } + void SetImage( int index, int image ); + int GetImage( int index ) const; + bool HasImage() const { return GetImage() != -1; } bool HasText() const { return !GetText(0).empty(); } void SetItem( int index, const wxListItem &info ); @@ -408,13 +411,8 @@ // draw the text on the DC with the correct justification; also add an // ellipsis if the text is too large to fit in the current width void DrawTextFormatted(wxDC *dc, const wxString &text, int col, int x, int y, int width); - - // these are only used by GetImage/SetImage above, we don't support images - // with subitems at the public API level yet - void SetImage( int index, int image ); - int GetImage( int index ) const; }; WX_DECLARE_EXPORTED_OBJARRAY(wxListLineData, wxListLineDataArray); #include "wx/arrimpl.cpp" @@ -2295,11 +2293,11 @@ size_t countCol = GetColumnCount(); for ( size_t col = 0; col < countCol; col++ ) { ld->SetText(col, listctrl->OnGetItemText(line, col)); + ld->SetImage(col, listctrl->OnGetItemColumnImage(line, col)); } - ld->SetImage(listctrl->OnGetItemImage(line)); ld->SetAttr(listctrl->OnGetItemAttr(line)); } wxListLineData *wxListMainWindow::GetDummyLine() const @@ -5645,9 +5643,17 @@ int wxGenericListCtrl::OnGetItemImage(long WXUNUSED(item)) const { wxCHECK_MSG(!GetImageList(wxIMAGE_LIST_SMALL), -1, - wxT("List control has an image list, OnGetItemImage should be overridden.")); + wxT("List control has an image list, OnGetItemImage or OnGetItemColumnImage should be overridden.")); + return -1; +} + +int wxGenericListCtrl::OnGetItemColumnImage(long item, long column) const +{ + if (!column) + return OnGetItemImage(item); + return -1; } wxListItemAttr * Index: src/msw/listctrl.cpp =================================================================== RCS file: /pack/cvsroots/wxwidgets/wxWidgets/src/msw/listctrl.cpp,v retrieving revision 1.233.2.6 diff -u -4 -r1.233.2.6 listctrl.cpp --- src/msw/listctrl.cpp 2006/03/10 21:37:18 1.233.2.6 +++ src/msw/listctrl.cpp 2006/04/04 03:06:51 @@ -2273,12 +2273,9 @@ // see comment at the end of wxListCtrl::GetColumn() #ifdef NM_CUSTOMDRAW if ( lvi.mask & LVIF_IMAGE ) { - if ( lvi.iSubItem == 0 ) - lvi.iImage = OnGetItemImage(item); - else - lvi.iImage = -1; + lvi.iImage = OnGetItemColumnImage(item, lvi.iSubItem); } #endif // NM_CUSTOMDRAW // a little dose of healthy paranoia: as we never use @@ -2542,9 +2539,17 @@ int wxListCtrl::OnGetItemImage(long WXUNUSED(item)) const { wxCHECK_MSG(!GetImageList(wxIMAGE_LIST_SMALL), -1, - wxT("List control has an image list, OnGetItemImage should be overridden.")); + wxT("List control has an image list, OnGetItemImage or OnGetItemColumnImage should be overridden.")); + return -1; +} + +int wxListCtrl::OnGetItemColumnImage(long item, long column) const +{ + if (!column) + return OnGetItemImage(item); + return -1; } wxListItemAttr *wxListCtrl::OnGetItemAttr(long WXUNUSED_UNLESS_DEBUG(item)) const