return syntax;
}
+
+
+/* Return the width of an upper case M (in pixels) when rendered onto
+ WIDGET with its current style. */
+gdouble
+width_of_m (GtkWidget *widget)
+{
+ PangoContext *context = gtk_widget_create_pango_context (widget);
+ PangoLayout *layout = pango_layout_new (context);
+ PangoRectangle rect;
+
+ pango_layout_set_text (layout, "M", 1);
+ pango_layout_get_extents (layout, NULL, &rect);
+
+ g_object_unref (G_OBJECT (layout));
+ g_object_unref (G_OBJECT (context));
+
+ return rect.width / (gdouble) PANGO_SCALE;
+}
+
implementations rely on this. */
#define GFUNC_COMPAT_CAST(x) ((GFunc) (void (*)(void)) (x))
+
+/* Return the width of an upper case M (in pixels) when rendered onto
+ WIDGET with its current style. */
+gdouble width_of_m (GtkWidget *widget);
+
#endif
#include "ui/gui/executor.h"
#include "psppire-data-window.h"
#include "ssw-axis-model.h"
+#include "helper.h"
static void
do_sort (PsppireDataSheet *sheet, GtkSortType order)
g_signal_connect_after (button, "draw", G_CALLBACK (indicate_filtered_case), data_store);
}
-
static gboolean
resize_display_width (PsppireDict *dict, gint pos, gint size, gpointer user_data)
{
return FALSE;
PsppireDataSheet *sheet = PSPPIRE_DATA_SHEET (user_data);
- PangoContext *context = gtk_widget_create_pango_context (GTK_WIDGET (sheet));
- PangoLayout *layout = pango_layout_new (context);
- PangoRectangle rect;
-
- pango_layout_set_text (layout, "M", 1);
- pango_layout_get_extents (layout, NULL, &rect);
-
- gdouble width_of_M = rect.width / (gdouble) PANGO_SCALE;
-
- g_object_unref (G_OBJECT (layout));
- g_object_unref (G_OBJECT (context));
+ gdouble wm = width_of_m (GTK_WIDGET (sheet));
- gint Ms = round ((size / width_of_M) - 0.25);
+ gint Ms = round ((size / wm) - 0.25);
struct variable *var = psppire_dict_get_variable (dict, pos);
g_return_val_if_fail (var, TRUE);
var_set_display_width (var, Ms);