All (GUI):
- Added support for showing bitmaps in wxButton.
+- Added support for corner, row and column headers renderers to wxGrid.
- wxWindow::SetAutoLayout() now works for all windows, not just panels.
- Support wxListCtrl columns, items and image lists in XRC (Kinaou Hervé).
- Added support for wxFileCtrl to XRC (Kinaou Hervé).
wxDECLARE_NO_COPY_CLASS(wxGridCellEditor);
};
+// ----------------------------------------------------------------------------
+// wxGridHeaderRenderer and company: like wxGridCellRenderer but for headers
+// ----------------------------------------------------------------------------
+
+// Base class for corner window renderer: it is the simplest of all renderers
+// and only has a single function
+class WXDLLIMPEXP_ADV wxGridCornerHeaderRenderer
+{
+public:
+ // Draw the border around the corner window.
+ virtual void DrawBorder(const wxGrid& grid,
+ wxDC& dc,
+ wxRect& rect) const = 0;
+};
+
+
+// Base class for the row/column header cells renderers
+class WXDLLIMPEXP_ADV wxGridHeaderLabelsRenderer
+ : public wxGridCornerHeaderRenderer
+{
+public:
+ // Draw header cell label
+ virtual void DrawLabel(const wxGrid& grid,
+ wxDC& dc,
+ const wxString& value,
+ const wxRect& rect,
+ int horizAlign,
+ int vertAlign,
+ int textOrientation) const;
+};
+
+// Currently the row/column/corner renders don't need any methods other than
+// those already in wxGridHeaderLabelsRenderer but still define separate classes
+// for them for future extensions and also for better type safety (i.e. to
+// avoid inadvertently using a column header renderer for the row headers)
+class WXDLLIMPEXP_ADV wxGridRowHeaderRenderer
+ : public wxGridHeaderLabelsRenderer
+{
+};
+
+class WXDLLIMPEXP_ADV wxGridColumnHeaderRenderer
+ : public wxGridHeaderLabelsRenderer
+{
+};
+
+// Also define the default renderers which are used by wxGridCellAttrProvider
+// by default
+class WXDLLIMPEXP_ADV wxGridRowHeaderRendererDefault
+ : public wxGridRowHeaderRenderer
+{
+public:
+ virtual void DrawBorder(const wxGrid& grid,
+ wxDC& dc,
+ wxRect& rect) const;
+};
+
+// Column header cells renderers
+class WXDLLIMPEXP_ADV wxGridColumnHeaderRendererDefault
+ : public wxGridColumnHeaderRenderer
+{
+public:
+ virtual void DrawBorder(const wxGrid& grid,
+ wxDC& dc,
+ wxRect& rect) const;
+};
+
+// Header corner renderer
+class WXDLLIMPEXP_ADV wxGridCornerHeaderRendererDefault
+ : public wxGridCornerHeaderRenderer
+{
+public:
+ virtual void DrawBorder(const wxGrid& grid,
+ wxDC& dc,
+ wxRect& rect) const;
+};
+
// ----------------------------------------------------------------------------
// wxGridCellAttr: this class can be used to alter the cells appearance in
void UpdateAttrRows( size_t pos, int numRows );
void UpdateAttrCols( size_t pos, int numCols );
+
+ // get renderers for the given row/column header label and the corner
+ // window: unlike cell renderers, these objects are not reference counted
+ // and are never NULL so they are returned by reference
+ virtual const wxGridColumnHeaderRenderer&
+ GetColumnHeaderRenderer(int WXUNUSED(col))
+ {
+ return m_defaultHeaderRenderers.colRenderer;
+ }
+
+ virtual const wxGridRowHeaderRenderer&
+ GetRowHeaderRenderer(int WXUNUSED(row))
+ {
+ return m_defaultHeaderRenderers.rowRenderer;
+ }
+
+ virtual const wxGridCornerHeaderRenderer& GetCornerRenderer()
+ {
+ return m_defaultHeaderRenderers.cornerRenderer;
+ }
+
private:
void InitData();
wxGridCellAttrProviderData *m_data;
+ // this struct simply combines together the default header renderers
+ struct
+ {
+ wxGridColumnHeaderRendererDefault colRenderer;
+ wxGridRowHeaderRendererDefault rowRenderer;
+ wxGridCornerHeaderRendererDefault cornerRenderer;
+ } m_defaultHeaderRenderers;
+
wxDECLARE_NO_COPY_CLASS(wxGridCellAttrProvider);
};
void DrawTextRectangle( wxDC& dc, const wxString&, const wxRect&,
int horizontalAlignment = wxALIGN_LEFT,
int verticalAlignment = wxALIGN_TOP,
- int textOrientation = wxHORIZONTAL );
+ int textOrientation = wxHORIZONTAL ) const;
void DrawTextRectangle( wxDC& dc, const wxArrayString& lines, const wxRect&,
int horizontalAlignment = wxALIGN_LEFT,
int verticalAlignment = wxALIGN_TOP,
- int textOrientation = wxHORIZONTAL );
+ int textOrientation = wxHORIZONTAL ) const;
// Split a string containing newline characters into an array of
friend class wxGridColLabelWindow;
friend class wxGridRowLabelWindow;
friend class wxGridWindow;
+ friend class wxGridHeaderRenderer;
friend class wxGridHeaderCtrl;
private:
+
// implement wxScrolledWindow method to return m_gridWin size
virtual wxSize GetSizeAvailableForScrollTarget(const wxSize& size);
void SetTextColour(const wxColour& colText);
};
+/**
+ Base class for corner window renderer.
+
+ This is the simplest of all header renderers and only has a single
+ function.
+
+ @see wxGridCellAttrProvider::GetCornerRenderer()
+
+ @since 2.9.1
+ */
+class wxGridCornerHeaderRenderer
+{
+public:
+ /**
+ Called by the grid to draw the corner window border.
+
+ This method is responsible for drawing the border inside the given @a
+ rect and adjusting the rectangle size to correspond to the area inside
+ the border, i.e. usually call wxRect::Deflate() to account for the
+ border width.
+
+ @param grid
+ The grid whose corner window is being drawn.
+ @param dc
+ The device context to use for drawing.
+ @param rect
+ Input/output parameter which contains the border rectangle on input
+ and should be updated to contain the area inside the border on
+ function return.
+ */
+ virtual void DrawBorder(const wxGrid& grid,
+ wxDC& dc,
+ wxRect& rect) const = 0;
+};
+/**
+ Common base class for row and column headers renderers.
+
+ @see wxGridColumnHeaderRenderer, wxGridRowHeaderRenderer
+
+ @since 2.9.1
+ */
+class wxGridHeaderLabelsRenderer : public wxGridCornerHeaderRenderer
+{
+public:
+ /**
+ Called by the grid to draw the specified label.
+
+ Notice that the base class DrawBorder() method is called before this
+ one.
+
+ The default implementation uses wxGrid::GetLabelTextColour() and
+ wxGrid::GetLabelFont() to draw the label.
+ */
+ virtual void DrawLabel(const wxGrid& grid,
+ wxDC& dc,
+ const wxString& value,
+ const wxRect& rect,
+ int horizAlign,
+ int vertAlign,
+ int textOrientation) const;
+};
+
+/**
+ Base class for row headers renderer.
+
+ This is the same as wxGridHeaderLabelsRenderer currently but we still use a
+ separate class for it to distinguish it from wxGridColumnHeaderRenderer.
+
+ @see wxGridRowHeaderRendererDefault
+
+ @see wxGridCellAttrProvider::GetRowHeaderRenderer()
+
+ @since 2.9.1
+ */
+class wxGridRowHeaderRenderer : public wxGridHeaderLabelsRenderer
+{
+};
+
+/**
+ Base class for column headers renderer.
+
+ This is the same as wxGridHeaderLabelsRenderer currently but we still use a
+ separate class for it to distinguish it from wxGridRowHeaderRenderer.
+
+ @see wxGridColumnHeaderRendererDefault
+
+ @see wxGridCellAttrProvider::GetColumnHeaderRenderer()
+
+ @since 2.9.1
+ */
+class wxGridColumnHeaderRenderer : public wxGridHeaderLabelsRenderer
+{
+};
+
+/**
+ Default row header renderer.
+
+ You may derive from this class if you need to only override one of its
+ methods (i.e. either DrawLabel() or DrawBorder()) but continue to use the
+ default implementation for the other one.
+
+ @see wxGridColumnHeaderRendererDefault
+
+ @since 2.9.1
+ */
+class wxGridRowHeaderRendererDefault : public wxGridRowHeaderRendererDefault
+{
+public:
+ /// Implement border drawing for the row labels.
+ virtual void DrawBorder(const wxGrid& grid,
+ wxDC& dc,
+ wxRect& rect) const;
+};
+
+/**
+ Default column header renderer.
+
+ @see wxGridRowHeaderRendererDefault
+
+ @since 2.9.1
+ */
+class wxGridColumnHeaderRendererDefault : public wxGridColumnHeaderRenderer
+{
+public:
+ /// Implement border drawing for the column labels.
+ virtual void DrawBorder(const wxGrid& grid,
+ wxDC& dc,
+ wxRect& rect) const;
+};
+
+/**
+ Default corner window renderer.
+
+ @see wxGridColumnHeaderRendererDefault, wxGridRowHeaderRendererDefault
+
+ @since 2.9.1
+ */
+class wxGridCornerHeaderRendererDefault : public wxGridCornerHeaderRenderer
+{
+public:
+ /// Implement border drawing for the corner window.
+ virtual void DrawBorder(const wxGrid& grid,
+ wxDC& dc,
+ wxRect& rect) const;
+};
+
/**
Class providing attributes to be used for the grid cells.
virtual void SetColAttr(wxGridCellAttr *attr, int col);
//@}
+
+ /**
+ Getting header renderers.
+
+ These functions return the renderers for the given row or column header
+ label and the corner window. Unlike cell attributes, these objects are
+ not reference counted and are never @NULL so they are returned by
+ reference and not pointer and DecRef() shouldn't (and can't) be called
+ for them.
+
+ All these functions were added in wxWidgets 2.9.1.
+ */
+ //@{
+
+ /**
+ Return the renderer used for drawing column headers.
+
+ By default wxGridColumnHeaderRendererDefault is returned.
+
+ @see wxGrid::SetUseNativeColLabels(), wxGrid::UseNativeColHeader()
+
+ @since 2.9.1
+ */
+ virtual const wxGridColumnHeaderRenderer& GetColumnHeaderRenderer(int col);
+
+ /**
+ Return the renderer used for drawing row headers.
+
+ By default wxGridRowHeaderRendererDefault is returned.
+
+ @since 2.9.1
+ */
+ virtual const wxGridRowHeaderRenderer& GetRowHeaderRenderer(int row);
+
+ /**
+ Return the renderer used for drawing the corner window.
+
+ By default wxGridCornerHeaderRendererDefault is returned.
+
+ @since 2.9.1
+ */
+ virtual const wxGridCornerHeaderRenderer& GetCornerRenderer();
+
+ //@}
};
#include "../sample.xpm"
#endif
+// Custom renderer that renders column header cells without borders and in
+// italic
+class CustomColumnHeaderRenderer : public wxGridColumnHeaderRenderer
+{
+public:
+ CustomColumnHeaderRenderer(const wxColour& colFg, const wxColour& colBg)
+ : m_colFg(colFg),
+ m_colBg(colBg)
+ {
+ }
+
+ virtual void DrawLabel(const wxGrid& WXUNUSED(grid),
+ wxDC& dc,
+ const wxString& value,
+ const wxRect& rect,
+ int horizAlign,
+ int vertAlign,
+ int WXUNUSED(textOrientation)) const
+ {
+ dc.SetTextForeground(m_colFg);
+ dc.SetFont(wxITALIC_FONT->Bold());
+ dc.DrawLabel(value, rect, horizAlign | vertAlign);
+ }
+
+ virtual void DrawBorder(const wxGrid& WXUNUSED(grid),
+ wxDC& dc,
+ wxRect& rect) const
+ {
+ dc.SetPen(*wxTRANSPARENT_PEN);
+ dc.SetBrush(wxBrush(m_colBg));
+ dc.DrawRectangle(rect);
+ }
+
+private:
+ const wxColour m_colFg, m_colBg;
+
+ wxDECLARE_NO_COPY_CLASS(CustomColumnHeaderRenderer);
+};
+
+// And a custom attributes provider which uses custom column header renderer
+// defined above
+class CustomColumnHeadersProvider : public wxGridCellAttrProvider
+{
+public:
+ // by default custom column renderer is not used, call
+ // UseCustomColHeaders() to enable it
+ CustomColumnHeadersProvider()
+ : m_customOddRenderer(*wxYELLOW, *wxBLUE),
+ m_customEvenRenderer(*wxWHITE, *wxBLACK),
+ m_useCustom(false)
+ {
+ }
+
+ // enable or disable the use of custom renderer for column headers
+ void UseCustomColHeaders(bool use = true) { m_useCustom = use; }
+
+protected:
+ virtual const wxGridColumnHeaderRenderer& GetColumnHeaderRenderer(int col)
+ {
+ // if enabled, use custom renderers
+ if ( m_useCustom )
+ {
+ // and use different ones for odd and even columns -- just to show
+ // that we can
+ return col % 2 ? m_customOddRenderer : m_customEvenRenderer;
+ }
+
+ return wxGridCellAttrProvider::GetColumnHeaderRenderer(col);
+ }
+
+private:
+ CustomColumnHeaderRenderer m_customOddRenderer,
+ m_customEvenRenderer;
+
+ bool m_useCustom;
+
+ wxDECLARE_NO_COPY_CLASS(CustomColumnHeadersProvider);
+};
+
// ----------------------------------------------------------------------------
// wxWin macros
// ----------------------------------------------------------------------------
EVT_MENU( ID_TOGGLECOLMOVING, GridFrame::ToggleColMoving )
EVT_MENU( ID_TOGGLEGRIDSIZING, GridFrame::ToggleGridSizing )
EVT_MENU( ID_TOGGLEGRIDDRAGCELL, GridFrame::ToggleGridDragCell )
- EVT_MENU( ID_TOGGLENATIVEHEADER, GridFrame::ToggleNativeHeader )
+ EVT_MENU( ID_COLNATIVEHEADER, GridFrame::SetNativeColHeader )
+ EVT_MENU( ID_COLDEFAULTHEADER, GridFrame::SetDefaultColHeader )
+ EVT_MENU( ID_COLCUSTOMHEADER, GridFrame::SetCustomColHeader )
EVT_MENU( ID_TOGGLEGRIDLINES, GridFrame::ToggleGridLines )
EVT_MENU( ID_AUTOSIZECOLS, GridFrame::AutoSizeCols )
EVT_MENU( ID_CELLOVERFLOW, GridFrame::CellOverflow )
viewMenu->AppendCheckItem(ID_TOGGLECOLMOVING, "Col drag-&move");
viewMenu->AppendCheckItem(ID_TOGGLEGRIDSIZING, "&Grid drag-resize");
viewMenu->AppendCheckItem(ID_TOGGLEGRIDDRAGCELL, "&Grid drag-cell");
- viewMenu->AppendCheckItem(ID_TOGGLENATIVEHEADER, "&Native column headers");
viewMenu->AppendCheckItem(ID_TOGGLEGRIDLINES, "&Grid Lines");
viewMenu->AppendCheckItem(ID_SET_HIGHLIGHT_WIDTH, "&Set Cell Highlight Width...");
viewMenu->AppendCheckItem(ID_SET_RO_HIGHLIGHT_WIDTH, "&Set Cell RO Highlight Width...");
rowLabelMenu,
wxT("Change alignment of row labels") );
- rowLabelMenu->Append( ID_ROWLABELHORIZALIGN, wxT("&Horizontal") );
- rowLabelMenu->Append( ID_ROWLABELVERTALIGN, wxT("&Vertical") );
+ rowLabelMenu->AppendRadioItem( ID_ROWLABELHORIZALIGN, wxT("&Horizontal") );
+ rowLabelMenu->AppendRadioItem( ID_ROWLABELVERTALIGN, wxT("&Vertical") );
wxMenu *colLabelMenu = new wxMenu;
colLabelMenu,
wxT("Change alignment of col labels") );
- colLabelMenu->Append( ID_COLLABELHORIZALIGN, wxT("&Horizontal") );
- colLabelMenu->Append( ID_COLLABELVERTALIGN, wxT("&Vertical") );
+ colLabelMenu->AppendRadioItem( ID_COLLABELHORIZALIGN, wxT("&Horizontal") );
+ colLabelMenu->AppendRadioItem( ID_COLLABELVERTALIGN, wxT("&Vertical") );
+
+ wxMenu *colHeaderMenu = new wxMenu;
+
+ viewMenu->Append( ID_ROWLABELALIGN, wxT("Col header style"),
+ colHeaderMenu,
+ wxT("Change style of col header") );
+
+ colHeaderMenu->AppendRadioItem( ID_COLDEFAULTHEADER, wxT("&Default") );
+ colHeaderMenu->AppendRadioItem( ID_COLNATIVEHEADER, wxT("&Native") );
+ colHeaderMenu->AppendRadioItem( ID_COLCUSTOMHEADER, wxT("&Custom") );
+
wxMenu *colMenu = new wxMenu;
colMenu->Append( ID_SETLABELCOLOUR, wxT("Set &label colour...") );
wxPoint( 0, 0 ),
wxSize( 400, 300 ) );
+
#if wxUSE_LOG
int gridW = 600, gridH = 300;
int logW = gridW, logH = 100;
// this will create a grid and, by default, an associated grid
// table for strings
grid->CreateGrid( 0, 0 );
+
+ grid->GetTable()->SetAttrProvider(new CustomColumnHeadersProvider());
+
grid->AppendRows(100);
grid->AppendCols(100);
GetMenuBar()->Check( ID_TOGGLECOLMOVING, false );
GetMenuBar()->Check( ID_TOGGLEGRIDSIZING, true );
GetMenuBar()->Check( ID_TOGGLEGRIDDRAGCELL, false );
- GetMenuBar()->Check( ID_TOGGLENATIVEHEADER, false );
GetMenuBar()->Check( ID_TOGGLEGRIDLINES, true );
GetMenuBar()->Check( ID_CELLOVERFLOW, true );
}
GetMenuBar()->IsChecked( ID_TOGGLEGRIDDRAGCELL ) );
}
-void GridFrame::ToggleNativeHeader( wxCommandEvent& WXUNUSED(ev) )
+void GridFrame::SetNativeColHeader( wxCommandEvent& WXUNUSED(ev) )
{
- grid->SetUseNativeColLabels(
- GetMenuBar()->IsChecked( ID_TOGGLENATIVEHEADER ) );
+ CustomColumnHeadersProvider* provider =
+ static_cast<CustomColumnHeadersProvider*>(grid->GetTable()->GetAttrProvider());
+ provider->UseCustomColHeaders(false);
+ grid->SetUseNativeColLabels(true);
}
+void GridFrame::SetCustomColHeader( wxCommandEvent& WXUNUSED(ev) )
+{
+ CustomColumnHeadersProvider* provider =
+ static_cast<CustomColumnHeadersProvider*>(grid->GetTable()->GetAttrProvider());
+ provider->UseCustomColHeaders(true);
+ grid->SetUseNativeColLabels(false);
+}
+
+void GridFrame::SetDefaultColHeader( wxCommandEvent& WXUNUSED(ev) )
+{
+ CustomColumnHeadersProvider* provider =
+ static_cast<CustomColumnHeadersProvider*>(grid->GetTable()->GetAttrProvider());
+ provider->UseCustomColHeaders(false);
+ grid->SetUseNativeColLabels(false);
+}
+
+
void GridFrame::ToggleGridLines( wxCommandEvent& WXUNUSED(ev) )
{
grid->EnableGridLines(
void ToggleColMoving( wxCommandEvent& );
void ToggleGridSizing( wxCommandEvent& );
void ToggleGridDragCell ( wxCommandEvent& );
- void ToggleNativeHeader ( wxCommandEvent& );
+ void SetNativeColHeader ( wxCommandEvent& );
+ void SetCustomColHeader( wxCommandEvent& );
+ void SetDefaultColHeader( wxCommandEvent& );
void ToggleGridLines( wxCommandEvent& );
void AutoSizeCols( wxCommandEvent& );
void CellOverflow( wxCommandEvent& );
ID_TOGGLECOLMOVING,
ID_TOGGLEGRIDSIZING,
ID_TOGGLEGRIDDRAGCELL,
- ID_TOGGLENATIVEHEADER,
ID_TOGGLEGRIDLINES,
ID_AUTOSIZECOLS,
ID_CELLOVERFLOW,
ID_COLLABELALIGN,
ID_COLLABELHORIZALIGN,
ID_COLLABELVERTALIGN,
+ ID_COLDEFAULTHEADER,
+ ID_COLNATIVEHEADER,
+ ID_COLCUSTOMHEADER,
ID_GRIDLINECOLOUR,
ID_INSERTROW,
ID_INSERTCOL,
{
}
+// ----------------------------------------------------------------------------
+// wxGridHeaderLabelsRenderer and related classes
+// ----------------------------------------------------------------------------
+
+void wxGridHeaderLabelsRenderer::DrawLabel(const wxGrid& grid,
+ wxDC& dc,
+ const wxString& value,
+ const wxRect& rect,
+ int horizAlign,
+ int vertAlign,
+ int textOrientation) const
+{
+ dc.SetBackgroundMode(wxBRUSHSTYLE_TRANSPARENT);
+ dc.SetTextForeground(grid.GetLabelTextColour());
+ dc.SetFont(grid.GetLabelFont());
+ grid.DrawTextRectangle(dc, value, rect, horizAlign, vertAlign, textOrientation);
+}
+
+
+void wxGridRowHeaderRendererDefault::DrawBorder(const wxGrid& WXUNUSED(grid),
+ wxDC& dc,
+ wxRect& rect) const
+{
+ dc.SetPen(wxPen(wxSystemSettings::GetColour(wxSYS_COLOUR_3DSHADOW)));
+ dc.DrawLine(rect.GetRight(), rect.GetTop(),
+ rect.GetRight(), rect.GetBottom());
+ dc.DrawLine(rect.GetLeft(), rect.GetTop(),
+ rect.GetLeft(), rect.GetBottom());
+ dc.DrawLine(rect.GetLeft(), rect.GetBottom(),
+ rect.GetRight() + 1, rect.GetBottom());
+
+ dc.SetPen(*wxWHITE_PEN);
+ dc.DrawLine(rect.GetLeft() + 1, rect.GetTop(),
+ rect.GetLeft() + 1, rect.GetBottom());
+ dc.DrawLine(rect.GetLeft() + 1, rect.GetTop(),
+ rect.GetRight(), rect.GetTop());
+
+ rect.Deflate(2);
+}
+
+void wxGridColumnHeaderRendererDefault::DrawBorder(const wxGrid& WXUNUSED(grid),
+ wxDC& dc,
+ wxRect& rect) const
+{
+ dc.SetPen(wxPen(wxSystemSettings::GetColour(wxSYS_COLOUR_3DSHADOW)));
+ dc.DrawLine(rect.GetRight(), rect.GetTop(),
+ rect.GetRight(), rect.GetBottom());
+ dc.DrawLine(rect.GetLeft(), rect.GetTop(),
+ rect.GetRight(), rect.GetTop());
+ dc.DrawLine(rect.GetLeft(), rect.GetBottom(),
+ rect.GetRight() + 1, rect.GetBottom());
+
+ dc.SetPen(*wxWHITE_PEN);
+ dc.DrawLine(rect.GetLeft(), rect.GetTop() + 1,
+ rect.GetLeft(), rect.GetBottom());
+ dc.DrawLine(rect.GetLeft(), rect.GetTop() + 1,
+ rect.GetRight(), rect.GetTop() + 1);
+
+ rect.Deflate(2);
+}
+
+void wxGridCornerHeaderRendererDefault::DrawBorder(const wxGrid& WXUNUSED(grid),
+ wxDC& dc,
+ wxRect& rect) const
+{
+ dc.SetPen(wxPen(wxSystemSettings::GetColour(wxSYS_COLOUR_3DSHADOW)));
+ dc.DrawLine(rect.GetRight() - 1, rect.GetBottom() - 1,
+ rect.GetRight() - 1, rect.GetTop());
+ dc.DrawLine(rect.GetRight() - 1, rect.GetBottom() - 1,
+ rect.GetLeft(), rect.GetBottom() - 1);
+ dc.DrawLine(rect.GetLeft(), rect.GetTop(),
+ rect.GetRight(), rect.GetTop());
+ dc.DrawLine(rect.GetLeft(), rect.GetTop(),
+ rect.GetLeft(), rect.GetBottom());
+
+ dc.SetPen(*wxWHITE_PEN);
+ dc.DrawLine(rect.GetLeft() + 1, rect.GetTop() + 1,
+ rect.GetRight() - 1, rect.GetTop() + 1);
+ dc.DrawLine(rect.GetLeft() + 1, rect.GetTop() + 1,
+ rect.GetLeft() + 1, rect.GetBottom() - 1);
+
+ rect.Deflate(2);
+}
+
// ----------------------------------------------------------------------------
// wxGridCellAttr
// ----------------------------------------------------------------------------
if ( GetRowHeight(row) <= 0 || m_rowLabelWidth <= 0 )
return;
- wxRect rect;
-
- int rowTop = GetRowTop(row),
- rowBottom = GetRowBottom(row) - 1;
-
- dc.SetPen( wxPen(wxSystemSettings::GetColour(wxSYS_COLOUR_3DSHADOW)));
- dc.DrawLine( m_rowLabelWidth - 1, rowTop, m_rowLabelWidth - 1, rowBottom );
- dc.DrawLine( 0, rowTop, 0, rowBottom );
- dc.DrawLine( 0, rowBottom, m_rowLabelWidth, rowBottom );
-
- dc.SetPen( *wxWHITE_PEN );
- dc.DrawLine( 1, rowTop, 1, rowBottom );
- dc.DrawLine( 1, rowTop, m_rowLabelWidth - 1, rowTop );
-
- dc.SetBackgroundMode( wxBRUSHSTYLE_TRANSPARENT );
- dc.SetTextForeground( GetLabelTextColour() );
- dc.SetFont( GetLabelFont() );
+ const wxGridRowHeaderRenderer&
+ rend = m_table->GetAttrProvider()->GetRowHeaderRenderer(row);
+ wxRect rect(0, GetRowTop(row), m_rowLabelWidth, GetRowHeight(row));
+ rend.DrawBorder(*this, dc, rect);
int hAlign, vAlign;
- GetRowLabelAlignment( &hAlign, &vAlign );
+ GetRowLabelAlignment(&hAlign, &vAlign);
- rect.SetX( 2 );
- rect.SetY( GetRowTop(row) + 2 );
- rect.SetWidth( m_rowLabelWidth - 4 );
- rect.SetHeight( GetRowHeight(row) - 4 );
- DrawTextRectangle( dc, GetRowLabelValue( row ), rect, hAlign, vAlign );
+ rend.DrawLabel(*this, dc, GetRowLabelValue(row),
+ rect, hAlign, vAlign, wxHORIZONTAL);
}
void wxGrid::UseNativeColHeader(bool native)
void wxGrid::DrawCornerLabel(wxDC& dc)
{
+ wxRect rect(wxSize(m_rowLabelWidth, m_colLabelHeight));
+
if ( m_nativeColumnLabels )
{
- wxRect rect(wxSize(m_rowLabelWidth, m_colLabelHeight));
rect.Deflate(1);
wxRendererNative::Get().DrawHeaderButton(m_cornerLabelWin, dc, rect, 0);
}
else
{
- dc.SetPen(wxPen(wxSystemSettings::GetColour(wxSYS_COLOUR_3DSHADOW)));
- dc.DrawLine( m_rowLabelWidth - 1, m_colLabelHeight - 1,
- m_rowLabelWidth - 1, 0 );
- dc.DrawLine( m_rowLabelWidth - 1, m_colLabelHeight - 1,
- 0, m_colLabelHeight - 1 );
- dc.DrawLine( 0, 0, m_rowLabelWidth, 0 );
- dc.DrawLine( 0, 0, 0, m_colLabelHeight );
+ rect.width++;
+ rect.height++;
- dc.SetPen( *wxWHITE_PEN );
- dc.DrawLine( 1, 1, m_rowLabelWidth - 1, 1 );
- dc.DrawLine( 1, 1, 1, m_colLabelHeight - 1 );
+ const wxGridCornerHeaderRenderer&
+ rend = m_table->GetAttrProvider()->GetCornerRenderer();
+
+ rend.DrawBorder(*this, dc, rect);
}
}
int colLeft = GetColLeft(col);
wxRect rect(colLeft, 0, GetColWidth(col), m_colLabelHeight);
+ const wxGridColumnHeaderRenderer&
+ rend = m_table->GetAttrProvider()->GetColumnHeaderRenderer(col);
if ( m_nativeColumnLabels )
{
: wxHDR_SORT_ICON_DOWN
: wxHDR_SORT_ICON_NONE
);
+ rect.Deflate(2);
}
else
{
- int colRight = GetColRight(col) - 1;
-
- dc.SetPen(wxPen(wxSystemSettings::GetColour(wxSYS_COLOUR_3DSHADOW)));
- dc.DrawLine( colRight, 0,
- colRight, m_colLabelHeight - 1 );
- dc.DrawLine( colLeft, 0,
- colRight, 0 );
- dc.DrawLine( colLeft, m_colLabelHeight - 1,
- colRight + 1, m_colLabelHeight - 1 );
-
- dc.SetPen( *wxWHITE_PEN );
- dc.DrawLine( colLeft, 1, colLeft, m_colLabelHeight - 1 );
- dc.DrawLine( colLeft, 1, colRight, 1 );
+ rend.DrawBorder(*this, dc, rect);
}
- dc.SetBackgroundMode( wxBRUSHSTYLE_TRANSPARENT );
- dc.SetTextForeground( GetLabelTextColour() );
- dc.SetFont( GetLabelFont() );
-
int hAlign, vAlign;
- GetColLabelAlignment( &hAlign, &vAlign );
+ GetColLabelAlignment(&hAlign, &vAlign);
const int orient = GetColLabelTextOrientation();
- rect.Deflate(2);
- DrawTextRectangle(dc, GetColLabelValue(col), rect, hAlign, vAlign, orient);
+ rend.DrawLabel(*this, dc, GetColLabelValue(col), rect, hAlign, vAlign, orient);
}
// TODO: these 2 functions should be replaced with wxDC::DrawLabel() to which
const wxRect& rect,
int horizAlign,
int vertAlign,
- int textOrientation )
+ int textOrientation ) const
{
wxArrayString lines;
const wxRect& rect,
int horizAlign,
int vertAlign,
- int textOrientation)
+ int textOrientation) const
{
if ( lines.empty() )
return;