diff --git a/include/wx/gtk/private/stylecontext.h b/include/wx/gtk/private/stylecontext.h index a81ac3823e..6a5deef9c1 100644 --- a/include/wx/gtk/private/stylecontext.h +++ b/include/wx/gtk/private/stylecontext.h @@ -15,7 +15,7 @@ class wxGtkStyleContext { public: - wxGtkStyleContext(); + wxGtkStyleContext(double scale = 1); ~wxGtkStyleContext(); wxGtkStyleContext& Add(GType type, const char* objectName, ...) G_GNUC_NULL_TERMINATED; wxGtkStyleContext& Add(const char* objectName); @@ -38,6 +38,7 @@ public: private: GtkStyleContext* m_context; GtkWidgetPath* const m_path; + const int m_scale; wxDECLARE_NO_COPY_CLASS(wxGtkStyleContext); }; diff --git a/src/gtk/renderer.cpp b/src/gtk/renderer.cpp index 479a6a279d..cac350e8cb 100644 --- a/src/gtk/renderer.cpp +++ b/src/gtk/renderer.cpp @@ -249,7 +249,7 @@ wxRendererGTK::DrawHeaderButton(wxWindow *win, if (flags & wxCONTROL_DIRTY) pos = 2; - wxGtkStyleContext sc; + wxGtkStyleContext sc(dc.GetContentScaleFactor()); sc.AddTreeviewHeaderButton(pos); gtk_style_context_set_state(sc, stateTypeToFlags[state]); @@ -450,7 +450,7 @@ wxRendererGTK::DrawSplitterSash(wxWindow* win, x_diff = rect.width; #ifdef __WXGTK3__ - wxGtkStyleContext sc; + wxGtkStyleContext sc(dc.GetContentScaleFactor()); sc.Add(GTK_TYPE_PANED, "paned", "pane-separator", NULL); if (gtk_check_version(3,20,0) == NULL) sc.Add("separator"); @@ -561,7 +561,7 @@ wxRendererGTK::GetCheckBoxSize(wxWindow* win) #ifdef __WXGTK3__ int min_width, min_height; - wxGtkStyleContext sc; + wxGtkStyleContext sc(win->GetContentScaleFactor()); sc.AddCheckButton(); if (gtk_check_version(3,20,0) == NULL) { @@ -654,7 +654,7 @@ wxRendererGTK::DrawCheckBox(wxWindow*, state |= GTK_STATE_FLAG_PRELIGHT; int min_width, min_height; - wxGtkStyleContext sc; + wxGtkStyleContext sc(dc.GetContentScaleFactor()); sc.AddCheckButton(); if (gtk_check_version(3,20,0) == NULL) { @@ -851,7 +851,7 @@ void wxRendererGTK::DrawTextCtrl(wxWindow*, wxDC& dc, const wxRect& rect, int fl if (flags & wxCONTROL_DISABLED) state = GTK_STATE_FLAG_INSENSITIVE; - wxGtkStyleContext sc; + wxGtkStyleContext sc(dc.GetContentScaleFactor()); sc.Add(GTK_TYPE_ENTRY, "entry", "entry", NULL); gtk_style_context_set_state(sc, GtkStateFlags(state)); @@ -1001,7 +1001,7 @@ void wxRendererGTK::DrawRadioBitmap(wxWindow*, wxDC& dc, const wxRect& rect, int state |= GTK_STATE_FLAG_PRELIGHT; int min_width, min_height; - wxGtkStyleContext sc; + wxGtkStyleContext sc(dc.GetContentScaleFactor()); sc.Add(GTK_TYPE_RADIO_BUTTON, "radiobutton", NULL); #if GTK_CHECK_VERSION(3,20,0) if (gtk_check_version(3,20,0) == NULL) diff --git a/src/gtk/settings.cpp b/src/gtk/settings.cpp index 2c8132cbbe..1e3a553340 100644 --- a/src/gtk/settings.cpp +++ b/src/gtk/settings.cpp @@ -209,8 +209,9 @@ private: // wxGtkStyleContext //----------------------------------------------------------------------------- -wxGtkStyleContext::wxGtkStyleContext() +wxGtkStyleContext::wxGtkStyleContext(double scale) : m_path(gtk_widget_path_new()) + , m_scale(int(scale)) { m_context = NULL; } @@ -233,6 +234,10 @@ wxGtkStyleContext& wxGtkStyleContext::Add(GType type, const char* objectName, .. va_end(args); GtkStyleContext* sc = gtk_style_context_new(); +#if GTK_CHECK_VERSION(3,10,0) + if (gtk_check_version(3,10,0) == NULL) + gtk_style_context_set_scale(sc, m_scale); +#endif gtk_style_context_set_path(sc, m_path); if (m_context) {