static inline glong
max_visible_row (const GtkSheet *sheet)
{
- return row_from_ypixel (sheet,
- sheet->vadjustment->value +
- sheet->vadjustment->page_size);
+ return row_from_ypixel (sheet, sheet->vadjustment->value + sheet->vadjustment->page_size);
}
static inline glong
max_visible_column (const GtkSheet *sheet)
{
- return column_from_xpixel (sheet,
- sheet->hadjustment->value +
- sheet->hadjustment->page_size);
+ return column_from_xpixel (sheet, sheet->hadjustment->value + sheet->hadjustment->page_size);
}
static inline glong
g_return_if_fail (drawing_range.rowi >= drawing_range.row0);
g_return_if_fail (drawing_range.coli >= drawing_range.col0);
-
gdk_window_begin_paint_rect (sheet->sheet_window, &area);
for (i = drawing_range.row0; i <= drawing_range.rowi; i++)
}
- range.row0 =
- row_from_ypixel (sheet,
- event->area.y + sheet->vadjustment->value);
- range.row0--;
+ {
+ gint y = event->area.y + sheet->vadjustment->value;
+ gint x = event->area.x + sheet->hadjustment->value;
+
+ if ( sheet->column_titles_visible)
+ y -= sheet->column_title_area.height;
+
+ if ( sheet->row_titles_visible)
+ x -= sheet->row_title_area.width;
+
+ maximize_int (&x, 0);
+ maximize_int (&y, 0);
- range.rowi =
- row_from_ypixel (sheet,
- event->area.y +
- event->area.height + sheet->vadjustment->value);
- range.rowi++;
+ range.row0 = row_from_ypixel (sheet, y);
- range.col0 =
- column_from_xpixel (sheet,
- event->area.x + sheet->hadjustment->value);
- range.col0--;
+ range.rowi = row_from_ypixel (sheet, y + event->area.height);
- range.coli =
- column_from_xpixel (sheet,
- event->area.x + event->area.width +
- sheet->hadjustment->value);
- range.coli++;
+ range.col0 = column_from_xpixel (sheet, x);
+ range.coli = column_from_xpixel (sheet, x + event->area.width);
+ }
if (event->window == sheet->sheet_window)
{
#include <libpspp/tower.h>
#include <libpspp/pool.h>
+#include <libpspp/misc.h>
#include "psppire-axis.h"
#include <gtk/gtk.h>
actual_size = PSPPIRE_AXIS_GET_IFACE (a)->total_size (a);
if ( actual_size < a->min_extent )
- padding = (a->min_extent - actual_size) / a->default_size;
+ padding = DIV_RND_UP (a->min_extent - actual_size, a->default_size);
return PSPPIRE_AXIS_GET_IFACE (a)->unit_count (a) + padding;
}
return total_size + (unit - the_count) * a->default_size;
}
- // g_print ("%s %d\n", __FUNCTION__, unit);
-
return PSPPIRE_AXIS_GET_IFACE (a)->pixel_start (a, unit);
}
gint n_items = PSPPIRE_AXIS_GET_IFACE (a)->unit_count (a);
glong extra = pixel - total_size;
- return n_items - 1 + extra / a->default_size;
+ return n_items - 1 + DIV_RND_UP (extra, a->default_size);
}
return PSPPIRE_AXIS_GET_IFACE (a)->get_unit_at_pixel (a, pixel);
}
}
+/* Return the width (in pixels) of an upper case M when rendered in the
+ current font of W
+*/
+static gint
+width_of_m (GtkWidget *w)
+{
+ PangoRectangle rect;
+ PangoLayout *layout = gtk_widget_create_pango_layout (w, "M");
+
+ pango_layout_get_pixel_extents (layout, NULL, &rect);
+
+ g_object_unref (layout);
+
+ return rect.width;
+}
+
static void
new_variables_callback (PsppireDict *dict, gpointer data)
{
gint v, i;
PsppireDataEditor *de = PSPPIRE_DATA_EDITOR (data);
+ gint m_width = width_of_m (GTK_WIDGET (de));
PsppireAxisHetero *vaxis;
g_object_get (de->var_sheet, "vertical-axis", &vaxis, NULL);
{
const struct variable *var = psppire_dict_get_variable (dict, v);
- psppire_axis_hetero_append (haxis, 10 * var_get_display_width (var));
+ psppire_axis_hetero_append (haxis, m_width * var_get_display_width (var));
}
}
}
-/* Return the width (in pixels) of an upper case M when rendered in the
- current font of W
-*/
-static gint
-width_of_m (GtkWidget *w)
-{
- PangoRectangle rect;
- PangoLayout *layout = gtk_widget_create_pango_layout (w, "M");
-
- pango_layout_get_pixel_extents (layout, NULL, &rect);
-
- g_object_unref (layout);
-
- return rect.width;
-}
-
static void
insert_variable_callback (PsppireDict *dict, gint x, gpointer data)
{