Improve wxRendererGTK drawing with HiDPI
This commit is contained in:
@@ -15,7 +15,7 @@
|
|||||||
class wxGtkStyleContext
|
class wxGtkStyleContext
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
wxGtkStyleContext();
|
wxGtkStyleContext(double scale = 1);
|
||||||
~wxGtkStyleContext();
|
~wxGtkStyleContext();
|
||||||
wxGtkStyleContext& Add(GType type, const char* objectName, ...) G_GNUC_NULL_TERMINATED;
|
wxGtkStyleContext& Add(GType type, const char* objectName, ...) G_GNUC_NULL_TERMINATED;
|
||||||
wxGtkStyleContext& Add(const char* objectName);
|
wxGtkStyleContext& Add(const char* objectName);
|
||||||
@@ -38,6 +38,7 @@ public:
|
|||||||
private:
|
private:
|
||||||
GtkStyleContext* m_context;
|
GtkStyleContext* m_context;
|
||||||
GtkWidgetPath* const m_path;
|
GtkWidgetPath* const m_path;
|
||||||
|
const int m_scale;
|
||||||
|
|
||||||
wxDECLARE_NO_COPY_CLASS(wxGtkStyleContext);
|
wxDECLARE_NO_COPY_CLASS(wxGtkStyleContext);
|
||||||
};
|
};
|
||||||
|
@@ -249,7 +249,7 @@ wxRendererGTK::DrawHeaderButton(wxWindow *win,
|
|||||||
if (flags & wxCONTROL_DIRTY)
|
if (flags & wxCONTROL_DIRTY)
|
||||||
pos = 2;
|
pos = 2;
|
||||||
|
|
||||||
wxGtkStyleContext sc;
|
wxGtkStyleContext sc(dc.GetContentScaleFactor());
|
||||||
sc.AddTreeviewHeaderButton(pos);
|
sc.AddTreeviewHeaderButton(pos);
|
||||||
|
|
||||||
gtk_style_context_set_state(sc, stateTypeToFlags[state]);
|
gtk_style_context_set_state(sc, stateTypeToFlags[state]);
|
||||||
@@ -450,7 +450,7 @@ wxRendererGTK::DrawSplitterSash(wxWindow* win,
|
|||||||
x_diff = rect.width;
|
x_diff = rect.width;
|
||||||
|
|
||||||
#ifdef __WXGTK3__
|
#ifdef __WXGTK3__
|
||||||
wxGtkStyleContext sc;
|
wxGtkStyleContext sc(dc.GetContentScaleFactor());
|
||||||
sc.Add(GTK_TYPE_PANED, "paned", "pane-separator", NULL);
|
sc.Add(GTK_TYPE_PANED, "paned", "pane-separator", NULL);
|
||||||
if (gtk_check_version(3,20,0) == NULL)
|
if (gtk_check_version(3,20,0) == NULL)
|
||||||
sc.Add("separator");
|
sc.Add("separator");
|
||||||
@@ -561,7 +561,7 @@ wxRendererGTK::GetCheckBoxSize(wxWindow* win)
|
|||||||
|
|
||||||
#ifdef __WXGTK3__
|
#ifdef __WXGTK3__
|
||||||
int min_width, min_height;
|
int min_width, min_height;
|
||||||
wxGtkStyleContext sc;
|
wxGtkStyleContext sc(win->GetContentScaleFactor());
|
||||||
sc.AddCheckButton();
|
sc.AddCheckButton();
|
||||||
if (gtk_check_version(3,20,0) == NULL)
|
if (gtk_check_version(3,20,0) == NULL)
|
||||||
{
|
{
|
||||||
@@ -654,7 +654,7 @@ wxRendererGTK::DrawCheckBox(wxWindow*,
|
|||||||
state |= GTK_STATE_FLAG_PRELIGHT;
|
state |= GTK_STATE_FLAG_PRELIGHT;
|
||||||
|
|
||||||
int min_width, min_height;
|
int min_width, min_height;
|
||||||
wxGtkStyleContext sc;
|
wxGtkStyleContext sc(dc.GetContentScaleFactor());
|
||||||
sc.AddCheckButton();
|
sc.AddCheckButton();
|
||||||
if (gtk_check_version(3,20,0) == NULL)
|
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)
|
if (flags & wxCONTROL_DISABLED)
|
||||||
state = GTK_STATE_FLAG_INSENSITIVE;
|
state = GTK_STATE_FLAG_INSENSITIVE;
|
||||||
|
|
||||||
wxGtkStyleContext sc;
|
wxGtkStyleContext sc(dc.GetContentScaleFactor());
|
||||||
sc.Add(GTK_TYPE_ENTRY, "entry", "entry", NULL);
|
sc.Add(GTK_TYPE_ENTRY, "entry", "entry", NULL);
|
||||||
|
|
||||||
gtk_style_context_set_state(sc, GtkStateFlags(state));
|
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;
|
state |= GTK_STATE_FLAG_PRELIGHT;
|
||||||
|
|
||||||
int min_width, min_height;
|
int min_width, min_height;
|
||||||
wxGtkStyleContext sc;
|
wxGtkStyleContext sc(dc.GetContentScaleFactor());
|
||||||
sc.Add(GTK_TYPE_RADIO_BUTTON, "radiobutton", NULL);
|
sc.Add(GTK_TYPE_RADIO_BUTTON, "radiobutton", NULL);
|
||||||
#if GTK_CHECK_VERSION(3,20,0)
|
#if GTK_CHECK_VERSION(3,20,0)
|
||||||
if (gtk_check_version(3,20,0) == NULL)
|
if (gtk_check_version(3,20,0) == NULL)
|
||||||
|
@@ -209,8 +209,9 @@ private:
|
|||||||
// wxGtkStyleContext
|
// wxGtkStyleContext
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
wxGtkStyleContext::wxGtkStyleContext()
|
wxGtkStyleContext::wxGtkStyleContext(double scale)
|
||||||
: m_path(gtk_widget_path_new())
|
: m_path(gtk_widget_path_new())
|
||||||
|
, m_scale(int(scale))
|
||||||
{
|
{
|
||||||
m_context = NULL;
|
m_context = NULL;
|
||||||
}
|
}
|
||||||
@@ -233,6 +234,10 @@ wxGtkStyleContext& wxGtkStyleContext::Add(GType type, const char* objectName, ..
|
|||||||
va_end(args);
|
va_end(args);
|
||||||
|
|
||||||
GtkStyleContext* sc = gtk_style_context_new();
|
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);
|
gtk_style_context_set_path(sc, m_path);
|
||||||
if (m_context)
|
if (m_context)
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user