allow customization of individual grid lines appearance (patch 1496015)

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@40291 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin 2006-07-24 23:16:37 +00:00
parent be085544e9
commit 3d3f3e3749
4 changed files with 82 additions and 2 deletions

View File

@ -164,6 +164,7 @@ All (GUI):
- wxNB_HITTEST_* flags renamed to wxBK_HITTEST_* to serve all book controls.
- Added wxTopLevelWindow::SetTransparent and CanSetTransparent, with
implementations (so far) for wxMSW and wxMac.
- Allow customizing individual grid lines appearance (Søren Lassen)
wxMSW:

View File

@ -845,6 +845,62 @@ Returns the current grid cell row position.
Returns the colour used for grid lines.
\wxheading{See also}
\helpref{GetDefaultGridLinePen()}{wxgridgetdefaultgridlinepen}
\membersection{wxGrid::GetDefaultGridLinePen}\label{wxgridgetdefaultgridlinepen}
\func{wxPen}{GetDefaultGridLinePen}{\void}
Returns the pen used for grid lines. This virtual function may be overridden in
derived classes in order to change the appearance of grid lines. Note that
currently the pen width must be $1$.
\wxheading{See also}
\helpref{GetColGridLinePen()}{wxgridgetcolgridlinepen},\\
\helpref{GetRowGridLinePen()}{wxgridgetrowgridlinepen}
\membersection{wxGrid::GetRowGridLinePen}\label{wxgridgetrowgridlinepen}
\func{wxPen}{GetRowGridLinePen}{\param{int }{row}}
Returns the pen used for horizontal grid lines. This virtual function may be
overridden in derived classes in order to change the appearance of individual
grid line for the given row \arg{row}.
Example: \\
\\
\begin{verbatim}
// in a grid displaying music notation, use a solid black pen between
// octaves (C0=row 127, C1=row 115 etc.)
wxPen MidiGrid::GetRowGridLinePen(int row)
{
if ( row%12 == 7 )
return wxPen(*wxBLACK, 1, wxSOLID);
else
return GetDefaultGridLinePen();
}
\end{verbatim}
\membersection{wxGrid::GetColGridLinePen}\label{wxgridgetcolgridlinepen}
\func{wxPen}{GetColGridLinePen}{\param{int }{col}}
Returns the pen used for vertical grid lines. This virtual function may be
overridden in derived classes in order to change the appearance of individual
grid lines for the given column \arg{col}.
See \helpref{GetRowGridLinePen()}{wxgridgetrowgridlinepen} for an example.
\membersection{wxGrid::GridLinesEnabled}\label{wxgridgridlinesenabled}

View File

@ -1282,6 +1282,12 @@ public:
wxString GetRowLabelValue( int row );
wxString GetColLabelValue( int col );
wxColour GetGridLineColour() { return m_gridLineColour; }
// these methods may be overridden to customize individual grid lines
// appearance
virtual wxPen GetDefaultGridLinePen();
virtual wxPen GetRowGridLinePen(int row);
virtual wxPen GetColGridLinePen(int col);
wxColour GetCellHighlightColour() { return m_cellHighlightColour; }
int GetCellHighlightPenWidth() { return m_cellHighlightPenWidth; }
int GetCellHighlightROPenWidth() { return m_cellHighlightROPenWidth; }

View File

@ -7533,6 +7533,21 @@ void wxGrid::DrawCellHighlight( wxDC& dc, const wxGridCellAttr *attr )
#endif
}
wxPen wxGrid::GetDefaultGridLinePen()
{
return wxPen(GetGridLineColour(), 1, wxSOLID);
}
wxPen wxGrid::GetRowGridLinePen(int WXUNUSED(row))
{
return GetDefaultGridLinePen();
}
wxPen wxGrid::GetColGridLinePen(int WXUNUSED(col))
{
return GetDefaultGridLinePen();
}
void wxGrid::DrawCellBorder( wxDC& dc, const wxGridCellCoords& coords )
{
int row = coords.GetRow();
@ -7540,15 +7555,16 @@ void wxGrid::DrawCellBorder( wxDC& dc, const wxGridCellCoords& coords )
if ( GetColWidth(col) <= 0 || GetRowHeight(row) <= 0 )
return;
dc.SetPen( wxPen(GetGridLineColour(), 1, wxSOLID) );
wxRect rect = CellToRect( row, col );
// right hand border
dc.SetPen( GetColGridLinePen(col) );
dc.DrawLine( rect.x + rect.width, rect.y,
rect.x + rect.width, rect.y + rect.height + 1 );
// bottom border
dc.SetPen( GetRowGridLinePen(row) );
dc.DrawLine( rect.x, rect.y + rect.height,
rect.x + rect.width, rect.y + rect.height);
}
@ -7693,7 +7709,6 @@ void wxGrid::DrawAllGridLines( wxDC& dc, const wxRegion & WXUNUSED(reg) )
dc.SetClippingRegion( clippedcells );
dc.SetPen( wxPen(GetGridLineColour(), 1, wxSOLID) );
// horizontal grid lines
//
@ -7709,6 +7724,7 @@ void wxGrid::DrawAllGridLines( wxDC& dc, const wxRegion & WXUNUSED(reg) )
if ( bot >= top )
{
dc.SetPen( GetRowGridLinePen(i) );
dc.DrawLine( left, bot, right, bot );
}
}
@ -7728,6 +7744,7 @@ void wxGrid::DrawAllGridLines( wxDC& dc, const wxRegion & WXUNUSED(reg) )
if ( colRight >= left )
{
dc.SetPen( GetColGridLinePen(i) );
dc.DrawLine( colRight, top, colRight, bottom );
}
}