Gets rid of gtk_entry_get_layout_offsets in GTKGetEntryMargins

due to returning invalid values when used before size_allocate.

Using padding + border on GTK3 and thickness + inner border on GTK2
looks correct.
This commit is contained in:
Alex Shvartzkop 2023-06-08 21:28:12 +03:00
parent b9d0541f9a
commit f9eea9fdfd

View file

@ -366,12 +366,17 @@ wxSize wxControl::GTKGetPreferredSize(GtkWidget* widget) const
wxSize wxControl::GTKGetEntryMargins(GtkEntry* entry) const
{
wxSize size;
gtk_entry_get_layout_offsets(entry, &size.x, &size.y);
#ifdef __WXGTK3__
GtkBorder border;
GtkStyleContext* sc = gtk_widget_get_style_context(GTK_WIDGET(entry));
gtk_style_context_get_padding(sc, gtk_style_context_get_state(sc), &border);
GtkStateFlags state = gtk_style_context_get_state(sc);
GtkBorder padding, border;
gtk_style_context_get_padding(sc, state, &padding);
gtk_style_context_get_border(sc, state, &border);
size.x += padding.left + padding.right + border.left + border.right;
size.y += padding.top + padding.bottom + border.top + border.bottom;
#else
if (gtk_entry_get_has_frame(entry))
{
@ -402,10 +407,10 @@ wxSize wxControl::GTKGetEntryMargins(GtkEntry* entry) const
}
}
#endif // GTK+ 2.10+
#endif
size.x += border.left + border.right;
size.y += border.top + border.bottom;
#endif
return size;
}