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
This commit is contained in:
Vadim Zeitlin
2008-12-17 00:11:57 +00:00
parent af67f39da8
commit 482d06f8b5
6 changed files with 10 additions and 14 deletions

View File

@@ -154,7 +154,7 @@ public:
protected: protected:
// this method must be implemented by the derived classes to return the // this method must be implemented by the derived classes to return the
// information for the given column // 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 // this method is called from the default EVT_HEADER_SEPARATOR_DCLICK
// handler to update the fitting column width of the given column, it // handler to update the fitting column width of the given column, it
@@ -311,7 +311,7 @@ public:
protected: protected:
// implement/override base class methods // 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); virtual bool UpdateColumnWidthToFit(unsigned int idx, int widthTitle);
// and define another one to be overridden in the derived classes: it // and define another one to be overridden in the derived classes: it

View File

@@ -354,7 +354,7 @@ protected:
The column index, between 0 and the value last passed to The column index, between 0 and the value last passed to
SetColumnCount(). 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. Method called when the column visibility is changed by the user.
@@ -426,7 +426,7 @@ protected:
{ {
public: public:
protected: protected:
virtual wxHeaderColumnBase& GetColumn(unsigned int idx) virtual wxHeaderColumnBase& GetColumn(unsigned int idx) const
{ {
return m_cols[idx]; return m_cols[idx];
} }

View File

@@ -366,7 +366,7 @@ void wxHeaderCtrlSimple::Init()
m_sortKey = wxNO_COLUMN; m_sortKey = wxNO_COLUMN;
} }
wxHeaderColumn& wxHeaderCtrlSimple::GetColumn(unsigned int idx) const wxHeaderColumn& wxHeaderCtrlSimple::GetColumn(unsigned int idx) const
{ {
return m_cols[idx]; return m_cols[idx];
} }

View File

@@ -91,7 +91,7 @@ public:
protected: protected:
// implement/override wxHeaderCtrl functions by forwarding them to the main // implement/override wxHeaderCtrl functions by forwarding them to the main
// control // control
virtual wxHeaderColumn& GetColumn(unsigned int idx) virtual const wxHeaderColumn& GetColumn(unsigned int idx) const
{ {
return *(GetOwner()->GetColumn(idx)); return *(GetOwner()->GetColumn(idx));
} }

View File

@@ -230,7 +230,7 @@ public:
} }
protected: protected:
virtual wxHeaderColumn& GetColumn(unsigned int idx) virtual const wxHeaderColumn& GetColumn(unsigned int idx) const
{ {
return m_columns[idx]; return m_columns[idx];
} }

View File

@@ -145,8 +145,6 @@ wxSize wxHeaderCtrl::DoGetBestSize() const
int wxHeaderCtrl::GetColStart(unsigned int idx) const int wxHeaderCtrl::GetColStart(unsigned int idx) const
{ {
wxHeaderCtrl * const self = const_cast<wxHeaderCtrl *>(this);
int pos = m_scrollOffset; int pos = m_scrollOffset;
for ( unsigned n = 0; ; n++ ) for ( unsigned n = 0; ; n++ )
{ {
@@ -154,7 +152,7 @@ int wxHeaderCtrl::GetColStart(unsigned int idx) const
if ( i == idx ) if ( i == idx )
break; break;
const wxHeaderColumn& col = self->GetColumn(i); const wxHeaderColumn& col = GetColumn(i);
if ( col.IsShown() ) if ( col.IsShown() )
pos += col.GetWidth(); pos += col.GetWidth();
} }
@@ -166,19 +164,17 @@ int wxHeaderCtrl::GetColEnd(unsigned int idx) const
{ {
int x = GetColStart(idx); int x = GetColStart(idx);
return x + const_cast<wxHeaderCtrl *>(this)->GetColumn(idx).GetWidth(); return x + GetColumn(idx).GetWidth();
} }
unsigned int wxHeaderCtrl::FindColumnAtPoint(int x, bool *onSeparator) const unsigned int wxHeaderCtrl::FindColumnAtPoint(int x, bool *onSeparator) const
{ {
wxHeaderCtrl * const self = const_cast<wxHeaderCtrl *>(this);
int pos = 0; int pos = 0;
const unsigned count = GetColumnCount(); const unsigned count = GetColumnCount();
for ( unsigned n = 0; n < count; n++ ) for ( unsigned n = 0; n < count; n++ )
{ {
const unsigned idx = m_colIndices[n]; const unsigned idx = m_colIndices[n];
const wxHeaderColumn& col = self->GetColumn(idx); const wxHeaderColumn& col = GetColumn(idx);
if ( col.IsHidden() ) if ( col.IsHidden() )
continue; continue;