Improve wxSystemSettings::GetMetric() scrollbar width calculation for GTK3
See #24057
This commit is contained in:
parent
2d07dd25b4
commit
67090e61d2
1 changed files with 24 additions and 12 deletions
|
|
@ -949,33 +949,45 @@ static GdkRectangle GetMonitorGeom(GdkWindow* window)
|
|||
}
|
||||
#endif
|
||||
|
||||
#ifdef __WXGTK3__
|
||||
static int GetNodeWidth(wxGtkStyleContext& sc)
|
||||
{
|
||||
int width;
|
||||
gtk_style_context_get(sc, GTK_STATE_FLAG_NORMAL, "min-width", &width, nullptr);
|
||||
GtkBorder border;
|
||||
gtk_style_context_get_padding(sc, GTK_STATE_FLAG_NORMAL, &border);
|
||||
width += border.left + border.right;
|
||||
gtk_style_context_get_border(sc, GTK_STATE_FLAG_NORMAL, &border);
|
||||
width += border.left + border.right;
|
||||
gtk_style_context_get_margin(sc, GTK_STATE_FLAG_NORMAL, &border);
|
||||
width += border.left + border.right;
|
||||
|
||||
return width < 0 ? 0 : width;
|
||||
}
|
||||
#endif // __WXGTK3__
|
||||
|
||||
static int GetScrollbarWidth()
|
||||
{
|
||||
int width;
|
||||
#ifdef __WXGTK3__
|
||||
if (wx_is_at_least_gtk3(20))
|
||||
{
|
||||
GtkBorder border;
|
||||
#if GTK_CHECK_VERSION(3,10,0)
|
||||
wxGtkStyleContext sc(gtk_widget_get_scale_factor(ScrollBarWidget()));
|
||||
#else
|
||||
wxGtkStyleContext sc;
|
||||
#endif
|
||||
sc.Add(GTK_TYPE_SCROLLBAR, "scrollbar", "scrollbar", "vertical", "right", nullptr);
|
||||
width = GetNodeWidth(sc);
|
||||
|
||||
gtk_style_context_get_border(sc, GTK_STATE_FLAG_NORMAL, &border);
|
||||
sc.Add("contents");
|
||||
width += GetNodeWidth(sc);
|
||||
|
||||
sc.Add("contents").Add("trough").Add("slider");
|
||||
sc.Add("trough");
|
||||
width += GetNodeWidth(sc);
|
||||
|
||||
gtk_style_context_get(sc, GTK_STATE_FLAG_NORMAL, "min-width", &width, nullptr);
|
||||
width += border.left + border.right;
|
||||
|
||||
gtk_style_context_get_border(sc, GTK_STATE_FLAG_NORMAL, &border);
|
||||
width += border.left + border.right;
|
||||
gtk_style_context_get_padding(sc, GTK_STATE_FLAG_NORMAL, &border);
|
||||
width += border.left + border.right;
|
||||
gtk_style_context_get_margin(sc, GTK_STATE_FLAG_NORMAL, &border);
|
||||
width += border.left + border.right;
|
||||
sc.Add("slider");
|
||||
width += GetNodeWidth(sc);
|
||||
}
|
||||
else
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue