From fc0108ce71c870059271a7bb1c56e5a91c8c7746 Mon Sep 17 00:00:00 2001 From: Damien Ruscoe Date: Sat, 9 Jul 2016 15:32:34 +0200 Subject: [PATCH] Hide empty wxCheckBoxes in wxGTK to fix display problem Focus rectangle was still drawn around the label when it was empty with some themes, so hide it completely to ensure this doesn't happen. Closes #17443. --- docs/changes.txt | 1 + src/gtk/checkbox.cpp | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/docs/changes.txt b/docs/changes.txt index cba00d6460..1b8ee90d70 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -101,6 +101,7 @@ wxGTK: - Support background colour in wxDataViewCtrl attributes. - Improve wxSpinCtrl best size calculation. - Implement support for icon locations in wxMimeTypesManager (Hanmac). +- Cosmetic fix for empty wxCheckBoxes display (Chuddah). wxMSW: diff --git a/src/gtk/checkbox.cpp b/src/gtk/checkbox.cpp index 166d37cf02..997f81fb55 100644 --- a/src/gtk/checkbox.cpp +++ b/src/gtk/checkbox.cpp @@ -204,6 +204,13 @@ void wxCheckBox::SetLabel( const wxString& label ) { wxCHECK_RET( m_widgetLabel != NULL, wxT("invalid checkbox") ); + // If we don't hide the empty label, in some themes a focus rectangle is + // still drawn around it and this looks out of place. + if ( label.empty() ) + gtk_widget_hide(m_widgetLabel); + else + gtk_widget_show(m_widgetLabel); + // save the label inside m_label in case user calls GetLabel() later wxControl::SetLabel(label);