From 35c2acd4a81a3b41ced9253f744a00e64de2a423 Mon Sep 17 00:00:00 2001 From: Michael Wetherell Date: Fri, 22 Jul 2005 22:29:20 +0000 Subject: [PATCH 1/1] Add wxListCtrl::Get/SetItemFont, patch 1236820 Francesco Montorsi git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@34921 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- docs/latex/wx/listctrl.tex | 14 ++++++++++++++ include/wx/generic/listctrl.h | 4 ++++ include/wx/msw/listctrl.h | 6 ++++++ samples/listctrl/listtest.cpp | 3 +++ src/generic/listctrl.cpp | 16 ++++++++++++++++ src/msw/listctrl.cpp | 18 ++++++++++++++++++ version-script.in | 2 ++ 7 files changed, 63 insertions(+) diff --git a/docs/latex/wx/listctrl.tex b/docs/latex/wx/listctrl.tex index 3cc184d6df..31f5e41f38 100644 --- a/docs/latex/wx/listctrl.tex +++ b/docs/latex/wx/listctrl.tex @@ -377,6 +377,13 @@ Returns the number of items in the list control. Gets the application-defined data associated with this item. +\membersection{wxListCtrl::GetItemFont}\label{wxlistctrlgetitemfont} + +\constfunc{wxFont}{GetItemFont}{\param{long }{item}} + +Returns the item's font. + + \membersection{wxListCtrl::GetItemPosition}\label{wxlistctrlgetitemposition} \constfunc{bool}{GetItemPosition}{\param{long }{item}, \param{wxPoint\& }{pos}} @@ -866,6 +873,13 @@ from $0$ to {\it count}. Associates application-defined data with this item. +\membersection{wxListCtrl::SetItemFont}\label{wxlistctrlsetitemfont} + +\func{void}{SetItemFont}{\param{long }{item}, \param{const wxFont\& }{font}} + +Sets the item's font. + + \membersection{wxListCtrl::SetItemImage}\label{wxlistctrlsetitemimage} \func{bool}{SetItemImage}{\param{long }{item}, \param{int }{image}} diff --git a/include/wx/generic/listctrl.h b/include/wx/generic/listctrl.h index 8a31822b80..1aa689c284 100644 --- a/include/wx/generic/listctrl.h +++ b/include/wx/generic/listctrl.h @@ -118,6 +118,10 @@ public: wxColour GetItemTextColour( long item ) const; void SetItemBackgroundColour( long item, const wxColour &col); wxColour GetItemBackgroundColour( long item ) const; +#if wxABI_VERSION >= 20602 + void SetItemFont( long item, const wxFont &f); + wxFont GetItemFont( long item ) const; +#endif int GetSelectedItemCount() const; wxColour GetTextColour() const; void SetTextColour(const wxColour& col); diff --git a/include/wx/msw/listctrl.h b/include/wx/msw/listctrl.h index 711e1f93c6..eb08f739c0 100644 --- a/include/wx/msw/listctrl.h +++ b/include/wx/msw/listctrl.h @@ -200,6 +200,12 @@ public: void SetItemBackgroundColour( long item, const wxColour &col); wxColour GetItemBackgroundColour( long item ) const; +#if wxABI_VERSION >= 20602 + // Font of an item. + void SetItemFont( long item, const wxFont &f); + wxFont GetItemFont( long item ) const; +#endif + // Gets the number of selected items in the list control int GetSelectedItemCount() const; diff --git a/samples/listctrl/listtest.cpp b/samples/listctrl/listtest.cpp index 99013eec8f..28d151f6cc 100644 --- a/samples/listctrl/listtest.cpp +++ b/samples/listctrl/listtest.cpp @@ -494,6 +494,9 @@ void MyFrame::InitWithReportItems() m_listCtrl->SetColumnWidth( 0, wxLIST_AUTOSIZE ); m_listCtrl->SetColumnWidth( 1, wxLIST_AUTOSIZE ); m_listCtrl->SetColumnWidth( 2, wxLIST_AUTOSIZE ); + + // test SetItemFont too + m_listCtrl->SetItemFont(0, *wxITALIC_FONT); } void MyFrame::InitWithIconItems(bool withText, bool sameIcon) diff --git a/src/generic/listctrl.cpp b/src/generic/listctrl.cpp index d7677af92d..28e4547c3c 100644 --- a/src/generic/listctrl.cpp +++ b/src/generic/listctrl.cpp @@ -5094,6 +5094,22 @@ wxColour wxGenericListCtrl::GetItemBackgroundColour( long item ) const return info.GetBackgroundColour(); } +void wxGenericListCtrl::SetItemFont( long item, const wxFont &f ) +{ + wxListItem info; + info.m_itemId = item; + info.SetFont( f ); + m_mainWin->SetItem( info ); +} + +wxFont wxGenericListCtrl::GetItemFont( long item ) const +{ + wxListItem info; + info.m_itemId = item; + m_mainWin->GetItem( info ); + return info.GetFont(); +} + int wxGenericListCtrl::GetSelectedItemCount() const { return m_mainWin->GetSelectedItemCount(); diff --git a/src/msw/listctrl.cpp b/src/msw/listctrl.cpp index 3769867501..578af99fef 100644 --- a/src/msw/listctrl.cpp +++ b/src/msw/listctrl.cpp @@ -1092,6 +1092,24 @@ wxColour wxListCtrl::GetItemBackgroundColour( long item ) const return col; } +void wxListCtrl::SetItemFont( long item, const wxFont &f ) +{ + wxListItem info; + info.m_itemId = item; + info.SetFont( f ); + SetItem( info ); +} + +wxFont wxListCtrl::GetItemFont( long item ) const +{ + wxFont f; + wxListItemInternalData *data = wxGetInternalData(this, item); + if ( data && data->attr ) + f = data->attr->GetFont(); + + return f; +} + // Gets the number of selected items in the list control int wxListCtrl::GetSelectedItemCount() const { diff --git a/version-script.in b/version-script.in index bc3bd11276..42526223b0 100644 --- a/version-script.in +++ b/version-script.in @@ -18,6 +18,8 @@ *wxXmlResource*Unload*wxString*; *wxXmlResource*IsArchive*wxString*; *wxShadowObject*; + *wxGenericListCtrl*SetItemFont*wxFont*; + *wxGenericListCtrl*GetItemFont*; }; -- 2.45.2