-#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
*
#include <gtk/gtkentry.h>
#include <gtk/gtkcontainer.h>
#include <pango/pango.h>
-#include "gtkitementry.h"
#include "gtksheet.h"
-#include "gtkextra-marshal.h"
+#include <gtksheet/psppire-marshal.h>
#include "gsheetmodel.h"
+#include <libpspp/misc.h>
+#include <math.h>
/* 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,
#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
#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 draw_column_title_buttons_range (GtkSheet *sheet, gint first, gint n);
+static void draw_row_title_buttons_range (GtkSheet *sheet, gint first, gint n);
-static void gtk_sheet_row_title_button_draw (GtkSheet *sheet, gint row);
static void gtk_sheet_set_row_height (GtkSheet *sheet,
gint row,
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;
- }
-}
+/* FIXME: Why bother with these two ? */
-static
-guint STRING_WIDTH (GtkWidget *widget,
- const PangoFontDescription *font, const gchar *text)
+/* returns the column index from a pixel location */
+static inline gint
+column_from_xpixel (const GtkSheet *sheet, gint pixel)
{
- PangoRectangle rect;
- PangoLayout *layout;
-
- layout = gtk_widget_create_pango_layout (widget, text);
- pango_layout_set_font_description (layout, font);
-
- pango_layout_get_extents (layout, NULL, &rect);
-
- g_object_unref (layout);
- return PANGO_PIXELS (rect.width);
+ return psppire_axis_get_unit_at_pixel (sheet->haxis, pixel);
}
-/* Return the row containing pixel Y */
-static gint
-yyy_row_ypixel_to_row (const GtkSheet *sheet, gint y)
+static inline gint
+row_from_ypixel (const GtkSheet *sheet, gint pixel)
{
- GSheetRow *geo = sheet->row_geometry;
-
- if (y < 0)
- {
- g_error ("This shouldnt happen");
- return -1;
- }
-
- return g_sheet_row_pixel_to_row (geo, y);
+ return psppire_axis_get_unit_at_pixel (sheet->vaxis, pixel);
}
+/* 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)
{
- return yyy_row_ypixel_to_row (sheet, sheet->vadjustment->value);
+ return row_from_ypixel (sheet, sheet->vadjustment->value);
}
+static inline glong
+min_fully_visible_row (const GtkSheet *sheet)
+{
+ glong row = min_visible_row (sheet);
+
+ if ( psppire_axis_pixel_start (sheet->vaxis, row) < sheet->vadjustment->value)
+ row++;
+
+ return row;
+}
static inline glong
max_visible_row (const GtkSheet *sheet)
{
- return yyy_row_ypixel_to_row (sheet,
- sheet->vadjustment->value +
- sheet->vadjustment->page_size);
+ return row_from_ypixel (sheet,
+ sheet->vadjustment->value +
+ sheet->vadjustment->page_size);
}
-/* returns the column index from a x pixel location */
-static inline gint
-column_from_xpixel (const GtkSheet *sheet, gint x)
+static inline glong
+max_fully_visible_row (const GtkSheet *sheet)
{
- 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)))
- return i;
+ glong row = max_visible_row (sheet);
- cx += g_sheet_column_get_width (sheet->column_geometry, i);
- }
+ if ( psppire_axis_pixel_start (sheet->vaxis, row)
+ +
+ psppire_axis_unit_size (sheet->vaxis, row)
+ > sheet->vadjustment->value)
+ row--;
- /* no match */
- return g_sheet_column_get_column_count (sheet->column_geometry) - 1;
+ return row;
}
+/* 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)
{
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 */
return FALSE;
}
-static inline gboolean
-POSSIBLE_YDRAG (const GtkSheet *sheet, gint y, gint *drag_row)
-{
- gint row, ydrag;
-
- y += sheet->vadjustment->value;
- row = yyy_row_ypixel_to_row (sheet, y);
- *drag_row = row;
-
- ydrag = g_sheet_row_start_pixel (sheet->row_geometry, row) + CELL_SPACING;
- if (y <= ydrag + DRAG_WIDTH / 2 && row != 0)
- {
- *drag_row = row - 1;
- return g_sheet_row_get_sensitivity (sheet->row_geometry, row - 1);
- }
-
- ydrag += g_sheet_row_get_height (sheet->row_geometry, row);
-
- if (y >= ydrag - DRAG_WIDTH / 2 && y <= ydrag + DRAG_WIDTH / 2)
- return g_sheet_row_get_sensitivity (sheet->row_geometry, row);
-
- return FALSE;
-}
-
static inline gboolean
POSSIBLE_DRAG (const GtkSheet *sheet, gint x, gint y,
gint *drag_row, gint *drag_column)
return FALSE;
*drag_column = column_from_xpixel (sheet, x);
- *drag_row = yyy_row_ypixel_to_row (sheet, y);
+ *drag_row = row_from_ypixel (sheet, y);
- if (x >= g_sheet_column_start_pixel (sheet->column_geometry, sheet->range.col0) - DRAG_WIDTH / 2 &&
- x <= g_sheet_column_start_pixel (sheet->column_geometry, 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);
+ ydrag = psppire_axis_pixel_start (sheet->vaxis, sheet->range.row0);
if (y >= ydrag - DRAG_WIDTH / 2 && y <= ydrag + DRAG_WIDTH / 2)
{
*drag_row = sheet->range.row0;
return TRUE;
}
- ydrag = g_sheet_row_start_pixel (sheet->row_geometry, sheet->range.rowi) +
- g_sheet_row_get_height (sheet->row_geometry, sheet->range.rowi);
+ ydrag = psppire_axis_pixel_start (sheet->vaxis, sheet->range.rowi) +
+ psppire_axis_unit_size (sheet->vaxis, sheet->range.rowi);
if (y >= ydrag - DRAG_WIDTH / 2 && y <= ydrag + DRAG_WIDTH / 2)
{
*drag_row = sheet->range.rowi;
}
}
- if (y >= g_sheet_row_start_pixel (sheet->row_geometry, sheet->range.row0) - DRAG_WIDTH / 2 &&
- 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)
+ if (y >= psppire_axis_pixel_start (sheet->vaxis, sheet->range.row0) - DRAG_WIDTH / 2 &&
+ y <= psppire_axis_pixel_start (sheet->vaxis, sheet->range.rowi) +
+ psppire_axis_unit_size (sheet->vaxis, sheet->range.rowi) + DRAG_WIDTH / 2)
{
- xdrag = g_sheet_column_start_pixel (sheet->column_geometry, 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 = g_sheet_column_start_pixel (sheet->column_geometry, 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;
sheet->range.col0 < 0 || sheet->range.coli < 0 )
return FALSE;
- xdrag = g_sheet_column_start_pixel (sheet->column_geometry, 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);
+ ydrag = psppire_axis_pixel_start (sheet->vaxis, sheet->range.rowi) +
+ psppire_axis_unit_size (sheet->vaxis, sheet->range.rowi);
if (sheet->state == GTK_SHEET_COLUMN_SELECTED)
- ydrag = g_sheet_row_start_pixel (sheet->row_geometry, min_visible_row (sheet));
+ ydrag = psppire_axis_pixel_start (sheet->vaxis, min_visible_row (sheet));
if (sheet->state == GTK_SHEET_ROW_SELECTED)
- xdrag = g_sheet_column_start_pixel (sheet->column_geometry, 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);
+ *drag_row = row_from_ypixel (sheet, y);
if (x >= xdrag - DRAG_WIDTH / 2 && x <= xdrag + DRAG_WIDTH / 2 &&
y >= ydrag - DRAG_WIDTH / 2 && y <= ydrag + DRAG_WIDTH / 2) return TRUE;
{
g_return_val_if_fail (range, FALSE);
- r->x = g_sheet_column_start_pixel (sheet->column_geometry, range->col0);
- r->x -= sheet->hadjustment->value;
+ 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 -= sheet->vadjustment->value;
+ r->y = psppire_axis_pixel_start (sheet->vaxis, range->row0);
+ r->y -= round (sheet->vadjustment->value);
if ( sheet->column_titles_visible)
r->y += sheet->column_title_area.height;
- r->width = g_sheet_column_start_pixel (sheet->column_geometry, range->coli) -
- g_sheet_column_start_pixel (sheet->column_geometry, range->col0) +
- g_sheet_column_get_width (sheet->column_geometry, range->coli);
+ 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);
+ r->height = psppire_axis_pixel_start (sheet->vaxis, range->rowi) -
+ psppire_axis_pixel_start (sheet->vaxis, range->row0) +
+ psppire_axis_unit_size (sheet->vaxis, range->rowi);
return TRUE;
}
/* Sheet queries */
static gboolean gtk_sheet_range_isvisible (const GtkSheet *sheet,
- GtkSheetRange range);
+ const GtkSheetRange *range);
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_bg (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,
/* 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,
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 gtk_sheet_hide_entry_widget (GtkSheet *sheet);
+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 void gtk_sheet_show_entry_widget (GtkSheet *sheet);
static gboolean gtk_sheet_click_cell (GtkSheet *sheet,
gint row,
gint column);
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);
RESIZE_RANGE,
MOVE_RANGE,
TRAVERSE,
- DEACTIVATE,
ACTIVATE,
- CHANGED,
LAST_SIGNAL
};
return sheet_type;
}
+\f
+
static GtkSheetRange*
gtk_sheet_range_copy (const GtkSheetRange *range)
{
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);
+ }
-static void column_titles_changed (GtkWidget *w, gint first, gint n_columns,
- gpointer data);
+ return sheet_cell_type;
+}
+\f
/* Properties */
enum
{
PROP_0,
- PROP_ROW_GEO,
- PROP_COL_GEO,
+ PROP_VAXIS,
+ PROP_HAXIS,
PROP_MODEL
};
static void
-gtk_sheet_set_row_geometry (GtkSheet *sheet, GSheetRow *geo)
+gtk_sheet_set_horizontal_axis (GtkSheet *sheet, PsppireAxis *a)
{
- if ( sheet->row_geometry ) g_object_unref (sheet->row_geometry);
+ if ( sheet->haxis )
+ g_object_unref (sheet->haxis);
- sheet->row_geometry = geo;
+ sheet->haxis = a;
- if ( sheet->row_geometry ) g_object_ref (sheet->row_geometry);
+ if ( sheet->haxis )
+ g_object_ref (sheet->haxis);
}
static void
-gtk_sheet_set_column_geometry (GtkSheet *sheet, GSheetColumn *geo)
+gtk_sheet_set_vertical_axis (GtkSheet *sheet, PsppireAxis *a)
{
- if ( sheet->column_geometry ) g_object_unref (sheet->column_geometry);
+ if ( sheet->vaxis )
+ g_object_unref (sheet->vaxis);
- sheet->column_geometry = geo;
+ sheet->vaxis = a;
- if ( sheet->column_geometry ) g_object_ref (sheet->column_geometry);
+ if ( sheet->vaxis )
+ g_object_ref (sheet->vaxis);
}
switch (prop_id)
{
- case PROP_ROW_GEO:
- gtk_sheet_set_row_geometry (sheet, g_value_get_pointer (value));
+ case PROP_VAXIS:
+ gtk_sheet_set_vertical_axis (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));
switch (prop_id)
{
- case PROP_ROW_GEO:
- g_value_set_pointer (value, sheet->row_geometry);
+ case PROP_VAXIS:
+ g_value_set_pointer (value, sheet->vaxis);
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);
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
- GParamSpec *row_geo_spec ;
- GParamSpec *col_geo_spec ;
+ GParamSpec *haxis_spec ;
+ GParamSpec *vaxis_spec ;
GParamSpec *model_spec ;
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
G_SIGNAL_RUN_LAST,
0,
NULL, NULL,
- gtkextra_VOID__INT_POINTER,
+ psppire_marshal_VOID__INT_POINTER,
G_TYPE_NONE,
2,
G_TYPE_INT,
G_SIGNAL_RUN_LAST,
0,
NULL, NULL,
- gtkextra_VOID__INT_POINTER,
+ psppire_marshal_VOID__INT_POINTER,
G_TYPE_NONE,
2,
G_TYPE_INT,
G_SIGNAL_RUN_LAST,
offsetof (GtkSheetClass, resize_range),
NULL, NULL,
- gtkextra_VOID__BOXED_BOXED,
+ psppire_marshal_VOID__BOXED_BOXED,
G_TYPE_NONE,
2,
GTK_TYPE_SHEET_RANGE, GTK_TYPE_SHEET_RANGE
G_SIGNAL_RUN_LAST,
offsetof (GtkSheetClass, move_range),
NULL, NULL,
- gtkextra_VOID__BOXED_BOXED,
+ psppire_marshal_VOID__BOXED_BOXED,
G_TYPE_NONE,
2,
GTK_TYPE_SHEET_RANGE, GTK_TYPE_SHEET_RANGE
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);
+ psppire_marshal_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);
+ psppire_marshal_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",
G_SIGNAL_RUN_LAST,
offsetof (GtkSheetClass, set_scroll_adjustments),
NULL, NULL,
- gtkextra_VOID__OBJECT_OBJECT,
+ psppire_marshal_VOID__OBJECT_OBJECT,
G_TYPE_NONE, 2, GTK_TYPE_ADJUSTMENT, GTK_TYPE_ADJUSTMENT);
object_class->finalize = gtk_sheet_finalize;
- row_geo_spec =
- g_param_spec_pointer ("row-geometry",
- "Row Geometry",
- "A pointer to the model of the row geometry",
+ vaxis_spec =
+ g_param_spec_pointer ("vertical-axis",
+ "Vertical Axis",
+ "A pointer to the PsppireAxis object for the rows",
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 =
object_class->get_property = gtk_sheet_get_property;
g_object_class_install_property (object_class,
- PROP_ROW_GEO,
- row_geo_spec);
+ PROP_VAXIS,
+ vaxis_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,
klass->resize_range = NULL;
klass->move_range = NULL;
klass->traverse = NULL;
- klass->deactivate = NULL;
klass->activate = NULL;
klass->changed = NULL;
}
gtk_sheet_init (GtkSheet *sheet)
{
sheet->model = NULL;
- sheet->column_geometry = NULL;
- sheet->row_geometry = NULL;
+ sheet->haxis = NULL;
+ sheet->vaxis = NULL;
sheet->flags = 0;
sheet->selection_mode = GTK_SELECTION_NONE;
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;
sheet->sheet_window = NULL;
sheet->entry_widget = NULL;
- sheet->entry_container = NULL;
+ sheet->entry_handler_id = 0;
sheet->button = NULL;
sheet->hadjustment = NULL;
/* create sheet entry */
- sheet->entry_type = 0;
+ sheet->entry_type = GTK_TYPE_ENTRY;
create_sheet_entry (sheet);
/* create global selection button */
gint n_columns,
gpointer data)
{
- gint i;
GtkSheet *sheet = GTK_SHEET (data);
GtkSheetRange range;
*/
range.col0 = first_column;
range.row0 = 0;
- range.coli = g_sheet_column_get_column_count (sheet->column_geometry) - 1;
- range.rowi = g_sheet_row_get_row_count (sheet->row_geometry) - 1;
+ range.coli = psppire_axis_unit_count (sheet->haxis) - 1;
+ range.rowi = psppire_axis_unit_count (sheet->vaxis) - 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);
+ draw_column_title_buttons_range (sheet,
+ first_column, max_visible_column (sheet));
gtk_sheet_range_draw (sheet, &range);
}
rows_inserted_deleted_callback (GSheetModel *model, gint first_row,
gint n_rows, gpointer data)
{
- gint i;
GtkSheet *sheet = GTK_SHEET (data);
GtkSheetRange range;
*/
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.rowi = psppire_axis_unit_count (sheet->vaxis) - 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);
+ draw_row_title_buttons_range (sheet, first_row, max_visible_row (sheet));
gtk_sheet_range_draw (sheet, &range);
}
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 ) )
{
- gint i;
gtk_sheet_range_draw (sheet, NULL);
adjust_scrollbars (sheet);
- for (i = min_visible_row (sheet); i <= max_visible_row (sheet); i++)
- gtk_sheet_row_title_button_draw (sheet, i);
+ draw_row_title_buttons_range (sheet, min_visible_row (sheet),
+ max_visible_row (sheet));
- for (i = min_visible_column (sheet);
- i <= max_visible_column (sheet); i++)
- gtk_sheet_column_title_button_draw (sheet, i);
+ draw_column_title_buttons_range (sheet, min_visible_column (sheet),
+ max_visible_column (sheet));
return;
}
* Returns: the new sheet widget
*/
GtkWidget *
-gtk_sheet_new (GSheetRow *vgeo, GSheetColumn *hgeo, GSheetModel *model)
+gtk_sheet_new (GSheetModel *model)
{
GtkWidget *widget = g_object_new (GTK_TYPE_SHEET,
- "row-geometry", vgeo,
- "column-geometry", hgeo,
"model", model,
NULL);
return widget;
}
-/* 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
-*/
-static void
-column_titles_changed (GtkWidget *w, gint first, gint n_columns, gpointer data)
-{
- GtkSheet *sheet = GTK_SHEET (data);
- gboolean extremity = FALSE;
-
- if ( n_columns == -1 )
- {
- extremity = TRUE;
- n_columns = g_sheet_column_get_column_count (sheet->column_geometry) - 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
gtk_sheet_change_entry (GtkSheet *sheet, GtkType entry_type)
{
state = sheet->state;
if (sheet->state == GTK_SHEET_NORMAL)
- gtk_sheet_hide_active_cell (sheet);
+ gtk_sheet_hide_entry_widget (sheet);
sheet->entry_type = 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);
+ gtk_sheet_show_entry_widget (sheet);
}
+
}
void
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);
+ return psppire_axis_unit_count (sheet->haxis);
}
static void
guint width);
-static void
-gtk_sheet_autoresize_column (GtkSheet *sheet, gint column)
-{
- gint text_width = 0;
- gint row;
-
- 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;
-
- for (row = 0; row < g_sheet_row_get_row_count (sheet->row_geometry); row++)
- {
- gchar *text = gtk_sheet_cell_get_text (sheet, row, column);
- if (text && strlen (text) > 0)
- {
- GtkSheetCellAttr attributes;
-
- gtk_sheet_get_attributes (sheet, row, column, &attributes);
- if (attributes.is_visible)
- {
- gint width = STRING_WIDTH (GTK_WIDGET (sheet),
- attributes.font_desc,
- text)
- + 2 * COLUMN_TITLES_HEIGHT + attributes.border.width;
- text_width = MAX (text_width, width);
- }
- }
- dispose_string (sheet, text);
- }
-
- if (text_width > g_sheet_column_get_width (sheet->column_geometry, column) )
- {
- gtk_sheet_set_column_width (sheet, column, text_width);
- GTK_SHEET_SET_FLAGS (sheet, GTK_SHEET_REDRAW_PENDING);
- }
-}
-
void
gtk_sheet_show_column_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;
gint 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;
-
- gdk_drawable_get_size (sheet->sheet_window, &width, &height);
-
- /* 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))
- {
- adjust += g_sheet_row_get_height (sheet->row_geometry, min_row);
- 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 <
+ psppire_axis_unit_count (sheet->vaxis));
- 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 = psppire_axis_pixel_start (sheet->vaxis, row);
- /* adjust horizontal scrollbar */
- if (column >= 0 && col_align >= 0.0)
- {
- x = g_sheet_column_start_pixel (sheet->column_geometry, 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))
- {
- 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 = g_sheet_column_start_pixel (sheet->column_geometry, 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);
+ }
}
g_return_if_fail (sheet != NULL);
g_return_if_fail (GTK_IS_SHEET (sheet));
- if (row < 0 || row >= g_sheet_row_get_row_count (sheet->row_geometry))
+ if (row < 0 || row >= psppire_axis_unit_count (sheet->vaxis))
return;
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;
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;
sheet->range.col0 = column;
- sheet->range.rowi = g_sheet_row_get_row_count (sheet->row_geometry) - 1;
+ sheet->range.rowi = psppire_axis_unit_count (sheet->vaxis) - 1;
sheet->range.coli = column;
sheet->active_cell.row = 0;
sheet->active_cell.col = column;
static gboolean
gtk_sheet_range_isvisible (const GtkSheet *sheet,
- GtkSheetRange range)
+ const GtkSheetRange *range)
{
g_return_val_if_fail (sheet != NULL, FALSE);
- if (range.row0 < 0 || range.row0 >= g_sheet_row_get_row_count (sheet->row_geometry))
+ if (range->row0 < 0 || range->row0 >= psppire_axis_unit_count (sheet->vaxis))
return FALSE;
- if (range.rowi < 0 || range.rowi >= g_sheet_row_get_row_count (sheet->row_geometry))
+ if (range->rowi < 0 || range->rowi >= psppire_axis_unit_count (sheet->vaxis))
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))
+ if (range->rowi < min_visible_row (sheet))
return FALSE;
- if (range.row0 > max_visible_row (sheet))
+ if (range->row0 > max_visible_row (sheet))
return FALSE;
- if (range.coli < min_visible_column (sheet))
+ if (range->coli < min_visible_column (sheet))
return FALSE;
- if (range.col0 > max_visible_column (sheet))
+ if (range->col0 > max_visible_column (sheet))
return FALSE;
return TRUE;
range.rowi = row;
range.coli = column;
- return gtk_sheet_range_isvisible (sheet, range);
+ return gtk_sheet_range_isvisible (sheet, &range);
}
void
sheet->dispose_has_run = TRUE;
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);
-
- g_object_unref (sheet->entry_container);
- sheet->entry_container = NULL;
+ if (sheet->vaxis) g_object_unref (sheet->vaxis);
+ if (sheet->haxis) g_object_unref (sheet->haxis);
g_object_unref (sheet->button);
sheet->button = NULL;
}
+#define BORDER_WIDTH 4
+
static void
gtk_sheet_realize (GtkWidget *widget)
{
const gint attributes_mask =
GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP | GDK_WA_CURSOR;
- GdkGCValues values, auxvalues;
+ GdkGCValues values;
GdkColormap *colormap;
GdkDisplay *display;
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;
values.function = GDK_INVERT;
values.subwindow_mode = GDK_INCLUDE_INFERIORS;
- values.line_width = 3;
+ values.line_width = BORDER_WIDTH;
sheet->xor_gc = gdk_gc_new_with_values (widget->window,
&values,
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);
}
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);
}
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_cell_draw_bg (GtkSheet *sheet, gint row, gint col)
+gtk_sheet_cell_draw (GtkSheet *sheet, gint row, gint col)
{
+ PangoLayout *layout;
+ PangoRectangle text;
+ gint font_height;
+
+ gchar *label;
+
GtkSheetCellAttr attributes;
GdkRectangle area;
if (!GTK_WIDGET_DRAWABLE (sheet)) return;
if (row < 0 ||
- row >= g_sheet_row_get_row_count (sheet->row_geometry))
+ row >= psppire_axis_unit_count (sheet->vaxis))
return;
if (col < 0 ||
- col >= g_sheet_column_get_column_count (sheet->column_geometry))
+ col >= psppire_axis_unit_count (sheet->haxis))
return;
gtk_sheet_get_attributes (sheet, row, col, &attributes);
area.x, area.y,
area.width, area.height);
}
-}
-
-
-static void
-gtk_sheet_cell_draw_label (GtkSheet *sheet, gint row, gint col)
-{
- GtkWidget *widget;
- GdkRectangle area;
- GtkSheetCellAttr attributes;
- PangoLayout *layout;
- PangoRectangle text;
- gint font_height;
-
- gchar *label;
-
- g_return_if_fail (sheet != NULL);
- 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;
-
- 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);
-
- rectangle_from_cell (sheet, row, col, &area);
layout = gtk_widget_create_pango_layout (GTK_WIDGET (sheet), label);
dispose_string (sheet, label);
g_object_unref (layout);
}
+
+
static void
gtk_sheet_range_draw (GtkSheet *sheet, const GtkSheetRange *range)
{
drawing_range.row0 = min_visible_row (sheet);
drawing_range.col0 = min_visible_column (sheet);
drawing_range.rowi = MIN (max_visible_row (sheet),
- g_sheet_row_get_row_count (sheet->row_geometry) - 1);
+ psppire_axis_unit_count (sheet->vaxis) - 1);
drawing_range.coli = max_visible_column (sheet);
gdk_drawable_get_size (sheet->sheet_window, &area.width, &area.height);
area.x = area.y = 0;
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);
}
+ g_return_if_fail (drawing_range.rowi >= drawing_range.row0);
+ g_return_if_fail (drawing_range.coli >= drawing_range.col0);
+
gdk_draw_rectangle (sheet->sheet_window,
GTK_WIDGET (sheet)->style->white_gc,
TRUE,
for (i = drawing_range.row0; i <= drawing_range.rowi; i++)
for (j = drawing_range.col0; j <= drawing_range.coli; j++)
{
- gtk_sheet_cell_draw_bg (sheet, i, j);
- gtk_sheet_cell_draw_label (sheet, i, j);
+ gtk_sheet_cell_draw (sheet, i, j);
}
if (sheet->state != GTK_SHEET_NORMAL &&
- gtk_sheet_range_isvisible (sheet, sheet->range))
+ gtk_sheet_range_isvisible (sheet, &sheet->range))
gtk_sheet_range_draw_selection (sheet, drawing_range);
if (sheet->state == GTK_STATE_NORMAL &&
sheet->active_cell.row <= drawing_range.rowi &&
sheet->active_cell.col >= drawing_range.col0 &&
sheet->active_cell.col <= drawing_range.coli)
- gtk_sheet_show_active_cell (sheet);
+ gtk_sheet_show_entry_widget (sheet);
}
static void
range.row0 > sheet->range.rowi || range.rowi < sheet->range.row0)
return;
- if (!gtk_sheet_range_isvisible (sheet, range)) return;
+ if (!gtk_sheet_range_isvisible (sheet, &range)) return;
if (!GTK_WIDGET_REALIZED (GTK_WIDGET (sheet))) return;
aux = range;
gtk_sheet_draw_border (sheet, sheet->range);
}
-static void gtk_sheet_set_cell (GtkSheet *sheet, gint row, gint col,
- GtkJustification justification,
- const gchar *text);
-
-
static inline gint
safe_strcmp (const gchar *s1, const gchar *s2)
{
if ( !s1 && !s2) return 0;
- if ( !s1) return - 1;
+ if ( !s1) return -1;
if ( !s2) return +1;
return strcmp (s1, s2);
}
const gchar *text)
{
GSheetModel *model ;
- gboolean changed = FALSE;
gchar *old_text ;
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))
+ if (col >= psppire_axis_unit_count (sheet->haxis)
+ || row >= psppire_axis_unit_count (sheet->vaxis))
return;
if (col < 0 || row < 0) return;
old_text = g_sheet_model_get_string (model, row, col);
if (0 != safe_strcmp (old_text, text))
- changed = g_sheet_model_set_string (model, text, row, col);
+ g_sheet_model_set_string (model, text, row, col);
if ( g_sheet_model_free_strings (model))
g_free (old_text);
-
- if ( changed )
- g_signal_emit (sheet, sheet_signals[CHANGED], 0, row, col);
}
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) ||
- row >= g_sheet_row_get_row_count (sheet->row_geometry)) return;
+ if (column >= psppire_axis_unit_count (sheet->haxis) ||
+ row >= psppire_axis_unit_count (sheet->vaxis)) return;
if (column < 0 || row < 0) return;
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 >= psppire_axis_unit_count (sheet->vaxis))
return NULL;
if (col < 0 || row < 0) return NULL;
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 >= psppire_axis_unit_count (sheet->vaxis)) return 0;
if (col < 0 || row < 0) return 0;
state = sheet->state;
}
else
{
- trow = yyy_row_ypixel_to_row (sheet, y);
- if (trow > g_sheet_row_get_row_count (sheet->row_geometry))
+ trow = row_from_ypixel (sheet, y);
+ if (trow > psppire_axis_unit_count (sheet->vaxis))
return FALSE;
}
else
{
tcol = column_from_xpixel (sheet, x);
- if (tcol > g_sheet_column_get_column_count (sheet->column_geometry))
+ if (tcol > psppire_axis_unit_count (sheet->haxis))
return FALSE;
}
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 >= psppire_axis_unit_count (sheet->vaxis) || column >= psppire_axis_unit_count (sheet->haxis))
return FALSE;
- area->x = (column == -1) ? 0 : g_sheet_column_start_pixel (sheet->column_geometry, column);
- area->y = (row == -1) ? 0 : g_sheet_row_start_pixel (sheet->row_geometry, row);
+ area->x = (column == -1) ? 0 : psppire_axis_pixel_start (sheet->haxis, column);
+ area->y = (row == -1) ? 0 : psppire_axis_pixel_start (sheet->vaxis, 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);
+ : psppire_axis_unit_size (sheet->vaxis, row);
return TRUE;
}
-gboolean
+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 || col < -1)
+ return;
- if (row < -1 || col < -1) return FALSE;
- if (row >= g_sheet_row_get_row_count (sheet->row_geometry)
+ if (row >= psppire_axis_unit_count (sheet->vaxis)
||
- col >= g_sheet_column_get_column_count (sheet->column_geometry))
- return FALSE;
+ col >= psppire_axis_unit_count (sheet->haxis))
+ return;
sheet->active_cell.row = row;
sheet->active_cell.col = col;
if (!GTK_WIDGET_REALIZED (GTK_WIDGET (sheet)))
- return TRUE;
-
- gtk_sheet_deactivate_cell (sheet);
+ return;
if ( row == -1 || col == -1)
{
- gtk_sheet_hide_active_cell (sheet);
- return TRUE;
+ gtk_sheet_hide_entry_widget (sheet);
+ return;
}
- return gtk_sheet_activate_cell (sheet, row, col);
+ change_active_cell (sheet, row, col);
}
void
sheet->active_cell.row = -1;
sheet->active_cell.col = -1;
- text = gtk_entry_get_text (GTK_ENTRY (gtk_sheet_get_entry (sheet)));
+ text = gtk_entry_get_text (gtk_sheet_get_entry (sheet));
if (text && strlen (text) > 0)
{
static void
-gtk_sheet_deactivate_cell (GtkSheet *sheet)
+gtk_sheet_hide_entry_widget (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 (!GTK_WIDGET_REALIZED (GTK_WIDGET (sheet))) return ;
- if (sheet->state != GTK_SHEET_NORMAL) return ;
+ if (sheet->active_cell.row < 0 ||
+ sheet->active_cell.col < 0) return;
+ gtk_widget_hide (sheet->entry_widget);
+ gtk_widget_unmap (sheet->entry_widget);
- if ( sheet->active_cell.row == -1 || sheet->active_cell.col == -1 )
- return ;
+ GTK_WIDGET_UNSET_FLAGS (GTK_WIDGET (sheet->entry_widget), GTK_VISIBLE);
+}
- /*
- g_print ("%s\n", __FUNCTION__);
+static void
+change_active_cell (GtkSheet *sheet, gint row, gint col)
+{
+ gint old_row, old_col;
+ glong old_handler_id = sheet->entry_handler_id;
+ g_return_if_fail (GTK_IS_SHEET (sheet));
- GtkSheetRange r;
- r.col0 = r.coli = sheet->active_cell.col;
- r.row0 = r.rowi = sheet->active_cell.row;
- gtk_sheet_range_draw (sheet, &r);
- */
+ if (row < 0 || col < 0)
+ return;
+ if ( row > psppire_axis_unit_count (sheet->vaxis)
+ || col > psppire_axis_unit_count (sheet->haxis))
+ return;
- g_signal_emit (sheet, sheet_signals[DEACTIVATE], 0,
- sheet->active_cell.row,
- sheet->active_cell.col);
+ if (sheet->state != GTK_SHEET_NORMAL)
+ {
+ sheet->state = GTK_SHEET_NORMAL;
+ gtk_sheet_real_unselect_range (sheet, NULL);
+ }
- g_signal_handlers_disconnect_by_func (gtk_sheet_get_entry (sheet),
- G_CALLBACK (gtk_sheet_entry_changed),
- sheet);
+ g_signal_handler_block (sheet->entry_widget, sheet->entry_handler_id);
- gtk_sheet_hide_active_cell (sheet);
- sheet->active_cell.row = -1;
- sheet->active_cell.col = -1;
+ old_row = sheet->active_cell.row;
+ old_col = sheet->active_cell.col;
-#if 0
- if (GTK_SHEET_REDRAW_PENDING (sheet))
- {
- GTK_SHEET_UNSET_FLAGS (sheet, GTK_SHEET_REDRAW_PENDING);
- gtk_sheet_range_draw (sheet, NULL);
- }
-#endif
-}
+ {
+ /* Redraw the neighbourhood of the old active cell */
+ GtkSheetRange r;
+ r.col0 = old_col - 1;
+ r.coli = old_col + 1;
+ r.row0 = old_row - 1;
+ r.rowi = old_row + 1;
+ maximize_int (&r.row0, 0);
+ maximize_int (&r.col0, 0);
+ minimize_int (&r.rowi, psppire_axis_unit_count (sheet->vaxis) - 1);
+ minimize_int (&r.coli, psppire_axis_unit_count (sheet->haxis) - 1);
-static void
-gtk_sheet_hide_active_cell (GtkSheet *sheet)
-{
- GdkRectangle area;
-
- if (!GTK_WIDGET_REALIZED (GTK_WIDGET (sheet)))
- return;
-
- if (sheet->active_cell.row < 0 ||
- sheet->active_cell.col < 0) return;
-
- gtk_widget_hide (sheet->entry_widget);
- gtk_widget_unmap (sheet->entry_widget);
-
- 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_bg (sheet, sheet->active_cell.row,
- sheet->active_cell.col);
-
- gtk_sheet_cell_draw_label (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)
-{
- gboolean veto = TRUE;
-
- 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;
+ if ( gtk_sheet_range_isvisible (sheet, &r))
+ gtk_sheet_range_draw (sheet, &r);
+ }
- if ( row > g_sheet_row_get_row_count (sheet->row_geometry)
- || col > g_sheet_column_get_column_count (sheet->column_geometry))
- return FALSE;
- if (!veto) return FALSE;
- if (sheet->state != GTK_SHEET_NORMAL)
- {
- sheet->state = GTK_SHEET_NORMAL;
- gtk_sheet_real_unselect_range (sheet, NULL);
- }
sheet->range.row0 = row;
sheet->range.col0 = col;
GTK_SHEET_UNSET_FLAGS (sheet, GTK_SHEET_IN_SELECTION);
- gtk_sheet_show_active_cell (sheet);
+ gtk_sheet_draw_active_cell (sheet);
+ gtk_sheet_show_entry_widget (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
-gtk_sheet_show_active_cell (GtkSheet *sheet)
+gtk_sheet_show_entry_widget (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);
GTK_WIDGET_SET_FLAGS (GTK_WIDGET (sheet->entry_widget), GTK_VISIBLE);
- sheet_entry = GTK_ENTRY (gtk_sheet_get_entry (sheet));
+ sheet_entry = gtk_sheet_get_entry (sheet);
gtk_sheet_get_attributes (sheet, row, col, &attributes);
- justification = GTK_JUSTIFY_LEFT;
-
text = gtk_sheet_cell_get_text (sheet, row, col);
if ( ! text )
text = g_strdup ("");
- 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))
- gtk_entry_set_text (GTK_ENTRY (sheet_entry), text);
- else
- gtk_item_entry_set_text (GTK_ITEM_ENTRY (sheet_entry), text, justification);
+ const gchar *old_text = gtk_entry_get_text (GTK_ENTRY (sheet_entry));
+ if (strcmp (old_text, text) != 0)
+ gtk_entry_set_text (sheet_entry, text);
+
+ 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_set_sensitive (GTK_WIDGET (sheet_entry),
+ g_sheet_model_is_editable (sheet->model,
+ row, col));
gtk_widget_map (sheet->entry_widget);
gtk_widget_grab_focus (GTK_WIDGET (sheet_entry));
if (mask1 != mask2)
{
- x = g_sheet_column_start_pixel (sheet->column_geometry, j);
- y = g_sheet_row_start_pixel (sheet->row_geometry, i);
- width = g_sheet_column_start_pixel (sheet->column_geometry, j)- x+
- g_sheet_column_get_width (sheet->column_geometry, j);
- height = g_sheet_row_start_pixel (sheet->row_geometry, i) - y + g_sheet_row_get_height (sheet->row_geometry, i);
+ x = psppire_axis_pixel_start (sheet->haxis, j);
+ y = psppire_axis_pixel_start (sheet->vaxis, i);
+ width = psppire_axis_pixel_start (sheet->haxis, j)- x+
+ psppire_axis_unit_size (sheet->haxis, j);
+ height = psppire_axis_pixel_start (sheet->vaxis, i) - y + psppire_axis_unit_size (sheet->vaxis, i);
if (i == sheet->range.row0)
{
if (i != sheet->active_cell.row || j != sheet->active_cell.col)
{
- x = g_sheet_column_start_pixel (sheet->column_geometry, j);
- y = g_sheet_row_start_pixel (sheet->row_geometry, i);
- width = g_sheet_column_start_pixel (sheet->column_geometry, j)- x+
- g_sheet_column_get_width (sheet->column_geometry, j);
+ x = psppire_axis_pixel_start (sheet->haxis, j);
+ y = psppire_axis_pixel_start (sheet->vaxis, i);
+ 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);
+ height = psppire_axis_pixel_start (sheet->vaxis, i) - y + psppire_axis_unit_size (sheet->vaxis, i);
if (i == new_range.row0)
{
if (state == GTK_STATE_SELECTED && !selected)
{
- x = g_sheet_column_start_pixel (sheet->column_geometry, j);
- y = g_sheet_row_start_pixel (sheet->row_geometry, i);
- width = g_sheet_column_start_pixel (sheet->column_geometry, j) - x + g_sheet_column_get_width (sheet->column_geometry, j);
- height = g_sheet_row_start_pixel (sheet->row_geometry, i) - y + g_sheet_row_get_height (sheet->row_geometry, i);
+ x = psppire_axis_pixel_start (sheet->haxis, j);
+ y = psppire_axis_pixel_start (sheet->vaxis, i);
+ width = psppire_axis_pixel_start (sheet->haxis, j) - x + psppire_axis_unit_size (sheet->haxis, j);
+ height = psppire_axis_pixel_start (sheet->vaxis, i) - y + psppire_axis_unit_size (sheet->vaxis, i);
if (i == sheet->range.row0)
{
(i != sheet->active_cell.row || j != sheet->active_cell.col))
{
- x = g_sheet_column_start_pixel (sheet->column_geometry, j);
- y = g_sheet_row_start_pixel (sheet->row_geometry, i);
- width = g_sheet_column_start_pixel (sheet->column_geometry, j) - x + g_sheet_column_get_width (sheet->column_geometry, j);
- height = g_sheet_row_start_pixel (sheet->row_geometry, i) - y + g_sheet_row_get_height (sheet->row_geometry, i);
+ x = psppire_axis_pixel_start (sheet->haxis, j);
+ y = psppire_axis_pixel_start (sheet->vaxis, i);
+ width = psppire_axis_pixel_start (sheet->haxis, j) - x + psppire_axis_unit_size (sheet->haxis, j);
+ height = psppire_axis_pixel_start (sheet->vaxis, i) - y + psppire_axis_unit_size (sheet->vaxis, i);
if (i == new_range.row0)
{
mask2 = j == new_range.coli ? mask2 + 8 : mask2;
if (mask2 != mask1 || (mask2 == mask1 && state != GTK_STATE_SELECTED))
{
- x = g_sheet_column_start_pixel (sheet->column_geometry, 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);
+ x = psppire_axis_pixel_start (sheet->haxis, j);
+ y = psppire_axis_pixel_start (sheet->vaxis, i);
+ width = psppire_axis_unit_size (sheet->haxis, j);
+ height = psppire_axis_unit_size (sheet->vaxis, i);
if (mask2 & 1)
gdk_draw_rectangle (sheet->sheet_window,
sheet->xor_gc,
*range = new_range;
}
+
+
static void
gtk_sheet_draw_border (GtkSheet *sheet, GtkSheetRange new_range)
{
gdk_draw_rectangle (sheet->sheet_window,
sheet->xor_gc,
FALSE,
- area.x + 1,
- area.y + 1,
- area.width - 2,
- area.height - 2);
+ area.x - BORDER_WIDTH / 2,
+ area.y - BORDER_WIDTH / 2,
+ area.width + BORDER_WIDTH,
+ area.height + BORDER_WIDTH);
}
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;
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);
}
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;
sheet->range.col0 = -1;
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);
+ draw_row_title_buttons_range (sheet,
+ min_visible_row (sheet),
+ max_visible_row (sheet));
}
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);
+ draw_column_title_buttons_range (sheet,
+ min_visible_column (sheet),
+ max_visible_column (sheet));
}
range.row0 =
- yyy_row_ypixel_to_row (sheet,
+ row_from_ypixel (sheet,
event->area.y + sheet->vadjustment->value);
range.row0--;
range.rowi =
- yyy_row_ypixel_to_row (sheet,
+ row_from_ypixel (sheet,
event->area.y +
event->area.height + sheet->vadjustment->value);
range.rowi++;
sheet->hadjustment->value);
range.coli++;
+
if (event->window == sheet->sheet_window)
{
gtk_sheet_range_draw (sheet, &range);
if (sheet->state != GTK_SHEET_NORMAL)
{
- if (gtk_sheet_range_isvisible (sheet, sheet->range))
+ if (gtk_sheet_range_isvisible (sheet, &sheet->range))
gtk_sheet_range_draw (sheet, &sheet->range);
if (GTK_SHEET_IN_RESIZE (sheet) || GTK_SHEET_IN_DRAG (sheet))
gtk_sheet_range_draw (sheet, &sheet->drag_range);
- if (gtk_sheet_range_isvisible (sheet, sheet->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 (sheet->state != GTK_SHEET_NORMAL && GTK_SHEET_IN_SELECTION (sheet))
- gtk_widget_grab_focus (GTK_WIDGET (sheet));
-
(* GTK_WIDGET_CLASS (parent_class)->expose_event) (widget, event);
return FALSE;
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)
{
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_model_get_row_sensitivity (sheet->model, 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);
if (! (mods & GDK_BUTTON1_MASK)) return TRUE;
if (on_column_boundary (sheet, sheet->x_drag, &sheet->drag_cell.col))
{
guint req;
- if (event->type == GDK_2BUTTON_PRESS)
- {
- gtk_sheet_autoresize_column (sheet, sheet->drag_cell.col);
- GTK_SHEET_UNSET_FLAGS (sheet, GTK_SHEET_IN_XDRAG);
- return TRUE;
- }
gtk_sheet_column_size_request (sheet, sheet->drag_cell.col, &req);
GTK_SHEET_SET_FLAGS (sheet, GTK_SHEET_IN_XDRAG);
gdk_pointer_grab (sheet->column_title_window, FALSE,
{
gtk_widget_get_pointer (widget, NULL, &sheet->y_drag);
+#if AXIS_TRANSITION
if (POSSIBLE_YDRAG (sheet, sheet->y_drag, &sheet->drag_cell.row))
{
guint req;
draw_xor_hline (sheet);
return TRUE;
}
+#endif
}
/* the sheet itself does not handle other than single click events */
{
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;
{
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;
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));
y += sheet->vadjustment->value;
- row = yyy_row_ypixel_to_row (sheet, y);
- if (g_sheet_row_get_sensitivity (sheet->row_geometry, row))
+ row = row_from_ypixel (sheet, y);
+ if (g_sheet_model_get_row_sensitivity (sheet->model, row))
{
veto = gtk_sheet_click_cell (sheet, row, -1);
gtk_grab_add (GTK_WIDGET (sheet));
static gboolean
gtk_sheet_click_cell (GtkSheet *sheet, gint row, gint column)
{
+ GtkSheetCell cell;
gboolean forbid_move;
- if (row >= g_sheet_row_get_row_count (sheet->row_geometry)
- || column >= g_sheet_column_get_column_count (sheet->column_geometry))
+ cell.row = row;
+ cell.col = column;
+
+ if (row >= psppire_axis_unit_count (sheet->vaxis)
+ || column >= psppire_axis_unit_count (sheet->haxis))
{
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)
{
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;
}
{
sheet->range.row0 = 0;
sheet->range.col0 = 0;
- sheet->range.rowi = g_sheet_row_get_row_count (sheet->row_geometry) - 1;
+ sheet->range.rowi = psppire_axis_unit_count (sheet->vaxis) - 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);
}
else
{
- gtk_sheet_deactivate_cell (sheet);
- gtk_sheet_activate_cell (sheet, row, column);
+ change_active_cell (sheet, row, column);
}
sheet->active_cell.row = row;
{
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);
}
{
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_model_get_row_subtitle (sheet->model, row);
show_subtitle (sheet, row, -1, text);
g_free (text);
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);
if (event->window == sheet->row_title_window &&
gtk_sheet_rows_resizable (sheet))
{
+#if AXIS_TRANSITION
if (!GTK_SHEET_IN_SELECTION (sheet) && POSSIBLE_YDRAG (sheet, y, &column))
{
new_cursor = GDK_SB_V_DOUBLE_ARROW;
}
}
else
+#endif
{
new_cursor = GDK_TOP_LEFT_ARROW;
if (!GTK_SHEET_IN_YDRAG (sheet) &&
{
GtkSheetRange aux;
column = column_from_xpixel (sheet, x)- sheet->drag_cell.col;
- row = yyy_row_ypixel_to_row (sheet, y) - sheet->drag_cell.row;
+ row = row_from_ypixel (sheet, y) - sheet->drag_cell.row;
if (sheet->state == GTK_SHEET_COLUMN_SELECTED) row = 0;
if (sheet->state == GTK_SHEET_ROW_SELECTED) column = 0;
sheet->x_drag = x;
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))
+ if (aux.row0 + row >= 0 && aux.rowi + row < psppire_axis_unit_count (sheet->vaxis) &&
+ 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;
GtkSheetRange aux;
gint v_h, current_col, current_row, col_threshold, row_threshold;
v_h = 1;
- if (abs (x - g_sheet_column_start_pixel (sheet->column_geometry, sheet->drag_cell.col)) >
- abs (y - g_sheet_row_start_pixel (sheet->row_geometry, sheet->drag_cell.row))) v_h = 2;
+ if (abs (x - psppire_axis_pixel_start (sheet->haxis, sheet->drag_cell.col)) >
+ abs (y - psppire_axis_pixel_start (sheet->vaxis, sheet->drag_cell.row))) v_h = 2;
current_col = column_from_xpixel (sheet, x);
- current_row = yyy_row_ypixel_to_row (sheet, y);
+ current_row = row_from_ypixel (sheet, y);
column = current_col - sheet->drag_cell.col;
row = current_row - sheet->drag_cell.row;
/*use half of column width resp. row height as threshold to
expand selection*/
- col_threshold = g_sheet_column_start_pixel (sheet->column_geometry, 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)
if (x > col_threshold)
column +=1;
}
- row_threshold = g_sheet_row_start_pixel (sheet->row_geometry, current_row) +
- g_sheet_row_get_height (sheet->row_geometry, current_row)/2;
+ row_threshold = psppire_axis_pixel_start (sheet->vaxis, current_row) +
+ psppire_axis_unit_size (sheet->vaxis, current_row)/2;
if (row > 0)
{
if (y < row_threshold)
else
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))
+ if (aux.row0 + row >= 0 && aux.rowi + row < psppire_axis_unit_count (sheet->vaxis) &&
+ aux.col0 + column >= 0 && aux.coli + column < psppire_axis_unit_count (sheet->haxis))
{
aux = sheet->drag_range;
sheet->drag_range = sheet->range;
return TRUE;
}
-
-static gboolean
-gtk_sheet_move_query (GtkSheet *sheet, gint row, gint column)
-{
- gint 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;
-
- if (!GTK_WIDGET_REALIZED (GTK_WIDGET (sheet)))
- return FALSE;
-
- gdk_drawable_get_size (sheet->sheet_window, &width, &height);
-
- 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) &&
- g_sheet_column_start_pixel (sheet->column_geometry, 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)
{
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;
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;
+ row = psppire_axis_unit_count (sheet->vaxis) - 1;
break;
case GTK_SHEET_NORMAL:
sheet->state = GTK_SHEET_RANGE_SELECTED;
page_vertical (GtkSheet *sheet, GtkScrollType dir)
{
gint old_row = sheet->active_cell.row ;
- glong vpixel = g_sheet_row_start_pixel (sheet->row_geometry, old_row);
+ glong vpixel = psppire_axis_pixel_start (sheet->vaxis, old_row);
gint new_row;
- vpixel -= g_sheet_row_start_pixel (sheet->row_geometry,
+ vpixel -= psppire_axis_pixel_start (sheet->vaxis,
min_visible_row (sheet));
switch ( dir)
}
- vpixel += g_sheet_row_start_pixel (sheet->row_geometry,
+ vpixel += psppire_axis_pixel_start (sheet->vaxis,
min_visible_row (sheet));
- new_row = yyy_row_ypixel_to_row (sheet, vpixel);
+ new_row = row_from_ypixel (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,
+ psppire_axis_unit_count (sheet->vaxis) - 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 =
+ psppire_axis_pixel_start (sheet->vaxis,
+ 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 =
+ psppire_axis_pixel_start (sheet->vaxis,
+ new_cell.row);
+
+ gtk_adjustment_set_value (sheet->vadjustment,
+ vpos);
+ }
}
+
static gboolean
gtk_sheet_key_press (GtkWidget *widget,
GdkEventKey *key)
{
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:
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;
sheet->vadjustment->page_increment);
/*
- gtk_sheet_activate_cell (sheet,
- g_sheet_row_get_row_count (sheet->row_geometry) - 1,
+ change_active_cellx (sheet,
+ psppire_axis_unit_count (sheet->vaxis) - 1,
sheet->active_cell.col);
*/
break;
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)
allocation->width - 2 * border_width,
allocation->height - 2 * border_width);
- /* use internal allocation structure for all the math
- * because it's easier than always subtracting the container
- * border width */
- sheet->internal_allocation.x = 0;
- sheet->internal_allocation.y = 0;
- sheet->internal_allocation.width = allocation->width - 2 * border_width;
- sheet->internal_allocation.height = allocation->height - 2 * border_width;
-
sheet_allocation.x = 0;
sheet_allocation.y = 0;
sheet_allocation.width = allocation->width - 2 * border_width;
/* position the window which holds the column title buttons */
sheet->column_title_area.x = 0;
sheet->column_title_area.y = 0;
+ sheet->column_title_area.width = sheet_allocation.width ;
+
+
+ /* position the window which holds the row title buttons */
+ sheet->row_title_area.x = 0;
+ sheet->row_title_area.y = 0;
+ sheet->row_title_area.height = sheet_allocation.height;
if (sheet->row_titles_visible)
- {
- sheet->column_title_area.x = sheet->row_title_area.width;
- }
+ sheet->column_title_area.x += sheet->row_title_area.width;
- sheet->column_title_area.width = sheet_allocation.width ;
+ if (sheet->column_titles_visible)
+ sheet->row_title_area.y += sheet->column_title_area.height;
if (GTK_WIDGET_REALIZED (widget) && sheet->column_titles_visible)
sheet->column_title_area.height);
- /* column button allocation */
- size_allocate_column_title_buttons (sheet);
-
- /* position the window which holds the row title buttons */
- sheet->row_title_area.x = 0;
- sheet->row_title_area.y = 0;
- if (sheet->column_titles_visible)
- {
- sheet->row_title_area.y = sheet->column_title_area.height;
- }
-
- sheet->row_title_area.height = sheet_allocation.height -
- sheet->row_title_area.y;
-
if (GTK_WIDGET_REALIZED (widget) && sheet->row_titles_visible)
gdk_window_move_resize (sheet->row_title_window,
sheet->row_title_area.x,
sheet->row_title_area.width,
sheet->row_title_area.height);
+ if (sheet->haxis)
+ {
+ gint width = sheet->column_title_area.width;
+
+ if ( sheet->row_titles_visible)
+ width -= sheet->row_title_area.width;
+
+ g_object_set (sheet->haxis,
+ "minimum-extent", width,
+ NULL);
+ }
+
+
+ if (sheet->vaxis)
+ {
+ gint height = sheet->row_title_area.height;
+
+ if ( sheet->column_titles_visible)
+ height -= sheet->column_title_area.height;
+
+ g_object_set (sheet->vaxis,
+ "minimum-extent", height,
+ NULL);
+ }
- /* row button allocation */
- size_allocate_row_title_buttons (sheet);
- size_allocate_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;
if (!sheet->column_titles_visible) return;
}
if (max_visible_column (sheet) ==
- g_sheet_column_get_column_count (sheet->column_geometry) - 1)
+ psppire_axis_unit_count (sheet->haxis) - 1)
gdk_window_clear_area (sheet->column_title_window,
0, 0,
sheet->column_title_area.width,
size_allocate_global_button (sheet);
- for (i = min_visible_column (sheet); i <= max_visible_column (sheet); i++)
- gtk_sheet_column_title_button_draw (sheet, i);
+ draw_column_title_buttons_range (sheet, min_visible_column (sheet),
+ max_visible_column (sheet));
}
static void
-size_allocate_row_title_buttons (GtkSheet *sheet)
+draw_row_title_buttons (GtkSheet *sheet)
{
- gint i;
gint y = 0;
gint height;
sheet->row_title_area.height);
}
- if (max_visible_row (sheet) == g_sheet_row_get_row_count (sheet->row_geometry) - 1)
+ if (max_visible_row (sheet) == psppire_axis_unit_count (sheet->vaxis) - 1)
gdk_window_clear_area (sheet->row_title_window,
0, 0,
sheet->row_title_area.width,
size_allocate_global_button (sheet);
- for (i = min_visible_row (sheet); i <= max_visible_row (sheet); i++)
- {
- if ( i >= g_sheet_row_get_row_count (sheet->row_geometry))
- break;
- gtk_sheet_row_title_button_draw (sheet, i);
- }
+
+ draw_row_title_buttons_range (sheet, min_visible_row (sheet),
+ max_visible_row (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;
- const gchar *text;
if (!GTK_WIDGET_REALIZED (GTK_WIDGET (sheet))) return;
if (!GTK_WIDGET_MAPPED (GTK_WIDGET (sheet))) return;
- sheet_entry = GTK_ENTRY (gtk_sheet_get_entry (sheet));
+ sheet_entry = gtk_sheet_get_entry (sheet);
if ( ! gtk_sheet_get_attributes (sheet, sheet->active_cell.row,
sheet->active_cell.col,
if ( GTK_WIDGET_REALIZED (sheet->entry_widget) )
{
- if (!GTK_WIDGET (sheet_entry)->style)
- gtk_widget_ensure_style (GTK_WIDGET (sheet_entry));
-
- previous_style = GTK_WIDGET (sheet_entry)->style;
+ GtkStyle *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;
style->bg[GTK_STATE_ACTIVE] = attributes.background;
style->fg[GTK_STATE_ACTIVE] = attributes.foreground;
style->text[GTK_STATE_ACTIVE] = attributes.foreground;
-
- 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);
-
- row = sheet->active_cell.row;
- col = sheet->active_cell.col;
-
-
- rectangle_from_cell (sheet, row, col, &shentry_allocation);
-
- size = MIN (text_size, max_size);
- size = MAX (size, shentry_allocation.width - 2 * COLUMN_TITLES_HEIGHT);
-
- 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 += shentry_allocation.width / 2 - size / 2;
- break;
- case GTK_JUSTIFY_RIGHT:
- shentry_allocation.x += shentry_allocation.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;
- gint width;
-
- 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;
-
- gdk_drawable_get_size (sheet->sheet_window, &width, NULL);
-
- 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, width -
- g_sheet_column_start_pixel (sheet->column_geometry, 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;
- }
+ rectangle_from_cell (sheet, sheet->active_cell.row,
+ sheet->active_cell.col, &entry_alloc);
- 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);
}
gtk_widget_unparent (sheet->entry_widget);
}
- if (sheet->entry_type)
- {
- sheet->entry_container = g_object_new (sheet->entry_type, NULL);
- g_object_ref_sink (sheet->entry_container);
- sheet->entry_widget = gtk_sheet_get_entry (sheet);
-
- if ( NULL == sheet->entry_widget)
- {
- 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 ();
- }
- else
- {
- sheet->entry_widget = sheet->entry_container ;
- }
- }
- else
- {
- sheet->entry_widget = sheet->entry_container = gtk_item_entry_new ();
- g_object_ref_sink (sheet->entry_container);
- }
+ sheet->entry_widget = g_object_new (sheet->entry_type, NULL);
+ g_object_ref_sink (sheet->entry_widget);
gtk_widget_size_request (sheet->entry_widget, NULL);
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);
}
}
}
-GtkWidget *
+
+GtkEntry *
gtk_sheet_get_entry (GtkSheet *sheet)
{
- GtkWidget *parent;
- GtkWidget *entry = NULL;
+ GtkWidget *w = sheet->entry_widget;
g_return_val_if_fail (sheet != NULL, NULL);
g_return_val_if_fail (GTK_IS_SHEET (sheet), NULL);
g_return_val_if_fail (sheet->entry_widget != NULL, NULL);
- if (GTK_IS_ENTRY (sheet->entry_container))
- return (sheet->entry_container);
-
- parent = sheet->entry_container;
-
- if (GTK_IS_CONTAINER (parent))
+ while (! GTK_IS_ENTRY (w))
{
- gtk_container_forall (GTK_CONTAINER (parent), find_entry, &entry);
+ GtkWidget *entry = NULL;
- if (GTK_IS_ENTRY (entry))
- return entry;
- }
-
- if (!GTK_IS_ENTRY (entry)) return NULL;
-
- return (entry);
+ if (GTK_IS_CONTAINER (w))
+ {
+ gtk_container_forall (GTK_CONTAINER (w), find_entry, &entry);
-}
+ if (NULL == entry)
+ break;
-GtkWidget *
-gtk_sheet_get_entry_widget (GtkSheet *sheet)
-{
- g_return_val_if_fail (sheet != NULL, NULL);
- g_return_val_if_fail (GTK_IS_SHEET (sheet), NULL);
- g_return_val_if_fail (sheet->entry_widget != NULL, NULL);
+ w = entry;
+ }
+ }
- return (sheet->entry_widget);
+ return GTK_ENTRY (w);
}
static void
-gtk_sheet_button_draw (GtkSheet *sheet, GdkWindow *window,
+draw_button (GtkSheet *sheet, GdkWindow *window,
GtkSheetButton *button, gboolean is_sensitive,
GdkRectangle allocation)
{
gboolean rtl ;
gint state = 0;
- gint len = 0;
- gchar *line = 0;
g_return_if_fail (sheet != NULL);
g_return_if_fail (button != NULL);
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],
allocation.y += 2 * sheet->button->style->ythickness;
-
if (button->label && strlen (button->label)>0)
{
- gchar *words = 0;
+ PangoRectangle rect;
+ gchar *line = button->label;
+
PangoLayout *layout = NULL;
- gint real_x = allocation.x, real_y = allocation.y;
+ gint real_x = allocation.x;
+ gint real_y = allocation.y;
- words = button->label;
- line = g_new (gchar, 1);
- line[0]='\0';
+ layout = gtk_widget_create_pango_layout (GTK_WIDGET (sheet), line);
+ pango_layout_get_extents (layout, NULL, &rect);
- while (words && *words != '\0')
+ text_width = PANGO_PIXELS (rect.width);
+ switch (button->justification)
{
- if (*words != '\n')
- {
- len = strlen (line);
- line = g_realloc (line, len + 2);
- line[len]=*words;
- line[len + 1]='\0';
- }
- if (*words == '\n' || * (words + 1) == '\0')
- {
- text_width = STRING_WIDTH (GTK_WIDGET (sheet), GTK_WIDGET (sheet)->style->font_desc, line);
-
- layout = gtk_widget_create_pango_layout (GTK_WIDGET (sheet), line);
- switch (button->justification)
- {
- case GTK_JUSTIFY_LEFT:
- real_x = allocation.x + COLUMN_TITLES_HEIGHT;
- align = rtl ? PANGO_ALIGN_RIGHT : PANGO_ALIGN_LEFT;
- break;
- case GTK_JUSTIFY_RIGHT:
- real_x = allocation.x + allocation.width - text_width - COLUMN_TITLES_HEIGHT;
- align = rtl ? PANGO_ALIGN_LEFT : PANGO_ALIGN_RIGHT;
- break;
- case GTK_JUSTIFY_CENTER:
- default:
- real_x = allocation.x + (allocation.width - text_width)/2;
- align = rtl ? PANGO_ALIGN_RIGHT : PANGO_ALIGN_LEFT;
- pango_layout_set_justify (layout, TRUE);
- }
- pango_layout_set_alignment (layout, align);
- gtk_paint_layout (GTK_WIDGET (sheet)->style,
- window,
- state,
- FALSE,
- &allocation,
- GTK_WIDGET (sheet),
- "label",
- real_x, real_y,
- layout);
- g_object_unref (layout);
-
- real_y += text_height + 2;
-
- g_free (line);
- line = g_new (gchar, 1);
- line[0]='\0';
- }
- words++;
+ case GTK_JUSTIFY_LEFT:
+ real_x = allocation.x + COLUMN_TITLES_HEIGHT;
+ align = rtl ? PANGO_ALIGN_RIGHT : PANGO_ALIGN_LEFT;
+ break;
+ case GTK_JUSTIFY_RIGHT:
+ real_x = allocation.x + allocation.width - text_width - COLUMN_TITLES_HEIGHT;
+ align = rtl ? PANGO_ALIGN_LEFT : PANGO_ALIGN_RIGHT;
+ break;
+ case GTK_JUSTIFY_CENTER:
+ default:
+ real_x = allocation.x + (allocation.width - text_width)/2;
+ align = rtl ? PANGO_ALIGN_RIGHT : PANGO_ALIGN_LEFT;
+ pango_layout_set_justify (layout, TRUE);
}
- g_free (line);
+ pango_layout_set_alignment (layout, align);
+ gtk_paint_layout (GTK_WIDGET (sheet)->style,
+ window,
+ state,
+ FALSE,
+ &allocation,
+ GTK_WIDGET (sheet),
+ "label",
+ real_x, real_y,
+ layout);
+ g_object_unref (layout);
}
gdk_gc_set_clip_rectangle (GTK_WIDGET (sheet)->style->fg_gc[button->state],
gtk_sheet_button_free (button);
}
+
+/* Draw the column title buttons FIRST through to LAST */
static void
-gtk_sheet_column_title_button_draw (GtkSheet *sheet, gint column)
+draw_column_title_buttons_range (GtkSheet *sheet, gint first, gint last)
{
- GdkRectangle allocation;
- GtkSheetButton *button = NULL;
- gboolean is_sensitive = FALSE;
-
+ GdkRectangle rect;
+ gint col;
if (!GTK_WIDGET_REALIZED (GTK_WIDGET (sheet))) return;
if (!sheet->column_titles_visible) return;
- if (column < min_visible_column (sheet)) return;
- if (column > max_visible_column (sheet)) return;
+ g_return_if_fail (first >= min_visible_column (sheet));
+ g_return_if_fail (last <= max_visible_column (sheet));
- button = g_sheet_column_get_button (sheet->column_geometry, column);
- allocation.y = 0;
- allocation.x = g_sheet_column_start_pixel (sheet->column_geometry, column) + CELL_SPACING;
- allocation.x -= sheet->hadjustment->value;
+ rect.y = 0;
+ rect.height = sheet->column_title_area.height;
+ rect.x = psppire_axis_pixel_start (sheet->haxis, first) + CELL_SPACING;
+ rect.width = psppire_axis_pixel_start (sheet->haxis, last) + CELL_SPACING
+ + psppire_axis_unit_size (sheet->haxis, last);
- 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);
+ rect.x -= sheet->hadjustment->value;
+
+ minimize_int (&rect.width, sheet->column_title_area.width);
+ maximize_int (&rect.x, 0);
+
+ gdk_window_begin_paint_rect (sheet->column_title_window, &rect);
+
+ for (col = first ; col <= last ; ++col)
+ {
+ GdkRectangle allocation;
+ gboolean is_sensitive = FALSE;
- gtk_sheet_button_draw (sheet, sheet->column_title_window,
- button, is_sensitive, allocation);
+ GtkSheetButton *
+ button = g_sheet_model_get_column_button (sheet->model, col);
+ allocation.y = 0;
+ allocation.x = psppire_axis_pixel_start (sheet->haxis, col)
+ + CELL_SPACING;
+ allocation.x -= sheet->hadjustment->value;
+
+ allocation.height = sheet->column_title_area.height;
+ allocation.width = psppire_axis_unit_size (sheet->haxis, col);
+ is_sensitive = g_sheet_model_get_column_sensitivity (sheet->model, col);
+
+ draw_button (sheet, sheet->column_title_window,
+ button, is_sensitive, allocation);
+ }
+
+ gdk_window_end_paint (sheet->column_title_window);
}
static void
-gtk_sheet_row_title_button_draw (GtkSheet *sheet, gint row)
+draw_row_title_buttons_range (GtkSheet *sheet, gint first, gint last)
{
- GdkRectangle allocation;
- GtkSheetButton *button = NULL;
- gboolean is_sensitive = FALSE;
-
-
+ GdkRectangle rect;
+ gint row;
if (!GTK_WIDGET_REALIZED (GTK_WIDGET (sheet))) return;
if (!sheet->row_titles_visible) return;
- if (row < min_visible_row (sheet)) return;
- if (row > max_visible_row (sheet)) return;
+ g_return_if_fail (first >= min_visible_row (sheet));
+ g_return_if_fail (last <= max_visible_row (sheet));
- button = g_sheet_row_get_button (sheet->row_geometry, row);
- allocation.x = 0;
- allocation.y = g_sheet_row_start_pixel (sheet->row_geometry, row) + CELL_SPACING;
- allocation.y -= sheet->vadjustment->value;
+ rect.x = 0;
+ rect.width = sheet->row_title_area.width;
+ rect.y = psppire_axis_pixel_start (sheet->vaxis, first) + CELL_SPACING;
+ rect.height = psppire_axis_pixel_start (sheet->vaxis, last) + CELL_SPACING
+ + psppire_axis_unit_size (sheet->vaxis, last);
- allocation.width = sheet->row_title_area.width;
- allocation.height = g_sheet_row_get_height (sheet->row_geometry, row);
- is_sensitive = g_sheet_row_get_sensitivity (sheet->row_geometry, row);
+ rect.y -= sheet->vadjustment->value;
+
+ minimize_int (&rect.height, sheet->row_title_area.height);
+ maximize_int (&rect.y, 0);
+
+ gdk_window_begin_paint_rect (sheet->row_title_window, &rect);
+ for (row = first; row <= last; ++row)
+ {
+ GdkRectangle allocation;
+
+ gboolean is_sensitive = FALSE;
+
+ GtkSheetButton *button =
+ g_sheet_model_get_row_button (sheet->model, row);
+ allocation.x = 0;
+ allocation.y = psppire_axis_pixel_start (sheet->vaxis, row)
+ + CELL_SPACING;
+ allocation.y -= sheet->vadjustment->value;
+
+ allocation.width = sheet->row_title_area.width;
+ allocation.height = psppire_axis_unit_size (sheet->vaxis, row);
+ is_sensitive = g_sheet_model_get_row_sensitivity (sheet->model, row);
+
+ draw_button (sheet, sheet->row_title_window,
+ button, is_sensitive, allocation);
+ }
- gtk_sheet_button_draw (sheet, sheet->row_title_window,
- button, is_sensitive, allocation);
+ gdk_window_end_paint (sheet->row_title_window);
}
/* SCROLLBARS
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;
+ glong last_row = psppire_axis_unit_count (sheet->vaxis) - 1;
sheet->vadjustment->step_increment =
ROWS_PER_STEP *
- g_sheet_row_get_height (sheet->row_geometry, last_row);
+ psppire_axis_unit_size (sheet->vaxis, last_row);
sheet->vadjustment->page_increment =
height -
sheet->column_title_area.height -
- g_sheet_row_get_height (sheet->row_geometry, last_row);
+ psppire_axis_unit_size (sheet->vaxis, last_row);
sheet->vadjustment->upper =
- g_sheet_row_start_pixel (sheet->row_geometry, last_row)
+ psppire_axis_pixel_start (sheet->vaxis, last_row)
+
- g_sheet_row_get_height (sheet->row_geometry, last_row)
+ psppire_axis_unit_size (sheet->vaxis, last_row)
;
- if (sheet->column_titles_visible)
- sheet->vadjustment->upper += sheet->column_title_area.height;
-
sheet->vadjustment->lower = 0;
sheet->vadjustment->page_size = height;
if (sheet->hadjustment)
{
gint last_col;
- sheet->hadjustment->step_increment = 1 ; //DEFAULT_COLUMN_WIDTH;
+ sheet->hadjustment->step_increment = 1;
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)
;
- if (sheet->row_titles_visible)
- sheet->hadjustment->upper += sheet->row_title_area.width;
-
sheet->hadjustment->lower = 0;
sheet->hadjustment->page_size = width;
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);
+ gtk_sheet_draw_active_cell (sheet);
+
+ gdk_window_end_paint (sheet->sheet_window);
}
hadjustment_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_column_title_buttons (sheet);
+ draw_column_title_buttons (sheet);
// size_allocate_global_button (sheet);
+
+ gtk_sheet_draw_active_cell (sheet);
+
+ gdk_window_end_paint (sheet->sheet_window);
}
GdkRectangle clip_area, area;
GdkGCValues values;
- area.x = g_sheet_column_start_pixel (sheet->column_geometry, range.col0);
- area.y = g_sheet_row_start_pixel (sheet->row_geometry, range.row0);
- area.width = g_sheet_column_start_pixel (sheet->column_geometry, range.coli)- area.x+
- g_sheet_column_get_width (sheet->column_geometry, 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);
+ area.x = psppire_axis_pixel_start (sheet->haxis, range.col0);
+ area.y = psppire_axis_pixel_start (sheet->vaxis, range.row0);
+ area.width = psppire_axis_pixel_start (sheet->haxis, range.coli)- area.x+
+ psppire_axis_unit_size (sheet->haxis, range.coli);
+ area.height = psppire_axis_pixel_start (sheet->vaxis, range.rowi)- area.y +
+ psppire_axis_unit_size (sheet->vaxis, range.rowi);
clip_area.x = sheet->row_title_area.width;
clip_area.y = sheet->column_title_area.height;
static guint
new_column_width (GtkSheet *sheet, gint column, gint *x)
{
- gint left_pos = g_sheet_column_start_pixel (sheet->column_geometry, column)
+ gint left_pos = psppire_axis_pixel_start (sheet->haxis, column)
- sheet->hadjustment->value;
gint width = *x - left_pos;
*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;
}
min_height = sheet->row_requisition;
/* you can't shrink a row to less than its minimum height */
- if (cy < g_sheet_row_start_pixel (sheet->row_geometry, row) + min_height)
+ if (cy < psppire_axis_pixel_start (sheet->vaxis, row) + min_height)
{
- *y = cy = g_sheet_row_start_pixel (sheet->row_geometry, row) + min_height;
+ *y = cy = psppire_axis_pixel_start (sheet->vaxis, row) + min_height;
}
/* calculate new row height making sure it doesn't end up
* less than the minimum height */
- height = (cy - g_sheet_row_start_pixel (sheet->row_geometry, row));
+ height = (cy - psppire_axis_pixel_start (sheet->vaxis, row));
if (height < min_height)
height = min_height;
+#if AXIS_TRANSITION
g_sheet_row_set_height (sheet->row_geometry, row, height);
- size_allocate_row_title_buttons (sheet);
+#endif
+ draw_row_title_buttons (sheet);
return height;
}
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);
}
g_return_if_fail (sheet != NULL);
g_return_if_fail (GTK_IS_SHEET (sheet));
- if (row < 0 || row >= g_sheet_row_get_row_count (sheet->row_geometry))
+ if (row < 0 || row >= psppire_axis_unit_count (sheet->vaxis))
return;
gtk_sheet_row_size_request (sheet, row, &min_height);
if (height < min_height) return;
+#if AXIS_TRANSITION
g_sheet_row_set_height (sheet->row_geometry, row, height);
+#endif
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
if (row < 0 || col < 0) return FALSE;
-
attr->foreground = GTK_WIDGET (sheet)->style->black;
attr->background = sheet->color[BG_COLOR];
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);
}
attr->justification =
- g_sheet_column_get_justification (sheet->column_geometry, col);
+ g_sheet_model_get_column_justification (sheet->model, col);
j = g_sheet_model_get_justification (sheet->model, row, col);
if (j)
GtkRequisition requisition;
GtkRequisition label_requisition;
- label_requisition.height = default_row_height (sheet);
+ 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;
GtkRequisition button_requisition;
gtk_sheet_button_size_request (sheet,
- g_sheet_row_get_button (sheet->row_geometry, row),
+ g_sheet_model_get_row_button (sheet->model, row),
&button_requisition);
*requisition = button_requisition.height;
{
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,
if (sheet->button && sheet->button->parent)
(* callback) (sheet->button, callback_data);
- if (sheet->entry_container && GTK_IS_CONTAINER (sheet->entry_container))
- (* callback) (sheet->entry_container, callback_data);
+ if (sheet->entry_widget && GTK_IS_CONTAINER (sheet->entry_widget))
+ (* callback) (sheet->entry_widget, callback_data);
}
g_free (button);
}
-
static void
append_cell_text (GString *string, const GtkSheet *sheet, gint r, gint c)
{
gint r, c;
GString *string;
- if ( !gtk_sheet_range_isvisible (sheet, sheet->range))
+ if ( !gtk_sheet_range_isvisible (sheet, &sheet->range))
return NULL;
string = g_string_sized_new (80);
gint r, c;
GString *string;
- if ( !gtk_sheet_range_isvisible (sheet, sheet->range))
+ if ( !gtk_sheet_range_isvisible (sheet, &sheet->range))
return NULL;
string = g_string_sized_new (480);
clipboard = gtk_widget_get_clipboard (GTK_WIDGET (sheet),
GDK_SELECTION_PRIMARY);
- if (gtk_sheet_range_isvisible (sheet, sheet->range))
+ if (gtk_sheet_range_isvisible (sheet, &sheet->range))
{
if (!gtk_clipboard_set_with_owner (clipboard, targets,
G_N_ELEMENTS (targets),