]> git.saurik.com Git - wxWidgets.git/commitdiff
allow customization of individual grid lines appearance (patch 1496015)
authorVadim Zeitlin <vadim@wxwidgets.org>
Mon, 24 Jul 2006 23:16:37 +0000 (23:16 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Mon, 24 Jul 2006 23:16:37 +0000 (23:16 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@40291 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

docs/changes.txt
docs/latex/wx/grid.tex
include/wx/generic/grid.h
src/generic/grid.cpp

index 9efa044396a672617bc899b34270f52045d1d511..6b6668c5452fa28b8f2f2c56bcd3e56e6ac71eb2 100644 (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:
 
index de383355c7863c5472fc469bb6750a0beb870450..0fdfd59eb69e01ea0cf201757db2bced2bcd87d7 100644 (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}
index a262d1b9538387a899c2bfa6fed39a533d70238d..5631332d215543e40789ad078f71bb247bda28d7 100644 (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; }
index 284143a62ecf731a087cd51ffeb3b060eb629a88..7be6a92d1f84fe0ecdd86736b5bba21e6fefbd51 100644 (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 );
         }
     }