From 0c35333e9eb2b387c06cc285916b65a7cebdf0b9 Mon Sep 17 00:00:00 2001 From: Robin Dunn Date: Fri, 28 May 1999 17:27:55 +0000 Subject: [PATCH] Made SetFont for wxCheckListBox more intelligent. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@2592 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/msw/checklst.h | 6 ++++-- src/msw/checklst.cpp | 18 ++++++++++++------ 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/include/wx/msw/checklst.h b/include/wx/msw/checklst.h index 33ac083c8f..df6b479e9c 100644 --- a/include/wx/msw/checklst.h +++ b/include/wx/msw/checklst.h @@ -2,7 +2,7 @@ // Name: checklst.h // Purpose: wxCheckListBox class - a listbox with checkable items // Author: Vadim Zeitlin -// Modified by: +// Modified by: // Created: 16.11.97 // RCS-ID: $Id$ // Copyright: (c) 1998 Vadim Zeitlin @@ -35,7 +35,7 @@ public: wxCheckListBox(wxWindow *parent, wxWindowID id, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, - int nStrings = 0, + int nStrings = 0, const wxString choices[] = NULL, long style = 0, const wxValidator& validator = wxDefaultValidator, @@ -45,6 +45,8 @@ public: virtual void Delete(int n); virtual void InsertItems(int nItems, const wxString items[], int pos); + virtual bool SetFont( const wxFont &font ); + // items may be checked bool IsChecked(size_t uiIndex) const; void Check(size_t uiIndex, bool bCheck = TRUE); diff --git a/src/msw/checklst.cpp b/src/msw/checklst.cpp index 5e46c81073..d0b312fb84 100644 --- a/src/msw/checklst.cpp +++ b/src/msw/checklst.cpp @@ -101,7 +101,6 @@ wxCheckListBoxItem::wxCheckListBoxItem(wxCheckListBox *pParent, size_t nIndex) // know that there will always be OnMeasure before OnDraw // fix appearance - SetFont(wxSystemSettings::GetSystemFont(wxSYS_ANSI_VAR_FONT)); SetMarginWidth(GetDefaultMarginWidth()); } @@ -231,7 +230,7 @@ void wxCheckListBoxItem::Check(bool check) #ifdef __WIN32__ RECT rcUpdate; - + if ( ::SendMessage(hwndListbox, LB_GETITEMRECT, m_nIndex, (LPARAM)&rcUpdate) == LB_ERR ) { @@ -245,7 +244,7 @@ void wxCheckListBoxItem::Check(bool check) #endif // Win32/16 InvalidateRect(hwndListbox, &rcUpdate, FALSE); - + wxCommandEvent event(wxEVT_COMMAND_CHECKLISTBOX_TOGGLED, m_pParent->GetId()); event.SetInt(m_nIndex); event.SetEventObject(m_pParent); @@ -312,6 +311,16 @@ void wxCheckListBox::InsertItems(int nItems, const wxString items[], int pos) } } + +bool wxCheckListBox::SetFont( const wxFont &font ) +{ + size_t i; + for (i=0; i < m_aItems.GetCount(); i++) + m_aItems[i]->SetFont(font); + wxListBox::SetFont(font); + return TRUE; +} + // create/retrieve item // -------------------- @@ -319,9 +328,6 @@ void wxCheckListBox::InsertItems(int nItems, const wxString items[], int pos) wxOwnerDrawn *wxCheckListBox::CreateItem(size_t nIndex) { wxCheckListBoxItem *pItem = new wxCheckListBoxItem(this, nIndex); - if ( m_font.Ok() ) - pItem->SetFont(m_font); - return pItem; } -- 2.45.2