Fix wxBitmapButon used as wxPG editor button under wxGTK2

wxBitmapButton without inner border should work better with themes
if we reduce inner border in a more GTK-compliant way by applying
a dedicated GTK style to the button.
This commit is contained in:
Artur Wieczorek
2021-02-27 17:10:03 +01:00
parent 9a29ea6e63
commit 04ea7b552a

View File

@@ -2162,28 +2162,36 @@ public:
#if defined(__WXGTK3__) #if defined(__WXGTK3__)
GTKApplyCssStyle("*{ padding:0 }"); GTKApplyCssStyle("*{ padding:0 }");
#else #else
#if !defined( __WXGTK127__ ) // Define a special button style without inner border
GTKApplyWidgetStyle(true); // To enforce call to DoApplyWidgetStyle() // if it's not yet done.
#endif if ( !m_exactFitStyleDefined )
{
gtk_rc_parse_string(
"style \"wxPGEditorBitmapButton_style\"\n"
"{ GtkButton::inner-border = { 0, 0, 0, 0 } }\n"
"widget \"*wxPGEditorBitmapButton*\" style \"wxPGEditorBitmapButton_style\"\n"
);
m_exactFitStyleDefined = true;
}
// Assign the button to the GTK style without inner border.
gtk_widget_set_name(m_widget, "wxPGEditorBitmapButton");
#endif #endif
} }
virtual ~wxPGEditorBitmapButton() { } virtual ~wxPGEditorBitmapButton() { }
protected: private:
virtual void DoApplyWidgetStyle(GtkRcStyle *style) wxOVERRIDE #ifndef __WXGTK3__
{ // To mark if special GTK style was already defined.
if ( style ) static bool m_exactFitStyleDefined;
{ #endif // !__WXGTK3__
#if !defined( __WXGTK127__ )
style->xthickness = 0;
style->ythickness = 0;
#endif
}
wxBitmapButton::DoApplyWidgetStyle(style);
}
}; };
#ifndef __WXGTK3__
bool wxPGEditorBitmapButton::m_exactFitStyleDefined = false;
#endif // !__WXGTK3__
#else // !__WXGTK__ #else // !__WXGTK__
typedef wxBitmapButton wxPGEditorBitmapButton; typedef wxBitmapButton wxPGEditorBitmapButton;