From 4635abaca683ac7444e404dab6437e178e8920f6 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Thu, 11 Dec 2008 17:15:43 +0000 Subject: [PATCH] added wxHeaderCtrl::OnColumnCountChanging() git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@57255 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/headerctrl.h | 7 ++++++- interface/wx/headerctrl.h | 12 ++++++++++++ src/common/headerctrlcmn.cpp | 7 +++++++ 3 files changed, 25 insertions(+), 1 deletion(-) diff --git a/include/wx/headerctrl.h b/include/wx/headerctrl.h index d3223c7131..b242b9c920 100644 --- a/include/wx/headerctrl.h +++ b/include/wx/headerctrl.h @@ -70,7 +70,7 @@ public: // set the number of columns in the control // // this also calls UpdateColumn() for all columns - void SetColumnCount(unsigned int count) { DoSetCount(count); } + void SetColumnCount(unsigned int count); // return the number of columns in the control as set by SetColumnCount() unsigned int GetColumnCount() const { return DoGetCount(); } @@ -124,6 +124,11 @@ protected: return false; } + // this method can be overridden in the derived classes to do something + // (e.g. update/resize some internal data structures) before the number of + // columns in the control changes + virtual void OnColumnCountChanging(unsigned int WXUNUSED(count)) { } + private: // methods implementing our public API and defined in platform-specific // implementations diff --git a/interface/wx/headerctrl.h b/interface/wx/headerctrl.h index ce8dd8b2ca..1feaa0d01f 100644 --- a/interface/wx/headerctrl.h +++ b/interface/wx/headerctrl.h @@ -337,6 +337,18 @@ protected: meaning that the control didn't reach to the separator double click. */ virtual bool UpdateColumnWidthToFit(unsigned int idx, int widthTitle); + + /** + Can be overridden in the derived class to update internal data + structures when the number of the columns in the control changes. + + This method is called by SetColumnCount() before effectively changing + the number of columns. + + The base class version does nothing but it is good practice to still + call it from the overridden version in the derived class. + */ + virtual void OnColumnCountChanging(unsigned int count); }; diff --git a/src/common/headerctrlcmn.cpp b/src/common/headerctrlcmn.cpp index 2cc69b4566..75239d8151 100644 --- a/src/common/headerctrlcmn.cpp +++ b/src/common/headerctrlcmn.cpp @@ -64,6 +64,13 @@ void wxHeaderCtrlBase::ScrollWindow(int dx, DoScrollHorz(dx); } +void wxHeaderCtrlBase::SetColumnCount(unsigned int count) +{ + OnColumnCountChanging(count); + + DoSetCount(count); +} + // ---------------------------------------------------------------------------- // wxHeaderCtrlBase event handling // ---------------------------------------------------------------------------- -- 2.45.2