From: Robin Dunn Date: Wed, 25 Jan 2006 23:29:02 +0000 (+0000) Subject: Patch from Tim Kosse to add supoprt for wxListCtrl::OnGetItemColumnImage X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/208458a7f59c7ba95a795597548fc8ae4be655cc?ds=sidebyside;hp=0a6f92b85cb0833682e61dee893f6087905c0ba7 Patch from Tim Kosse to add supoprt for wxListCtrl::OnGetItemColumnImage which enables images to be specified for columns other than zero in virtual list controls. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@37144 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/docs/latex/wx/listctrl.tex b/docs/latex/wx/listctrl.tex index 5c6a4a11ca..754c03acb6 100644 --- a/docs/latex/wx/listctrl.tex +++ b/docs/latex/wx/listctrl.tex @@ -23,7 +23,7 @@ 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 @@ -672,6 +672,7 @@ The base class version always returns {\tt NULL}. \wxheading{See also} \helpref{OnGetItemImage}{wxlistctrlongetitemimage},\\ +\helpref{OnGetItemColumnImage}{wxlistctrlongetitemcolumnimage},\\ \helpref{OnGetItemText}{wxlistctrlongetitemtext} @@ -684,14 +685,33 @@ This function must be overloaded in the derived class for a control with (if the control doesn't have an image list, it is not necessary to overload it). It should return the index of the items image in the controls image list or $-1$ for no image. +In a control with {\tt wxLC\_REPORT} style, OnGetItemImage only gets called for +the first column of each line. The base class version always returns $-1$. \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} @@ -705,6 +725,7 @@ the given {\it column} for the specified {\tt item}. \helpref{SetItemCount}{wxlistctrlsetitemcount},\\ \helpref{OnGetItemImage}{wxlistctrlongetitemimage},\\ +\helpref{OnGetItemColumnImage}{wxlistctrlongetitemcolumnimage},\\ \helpref{OnGetItemAttr}{wxlistctrlongetitemattr} diff --git a/include/wx/generic/listctrl.h b/include/wx/generic/listctrl.h index cfefe3ecce..5d4a4121c7 100644 --- a/include/wx/generic/listctrl.h +++ b/include/wx/generic/listctrl.h @@ -232,9 +232,14 @@ 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; diff --git a/include/wx/msw/listctrl.h b/include/wx/msw/listctrl.h index c937308b00..8a09699b1a 100644 --- a/include/wx/msw/listctrl.h +++ b/include/wx/msw/listctrl.h @@ -407,9 +407,14 @@ 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; diff --git a/include/wx/os2/listctrl.h b/include/wx/os2/listctrl.h index c9995b0423..8aba96302b 100644 --- a/include/wx/os2/listctrl.h +++ b/include/wx/os2/listctrl.h @@ -503,10 +503,17 @@ protected: ) 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 lItem) const; + // + // Return the icon for the given item and column + // + virtual int OnGetItemColumnImage(long lItem, long lColumn) const; + // // Return the attribute for the item (may return NULL if none) // diff --git a/include/wx/palmos/listctrl.h b/include/wx/palmos/listctrl.h index 04baabc2e1..68f7399c83 100644 --- a/include/wx/palmos/listctrl.h +++ b/include/wx/palmos/listctrl.h @@ -374,7 +374,12 @@ 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 text for the given column of the given item + virtual wxString OnGetItemText(long item, long column) const; + + // 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 attribute for the item (may return NULL if none) diff --git a/src/generic/listctrl.cpp b/src/generic/listctrl.cpp index cfcee8e268..3608f7e033 100644 --- a/src/generic/listctrl.cpp +++ b/src/generic/listctrl.cpp @@ -2226,9 +2226,9 @@ void wxListMainWindow::CacheLineData(size_t line) for ( size_t col = 0; col < countCol; col++ ) { ld->SetText(col, listctrl->OnGetItemText(line, col)); + ld->SetImage(listctrl->OnGetItemColumnImage(line, col)); } - ld->SetImage(listctrl->OnGetItemImage(line)); ld->SetAttr(listctrl->OnGetItemAttr(line)); } @@ -5470,11 +5470,18 @@ 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 * wxGenericListCtrl::OnGetItemAttr(long WXUNUSED_UNLESS_DEBUG(item)) const { diff --git a/src/msw/listctrl.cpp b/src/msw/listctrl.cpp index cbedea6f73..9721b54651 100644 --- a/src/msw/listctrl.cpp +++ b/src/msw/listctrl.cpp @@ -2253,7 +2253,7 @@ bool wxListCtrl::MSWOnNotify(int idCtrl, WXLPARAM lParam, WXLPARAM *result) #ifdef NM_CUSTOMDRAW if ( lvi.mask & LVIF_IMAGE ) { - lvi.iImage = OnGetItemImage(item); + lvi.iImage = OnGetItemColumnImage(item, lvi.iSubItem); } #endif // NM_CUSTOMDRAW @@ -2519,7 +2519,15 @@ 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; } diff --git a/src/os2/listctrl.cpp b/src/os2/listctrl.cpp index 04d05027cd..aaa7d81587 100644 --- a/src/os2/listctrl.cpp +++ b/src/os2/listctrl.cpp @@ -2718,6 +2718,17 @@ int wxListCtrl::OnGetItemImage ( return -1; } // end of wxListCtrl::OnGetItemImage +int wxListCtrl::OnGetItemColumnImage ( + long lItem, + long lColumn +) const +{ + if (!lColumn) + return OnGetItemImage(lItem); + + return -1; +} // end of wxListCtrl::OnGetItemColumnImage + wxListItemAttr* wxListCtrl::OnGetItemAttr ( long WXUNUSED_UNLESS_DEBUG(lItem) ) const diff --git a/src/palmos/listctrl.cpp b/src/palmos/listctrl.cpp index 766497d020..3d4dade775 100644 --- a/src/palmos/listctrl.cpp +++ b/src/palmos/listctrl.cpp @@ -622,6 +622,14 @@ int wxListCtrl::OnGetItemImage(long WXUNUSED(item)) const 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 { // no attributes by default