From d7fed302a3e0fe75b653e45884450d62ca81e0af Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sun, 9 Jun 2019 00:02:27 +0200 Subject: [PATCH] Grey out wxGrid row/column labels when it is disabled Grid contents was drawn in grey colour instead of the usual active one when it was disabled, but the row and column labels kept their default appearance, which looked out of place. Fix this by greying them out too. This should have been arguably done in 73145b0ed18e99b66988c3caf6ad9119911913bb ~17 years ago, but better late than never. --- src/generic/grid.cpp | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/src/generic/grid.cpp b/src/generic/grid.cpp index f79ad3035a..4c80962545 100644 --- a/src/generic/grid.cpp +++ b/src/generic/grid.cpp @@ -228,8 +228,35 @@ 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); }