From eab1336c903271946530509a6c7939eba54371e6 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sun, 25 Jan 2009 13:27:48 +0000 Subject: [PATCH] added (MSW-only) wxListCtrl::OnGetItemColumnAttr() (#10018) git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@58393 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/msw/listctrl.h | 8 +++++++- interface/wx/listctrl.h | 23 +++++++++++++++++++++-- src/msw/listctrl.cpp | 14 +++++++++++--- 3 files changed, 39 insertions(+), 6 deletions(-) diff --git a/include/wx/msw/listctrl.h b/include/wx/msw/listctrl.h index ea13f0b6a6..13b7586b04 100644 --- a/include/wx/msw/listctrl.h +++ b/include/wx/msw/listctrl.h @@ -402,7 +402,7 @@ protected: // get the item attribute, either by quering it for virtual control, or by // returning the one previously set using setter methods for a normal one - wxListItemAttr *DoGetItemAttr(long item) const; + wxListItemAttr *DoGetItemColumnAttr(long item, long column) const; wxTextCtrl* m_textCtrl; // The control used for editing a label @@ -442,6 +442,12 @@ protected: // return the attribute for the item (may return NULL if none) virtual wxListItemAttr *OnGetItemAttr(long item) const; + // return the attribute for the given item and column (may return NULL if none) + virtual wxListItemAttr *OnGetItemColumnAttr(long item, long WXUNUSED(column)) const + { + return OnGetItemAttr(item); + } + private: // process NM_CUSTOMDRAW notification message WXLPARAM OnCustomDraw(WXLPARAM lParam); diff --git a/interface/wx/listctrl.h b/interface/wx/listctrl.h index 0729e48382..d7f0e2ba06 100644 --- a/interface/wx/listctrl.h +++ b/interface/wx/listctrl.h @@ -873,10 +873,28 @@ protected: The base class version always returns @NULL. - @see OnGetItemImage(), OnGetItemColumnImage(), OnGetItemText() + @see OnGetItemImage(), OnGetItemColumnImage(), OnGetItemText(), + OnGetItemColumnAttr() */ virtual wxListItemAttr* OnGetItemAttr(long item) const; + /** + This function may be overridden in the derived class for a control with + @c wxLC_VIRTUAL style. + + It should return the attribute for the for the specified @a item and @a + column or @NULL to use the default appearance parameters. + + The base class version returns @c OnGetItemAttr(item). + + @note Currently this function is only called under wxMSW, the other + ports only support OnGetItemAttr() + + @see OnGetItemAttr(), OnGetItemText(), + OnGetItemImage(), OnGetItemColumnImage(), + */ + virtual wxListItemAttr* OnGetItemColumnAttr(long item, long column) const; + /** Overload this function in the derived class for a control with @c wxLC_VIRTUAL and @c wxLC_REPORT styles in order to specify the image @@ -885,7 +903,8 @@ protected: The base class version always calls OnGetItemImage() for the first column, else it returns -1. - @see OnGetItemText(), OnGetItemImage(), OnGetItemAttr() + @see OnGetItemText(), OnGetItemImage(), OnGetItemAttr(), + OnGetItemColumnAttr() */ virtual int OnGetItemColumnImage(long item, long column) const; diff --git a/src/msw/listctrl.cpp b/src/msw/listctrl.cpp index f05ea49fb8..d3d423b717 100644 --- a/src/msw/listctrl.cpp +++ b/src/msw/listctrl.cpp @@ -2821,14 +2821,22 @@ WXLPARAM wxListCtrl::OnCustomDraw(WXLPARAM lParam) break; case CDDS_ITEMPREPAINT: + // get a message for each subitem + return CDRF_NOTIFYITEMDRAW; + + case CDDS_SUBITEM | CDDS_ITEMPREPAINT: const int item = nmcd.dwItemSpec; + const int column = pLVCD->iSubItem; // we get this message with item == 0 for an empty control, we // must ignore it as calling OnGetItemAttr() would be wrong if ( item < 0 || item >= GetItemCount() ) break; + // same for columns + if ( column < 0 || column >= GetColumnCount() ) + break; - return HandleItemPrepaint(this, pLVCD, DoGetItemAttr(item)); + return HandleItemPrepaint(this, pLVCD, DoGetItemColumnAttr(item, column)); } return CDRF_DODEFAULT; @@ -2990,9 +2998,9 @@ wxListItemAttr *wxListCtrl::OnGetItemAttr(long WXUNUSED_UNLESS_DEBUG(item)) cons return NULL; } -wxListItemAttr *wxListCtrl::DoGetItemAttr(long item) const +wxListItemAttr *wxListCtrl::DoGetItemColumnAttr(long item, long column) const { - return IsVirtual() ? OnGetItemAttr(item) + return IsVirtual() ? OnGetItemColumnAttr(item, column) : wxGetInternalDataAttr(this, item); } -- 2.45.2