From: John Darrington Date: Mon, 1 Dec 2008 12:47:21 +0000 (+0900) Subject: Fixed some boundary conditions displaying row/column data X-Git-Tag: v0.7.1~85 X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=abaa4252a054287a9fdfe6fc3927bb18cf354d9f;p=pspp-builds.git Fixed some boundary conditions displaying row/column data --- diff --git a/lib/gtksheet/gtksheet.c b/lib/gtksheet/gtksheet.c index 962ac621..e8ca1658 100644 --- a/lib/gtksheet/gtksheet.c +++ b/lib/gtksheet/gtksheet.c @@ -154,9 +154,7 @@ min_fully_visible_row (const GtkSheet *sheet) 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); } @@ -200,9 +198,7 @@ min_fully_visible_column (const GtkSheet *sheet) 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 @@ -2144,7 +2140,6 @@ gtk_sheet_range_draw (GtkSheet *sheet, const GtkSheetRange *range) 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++) @@ -3102,28 +3097,27 @@ gtk_sheet_expose (GtkWidget *widget, } - 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) { diff --git a/lib/gtksheet/psppire-axis.c b/lib/gtksheet/psppire-axis.c index 92eba59b..94c2aa41 100644 --- a/lib/gtksheet/psppire-axis.c +++ b/lib/gtksheet/psppire-axis.c @@ -20,6 +20,7 @@ #include #include +#include #include "psppire-axis.h" #include @@ -203,7 +204,7 @@ psppire_axis_unit_count (const PsppireAxis *a) 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; } @@ -224,8 +225,6 @@ psppire_axis_pixel_start (const PsppireAxis *a, gint unit) 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); } @@ -249,7 +248,7 @@ psppire_axis_get_unit_at_pixel (const PsppireAxis *a, glong pixel) 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); diff --git a/src/ui/gui/psppire-data-editor.c b/src/ui/gui/psppire-data-editor.c index ff96109d..79682fe0 100644 --- a/src/ui/gui/psppire-data-editor.c +++ b/src/ui/gui/psppire-data-editor.c @@ -227,11 +227,28 @@ new_data_callback (PsppireDataStore *ds, gpointer data) } } +/* 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); @@ -252,27 +269,11 @@ new_variables_callback (PsppireDict *dict, gpointer data) { 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) {