+ }
+}
+
+void wxGrid::SetGridLineColour( const wxColour& colour )
+{
+ if ( m_gridLineColour != colour )
+ {
+ m_gridLineColour = colour;
+
+ if ( GridLinesEnabled() )
+ RedrawGridLines();
+ }
+}
+
+void wxGrid::SetCellHighlightColour( const wxColour& colour )
+{
+ if ( m_cellHighlightColour != colour )
+ {
+ m_cellHighlightColour = colour;
+
+ wxClientDC dc( m_gridWin );
+ PrepareDC( dc );
+ wxGridCellAttr* attr = GetCellAttr(m_currentCellCoords);
+ DrawCellHighlight(dc, attr);
+ attr->DecRef();
+ }
+}
+
+void wxGrid::SetCellHighlightPenWidth(int width)
+{
+ if (m_cellHighlightPenWidth != width)
+ {
+ m_cellHighlightPenWidth = width;
+
+ // Just redrawing the cell highlight is not enough since that won't
+ // make any visible change if the the thickness is getting smaller.
+ int row = m_currentCellCoords.GetRow();
+ int col = m_currentCellCoords.GetCol();
+ if ( row == -1 || col == -1 || GetColWidth(col) <= 0 || GetRowHeight(row) <= 0 )
+ return;
+
+ wxRect rect = CellToRect(row, col);
+ m_gridWin->Refresh(true, &rect);
+ }
+}
+
+void wxGrid::SetCellHighlightROPenWidth(int width)
+{
+ if (m_cellHighlightROPenWidth != width)
+ {
+ m_cellHighlightROPenWidth = width;
+
+ // Just redrawing the cell highlight is not enough since that won't
+ // make any visible change if the the thickness is getting smaller.
+ int row = m_currentCellCoords.GetRow();
+ int col = m_currentCellCoords.GetCol();
+ if ( row == -1 || col == -1 ||
+ GetColWidth(col) <= 0 || GetRowHeight(row) <= 0 )
+ return;
+
+ wxRect rect = CellToRect(row, col);
+ m_gridWin->Refresh(true, &rect);
+ }
+}
+
+void wxGrid::RedrawGridLines()
+{
+ // the lines will be redrawn when the window is thawn
+ if ( GetBatchCount() )
+ return;
+
+ if ( GridLinesEnabled() )
+ {
+ wxClientDC dc( m_gridWin );
+ PrepareDC( dc );
+ DrawAllGridLines( dc, wxRegion() );
+ }
+ else // remove the grid lines
+ {
+ m_gridWin->Refresh();
+ }
+}
+
+void wxGrid::EnableGridLines( bool enable )
+{
+ if ( enable != m_gridLinesEnabled )
+ {
+ m_gridLinesEnabled = enable;
+
+ RedrawGridLines();
+ }
+}
+
+void wxGrid::DoClipGridLines(bool& var, bool clip)
+{
+ if ( clip != var )
+ {
+ var = clip;
+
+ if ( GridLinesEnabled() )
+ RedrawGridLines();
+ }
+}
+
+int wxGrid::GetDefaultRowSize() const
+{
+ return m_defaultRowHeight;
+}
+
+int wxGrid::GetRowSize( int row ) const
+{
+ wxCHECK_MSG( row >= 0 && row < m_numRows, 0, _T("invalid row index") );
+
+ return GetRowHeight(row);
+}
+
+int wxGrid::GetDefaultColSize() const
+{
+ return m_defaultColWidth;
+}
+
+int wxGrid::GetColSize( int col ) const
+{
+ wxCHECK_MSG( col >= 0 && col < m_numCols, 0, _T("invalid column index") );
+
+ return GetColWidth(col);
+}
+
+// ============================================================================
+// access to the grid attributes: each of them has a default value in the grid
+// itself and may be overidden on a per-cell basis
+// ============================================================================
+
+// ----------------------------------------------------------------------------
+// setting default attributes
+// ----------------------------------------------------------------------------
+
+void wxGrid::SetDefaultCellBackgroundColour( const wxColour& col )
+{
+ m_defaultCellAttr->SetBackgroundColour(col);
+#ifdef __WXGTK__
+ m_gridWin->SetBackgroundColour(col);
+#endif
+}
+
+void wxGrid::SetDefaultCellTextColour( const wxColour& col )
+{
+ m_defaultCellAttr->SetTextColour(col);
+}
+
+void wxGrid::SetDefaultCellAlignment( int horiz, int vert )
+{
+ m_defaultCellAttr->SetAlignment(horiz, vert);
+}
+
+void wxGrid::SetDefaultCellOverflow( bool allow )
+{
+ m_defaultCellAttr->SetOverflow(allow);
+}
+
+void wxGrid::SetDefaultCellFont( const wxFont& font )
+{
+ m_defaultCellAttr->SetFont(font);
+}
+
+// For editors and renderers the type registry takes precedence over the
+// default attr, so we need to register the new editor/renderer for the string
+// data type in order to make setting a default editor/renderer appear to
+// work correctly.
+
+void wxGrid::SetDefaultRenderer(wxGridCellRenderer *renderer)
+{
+ RegisterDataType(wxGRID_VALUE_STRING,
+ renderer,
+ GetDefaultEditorForType(wxGRID_VALUE_STRING));
+}
+
+void wxGrid::SetDefaultEditor(wxGridCellEditor *editor)
+{
+ RegisterDataType(wxGRID_VALUE_STRING,
+ GetDefaultRendererForType(wxGRID_VALUE_STRING),
+ editor);
+}
+
+// ----------------------------------------------------------------------------
+// access to the default attributes
+// ----------------------------------------------------------------------------
+
+wxColour wxGrid::GetDefaultCellBackgroundColour() const
+{
+ return m_defaultCellAttr->GetBackgroundColour();
+}
+
+wxColour wxGrid::GetDefaultCellTextColour() const
+{
+ return m_defaultCellAttr->GetTextColour();
+}
+
+wxFont wxGrid::GetDefaultCellFont() const
+{
+ return m_defaultCellAttr->GetFont();
+}
+
+void wxGrid::GetDefaultCellAlignment( int *horiz, int *vert ) const
+{
+ m_defaultCellAttr->GetAlignment(horiz, vert);
+}
+
+bool wxGrid::GetDefaultCellOverflow() const
+{
+ return m_defaultCellAttr->GetOverflow();
+}
+
+wxGridCellRenderer *wxGrid::GetDefaultRenderer() const
+{
+ return m_defaultCellAttr->GetRenderer(NULL, 0, 0);
+}
+
+wxGridCellEditor *wxGrid::GetDefaultEditor() const
+{
+ return m_defaultCellAttr->GetEditor(NULL, 0, 0);
+}
+
+// ----------------------------------------------------------------------------
+// access to cell attributes
+// ----------------------------------------------------------------------------
+
+wxColour wxGrid::GetCellBackgroundColour(int row, int col) const
+{
+ wxGridCellAttr *attr = GetCellAttr(row, col);
+ wxColour colour = attr->GetBackgroundColour();
+ attr->DecRef();
+
+ return colour;
+}
+
+wxColour wxGrid::GetCellTextColour( int row, int col ) const
+{
+ wxGridCellAttr *attr = GetCellAttr(row, col);
+ wxColour colour = attr->GetTextColour();
+ attr->DecRef();
+
+ return colour;
+}
+
+wxFont wxGrid::GetCellFont( int row, int col ) const
+{
+ wxGridCellAttr *attr = GetCellAttr(row, col);
+ wxFont font = attr->GetFont();
+ attr->DecRef();
+
+ return font;
+}