renamed GetColHeader() to GetGridColHeader() for consistency with the other existing accessors (even if this is redundant) and made it public/documented (also documented the others)

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@57353 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2008-12-15 10:34:04 +00:00
parent 22f4180e59
commit 3039ade95d
3 changed files with 88 additions and 22 deletions

View File

@@ -1747,6 +1747,17 @@ public:
wxWindow* GetGridColLabelWindow() const { return m_colWindow; } wxWindow* GetGridColLabelWindow() const { return m_colWindow; }
wxWindow* GetGridCornerLabelWindow() const { return (wxWindow*)m_cornerLabelWin; } wxWindow* GetGridCornerLabelWindow() const { return (wxWindow*)m_cornerLabelWin; }
// This one can only be called if we are using the native header window
wxHeaderCtrl *GetGridColHeader() const
{
wxASSERT_MSG( m_useNativeHeader, "no column header window" );
// static_cast<> doesn't work without the full class declaration in
// view and we prefer to avoid adding more compile-time dependencies
// even at the cost of using reinterpret_cast<>
return reinterpret_cast<wxHeaderCtrl *>(m_colWindow);
}
// Allow adjustment of scroll increment. The default is (15, 15). // Allow adjustment of scroll increment. The default is (15, 15).
void SetScrollLineX(int x) { m_scrollLineX = x; } void SetScrollLineX(int x) { m_scrollLineX = x; }
void SetScrollLineY(int y) { m_scrollLineY = y; } void SetScrollLineY(int y) { m_scrollLineY = y; }
@@ -1970,16 +1981,6 @@ protected:
// wxGridColLabelWindow, use accessors below when the real type matters // wxGridColLabelWindow, use accessors below when the real type matters
wxWindow *m_colWindow; wxWindow *m_colWindow;
wxHeaderCtrl *GetColHeader() const
{
wxASSERT_MSG( m_useNativeHeader, "no column header window" );
// static_cast<> doesn't work without the full class declaration in
// view and we prefer to avoid adding more compile-time dependencies
// even at the cost of using reinterpret_cast<>
return reinterpret_cast<wxHeaderCtrl *>(m_colWindow);
}
wxGridColLabelWindow *GetColLabelWindow() const wxGridColLabelWindow *GetColLabelWindow() const
{ {
wxASSERT_MSG( !m_useNativeHeader, "no column label window" ); wxASSERT_MSG( !m_useNativeHeader, "no column label window" );

View File

@@ -3166,6 +3166,71 @@ protected:
*/ */
void UnsetSortingColumn(); void UnsetSortingColumn();
//@} //@}
/**
@name Accessors for component windows.
Return the various child windows of wxGrid.
wxGrid is an empty parent window for 4 children representing the column
labels window (top), the row labels window (left), the corner window
(top left) and the main grid window. It may be necessary to use these
individual windows and not the wxGrid window itself if you need to
handle events for them (this can be done using wxEvtHandler::Connect()
or wxWindow::PushEventHandler()) or do something else requiring the use
of the correct window pointer. Notice that you should not, however,
change these windows (e.g. reposition them or draw over them) because
they are managed by wxGrid itself.
*/
//@{
/**
Return the main grid window containing the grid cells.
This window is always shown.
*/
wxWindow *GetGridWindow() const;
/**
Return the row labels window.
This window is not shown if the row labels were hidden using
HideRowLabels().
*/
wxWindow *GetGridRowLabelWindow() const;
/**
Return the column labels window.
This window is not shown if the columns labels were hidden using
HideColLabels().
Depending on whether UseNativeColHeader() was called or not this can be
either a wxHeaderCtrl or a plain wxWindow. This function returns a valid
window pointer in either case but in the former case you can also use
GetGridColHeader() to access it if you need wxHeaderCtrl-specific
functionality.
*/
wxWindow *GetGridWindow() const;
/**
Return the window in the top left grid corner.
This window is shown only of both columns and row labels are shown and
normally doesn't contain anything. Clicking on it is handled by wxGrid
however and can be used to select the entire grid.
*/
wxWindow *GetGridCornerLabelWindow() const;
/**
Return the header control used for column labels display.
This function can only be called if UseNativeColHeader() had been
called.
*/
wxHeaderCtrl *GetGridColHeader() const;
//@}
}; };

View File

