From 482d06f8b5917f9ba0bf1b5623a70262220aed52 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Wed, 17 Dec 2008 00:11:57 +0000 Subject: [PATCH] made wxHeaderCtrl::GetColumn() const to get rid of the const_cast<>s git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@57380 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/headerctrl.h | 4 ++-- interface/wx/headerctrl.h | 4 ++-- src/common/headerctrlcmn.cpp | 2 +- src/generic/datavgen.cpp | 2 +- src/generic/grid.cpp | 2 +- src/generic/headerctrlg.cpp | 10 +++------- 6 files changed, 10 insertions(+), 14 deletions(-) diff --git a/include/wx/headerctrl.h b/include/wx/headerctrl.h index 0d7dc125d6..a95d094cb3 100644 --- a/include/wx/headerctrl.h +++ b/include/wx/headerctrl.h @@ -154,7 +154,7 @@ public: protected: // this method must be implemented by the derived classes to return the // information for the given column - virtual wxHeaderColumn& GetColumn(unsigned int idx) = 0; + virtual const wxHeaderColumn& GetColumn(unsigned int idx) const = 0; // this method is called from the default EVT_HEADER_SEPARATOR_DCLICK // handler to update the fitting column width of the given column, it @@ -311,7 +311,7 @@ public: protected: // implement/override base class methods - virtual wxHeaderColumn& GetColumn(unsigned int idx); + virtual const wxHeaderColumn& GetColumn(unsigned int idx) const; virtual bool UpdateColumnWidthToFit(unsigned int idx, int widthTitle); // and define another one to be overridden in the derived classes: it diff --git a/interface/wx/headerctrl.h b/interface/wx/headerctrl.h index 7f3a5ee756..02eed62ee4 100644 --- a/interface/wx/headerctrl.h +++ b/interface/wx/headerctrl.h @@ -354,7 +354,7 @@ protected: The column index, between 0 and the value last passed to SetColumnCount(). */ - virtual wxHeaderColumnBase& GetColumn(unsigned int idx) = 0; + virtual const wxHeaderColumnBase& GetColumn(unsigned int idx) const = 0; /** Method called when the column visibility is changed by the user. @@ -426,7 +426,7 @@ protected: { public: protected: - virtual wxHeaderColumnBase& GetColumn(unsigned int idx) + virtual wxHeaderColumnBase& GetColumn(unsigned int idx) const { return m_cols[idx]; } diff --git a/src/common/headerctrlcmn.cpp b/src/common/headerctrlcmn.cpp index 51282c560c..bc5fd71f60 100644 --- a/src/common/headerctrlcmn.cpp +++ b/src/common/headerctrlcmn.cpp @@ -366,7 +366,7 @@ void wxHeaderCtrlSimple::Init() m_sortKey = wxNO_COLUMN; } -wxHeaderColumn& wxHeaderCtrlSimple::GetColumn(unsigned int idx) +const wxHeaderColumn& wxHeaderCtrlSimple::GetColumn(unsigned int idx) const { return m_cols[idx]; } diff --git a/src/generic/datavgen.cpp b/src/generic/datavgen.cpp index ca25072179..254507c2e6 100644 --- a/src/generic/datavgen.cpp +++ b/src/generic/datavgen.cpp @@ -91,7 +91,7 @@ public: protected: // implement/override wxHeaderCtrl functions by forwarding them to the main // control - virtual wxHeaderColumn& GetColumn(unsigned int idx) + virtual const wxHeaderColumn& GetColumn(unsigned int idx) const { return *(GetOwner()->GetColumn(idx)); } diff --git a/src/generic/grid.cpp b/src/generic/grid.cpp index a49d972c5c..1b1ed6c604 100644 --- a/src/generic/grid.cpp +++ b/src/generic/grid.cpp @@ -230,7 +230,7 @@ public: } protected: - virtual wxHeaderColumn& GetColumn(unsigned int idx) + virtual const wxHeaderColumn& GetColumn(unsigned int idx) const { return m_columns[idx]; } diff --git a/src/generic/headerctrlg.cpp b/src/generic/headerctrlg.cpp index 8f2c919f08..37d848fc18 100644 --- a/src/generic/headerctrlg.cpp +++ b/src/generic/headerctrlg.cpp @@ -145,8 +145,6 @@ wxSize wxHeaderCtrl::DoGetBestSize() const int wxHeaderCtrl::GetColStart(unsigned int idx) const { - wxHeaderCtrl * const self = const_cast(this); - int pos = m_scrollOffset; for ( unsigned n = 0; ; n++ ) { @@ -154,7 +152,7 @@ int wxHeaderCtrl::GetColStart(unsigned int idx) const if ( i == idx ) break; - const wxHeaderColumn& col = self->GetColumn(i); + const wxHeaderColumn& col = GetColumn(i); if ( col.IsShown() ) pos += col.GetWidth(); } @@ -166,19 +164,17 @@ int wxHeaderCtrl::GetColEnd(unsigned int idx) const { int x = GetColStart(idx); - return x + const_cast(this)->GetColumn(idx).GetWidth(); + return x + GetColumn(idx).GetWidth(); } unsigned int wxHeaderCtrl::FindColumnAtPoint(int x, bool *onSeparator) const { - wxHeaderCtrl * const self = const_cast(this); - int pos = 0; const unsigned count = GetColumnCount(); for ( unsigned n = 0; n < count; n++ ) { const unsigned idx = m_colIndices[n]; - const wxHeaderColumn& col = self->GetColumn(idx); + const wxHeaderColumn& col = GetColumn(idx); if ( col.IsHidden() ) continue; -- 2.45.2