From 2f1e3c464ce0886163be49d4a10843f2b4c9679b Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Tue, 8 Jul 2003 11:19:10 +0000 Subject: [PATCH] Refresh() didn't work as it wasn't passed to subwindows git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@21754 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- docs/changes.txt | 1 + include/wx/generic/listctrl.h | 6 +++-- src/generic/listctrl.cpp | 51 +++++++++++++++++++++++++++++++++++ 3 files changed, 56 insertions(+), 2 deletions(-) diff --git a/docs/changes.txt b/docs/changes.txt index c23f143cd7..f094d7013b 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -124,6 +124,7 @@ wxGTK: - added wxTextCtrl::SetSelection implementation for GTK+ 2 - fixed wxTextCtrl::IsEditable() for GTK+ 2 - don't consume 100% CPU when showing a poup menu +- implemented wxListCtrl::Refresh() (Norbert Berzen) wxMac: diff --git a/include/wx/generic/listctrl.h b/include/wx/generic/listctrl.h index 31c38e9638..6a7dc88036 100644 --- a/include/wx/generic/listctrl.h +++ b/include/wx/generic/listctrl.h @@ -148,8 +148,8 @@ public: long InsertItem( long index, int imageIndex ); long InsertItem( long index, const wxString& label, int imageIndex ); long InsertColumn( long col, wxListItem& info ); - long InsertColumn( long col, const wxString& heading, int format = wxLIST_FORMAT_LEFT, - int width = -1 ); + long InsertColumn( long col, const wxString& heading, + int format = wxLIST_FORMAT_LEFT, int width = -1 ); bool ScrollList( int dx, int dy ); bool SortItems( wxListCtrlCompare fn, long data ); bool Update( long item ); @@ -168,6 +168,8 @@ public: void OnSize( wxSizeEvent &event ); // We have to hand down a few functions + virtual void Refresh(bool eraseBackground = TRUE, + const wxRect *rect = NULL); virtual void Freeze(); virtual void Thaw(); diff --git a/src/generic/listctrl.cpp b/src/generic/listctrl.cpp index 0a9299f9df..c80ade054d 100644 --- a/src/generic/listctrl.cpp +++ b/src/generic/listctrl.cpp @@ -5168,6 +5168,57 @@ void wxGenericListCtrl::RefreshItems(long itemFrom, long itemTo) m_mainWin->RefreshLines(itemFrom, itemTo); } +/* + * Generic wxListCtrl is more or less a container for two other + * windows which drawings are done upon. These are namely + * 'm_headerWin' and 'm_mainWin'. + * Here we override 'virtual wxWindow::Refresh()' to mimic the + * behaviour wxListCtrl has under wxMSW. + */ +void wxGenericListCtrl::Refresh(bool eraseBackground, const wxRect *rect) +{ + if (!rect) + { + // The easy case, no rectangle specified. + if (m_headerWin) + m_headerWin->Refresh(eraseBackground); + + if (m_mainWin) + m_mainWin->Refresh(eraseBackground); + } + else + { + // Refresh the header window + if (m_headerWin) + { + wxRect rectHeader = m_headerWin->GetRect(); + rectHeader.Intersect(*rect); + if (rectHeader.GetWidth() && rectHeader.GetHeight()) + { + int x, y; + m_headerWin->GetPosition(&x, &y); + rectHeader.Offset(-x, -y); + m_headerWin->Refresh(eraseBackground, &rectHeader); + } + + } + + // Refresh the main window + if (m_mainWin) + { + wxRect rectMain = m_mainWin->GetRect(); + rectMain.Intersect(*rect); + if (rectMain.GetWidth() && rectMain.GetHeight()) + { + int x, y; + m_mainWin->GetPosition(&x, &y); + rectMain.Offset(-x, -y); + m_mainWin->Refresh(eraseBackground, &rectMain); + } + } + } +} + void wxGenericListCtrl::Freeze() { m_mainWin->Freeze(); -- 2.45.2