X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=lib%2Fgtksheet%2Fgtksheet.c;h=31f242d28f1283648c517f7d122a2a1bd53a3751;hb=11706f97dd318697e43e6468b130ca5b7f1bff87;hp=f7cf7822faae2629841fc57787e90751f9ef3079;hpb=2fbfb300e1200847986e5c669aa8322fe96683e7;p=pspp-builds.git diff --git a/lib/gtksheet/gtksheet.c b/lib/gtksheet/gtksheet.c index f7cf7822..31f242d2 100644 --- a/lib/gtksheet/gtksheet.c +++ b/lib/gtksheet/gtksheet.c @@ -1,7 +1,3 @@ -#define GDK_MULTIHEAD_SAFE 1 -#define GLIB_DISABLE_DEPRECATED 1 -#define GDK_DISABLE_DEPRECATED 1 -#define GTK_DISABLE_DEPRECATED 1 /* * Copyright (C) 2006, 2008 Free Software Foundation * @@ -55,17 +51,16 @@ #include #include #include -#include #include -#include "gtkitementry.h" #include "gtksheet.h" #include "gtkextra-marshal.h" #include "gsheetmodel.h" +#include +#include /* sheet flags */ enum { - GTK_SHEET_REDRAW_PENDING = 1 << 0, GTK_SHEET_IN_XDRAG = 1 << 1, GTK_SHEET_IN_YDRAG = 1 << 2, GTK_SHEET_IN_DRAG = 1 << 3, @@ -82,7 +77,6 @@ enum #define GTK_SHEET_IN_DRAG(sheet) (GTK_SHEET_FLAGS (sheet) & GTK_SHEET_IN_DRAG) #define GTK_SHEET_IN_SELECTION(sheet) (GTK_SHEET_FLAGS (sheet) & GTK_SHEET_IN_SELECTION) #define GTK_SHEET_IN_RESIZE(sheet) (GTK_SHEET_FLAGS (sheet) & GTK_SHEET_IN_RESIZE) -#define GTK_SHEET_REDRAW_PENDING(sheet) (GTK_SHEET_FLAGS (sheet) & GTK_SHEET_REDRAW_PENDING) #define CELL_SPACING 1 @@ -90,18 +84,23 @@ enum #define COLUMN_MIN_WIDTH 10 #define COLUMN_TITLES_HEIGHT 4 #define DEFAULT_COLUMN_WIDTH 80 +#define DEFAULT_ROW_HEIGHT 25 static void gtk_sheet_update_primary_selection (GtkSheet *sheet); static void gtk_sheet_column_title_button_draw (GtkSheet *sheet, gint column); static void gtk_sheet_row_title_button_draw (GtkSheet *sheet, gint row); - -static gboolean gtk_sheet_cell_empty (const GtkSheet *, gint, gint); +static void gtk_sheet_set_row_height (GtkSheet *sheet, + gint row, + guint height); static void destroy_hover_window (GtkSheetHoverTitle *); static GtkSheetHoverTitle *create_hover_window (void); +static GtkStateType gtk_sheet_cell_get_state (GtkSheet *sheet, gint row, gint col); + + static inline void dispose_string (const GtkSheet *sheet, gchar *text) { @@ -114,46 +113,6 @@ dispose_string (const GtkSheet *sheet, gchar *text) g_free (text); } -static guint -default_row_height (const GtkSheet *sheet) -{ - GtkWidget *widget = GTK_WIDGET (sheet); - - if (!widget->style->font_desc) return 25; - else - { - PangoContext *context = gtk_widget_get_pango_context (widget); - PangoFontMetrics *metrics = - pango_context_get_metrics (context, - widget->style->font_desc, - pango_context_get_language (context)); - - guint val = pango_font_metrics_get_descent (metrics) + - pango_font_metrics_get_ascent (metrics); - - pango_font_metrics_unref (metrics); - - return PANGO_PIXELS (val) + 2 * COLUMN_TITLES_HEIGHT; - } -} - -static -guint DEFAULT_FONT_ASCENT (GtkWidget *widget) -{ - if (!widget->style->font_desc) return 12; - else - { - PangoContext *context = gtk_widget_get_pango_context (widget); - PangoFontMetrics *metrics = - pango_context_get_metrics (context, - widget->style->font_desc, - pango_context_get_language (context)); - guint val = pango_font_metrics_get_ascent (metrics); - pango_font_metrics_unref (metrics); - return PANGO_PIXELS (val); - } -} - static guint STRING_WIDTH (GtkWidget *widget, const PangoFontDescription *font, const gchar *text) @@ -170,99 +129,92 @@ guint STRING_WIDTH (GtkWidget *widget, return PANGO_PIXELS (rect.width); } -static -guint DEFAULT_FONT_DESCENT (GtkWidget *widget) -{ - if (!widget->style->font_desc) return 12; - else - { - PangoContext *context = gtk_widget_get_pango_context (widget); - PangoFontMetrics *metrics = - pango_context_get_metrics (context, - widget->style->font_desc, - pango_context_get_language (context)); - guint val = pango_font_metrics_get_descent (metrics); - pango_font_metrics_unref (metrics); - return PANGO_PIXELS (val); - } -} - - /* Return the row containing pixel Y */ static gint yyy_row_ypixel_to_row (const GtkSheet *sheet, gint y) { GSheetRow *geo = sheet->row_geometry; - if (y < 0) return -1; + g_return_val_if_fail (y >= 0, -1); return g_sheet_row_pixel_to_row (geo, y); } - +/* Return the lowest row number which is wholly or partially on + the visible range of the sheet */ static inline glong min_visible_row (const GtkSheet *sheet) { - glong row = - yyy_row_ypixel_to_row (sheet, sheet->vadjustment->value); + return yyy_row_ypixel_to_row (sheet, sheet->vadjustment->value); +} - return row; +static inline glong +min_fully_visible_row (const GtkSheet *sheet) +{ + glong row = yyy_row_ypixel_to_row (sheet, sheet->vadjustment->value); + + if ( g_sheet_row_start_pixel (sheet->row_geometry, row) < sheet->vadjustment->value) + row++; + + return row; } + static inline glong max_visible_row (const GtkSheet *sheet) { - glong row = - yyy_row_ypixel_to_row (sheet, + return yyy_row_ypixel_to_row (sheet, sheet->vadjustment->value + sheet->vadjustment->page_size); - - return row; } - -/* gives the left pixel of the given column in context of - * the sheet's hoffset */ -static inline gint -column_left_xpixel (const GtkSheet *sheet, gint ncol) +static inline glong +max_fully_visible_row (const GtkSheet *sheet) { - return g_sheet_column_start_pixel (sheet->column_geometry, ncol); + glong row = max_visible_row (sheet); + + if ( g_sheet_row_start_pixel (sheet->row_geometry, row) + + + g_sheet_row_get_height (sheet->row_geometry, row) + > sheet->vadjustment->value) + row--; + + return row; } -/* returns the column index from a x pixel location */ +/* returns the column index from a pixel location */ static inline gint -column_from_xpixel (const GtkSheet *sheet, gint x) +column_from_xpixel (const GtkSheet *sheet, gint pixel) { - gint i; - gint cx = 0; - - if (x < 0) return -1; - for (i = 0; - i < g_sheet_column_get_column_count (sheet->column_geometry); i++) - { - if (x >= cx && - x <= (cx + g_sheet_column_get_width (sheet->column_geometry, i)) && - g_sheet_column_get_visibility (sheet->column_geometry, i)) - return i; - if ( g_sheet_column_get_visibility (sheet->column_geometry, i)) - cx += g_sheet_column_get_width (sheet->column_geometry, i); - } - - /* no match */ - return g_sheet_column_get_column_count (sheet->column_geometry) - 1; + return psppire_axis_get_unit_at_pixel (sheet->haxis, pixel); } +/* Returns the lowest column number which is wholly or partially + on the sheet */ static inline glong min_visible_column (const GtkSheet *sheet) { return column_from_xpixel (sheet, sheet->hadjustment->value); } +static inline glong +min_fully_visible_column (const GtkSheet *sheet) +{ + glong col = min_visible_column (sheet); + + if ( psppire_axis_pixel_start (sheet->haxis, col) < sheet->hadjustment->value) + col++; + + return col; +} + +/* Returns the highest column number which is wholly or partially + on the sheet */ static inline glong max_visible_column (const GtkSheet *sheet) { @@ -271,6 +223,21 @@ max_visible_column (const GtkSheet *sheet) sheet->hadjustment->page_size); } +static inline glong +max_fully_visible_column (const GtkSheet *sheet) +{ + glong col = max_visible_column (sheet); + + if ( psppire_axis_pixel_start (sheet->haxis, col) + + + psppire_axis_unit_size (sheet->haxis, col) + > sheet->hadjustment->value) + col--; + + return col; +} + + /* The size of the region (in pixels) around the row/column boundaries where the height/width may be grabbed to change size */ @@ -312,7 +279,6 @@ POSSIBLE_YDRAG (const GtkSheet *sheet, gint y, gint *drag_row) ydrag = g_sheet_row_start_pixel (sheet->row_geometry, row) + CELL_SPACING; if (y <= ydrag + DRAG_WIDTH / 2 && row != 0) { - while (!g_sheet_row_get_visibility (sheet->row_geometry, row - 1) && row > 0) row--; *drag_row = row - 1; return g_sheet_row_get_sensitivity (sheet->row_geometry, row - 1); } @@ -339,9 +305,9 @@ POSSIBLE_DRAG (const GtkSheet *sheet, gint x, gint y, *drag_column = column_from_xpixel (sheet, x); *drag_row = yyy_row_ypixel_to_row (sheet, y); - if (x >= column_left_xpixel (sheet, sheet->range.col0) - DRAG_WIDTH / 2 && - x <= column_left_xpixel (sheet, sheet->range.coli) + - g_sheet_column_get_width (sheet->column_geometry, sheet->range.coli) + DRAG_WIDTH / 2) + if (x >= psppire_axis_pixel_start (sheet->haxis, sheet->range.col0) - DRAG_WIDTH / 2 && + x <= psppire_axis_pixel_start (sheet->haxis, sheet->range.coli) + + psppire_axis_unit_size (sheet->haxis, sheet->range.coli) + DRAG_WIDTH / 2) { ydrag = g_sheet_row_start_pixel (sheet->row_geometry, sheet->range.row0); if (y >= ydrag - DRAG_WIDTH / 2 && y <= ydrag + DRAG_WIDTH / 2) @@ -362,14 +328,14 @@ POSSIBLE_DRAG (const GtkSheet *sheet, gint x, gint y, y <= g_sheet_row_start_pixel (sheet->row_geometry, sheet->range.rowi) + g_sheet_row_get_height (sheet->row_geometry, sheet->range.rowi) + DRAG_WIDTH / 2) { - xdrag = column_left_xpixel (sheet, sheet->range.col0); + xdrag = psppire_axis_pixel_start (sheet->haxis, sheet->range.col0); if (x >= xdrag - DRAG_WIDTH / 2 && x <= xdrag + DRAG_WIDTH / 2) { *drag_column = sheet->range.col0; return TRUE; } - xdrag = column_left_xpixel (sheet, sheet->range.coli) + - g_sheet_column_get_width (sheet->column_geometry, sheet->range.coli); + xdrag = psppire_axis_pixel_start (sheet->haxis, sheet->range.coli) + + psppire_axis_unit_size (sheet->haxis, sheet->range.coli); if (x >= xdrag - DRAG_WIDTH / 2 && x <= xdrag + DRAG_WIDTH / 2) { *drag_column = sheet->range.coli; @@ -391,8 +357,8 @@ POSSIBLE_RESIZE (const GtkSheet *sheet, gint x, gint y, sheet->range.col0 < 0 || sheet->range.coli < 0 ) return FALSE; - xdrag = column_left_xpixel (sheet, sheet->range.coli)+ - g_sheet_column_get_width (sheet->column_geometry, sheet->range.coli); + xdrag = psppire_axis_pixel_start (sheet->haxis, sheet->range.coli)+ + psppire_axis_unit_size (sheet->haxis, sheet->range.coli); ydrag = g_sheet_row_start_pixel (sheet->row_geometry, sheet->range.rowi) + g_sheet_row_get_height (sheet->row_geometry, sheet->range.rowi); @@ -401,7 +367,7 @@ POSSIBLE_RESIZE (const GtkSheet *sheet, gint x, gint y, ydrag = g_sheet_row_start_pixel (sheet->row_geometry, min_visible_row (sheet)); if (sheet->state == GTK_SHEET_ROW_SELECTED) - xdrag = column_left_xpixel (sheet, min_visible_column (sheet)); + xdrag = psppire_axis_pixel_start (sheet->haxis, min_visible_column (sheet)); *drag_column = column_from_xpixel (sheet, x); *drag_row = yyy_row_ypixel_to_row (sheet, y); @@ -412,18 +378,64 @@ POSSIBLE_RESIZE (const GtkSheet *sheet, gint x, gint y, return FALSE; } -static void gtk_sheet_class_init (GtkSheetClass * klass); -static void gtk_sheet_init (GtkSheet * sheet); -static void gtk_sheet_dispose (GObject * object); -static void gtk_sheet_finalize (GObject * object); + +static gboolean +rectangle_from_range (GtkSheet *sheet, const GtkSheetRange *range, + GdkRectangle *r) +{ + g_return_val_if_fail (range, FALSE); + + r->x = psppire_axis_pixel_start (sheet->haxis, range->col0); + r->x -= round (sheet->hadjustment->value); + + if ( sheet->row_titles_visible) + r->x += sheet->row_title_area.width; + + + r->y = g_sheet_row_start_pixel (sheet->row_geometry, range->row0); + r->y -= round (sheet->vadjustment->value); + + if ( sheet->column_titles_visible) + r->y += sheet->column_title_area.height; + + r->width = psppire_axis_pixel_start (sheet->haxis, range->coli) - + psppire_axis_pixel_start (sheet->haxis, range->col0) + + psppire_axis_unit_size (sheet->haxis, range->coli); + + r->height = g_sheet_row_start_pixel (sheet->row_geometry, range->rowi) - + g_sheet_row_start_pixel (sheet->row_geometry, range->row0) + + g_sheet_row_get_height (sheet->row_geometry, range->rowi); + + return TRUE; +} + +static gboolean +rectangle_from_cell (GtkSheet *sheet, gint row, gint col, + GdkRectangle *r) +{ + GtkSheetRange range; + g_return_val_if_fail (row >= 0, FALSE); + g_return_val_if_fail (col >= 0, FALSE); + + range.row0 = range.rowi = row; + range.col0 = range.coli = col; + + return rectangle_from_range (sheet, &range, r); +} + + +static void gtk_sheet_class_init (GtkSheetClass *klass); +static void gtk_sheet_init (GtkSheet *sheet); +static void gtk_sheet_dispose (GObject *object); +static void gtk_sheet_finalize (GObject *object); static void gtk_sheet_style_set (GtkWidget *widget, GtkStyle *previous_style); -static void gtk_sheet_realize (GtkWidget * widget); -static void gtk_sheet_unrealize (GtkWidget * widget); -static void gtk_sheet_map (GtkWidget * widget); -static void gtk_sheet_unmap (GtkWidget * widget); -static gint gtk_sheet_expose (GtkWidget * widget, - GdkEventExpose * event); +static void gtk_sheet_realize (GtkWidget *widget); +static void gtk_sheet_unrealize (GtkWidget *widget); +static void gtk_sheet_map (GtkWidget *widget); +static void gtk_sheet_unmap (GtkWidget *widget); +static gint gtk_sheet_expose (GtkWidget *widget, + GdkEventExpose *event); static void gtk_sheet_forall (GtkContainer *container, gboolean include_internals, GtkCallback callback, @@ -433,42 +445,38 @@ static void gtk_sheet_set_scroll_adjustments (GtkSheet *sheet, GtkAdjustment *hadjustment, GtkAdjustment *vadjustment); -static gint gtk_sheet_button_press (GtkWidget * widget, - GdkEventButton * event); -static gint gtk_sheet_button_release (GtkWidget * widget, - GdkEventButton * event); -static gint gtk_sheet_motion (GtkWidget * widget, - GdkEventMotion * event); +static gint gtk_sheet_button_press (GtkWidget *widget, + GdkEventButton *event); +static gint gtk_sheet_button_release (GtkWidget *widget, + GdkEventButton *event); +static gint gtk_sheet_motion (GtkWidget *widget, + GdkEventMotion *event); static gboolean gtk_sheet_crossing_notify (GtkWidget *widget, GdkEventCrossing *event); static gint gtk_sheet_entry_key_press (GtkWidget *widget, GdkEventKey *key); static gboolean gtk_sheet_key_press (GtkWidget *widget, GdkEventKey *key); -static void gtk_sheet_size_request (GtkWidget * widget, - GtkRequisition * requisition); -static void gtk_sheet_size_allocate (GtkWidget * widget, - GtkAllocation * allocation); +static void gtk_sheet_size_request (GtkWidget *widget, + GtkRequisition *requisition); +static void gtk_sheet_size_allocate (GtkWidget *widget, + GtkAllocation *allocation); /* Sheet queries */ -static gboolean gtk_sheet_range_isvisible (const GtkSheet * sheet, +static gboolean gtk_sheet_range_isvisible (const GtkSheet *sheet, GtkSheetRange range); -static gboolean gtk_sheet_cell_isvisible (GtkSheet * sheet, +static gboolean gtk_sheet_cell_isvisible (GtkSheet *sheet, gint row, gint column); /* Drawing Routines */ -/* draw cell background and frame */ -static void gtk_sheet_cell_draw_default (GtkSheet *sheet, - gint row, gint column); +/* draw cell */ +static void gtk_sheet_cell_draw (GtkSheet *sheet, gint row, gint column); -/* draw cell contents */ -static void gtk_sheet_cell_draw_label (GtkSheet *sheet, - gint row, gint column); /* draw visible part of range. If range == NULL then draw the whole screen */ -static void gtk_sheet_range_draw (GtkSheet *sheet, - const GtkSheetRange *range); +static void gtk_sheet_range_draw (GtkSheet *sheet, + const GtkSheetRange *range); /* highlight the visible part of the selected range */ static void gtk_sheet_range_draw_selection (GtkSheet *sheet, @@ -476,12 +484,10 @@ static void gtk_sheet_range_draw_selection (GtkSheet *sheet, /* Selection */ -static gboolean gtk_sheet_move_query (GtkSheet *sheet, - gint row, gint column); -static void gtk_sheet_real_select_range (GtkSheet * sheet, - const GtkSheetRange * range); -static void gtk_sheet_real_unselect_range (GtkSheet * sheet, - const GtkSheetRange * range); +static void gtk_sheet_real_select_range (GtkSheet *sheet, + const GtkSheetRange *range); +static void gtk_sheet_real_unselect_range (GtkSheet *sheet, + const GtkSheetRange *range); static void gtk_sheet_extend_selection (GtkSheet *sheet, gint row, gint column); static void gtk_sheet_new_selection (GtkSheet *sheet, @@ -493,41 +499,36 @@ static void gtk_sheet_draw_border (GtkSheet *sheet, static void gtk_sheet_entry_changed (GtkWidget *widget, gpointer data); -static void gtk_sheet_deactivate_cell (GtkSheet *sheet); static void gtk_sheet_hide_active_cell (GtkSheet *sheet); -static gboolean gtk_sheet_activate_cell (GtkSheet *sheet, - gint row, gint col); +static void change_active_cell (GtkSheet *sheet, + gint row, gint col); static void gtk_sheet_draw_active_cell (GtkSheet *sheet); static void gtk_sheet_show_active_cell (GtkSheet *sheet); static gboolean gtk_sheet_click_cell (GtkSheet *sheet, gint row, gint column); -/* Backing Pixmap */ -static void gtk_sheet_make_backing_pixmap (GtkSheet *sheet); -static void gtk_sheet_draw_backing_pixmap (GtkSheet *sheet, - GtkSheetRange range); /* Scrollbars */ -static void adjust_scrollbars (GtkSheet * sheet); -static void vadjustment_value_changed (GtkAdjustment * adjustment, +static void adjust_scrollbars (GtkSheet *sheet); +static void vadjustment_value_changed (GtkAdjustment *adjustment, gpointer data); -static void hadjustment_value_changed (GtkAdjustment * adjustment, +static void hadjustment_value_changed (GtkAdjustment *adjustment, gpointer data); -static void draw_xor_vline (GtkSheet * sheet); -static void draw_xor_hline (GtkSheet * sheet); +static void draw_xor_vline (GtkSheet *sheet); +static void draw_xor_hline (GtkSheet *sheet); static void draw_xor_rectangle (GtkSheet *sheet, GtkSheetRange range); -static guint new_column_width (GtkSheet * sheet, +static guint new_column_width (GtkSheet *sheet, gint column, - gint * x); -static guint new_row_height (GtkSheet * sheet, + gint *x); +static guint new_row_height (GtkSheet *sheet, gint row, - gint * y); + gint *y); /* Sheet Button */ static void create_global_button (GtkSheet *sheet); @@ -537,12 +538,11 @@ static void global_button_clicked (GtkWidget *widget, static void create_sheet_entry (GtkSheet *sheet); static void gtk_sheet_size_allocate_entry (GtkSheet *sheet); -static void gtk_sheet_entry_set_max_size (GtkSheet *sheet); /* Sheet button gadgets */ -static void size_allocate_column_title_buttons (GtkSheet * sheet); -static void size_allocate_row_title_buttons (GtkSheet * sheet); +static void draw_column_title_buttons (GtkSheet *sheet); +static void draw_row_title_buttons (GtkSheet *sheet); static void size_allocate_global_button (GtkSheet *sheet); @@ -550,16 +550,6 @@ static void gtk_sheet_button_size_request (GtkSheet *sheet, const GtkSheetButton *button, GtkRequisition *requisition); -/* Attributes routines */ -static void init_attributes (const GtkSheet *sheet, - gint col, - GtkSheetCellAttr *attributes); - - -/* Memory allocation routines */ -static void gtk_sheet_real_range_clear (GtkSheet *sheet, - const GtkSheetRange *range); - static void gtk_sheet_real_cell_clear (GtkSheet *sheet, gint row, gint column); @@ -586,9 +576,7 @@ enum RESIZE_RANGE, MOVE_RANGE, TRAVERSE, - DEACTIVATE, ACTIVATE, - CHANGED, LAST_SIGNAL }; @@ -624,6 +612,8 @@ gtk_sheet_get_type () return sheet_type; } + + static GtkSheetRange* gtk_sheet_range_copy (const GtkSheetRange *range) { @@ -662,6 +652,44 @@ gtk_sheet_range_get_type (void) return sheet_range_type; } +static GtkSheetCell* +gtk_sheet_cell_copy (const GtkSheetCell *cell) +{ + GtkSheetCell *new_cell; + + g_return_val_if_fail (cell != NULL, NULL); + + new_cell = g_new (GtkSheetCell, 1); + + *new_cell = *cell; + + return new_cell; +} + +static void +gtk_sheet_cell_free (GtkSheetCell *cell) +{ + g_return_if_fail (cell != NULL); + + g_free (cell); +} + +GType +gtk_sheet_cell_get_type (void) +{ + static GType sheet_cell_type = 0; + + if (!sheet_cell_type) + { + sheet_cell_type = + g_boxed_type_register_static ("GtkSheetCell", + (GBoxedCopyFunc) gtk_sheet_cell_copy, + (GBoxedFreeFunc) gtk_sheet_cell_free); + } + + return sheet_cell_type; +} + static void column_titles_changed (GtkWidget *w, gint first, gint n_columns, gpointer data); @@ -671,7 +699,7 @@ enum { PROP_0, PROP_ROW_GEO, - PROP_COL_GEO, + PROP_HAXIS, PROP_MODEL }; @@ -686,13 +714,15 @@ gtk_sheet_set_row_geometry (GtkSheet *sheet, GSheetRow *geo) } static void -gtk_sheet_set_column_geometry (GtkSheet *sheet, GSheetColumn *geo) +gtk_sheet_set_horizontal_axis (GtkSheet *sheet, PsppireAxis *a) { - if ( sheet->column_geometry ) g_object_unref (sheet->column_geometry); + if ( sheet->haxis ) + g_object_unref (sheet->haxis); - sheet->column_geometry = geo; + sheet->haxis = a; - if ( sheet->column_geometry ) g_object_ref (sheet->column_geometry); + if ( sheet->haxis ) + g_object_ref (sheet->haxis); } @@ -710,11 +740,8 @@ gtk_sheet_set_property (GObject *object, case PROP_ROW_GEO: gtk_sheet_set_row_geometry (sheet, g_value_get_pointer (value)); break; - case PROP_COL_GEO: - gtk_sheet_set_column_geometry (sheet, g_value_get_pointer (value)); - if ( sheet->column_geometry) - g_signal_connect (sheet->column_geometry, "columns_changed", - G_CALLBACK (column_titles_changed), sheet); + case PROP_HAXIS: + gtk_sheet_set_horizontal_axis (sheet, g_value_get_pointer (value)); break; case PROP_MODEL: gtk_sheet_set_model (sheet, g_value_get_pointer (value)); @@ -738,8 +765,8 @@ gtk_sheet_get_property (GObject *object, case PROP_ROW_GEO: g_value_set_pointer (value, sheet->row_geometry); break; - case PROP_COL_GEO: - g_value_set_pointer (value, sheet->column_geometry); + case PROP_HAXIS: + g_value_set_pointer (value, sheet->haxis); break; case PROP_MODEL: g_value_set_pointer (value, sheet->model); @@ -752,12 +779,12 @@ gtk_sheet_get_property (GObject *object, static void -gtk_sheet_class_init (GtkSheetClass * klass) +gtk_sheet_class_init (GtkSheetClass *klass) { GObjectClass *object_class = G_OBJECT_CLASS (klass); GParamSpec *row_geo_spec ; - GParamSpec *col_geo_spec ; + GParamSpec *haxis_spec ; GParamSpec *model_spec ; GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass); @@ -925,37 +952,22 @@ gtk_sheet_class_init (GtkSheetClass * klass) G_SIGNAL_RUN_LAST, offsetof (GtkSheetClass, traverse), NULL, NULL, - gtkextra_BOOLEAN__INT_INT_POINTER_POINTER, - G_TYPE_BOOLEAN, 4, G_TYPE_INT, G_TYPE_INT, - G_TYPE_POINTER, G_TYPE_POINTER); + gtkextra_BOOLEAN__BOXED_POINTER, + G_TYPE_BOOLEAN, 2, + GTK_TYPE_SHEET_CELL, + G_TYPE_POINTER); - sheet_signals[DEACTIVATE] = - g_signal_new ("deactivate", - G_TYPE_FROM_CLASS (object_class), - G_SIGNAL_RUN_LAST, - offsetof (GtkSheetClass, deactivate), - NULL, NULL, - gtkextra_VOID__INT_INT, - G_TYPE_NONE, 2, G_TYPE_INT, G_TYPE_INT); - sheet_signals[ACTIVATE] = g_signal_new ("activate", G_TYPE_FROM_CLASS (object_class), G_SIGNAL_RUN_LAST, offsetof (GtkSheetClass, activate), NULL, NULL, - gtkextra_BOOLEAN__INT_INT, - G_TYPE_BOOLEAN, 2, G_TYPE_INT, G_TYPE_INT); - - sheet_signals[CHANGED] = - g_signal_new ("changed", - G_TYPE_FROM_CLASS (object_class), - G_SIGNAL_RUN_LAST, - offsetof (GtkSheetClass, changed), - NULL, NULL, - gtkextra_VOID__INT_INT, - G_TYPE_NONE, 2, G_TYPE_INT, G_TYPE_INT); + gtkextra_VOID__INT_INT_INT_INT, + G_TYPE_NONE, 4, + G_TYPE_INT, G_TYPE_INT, + G_TYPE_INT, G_TYPE_INT); widget_class->set_scroll_adjustments_signal = g_signal_new ("set-scroll-adjustments", @@ -981,10 +993,10 @@ gtk_sheet_class_init (GtkSheetClass * klass) "A pointer to the model of the row geometry", G_PARAM_READABLE | G_PARAM_WRITABLE ); - col_geo_spec = - g_param_spec_pointer ("column-geometry", - "Column Geometry", - "A pointer to the model of the column geometry", + haxis_spec = + g_param_spec_pointer ("horizontal-axis", + "Horizontal Axis", + "A pointer to the PsppireAxis object for the columns", G_PARAM_READABLE | G_PARAM_WRITABLE ); model_spec = @@ -1002,8 +1014,8 @@ gtk_sheet_class_init (GtkSheetClass * klass) row_geo_spec); g_object_class_install_property (object_class, - PROP_COL_GEO, - col_geo_spec); + PROP_HAXIS, + haxis_spec); g_object_class_install_property (object_class, PROP_MODEL, @@ -1034,7 +1046,6 @@ gtk_sheet_class_init (GtkSheetClass * klass) klass->resize_range = NULL; klass->move_range = NULL; klass->traverse = NULL; - klass->deactivate = NULL; klass->activate = NULL; klass->changed = NULL; } @@ -1043,7 +1054,7 @@ static void gtk_sheet_init (GtkSheet *sheet) { sheet->model = NULL; - sheet->column_geometry = NULL; + sheet->haxis = NULL; sheet->row_geometry = NULL; sheet->flags = 0; @@ -1057,7 +1068,7 @@ gtk_sheet_init (GtkSheet *sheet) sheet->column_title_area.x = 0; sheet->column_title_area.y = 0; sheet->column_title_area.width = 0; - sheet->column_title_area.height = default_row_height (sheet); + sheet->column_title_area.height = DEFAULT_ROW_HEIGHT; sheet->row_title_window = NULL; sheet->row_title_area.x = 0; @@ -1071,8 +1082,6 @@ gtk_sheet_init (GtkSheet *sheet) sheet->selection_cell.row = 0; sheet->selection_cell.col = 0; - sheet->pixmap = NULL; - sheet->range.row0 = 0; sheet->range.rowi = 0; sheet->range.col0 = 0; @@ -1081,10 +1090,9 @@ gtk_sheet_init (GtkSheet *sheet) sheet->state = GTK_SHEET_NORMAL; sheet->sheet_window = NULL; - sheet->sheet_window_width = 0; - sheet->sheet_window_height = 0; sheet->entry_widget = NULL; sheet->entry_container = NULL; + sheet->entry_handler_id = 0; sheet->button = NULL; sheet->hadjustment = NULL; @@ -1137,13 +1145,13 @@ columns_inserted_deleted_callback (GSheetModel *model, gint first_column, */ range.col0 = first_column; range.row0 = 0; - range.coli = g_sheet_column_get_column_count (sheet->column_geometry) - 1; + range.coli = psppire_axis_unit_count (sheet->haxis) - 1; range.rowi = g_sheet_row_get_row_count (sheet->row_geometry) - 1; adjust_scrollbars (sheet); if (sheet->active_cell.col >= model_columns) - gtk_sheet_activate_cell (sheet, sheet->active_cell.row, model_columns - 1); + change_active_cell (sheet, sheet->active_cell.row, model_columns - 1); for (i = first_column; i <= max_visible_column (sheet); i++) gtk_sheet_column_title_button_draw (sheet, i); @@ -1170,12 +1178,12 @@ rows_inserted_deleted_callback (GSheetModel *model, gint first_row, range.row0 = first_row; range.col0 = 0; range.rowi = g_sheet_row_get_row_count (sheet->row_geometry) - 1; - range.coli = g_sheet_column_get_column_count (sheet->column_geometry) - 1; + range.coli = psppire_axis_unit_count (sheet->haxis) - 1; adjust_scrollbars (sheet); if (sheet->active_cell.row >= model_rows) - gtk_sheet_activate_cell (sheet, model_rows - 1, sheet->active_cell.col); + change_active_cell (sheet, model_rows - 1, sheet->active_cell.col); for (i = first_row; i <= max_visible_row (sheet); i++) gtk_sheet_row_title_button_draw (sheet, i); @@ -1200,13 +1208,14 @@ range_update_callback (GSheetModel *m, gint row0, gint col0, range.rowi = rowi; range.coli = coli; - if ( max_visible_row (sheet) > - g_sheet_model_get_row_count (sheet->model) + if ( !GTK_WIDGET_REALIZED (GTK_WIDGET (sheet))) + return; + + if ( max_visible_row (sheet) > g_sheet_model_get_row_count (sheet->model) || - max_visible_column (sheet) > - g_sheet_model_get_column_count (sheet->model)) + max_visible_column (sheet) > g_sheet_model_get_column_count (sheet->model)) { - gtk_sheet_move_query (sheet, 0, 0); + gtk_sheet_moveto (sheet, 0, 0, 0, 0); } if ( ( row0 < 0 && col0 < 0 ) || ( rowi < 0 && coli < 0 ) ) @@ -1251,11 +1260,10 @@ range_update_callback (GSheetModel *m, gint row0, gint col0, * Returns: the new sheet widget */ GtkWidget * -gtk_sheet_new (GSheetRow *vgeo, GSheetColumn *hgeo, GSheetModel *model) +gtk_sheet_new (GSheetRow *vgeo, void *hgeo, GSheetModel *model) { GtkWidget *widget = g_object_new (GTK_TYPE_SHEET, "row-geometry", vgeo, - "column-geometry", hgeo, "model", model, NULL); return widget; @@ -1303,8 +1311,8 @@ gtk_sheet_set_model (GtkSheet *sheet, GSheetModel *model) /* Call back for when the column titles have changed. FIRST is the first column changed. - N_COLUMNS is the number of columns which have changed, or - 1, which - indicates that the column has changed to its right - most extremity + N_COLUMNS is the number of columns which have changed, or -1, which + indicates that the column has changed to its right-most extremity */ static void column_titles_changed (GtkWidget *w, gint first, gint n_columns, gpointer data) @@ -1315,21 +1323,11 @@ column_titles_changed (GtkWidget *w, gint first, gint n_columns, gpointer data) if ( n_columns == -1 ) { extremity = TRUE; - n_columns = g_sheet_column_get_column_count (sheet->column_geometry) - 1 ; + n_columns = psppire_axis_unit_count (sheet->haxis) - 1 ; } - { - gint i; - for ( i = first ; i <= first + n_columns ; ++i ) - { - gtk_sheet_column_title_button_draw (sheet, i); - g_signal_emit (sheet, sheet_signals[CHANGED], 0, -1, i); - } - } - if ( extremity) gtk_sheet_column_title_button_draw (sheet, -1); - } void @@ -1352,11 +1350,8 @@ gtk_sheet_change_entry (GtkSheet *sheet, GtkType entry_type) if (state == GTK_SHEET_NORMAL) { gtk_sheet_show_active_cell (sheet); - g_signal_connect (gtk_sheet_get_entry (sheet), - "changed", - G_CALLBACK (gtk_sheet_entry_changed), - sheet); } + } void @@ -1387,50 +1382,11 @@ gtk_sheet_get_columns_count (GtkSheet *sheet) g_return_val_if_fail (sheet != NULL, 0); g_return_val_if_fail (GTK_IS_SHEET (sheet), 0); - return g_sheet_column_get_column_count (sheet->column_geometry); -} - -guint -gtk_sheet_get_rows_count (GtkSheet *sheet) -{ - g_return_val_if_fail (sheet != NULL, 0); - g_return_val_if_fail (GTK_IS_SHEET (sheet), 0); - - return g_sheet_row_get_row_count (sheet->row_geometry); -} - -void -gtk_sheet_set_selection_mode (GtkSheet *sheet, gint mode) -{ - g_return_if_fail (sheet != NULL); - g_return_if_fail (GTK_IS_SHEET (sheet)); - - if (GTK_WIDGET_REALIZED (sheet)) - gtk_sheet_real_unselect_range (sheet, NULL); - - sheet->selection_mode = mode; -} - -void -gtk_sheet_set_autoresize (GtkSheet *sheet, gboolean autoresize) -{ - g_return_if_fail (sheet != NULL); - g_return_if_fail (GTK_IS_SHEET (sheet)); - - sheet->autoresize = autoresize; -} - -gboolean -gtk_sheet_autoresize (GtkSheet *sheet) -{ - g_return_val_if_fail (sheet != NULL, FALSE); - g_return_val_if_fail (GTK_IS_SHEET (sheet), FALSE); - - return sheet->autoresize; + return psppire_axis_unit_count (sheet->haxis); } static void -gtk_sheet_set_column_width (GtkSheet * sheet, +gtk_sheet_set_column_width (GtkSheet *sheet, gint column, guint width); @@ -1443,7 +1399,7 @@ gtk_sheet_autoresize_column (GtkSheet *sheet, gint column) g_return_if_fail (sheet != NULL); g_return_if_fail (GTK_IS_SHEET (sheet)); - if (column >= g_sheet_column_get_column_count (sheet->column_geometry) || column < 0) return; + if (column >= psppire_axis_unit_count (sheet->haxis) || column < 0) return; for (row = 0; row < g_sheet_row_get_row_count (sheet->row_geometry); row++) { @@ -1465,46 +1421,12 @@ gtk_sheet_autoresize_column (GtkSheet *sheet, gint column) dispose_string (sheet, text); } - if (text_width > g_sheet_column_get_width (sheet->column_geometry, column) ) + if (text_width > psppire_axis_unit_size (sheet->haxis, column) ) { gtk_sheet_set_column_width (sheet, column, text_width); - GTK_SHEET_SET_FLAGS (sheet, GTK_SHEET_REDRAW_PENDING); } } - - -void -gtk_sheet_set_row_titles_width (GtkSheet *sheet, guint width) -{ - if (width < COLUMN_MIN_WIDTH) return; - - sheet->row_title_area.width = width; - - adjust_scrollbars (sheet); - - if (sheet->hadjustment) - g_signal_emit_by_name (sheet->hadjustment, - "value_changed"); - size_allocate_global_button (sheet); -} - -void -gtk_sheet_set_column_titles_height (GtkSheet *sheet, guint height) -{ - if (height < default_row_height (sheet)) - return; - - sheet->column_title_area.height = height; - - adjust_scrollbars (sheet); - - if (sheet->vadjustment) - g_signal_emit_by_name (sheet->vadjustment, - "value_changed"); - size_allocate_global_button (sheet); -} - void gtk_sheet_show_column_titles (GtkSheet *sheet) { @@ -1603,121 +1525,54 @@ gtk_sheet_hide_row_titles (GtkSheet *sheet) } +/* Scroll the sheet so that the cell ROW, COLUMN is visible. + If {ROW,COL}_ALIGN is zero, then the cell will be placed + at the {top,left} of the sheet. If it's 1, then it'll + be placed at the {bottom,right}. + ROW or COL may be -1, in which case scrolling in that dimension + does not occur. + */ void gtk_sheet_moveto (GtkSheet *sheet, gint row, - gint column, + gint col, gfloat row_align, gfloat col_align) { - gint x, y; - guint width, height; - gint adjust; - gint min_row, min_col; - - g_return_if_fail (sheet != NULL); - g_return_if_fail (GTK_IS_SHEET (sheet)); - g_return_if_fail (sheet->hadjustment != NULL); - g_return_if_fail (sheet->vadjustment != NULL); - - if (row < 0 || row >= g_sheet_row_get_row_count (sheet->row_geometry)) - return; - if (column < 0 || column >= g_sheet_column_get_column_count (sheet->column_geometry)) - return; - - height = sheet->sheet_window_height; - width = sheet->sheet_window_width; - - /* adjust vertical scrollbar */ - if (row >= 0 && row_align >= 0.0) - { - y = g_sheet_row_start_pixel (sheet->row_geometry, row) - - (gint) ( row_align * height + (1.0 - row_align) - * g_sheet_row_get_height (sheet->row_geometry, row)); - - /* This forces the sheet to scroll when you don't see the entire cell */ - min_row = row; - adjust = 0; - if (row_align >= 1.0) - { - while (min_row >= 0 && min_row > min_visible_row (sheet)) - { - if (g_sheet_row_get_visibility (sheet->row_geometry, min_row)) - adjust += g_sheet_row_get_height (sheet->row_geometry, min_row); + gint width, height; - if (adjust >= height) - { - break; - } - min_row--; - } - min_row = MAX (min_row, 0); + g_return_if_fail (row_align >= 0); + g_return_if_fail (col_align >= 0); - min_row ++; + g_return_if_fail (row_align <= 1); + g_return_if_fail (col_align <= 1); - y = g_sheet_row_start_pixel (sheet->row_geometry, min_row) + - g_sheet_row_get_height (sheet->row_geometry, min_row) - 1; - } + g_return_if_fail (col < + psppire_axis_unit_count (sheet->haxis)); + g_return_if_fail (row < + g_sheet_row_get_row_count (sheet->row_geometry)); - if (y < 0) - sheet->vadjustment->value = 0.0; - else - sheet->vadjustment->value = y; + gdk_drawable_get_size (sheet->sheet_window, &width, &height); - g_signal_emit_by_name (sheet->vadjustment, - "value_changed"); - } + if (row >= 0) + { + gint y = g_sheet_row_start_pixel (sheet->row_geometry, row); - /* adjust horizontal scrollbar */ - if (column >= 0 && col_align >= 0.0) - { - x = column_left_xpixel (sheet, column) - - (gint) ( col_align*width + (1.0 - col_align)* - g_sheet_column_get_width (sheet->column_geometry, column)); - - /* This forces the sheet to scroll when you don't see the entire cell */ - min_col = column; - adjust = 0; - if (col_align == 1.0) - { - while (min_col >= 0 && min_col > min_visible_column (sheet)) - { - if (g_sheet_column_get_visibility (sheet->column_geometry, min_col)) - adjust += g_sheet_column_get_width (sheet->column_geometry, min_col); + gtk_adjustment_set_value (sheet->vadjustment, y - height * row_align); + } - if (adjust >= width) - { - break; - } - min_col--; - } - min_col = MAX (min_col, 0); - x = column_left_xpixel (sheet, min_col) + - g_sheet_column_get_width (sheet->column_geometry, min_col) - 1; - } - if (x < 0) - sheet->hadjustment->value = 0.0; - else - sheet->hadjustment->value = x; + if (col >= 0) + { + gint x = psppire_axis_pixel_start (sheet->haxis, col); - g_signal_emit_by_name (sheet->hadjustment, - "value_changed"); - } + gtk_adjustment_set_value (sheet->hadjustment, x - width * col_align); + } } -void -gtk_sheet_columns_set_resizable (GtkSheet *sheet, gboolean resizable) -{ - g_return_if_fail (sheet != NULL); - g_return_if_fail (GTK_IS_SHEET (sheet)); - - sheet->columns_resizable = resizable; -} - -gboolean +static gboolean gtk_sheet_columns_resizable (GtkSheet *sheet) { g_return_val_if_fail (sheet != NULL, FALSE); @@ -1727,16 +1582,7 @@ gtk_sheet_columns_resizable (GtkSheet *sheet) } -void -gtk_sheet_rows_set_resizable (GtkSheet *sheet, gboolean resizable) -{ - g_return_if_fail (sheet != NULL); - g_return_if_fail (GTK_IS_SHEET (sheet)); - - sheet->rows_resizable = resizable; -} - -gboolean +static gboolean gtk_sheet_rows_resizable (GtkSheet *sheet) { g_return_val_if_fail (sheet != NULL, FALSE); @@ -1757,14 +1603,12 @@ gtk_sheet_select_row (GtkSheet *sheet, gint row) if (sheet->state != GTK_SHEET_NORMAL) gtk_sheet_real_unselect_range (sheet, NULL); - else - gtk_sheet_deactivate_cell (sheet); sheet->state = GTK_SHEET_ROW_SELECTED; sheet->range.row0 = row; sheet->range.col0 = 0; sheet->range.rowi = row; - sheet->range.coli = g_sheet_column_get_column_count (sheet->column_geometry) - 1; + sheet->range.coli = psppire_axis_unit_count (sheet->haxis) - 1; sheet->active_cell.row = row; sheet->active_cell.col = 0; @@ -1774,19 +1618,16 @@ gtk_sheet_select_row (GtkSheet *sheet, gint row) void -gtk_sheet_select_column (GtkSheet * sheet, gint column) +gtk_sheet_select_column (GtkSheet *sheet, gint column) { g_return_if_fail (sheet != NULL); g_return_if_fail (GTK_IS_SHEET (sheet)); - if (column < 0 || column >= g_sheet_column_get_column_count (sheet->column_geometry)) + if (column < 0 || column >= psppire_axis_unit_count (sheet->haxis)) return; if (sheet->state != GTK_SHEET_NORMAL) gtk_sheet_real_unselect_range (sheet, NULL); - else - gtk_sheet_deactivate_cell (sheet); - sheet->state = GTK_SHEET_COLUMN_SELECTED; sheet->range.row0 = 0; @@ -1804,7 +1645,7 @@ gtk_sheet_select_column (GtkSheet * sheet, gint column) static gboolean -gtk_sheet_range_isvisible (const GtkSheet * sheet, +gtk_sheet_range_isvisible (const GtkSheet *sheet, GtkSheetRange range) { g_return_val_if_fail (sheet != NULL, FALSE); @@ -1815,10 +1656,10 @@ gtk_sheet_range_isvisible (const GtkSheet * sheet, if (range.rowi < 0 || range.rowi >= g_sheet_row_get_row_count (sheet->row_geometry)) return FALSE; - if (range.col0 < 0 || range.col0 >= g_sheet_column_get_column_count (sheet->column_geometry)) + if (range.col0 < 0 || range.col0 >= psppire_axis_unit_count (sheet->haxis)) return FALSE; - if (range.coli < 0 || range.coli >= g_sheet_column_get_column_count (sheet->column_geometry)) + if (range.coli < 0 || range.coli >= psppire_axis_unit_count (sheet->haxis)) return FALSE; if (range.rowi < min_visible_row (sheet)) @@ -1837,7 +1678,7 @@ gtk_sheet_range_isvisible (const GtkSheet * sheet, } static gboolean -gtk_sheet_cell_isvisible (GtkSheet * sheet, +gtk_sheet_cell_isvisible (GtkSheet *sheet, gint row, gint column) { GtkSheetRange range; @@ -1895,7 +1736,7 @@ gtk_sheet_set_scroll_adjustments (GtkSheet *sheet, } static void -gtk_sheet_finalize (GObject * object) +gtk_sheet_finalize (GObject *object) { GtkSheet *sheet; @@ -1923,7 +1764,7 @@ gtk_sheet_dispose (GObject *object) if (sheet->model) g_object_unref (sheet->model); if (sheet->row_geometry) g_object_unref (sheet->row_geometry); - if (sheet->column_geometry) g_object_unref (sheet->column_geometry); + if (sheet->haxis) g_object_unref (sheet->haxis); g_object_unref (sheet->entry_container); sheet->entry_container = NULL; @@ -1985,7 +1826,9 @@ gtk_sheet_realize (GtkWidget *widget) { GtkSheet *sheet; GdkWindowAttr attributes; - gint attributes_mask; + const gint attributes_mask = + GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP | GDK_WA_CURSOR; + GdkGCValues values, auxvalues; GdkColormap *colormap; GdkDisplay *display; @@ -2019,8 +1862,6 @@ gtk_sheet_realize (GtkWidget *widget) GDK_LEAVE_NOTIFY_MASK | GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK); - attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP | - GDK_WA_CURSOR; attributes.cursor = gdk_cursor_new_for_display (display, GDK_TOP_LEFT_ARROW); @@ -2071,8 +1912,6 @@ gtk_sheet_realize (GtkWidget *widget) attributes.x = 0; attributes.y = 0; - attributes.width = sheet->sheet_window_width; - attributes.height = sheet->sheet_window_height; sheet->sheet_window = gdk_window_new (widget->window, &attributes, attributes_mask); @@ -2083,15 +1922,10 @@ gtk_sheet_realize (GtkWidget *widget) gdk_window_set_background (sheet->sheet_window, &widget->style->white); gdk_window_show (sheet->sheet_window); - /* backing_pixmap */ - gtk_sheet_make_backing_pixmap (sheet); - /* GCs */ sheet->fg_gc = gdk_gc_new (widget->window); sheet->bg_gc = gdk_gc_new (widget->window); - - gdk_gc_get_values (sheet->fg_gc, &auxvalues); values.foreground = widget->style->white; @@ -2124,8 +1958,8 @@ gtk_sheet_realize (GtkWidget *widget) sheet->hover_window = create_hover_window (); - size_allocate_row_title_buttons (sheet); - size_allocate_column_title_buttons (sheet); + draw_row_title_buttons (sheet); + draw_column_title_buttons (sheet); gtk_sheet_update_primary_selection (sheet); } @@ -2196,12 +2030,6 @@ gtk_sheet_unrealize (GtkWidget *widget) gdk_window_destroy (sheet->column_title_window); gdk_window_destroy (sheet->row_title_window); - if (sheet->pixmap) - { - g_object_unref (sheet->pixmap); - sheet->pixmap = NULL; - } - gtk_widget_unparent (sheet->entry_widget); if (sheet->button != NULL) gtk_widget_unparent (sheet->button); @@ -2211,7 +2039,7 @@ gtk_sheet_unrealize (GtkWidget *widget) } static void -gtk_sheet_map (GtkWidget * widget) +gtk_sheet_map (GtkWidget *widget) { GtkSheet *sheet = GTK_SHEET (widget); @@ -2227,12 +2055,12 @@ gtk_sheet_map (GtkWidget * widget) if (sheet->column_titles_visible) { - size_allocate_column_title_buttons (sheet); + draw_column_title_buttons (sheet); gdk_window_show (sheet->column_title_window); } if (sheet->row_titles_visible) { - size_allocate_row_title_buttons (sheet); + draw_row_title_buttons (sheet); gdk_window_show (sheet->row_title_window); } @@ -2257,14 +2085,14 @@ gtk_sheet_map (GtkWidget * widget) gtk_widget_map (GTK_BIN (sheet->button)->child); gtk_sheet_range_draw (sheet, NULL); - gtk_sheet_activate_cell (sheet, - sheet->active_cell.row, - sheet->active_cell.col); + change_active_cell (sheet, + sheet->active_cell.row, + sheet->active_cell.col); } } static void -gtk_sheet_unmap (GtkWidget * widget) +gtk_sheet_unmap (GtkWidget *widget) { GtkSheet *sheet = GTK_SHEET (widget); @@ -2289,21 +2117,29 @@ gtk_sheet_unmap (GtkWidget * widget) static void -gtk_sheet_cell_draw_default (GtkSheet *sheet, gint row, gint col) +gtk_sheet_cell_draw (GtkSheet *sheet, gint row, gint col) { - GdkGC *fg_gc, *bg_gc; + PangoLayout *layout; + PangoRectangle text; + gint font_height; + + gchar *label; + GtkSheetCellAttr attributes; GdkRectangle area; g_return_if_fail (sheet != NULL); - /* bail now if we arn't drawable yet */ + /* bail now if we aren't yet drawable */ if (!GTK_WIDGET_DRAWABLE (sheet)) return; - if (row < 0 || row >= g_sheet_row_get_row_count (sheet->row_geometry)) return; - if (col < 0 || col >= g_sheet_column_get_column_count (sheet->column_geometry)) return; - if (! g_sheet_column_get_visibility (sheet->column_geometry, col)) return; - if (! g_sheet_row_get_visibility (sheet->row_geometry, row)) return; + if (row < 0 || + row >= g_sheet_row_get_row_count (sheet->row_geometry)) + return; + + if (col < 0 || + col >= psppire_axis_unit_count (sheet->haxis)) + return; gtk_sheet_get_attributes (sheet, row, col, &attributes); @@ -2311,17 +2147,7 @@ gtk_sheet_cell_draw_default (GtkSheet *sheet, gint row, gint col) gdk_gc_set_foreground (sheet->fg_gc, &attributes.foreground); gdk_gc_set_foreground (sheet->bg_gc, &attributes.background); - fg_gc = sheet->fg_gc; - bg_gc = sheet->bg_gc; - - area.x = g_sheet_column_start_pixel (sheet->column_geometry, col); - area.x -= sheet->hadjustment->value; - - area.y = g_sheet_row_start_pixel (sheet->row_geometry, row); - area.y -= sheet->vadjustment->value; - - area.width= g_sheet_column_get_width (sheet->column_geometry, col); - area.height = g_sheet_row_get_height (sheet->row_geometry, row); + rectangle_from_cell (sheet, row, col, &area); gdk_gc_set_line_attributes (sheet->fg_gc, 1, 0, 0, 0); @@ -2329,196 +2155,71 @@ gtk_sheet_cell_draw_default (GtkSheet *sheet, gint row, gint col) { gdk_gc_set_foreground (sheet->bg_gc, &sheet->color[GRID_COLOR]); - gdk_draw_rectangle (sheet->pixmap, + gdk_draw_rectangle (sheet->sheet_window, sheet->bg_gc, FALSE, area.x, area.y, area.width, area.height); } -} + // gtk_sheet_cell_draw_label (sheet, row, col); -static void -gtk_sheet_cell_draw_label (GtkSheet *sheet, gint row, gint col) -{ - GtkWidget *widget; - GdkRectangle area; - gint i; - gint text_width, text_height, y; - gint xoffset = 0; - gint size, sizel, sizer; - GdkGC *fg_gc, *bg_gc; - GtkSheetCellAttr attributes; - PangoLayout *layout; - PangoRectangle rect; - PangoRectangle logical_rect; - PangoLayoutLine *line; - PangoFontMetrics *metrics; - PangoContext *context = gtk_widget_get_pango_context (GTK_WIDGET (sheet)); - gint ascent, descent, y_pos; - - gchar *label; - - g_return_if_fail (sheet != NULL); - - /* bail now if we aren't drawable yet */ - if (!GTK_WIDGET_DRAWABLE (sheet)) - return; label = gtk_sheet_cell_get_text (sheet, row, col); - if (!label) + if (NULL == label) return; - if (row < 0 || row >= g_sheet_row_get_row_count (sheet->row_geometry)) return; - if (col < 0 || col >= g_sheet_column_get_column_count (sheet->column_geometry)) return; - if (! g_sheet_column_get_visibility (sheet->column_geometry, col)) return; - if (!g_sheet_row_get_visibility (sheet->row_geometry, row)) return; - - widget = GTK_WIDGET (sheet); - - gtk_sheet_get_attributes (sheet, row, col, &attributes); - - /* select GC for background rectangle */ - gdk_gc_set_foreground (sheet->fg_gc, &attributes.foreground); - gdk_gc_set_foreground (sheet->bg_gc, &attributes.background); - - fg_gc = sheet->fg_gc; - bg_gc = sheet->bg_gc; - - area.x = g_sheet_column_start_pixel (sheet->column_geometry, col); - area.x -= sheet->hadjustment->value; - - area.y = g_sheet_row_start_pixel (sheet->row_geometry, row); - area.y -= sheet->vadjustment->value; - - area.width = g_sheet_column_get_width (sheet->column_geometry, col); - area.height = g_sheet_row_get_height (sheet->row_geometry, row); - layout = gtk_widget_create_pango_layout (GTK_WIDGET (sheet), label); dispose_string (sheet, label); pango_layout_set_font_description (layout, attributes.font_desc); - pango_layout_get_pixel_extents (layout, NULL, &rect); - line = pango_layout_get_lines (layout)->data; - pango_layout_line_get_extents (line, NULL, &logical_rect); + pango_layout_get_pixel_extents (layout, NULL, &text); - metrics = pango_context_get_metrics (context, - attributes.font_desc, - pango_context_get_language (context)); + gdk_gc_set_clip_rectangle (sheet->fg_gc, &area); - ascent = pango_font_metrics_get_ascent (metrics) / PANGO_SCALE; - descent = pango_font_metrics_get_descent (metrics) / PANGO_SCALE; + font_height = pango_font_description_get_size (attributes.font_desc); + if ( !pango_font_description_get_size_is_absolute (attributes.font_desc)) + font_height /= PANGO_SCALE; - pango_font_metrics_unref (metrics); - - /* Align primarily for locale's ascent / descent */ - - logical_rect.height /= PANGO_SCALE; - logical_rect.y /= PANGO_SCALE; - y_pos = area.height - logical_rect.height; - - if (logical_rect.height > area.height) - y_pos = (logical_rect.height - area.height - 2 * COLUMN_TITLES_HEIGHT) / 2; - else if (y_pos < 0) - y_pos = 0; - else if (y_pos + logical_rect.height > area.height) - y_pos = area.height - logical_rect.height; - - text_width = rect.width; - text_height = rect.height; - y = area.y + y_pos - COLUMN_TITLES_HEIGHT; + /* Centre the text vertically */ + area.y += (area.height - font_height) / 2.0; switch (attributes.justification) { case GTK_JUSTIFY_RIGHT: - size = area.width; - area.x +=area.width; - { - for (i = col - 1; i >= min_visible_column (sheet); i--) - { - if ( !gtk_sheet_cell_empty (sheet, row, i)) break; - if (size >= text_width + COLUMN_TITLES_HEIGHT) break; - size += g_sheet_column_get_width (sheet->column_geometry, i); - g_sheet_column_set_right_text_column (sheet->column_geometry, i, - MAX (col, - g_sheet_column_get_right_text_column (sheet->column_geometry, i))); - } - area.width = size; - } - area.x -= size; - xoffset += area.width - text_width - 2 * COLUMN_TITLES_HEIGHT - - attributes.border.width / 2; + area.x += area.width - text.width; break; case GTK_JUSTIFY_CENTER: - sizel = area.width / 2; - sizer = area.width / 2; - area.x += area.width / 2; - { - for (i = col + 1; i <= max_visible_column (sheet); i++) - { - if ( ! gtk_sheet_cell_empty (sheet, row, i)) break; - if (sizer >= text_width / 2) break; - sizer += g_sheet_column_get_width (sheet->column_geometry, i); - g_sheet_column_set_left_text_column (sheet->column_geometry, i, - MIN ( - col, - g_sheet_column_get_left_text_column (sheet->column_geometry, i))); - } - for (i = col - 1; i >= min_visible_column (sheet); i--) - { - if ( ! gtk_sheet_cell_empty (sheet, row, i)) break; - if (sizel >= text_width / 2) break; - sizel += g_sheet_column_get_width (sheet->column_geometry, i); - g_sheet_column_set_right_text_column (sheet->column_geometry, i, - MAX (col, - g_sheet_column_get_right_text_column (sheet->column_geometry, i))); - } - size = MIN (sizel, sizer); - } - area.x -= sizel; - xoffset += sizel - text_width / 2 - COLUMN_TITLES_HEIGHT; - area.width = sizel + sizer; + area.x += (area.width - text.width) / 2.0; break; case GTK_JUSTIFY_LEFT: + /* Do nothing */ + break; default: - size = area.width; - { - for (i = col + 1; i <= max_visible_column (sheet); i++) - { - if (! gtk_sheet_cell_empty (sheet, row, i)) break; - if (size >= text_width + COLUMN_TITLES_HEIGHT) break; - size += g_sheet_column_get_width (sheet->column_geometry, i); - g_sheet_column_set_left_text_column (sheet->column_geometry, i, - MIN ( - col, - g_sheet_column_get_left_text_column (sheet->column_geometry, i))); - - } - area.width = size; - } - xoffset += attributes.border.width / 2; + g_critical ("Unhandled justification %d in column %d\n", + attributes.justification, col); break; } - gdk_gc_set_clip_rectangle (fg_gc, &area); - - - gdk_draw_layout (sheet->pixmap, fg_gc, - area.x + xoffset + COLUMN_TITLES_HEIGHT, + gdk_draw_layout (sheet->sheet_window, sheet->fg_gc, + area.x, area.y, layout); - gdk_gc_set_clip_rectangle (fg_gc, NULL); + gdk_gc_set_clip_rectangle (sheet->fg_gc, NULL); g_object_unref (layout); - } + + static void gtk_sheet_range_draw (GtkSheet *sheet, const GtkSheetRange *range) { gint i, j; + + GdkRectangle area; GtkSheetRange drawing_range; g_return_if_fail (sheet != NULL); @@ -2528,11 +2229,6 @@ gtk_sheet_range_draw (GtkSheet *sheet, const GtkSheetRange *range) if (!GTK_WIDGET_REALIZED (GTK_WIDGET (sheet))) return; if (!GTK_WIDGET_MAPPED (GTK_WIDGET (sheet))) return; - if (sheet->sheet_window_width <= 0) return; - if (sheet->sheet_window_height <=0) return; - - if (sheet->pixmap == NULL) return ; - if (range == NULL) { drawing_range.row0 = min_visible_row (sheet); @@ -2540,13 +2236,8 @@ gtk_sheet_range_draw (GtkSheet *sheet, const GtkSheetRange *range) drawing_range.rowi = MIN (max_visible_row (sheet), g_sheet_row_get_row_count (sheet->row_geometry) - 1); drawing_range.coli = max_visible_column (sheet); - - gdk_draw_rectangle (sheet->pixmap, - GTK_WIDGET (sheet)->style->white_gc, - TRUE, - 0, 0, - sheet->sheet_window_width, - sheet->sheet_window_height); + gdk_drawable_get_size (sheet->sheet_window, &area.width, &area.height); + area.x = area.y = 0; } else { @@ -2554,17 +2245,24 @@ gtk_sheet_range_draw (GtkSheet *sheet, const GtkSheetRange *range) drawing_range.col0 = MAX (range->col0, min_visible_column (sheet)); drawing_range.rowi = MIN (range->rowi, max_visible_row (sheet)); drawing_range.coli = MIN (range->coli, max_visible_column (sheet)); + + + rectangle_from_range (sheet, &drawing_range, &area); } + + gdk_draw_rectangle (sheet->sheet_window, + GTK_WIDGET (sheet)->style->white_gc, + TRUE, + area.x, area.y, + area.width, area.height); + for (i = drawing_range.row0; i <= drawing_range.rowi; i++) for (j = drawing_range.col0; j <= drawing_range.coli; j++) { - gtk_sheet_cell_draw_default (sheet, i, j); - gtk_sheet_cell_draw_label (sheet, i, j); + gtk_sheet_cell_draw (sheet, i, j); } - gtk_sheet_draw_backing_pixmap (sheet, drawing_range); - if (sheet->state != GTK_SHEET_NORMAL && gtk_sheet_range_isvisible (sheet, sheet->range)) gtk_sheet_range_draw_selection (sheet, drawing_range); @@ -2607,25 +2305,9 @@ gtk_sheet_range_draw_selection (GtkSheet *sheet, GtkSheetRange range) { for (j = range.col0; j <= range.coli; j++) { - - if (gtk_sheet_cell_get_state (sheet, i, j) == GTK_STATE_SELECTED && - g_sheet_column_get_visibility (sheet->column_geometry, j) && g_sheet_row_get_visibility (sheet->row_geometry, i)) + if (gtk_sheet_cell_get_state (sheet, i, j) == GTK_STATE_SELECTED) { - area.x = column_left_xpixel (sheet, j); - if ( sheet->row_titles_visible) - area.x += sheet->row_title_area.width; - - area.x -= sheet->hadjustment->value; - - area.y = g_sheet_row_start_pixel (sheet->row_geometry, i); - if ( sheet->column_titles_visible) - area.y += sheet->column_title_area.height; - - area.y -= sheet->vadjustment->value; - - - area.width= g_sheet_column_get_width (sheet->column_geometry, j); - area.height = g_sheet_row_get_height (sheet->row_geometry, i); + rectangle_from_cell (sheet, i, j, &area); if (i == sheet->range.row0) { @@ -2656,26 +2338,6 @@ gtk_sheet_range_draw_selection (GtkSheet *sheet, GtkSheetRange range) gtk_sheet_draw_border (sheet, sheet->range); } -static void -gtk_sheet_draw_backing_pixmap (GtkSheet *sheet, GtkSheetRange range) -{ - gint width, height; - - if (!GTK_WIDGET_REALIZED (GTK_WIDGET (sheet))) return; - - if ( sheet->pixmap == NULL) return; - - gdk_drawable_get_size (sheet->pixmap, &width, &height); - - gdk_draw_drawable (sheet->sheet_window, - GTK_WIDGET (sheet)->style->fg_gc[GTK_STATE_NORMAL], - sheet->pixmap, - 0, 0, /* src */ - sheet->row_titles_visible ? sheet->row_title_area.width : 0, - sheet->column_titles_visible ? sheet->column_title_area.height : 0, - width, height); -} - static void gtk_sheet_set_cell (GtkSheet *sheet, gint row, gint col, GtkJustification justification, const gchar *text); @@ -2696,66 +2358,23 @@ gtk_sheet_set_cell (GtkSheet *sheet, gint row, gint col, const gchar *text) { GSheetModel *model ; - gboolean changed ; gchar *old_text ; - GtkSheetRange range; - gint text_width; - GtkSheetCellAttr attributes; - g_return_if_fail (sheet != NULL); g_return_if_fail (GTK_IS_SHEET (sheet)); - if (col >= g_sheet_column_get_column_count (sheet->column_geometry) || row >= g_sheet_row_get_row_count (sheet->row_geometry)) return; - if (col < 0 || row < 0) return; - gtk_sheet_get_attributes (sheet, row, col, &attributes); + if (col >= psppire_axis_unit_count (sheet->haxis) + || row >= g_sheet_row_get_row_count (sheet->row_geometry)) + return; - attributes.justification = justification; + if (col < 0 || row < 0) return; model = gtk_sheet_get_model (sheet); old_text = g_sheet_model_get_string (model, row, col); - changed = FALSE; - - if (0 != safe_strcmp (old_text, text)) - changed = g_sheet_model_set_string (model, text, row, col); - if ( g_sheet_model_free_strings (model)) g_free (old_text); - - - if (changed && attributes.is_visible) - { - gchar *s = gtk_sheet_cell_get_text (sheet, row, col); - text_width = 0; - if (s && strlen (s) > 0) - { - text_width = STRING_WIDTH (GTK_WIDGET (sheet), - attributes.font_desc, text); - } - dispose_string (sheet, s); - - range.row0 = row; - range.rowi = row; - range.col0 = min_visible_column (sheet); - range.coli = max_visible_column (sheet); - - if (gtk_sheet_autoresize (sheet) && - text_width > g_sheet_column_get_width (sheet->column_geometry, col) - - 2 * COLUMN_TITLES_HEIGHT- attributes.border.width) - { - gtk_sheet_set_column_width (sheet, col, text_width + 2 * COLUMN_TITLES_HEIGHT - + attributes.border.width); - GTK_SHEET_SET_FLAGS (sheet, GTK_SHEET_REDRAW_PENDING); - } - else - gtk_sheet_range_draw (sheet, &range); - } - - if ( changed ) - g_signal_emit (sheet, sheet_signals[CHANGED], 0, row, col); - } @@ -2766,7 +2385,7 @@ gtk_sheet_cell_clear (GtkSheet *sheet, gint row, gint column) g_return_if_fail (sheet != NULL); g_return_if_fail (GTK_IS_SHEET (sheet)); - if (column >= g_sheet_column_get_column_count (sheet->column_geometry) || + if (column >= psppire_axis_unit_count (sheet->haxis) || row >= g_sheet_row_get_row_count (sheet->row_geometry)) return; if (column < 0 || row < 0) return; @@ -2796,59 +2415,6 @@ gtk_sheet_real_cell_clear (GtkSheet *sheet, gint row, gint column) dispose_string (sheet, old_text); } -void -gtk_sheet_range_clear (GtkSheet *sheet, const GtkSheetRange *range) -{ - g_return_if_fail (sheet != NULL); - g_return_if_fail (GTK_IS_SHEET (sheet)); - - gtk_sheet_real_range_clear (sheet, range); -} - -static void -gtk_sheet_real_range_clear (GtkSheet *sheet, const GtkSheetRange *range) -{ - gint i, j; - GtkSheetRange clear; - - if (!range) - { - clear.row0 = 0; - clear.rowi = g_sheet_row_get_row_count (sheet->row_geometry) - 1; - clear.col0 = 0; - clear.coli = g_sheet_column_get_column_count (sheet->column_geometry) - 1; - } - else - clear=*range; - - clear.row0 = MAX (clear.row0, 0); - clear.col0 = MAX (clear.col0, 0); - clear.rowi = MIN (clear.rowi, g_sheet_row_get_row_count (sheet->row_geometry) - 1 ); - clear.coli = MIN (clear.coli, g_sheet_column_get_column_count (sheet->column_geometry) - 1 ); - - for (i = clear.row0; i <= clear.rowi; i++) - for (j = clear.col0; j <= clear.coli; j++) - { - gtk_sheet_real_cell_clear (sheet, i, j); - } - - gtk_sheet_range_draw (sheet, NULL); -} - - -static gboolean -gtk_sheet_cell_empty (const GtkSheet *sheet, gint row, gint col) -{ - gboolean empty; - char *text = gtk_sheet_cell_get_text (sheet, row, col); - empty = (text == NULL ); - - dispose_string (sheet, text); - - return empty; -} - - gchar * gtk_sheet_cell_get_text (const GtkSheet *sheet, gint row, gint col) { @@ -2856,7 +2422,7 @@ gtk_sheet_cell_get_text (const GtkSheet *sheet, gint row, gint col) g_return_val_if_fail (sheet != NULL, NULL); g_return_val_if_fail (GTK_IS_SHEET (sheet), NULL); - if (col >= g_sheet_column_get_column_count (sheet->column_geometry) || row >= g_sheet_row_get_row_count (sheet->row_geometry)) + if (col >= psppire_axis_unit_count (sheet->haxis) || row >= g_sheet_row_get_row_count (sheet->row_geometry)) return NULL; if (col < 0 || row < 0) return NULL; @@ -2869,7 +2435,7 @@ gtk_sheet_cell_get_text (const GtkSheet *sheet, gint row, gint col) } -GtkStateType +static GtkStateType gtk_sheet_cell_get_state (GtkSheet *sheet, gint row, gint col) { gint state; @@ -2877,7 +2443,7 @@ gtk_sheet_cell_get_state (GtkSheet *sheet, gint row, gint col) g_return_val_if_fail (sheet != NULL, 0); g_return_val_if_fail (GTK_IS_SHEET (sheet), 0); - if (col >= g_sheet_column_get_column_count (sheet->column_geometry) || row >= g_sheet_row_get_row_count (sheet->row_geometry)) return 0; + if (col >= psppire_axis_unit_count (sheet->haxis) || row >= g_sheet_row_get_row_count (sheet->row_geometry)) return 0; if (col < 0 || row < 0) return 0; state = sheet->state; @@ -2935,9 +2501,16 @@ gtk_sheet_get_pixel_info (GtkSheet *sheet, y += sheet->vadjustment->value; - trow = yyy_row_ypixel_to_row (sheet, y); - if (trow > g_sheet_row_get_row_count (sheet->row_geometry)) - return FALSE; + if ( y < 0 && sheet->column_titles_visible) + { + trow = -1; + } + else + { + trow = yyy_row_ypixel_to_row (sheet, y); + if (trow > g_sheet_row_get_row_count (sheet->row_geometry)) + return FALSE; + } *row = trow; @@ -2946,9 +2519,16 @@ gtk_sheet_get_pixel_info (GtkSheet *sheet, x += sheet->hadjustment->value; - tcol = column_from_xpixel (sheet, x); - if (tcol > g_sheet_column_get_column_count (sheet->column_geometry)) - return FALSE; + if ( x < 0 && sheet->row_titles_visible) + { + tcol = -1; + } + else + { + tcol = column_from_xpixel (sheet, x); + if (tcol > psppire_axis_unit_count (sheet->haxis)) + return FALSE; + } *column = tcol; @@ -2956,7 +2536,7 @@ gtk_sheet_get_pixel_info (GtkSheet *sheet, } gboolean -gtk_sheet_get_cell_area (GtkSheet * sheet, +gtk_sheet_get_cell_area (GtkSheet *sheet, gint row, gint column, GdkRectangle *area) @@ -2964,14 +2544,14 @@ gtk_sheet_get_cell_area (GtkSheet * sheet, g_return_val_if_fail (sheet != NULL, 0); g_return_val_if_fail (GTK_IS_SHEET (sheet), 0); - if (row >= g_sheet_row_get_row_count (sheet->row_geometry) || column >= g_sheet_column_get_column_count (sheet->column_geometry)) + if (row >= g_sheet_row_get_row_count (sheet->row_geometry) || column >= psppire_axis_unit_count (sheet->haxis)) return FALSE; - area->x = (column == -1) ? 0 : column_left_xpixel (sheet, column); + area->x = (column == -1) ? 0 : psppire_axis_pixel_start (sheet->haxis, column); area->y = (row == -1) ? 0 : g_sheet_row_start_pixel (sheet->row_geometry, row); area->width= (column == -1) ? sheet->row_title_area.width - : g_sheet_column_get_width (sheet->column_geometry, column); + : psppire_axis_unit_size (sheet->haxis, column); area->height= (row == -1) ? sheet->column_title_area.height : g_sheet_row_get_height (sheet->row_geometry, row); @@ -2979,32 +2559,33 @@ gtk_sheet_get_cell_area (GtkSheet * sheet, return TRUE; } -gboolean -gtk_sheet_set_active_cell (GtkSheet *sheet, gint row, gint column) +void +gtk_sheet_set_active_cell (GtkSheet *sheet, gint row, gint col) { - g_return_val_if_fail (sheet != NULL, 0); - g_return_val_if_fail (GTK_IS_SHEET (sheet), 0); + g_return_if_fail (sheet != NULL); + g_return_if_fail (GTK_IS_SHEET (sheet)); - if (row < - 1 || column < - 1) return FALSE; - if (row >= g_sheet_row_get_row_count (sheet->row_geometry) || column >= g_sheet_column_get_column_count (sheet->column_geometry)) - return FALSE; + if (row < -1 || col < -1) + return; - if (GTK_WIDGET_REALIZED (GTK_WIDGET (sheet))) - gtk_sheet_deactivate_cell (sheet); + if (row >= g_sheet_row_get_row_count (sheet->row_geometry) + || + col >= psppire_axis_unit_count (sheet->haxis)) + return; sheet->active_cell.row = row; - sheet->active_cell.col = column; + sheet->active_cell.col = col; + + if (!GTK_WIDGET_REALIZED (GTK_WIDGET (sheet))) + return; - if ( row == -1 || column == -1) + if ( row == -1 || col == -1) { gtk_sheet_hide_active_cell (sheet); - return TRUE; + return; } - if (!gtk_sheet_activate_cell (sheet, row, column)) return FALSE; - - - return TRUE; + change_active_cell (sheet, row, col); } void @@ -3056,89 +2637,62 @@ gtk_sheet_entry_changed (GtkWidget *widget, gpointer data) } -static void -gtk_sheet_deactivate_cell (GtkSheet *sheet) -{ - g_return_if_fail (sheet != NULL); - g_return_if_fail (GTK_IS_SHEET (sheet)); - - if (!GTK_WIDGET_REALIZED (GTK_WIDGET (sheet))) return ; - if (sheet->state != GTK_SHEET_NORMAL) return ; - - if ( sheet->active_cell.row == -1 || sheet->active_cell.col == -1 ) - return ; - - g_signal_emit (sheet, sheet_signals[DEACTIVATE], 0, - sheet->active_cell.row, - sheet->active_cell.col); - - - g_signal_handlers_disconnect_by_func (gtk_sheet_get_entry (sheet), - G_CALLBACK (gtk_sheet_entry_changed), - sheet); - - gtk_sheet_hide_active_cell (sheet); - sheet->active_cell.row = -1; - sheet->active_cell.col = -1; - - if (GTK_SHEET_REDRAW_PENDING (sheet)) - { - GTK_SHEET_UNSET_FLAGS (sheet, GTK_SHEET_REDRAW_PENDING); - gtk_sheet_range_draw (sheet, NULL); - } -} - static void gtk_sheet_hide_active_cell (GtkSheet *sheet) { - const char *text; - gint row, col; - GtkJustification justification; - GtkSheetCellAttr attributes; - - if (!GTK_WIDGET_REALIZED (GTK_WIDGET (sheet))) return; - - row = sheet->active_cell.row; - col = sheet->active_cell.col; - - if (row < 0 || col < 0) return; - - text = gtk_entry_get_text (GTK_ENTRY (gtk_sheet_get_entry (sheet))); + GdkRectangle area; - gtk_sheet_get_attributes (sheet, row, col, &attributes); - justification = attributes.justification; + if (!GTK_WIDGET_REALIZED (GTK_WIDGET (sheet))) + return; - row = sheet->active_cell.row; - col = sheet->active_cell.col; + if (sheet->active_cell.row < 0 || + sheet->active_cell.col < 0) return; gtk_widget_hide (sheet->entry_widget); gtk_widget_unmap (sheet->entry_widget); - gtk_widget_grab_focus (GTK_WIDGET (sheet)); + rectangle_from_cell (sheet, + sheet->active_cell.row, sheet->active_cell.col, + &area); + + gdk_draw_rectangle (sheet->sheet_window, + GTK_WIDGET (sheet)->style->white_gc, + TRUE, + area.x, area.y, + area.width, area.height); + + gtk_sheet_cell_draw (sheet, sheet->active_cell.row, + sheet->active_cell.col); GTK_WIDGET_UNSET_FLAGS (GTK_WIDGET (sheet->entry_widget), GTK_VISIBLE); } -static gboolean -gtk_sheet_activate_cell (GtkSheet *sheet, gint row, gint col) +static void +change_active_cell (GtkSheet *sheet, gint row, gint col) { - gboolean veto = TRUE; + gint old_row, old_col; + glong old_handler_id = sheet->entry_handler_id; - g_return_val_if_fail (sheet != NULL, FALSE); - g_return_val_if_fail (GTK_IS_SHEET (sheet), FALSE); + g_return_if_fail (GTK_IS_SHEET (sheet)); - if (row < 0 || col < 0) return FALSE; + if (row < 0 || col < 0) + return; - if ( row > g_sheet_row_get_row_count (sheet->row_geometry) || col > g_sheet_column_get_column_count (sheet->column_geometry)) - return FALSE; + if ( row > g_sheet_row_get_row_count (sheet->row_geometry) + || col > psppire_axis_unit_count (sheet->haxis)) + return; - if (!veto) return FALSE; if (sheet->state != GTK_SHEET_NORMAL) { sheet->state = GTK_SHEET_NORMAL; gtk_sheet_real_unselect_range (sheet, NULL); } + g_signal_handler_block (sheet->entry_widget, sheet->entry_handler_id); + + old_row = sheet->active_cell.row; + old_col = sheet->active_cell.col; + sheet->range.row0 = row; sheet->range.col0 = col; sheet->range.rowi = row; @@ -3150,18 +2704,14 @@ gtk_sheet_activate_cell (GtkSheet *sheet, gint row, gint col) GTK_SHEET_UNSET_FLAGS (sheet, GTK_SHEET_IN_SELECTION); - - gtk_sheet_show_active_cell (sheet); - g_signal_connect (gtk_sheet_get_entry (sheet), - "changed", - G_CALLBACK (gtk_sheet_entry_changed), - sheet); - g_signal_emit (sheet, sheet_signals [ACTIVATE], 0, row, col, &veto); + g_signal_emit (sheet, sheet_signals [ACTIVATE], 0, + row, col, old_row, old_col); - return TRUE; + if ( old_handler_id == sheet->entry_handler_id) + g_signal_handler_unblock (sheet->entry_widget, sheet->entry_handler_id); } static void @@ -3170,8 +2720,6 @@ gtk_sheet_show_active_cell (GtkSheet *sheet) GtkEntry *sheet_entry; GtkSheetCellAttr attributes; gchar *text = NULL; - const gchar *old_text; - GtkJustification justification; gint row, col; g_return_if_fail (sheet != NULL); @@ -3194,8 +2742,6 @@ gtk_sheet_show_active_cell (GtkSheet *sheet) gtk_sheet_get_attributes (sheet, row, col, &attributes); - justification = GTK_JUSTIFY_LEFT; - text = gtk_sheet_cell_get_text (sheet, row, col); if ( ! text ) @@ -3204,17 +2750,27 @@ gtk_sheet_show_active_cell (GtkSheet *sheet) gtk_entry_set_visibility (GTK_ENTRY (sheet_entry), attributes.is_visible); - /*** Added by John Gotts. Mar 25, 2005 *********/ - old_text = gtk_entry_get_text (GTK_ENTRY (sheet_entry)); - if (strcmp (old_text, text) != 0) + if ( GTK_IS_ENTRY (sheet_entry)) { - if (!GTK_IS_ITEM_ENTRY (sheet_entry)) + const gchar *old_text = gtk_entry_get_text (GTK_ENTRY (sheet_entry)); + if (strcmp (old_text, text) != 0) gtk_entry_set_text (GTK_ENTRY (sheet_entry), text); - else - gtk_item_entry_set_text (GTK_ITEM_ENTRY (sheet_entry), text, justification); + + switch (attributes.justification) + { + case GTK_JUSTIFY_RIGHT: + gtk_entry_set_alignment (GTK_ENTRY (sheet_entry), 1.0); + break; + case GTK_JUSTIFY_CENTER: + gtk_entry_set_alignment (GTK_ENTRY (sheet_entry), 0.5); + break; + case GTK_JUSTIFY_LEFT: + default: + gtk_entry_set_alignment (GTK_ENTRY (sheet_entry), 0.0); + break; + } } - gtk_sheet_entry_set_max_size (sheet); gtk_sheet_size_allocate_entry (sheet); gtk_widget_map (sheet->entry_widget); @@ -3222,6 +2778,7 @@ gtk_sheet_show_active_cell (GtkSheet *sheet) gtk_widget_grab_focus (GTK_WIDGET (sheet_entry)); dispose_string (sheet, text); + } static void @@ -3238,7 +2795,8 @@ gtk_sheet_draw_active_cell (GtkSheet *sheet) if (row < 0 || col < 0) return; - if (!gtk_sheet_cell_isvisible (sheet, row, col)) return; + if (!gtk_sheet_cell_isvisible (sheet, row, col)) + return; range.col0 = range.coli = col; range.row0 = range.rowi = row; @@ -3248,46 +2806,6 @@ gtk_sheet_draw_active_cell (GtkSheet *sheet) -static void -gtk_sheet_make_backing_pixmap (GtkSheet *sheet) -{ - gint pixmap_width, pixmap_height; - gint width, height; - - if (!GTK_WIDGET_REALIZED (GTK_WIDGET (sheet))) return; - - width = sheet->sheet_window_width ; - height = sheet->sheet_window_height ; - - - if ( width <= 0) return; - if ( height <= 0) return; - - if (!sheet->pixmap) - { - /* allocate */ - sheet->pixmap = gdk_pixmap_new (sheet->sheet_window, - width, height, - - 1); - - gtk_sheet_range_draw (sheet, NULL); - } - else - { - /* reallocate if sizes don't match */ - gdk_drawable_get_size (sheet->pixmap, - &pixmap_width, &pixmap_height); - if ( (pixmap_width != width) || (pixmap_height != height)) - { - g_object_unref (sheet->pixmap); - sheet->pixmap = gdk_pixmap_new (sheet->sheet_window, - width, height, - - 1); - gtk_sheet_range_draw (sheet, NULL); - } - } -} - static void gtk_sheet_new_selection (GtkSheet *sheet, GtkSheetRange *range) { @@ -3327,7 +2845,6 @@ gtk_sheet_new_selection (GtkSheet *sheet, GtkSheetRange *range) j <= new_range.coli && j >= new_range.col0) ? TRUE : FALSE; if (state == GTK_STATE_SELECTED && selected && - g_sheet_column_get_visibility (sheet->column_geometry, j) && g_sheet_row_get_visibility (sheet->row_geometry, i) && (i == sheet->range.row0 || i == sheet->range.rowi || j == sheet->range.col0 || j == sheet->range.coli || i == new_range.row0 || i == new_range.rowi || @@ -3346,10 +2863,10 @@ gtk_sheet_new_selection (GtkSheet *sheet, GtkSheetRange *range) if (mask1 != mask2) { - x = column_left_xpixel (sheet, j); + x = psppire_axis_pixel_start (sheet->haxis, j); y = g_sheet_row_start_pixel (sheet->row_geometry, i); - width = column_left_xpixel (sheet, j)- x+ - g_sheet_column_get_width (sheet->column_geometry, j); + width = psppire_axis_pixel_start (sheet->haxis, j)- x+ + psppire_axis_unit_size (sheet->haxis, j); height = g_sheet_row_start_pixel (sheet->row_geometry, i) - y + g_sheet_row_get_height (sheet->row_geometry, i); if (i == sheet->range.row0) @@ -3367,10 +2884,10 @@ gtk_sheet_new_selection (GtkSheet *sheet, GtkSheetRange *range) if (i != sheet->active_cell.row || j != sheet->active_cell.col) { - x = column_left_xpixel (sheet, j); + x = psppire_axis_pixel_start (sheet->haxis, j); y = g_sheet_row_start_pixel (sheet->row_geometry, i); - width = column_left_xpixel (sheet, j)- x+ - g_sheet_column_get_width (sheet->column_geometry, j); + width = psppire_axis_pixel_start (sheet->haxis, j)- x+ + psppire_axis_unit_size (sheet->haxis, j); height = g_sheet_row_start_pixel (sheet->row_geometry, i) - y + g_sheet_row_get_height (sheet->row_geometry, i); @@ -3407,13 +2924,12 @@ gtk_sheet_new_selection (GtkSheet *sheet, GtkSheetRange *range) selected= (i <= new_range.rowi && i >= new_range.row0 && j <= new_range.coli && j >= new_range.col0) ? TRUE : FALSE; - if (state == GTK_STATE_SELECTED && !selected && - g_sheet_column_get_visibility (sheet->column_geometry, j) && g_sheet_row_get_visibility (sheet->row_geometry, i)) + if (state == GTK_STATE_SELECTED && !selected) { - x = column_left_xpixel (sheet, j); + x = psppire_axis_pixel_start (sheet->haxis, j); y = g_sheet_row_start_pixel (sheet->row_geometry, i); - width = column_left_xpixel (sheet, j) - x + g_sheet_column_get_width (sheet->column_geometry, j); + width = psppire_axis_pixel_start (sheet->haxis, j) - x + psppire_axis_unit_size (sheet->haxis, j); height = g_sheet_row_start_pixel (sheet->row_geometry, i) - y + g_sheet_row_get_height (sheet->row_geometry, i); if (i == sheet->range.row0) @@ -3443,13 +2959,12 @@ gtk_sheet_new_selection (GtkSheet *sheet, GtkSheetRange *range) j <= new_range.coli && j >= new_range.col0) ? TRUE : FALSE; if (state != GTK_STATE_SELECTED && selected && - g_sheet_column_get_visibility (sheet->column_geometry, j) && g_sheet_row_get_visibility (sheet->row_geometry, i) && (i != sheet->active_cell.row || j != sheet->active_cell.col)) { - x = column_left_xpixel (sheet, j); + x = psppire_axis_pixel_start (sheet->haxis, j); y = g_sheet_row_start_pixel (sheet->row_geometry, i); - width = column_left_xpixel (sheet, j) - x + g_sheet_column_get_width (sheet->column_geometry, j); + width = psppire_axis_pixel_start (sheet->haxis, j) - x + psppire_axis_unit_size (sheet->haxis, j); height = g_sheet_row_start_pixel (sheet->row_geometry, i) - y + g_sheet_row_get_height (sheet->row_geometry, i); if (i == new_range.row0) @@ -3480,67 +2995,56 @@ gtk_sheet_new_selection (GtkSheet *sheet, GtkSheetRange *range) { for (j = aux_range.col0; j <= aux_range.coli; j++) { + state = gtk_sheet_cell_get_state (sheet, i, j); - if (g_sheet_column_get_visibility (sheet->column_geometry, j) && g_sheet_row_get_visibility (sheet->row_geometry, i)) - { - - state = gtk_sheet_cell_get_state (sheet, i, j); - - mask1 = i == sheet->range.row0 ? 1 : 0; - mask1 = i == sheet->range.rowi ? mask1 + 2 : mask1; - mask1 = j == sheet->range.col0 ? mask1 + 4 : mask1; - mask1 = j == sheet->range.coli ? mask1 + 8 : mask1; - - mask2 = i == new_range.row0 ? 1 : 0; - mask2 = i == new_range.rowi ? mask2 + 2 : mask2; - mask2 = j == new_range.col0 ? mask2 + 4 : mask2; - mask2 = j == new_range.coli ? mask2 + 8 : mask2; - if (mask2 != mask1 || (mask2 == mask1 && state != GTK_STATE_SELECTED)) - { - x = column_left_xpixel (sheet, j); - y = g_sheet_row_start_pixel (sheet->row_geometry, i); - width = g_sheet_column_get_width (sheet->column_geometry, j); - height = g_sheet_row_get_height (sheet->row_geometry, i); - if (mask2 & 1) - gdk_draw_rectangle (sheet->sheet_window, - sheet->xor_gc, - TRUE, - x + 1, y - 1, - width, 3); - - - if (mask2 & 2) - gdk_draw_rectangle (sheet->sheet_window, - sheet->xor_gc, - TRUE, - x + 1, y + height - 1, - width, 3); - - if (mask2 & 4) - gdk_draw_rectangle (sheet->sheet_window, - sheet->xor_gc, - TRUE, - x - 1, y + 1, - 3, height); - - - if (mask2 & 8) - gdk_draw_rectangle (sheet->sheet_window, - sheet->xor_gc, - TRUE, - x + width - 1, y + 1, - 3, height); - - - - } + mask1 = i == sheet->range.row0 ? 1 : 0; + mask1 = i == sheet->range.rowi ? mask1 + 2 : mask1; + mask1 = j == sheet->range.col0 ? mask1 + 4 : mask1; + mask1 = j == sheet->range.coli ? mask1 + 8 : mask1; + mask2 = i == new_range.row0 ? 1 : 0; + mask2 = i == new_range.rowi ? mask2 + 2 : mask2; + mask2 = j == new_range.col0 ? mask2 + 4 : mask2; + mask2 = j == new_range.coli ? mask2 + 8 : mask2; + if (mask2 != mask1 || (mask2 == mask1 && state != GTK_STATE_SELECTED)) + { + x = psppire_axis_pixel_start (sheet->haxis, j); + y = g_sheet_row_start_pixel (sheet->row_geometry, i); + width = psppire_axis_unit_size (sheet->haxis, j); + height = g_sheet_row_get_height (sheet->row_geometry, i); + if (mask2 & 1) + gdk_draw_rectangle (sheet->sheet_window, + sheet->xor_gc, + TRUE, + x + 1, y - 1, + width, 3); + + + if (mask2 & 2) + gdk_draw_rectangle (sheet->sheet_window, + sheet->xor_gc, + TRUE, + x + 1, y + height - 1, + width, 3); + + if (mask2 & 4) + gdk_draw_rectangle (sheet->sheet_window, + sheet->xor_gc, + TRUE, + x - 1, y + 1, + 3, height); + + + if (mask2 & 8) + gdk_draw_rectangle (sheet->sheet_window, + sheet->xor_gc, + TRUE, + x + width - 1, y + 1, + 3, height); } - } } - *range = new_range; } @@ -3548,63 +3052,22 @@ static void gtk_sheet_draw_border (GtkSheet *sheet, GtkSheetRange new_range) { GdkRectangle area; - gint width, height; - - gint x = column_left_xpixel (sheet, new_range.col0); - gint y = g_sheet_row_start_pixel (sheet->row_geometry, new_range.row0); - - if ( sheet->row_titles_visible) - x += sheet->row_title_area.width; - - x -= sheet->hadjustment->value; - - if ( sheet->column_titles_visible) - y += sheet->column_title_area.height; - - y -= sheet->vadjustment->value; - - width = column_left_xpixel (sheet, new_range.coli) - - column_left_xpixel (sheet, new_range.col0) - + - g_sheet_column_get_width (sheet->column_geometry, new_range.coli); - - height = g_sheet_row_start_pixel (sheet->row_geometry, new_range.rowi) - - g_sheet_row_start_pixel (sheet->row_geometry, new_range.row0) - + - g_sheet_row_get_height (sheet->row_geometry, new_range.rowi); - - area.x = column_left_xpixel (sheet, min_visible_column (sheet)); - if ( sheet->row_titles_visible) - area.x += sheet->row_title_area.width; - - area.x -= sheet->hadjustment->value; - - area.y = g_sheet_row_start_pixel (sheet->row_geometry, min_visible_row (sheet)); - if ( sheet->column_titles_visible) - area.y += sheet->column_title_area.height; - - area.y -= sheet->vadjustment->value; - - area.width = sheet->sheet_window_width; - area.height = sheet->sheet_window_height; - - gdk_gc_set_clip_rectangle (sheet->xor_gc, &area); + rectangle_from_range (sheet, &new_range, &area); gdk_draw_rectangle (sheet->sheet_window, sheet->xor_gc, FALSE, - x, y, - width - 2, - height - 2); - - gdk_gc_set_clip_rectangle (sheet->xor_gc, NULL); + area.x + 1, + area.y + 1, + area.width - 2, + area.height - 2); } static void -gtk_sheet_real_select_range (GtkSheet * sheet, - const GtkSheetRange * range) +gtk_sheet_real_select_range (GtkSheet *sheet, + const GtkSheetRange *range) { gint state; @@ -3619,6 +3082,7 @@ gtk_sheet_real_select_range (GtkSheet * sheet, state = sheet->state; +#if 0 if (range->coli != sheet->range.coli || range->col0 != sheet->range.col0 || range->rowi != sheet->range.rowi || range->row0 != sheet->range.row0) { @@ -3626,9 +3090,9 @@ gtk_sheet_real_select_range (GtkSheet * sheet, } else { - gtk_sheet_draw_backing_pixmap (sheet, sheet->range); gtk_sheet_range_draw_selection (sheet, sheet->range); } +#endif gtk_sheet_update_primary_selection (sheet); @@ -3645,7 +3109,7 @@ gtk_sheet_get_selected_range (GtkSheet *sheet, GtkSheetRange *range) void -gtk_sheet_select_range (GtkSheet * sheet, const GtkSheetRange *range) +gtk_sheet_select_range (GtkSheet *sheet, const GtkSheetRange *range) { g_return_if_fail (sheet != NULL); @@ -3657,8 +3121,6 @@ gtk_sheet_select_range (GtkSheet * sheet, const GtkSheetRange *range) if (sheet->state != GTK_SHEET_NORMAL) gtk_sheet_real_unselect_range (sheet, NULL); - else - gtk_sheet_deactivate_cell (sheet); sheet->range.row0 = range->row0; sheet->range.rowi = range->rowi; @@ -3674,7 +3136,7 @@ gtk_sheet_select_range (GtkSheet * sheet, const GtkSheetRange *range) } void -gtk_sheet_unselect_range (GtkSheet * sheet) +gtk_sheet_unselect_range (GtkSheet *sheet) { if (! GTK_WIDGET_REALIZED (GTK_WIDGET (sheet))) return; @@ -3682,13 +3144,13 @@ gtk_sheet_unselect_range (GtkSheet * sheet) gtk_sheet_real_unselect_range (sheet, NULL); sheet->state = GTK_STATE_NORMAL; - gtk_sheet_activate_cell (sheet, - sheet->active_cell.row, sheet->active_cell.col); + change_active_cell (sheet, + sheet->active_cell.row, sheet->active_cell.col); } static void -gtk_sheet_real_unselect_range (GtkSheet * sheet, +gtk_sheet_real_unselect_range (GtkSheet *sheet, const GtkSheetRange *range) { g_return_if_fail (sheet != NULL); @@ -3703,8 +3165,10 @@ gtk_sheet_real_unselect_range (GtkSheet * sheet, g_signal_emit (sheet, sheet_signals[SELECT_COLUMN], 0, -1); g_signal_emit (sheet, sheet_signals[SELECT_ROW], 0, -1); +#if 0 if (gtk_sheet_range_isvisible (sheet, *range)) gtk_sheet_draw_backing_pixmap (sheet, *range); +#endif sheet->range.row0 = -1; sheet->range.rowi = -1; @@ -3714,8 +3178,8 @@ gtk_sheet_real_unselect_range (GtkSheet * sheet, static gint -gtk_sheet_expose (GtkWidget * widget, - GdkEventExpose * event) +gtk_sheet_expose (GtkWidget *widget, + GdkEventExpose *event) { GtkSheet *sheet; GtkSheetRange range; @@ -3726,57 +3190,73 @@ gtk_sheet_expose (GtkWidget * widget, sheet = GTK_SHEET (widget); - if (GTK_WIDGET_DRAWABLE (widget)) + if (!GTK_WIDGET_DRAWABLE (widget)) + return FALSE; + + /* exposure events on the sheet */ + if (event->window == sheet->row_title_window && + sheet->row_titles_visible) + { + gint i; + for (i = min_visible_row (sheet); i <= max_visible_row (sheet); i++) + gtk_sheet_row_title_button_draw (sheet, i); + } + + if (event->window == sheet->column_title_window && + sheet->column_titles_visible) { - range.row0 = yyy_row_ypixel_to_row (sheet, event->area.y); - range.col0 = column_from_xpixel (sheet, event->area.x); - range.rowi = yyy_row_ypixel_to_row (sheet, - event->area.y + event->area.height); + gint i; + for (i = min_visible_column (sheet); + i <= max_visible_column (sheet); + ++i) + gtk_sheet_column_title_button_draw (sheet, i); + } - range.coli = column_from_xpixel (sheet, - event->area.x + event->area.width); - /* exposure events on the sheet */ - if (event->window == sheet->row_title_window && - sheet->row_titles_visible) - { - gint i; - for (i = min_visible_row (sheet); i <= max_visible_row (sheet); i++) - gtk_sheet_row_title_button_draw (sheet, i); - } + range.row0 = + yyy_row_ypixel_to_row (sheet, + event->area.y + sheet->vadjustment->value); + range.row0--; - if (event->window == sheet->column_title_window && - sheet->column_titles_visible) - { - gint i; - for (i = min_visible_column (sheet); - i <= max_visible_column (sheet); - ++i) - gtk_sheet_column_title_button_draw (sheet, i); - } + range.rowi = + yyy_row_ypixel_to_row (sheet, + event->area.y + + event->area.height + sheet->vadjustment->value); + range.rowi++; + + range.col0 = + column_from_xpixel (sheet, + event->area.x + sheet->hadjustment->value); + range.col0--; - if (event->window == sheet->sheet_window) + range.coli = + column_from_xpixel (sheet, + event->area.x + event->area.width + + sheet->hadjustment->value); + range.coli++; + + if (event->window == sheet->sheet_window) + { + gtk_sheet_range_draw (sheet, &range); + + if (sheet->state != GTK_SHEET_NORMAL) { - gtk_sheet_draw_backing_pixmap (sheet, range); + if (gtk_sheet_range_isvisible (sheet, sheet->range)) + gtk_sheet_range_draw (sheet, &sheet->range); - if (sheet->state != GTK_SHEET_NORMAL) - { - if (gtk_sheet_range_isvisible (sheet, sheet->range)) - gtk_sheet_draw_backing_pixmap (sheet, sheet->range); - if (GTK_SHEET_IN_RESIZE (sheet) || GTK_SHEET_IN_DRAG (sheet)) - gtk_sheet_draw_backing_pixmap (sheet, sheet->drag_range); - - if (gtk_sheet_range_isvisible (sheet, sheet->range)) - gtk_sheet_range_draw_selection (sheet, sheet->range); - if (GTK_SHEET_IN_RESIZE (sheet) || GTK_SHEET_IN_DRAG (sheet)) - draw_xor_rectangle (sheet, sheet->drag_range); - } + if (GTK_SHEET_IN_RESIZE (sheet) || GTK_SHEET_IN_DRAG (sheet)) + gtk_sheet_range_draw (sheet, &sheet->drag_range); - if ((!GTK_SHEET_IN_XDRAG (sheet)) && (!GTK_SHEET_IN_YDRAG (sheet))) - { - if (sheet->state == GTK_SHEET_NORMAL) - gtk_sheet_draw_active_cell (sheet); - } + if (gtk_sheet_range_isvisible (sheet, sheet->range)) + gtk_sheet_range_draw_selection (sheet, sheet->range); + if (GTK_SHEET_IN_RESIZE (sheet) || GTK_SHEET_IN_DRAG (sheet)) + draw_xor_rectangle (sheet, sheet->drag_range); + } + + if ((!GTK_SHEET_IN_XDRAG (sheet)) && (!GTK_SHEET_IN_YDRAG (sheet))) + { + if (sheet->state == GTK_SHEET_NORMAL) + gtk_sheet_draw_active_cell (sheet); } } @@ -3790,12 +3270,13 @@ gtk_sheet_expose (GtkWidget * widget, static gboolean -gtk_sheet_button_press (GtkWidget * widget, - GdkEventButton * event) +gtk_sheet_button_press (GtkWidget *widget, + GdkEventButton *event) { GtkSheet *sheet; GdkModifierType mods; - gint x, y, row, column; + gint x, y; + gint row, column; gboolean veto; g_return_val_if_fail (widget != NULL, FALSE); @@ -3821,10 +3302,12 @@ gtk_sheet_button_press (GtkWidget * widget, sheet_signals[BUTTON_EVENT_COLUMN], 0, column, event); - if ( event->type == GDK_2BUTTON_PRESS && event->button == 1) - g_signal_emit (sheet, - sheet_signals[DOUBLE_CLICK_COLUMN], 0, column); - + if (g_sheet_model_get_column_sensitivity (sheet->model, column)) + { + if ( event->type == GDK_2BUTTON_PRESS && event->button == 1) + g_signal_emit (sheet, + sheet_signals[DOUBLE_CLICK_COLUMN], 0, column); + } } else if (event->window == sheet->row_title_window) { @@ -3832,11 +3315,14 @@ gtk_sheet_button_press (GtkWidget * widget, sheet_signals[BUTTON_EVENT_ROW], 0, row, event); - if ( event->type == GDK_2BUTTON_PRESS && event->button == 1) - g_signal_emit (sheet, - sheet_signals[DOUBLE_CLICK_ROW], 0, row); - } + if (g_sheet_row_get_sensitivity (sheet->row_geometry, row)) + { + if ( event->type == GDK_2BUTTON_PRESS && event->button == 1) + g_signal_emit (sheet, + sheet_signals[DOUBLE_CLICK_ROW], 0, row); + } + } gdk_window_get_pointer (widget->window, NULL, NULL, &mods); @@ -3927,7 +3413,6 @@ gtk_sheet_button_press (GtkWidget * widget, { row = sheet->active_cell.row; column = sheet->active_cell.col; - gtk_sheet_deactivate_cell (sheet); sheet->active_cell.row = row; sheet->active_cell.col = column; sheet->drag_range = sheet->range; @@ -3955,7 +3440,6 @@ gtk_sheet_button_press (GtkWidget * widget, { row = sheet->active_cell.row; column = sheet->active_cell.col; - gtk_sheet_deactivate_cell (sheet); sheet->active_cell.row = row; sheet->active_cell.col = column; sheet->drag_range = sheet->range; @@ -3991,7 +3475,7 @@ gtk_sheet_button_press (GtkWidget * widget, column = column_from_xpixel (sheet, x); - if (g_sheet_column_get_sensitivity (sheet->column_geometry, column)) + if (g_sheet_model_get_column_sensitivity (sheet->model, column)) { veto = gtk_sheet_click_cell (sheet, -1, column); gtk_grab_add (GTK_WIDGET (sheet)); @@ -4024,26 +3508,22 @@ gtk_sheet_button_press (GtkWidget * widget, static gboolean gtk_sheet_click_cell (GtkSheet *sheet, gint row, gint column) { + GtkSheetCell cell; gboolean forbid_move; + cell.row = row; + cell.col = column; + if (row >= g_sheet_row_get_row_count (sheet->row_geometry) - || column >= g_sheet_column_get_column_count (sheet->column_geometry)) + || column >= psppire_axis_unit_count (sheet->haxis)) { return FALSE; } - if (column >= 0 && row >= 0) - { - if (! g_sheet_column_get_visibility (sheet->column_geometry, column) - || !g_sheet_row_get_visibility (sheet->row_geometry, row)) - { - return FALSE; - } - } - g_signal_emit (sheet, sheet_signals[TRAVERSE], 0, - sheet->active_cell.row, sheet->active_cell.col, - &row, &column, &forbid_move); + &sheet->active_cell, + &cell, + &forbid_move); if (forbid_move) { @@ -4053,7 +3533,7 @@ gtk_sheet_click_cell (GtkSheet *sheet, gint row, gint column) row = sheet->active_cell.row; column = sheet->active_cell.col; - gtk_sheet_activate_cell (sheet, row, column); + change_active_cell (sheet, row, column); return FALSE; } @@ -4069,47 +3549,41 @@ gtk_sheet_click_cell (GtkSheet *sheet, gint row, gint column) return TRUE; } - if (row == - 1 && column == - 1) + if (row == -1 && column == -1) { sheet->range.row0 = 0; sheet->range.col0 = 0; sheet->range.rowi = g_sheet_row_get_row_count (sheet->row_geometry) - 1; sheet->range.coli = - g_sheet_column_get_column_count (sheet->column_geometry) - 1; + psppire_axis_unit_count (sheet->haxis) - 1; sheet->active_cell.row = 0; sheet->active_cell.col = 0; gtk_sheet_select_range (sheet, NULL); return TRUE; } - if (row != -1 && column != -1) + if (sheet->state != GTK_SHEET_NORMAL) { - if (sheet->state != GTK_SHEET_NORMAL) - { - sheet->state = GTK_SHEET_NORMAL; - gtk_sheet_real_unselect_range (sheet, NULL); - } - else - { - gtk_sheet_deactivate_cell (sheet); - gtk_sheet_activate_cell (sheet, row, column); - } - - sheet->active_cell.row = row; - sheet->active_cell.col = column; - sheet->selection_cell.row = row; - sheet->selection_cell.col = column; - sheet->range.row0 = row; - sheet->range.col0 = column; - sheet->range.rowi = row; - sheet->range.coli = column; sheet->state = GTK_SHEET_NORMAL; - GTK_SHEET_SET_FLAGS (sheet, GTK_SHEET_IN_SELECTION); - gtk_sheet_draw_active_cell (sheet); - return TRUE; + gtk_sheet_real_unselect_range (sheet, NULL); + } + else + { + change_active_cell (sheet, row, column); } - g_assert_not_reached (); + sheet->active_cell.row = row; + sheet->active_cell.col = column; + sheet->selection_cell.row = row; + sheet->selection_cell.col = column; + sheet->range.row0 = row; + sheet->range.col0 = column; + sheet->range.rowi = row; + sheet->range.coli = column; + sheet->state = GTK_SHEET_NORMAL; + GTK_SHEET_SET_FLAGS (sheet, GTK_SHEET_IN_SELECTION); + gtk_sheet_draw_active_cell (sheet); + return TRUE; } static gint @@ -4213,7 +3687,7 @@ gtk_sheet_button_release (GtkWidget *widget, { GTK_SHEET_UNSET_FLAGS (sheet, GTK_SHEET_IN_SELECTION); gdk_display_pointer_ungrab (display, event->time); - gtk_sheet_activate_cell (sheet, sheet->active_cell.row, + change_active_cell (sheet, sheet->active_cell.row, sheet->active_cell.col); } @@ -4229,6 +3703,7 @@ gtk_sheet_button_release (GtkWidget *widget, + /* Shamelessly lifted from gtktooltips */ static gboolean gtk_sheet_subtitle_paint_window (GtkWidget *tip_window) @@ -4351,9 +3826,7 @@ motion_timeout_callback (gpointer data) if (sheet->row_title_under) { GSheetRow *row_geo = sheet->row_geometry; - gchar *text; - - text = g_sheet_row_get_subtitle (row_geo, row); + gchar *text = g_sheet_row_get_subtitle (row_geo, row); show_subtitle (sheet, row, -1, text); g_free (text); @@ -4361,12 +3834,10 @@ motion_timeout_callback (gpointer data) if (sheet->column_title_under) { - GSheetColumn *col_geo = sheet->column_geometry; - gchar *text; - - text = g_sheet_column_get_subtitle (col_geo, column); + gchar *text = g_sheet_model_get_column_subtitle (sheet->model, + column); - show_subtitle (sheet, -1, column, text ); + show_subtitle (sheet, -1, column, text); g_free (text); } @@ -4412,7 +3883,8 @@ gtk_sheet_motion (GtkWidget *widget, GdkEventMotion *event) if ( gtk_sheet_get_pixel_info (sheet, wx, wy, &row, &column) ) { - if ( row != sheet->hover_window->row || column != sheet->hover_window->column) + if ( row != sheet->hover_window->row || + column != sheet->hover_window->column) { gtk_widget_hide (sheet->hover_window->window); } @@ -4561,7 +4033,7 @@ gtk_sheet_motion (GtkWidget *widget, GdkEventMotion *event) sheet->y_drag = y; aux = sheet->range; if (aux.row0 + row >= 0 && aux.rowi + row < g_sheet_row_get_row_count (sheet->row_geometry) && - aux.col0 + column >= 0 && aux.coli + column < g_sheet_column_get_column_count (sheet->column_geometry)) + aux.col0 + column >= 0 && aux.coli + column < psppire_axis_unit_count (sheet->haxis)) { aux = sheet->drag_range; sheet->drag_range.row0 = sheet->range.row0 + row; @@ -4583,7 +4055,7 @@ gtk_sheet_motion (GtkWidget *widget, GdkEventMotion *event) GtkSheetRange aux; gint v_h, current_col, current_row, col_threshold, row_threshold; v_h = 1; - if (abs (x - column_left_xpixel (sheet, sheet->drag_cell.col)) > + if (abs (x - psppire_axis_pixel_start (sheet->haxis, sheet->drag_cell.col)) > abs (y - g_sheet_row_start_pixel (sheet->row_geometry, sheet->drag_cell.row))) v_h = 2; current_col = column_from_xpixel (sheet, x); @@ -4593,8 +4065,8 @@ gtk_sheet_motion (GtkWidget *widget, GdkEventMotion *event) /*use half of column width resp. row height as threshold to expand selection*/ - col_threshold = column_left_xpixel (sheet, current_col) + - g_sheet_column_get_width (sheet->column_geometry, current_col) / 2; + col_threshold = psppire_axis_pixel_start (sheet->haxis, current_col) + + psppire_axis_unit_size (sheet->haxis, current_col) / 2; if (column > 0) { if (x < col_threshold) @@ -4630,7 +4102,7 @@ gtk_sheet_motion (GtkWidget *widget, GdkEventMotion *event) row = 0; if (aux.row0 + row >= 0 && aux.rowi + row < g_sheet_row_get_row_count (sheet->row_geometry) && - aux.col0 + column >= 0 && aux.coli + column < g_sheet_column_get_column_count (sheet->column_geometry)) + aux.col0 + column >= 0 && aux.coli + column < psppire_axis_unit_count (sheet->haxis)) { aux = sheet->drag_range; sheet->drag_range = sheet->range; @@ -4677,67 +4149,6 @@ gtk_sheet_crossing_notify (GtkWidget *widget, return TRUE; } - -static gboolean -gtk_sheet_move_query (GtkSheet *sheet, gint row, gint column) -{ - guint height, width; - gint new_row = row; - gint new_col = column; - - gint row_move = FALSE; - gint column_move = FALSE; - gfloat row_align = -1.0; - gfloat col_align = -1.0; - - height = sheet->sheet_window_height; - width = sheet->sheet_window_width; - - if (row >= max_visible_row (sheet) && sheet->state != GTK_SHEET_COLUMN_SELECTED) - { - row_align = 1.; - new_row = MIN (g_sheet_row_get_row_count (sheet->row_geometry) - 1, row + 1); - row_move = TRUE; - if (max_visible_row (sheet) == g_sheet_row_get_row_count (sheet->row_geometry) - 1 && - g_sheet_row_start_pixel (sheet->row_geometry, g_sheet_row_get_row_count (sheet->row_geometry) - 1) + - g_sheet_row_get_height (sheet->row_geometry, g_sheet_row_get_row_count (sheet->row_geometry) - 1) < height) - { - row_move = FALSE; - row_align = -1.; - } - } - if (row < min_visible_row (sheet) && sheet->state != GTK_SHEET_COLUMN_SELECTED) - { - row_align= 0.; - row_move = TRUE; - } - if (column >= max_visible_column (sheet) && sheet->state != GTK_SHEET_ROW_SELECTED) - { - col_align = 1.; - new_col = MIN (g_sheet_column_get_column_count (sheet->column_geometry) - 1, column + 1); - column_move = TRUE; - if (max_visible_column (sheet) == (g_sheet_column_get_column_count (sheet->column_geometry) - 1) && - column_left_xpixel (sheet, g_sheet_column_get_column_count (sheet->column_geometry) - 1) + - g_sheet_column_get_width (sheet->column_geometry, g_sheet_column_get_column_count (sheet->column_geometry) - 1) < width) - { - column_move = FALSE; - col_align = -1.; - } - } - if (column < min_visible_column (sheet) && sheet->state != GTK_SHEET_ROW_SELECTED) - { - col_align = 0.0; - column_move = TRUE; - } - - if (row_move || column_move) - { - gtk_sheet_moveto (sheet, new_row, new_col, row_align, col_align); - } - - return (row_move || column_move); -} - static void gtk_sheet_extend_selection (GtkSheet *sheet, gint row, gint column) { @@ -4750,7 +4161,6 @@ gtk_sheet_extend_selection (GtkSheet *sheet, gint row, gint column) if (sheet->selection_mode == GTK_SELECTION_SINGLE) return; - gtk_sheet_move_query (sheet, row, column); gtk_widget_grab_focus (GTK_WIDGET (sheet)); if (GTK_SHEET_IN_DRAG (sheet)) return; @@ -4760,7 +4170,7 @@ gtk_sheet_extend_selection (GtkSheet *sheet, gint row, gint column) switch (sheet->state) { case GTK_SHEET_ROW_SELECTED: - column = g_sheet_column_get_column_count (sheet->column_geometry) - 1; + column = psppire_axis_unit_count (sheet->haxis) - 1; break; case GTK_SHEET_COLUMN_SELECTED: row = g_sheet_row_get_row_count (sheet->row_geometry) - 1; @@ -4842,55 +4252,104 @@ page_vertical (GtkSheet *sheet, GtkScrollType dir) new_row = yyy_row_ypixel_to_row (sheet, vpixel); - gtk_sheet_activate_cell (sheet, new_row, + change_active_cell (sheet, new_row, sheet->active_cell.col); } static void -step_horizontal (GtkSheet *sheet, GtkScrollType dir) +step_sheet (GtkSheet *sheet, GtkScrollType dir) { + gint current_row = sheet->active_cell.row; + gint current_col = sheet->active_cell.col; + GtkSheetCell new_cell ; + gboolean forbidden = FALSE; + + new_cell.row = current_row; + new_cell.col = current_col; + switch ( dir) { + case GTK_SCROLL_STEP_DOWN: + new_cell.row++; + break; + case GTK_SCROLL_STEP_UP: + new_cell.row--; + break; case GTK_SCROLL_STEP_RIGHT: - - gtk_sheet_activate_cell (sheet, - sheet->active_cell.row, - sheet->active_cell.col + 1); + new_cell.col++; break; case GTK_SCROLL_STEP_LEFT: - - gtk_sheet_activate_cell (sheet, - sheet->active_cell.row, - sheet->active_cell.col - 1); + new_cell.col--; break; - default: g_assert_not_reached (); break; } - if ( sheet->active_cell.col >= max_visible_column (sheet)) + + maximize_int (&new_cell.row, 0); + maximize_int (&new_cell.col, 0); + + minimize_int (&new_cell.row, + g_sheet_row_get_row_count (sheet->row_geometry) - 1); + + minimize_int (&new_cell.col, + psppire_axis_unit_count (sheet->haxis) - 1); + + g_signal_emit (sheet, sheet_signals[TRAVERSE], 0, + &sheet->active_cell, + &new_cell, + &forbidden); + + if (forbidden) + return; + + change_active_cell (sheet, new_cell.row, new_cell.col); + + if ( new_cell.col > max_fully_visible_column (sheet)) { glong hpos = - g_sheet_column_start_pixel (sheet->column_geometry, - sheet->active_cell.col + 1); + psppire_axis_pixel_start (sheet->haxis, + new_cell.col + 1); hpos -= sheet->hadjustment->page_size; gtk_adjustment_set_value (sheet->hadjustment, hpos); } - else if ( sheet->active_cell.col <= min_visible_column (sheet)) + else if ( new_cell.col < min_fully_visible_column (sheet)) { glong hpos = - g_sheet_column_start_pixel (sheet->column_geometry, - sheet->active_cell.col); + psppire_axis_pixel_start (sheet->haxis, + new_cell.col); gtk_adjustment_set_value (sheet->hadjustment, hpos); } + + + if ( new_cell.row > max_fully_visible_row (sheet)) + { + glong vpos = + g_sheet_row_start_pixel (sheet->row_geometry, + new_cell.row + 1); + vpos -= sheet->vadjustment->page_size; + + gtk_adjustment_set_value (sheet->vadjustment, + vpos); + } + else if ( new_cell.row < min_fully_visible_row (sheet)) + { + glong vpos = + g_sheet_row_start_pixel (sheet->row_geometry, + new_cell.row); + + gtk_adjustment_set_value (sheet->vadjustment, + vpos); + } } + static gboolean gtk_sheet_key_press (GtkWidget *widget, GdkEventKey *key) @@ -4903,33 +4362,18 @@ gtk_sheet_key_press (GtkWidget *widget, { case GDK_Tab: case GDK_Right: - step_horizontal (sheet, GTK_SCROLL_STEP_RIGHT); + step_sheet (sheet, GTK_SCROLL_STEP_RIGHT); break; case GDK_ISO_Left_Tab: case GDK_Left: - step_horizontal (sheet, GTK_SCROLL_STEP_LEFT); + step_sheet (sheet, GTK_SCROLL_STEP_LEFT); break; - case GDK_Return: case GDK_Down: - gtk_sheet_activate_cell (sheet, - sheet->active_cell.row + ROWS_PER_STEP, - sheet->active_cell.col); - - if ( sheet->active_cell.row >= max_visible_row (sheet)) - gtk_adjustment_set_value (sheet->vadjustment, - sheet->vadjustment->value + - sheet->vadjustment->step_increment); + step_sheet (sheet, GTK_SCROLL_STEP_DOWN); break; case GDK_Up: - gtk_sheet_activate_cell (sheet, - sheet->active_cell.row - ROWS_PER_STEP, - sheet->active_cell.col); - - if ( sheet->active_cell.row < min_visible_row (sheet)) - gtk_adjustment_set_value (sheet->vadjustment, - sheet->vadjustment->value - - sheet->vadjustment->step_increment); + step_sheet (sheet, GTK_SCROLL_STEP_UP); break; case GDK_Page_Down: @@ -4943,7 +4387,7 @@ gtk_sheet_key_press (GtkWidget *widget, gtk_adjustment_set_value (sheet->vadjustment, sheet->vadjustment->lower); - gtk_sheet_activate_cell (sheet, 0, + change_active_cell (sheet, 0, sheet->active_cell.col); break; @@ -4955,11 +4399,13 @@ gtk_sheet_key_press (GtkWidget *widget, sheet->vadjustment->page_increment); /* - gtk_sheet_activate_cell (sheet, + change_active_cellx (sheet, g_sheet_row_get_row_count (sheet->row_geometry) - 1, sheet->active_cell.col); */ - + break; + case GDK_Delete: + gtk_sheet_real_cell_clear (sheet, sheet->active_cell.row, sheet->active_cell.col); break; default: return FALSE; @@ -4982,7 +4428,7 @@ gtk_sheet_size_request (GtkWidget *widget, sheet = GTK_SHEET (widget); requisition->width = 3 * DEFAULT_COLUMN_WIDTH; - requisition->height = 3 * default_row_height (sheet); + requisition->height = 3 * DEFAULT_ROW_HEIGHT; /* compute the size of the column title area */ if (sheet->column_titles_visible) @@ -4995,8 +4441,8 @@ gtk_sheet_size_request (GtkWidget *widget, static void -gtk_sheet_size_allocate (GtkWidget * widget, - GtkAllocation * allocation) +gtk_sheet_size_allocate (GtkWidget *widget, + GtkAllocation *allocation) { GtkSheet *sheet; GtkAllocation sheet_allocation; @@ -5030,9 +4476,6 @@ gtk_sheet_size_allocate (GtkWidget * widget, sheet_allocation.width = allocation->width - 2 * border_width; sheet_allocation.height = allocation->height - 2 * border_width; - sheet->sheet_window_width = sheet_allocation.width; - sheet->sheet_window_height = sheet_allocation.height; - if (GTK_WIDGET_REALIZED (widget)) gdk_window_move_resize (sheet->sheet_window, sheet_allocation.x, @@ -5047,7 +4490,6 @@ gtk_sheet_size_allocate (GtkWidget * widget, if (sheet->row_titles_visible) { sheet->column_title_area.x = sheet->row_title_area.width; - sheet->sheet_window_width -= sheet->row_title_area.width; } sheet->column_title_area.width = sheet_allocation.width ; @@ -5062,7 +4504,7 @@ gtk_sheet_size_allocate (GtkWidget * widget, /* column button allocation */ - size_allocate_column_title_buttons (sheet); + draw_column_title_buttons (sheet); /* position the window which holds the row title buttons */ sheet->row_title_area.x = 0; @@ -5070,7 +4512,6 @@ gtk_sheet_size_allocate (GtkWidget * widget, if (sheet->column_titles_visible) { sheet->row_title_area.y = sheet->column_title_area.height; - sheet->sheet_window_height -= sheet->column_title_area.height; } sheet->row_title_area.height = sheet_allocation.height - @@ -5085,18 +4526,15 @@ gtk_sheet_size_allocate (GtkWidget * widget, /* row button allocation */ - size_allocate_row_title_buttons (sheet); - size_allocate_column_title_buttons (sheet); - - /* re - scale backing pixmap */ - gtk_sheet_make_backing_pixmap (sheet); + draw_row_title_buttons (sheet); + draw_column_title_buttons (sheet); /* set the scrollbars adjustments */ adjust_scrollbars (sheet); } static void -size_allocate_column_title_buttons (GtkSheet * sheet) +draw_column_title_buttons (GtkSheet *sheet) { gint i; gint x, width; @@ -5105,8 +4543,7 @@ size_allocate_column_title_buttons (GtkSheet * sheet) if (!GTK_WIDGET_REALIZED (sheet)) return; - - width = sheet->sheet_window_width; + gdk_drawable_get_size (sheet->sheet_window, &width, NULL); x = 0; if (sheet->row_titles_visible) @@ -5125,7 +4562,8 @@ size_allocate_column_title_buttons (GtkSheet * sheet) sheet->column_title_area.height); } - if (max_visible_column (sheet) == g_sheet_column_get_column_count (sheet->column_geometry) - 1) + if (max_visible_column (sheet) == + psppire_axis_unit_count (sheet->haxis) - 1) gdk_window_clear_area (sheet->column_title_window, 0, 0, sheet->column_title_area.width, @@ -5140,17 +4578,17 @@ size_allocate_column_title_buttons (GtkSheet * sheet) } static void -size_allocate_row_title_buttons (GtkSheet * sheet) +draw_row_title_buttons (GtkSheet *sheet) { gint i; - gint y, height; + gint y = 0; + gint height; if (!sheet->row_titles_visible) return; if (!GTK_WIDGET_REALIZED (sheet)) return; - height = sheet->sheet_window_height; - y = 0; + gdk_drawable_get_size (sheet->sheet_window, NULL, &height); if (sheet->column_titles_visible) { @@ -5167,6 +4605,7 @@ size_allocate_row_title_buttons (GtkSheet * sheet) sheet->row_title_area.width, sheet->row_title_area.height); } + if (max_visible_row (sheet) == g_sheet_row_get_row_count (sheet->row_geometry) - 1) gdk_window_clear_area (sheet->row_title_window, 0, 0, @@ -5189,13 +4628,10 @@ size_allocate_row_title_buttons (GtkSheet * sheet) static void gtk_sheet_size_allocate_entry (GtkSheet *sheet) { - GtkAllocation shentry_allocation; + GtkAllocation entry_alloc; GtkSheetCellAttr attributes = { 0 }; GtkEntry *sheet_entry; - GtkStyle *style = NULL, *previous_style = NULL; - gint row, col; - gint size, max_size, text_size, column_width; - const gchar *text; + if (!GTK_WIDGET_REALIZED (GTK_WIDGET (sheet))) return; if (!GTK_WIDGET_MAPPED (GTK_WIDGET (sheet))) return; @@ -5207,14 +4643,12 @@ gtk_sheet_size_allocate_entry (GtkSheet *sheet) &attributes) ) return ; + gtk_widget_ensure_style (GTK_WIDGET (sheet_entry)); + if ( GTK_WIDGET_REALIZED (sheet->entry_widget) ) { - if (!GTK_WIDGET (sheet_entry)->style) - gtk_widget_ensure_style (GTK_WIDGET (sheet_entry)); + GtkStyle *style = GTK_WIDGET (sheet_entry)->style; - previous_style = GTK_WIDGET (sheet_entry)->style; - - style = gtk_style_copy (previous_style); style->bg[GTK_STATE_NORMAL] = attributes.background; style->fg[GTK_STATE_NORMAL] = attributes.foreground; style->text[GTK_STATE_NORMAL] = attributes.foreground; @@ -5225,157 +4659,14 @@ gtk_sheet_size_allocate_entry (GtkSheet *sheet) pango_font_description_free (style->font_desc); g_assert (attributes.font_desc); style->font_desc = pango_font_description_copy (attributes.font_desc); - - GTK_WIDGET (sheet_entry)->style = style; - gtk_widget_size_request (sheet->entry_widget, NULL); - GTK_WIDGET (sheet_entry)->style = previous_style; - - if (style != previous_style) - { - if (!GTK_IS_ITEM_ENTRY (sheet->entry_widget)) - { - style->bg[GTK_STATE_NORMAL] = previous_style->bg[GTK_STATE_NORMAL]; - style->fg[GTK_STATE_NORMAL] = previous_style->fg[GTK_STATE_NORMAL]; - style->bg[GTK_STATE_ACTIVE] = previous_style->bg[GTK_STATE_ACTIVE]; - style->fg[GTK_STATE_ACTIVE] = previous_style->fg[GTK_STATE_ACTIVE]; - } - gtk_widget_set_style (GTK_WIDGET (sheet_entry), style); - g_object_unref (style); - } - } - - if (GTK_IS_ITEM_ENTRY (sheet_entry)) - max_size = GTK_ITEM_ENTRY (sheet_entry)->text_max_size; - else - max_size = 0; - - text_size = 0; - text = gtk_entry_get_text (GTK_ENTRY (sheet_entry)); - if (text && strlen (text) > 0) - text_size = STRING_WIDTH (GTK_WIDGET (sheet), attributes.font_desc, text); - - column_width = g_sheet_column_get_width (sheet->column_geometry, sheet->active_cell.col); - - size = MIN (text_size, max_size); - size = MAX (size, column_width - 2 * COLUMN_TITLES_HEIGHT); - - row = sheet->active_cell.row; - col = sheet->active_cell.col; - - shentry_allocation.x = column_left_xpixel (sheet, sheet->active_cell.col); - shentry_allocation.y = g_sheet_row_start_pixel (sheet->row_geometry, sheet->active_cell.row); - if ( sheet->column_titles_visible) - shentry_allocation.y += sheet->column_title_area.height; - - shentry_allocation.y -= sheet->vadjustment->value; - - if ( sheet->row_titles_visible) - shentry_allocation.x += sheet->row_title_area.width; - - shentry_allocation.x -= sheet->hadjustment->value; - - shentry_allocation.width = column_width; - shentry_allocation.height = g_sheet_row_get_height (sheet->row_geometry, sheet->active_cell.row); - - if (GTK_IS_ITEM_ENTRY (sheet->entry_widget)) - { - shentry_allocation.height -= 2 * COLUMN_TITLES_HEIGHT; - shentry_allocation.y += COLUMN_TITLES_HEIGHT; - shentry_allocation.width = size; - - switch (GTK_ITEM_ENTRY (sheet_entry)->justification) - { - case GTK_JUSTIFY_CENTER: - shentry_allocation.x += column_width / 2 - size / 2; - break; - case GTK_JUSTIFY_RIGHT: - shentry_allocation.x += column_width - size - COLUMN_TITLES_HEIGHT; - break; - case GTK_JUSTIFY_LEFT: - case GTK_JUSTIFY_FILL: - shentry_allocation.x += COLUMN_TITLES_HEIGHT; - break; - } - } - - if (!GTK_IS_ITEM_ENTRY (sheet->entry_widget)) - { - shentry_allocation.x += 2; - shentry_allocation.y += 2; - shentry_allocation.width -= MIN (shentry_allocation.width, 3); - shentry_allocation.height -= MIN (shentry_allocation.height, 3); } - gtk_widget_size_allocate (sheet->entry_widget, &shentry_allocation); - - if (previous_style == style) g_object_unref (previous_style); -} - -static void -gtk_sheet_entry_set_max_size (GtkSheet *sheet) -{ - gint i; - gint size = 0; - gint sizel = 0, sizer = 0; - gint row, col; - GtkJustification justification; - gchar *s = NULL; - - row = sheet->active_cell.row; - col = sheet->active_cell.col; - - if ( ! GTK_IS_ITEM_ENTRY (sheet->entry_widget) ) - return; - - justification = GTK_ITEM_ENTRY (sheet->entry_widget)->justification; + rectangle_from_cell (sheet, sheet->active_cell.row, + sheet->active_cell.col, &entry_alloc); - switch (justification) - { - case GTK_JUSTIFY_FILL: - case GTK_JUSTIFY_LEFT: - for (i = col + 1; i <= max_visible_column (sheet); i++) - { - if ((s = gtk_sheet_cell_get_text (sheet, row, i))) - { - g_free (s); - break; - } - size +=g_sheet_column_get_width (sheet->column_geometry, i); - } - size = MIN (size, sheet->sheet_window_width - column_left_xpixel (sheet, col)); - break; - case GTK_JUSTIFY_RIGHT: - for (i = col - 1; i >= min_visible_column (sheet); i--) - { - if ((s = gtk_sheet_cell_get_text (sheet, row, i))) - { - g_free (s); - break; - } - size +=g_sheet_column_get_width (sheet->column_geometry, i); - } - break; - case GTK_JUSTIFY_CENTER: - for (i = col + 1; i <= max_visible_column (sheet); i++) - { - sizer += g_sheet_column_get_width (sheet->column_geometry, i); - } - for (i = col - 1; i >= min_visible_column (sheet); i--) - { - if ((s = gtk_sheet_cell_get_text (sheet, row, i))) - { - g_free (s); - break; - } - sizel +=g_sheet_column_get_width (sheet->column_geometry, i); - } - size = 2 * MIN (sizel, sizer); - break; - } - - if (size != 0) - size += g_sheet_column_get_width (sheet->column_geometry, col); - GTK_ITEM_ENTRY (sheet->entry_widget)->text_max_size = size; + gtk_widget_set_size_request (sheet->entry_widget, entry_alloc.width, + entry_alloc.height); + gtk_widget_size_allocate (sheet->entry_widget, &entry_alloc); } @@ -5398,7 +4689,7 @@ create_sheet_entry (GtkSheet *sheet) g_warning ("Entry type is %s. It must be GtkEntry subclass, or a widget containing one. " "Using default", g_type_name (sheet->entry_type)); g_object_unref (sheet->entry_container); - sheet->entry_widget = sheet->entry_container = gtk_item_entry_new (); + sheet->entry_widget = sheet->entry_container = gtk_entry_new (); } else { @@ -5407,7 +4698,7 @@ create_sheet_entry (GtkSheet *sheet) } else { - sheet->entry_widget = sheet->entry_container = gtk_item_entry_new (); + sheet->entry_widget = sheet->entry_container = gtk_entry_new (); g_object_ref_sink (sheet->entry_container); } @@ -5424,6 +4715,12 @@ create_sheet_entry (GtkSheet *sheet) G_CALLBACK (gtk_sheet_entry_key_press), sheet); + sheet->entry_handler_id = + g_signal_connect (sheet->entry_widget, + "changed", + G_CALLBACK (gtk_sheet_entry_changed), + sheet); + gtk_widget_show (sheet->entry_widget); } @@ -5530,7 +4827,7 @@ gtk_sheet_button_draw (GtkSheet *sheet, GdkWindow *window, if (button->label_visible) { - text_height = default_row_height (sheet) - + text_height = DEFAULT_ROW_HEIGHT - 2 * COLUMN_TITLES_HEIGHT; gdk_gc_set_clip_rectangle (GTK_WIDGET (sheet)->style->fg_gc[button->state], @@ -5623,19 +4920,18 @@ gtk_sheet_column_title_button_draw (GtkSheet *sheet, gint column) if (!GTK_WIDGET_REALIZED (GTK_WIDGET (sheet))) return; if (!sheet->column_titles_visible) return; - if (!g_sheet_column_get_visibility (sheet->column_geometry, column)) return; if (column < min_visible_column (sheet)) return; if (column > max_visible_column (sheet)) return; - button = g_sheet_column_get_button (sheet->column_geometry, column); + button = g_sheet_model_get_column_button (sheet->model, column); allocation.y = 0; - allocation.x = column_left_xpixel (sheet, column) + CELL_SPACING; + allocation.x = psppire_axis_pixel_start (sheet->haxis, column) + CELL_SPACING; allocation.x -= sheet->hadjustment->value; allocation.height = sheet->column_title_area.height; - allocation.width = g_sheet_column_get_width (sheet->column_geometry, column); - is_sensitive = g_sheet_column_get_sensitivity (sheet->column_geometry, column); + allocation.width = psppire_axis_unit_size (sheet->haxis, column); + is_sensitive = g_sheet_model_get_column_sensitivity (sheet->model, column); gtk_sheet_button_draw (sheet, sheet->column_title_window, button, is_sensitive, allocation); @@ -5653,7 +4949,6 @@ gtk_sheet_row_title_button_draw (GtkSheet *sheet, gint row) if (!GTK_WIDGET_REALIZED (GTK_WIDGET (sheet))) return; if (!sheet->row_titles_visible) return; - if (!g_sheet_row_get_visibility (sheet->row_geometry, row)) return; if (row < min_visible_row (sheet)) return; if (row > max_visible_row (sheet)) return; @@ -5681,6 +4976,19 @@ gtk_sheet_row_title_button_draw (GtkSheet *sheet, gint row) static void adjust_scrollbars (GtkSheet *sheet) { + gint width, height; + + if (!GTK_WIDGET_REALIZED (GTK_WIDGET (sheet))) + return; + + gdk_drawable_get_size (sheet->sheet_window, &width, &height); + + if ( sheet->row_titles_visible) + width -= sheet->row_title_area.width; + + if (sheet->column_titles_visible) + height -= sheet->column_title_area.height; + if (sheet->vadjustment) { glong last_row = g_sheet_row_get_row_count (sheet->row_geometry) - 1; @@ -5690,7 +4998,7 @@ adjust_scrollbars (GtkSheet *sheet) g_sheet_row_get_height (sheet->row_geometry, last_row); sheet->vadjustment->page_increment = - sheet->sheet_window_height - + height - sheet->column_title_area.height - g_sheet_row_get_height (sheet->row_geometry, last_row); @@ -5703,7 +5011,7 @@ adjust_scrollbars (GtkSheet *sheet) ; sheet->vadjustment->lower = 0; - sheet->vadjustment->page_size = sheet->sheet_window_height; + sheet->vadjustment->page_size = height; g_signal_emit_by_name (sheet->vadjustment, "changed"); } @@ -5711,46 +5019,58 @@ adjust_scrollbars (GtkSheet *sheet) if (sheet->hadjustment) { gint last_col; - sheet->hadjustment->step_increment = 1 ; //DEFAULT_COLUMN_WIDTH; + sheet->hadjustment->step_increment = 1; - sheet->hadjustment->page_increment = sheet->sheet_window_width ; + sheet->hadjustment->page_increment = width; - last_col = g_sheet_column_get_column_count (sheet->column_geometry) - 1; + last_col = psppire_axis_unit_count (sheet->haxis) - 1; sheet->hadjustment->upper = - g_sheet_column_start_pixel (sheet->column_geometry, last_col) + psppire_axis_pixel_start (sheet->haxis, last_col) + - g_sheet_column_get_width (sheet->column_geometry, last_col) + psppire_axis_unit_size (sheet->haxis, last_col) ; sheet->hadjustment->lower = 0; - sheet->hadjustment->page_size = sheet->sheet_window_width; + sheet->hadjustment->page_size = width; g_signal_emit_by_name (sheet->hadjustment, "changed"); } } static void -vadjustment_value_changed (GtkAdjustment * adjustment, +vadjustment_value_changed (GtkAdjustment *adjustment, gpointer data) { + GdkRegion *region; GtkSheet *sheet = GTK_SHEET (data); g_return_if_fail (adjustment != NULL); if ( ! GTK_WIDGET_REALIZED (sheet)) return; + gtk_widget_hide (sheet->entry_widget); + + region = + gdk_drawable_get_visible_region (GDK_DRAWABLE (sheet->sheet_window)); + + gdk_window_begin_paint_region (sheet->sheet_window, region); + + gtk_sheet_range_draw (sheet, NULL); - size_allocate_row_title_buttons (sheet); + draw_row_title_buttons (sheet); // size_allocate_global_button (sheet); + + gdk_window_end_paint (sheet->sheet_window); } static void -hadjustment_value_changed (GtkAdjustment * adjustment, +hadjustment_value_changed (GtkAdjustment *adjustment, gpointer data) { + GdkRegion *region; GtkSheet *sheet = GTK_SHEET (data); g_return_if_fail (adjustment != NULL); @@ -5758,17 +5078,30 @@ hadjustment_value_changed (GtkAdjustment * adjustment, if ( ! GTK_WIDGET_REALIZED (sheet)) return; gtk_widget_hide (sheet->entry_widget); + + + region = + gdk_drawable_get_visible_region (GDK_DRAWABLE (sheet->sheet_window)); + + gdk_window_begin_paint_region (sheet->sheet_window, region); + gtk_sheet_range_draw (sheet, NULL); - size_allocate_column_title_buttons (sheet); + draw_column_title_buttons (sheet); // size_allocate_global_button (sheet); + + gdk_window_end_paint (sheet->sheet_window); } /* COLUMN RESIZING */ static void -draw_xor_vline (GtkSheet * sheet) +draw_xor_vline (GtkSheet *sheet) { + gint height; gint xpos = sheet->x_drag; + gdk_drawable_get_size (sheet->sheet_window, + NULL, &height); + if (sheet->row_titles_visible) xpos += sheet->row_title_area.width; @@ -5777,23 +5110,28 @@ draw_xor_vline (GtkSheet * sheet) xpos, sheet->column_title_area.height, xpos, - sheet->sheet_window_height + CELL_SPACING); + height + CELL_SPACING); } /* ROW RESIZING */ static void -draw_xor_hline (GtkSheet * sheet) +draw_xor_hline (GtkSheet *sheet) { + gint width; gint ypos = sheet->y_drag; + gdk_drawable_get_size (sheet->sheet_window, + &width, NULL); + + if (sheet->column_titles_visible) ypos += sheet->column_title_area.height; gdk_draw_line (GTK_WIDGET (sheet)->window, sheet->xor_gc, sheet->row_title_area.width, ypos, - sheet->sheet_window_width + CELL_SPACING, + width + CELL_SPACING, ypos); } @@ -5805,17 +5143,18 @@ draw_xor_rectangle (GtkSheet *sheet, GtkSheetRange range) GdkRectangle clip_area, area; GdkGCValues values; - area.x = column_left_xpixel (sheet, range.col0); + area.x = psppire_axis_pixel_start (sheet->haxis, range.col0); area.y = g_sheet_row_start_pixel (sheet->row_geometry, range.row0); - area.width = column_left_xpixel (sheet, range.coli)- area.x+ - g_sheet_column_get_width (sheet->column_geometry, range.coli); + area.width = psppire_axis_pixel_start (sheet->haxis, range.coli)- area.x+ + psppire_axis_unit_size (sheet->haxis, range.coli); area.height = g_sheet_row_start_pixel (sheet->row_geometry, range.rowi)- area.y + g_sheet_row_get_height (sheet->row_geometry, range.rowi); clip_area.x = sheet->row_title_area.width; clip_area.y = sheet->column_title_area.height; - clip_area.width = sheet->sheet_window_width; - clip_area.height = sheet->sheet_window_height; + + gdk_drawable_get_size (sheet->sheet_window, + &clip_area.width, &clip_area.height); if (!sheet->row_titles_visible) clip_area.x = 0; if (!sheet->column_titles_visible) clip_area.y = 0; @@ -5862,7 +5201,7 @@ draw_xor_rectangle (GtkSheet *sheet, GtkSheetRange range) static guint new_column_width (GtkSheet *sheet, gint column, gint *x) { - gint left_pos = column_left_xpixel (sheet, column) + gint left_pos = psppire_axis_pixel_start (sheet->haxis, column) - sheet->hadjustment->value; gint width = *x - left_pos; @@ -5873,9 +5212,11 @@ new_column_width (GtkSheet *sheet, gint column, gint *x) *x = left_pos + width; } +#if AXIS_TRANSITION g_sheet_column_set_width (sheet->column_geometry, column, width); +#endif - size_allocate_column_title_buttons (sheet); + draw_column_title_buttons (sheet); return width; } @@ -5906,13 +5247,13 @@ new_row_height (GtkSheet *sheet, gint row, gint *y) height = min_height; g_sheet_row_set_height (sheet->row_geometry, row, height); - size_allocate_row_title_buttons (sheet); + draw_row_title_buttons (sheet); return height; } static void -gtk_sheet_set_column_width (GtkSheet * sheet, +gtk_sheet_set_column_width (GtkSheet *sheet, gint column, guint width) { @@ -5921,29 +5262,29 @@ gtk_sheet_set_column_width (GtkSheet * sheet, g_return_if_fail (sheet != NULL); g_return_if_fail (GTK_IS_SHEET (sheet)); - if (column < 0 || column >= g_sheet_column_get_column_count (sheet->column_geometry)) + if (column < 0 || column >= psppire_axis_unit_count (sheet->haxis)) return; gtk_sheet_column_size_request (sheet, column, &min_width); if (width < min_width) return; +#if AXIS_TRANSITION g_sheet_column_set_width (sheet->column_geometry, column, width); +#endif if (GTK_WIDGET_REALIZED (GTK_WIDGET (sheet))) { - size_allocate_column_title_buttons (sheet); + draw_column_title_buttons (sheet); adjust_scrollbars (sheet); gtk_sheet_size_allocate_entry (sheet); gtk_sheet_range_draw (sheet, NULL); } - - g_signal_emit (sheet, sheet_signals[CHANGED], 0, -1, column); } -void -gtk_sheet_set_row_height (GtkSheet * sheet, +static void +gtk_sheet_set_row_height (GtkSheet *sheet, gint row, guint height) { @@ -5962,111 +5303,76 @@ gtk_sheet_set_row_height (GtkSheet * sheet, if (GTK_WIDGET_REALIZED (GTK_WIDGET (sheet)) ) { - size_allocate_row_title_buttons (sheet); + draw_row_title_buttons (sheet); adjust_scrollbars (sheet); gtk_sheet_size_allocate_entry (sheet); gtk_sheet_range_draw (sheet, NULL); } - - g_signal_emit (sheet, sheet_signals[CHANGED], 0, row, - 1); } + gboolean gtk_sheet_get_attributes (const GtkSheet *sheet, gint row, gint col, - GtkSheetCellAttr *attributes) + GtkSheetCellAttr *attr) { - const GdkColor *fg, *bg; + GdkColor *fg, *bg; const GtkJustification *j ; const PangoFontDescription *font_desc ; const GtkSheetCellBorder *border ; + GdkColormap *colormap; g_return_val_if_fail (sheet != NULL, FALSE); g_return_val_if_fail (GTK_IS_SHEET (sheet), FALSE); if (row < 0 || col < 0) return FALSE; - init_attributes (sheet, col, attributes); - if ( !sheet->model) - return FALSE; + attr->foreground = GTK_WIDGET (sheet)->style->black; + attr->background = sheet->color[BG_COLOR]; - attributes->is_editable = g_sheet_model_is_editable (sheet->model, row, col); - attributes->is_visible = g_sheet_model_is_visible (sheet->model, row, col); + attr->border.width = 0; + attr->border.line_style = GDK_LINE_SOLID; + attr->border.cap_style = GDK_CAP_NOT_LAST; + attr->border.join_style = GDK_JOIN_MITER; + attr->border.mask = 0; + attr->border.color = GTK_WIDGET (sheet)->style->black; + attr->font_desc = GTK_WIDGET (sheet)->style->font_desc; + attr->is_editable = g_sheet_model_is_editable (sheet->model, row, col); + attr->is_visible = g_sheet_model_is_visible (sheet->model, row, col); + + + colormap = gtk_widget_get_colormap (GTK_WIDGET (sheet)); fg = g_sheet_model_get_foreground (sheet->model, row, col); if ( fg ) - attributes->foreground = *fg; + { + gdk_colormap_alloc_color (colormap, fg, TRUE, TRUE); + attr->foreground = *fg; + } bg = g_sheet_model_get_background (sheet->model, row, col); if ( bg ) - attributes->background = *bg; + { + gdk_colormap_alloc_color (colormap, bg, TRUE, TRUE); + attr->background = *bg; + } + + attr->justification = + g_sheet_model_get_column_justification (sheet->model, col); j = g_sheet_model_get_justification (sheet->model, row, col); - if (j) attributes->justification = *j; + if (j) + attr->justification = *j; font_desc = g_sheet_model_get_font_desc (sheet->model, row, col); - if ( font_desc ) attributes->font_desc = font_desc; + if ( font_desc ) attr->font_desc = font_desc; border = g_sheet_model_get_cell_border (sheet->model, row, col); - if ( border ) attributes->border = *border; + if ( border ) attr->border = *border; return TRUE; } -static void -init_attributes (const GtkSheet *sheet, gint col, GtkSheetCellAttr *attributes) -{ - /* DEFAULT VALUES */ - attributes->foreground = GTK_WIDGET (sheet)->style->black; - attributes->background = sheet->color[BG_COLOR]; - if (!GTK_WIDGET_REALIZED (GTK_WIDGET (sheet))) - { - attributes->background = sheet->color[BG_COLOR]; - } - attributes->justification = g_sheet_column_get_justification (sheet->column_geometry, col); - attributes->border.width = 0; - attributes->border.line_style = GDK_LINE_SOLID; - attributes->border.cap_style = GDK_CAP_NOT_LAST; - attributes->border.join_style = GDK_JOIN_MITER; - attributes->border.mask = 0; - attributes->border.color = GTK_WIDGET (sheet)->style->black; - attributes->is_editable = TRUE; - attributes->is_visible = TRUE; - attributes->font_desc = GTK_WIDGET (sheet)->style->font_desc; -} - -static void -label_size_request (GtkSheet *sheet, gchar *label, GtkRequisition *req) -{ - gchar *words; - gchar word[1000]; - gint n = 0; - gint row_height = default_row_height (sheet) - 2 * COLUMN_TITLES_HEIGHT + 2; - - req->height = 0; - req->width = 0; - words = label; - - while (words && *words != '\0') - { - if (*words == '\n' || * (words + 1) == '\0') - { - req->height += row_height; - - word[n] = '\0'; - req->width = MAX (req->width, STRING_WIDTH (GTK_WIDGET (sheet), GTK_WIDGET (sheet)->style->font_desc, word)); - n = 0; - } - else - { - word[n++] = *words; - } - words++; - } - - if (n > 0) req->height -= 2; -} - static void gtk_sheet_button_size_request (GtkSheet *sheet, const GtkSheetButton *button, @@ -6075,19 +5381,10 @@ gtk_sheet_button_size_request (GtkSheet *sheet, GtkRequisition requisition; GtkRequisition label_requisition; - if (gtk_sheet_autoresize (sheet) && button->label && strlen (button->label) > 0) - { - label_size_request (sheet, button->label, &label_requisition); - label_requisition.width += 2 * COLUMN_TITLES_HEIGHT; - label_requisition.height += 2 * COLUMN_TITLES_HEIGHT; - } - else - { - label_requisition.height = default_row_height (sheet); - label_requisition.width = COLUMN_MIN_WIDTH; - } + label_requisition.height = DEFAULT_ROW_HEIGHT; + label_requisition.width = COLUMN_MIN_WIDTH; - requisition.height = default_row_height (sheet); + requisition.height = DEFAULT_ROW_HEIGHT; requisition.width = COLUMN_MIN_WIDTH; @@ -6110,7 +5407,7 @@ gtk_sheet_row_size_request (GtkSheet *sheet, *requisition = button_requisition.height; - sheet->row_requisition = * requisition; + sheet->row_requisition = *requisition; } static void @@ -6120,7 +5417,7 @@ gtk_sheet_column_size_request (GtkSheet *sheet, { GtkRequisition button_requisition; - GtkSheetButton *button = g_sheet_column_get_button (sheet->column_geometry, col); + GtkSheetButton *button = g_sheet_model_get_column_button (sheet->model, col); gtk_sheet_button_size_request (sheet, button, @@ -6184,7 +5481,6 @@ gtk_sheet_button_free (GtkSheetButton *button) g_free (button); } - static void append_cell_text (GString *string, const GtkSheet *sheet, gint r, gint c) { @@ -6335,4 +5631,3 @@ gtk_sheet_update_primary_selection (GtkSheet *sheet) gtk_clipboard_clear (clipboard); } } -