diff --git a/interface/wx/grid.h b/interface/wx/grid.h index 27690c953a..ec87b3c6bc 100644 --- a/interface/wx/grid.h +++ b/interface/wx/grid.h @@ -2511,7 +2511,17 @@ public: /** Hides the column labels by calling SetColLabelSize() with a size of 0. - Show labels again by calling that method with a width greater than 0. + + The labels can be shown again by calling SetColLabelSize() with a + height greater than 0. + + Note that when the column labels are hidden, the grid won't have any + visible border on the top side, which may result in a less than ideal + appearance. Because of this, you may want to create the grid window + with a border style, such as @c wxBORDER_SIMPLE, when you don't plan to + show the column labels for it. + + @see HideRowLabels() */ void HideColLabels(); @@ -2520,6 +2530,9 @@ public: The labels can be shown again by calling SetRowLabelSize() with a width greater than 0. + + See HideColLabels() for a note explaining why you may want to use a + border with a grid without the row labels. */ void HideRowLabels(); diff --git a/src/generic/grid.cpp b/src/generic/grid.cpp index f79ad3035a..6f6fb05e2d 100644 --- a/src/generic/grid.cpp +++ b/src/generic/grid.cpp @@ -228,55 +228,101 @@ void wxGridHeaderLabelsRenderer::DrawLabel(const wxGrid& grid, int textOrientation) const { dc.SetBackgroundMode(wxBRUSHSTYLE_TRANSPARENT); - dc.SetTextForeground(grid.GetLabelTextColour()); dc.SetFont(grid.GetLabelFont()); + + // Draw text in a different colour and with a shadow when the control + // is disabled. + // + // Note that the colours used here are consistent with wxGenericStaticText + // rather than our own wxGridCellStringRenderer::SetTextColoursAndFont() + // because this results in a better disabled appearance for the default + // bold font used for the labels. + wxColour colText; + if ( !grid.IsThisEnabled() ) + { + colText = wxSystemSettings::GetColour(wxSYS_COLOUR_BTNHIGHLIGHT); + dc.SetTextForeground(colText); + + wxRect rectShadow = rect; + rectShadow.Offset(1, 1); + grid.DrawTextRectangle(dc, value, rectShadow, + horizAlign, vertAlign, textOrientation); + + colText = wxSystemSettings::GetColour(wxSYS_COLOUR_BTNSHADOW); + } + else + { + colText = grid.GetLabelTextColour(); + } + + dc.SetTextForeground(colText); + grid.DrawTextRectangle(dc, value, rect, horizAlign, vertAlign, textOrientation); } -void wxGridRowHeaderRendererDefault::DrawBorder(const wxGrid& WXUNUSED(grid), +void wxGridRowHeaderRendererDefault::DrawBorder(const wxGrid& 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()); + // Only draw the external borders when the containing control doesn't have + // any border, otherwise they would compound with the outer border which + // looks bad. + int ofs = 0; + if ( grid.GetBorder() == wxBORDER_NONE ) + { + dc.DrawLine(rect.GetLeft(), rect.GetTop(), + rect.GetLeft(), rect.GetBottom()); + + ofs = 1; + } + dc.SetPen(*wxWHITE_PEN); - dc.DrawLine(rect.GetLeft() + 1, rect.GetTop(), - rect.GetLeft() + 1, rect.GetBottom()); - dc.DrawLine(rect.GetLeft() + 1, rect.GetTop(), + dc.DrawLine(rect.GetLeft() + ofs, rect.GetTop(), + rect.GetLeft() + ofs, rect.GetBottom()); + dc.DrawLine(rect.GetLeft() + ofs, rect.GetTop(), rect.GetRight(), rect.GetTop()); - rect.Deflate(2); + rect.Deflate(1 + ofs); } -void wxGridColumnHeaderRendererDefault::DrawBorder(const wxGrid& WXUNUSED(grid), +void wxGridColumnHeaderRendererDefault::DrawBorder(const wxGrid& 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); + // As above, don't draw the outer border if the control has its own one. + int ofs = 0; + if ( grid.GetBorder() == wxBORDER_NONE ) + { + dc.DrawLine(rect.GetLeft(), rect.GetTop(), + rect.GetRight(), rect.GetTop()); - rect.Deflate(2); + ofs = 1; + } + + dc.SetPen(*wxWHITE_PEN); + dc.DrawLine(rect.GetLeft(), rect.GetTop() + ofs, + rect.GetLeft(), rect.GetBottom()); + dc.DrawLine(rect.GetLeft(), rect.GetTop() + ofs, + rect.GetRight(), rect.GetTop() + ofs); + + rect.Deflate(1 + ofs); } -void wxGridCornerHeaderRendererDefault::DrawBorder(const wxGrid& WXUNUSED(grid), +void wxGridCornerHeaderRendererDefault::DrawBorder(const wxGrid& grid, wxDC& dc, wxRect& rect) const { @@ -285,18 +331,27 @@ void wxGridCornerHeaderRendererDefault::DrawBorder(const wxGrid& WXUNUSED(grid), 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()); + + // As above, don't draw either of outer border if there is already a border + // around the entire window. + int ofs = 0; + if ( grid.GetBorder() == wxBORDER_NONE ) + { + dc.DrawLine(rect.GetLeft(), rect.GetTop(), + rect.GetRight(), rect.GetTop()); + dc.DrawLine(rect.GetLeft(), rect.GetTop(), + rect.GetLeft(), rect.GetBottom()); + + ofs = 1; + } 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); + dc.DrawLine(rect.GetLeft() + 1, rect.GetTop() + ofs, + rect.GetRight() - 1, rect.GetTop() + ofs); + dc.DrawLine(rect.GetLeft() + ofs, rect.GetTop() + ofs, + rect.GetLeft() + ofs, rect.GetBottom() - 1); - rect.Deflate(2); + rect.Deflate(1 + ofs); } // ----------------------------------------------------------------------------