@@ -4806,7 +4806,7 @@ wxGrid::SetTable(wxGridTableBase *table,
m_numCols = table->GetNumberCols(); m_numCols = table->GetNumberCols();
if ( m_useNativeHeader ) if ( m_useNativeHeader )
GetColHeader()->SetColumnCount(m_numCols); GetGridColHeader()->SetColumnCount(m_numCols);
m_table = table; m_table = table;
m_table->SetView( this ); m_table->SetView( this );
@@ -5279,7 +5279,7 @@ bool wxGrid::Redimension( wxGridTableMessage& msg )
m_numCols += numCols; m_numCols += numCols;
if ( m_useNativeHeader ) if ( m_useNativeHeader )
GetColHeader()->SetColumnCount(m_numCols); GetGridColHeader()->SetColumnCount(m_numCols);
if ( !m_colAt.IsEmpty() ) if ( !m_colAt.IsEmpty() )
{ {
@@ -5347,7 +5347,7 @@ bool wxGrid::Redimension( wxGridTableMessage& msg )
int oldNumCols = m_numCols; int oldNumCols = m_numCols;
m_numCols += numCols; m_numCols += numCols;
if ( m_useNativeHeader ) if ( m_useNativeHeader )
GetColHeader()->SetColumnCount(m_numCols); GetGridColHeader()->SetColumnCount(m_numCols);
if ( !m_colAt.IsEmpty() ) if ( !m_colAt.IsEmpty() )
{ {
@@ -5402,7 +5402,7 @@ bool wxGrid::Redimension( wxGridTableMessage& msg )
int numCols = msg.GetCommandInt2(); int numCols = msg.GetCommandInt2();
m_numCols -= numCols; m_numCols -= numCols;
if ( m_useNativeHeader ) if ( m_useNativeHeader )
GetColHeader()->SetColumnCount(m_numCols); GetGridColHeader()->SetColumnCount(m_numCols);
if ( !m_colAt.IsEmpty() ) if ( !m_colAt.IsEmpty() )
{ {
@@ -5863,7 +5863,7 @@ void wxGrid::UpdateColumnSortingIndicator(int col)
wxCHECK_RET( col != wxNOT_FOUND, "invalid column index" ); wxCHECK_RET( col != wxNOT_FOUND, "invalid column index" );
if ( m_useNativeHeader ) if ( m_useNativeHeader )
GetColHeader()->UpdateColumn(col); GetGridColHeader()->UpdateColumn(col);
else if ( m_nativeColumnLabels ) else if ( m_nativeColumnLabels )
m_colWindow->Refresh(); m_colWindow->Refresh();
//else: sorting indicator display not yet implemented in grid version //else: sorting indicator display not yet implemented in grid version
@@ -6863,9 +6863,9 @@ void wxGrid::RefreshAfterColPosChange()
if ( m_useNativeHeader ) if ( m_useNativeHeader )
{ {
if ( m_colAt.empty() ) if ( m_colAt.empty() )
GetColHeader()->ResetColumnsOrder(); GetGridColHeader()->ResetColumnsOrder();
else else
GetColHeader()->SetColumnsOrder(m_colAt); GetGridColHeader()->SetColumnsOrder(m_colAt);
} }
else else
{ {
@@ -6904,7 +6904,7 @@ void wxGrid::EnableDragColMove( bool enable )
if ( m_useNativeHeader ) if ( m_useNativeHeader )
{ {
// update all columns to make them [not] reorderable // update all columns to make them [not] reorderable
GetColHeader()->SetColumnCount(m_numCols); GetGridColHeader()->SetColumnCount(m_numCols);
} }
m_canDragColMove = enable; m_canDragColMove = enable;
@@ -8189,7 +8189,7 @@ void wxGrid::UseNativeColHeader(bool native)
CreateColumnWindow(); CreateColumnWindow();
if ( m_useNativeHeader ) if ( m_useNativeHeader )
GetColHeader()->SetColumnCount(m_numCols); GetGridColHeader()->SetColumnCount(m_numCols);
CalcWindowSizes(); CalcWindowSizes();
} }
@@ -9573,7 +9573,7 @@ void wxGrid::SetColLabelValue( int col, const wxString& s )
{ {
if ( m_useNativeHeader ) if ( m_useNativeHeader )
{ {
GetColHeader()->UpdateColumn(col); GetGridColHeader()->UpdateColumn(col);
} }
else else
{ {
@@ -10414,7 +10414,7 @@ void wxGrid::SetColSize( int col, int width )
const int diff = width - m_colWidths[col]; const int diff = width - m_colWidths[col];
m_colWidths[col] = width; m_colWidths[col] = width;
if ( m_useNativeHeader ) if ( m_useNativeHeader )
GetColHeader()->UpdateColumn(col); GetGridColHeader()->UpdateColumn(col);
//else: will be refreshed when the header is redrawn //else: will be refreshed when the header is redrawn
for ( int colPos = GetColPos(col); colPos < m_numCols; colPos++ ) for ( int colPos = GetColPos(col); colPos < m_numCols; colPos++ )
@@ -10581,7 +10581,7 @@ wxGrid::AutoSizeColOrRow(int colOrRow, bool setAsMin, wxGridDirection direction)
{ {
if ( m_useNativeHeader ) if ( m_useNativeHeader )
{ {
GetColHeader()->UpdateColumn(col); GetGridColHeader()->UpdateColumn(col);
} }
else else
{ {