Avoid gdk_screen_get_width() with GTK+4
This commit is contained in:
@@ -217,9 +217,19 @@ static void wxGtkTextApplyTagsFromAttr(GtkWidget *text,
|
|||||||
wxGtkTextRemoveTagsWithPrefix(text_buffer, "WXINDENT", ¶_start, ¶_end);
|
wxGtkTextRemoveTagsWithPrefix(text_buffer, "WXINDENT", ¶_start, ¶_end);
|
||||||
|
|
||||||
// Convert indent from 1/10th of a mm into pixels
|
// Convert indent from 1/10th of a mm into pixels
|
||||||
|
#ifdef __WXGTK4__
|
||||||
|
GdkMonitor* monitor = gdk_display_get_monitor_at_window(
|
||||||
|
gtk_widget_get_display(text), gtk_widget_get_window(text));
|
||||||
|
GdkRectangle rect;
|
||||||
|
gdk_monitor_get_geometry(monitor, &rect);
|
||||||
|
float factor = float(rect.width) / gdk_monitor_get_width_mm(monitor);
|
||||||
|
#else
|
||||||
|
wxGCC_WARNING_SUPPRESS(deprecated-declarations)
|
||||||
float factor =
|
float factor =
|
||||||
(float)gdk_screen_get_width(gtk_widget_get_screen(text)) /
|
(float)gdk_screen_get_width(gtk_widget_get_screen(text)) /
|
||||||
gdk_screen_get_width_mm(gtk_widget_get_screen(text)) / 10;
|
gdk_screen_get_width_mm(gtk_widget_get_screen(text)) / 10;
|
||||||
|
wxGCC_WARNING_RESTORE()
|
||||||
|
#endif
|
||||||
|
|
||||||
const int indent = (int)(factor * attr.GetLeftIndent());
|
const int indent = (int)(factor * attr.GetLeftIndent());
|
||||||
const int subIndent = (int)(factor * attr.GetLeftSubIndent());
|
const int subIndent = (int)(factor * attr.GetLeftSubIndent());
|
||||||
@@ -274,10 +284,19 @@ static void wxGtkTextApplyTagsFromAttr(GtkWidget *text,
|
|||||||
if (!tag)
|
if (!tag)
|
||||||
{
|
{
|
||||||
// Factor to convert from 1/10th of a mm into pixels
|
// Factor to convert from 1/10th of a mm into pixels
|
||||||
|
#ifdef __WXGTK4__
|
||||||
|
GdkMonitor* monitor = gdk_display_get_monitor_at_window(
|
||||||
|
gtk_widget_get_display(text), gtk_widget_get_window(text));
|
||||||
|
GdkRectangle rect;
|
||||||
|
gdk_monitor_get_geometry(monitor, &rect);
|
||||||
|
float factor = float(rect.width) / gdk_monitor_get_width_mm(monitor);
|
||||||
|
#else
|
||||||
|
wxGCC_WARNING_SUPPRESS(deprecated-declarations)
|
||||||
float factor =
|
float factor =
|
||||||
(float)gdk_screen_get_width(gtk_widget_get_screen(text)) /
|
(float)gdk_screen_get_width(gtk_widget_get_screen(text)) /
|
||||||
gdk_screen_get_width_mm(gtk_widget_get_screen(text)) / 10;
|
gdk_screen_get_width_mm(gtk_widget_get_screen(text)) / 10;
|
||||||
|
wxGCC_WARNING_RESTORE()
|
||||||
|
#endif
|
||||||
PangoTabArray* tabArray = pango_tab_array_new(tabs.GetCount(), TRUE);
|
PangoTabArray* tabArray = pango_tab_array_new(tabs.GetCount(), TRUE);
|
||||||
for (size_t i = 0; i < tabs.GetCount(); i++)
|
for (size_t i = 0; i < tabs.GetCount(); i++)
|
||||||
pango_tab_array_set_tab(tabArray, i, PANGO_TAB_LEFT, (gint)(tabs[i] * factor));
|
pango_tab_array_set_tab(tabArray, i, PANGO_TAB_LEFT, (gint)(tabs[i] * factor));
|
||||||
|
Reference in New Issue
Block a user