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:
@@ -2162,28 +2162,36 @@ public:
|
||||
#if defined(__WXGTK3__)
|
||||
GTKApplyCssStyle("*{ padding:0 }");
|
||||
#else
|
||||
#if !defined( __WXGTK127__ )
|
||||
GTKApplyWidgetStyle(true); // To enforce call to DoApplyWidgetStyle()
|
||||
#endif
|
||||
// Define a special button style without inner border
|
||||
// if it's not yet done.
|
||||
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
|
||||
}
|
||||
|
||||
virtual ~wxPGEditorBitmapButton() { }
|
||||
|
||||
protected:
|
||||
virtual void DoApplyWidgetStyle(GtkRcStyle *style) wxOVERRIDE
|
||||
{
|
||||
if ( style )
|
||||
{
|
||||
#if !defined( __WXGTK127__ )
|
||||
style->xthickness = 0;
|
||||
style->ythickness = 0;
|
||||
#endif
|
||||
}
|
||||
wxBitmapButton::DoApplyWidgetStyle(style);
|
||||
}
|
||||
private:
|
||||
#ifndef __WXGTK3__
|
||||
// To mark if special GTK style was already defined.
|
||||
static bool m_exactFitStyleDefined;
|
||||
#endif // !__WXGTK3__
|
||||
};
|
||||
|
||||
#ifndef __WXGTK3__
|
||||
bool wxPGEditorBitmapButton::m_exactFitStyleDefined = false;
|
||||
#endif // !__WXGTK3__
|
||||
|
||||
#else // !__WXGTK__
|
||||
|
||||
typedef wxBitmapButton wxPGEditorBitmapButton;
|
||||
|
Reference in New Issue
Block a user