lib_gtksheet_libgtksheet_a_SOURCES = \
lib/gtksheet/gsheetmodel.c \
lib/gtksheet/gsheetmodel.h \
- lib/gtksheet/gsheet-row-iface.c \
- lib/gtksheet/gsheet-row-iface.h \
- lib/gtksheet/gsheet-uniform-row.c \
- lib/gtksheet/gsheet-uniform-row.h \
- lib/gtksheet/gtkextrafeatures.h \
lib/gtksheet/gtkextra-marshal.c \
lib/gtksheet/gtkextra-marshal.h \
lib/gtksheet/gtkextra-sheet.h \
lib/gtksheet/gtkxpaned.c \
lib/gtksheet/gtkxpaned.h \
lib/gtksheet/psppire-axis.c \
- lib/gtksheet/psppire-axis.h
+ lib/gtksheet/psppire-axis.h \
+ lib/gtksheet/psppire-axis-hetero.c \
+ lib/gtksheet/psppire-axis-hetero.h \
+ lib/gtksheet/psppire-axis-uniform.c \
+ lib/gtksheet/psppire-axis-uniform.h
+
EXTRA_DIST += lib/gtksheet/OChangeLog \
+++ /dev/null
-/* GSheetRow --- an abstract model of the row geometry of a
- * GSheet widget.
- * Copyright (C) 2006 Free Software Foundation
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-#include <config.h>
-
-#include <stdlib.h>
-#include <string.h>
-#include <glib.h>
-#include <glib/gprintf.h>
-#include <gobject/gvaluecollector.h>
-#include "gsheet-row-iface.h"
-#include "gtkextra-marshal.h"
-
-
-enum {
- ROWS_CHANGED,
- LAST_SIGNAL
-};
-
-static guint sheet_row_signals[LAST_SIGNAL];
-
-
-
-static void g_sheet_row_base_init (gpointer g_class);
-
-
-GType
-g_sheet_row_get_type (void)
-{
- static GType sheet_row_type = 0;
-
- if (! sheet_row_type)
- {
- static const GTypeInfo sheet_row_info =
-
- {
- sizeof (GSheetRowIface), /* class_size */
- g_sheet_row_base_init, /* base_init */
- NULL, /* base_finalize */
- NULL,
- NULL, /* class_finalize */
- NULL, /* class_data */
- 0,
- 0, /* n_preallocs */
- NULL
- };
-
- sheet_row_type =
- g_type_register_static (G_TYPE_INTERFACE, "GSheetRow",
- &sheet_row_info, 0);
-
- g_type_interface_add_prerequisite (sheet_row_type, G_TYPE_OBJECT);
- }
-
- return sheet_row_type;
-}
-
-
-static GtkSheetButton default_button;
-
-static void
-g_sheet_row_base_init (gpointer g_class)
-{
- static gboolean initialized = FALSE;
-
- if (! initialized)
- {
-
- sheet_row_signals[ROWS_CHANGED] =
- g_signal_new ("rows_changed",
- G_TYPE_SHEET_ROW,
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (GSheetRowIface, rows_changed),
- NULL, NULL,
- gtkextra_VOID__INT_INT,
- G_TYPE_NONE, 2,
- G_TYPE_INT,
- G_TYPE_INT);
-
-
- default_button.state = GTK_STATE_NORMAL;
- default_button.label = NULL;
- default_button.label_visible = TRUE;
- default_button.justification = GTK_JUSTIFY_FILL;
-
- initialized = TRUE;
- }
-}
-
-void
-g_sheet_row_set_height (GSheetRow *row_geo,
- glong row, gint size)
-{
- g_return_if_fail (G_IS_SHEET_ROW (row_geo));
-
- if ((G_SHEET_ROW_GET_IFACE (row_geo)->set_height) )
- (G_SHEET_ROW_GET_IFACE (row_geo)->set_height) (row_geo, row,
- size);
-}
-
-
-gint
-g_sheet_row_get_height (const GSheetRow *row_geo,
- glong row)
-{
- g_return_val_if_fail (G_IS_SHEET_ROW (row_geo), -1);
-
- g_assert (G_SHEET_ROW_GET_IFACE (row_geo)->get_height);
-
- return (G_SHEET_ROW_GET_IFACE (row_geo)->get_height) (row_geo, row);
-}
-
-
-
-gboolean
-g_sheet_row_get_sensitivity (const GSheetRow *row_geo,
- glong row)
-{
- g_return_val_if_fail (G_IS_SHEET_ROW (row_geo), FALSE);
-
- g_assert (G_SHEET_ROW_GET_IFACE (row_geo)->get_sensitivity);
-
- return (G_SHEET_ROW_GET_IFACE (row_geo)->get_sensitivity) (row_geo,
- row);
-}
-
-
-GtkSheetButton *
-g_sheet_row_get_button (const GSheetRow *row_geo,
- glong row)
-{
- GtkSheetButton *button = gtk_sheet_button_new ();
-
- GSheetRowIface *iface = G_SHEET_ROW_GET_IFACE (row_geo);
-
- g_return_val_if_fail (G_IS_SHEET_ROW (row_geo), FALSE);
-
- if ( iface->get_button_label)
- button->label = iface->get_button_label (row_geo, row);
-
- return button;
-}
-
-gchar *
-g_sheet_row_get_subtitle (const GSheetRow *row_geo, glong row)
-{
- g_return_val_if_fail (G_IS_SHEET_ROW (row_geo), NULL);
-
- if ( ! G_SHEET_ROW_GET_IFACE (row_geo)->get_subtitle )
- return NULL;
-
- return (G_SHEET_ROW_GET_IFACE (row_geo)->get_subtitle) (row_geo, row);
-}
-
-
-
-
-glong
-g_sheet_row_get_row_count (const GSheetRow *geo)
-{
- g_return_val_if_fail (G_IS_SHEET_ROW (geo), -1);
-
- g_assert ( G_SHEET_ROW_GET_IFACE (geo)->get_row_count);
-
- return (G_SHEET_ROW_GET_IFACE (geo)->get_row_count) (geo);
-}
-
-/**
- * g_sheet_row_start_pixel:
- * @geo: the row model
- * @row: the row number
- * @sheet: pointer to the sheet
- *
- * Returns the top y pixel for ROW.
- * ROW may point to the row BELOW the last row, in which case it should
- * return the position where it would start if it existed.
- * Instances may override this method in order to achieve time and/or memory
- * optmisation.
- *
- * Returns: the y coordinate of the top of the row.
- */
-
-gint
-g_sheet_row_start_pixel (const GSheetRow *geo, glong row)
-{
- gint i;
- gint start_pixel = 0;
-
- g_return_val_if_fail (G_IS_SHEET_ROW (geo), -1);
- g_return_val_if_fail (row >= 0, -1);
- g_return_val_if_fail (row <= g_sheet_row_get_row_count (geo), -1);
-
- if ( G_SHEET_ROW_GET_IFACE (geo)->top_ypixel)
- return (G_SHEET_ROW_GET_IFACE (geo)->top_ypixel)(geo, row);
-
- for (i = 0; i < row; ++i)
- {
- start_pixel += g_sheet_row_get_height (geo, i);
- }
-
- return start_pixel;
-}
-
-
-glong
-g_sheet_row_pixel_to_row (const GSheetRow *geo, gint pixel)
-{
- gint i, cy;
- g_return_val_if_fail (G_IS_SHEET_ROW (geo), -1);
- g_return_val_if_fail (pixel >= 0, -1) ;
-
- if ( G_SHEET_ROW_GET_IFACE (geo)->pixel_to_row)
- return (G_SHEET_ROW_GET_IFACE (geo)->pixel_to_row)(geo, pixel);
-
- cy = 0;
- for (i = 0; i < g_sheet_row_get_row_count (geo); ++i )
- {
- if (pixel >= cy &&
- pixel <= (cy + g_sheet_row_get_height (geo, i)))
- return i;
-
- cy += g_sheet_row_get_height (geo, i);
- }
-
- /* no match */
- return g_sheet_row_get_row_count (geo) - 1;
-}
-
-
-
-void
-g_sheet_row_rows_deleted (GSheetRow *geo,
- glong first, glong n_rows)
-{
- g_return_if_fail (G_IS_SHEET_ROW (geo));
-
- g_signal_emit (geo, sheet_row_signals[ROWS_CHANGED], 0,
- first, n_rows);
-}
+++ /dev/null
-/* GSheetRow --- an abstract model of the row geometry of a
- * GSheet widget.
- * Copyright (C) 2006 Free Software Foundation
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#ifndef __G_SHEET_ROW_IFACE_H__
-#define __G_SHEET_ROW_IFACE_H__
-
-#include <glib-object.h>
-#include <gdk/gdk.h>
-#include <gtk/gtk.h>
-
-#include "gtkextra-sheet.h"
-
-
-G_BEGIN_DECLS
-
-#define G_TYPE_SHEET_ROW (g_sheet_row_get_type ())
-#define G_SHEET_ROW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), G_TYPE_SHEET_ROW, GSheetRow))
-#define G_IS_SHEET_ROW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), G_TYPE_SHEET_ROW))
-#define G_SHEET_ROW_GET_IFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), G_TYPE_SHEET_ROW, GSheetRowIface))
-
-
-
-
-typedef struct _GSheetRow GSheetRow;
-typedef struct _GSheetRowIface GSheetRowIface;
-
-struct _GSheetRowIface
-{
- GTypeInterface g_iface;
-
-
- /* Signals */
- void (* rows_changed) (GSheetRow *geo,
- glong row, glong n_rows);
-
- /* Virtual Table */
- gint (* get_height) (const GSheetRow *grow, glong row);
- void (* set_height) (GSheetRow *grow, glong row, gint height);
-
- gboolean (* get_sensitivity) (const GSheetRow *grow, glong row);
-
- const GtkSheetButton * (* get_button) (const GSheetRow *grow, glong row);
-
- glong (* get_row_count) (const GSheetRow *geo);
-
- GtkStateType (*get_button_state) (const GSheetRow *geo, glong row);
-
- gchar * (*get_button_label) (const GSheetRow *geo, glong row);
-
- gchar * (*get_subtitle) (const GSheetRow *geo, glong row);
-
- gboolean (*get_button_visibility) (const GSheetRow *geo,
- glong row);
-
- guint (*top_ypixel) (const GSheetRow *geo, glong row);
- glong (*pixel_to_row) (const GSheetRow *geo, guint pixel);
-};
-
-
-GType g_sheet_row_get_type (void) G_GNUC_CONST;
-
-
-gint g_sheet_row_get_height (const GSheetRow *grow,
- glong row);
-
-
-void g_sheet_row_set_height (GSheetRow *grow,
- glong row, gint size);
-
-
-gboolean g_sheet_row_get_visibility (const GSheetRow *grow,
- glong row);
-
-gboolean g_sheet_row_get_sensitivity (const GSheetRow *grow,
- glong row);
-
-
-GtkSheetButton *g_sheet_row_get_button (const GSheetRow *grow,
- glong row);
-
-
-glong g_sheet_row_get_row_count (const GSheetRow *geo);
-
-/* Return the top pixel of row ROW */
-gint g_sheet_row_start_pixel (const GSheetRow *geo, glong row);
-
-
-/* Return the row contained by pixel PIXEL */
-glong g_sheet_row_pixel_to_row (const GSheetRow *geo, gint pixel);
-
-
-void g_sheet_row_rows_deleted (GSheetRow *geo,
- glong first, glong n_rows);
-
-
-gchar *g_sheet_row_get_subtitle (const GSheetRow *row_geo, glong row);
-
-
-G_END_DECLS
-
-#endif /* __G_SHEET_ROW_IFACE_H__ */
+++ /dev/null
-/* gsheet-uniform-row.c
- *
- * PSPPIRE --- A Graphical User Interface for PSPP
- * Copyright (C) 2006 Free Software Foundation
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include <config.h>
-
-#include "gsheet-row-iface.h"
-#include "gsheet-uniform-row.h"
-
-
-static void g_sheet_uniform_row_init (GSheetUniformRow *ug);
-static void g_sheet_uniform_row_class_init (GSheetUniformRowClass *class);
-static void g_sheet_uniform_row_finalize (GObject *object);
-
-static void g_sheet_row_init (GSheetRowIface *iface);
-
-
-static GObjectClass *parent_class = NULL;
-
-GType
-g_sheet_uniform_row_get_type (void)
-{
- static GType uniform_row_type = 0;
-
- if (!uniform_row_type)
- {
- static const GTypeInfo uniform_row_info =
- {
- sizeof (GSheetUniformRowClass),
- NULL, /* base_init */
- NULL, /* base_finalize */
- (GClassInitFunc) g_sheet_uniform_row_class_init,
- NULL, /* class_finalize */
- NULL, /* class_data */
- sizeof (GSheetUniformRow),
- 0,
- (GInstanceInitFunc) g_sheet_uniform_row_init,
- };
-
- static const GInterfaceInfo row_info =
- {
- (GInterfaceInitFunc) g_sheet_row_init,
- NULL,
- NULL
- };
-
- uniform_row_type =
- g_type_register_static (G_TYPE_OBJECT, "g_sheet_uniform_row",
- &uniform_row_info, 0);
-
- g_type_add_interface_static (uniform_row_type,
- G_TYPE_SHEET_ROW,
- &row_info);
- }
-
- return uniform_row_type;
-}
-
-
-/**
- * g_sheet_uniform_row_new:
- * @height: The size of rows in this uniform row
- *
- * Return value: a new #g_sheet_uniform_row
- **/
-GObject *
-g_sheet_uniform_row_new (gint height, gint n_rows)
-{
- GSheetUniformRow *ug;
- GObject *retval;
-
- retval = g_object_new (G_TYPE_SHEET_UNIFORM_ROW, NULL);
-
- ug = G_SHEET_UNIFORM_ROW(retval);
- ug->n_rows = n_rows;
- ug->height = height;
-
- return retval;
-}
-
-static gint
-g_sheet_uniform_row_get_height (const GSheetRow *geom, glong u)
-{
- GSheetUniformRow *ug = G_SHEET_UNIFORM_ROW(geom);
-
- return ug->height;
-}
-
-static gboolean
-g_sheet_uniform_row_get_sensitivity (const GSheetRow *geom, glong u)
-{
- GSheetUniformRow *ug = G_SHEET_UNIFORM_ROW(geom);
-
- return (u < ug->n_rows);
-}
-
-
-static gchar *
-g_sheet_uniform_row_get_button_label (const GSheetRow *geom, glong u)
-{
- gchar *label = g_strdup_printf("%ld", u);
-
- return label;
-}
-
-
-
-static glong
-g_sheet_uniform_row_get_row_count (const GSheetRow *geom)
-{
- GSheetUniformRow *ug = G_SHEET_UNIFORM_ROW(geom);
-
- return ug->n_rows;
-}
-
-
-static void
-g_sheet_uniform_row_class_init (GSheetUniformRowClass *class)
-{
- GObjectClass *object_class;
-
- parent_class = g_type_class_peek_parent (class);
- object_class = (GObjectClass*) class;
-
- object_class->finalize = g_sheet_uniform_row_finalize;
-
-}
-
-
-static void
-g_sheet_uniform_row_init (GSheetUniformRow *o)
-{
-}
-
-static void
-g_sheet_uniform_row_finalize (GObject *object)
-{
-}
-
-
-static guint
-g_sheet_uniform_row_top_ypixel (const GSheetRow *geo, glong row)
-{
- GSheetUniformRow *ug = G_SHEET_UNIFORM_ROW(geo);
-
- return row * ug->height;
-}
-
-static glong
-g_sheet_uniform_row_pixel_to_row (const GSheetRow *geo, guint pixel)
-{
- GSheetUniformRow *ug = G_SHEET_UNIFORM_ROW(geo);
-
- gint row = pixel / ug->height;
-
- if (row >= g_sheet_uniform_row_get_row_count(geo))
- row = g_sheet_uniform_row_get_row_count(geo) - 1;
-
- return row;
-}
-
-
-
-static void
-g_sheet_row_init (GSheetRowIface *iface)
-{
- iface->get_height = g_sheet_uniform_row_get_height;
- iface->get_sensitivity = g_sheet_uniform_row_get_sensitivity ;
- iface->get_row_count = g_sheet_uniform_row_get_row_count;
- iface->get_button_label = g_sheet_uniform_row_get_button_label;
- iface->top_ypixel = g_sheet_uniform_row_top_ypixel;
- iface->pixel_to_row = g_sheet_uniform_row_pixel_to_row;
-}
-
+++ /dev/null
-/* GtkSheet widget for Gtk+.
- * Copyright (C) 2006 Free Software Foundation
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#ifndef __G_SHEET_UNIFORM_ROW_H__
-#define __G_SHEET_UNIFORM_ROW_H__
-
-#include <glib-object.h>
-#include <glib.h>
-
-
-#ifdef __cplusplus
-extern "C" {
-#endif /* __cplusplus */
-
-
-#define G_TYPE_SHEET_UNIFORM_ROW (g_sheet_uniform_row_get_type ())
-
-#define G_SHEET_UNIFORM_ROW(obj) G_TYPE_CHECK_INSTANCE_CAST (obj, G_TYPE_SHEET_UNIFORM_ROW, GSheetUniformRow )
-#define G_SHEET_UNIFORM_ROW_CLASS(klass) G_TYPE_CHECK_CLASS_CAST (klass, g_sheet_uniform_row_get_type (), GSheetUniformRowClass)
-#define G_IS_SHEET_UNIFORM_ROW(obj) G_TYPE_CHECK_INSTANCE_TYPE (obj, G_TYPE_SHEET_UNIFORM_ROW)
-
-
- struct _GSheetUniformRow{
- GObject parent;
-
- gint n_rows;
- gint height;
- };
-
- struct _GSheetUniformRowClass
- {
- GObjectClass parent_class;
- };
-
- /* create a new row */
- GObject * g_sheet_uniform_row_new (gint height, gint n_rows);
-
- GType g_sheet_uniform_row_get_type (void);
-
-
- typedef struct _GSheetUniformRow GSheetUniformRow;
- typedef struct _GSheetUniformRowClass GSheetUniformRowClass;
-
-#ifdef __cplusplus
-}
-#endif /* __cplusplus */
-
-#endif /* __G_SHEET_UNIFORM_ROW_H__ */
-
-
\f
-/* New functions since AXIS_TRANSITION */
+/* Column related functions */
gboolean
g_sheet_model_get_column_sensitivity (const GSheetModel *model, gint col)
{
return GTK_JUSTIFY_LEFT;
}
+\f
+
+gboolean
+g_sheet_model_get_row_sensitivity (const GSheetModel *model, gint row)
+{
+ if ( NULL == G_SHEET_MODEL_GET_IFACE (model)->get_row_sensitivity)
+ return TRUE;
+
+ return G_SHEET_MODEL_GET_IFACE (model)->get_row_sensitivity (model, row);
+}
+
+
+
+gchar *
+g_sheet_model_get_row_subtitle (const GSheetModel *model,
+ gint row)
+{
+ g_return_val_if_fail (G_IS_SHEET_MODEL (model), NULL);
+
+ if ( NULL == G_SHEET_MODEL_GET_IFACE (model)->get_row_subtitle)
+ return NULL;
+
+ return G_SHEET_MODEL_GET_IFACE (model)->get_row_subtitle (model, row);
+}
+
+
+GtkSheetButton *
+g_sheet_model_get_row_button (const GSheetModel *model,
+ gint row)
+{
+ GtkSheetButton *button = gtk_sheet_button_new ();
+
+ g_return_val_if_fail (G_IS_SHEET_MODEL (model), NULL);
+
+ if ( G_SHEET_MODEL_GET_IFACE (model)->get_row_title)
+ button->label = G_SHEET_MODEL_GET_IFACE (model)->get_row_title (model, row);
+
+ return button;
+}
+
/* column related metadata */
- gchar * (*get_column_title) (const GSheetModel *mode, gint col);
- gchar * (*get_column_subtitle) (const GSheetModel *mode, gint col);
- gboolean * (*get_column_sensitivity) (const GSheetModel *mode, gint col);
+ gchar * (*get_column_title) (const GSheetModel *, gint col);
+ gchar * (*get_column_subtitle) (const GSheetModel *, gint col);
+ gboolean (*get_column_sensitivity) (const GSheetModel *, gint col);
GtkJustification (*get_column_justification) (const GSheetModel *mode, gint col);
const GtkSheetButton * (* get_button) (const GSheetModel *model, gint col);
/* row related metadata */
+ gchar * (*get_row_title) (const GSheetModel *, gint row);
+ gchar * (*get_row_subtitle) (const GSheetModel *, gint row);
glong (*get_row_count) (const GSheetModel *model);
+ gboolean (*get_row_sensitivity) (const GSheetModel *, gint row);
};
GtkJustification g_sheet_model_get_column_justification (const GSheetModel *,
gint);
+\f
+
+gboolean g_sheet_model_get_row_sensitivity (const GSheetModel *model,
+ gint row);
+
+
+gchar * g_sheet_model_get_row_subtitle (const GSheetModel *model,
+ gint row);
+
+
+GtkSheetButton * g_sheet_model_get_row_button (const GSheetModel *, gint);
+
+
+
G_END_DECLS
g_free (text);
}
-/* Return the row containing pixel Y */
-static gint
-yyy_row_ypixel_to_row (const GtkSheet *sheet, gint y)
-{
- GSheetRow *geo = sheet->row_geometry;
- g_return_val_if_fail (y >= 0, -1);
+/* FIXME: Why bother with these two ? */
- return g_sheet_row_pixel_to_row (geo, y);
+/* returns the column index from a pixel location */
+static inline gint
+column_from_xpixel (const GtkSheet *sheet, gint pixel)
+{
+ return psppire_axis_get_unit_at_pixel (sheet->haxis, pixel);
+}
+
+static inline gint
+row_from_ypixel (const GtkSheet *sheet, gint pixel)
+{
+ 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 = yyy_row_ypixel_to_row (sheet, sheet->vadjustment->value);
+ glong row = min_visible_row (sheet);
- if ( g_sheet_row_start_pixel (sheet->row_geometry, row) < sheet->vadjustment->value)
+ if ( psppire_axis_pixel_start (sheet->vaxis, row) < sheet->vadjustment->value)
row++;
- return 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);
}
{
glong row = max_visible_row (sheet);
- if ( g_sheet_row_start_pixel (sheet->row_geometry, row)
+ if ( psppire_axis_pixel_start (sheet->vaxis, row)
+
- g_sheet_row_get_height (sheet->row_geometry, row)
+ psppire_axis_unit_size (sheet->vaxis, row)
> sheet->vadjustment->value)
row--;
}
-/* returns the column index from a pixel location */
-static inline gint
-column_from_xpixel (const GtkSheet *sheet, gint pixel)
-{
- return psppire_axis_get_unit_at_pixel (sheet->haxis, pixel);
-}
-
-
/* Returns the lowest column number which is wholly or partially
on the sheet */
static inline glong
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 >= 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 = psppire_axis_pixel_start (sheet->haxis, sheet->range.col0);
if (x >= xdrag - DRAG_WIDTH / 2 && x <= xdrag + DRAG_WIDTH / 2)
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 = 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;
r->x += sheet->row_title_area.width;
- r->y = g_sheet_row_start_pixel (sheet->row_geometry, range->row0);
+ r->y = psppire_axis_pixel_start (sheet->vaxis, range->row0);
r->y -= round (sheet->vadjustment->value);
if ( sheet->column_titles_visible)
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;
}
enum
{
PROP_0,
- PROP_ROW_GEO,
+ PROP_VAXIS,
PROP_HAXIS,
PROP_MODEL
};
-static void
-gtk_sheet_set_row_geometry (GtkSheet *sheet, GSheetRow *geo)
-{
- if ( sheet->row_geometry ) g_object_unref (sheet->row_geometry);
-
- sheet->row_geometry = geo;
-
- if ( sheet->row_geometry ) g_object_ref (sheet->row_geometry);
-}
-
static void
gtk_sheet_set_horizontal_axis (GtkSheet *sheet, PsppireAxis *a)
{
g_object_ref (sheet->haxis);
}
+static void
+gtk_sheet_set_vertical_axis (GtkSheet *sheet, PsppireAxis *a)
+{
+ if ( sheet->vaxis )
+ g_object_unref (sheet->vaxis);
+
+ sheet->vaxis = a;
+
+ if ( sheet->vaxis )
+ g_object_ref (sheet->vaxis);
+}
+
static void
gtk_sheet_set_property (GObject *object,
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_HAXIS:
gtk_sheet_set_horizontal_axis (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_HAXIS:
g_value_set_pointer (value, sheet->haxis);
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
- GParamSpec *row_geo_spec ;
GParamSpec *haxis_spec ;
+ GParamSpec *vaxis_spec ;
GParamSpec *model_spec ;
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
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 );
haxis_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_HAXIS,
{
sheet->model = NULL;
sheet->haxis = NULL;
- sheet->row_geometry = NULL;
+ sheet->vaxis = NULL;
sheet->flags = 0;
sheet->selection_mode = GTK_SELECTION_NONE;
range.col0 = first_column;
range.row0 = 0;
range.coli = psppire_axis_unit_count (sheet->haxis) - 1;
- range.rowi = g_sheet_row_get_row_count (sheet->row_geometry) - 1;
+ range.rowi = psppire_axis_unit_count (sheet->vaxis) - 1;
adjust_scrollbars (sheet);
*/
range.row0 = first_row;
range.col0 = 0;
- range.rowi = g_sheet_row_get_row_count (sheet->row_geometry) - 1;
+ range.rowi = psppire_axis_unit_count (sheet->vaxis) - 1;
range.coli = psppire_axis_unit_count (sheet->haxis) - 1;
adjust_scrollbars (sheet);
* Returns: the new sheet widget
*/
GtkWidget *
-gtk_sheet_new (GSheetRow *vgeo, void *hgeo, GSheetModel *model)
+gtk_sheet_new (void *vgeo, void *hgeo, GSheetModel *model)
{
GtkWidget *widget = g_object_new (GTK_TYPE_SHEET,
- "row-geometry", vgeo,
"model", model,
NULL);
return widget;
g_return_if_fail (col <
psppire_axis_unit_count (sheet->haxis));
g_return_if_fail (row <
- g_sheet_row_get_row_count (sheet->row_geometry));
+ psppire_axis_unit_count (sheet->vaxis));
gdk_drawable_get_size (sheet->sheet_window, &width, &height);
if (row >= 0)
{
- gint y = g_sheet_row_start_pixel (sheet->row_geometry, row);
+ gint y = psppire_axis_pixel_start (sheet->vaxis, row);
gtk_adjustment_set_value (sheet->vadjustment, y - height * row_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)
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;
{
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 >= psppire_axis_unit_count (sheet->haxis))
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->vaxis) g_object_unref (sheet->vaxis);
if (sheet->haxis) g_object_unref (sheet->haxis);
g_object_unref (sheet->entry_container);
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 ||
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;
g_return_if_fail (GTK_IS_SHEET (sheet));
if (col >= psppire_axis_unit_count (sheet->haxis)
- || row >= g_sheet_row_get_row_count (sheet->row_geometry))
+ || row >= psppire_axis_unit_count (sheet->vaxis))
return;
if (col < 0 || row < 0) return;
g_return_if_fail (sheet != NULL);
g_return_if_fail (GTK_IS_SHEET (sheet));
if (column >= psppire_axis_unit_count (sheet->haxis) ||
- row >= g_sheet_row_get_row_count (sheet->row_geometry)) return;
+ 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 >= psppire_axis_unit_count (sheet->haxis) || 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 >= psppire_axis_unit_count (sheet->haxis) || 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;
}
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 >= psppire_axis_unit_count (sheet->haxis))
+ if (row >= psppire_axis_unit_count (sheet->vaxis) || column >= psppire_axis_unit_count (sheet->haxis))
return FALSE;
area->x = (column == -1) ? 0 : psppire_axis_pixel_start (sheet->haxis, column);
- area->y = (row == -1) ? 0 : g_sheet_row_start_pixel (sheet->row_geometry, row);
+ area->y = (row == -1) ? 0 : psppire_axis_pixel_start (sheet->vaxis, row);
area->width= (column == -1) ? sheet->row_title_area.width
: 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;
}
if (row < -1 || col < -1)
return;
- if (row >= g_sheet_row_get_row_count (sheet->row_geometry)
+ if (row >= psppire_axis_unit_count (sheet->vaxis)
||
col >= psppire_axis_unit_count (sheet->haxis))
return;
if (row < 0 || col < 0)
return;
- if ( row > g_sheet_row_get_row_count (sheet->row_geometry)
+ if ( row > psppire_axis_unit_count (sheet->vaxis)
|| col > psppire_axis_unit_count (sheet->haxis))
return;
if (mask1 != mask2)
{
x = psppire_axis_pixel_start (sheet->haxis, j);
- y = g_sheet_row_start_pixel (sheet->row_geometry, i);
+ 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 == sheet->range.row0)
{
if (i != sheet->active_cell.row || j != sheet->active_cell.col)
{
x = psppire_axis_pixel_start (sheet->haxis, j);
- y = g_sheet_row_start_pixel (sheet->row_geometry, i);
+ 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)
{
{
x = psppire_axis_pixel_start (sheet->haxis, j);
- y = g_sheet_row_start_pixel (sheet->row_geometry, i);
+ 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 == sheet->range.row0)
{
{
x = psppire_axis_pixel_start (sheet->haxis, j);
- y = g_sheet_row_start_pixel (sheet->row_geometry, i);
+ 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 (mask2 != mask1 || (mask2 == mask1 && state != GTK_STATE_SELECTED))
{
x = psppire_axis_pixel_start (sheet->haxis, j);
- y = g_sheet_row_start_pixel (sheet->row_geometry, i);
+ y = psppire_axis_pixel_start (sheet->vaxis, i);
width = psppire_axis_unit_size (sheet->haxis, j);
- height = g_sheet_row_get_height (sheet->row_geometry, i);
+ height = psppire_axis_unit_size (sheet->vaxis, i);
if (mask2 & 1)
gdk_draw_rectangle (sheet->sheet_window,
sheet->xor_gc,
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_signals[BUTTON_EVENT_ROW], 0,
row, event);
-
- if (g_sheet_row_get_sensitivity (sheet->row_geometry, row))
+ if (g_sheet_model_get_row_sensitivity (sheet->model, row))
{
if ( event->type == GDK_2BUTTON_PRESS && event->button == 1)
g_signal_emit (sheet,
{
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 */
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));
cell.row = row;
cell.col = column;
- if (row >= g_sheet_row_get_row_count (sheet->row_geometry)
+ if (row >= psppire_axis_unit_count (sheet->vaxis)
|| column >= psppire_axis_unit_count (sheet->haxis))
{
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 =
psppire_axis_unit_count (sheet->haxis) - 1;
sheet->active_cell.row = 0;
{
if (sheet->row_title_under)
{
- GSheetRow *row_geo = sheet->row_geometry;
- gchar *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 (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) &&
+ 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;
gint v_h, current_col, current_row, col_threshold, row_threshold;
v_h = 1;
if (abs (x - psppire_axis_pixel_start (sheet->haxis, sheet->drag_cell.col)) >
- abs (y - g_sheet_row_start_pixel (sheet->row_geometry, sheet->drag_cell.row))) v_h = 2;
+ 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;
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) &&
+ 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;
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);
change_active_cell (sheet, new_row,
sheet->active_cell.col);
maximize_int (&new_cell.col, 0);
minimize_int (&new_cell.row,
- g_sheet_row_get_row_count (sheet->row_geometry) - 1);
+ psppire_axis_unit_count (sheet->vaxis) - 1);
minimize_int (&new_cell.col,
psppire_axis_unit_count (sheet->haxis) - 1);
if ( new_cell.row > max_fully_visible_row (sheet))
{
glong vpos =
- g_sheet_row_start_pixel (sheet->row_geometry,
+ psppire_axis_pixel_start (sheet->vaxis,
new_cell.row + 1);
vpos -= sheet->vadjustment->page_size;
else if ( new_cell.row < min_fully_visible_row (sheet))
{
glong vpos =
- g_sheet_row_start_pixel (sheet->row_geometry,
+ psppire_axis_pixel_start (sheet->vaxis,
new_cell.row);
gtk_adjustment_set_value (sheet->vadjustment,
/*
change_active_cellx (sheet,
- g_sheet_row_get_row_count (sheet->row_geometry) - 1,
+ psppire_axis_unit_count (sheet->vaxis) - 1,
sheet->active_cell.col);
*/
break;
/* 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);
- /* 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->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);
+ }
+
+
/* set the scrollbars adjustments */
adjust_scrollbars (sheet);
}
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,
gboolean is_sensitive = FALSE;
GtkSheetButton *button =
- g_sheet_row_get_button (sheet->row_geometry, row);
+ g_sheet_model_get_row_button (sheet->model, row);
allocation.x = 0;
- allocation.y = g_sheet_row_start_pixel (sheet->row_geometry, row)
+ 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 = g_sheet_row_get_height (sheet->row_geometry, row);
- is_sensitive = g_sheet_row_get_sensitivity (sheet->row_geometry, row);
+ 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);
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)
;
sheet->vadjustment->lower = 0;
GdkGCValues values;
area.x = psppire_axis_pixel_start (sheet->haxis, range.col0);
- area.y = g_sheet_row_start_pixel (sheet->row_geometry, range.row0);
+ 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 = g_sheet_row_start_pixel (sheet->row_geometry, range.rowi)- area.y +
- g_sheet_row_get_height (sheet->row_geometry, range.rowi);
+ 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;
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);
+#endif
draw_row_title_buttons (sheet);
return height;
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)) )
{
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;
#include "gtkextra-sheet.h"
#include "gsheetmodel.h"
-#include "gsheet-row-iface.h"
#include "psppire-axis.h"
G_BEGIN_DECLS
GtkBin parent;
gboolean dispose_has_run;
- /*
- GSheetColumn *column_geometry;
- */
PsppireAxis *haxis;
- GSheetRow *row_geometry;
+ PsppireAxis *vaxis;
guint16 flags;
/* create a new sheet */
-GtkWidget * gtk_sheet_new (GSheetRow *vgeo, void *hgeo,
+GtkWidget * gtk_sheet_new (void *vgeo, void *hgeo,
GSheetModel *model);
/* create a new sheet with custom entry */
GtkWidget *
-gtk_sheet_new_with_custom_entry (GSheetRow *vgeo,
+gtk_sheet_new_with_custom_entry (void *vgeo,
void *hgeo,
GtkType entry_type);
-void
-gtk_sheet_construct_with_custom_entry (GtkSheet *sheet,
- GSheetRow *vgeo,
- void *hgeo,
- GtkType entry_type);
/* Change entry */
void gtk_sheet_change_entry (GtkSheet *sheet, GtkType entry_type);
--- /dev/null
+/* PSPPIRE - a graphical user interface for PSPP.
+ Copyright (C) 2008 Free Software Foundation
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+#include <config.h>
+#include <string.h>
+#include <stdlib.h>
+
+#include <libpspp/tower.h>
+#include <libpspp/pool.h>
+#include "psppire-axis-hetero.h"
+#include <gtk/gtk.h>
+
+
+/* --- prototypes --- */
+static void psppire_axis_hetero_class_init (PsppireAxisHeteroClass *class);
+static void psppire_axis_hetero_init (PsppireAxisHetero *axis);
+static void psppire_axis_hetero_finalize (GObject *object);
+
+
+/* --- variables --- */
+static GObjectClass *parent_class = NULL;
+
+
+static gint
+get_unit_at_pixel (const PsppireAxis *a, glong pixel)
+{
+ PsppireAxisHetero *ah = PSPPIRE_AXIS_HETERO (a);
+ const struct tower_node *node;
+ unsigned long int node_start;
+
+ if (pixel >= tower_height (&ah->tower))
+ return tower_count (&ah->tower);
+
+ node = tower_lookup (&ah->tower, pixel, &node_start);
+
+ return tower_node_get_index (node);
+}
+
+
+static gint
+unit_count (const PsppireAxis *a)
+{
+ PsppireAxisHetero *ah = PSPPIRE_AXIS_HETERO (a);
+ return tower_count (&ah->tower);
+}
+
+
+static glong
+pixel_start (const PsppireAxis *a, gint unit)
+{
+ PsppireAxisHetero *ah = PSPPIRE_AXIS_HETERO (a);
+ const struct tower_node *node;
+
+ if ( unit >= tower_count (&ah->tower))
+ return tower_height (&ah->tower);
+
+ node = tower_get (&ah->tower, unit);
+
+ return tower_node_get_level (node);
+}
+
+
+static gint
+unit_size (const PsppireAxis *a, gint unit)
+{
+ PsppireAxisHetero *ah = PSPPIRE_AXIS_HETERO (a);
+ const struct tower_node *node;
+ if (unit >= tower_count (&ah->tower))
+ return 0;
+
+ node = tower_get (&ah->tower, unit);
+
+ return tower_node_get_size (node);
+}
+
+
+static glong
+total_size (const PsppireAxis *a)
+{
+ glong s;
+ PsppireAxisHetero *ah = PSPPIRE_AXIS_HETERO (a);
+
+ s = tower_height (&ah->tower);
+ return s;
+}
+
+static void
+psppire_hetero_iface_init (PsppireAxisIface *iface)
+{
+ iface->unit_size = unit_size;
+ iface->unit_count = unit_count;
+ iface->pixel_start = pixel_start;
+ iface->get_unit_at_pixel = get_unit_at_pixel;
+ iface->total_size = total_size;
+}
+
+/* --- functions --- */
+/**
+ * psppire_axis_hetero_get_type:
+ * @returns: the type ID for accelerator groups.
+ */
+GType
+psppire_axis_hetero_get_type (void)
+{
+ static GType object_type = 0;
+
+ if (!object_type)
+ {
+ static const GTypeInfo object_info = {
+ sizeof (PsppireAxisHeteroClass),
+ (GBaseInitFunc) NULL,
+ (GBaseFinalizeFunc) NULL,
+ (GClassInitFunc) psppire_axis_hetero_class_init,
+ NULL, /* class_finalize */
+ NULL, /* class_data */
+ sizeof (PsppireAxisHetero),
+ 0, /* n_preallocs */
+ (GInstanceInitFunc) psppire_axis_hetero_init,
+ };
+
+
+ static const GInterfaceInfo interface_info =
+ {
+ (GInterfaceInitFunc) psppire_hetero_iface_init,
+ NULL,
+ NULL
+ };
+
+ object_type = g_type_register_static (G_TYPE_PSPPIRE_AXIS,
+ "PsppireAxisHetero",
+ &object_info, 0);
+
+ g_type_add_interface_static (object_type,
+ PSPPIRE_TYPE_AXIS_IFACE,
+ &interface_info);
+ }
+
+ return object_type;
+}
+
+static void
+psppire_axis_hetero_class_init (PsppireAxisHeteroClass *class)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (class);
+ parent_class = g_type_class_peek_parent (class);
+
+ object_class->finalize = psppire_axis_hetero_finalize;
+}
+
+
+static void
+psppire_axis_hetero_init (PsppireAxisHetero *axis)
+{
+ axis->pool = NULL;
+ psppire_axis_hetero_clear (axis);
+}
+
+
+static void
+psppire_axis_hetero_finalize (GObject *object)
+{
+ PsppireAxisHetero *a = PSPPIRE_AXIS_HETERO (object);
+ pool_destroy (a->pool);
+ G_OBJECT_CLASS (parent_class)->finalize (object);
+}
+
+/**
+ * psppire_axis_hetero_new:
+ * @returns: a new #PsppireAxisHetero object
+ *
+ * Creates a new #PsppireAxisHetero.
+ */
+PsppireAxisHetero*
+psppire_axis_hetero_new (void)
+{
+ return g_object_new (G_TYPE_PSPPIRE_AXIS_HETERO, NULL);
+}
+
+
+void
+psppire_axis_hetero_append (PsppireAxisHetero *a, gint size)
+{
+ struct tower_node *new ;
+
+ g_return_if_fail (PSPPIRE_IS_AXIS_HETERO (a));
+
+ new = pool_malloc (a->pool, sizeof *new);
+
+ tower_insert (&a->tower, size, new, NULL);
+}
+
+
+
+/* Insert a new unit of size SIZE before position POSN */
+void
+psppire_axis_hetero_insert (PsppireAxisHetero *a, gint size, gint posn)
+{
+ struct tower_node *new;
+ struct tower_node *before = NULL;
+
+ g_return_if_fail (PSPPIRE_IS_AXIS_HETERO (a));
+
+ new = pool_malloc (a->pool, sizeof *new);
+
+ if ( posn != tower_count (&a->tower))
+ before = tower_get (&a->tower, posn);
+
+ tower_insert (&a->tower, size, new, before);
+}
+
+
+void
+psppire_axis_hetero_remove (PsppireAxisHetero *a, gint posn)
+{
+ struct tower_node *node;
+
+ g_return_if_fail (PSPPIRE_IS_AXIS_HETERO (a));
+
+ node = tower_get (&a->tower, posn);
+
+ tower_delete (&a->tower, node);
+
+ pool_free (a->pool, node);
+}
+
+
+void
+psppire_axis_hetero_resize_unit (PsppireAxisHetero *a, gint size, gint posn)
+{
+ struct tower_node *node;
+
+ g_return_if_fail (PSPPIRE_IS_AXIS_HETERO (a));
+
+ node = tower_get (&a->tower, posn);
+
+ tower_resize (&a->tower, node, size);
+}
+
+
+void
+psppire_axis_hetero_clear (PsppireAxisHetero *a)
+{
+ g_return_if_fail (PSPPIRE_IS_AXIS_HETERO (a));
+
+ pool_destroy (a->pool);
+ a->pool = pool_create ();
+ tower_init (&a->tower);
+}
+
+
--- /dev/null
+/* PSPPIRE - a graphical user interface for PSPP.
+ Copyright (C) 2008 Free Software Foundation
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+
+#ifndef PSPPIRE_AXIS_HETERO_H__
+#define PSPPIRE_AXIS_HETERO_H__
+
+
+#include <glib-object.h>
+#include <glib.h>
+
+#include <libpspp/tower.h>
+#include "psppire-axis.h"
+
+G_BEGIN_DECLS
+
+
+/* --- type macros --- */
+#define G_TYPE_PSPPIRE_AXIS_HETERO (psppire_axis_hetero_get_type ())
+#define PSPPIRE_AXIS_HETERO(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), G_TYPE_PSPPIRE_AXIS_HETERO, PsppireAxisHetero))
+#define PSPPIRE_AXIS_HETERO_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), G_TYPE_PSPPIRE_AXIS_HETERO, PsppireAxisHeteroClass))
+#define PSPPIRE_IS_AXIS_HETERO(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), G_TYPE_PSPPIRE_AXIS_HETERO))
+#define PSPPIRE_IS_AXIS_HETERO_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), G_TYPE_PSPPIRE_AXIS_HETERO))
+#define PSPPIRE_AXIS_HETERO_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), G_TYPE_PSPPIRE_AXIS_HETERO, PsppireAxisHeteroClass))
+
+
+
+/* --- typedefs & structures --- */
+typedef struct _PsppireAxisHetero PsppireAxisHetero;
+typedef struct _PsppireAxisHeteroClass PsppireAxisHeteroClass;
+
+struct pool;
+
+struct _PsppireAxisHetero
+{
+ PsppireAxis parent;
+
+ struct tower tower;
+ struct pool *pool;
+};
+
+struct _PsppireAxisHeteroClass
+{
+ PsppireAxisClass parent_class;
+};
+
+GType psppire_axis_hetero_get_type (void);
+
+PsppireAxisHetero* psppire_axis_hetero_new (void);
+
+\f
+/* Interface between axis and model */
+
+void psppire_axis_hetero_clear (PsppireAxisHetero *a);
+
+void psppire_axis_hetero_append (PsppireAxisHetero *a, gint size);
+
+void psppire_axis_hetero_insert (PsppireAxisHetero *a, gint size, gint posn);
+
+void psppire_axis_hetero_remove (PsppireAxisHetero *a, gint posn);
+
+void psppire_axis_hetero_resize_unit (PsppireAxisHetero *a, gint size, gint posn);
+
+
+G_END_DECLS
+
+#endif /* PSPPIRE_AXIS_HETERO_H__ */
--- /dev/null
+/* PSPPIRE - a graphical user interface for PSPP.
+ Copyright (C) 2008 Free Software Foundation
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+#include <config.h>
+#include <string.h>
+#include <stdlib.h>
+
+#include <libpspp/tower.h>
+#include <libpspp/pool.h>
+#include "psppire-axis-uniform.h"
+#include <gtk/gtk.h>
+
+
+/* --- prototypes --- */
+static void psppire_axis_uniform_class_init (PsppireAxisUniformClass *class);
+static void psppire_axis_uniform_init (PsppireAxisUniform *axis);
+static void psppire_axis_uniform_finalize (GObject *object);
+
+
+/* --- variables --- */
+static GObjectClass *parent_class = NULL;
+
+
+#define UNIT_SIZE 25
+
+static gint
+get_unit_at_pixel (const PsppireAxis *a, glong pixel)
+{
+ gint unit_size;
+ PsppireAxisUniform *au = PSPPIRE_AXIS_UNIFORM (a);
+
+ g_object_get (au, "default-size", &unit_size, NULL);
+
+ return pixel / unit_size;
+}
+
+
+static gint
+unit_count (const PsppireAxis *a)
+{
+ PsppireAxisUniform *au = PSPPIRE_AXIS_UNIFORM (a);
+
+ return au->n_items;
+}
+
+
+static glong
+pixel_start (const PsppireAxis *a, gint unit)
+{
+ gint unit_size;
+ PsppireAxisUniform *au = PSPPIRE_AXIS_UNIFORM (a);
+
+ g_object_get (au, "default-size", &unit_size, NULL);
+
+ return unit * unit_size;
+}
+
+
+static gint
+unit_size (const PsppireAxis *a, gint unit)
+{
+ gint unit_size;
+ PsppireAxisUniform *au = PSPPIRE_AXIS_UNIFORM (a);
+
+ g_object_get (au, "default-size", &unit_size, NULL);
+
+ return unit_size;
+}
+
+
+static glong
+total_size (const PsppireAxis *a)
+{
+ gint unit_size;
+ PsppireAxisUniform *au = PSPPIRE_AXIS_UNIFORM (a);
+
+ g_object_get (au, "default-size", &unit_size, NULL);
+
+ return unit_size * au->n_items;
+}
+
+
+
+static void
+psppire_uniform_iface_init (PsppireAxisIface *iface)
+{
+ iface->unit_size = unit_size;
+ iface->unit_count = unit_count;
+ iface->pixel_start = pixel_start;
+ iface->get_unit_at_pixel = get_unit_at_pixel;
+ iface->total_size = total_size;
+}
+
+/* --- functions --- */
+/**
+ * psppire_axis_uniform_get_type:
+ * @returns: the type ID for accelerator groups.
+ */
+GType
+psppire_axis_uniform_get_type (void)
+{
+ static GType object_type = 0;
+
+ if (!object_type)
+ {
+ static const GTypeInfo object_info = {
+ sizeof (PsppireAxisUniformClass),
+ (GBaseInitFunc) NULL,
+ (GBaseFinalizeFunc) NULL,
+ (GClassInitFunc) psppire_axis_uniform_class_init,
+ NULL, /* class_finalize */
+ NULL, /* class_data */
+ sizeof (PsppireAxisUniform),
+ 0, /* n_preallocs */
+ (GInstanceInitFunc) psppire_axis_uniform_init,
+ };
+
+ static const GInterfaceInfo interface_info =
+ {
+ (GInterfaceInitFunc) psppire_uniform_iface_init,
+ NULL,
+ NULL
+ };
+
+
+ object_type = g_type_register_static (G_TYPE_PSPPIRE_AXIS,
+ "PsppireAxisUniform",
+ &object_info, 0);
+
+
+ g_type_add_interface_static (object_type,
+ PSPPIRE_TYPE_AXIS_IFACE,
+ &interface_info);
+ }
+
+ return object_type;
+}
+
+static void
+psppire_axis_uniform_class_init (PsppireAxisUniformClass *class)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (class);
+ parent_class = g_type_class_peek_parent (class);
+
+ object_class->finalize = psppire_axis_uniform_finalize;
+}
+
+
+static void
+psppire_axis_uniform_init (PsppireAxisUniform *axis)
+{
+ axis->n_items = 0;
+}
+
+
+static void
+psppire_axis_uniform_finalize (GObject *object)
+{
+ G_OBJECT_CLASS (parent_class)->finalize (object);
+}
+
+/**
+ * psppire_axis_uniform_new:
+ * @returns: a new #PsppireAxisUniform object
+ *
+ * Creates a new #PsppireAxisUniform.
+ */
+PsppireAxisUniform*
+psppire_axis_uniform_new (void)
+{
+ return g_object_new (G_TYPE_PSPPIRE_AXIS_UNIFORM, NULL);
+}
+
+
+
+\f
+
+
+void
+psppire_axis_uniform_set_count (PsppireAxisUniform *axis, gint n)
+{
+ axis->n_items = n;
+}
--- /dev/null
+/* PSPPIRE - a graphical user interface for PSPP.
+ Copyright (C) 2008 Free Software Foundation
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+
+#ifndef PSPPIRE_AXIS_UNIFORM_H__
+#define PSPPIRE_AXIS_UNIFORM_H__
+
+
+#include <glib-object.h>
+#include <glib.h>
+
+#include "psppire-axis.h"
+
+G_BEGIN_DECLS
+
+
+/* --- type macros --- */
+#define G_TYPE_PSPPIRE_AXIS_UNIFORM (psppire_axis_uniform_get_type ())
+#define PSPPIRE_AXIS_UNIFORM(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), G_TYPE_PSPPIRE_AXIS_UNIFORM, PsppireAxisUniform))
+#define PSPPIRE_AXIS_UNIFORM_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), G_TYPE_PSPPIRE_AXIS_UNIFORM, PsppireAxisUniformClass))
+#define PSPPIRE_IS_AXIS_UNIFORM(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), G_TYPE_PSPPIRE_AXIS_UNIFORM))
+#define PSPPIRE_IS_AXIS_UNIFORM_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), G_TYPE_PSPPIRE_AXIS_UNIFORM))
+#define PSPPIRE_AXIS_UNIFORM_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), G_TYPE_PSPPIRE_AXIS_UNIFORM, PsppireAxisUniformClass))
+
+
+
+/* --- typedefs & structures --- */
+typedef struct _PsppireAxisUniform PsppireAxisUniform;
+typedef struct _PsppireAxisUniformClass PsppireAxisUniformClass;
+
+struct pool;
+
+struct _PsppireAxisUniform
+{
+ PsppireAxis parent;
+
+ gint n_items;
+};
+
+struct _PsppireAxisUniformClass
+{
+ PsppireAxisClass parent_class;
+};
+
+GType psppire_axis_uniform_get_type (void);
+
+PsppireAxisUniform* psppire_axis_uniform_new (void);
+
+\f
+/* Interface between axis and model */
+
+
+void psppire_axis_uniform_set_count (PsppireAxisUniform *axis, gint n);
+
+
+
+G_END_DECLS
+
+#endif /* PSPPIRE_AXIS_UNIFORM_H__ */
#include <gtk/gtk.h>
-/* --- prototypes --- */
-static void psppire_axis_class_init (PsppireAxisClass *class);
-static void psppire_axis_init (PsppireAxis *axis);
-static void psppire_axis_finalize (GObject *object);
-
-
-/* --- variables --- */
-static GObjectClass *parent_class = NULL;
+#define PSPPIRE_AXIS_GET_IFACE(obj) \
+ (G_TYPE_INSTANCE_GET_INTERFACE ((obj), PSPPIRE_TYPE_AXIS_IFACE, PsppireAxisIface))
-/* --- functions --- */
-/**
- * psppire_axis_get_type:
- * @returns: the type ID for accelerator groups.
- */
GType
-psppire_axis_get_type (void)
+psppire_axis_iface_get_type (void)
{
- static GType object_type = 0;
+ static GType psppire_axis_iface_type = 0;
- if (!object_type)
+ if (! psppire_axis_iface_type)
{
- static const GTypeInfo object_info = {
- sizeof (PsppireAxisClass),
- (GBaseInitFunc) NULL,
- (GBaseFinalizeFunc) NULL,
- (GClassInitFunc) psppire_axis_class_init,
- NULL, /* class_finalize */
- NULL, /* class_data */
- sizeof (PsppireAxis),
- 0, /* n_preallocs */
- (GInstanceInitFunc) psppire_axis_init,
+ static const GTypeInfo psppire_axis_iface_info =
+ {
+ sizeof (PsppireAxisIface), /* class_size */
+ NULL, /* base init */
+ NULL, /* base_finalize */
+ NULL,
+ NULL, /* class_finalize */
+ NULL, /* class_data */
+ 0,
+ 0, /* n_preallocs */
+ NULL
};
- object_type = g_type_register_static (G_TYPE_OBJECT,
- "PsppireAxis",
- &object_info, 0);
+ psppire_axis_iface_type =
+ g_type_register_static (G_TYPE_INTERFACE, "PsppireAxisIface",
+ &psppire_axis_iface_info, 0);
}
- return object_type;
+ return psppire_axis_iface_type;
}
+G_DEFINE_ABSTRACT_TYPE(PsppireAxis, psppire_axis, G_TYPE_OBJECT);
+
+
+
+/* --- prototypes --- */
+static void psppire_axis_class_init (PsppireAxisClass *class);
+static void psppire_axis_init (PsppireAxis *axis);
+static void psppire_axis_finalize (GObject *object);
+
+
+/* --- variables --- */
+static GObjectClass *parent_class = NULL;
+
+
+
enum
{
PROP_0,
min_extent_spec =
g_param_spec_long ("minimum-extent",
"Minimum Extent",
- "The smallest extent to which the axis will provide units (typically set to the height/width of the associated widget)",
+ "The smallest extent to which the axis will provide units (typically set to the height/width of the associated widget).",
0, G_MAXLONG,
- 800,
- G_PARAM_WRITABLE | G_PARAM_READABLE );
+ 0,
+ G_PARAM_CONSTRUCT | G_PARAM_WRITABLE | G_PARAM_READABLE );
g_object_class_install_property (object_class,
PROP_MIN_EXTENT,
default_size_spec =
- g_param_spec_pointer ("default-size",
- "Default Size",
- "The size given to units which haven't been explicity inserted",
- G_PARAM_WRITABLE | G_PARAM_READABLE );
+ g_param_spec_int ("default-size",
+ "Default Size",
+ "The size given to units which haven't been explicity inserted",
+ 0, G_MAXINT,
+ 25,
+ G_PARAM_CONSTRUCT | G_PARAM_WRITABLE | G_PARAM_READABLE );
g_object_class_install_property (object_class,
static void
psppire_axis_init (PsppireAxis *axis)
{
- axis->min_extent = 800;
- axis->default_size = 75;
- axis->pool = NULL;
- psppire_axis_clear (axis);
}
static void
psppire_axis_finalize (GObject *object)
{
- PsppireAxis *a = PSPPIRE_AXIS (object);
- pool_destroy (a->pool);
G_OBJECT_CLASS (parent_class)->finalize (object);
}
-/**
- * psppire_axis_new:
- * @returns: a new #PsppireAxis object
- *
- * Creates a new #PsppireAxis.
- */
-PsppireAxis*
-psppire_axis_new (void)
+gint
+psppire_axis_unit_size (const PsppireAxis *a, gint unit)
{
- return g_object_new (G_TYPE_PSPPIRE_AXIS, NULL);
-}
+ g_return_val_if_fail (PSPPIRE_IS_AXIS (a), -1);
+ g_return_val_if_fail (PSPPIRE_AXIS_GET_IFACE (a)->unit_size, -1);
-gint
-psppire_axis_unit_size (PsppireAxis *a, gint unit)
-{
- const struct tower_node *node;
- if (unit >= tower_count (&a->tower))
- return a->default_size;
- node = tower_get (&a->tower, unit);
+ if (unit >= PSPPIRE_AXIS_GET_IFACE (a)->unit_count(a))
+ return a->default_size;
- return tower_node_get_size (node);
+ return PSPPIRE_AXIS_GET_IFACE (a)->unit_size (a, unit);
}
gint
-psppire_axis_unit_count (PsppireAxis *a)
+psppire_axis_unit_count (const PsppireAxis *a)
{
glong padding = 0;
+ glong actual_size;
- if ( tower_height (&a->tower) < a->min_extent )
- padding = (a->min_extent - tower_height (&a->tower))
- / a->default_size;
+ g_return_val_if_fail (PSPPIRE_IS_AXIS (a), -1);
+ g_return_val_if_fail (PSPPIRE_AXIS_GET_IFACE (a)->unit_count, -1);
- return tower_count (&a->tower) + padding;
+ actual_size = PSPPIRE_AXIS_GET_IFACE (a)->total_size (a);
+
+ if ( actual_size < a->min_extent )
+ padding = (a->min_extent - actual_size) / a->default_size;
+
+ return PSPPIRE_AXIS_GET_IFACE (a)->unit_count (a) + padding;
}
/* Return the starting pixel of UNIT */
glong
-psppire_axis_pixel_start (PsppireAxis *a, gint unit)
+psppire_axis_pixel_start (const PsppireAxis *a, gint unit)
{
- const struct tower_node *node;
+ gint the_count, total_size ;
+ g_return_val_if_fail (PSPPIRE_IS_AXIS (a), -1);
- if ( unit >= tower_count (&a->tower))
- {
- return tower_height (&a->tower) +
- (unit - tower_count (&a->tower)) * a->default_size;
- }
+ the_count = PSPPIRE_AXIS_GET_IFACE (a)->unit_count (a);
+ total_size = PSPPIRE_AXIS_GET_IFACE (a)->total_size (a);
- node = tower_get (&a->tower, unit);
- return tower_node_get_level (node);
-}
-
-
-/* Return the unit covered by PIXEL */
-gint
-psppire_axis_get_unit_at_pixel (PsppireAxis *a, glong pixel)
-{
- const struct tower_node *node;
- unsigned long int node_start;
-
- if (pixel >= tower_height (&a->tower))
+ if ( unit >= the_count)
{
- glong extra = pixel - tower_height (&a->tower);
-
- if ( extra > a->min_extent - tower_height (&a->tower))
- extra = a->min_extent - tower_height (&a->tower);
-
- return tower_count (&a->tower) - 1 + extra / a->default_size;
+ return total_size + (unit - the_count) * a->default_size;
}
- node = tower_lookup (&a->tower, pixel, &node_start);
-
- return tower_node_get_index (node);
-}
-
-void
-psppire_axis_append (PsppireAxis *a, gint size)
-{
- struct tower_node *new = pool_malloc (a->pool, sizeof *new);
+ // g_print ("%s %d\n", __FUNCTION__, unit);
- tower_insert (&a->tower, size, new, NULL);
+ return PSPPIRE_AXIS_GET_IFACE (a)->pixel_start (a, unit);
}
-
-/* Insert a new unit of size SIZE before position POSN */
-void
-psppire_axis_insert (PsppireAxis *a, gint size, gint posn)
-{
- struct tower_node *new = pool_malloc (a->pool, sizeof *new);
-
- struct tower_node *before = NULL;
-
- if ( posn != tower_count (&a->tower))
- before = tower_get (&a->tower, posn);
-
- tower_insert (&a->tower, size, new, before);
-}
-
-
-void
-psppire_axis_remove (PsppireAxis *a, gint posn)
+/* Return the unit covered by PIXEL */
+gint
+psppire_axis_get_unit_at_pixel (const PsppireAxis *a, glong pixel)
{
- struct tower_node *node = tower_get (&a->tower, posn);
+ glong total_size;
- tower_delete (&a->tower, node);
+ g_return_val_if_fail (PSPPIRE_IS_AXIS (a), -1);
- pool_free (a->pool, node);
-}
+ g_return_val_if_fail (PSPPIRE_AXIS_GET_IFACE (a), -1);
+ g_return_val_if_fail (PSPPIRE_AXIS_GET_IFACE (a)->get_unit_at_pixel, -1);
-void
-psppire_axis_resize_unit (PsppireAxis *a, gint size, gint posn)
-{
- struct tower_node *node = tower_get (&a->tower, posn);
+ total_size = PSPPIRE_AXIS_GET_IFACE (a)->total_size (a);
- tower_resize (&a->tower, node, size);
-}
+ if (pixel >= total_size)
+ {
+ gint n_items = PSPPIRE_AXIS_GET_IFACE (a)->unit_count (a);
+ glong extra = pixel - total_size;
+ return n_items - 1 + extra / a->default_size;
+ }
-void
-psppire_axis_clear (PsppireAxis *a)
-{
- pool_destroy (a->pool);
- a->pool = pool_create ();
- tower_init (&a->tower);
+ return PSPPIRE_AXIS_GET_IFACE (a)->get_unit_at_pixel (a, pixel);
}
-
-
G_BEGIN_DECLS
+
/* --- type macros --- */
#define G_TYPE_PSPPIRE_AXIS (psppire_axis_get_type ())
#define PSPPIRE_AXIS(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), G_TYPE_PSPPIRE_AXIS, PsppireAxis))
#define PSPPIRE_AXIS_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), G_TYPE_PSPPIRE_AXIS, PsppireAxisClass))
-
/* --- typedefs & structures --- */
typedef struct _PsppireAxis PsppireAxis;
typedef struct _PsppireAxisClass PsppireAxisClass;
-struct pool;
-
struct _PsppireAxis
{
GObject parent;
- struct tower tower;
- struct pool *pool;
-
glong min_extent;
gint default_size;
};
GObjectClass parent_class;
};
+
GType psppire_axis_get_type (void);
-PsppireAxis* psppire_axis_new (void);
\f
-/* Interface between sheet and axis */
-gint psppire_axis_unit_size (PsppireAxis *a, gint unit);
+GType psppire_axis_iface_get_type (void);
+
+#define PSPPIRE_TYPE_AXIS_IFACE (psppire_axis_iface_get_type ())
-gint psppire_axis_unit_count (PsppireAxis *a);
+typedef struct _PsppireAxisIface PsppireAxisIface;
+
+struct _PsppireAxisIface
+{
+ GTypeInterface g_iface;
-glong psppire_axis_pixel_start (PsppireAxis *a, gint unit);
-gint psppire_axis_get_unit_at_pixel (PsppireAxis *a, glong pixel);
+ /* Virtual Table */
+ gint (*unit_size) (const PsppireAxis *a, gint unit);
+ gint (*unit_count) (const PsppireAxis *a);
-/* Interface between axis and model */
+ glong (*pixel_start) (const PsppireAxis *a, gint unit);
-void psppire_axis_clear (PsppireAxis *a);
+ gint (*get_unit_at_pixel) (const PsppireAxis *a, glong pixel);
+
+ glong (*total_size ) (const PsppireAxis *a);
+};
+
+
+/* Interface between sheet and axis */
-void psppire_axis_append (PsppireAxis *a, gint size);
+gint psppire_axis_unit_size (const PsppireAxis *a, gint unit);
-void psppire_axis_insert (PsppireAxis *a, gint size, gint posn);
+gint psppire_axis_unit_count (const PsppireAxis *a);
-void psppire_axis_remove (PsppireAxis *a, gint posn);
+glong psppire_axis_pixel_start (const PsppireAxis *a, gint unit);
-void psppire_axis_resize_unit (PsppireAxis *a, gint size, gint posn);
+gint psppire_axis_get_unit_at_pixel (const PsppireAxis *a, glong pixel);
G_END_DECLS
#include <language/syntax-string-source.h>
#include "psppire-data-store.h"
+#include <gtksheet/psppire-axis-hetero.h>
+#include <gtksheet/psppire-axis-uniform.h>
#include "helper.h"
#include <gtksheet/gtkxpaned.h>
#define WIDTH_OF_M 10
+#define DEFAULT_ROW_HEIGHT 25
+
+static void
+new_data_callback (PsppireDataStore *ds, gpointer data)
+{
+ PsppireDataEditor *de = PSPPIRE_DATA_EDITOR (data);
+ gint i;
+ for (i = 0 ; i < 4 ; ++i)
+ {
+ PsppireAxisUniform *vaxis;
+ casenumber n_cases = psppire_case_file_get_case_count (ds->case_file);
+
+ g_object_get (de->data_sheet[i], "vertical-axis", &vaxis, NULL);
+
+ psppire_axis_uniform_set_count (vaxis, n_cases);
+ }
+}
static void
new_variables_callback (PsppireDict *dict, gpointer data)
gint v, i;
PsppireDataEditor *de = PSPPIRE_DATA_EDITOR (data);
+ PsppireAxisHetero *vaxis;
+ g_object_get (de->var_sheet, "vertical-axis", &vaxis, NULL);
+
+ psppire_axis_hetero_clear (vaxis);
+
+ for (v = 0 ; v < psppire_dict_get_var_cnt (dict); ++v)
+ psppire_axis_hetero_append (vaxis, DEFAULT_ROW_HEIGHT);
+
for (i = 0 ; i < 4 ; ++i)
{
- PsppireAxis *haxis;
+ PsppireAxisHetero *haxis;
g_object_get (de->data_sheet[i], "horizontal-axis", &haxis, NULL);
- psppire_axis_clear (haxis);
+ psppire_axis_hetero_clear (haxis);
for (v = 0 ; v < psppire_dict_get_var_cnt (dict); ++v)
{
const struct variable *var = psppire_dict_get_variable (dict, v);
- psppire_axis_append (haxis, 10 * var_get_display_width (var));
+ psppire_axis_hetero_append (haxis, 10 * var_get_display_width (var));
}
}
}
gint i;
PsppireDataEditor *de = PSPPIRE_DATA_EDITOR (data);
+ PsppireAxisHetero *var_vaxis;
+ g_object_get (de->var_sheet, "vertical-axis", &var_vaxis, NULL);
+
+ psppire_axis_hetero_insert (var_vaxis, DEFAULT_ROW_HEIGHT, x);
+
for (i = 0 ; i < 4 ; ++i)
{
const struct variable *var = psppire_dict_get_variable (dict, x);
- PsppireAxis *haxis;
+ PsppireAxisHetero *haxis;
g_object_get (de->data_sheet[i], "horizontal-axis", &haxis, NULL);
- psppire_axis_insert (haxis, WIDTH_OF_M * var_get_display_width (var), x);
+ psppire_axis_hetero_insert (haxis, WIDTH_OF_M * var_get_display_width (var), x);
}
}
static void
-delete_variable_callback (PsppireDict *dict, gint posn, gint x UNUSED, gint y UNUSED, gpointer data)
+delete_variable_callback (PsppireDict *dict, gint posn,
+ gint x UNUSED, gint y UNUSED, gpointer data)
{
gint i;
PsppireDataEditor *de = PSPPIRE_DATA_EDITOR (data);
+ PsppireAxisHetero *var_vaxis;
+ g_object_get (de->var_sheet, "vertical-axis", &var_vaxis, NULL);
+
+ psppire_axis_hetero_remove (var_vaxis, posn);
+
for (i = 0 ; i < 4 ; ++i)
{
- PsppireAxis *haxis;
+ PsppireAxisHetero *haxis;
g_object_get (de->data_sheet[i], "horizontal-axis", &haxis, NULL);
- psppire_axis_remove (haxis, posn);
+ psppire_axis_hetero_remove (haxis, posn);
}
}
for (i = 0 ; i < 4 ; ++i)
{
const struct variable *var = psppire_dict_get_variable (dict, posn);
- PsppireAxis *haxis;
+ PsppireAxisHetero *haxis;
g_object_get (de->data_sheet[i], "horizontal-axis", &haxis, NULL);
- psppire_axis_resize_unit (haxis, WIDTH_OF_M * var_get_display_width (var), posn);
+ psppire_axis_hetero_resize_unit (haxis,
+ WIDTH_OF_M *
+ var_get_display_width (var), posn);
}
}
for (i = 0 ; i < 4 ; ++i )
g_object_set (de->data_sheet[i],
- "row-geometry", de->data_store,
"model", de->data_store,
NULL);
g_signal_connect (de->data_store->dict, "variable-inserted", G_CALLBACK (insert_variable_callback), de);
g_signal_connect (de->data_store->dict, "variable-deleted", G_CALLBACK (delete_variable_callback), de);
g_signal_connect (de->data_store->dict, "variable-display-width-changed", G_CALLBACK (rewidth_variable_callback), de);
+
+ g_signal_connect (de->data_store, "backend-changed", G_CALLBACK (new_data_callback), de);
break;
case PROP_VAR_STORE:
if ( de->var_store) g_object_unref (de->var_store);
g_object_ref (de->var_store);
g_object_set (de->var_sheet,
- "row-geometry", de->var_store,
"model", de->var_store,
NULL);
break;
init_sheet (PsppireDataEditor *de, int i,
GtkAdjustment *hadj, GtkAdjustment *vadj)
{
- PsppireAxis *haxis = psppire_axis_new ();
+ PsppireAxisHetero *haxis = psppire_axis_hetero_new ();
+ PsppireAxisUniform *vaxis = psppire_axis_uniform_new ();
de->sheet_bin[i] = gtk_scrolled_window_new (hadj, vadj);
de->data_sheet[i] = gtk_sheet_new (NULL, NULL, NULL);
"shadow-type", GTK_SHADOW_ETCHED_IN,
NULL);
+ g_object_set (haxis, "default-size", 75, NULL);
+ g_object_set (vaxis, "default-size", 25, NULL);
+
g_object_set (de->data_sheet[i],
"horizontal-axis", haxis,
+ "vertical-axis", vaxis,
NULL);
gtk_container_add (GTK_CONTAINER (de->sheet_bin[i]), de->data_sheet[i]);
#include <data/variable.h>
#include <gtksheet/gsheetmodel.h>
-#include <gtksheet/gsheet-row-iface.h>
#include <pango/pango-context.h>
static void psppire_data_store_init (PsppireDataStore *data_store);
static void psppire_data_store_class_init (PsppireDataStoreClass *class);
static void psppire_data_store_sheet_model_init (GSheetModelIface *iface);
-static void psppire_data_store_sheet_row_init (GSheetRowIface *iface);
static void psppire_data_store_finalize (GObject *object);
static void psppire_data_store_dispose (GObject *object);
glong row, glong column);
-#define MIN_COLUMNS 10
-#define TRAILING_ROWS 10
-
static GObjectClass *parent_class = NULL;
enum {FONT_CHANGED,
+ BACKEND_CHANGED,
n_SIGNALS};
static guint signals [n_SIGNALS];
NULL
};
- static const GInterfaceInfo sheet_row_info =
- {
- (GInterfaceInitFunc) psppire_data_store_sheet_row_init,
- NULL,
- NULL
- };
-
data_store_type = g_type_register_static (G_TYPE_OBJECT, "PsppireDataStore",
&data_store_info, 0);
G_TYPE_SHEET_MODEL,
&sheet_model_info);
- g_type_add_interface_static (data_store_type,
- G_TYPE_SHEET_ROW,
- &sheet_row_info);
}
return data_store_type;
g_cclosure_marshal_VOID__VOID,
G_TYPE_NONE,
0);
+
+
+ signals [BACKEND_CHANGED] =
+ g_signal_new ("backend-changed",
+ G_TYPE_FROM_CLASS (class),
+ G_SIGNAL_RUN_FIRST,
+ 0,
+ NULL, NULL,
+ g_cclosure_marshal_VOID__VOID,
+ G_TYPE_NONE,
+ 0);
}
static gboolean get_column_sensitivity (const GSheetModel *model, gint col);
static GtkJustification get_column_justification (const GSheetModel *model, gint col);
+static gchar * get_row_button_label (const GSheetModel *model, gint row);
+static gboolean get_row_sensitivity (const GSheetModel *model, gint row);
+
static void
psppire_data_store_sheet_model_init (GSheetModelIface *iface)
iface->get_column_title = get_column_button_label;
iface->get_column_sensitivity = get_column_sensitivity;
iface->get_column_justification = get_column_justification;
+
+ iface->get_row_title = get_row_button_label;
+ iface->get_row_sensitivity = get_row_sensitivity;
}
static void
static void
insert_case_callback (GtkWidget *w, casenumber casenum, gpointer data)
{
- PsppireDataStore *store ;
+ PsppireDataStore *store = PSPPIRE_DATA_STORE (data);
g_return_if_fail (data);
- store = PSPPIRE_DATA_STORE (data);
+ g_print ("%s\n", __FUNCTION__);
g_sheet_model_range_changed (G_SHEET_MODEL (store),
casenum, -1,
{
gint i;
if ( ds->case_file) g_object_unref (ds->case_file);
-
-
ds->case_file = cf;
g_sheet_model_range_changed (G_SHEET_MODEL (ds),
g_signal_connect (ds->case_file, "case-changed",
G_CALLBACK (changed_case_callback),
ds);
+
+ g_signal_emit (ds, signals[BACKEND_CHANGED], 0);
}
/* Column related funcs */
-#if AXIS_TRANSITION
-static glong
-geometry_get_column_count (const GSheetColumn *geom)
-{
- PsppireDataStore *ds = PSPPIRE_DATA_STORE (geom);
-
- return MAX (MIN_COLUMNS, psppire_dict_get_var_cnt (ds->dict));
-}
-
-
-
-static gint
-geometry_get_width (const GSheetColumn *geom, glong unit)
-{
- const struct variable *pv ;
- PsppireDataStore *ds = PSPPIRE_DATA_STORE (geom);
-
- if ( unit >= psppire_dict_get_var_cnt (ds->dict) )
- return ds->width_of_m * 8 ;
-
- pv = psppire_dict_get_variable (ds->dict, unit);
-
- if ( pv == NULL )
- return ds->width_of_m * 8 ;
-
- return ds->width_of_m * var_get_display_width (pv);
-}
-
-static void
-geometry_set_width (GSheetColumn *geom, glong unit, gint width)
-{
- PsppireDataStore *ds = PSPPIRE_DATA_STORE (geom);
-
- struct variable *v = psppire_dict_get_variable (ds->dict, unit);
-
- g_return_if_fail (v);
-
- var_set_display_width (v, width / ds->width_of_m );
-}
-
-#endif
-
static const gchar null_var_name[]=N_("var");
+\f
/* Row related funcs */
-static glong
-geometry_get_row_count (const GSheetRow *geom)
-{
- PsppireDataStore *ds = PSPPIRE_DATA_STORE (geom);
-
- return TRAILING_ROWS + psppire_case_file_get_case_count (ds->case_file);
-}
-
-#define ROW_HEIGHT 25
-
-static gint
-geometry_get_height (const GSheetRow *geom, glong unit)
-{
- return ROW_HEIGHT;
-}
-
-static guint
-geometry_get_top_ypixel (const GSheetRow *geo, glong row)
-{
- return row * ROW_HEIGHT;
-}
-
-static glong
-geometry_pixel_to_row (const GSheetRow *geo, guint pixel)
-{
- glong row = pixel / ROW_HEIGHT;
-
- if (row >= geometry_get_row_count (geo))
- row = geometry_get_row_count (geo) - 1;
-
- return row;
-}
-
-
-static gboolean
-geometry_get_row_sensitivity (const GSheetRow *geom, glong unit)
-{
- PsppireDataStore *ds = PSPPIRE_DATA_STORE (geom);
-
-
- return (unit < psppire_case_file_get_case_count (ds->case_file));
-}
-
static gchar *
-geometry_get_row_button_label (const GSheetRow *geom, glong unit)
+get_row_button_label (const GSheetModel *model, gint unit)
{
gchar *text;
gchar *s;
- PsppireDataStore *ds = PSPPIRE_DATA_STORE (geom);
-
- if ( unit >
- TRAILING_ROWS + psppire_case_file_get_case_count (ds->case_file))
- return 0;
+ PsppireDataStore *ds = PSPPIRE_DATA_STORE (model);
- s = g_strdup_printf (_("%ld"), unit + FIRST_CASE_NUMBER);
+ s = g_strdup_printf (_("%d"), unit + 1);
text = pspp_locale_to_utf8 (s, -1, 0);
return text;
}
-static void
-psppire_data_store_sheet_row_init (GSheetRowIface *iface)
+
+static gboolean
+get_row_sensitivity (const GSheetModel *model, gint unit)
{
- iface->get_row_count = geometry_get_row_count;
+ PsppireDataStore *ds = PSPPIRE_DATA_STORE (model);
- iface->get_height = geometry_get_height;
- iface->set_height = 0;
- iface->get_sensitivity = geometry_get_row_sensitivity;
- iface->top_ypixel = geometry_get_top_ypixel;
- iface->pixel_to_row = geometry_pixel_to_row;
- iface->get_button_label = geometry_get_row_button_label;
+ return (unit < psppire_case_file_get_case_count (ds->case_file));
}
#include <config.h>
#include "psppire-var-sheet.h"
+#include <gtksheet/psppire-axis-hetero.h>
#include <glade/glade.h>
#include "helper.h"
}
-
-
static void
psppire_var_sheet_init (PsppireVarSheet *vs)
{
- // gint i;
GladeXML *xml = XML_NEW ("data-editor.glade");
vs->val_labs_dialog = val_labs_dialog_create (xml);
vs->dispose_has_run = FALSE;
vs->may_create_vars = TRUE;
-#if 0
- for (i = 0 ; i < PSPPIRE_VAR_STORE_n_COLS ; ++i )
- {
- g_sheet_hetero_column_set_width (G_SHEET_HETERO_COLUMN (geo), i,
- column_def[i].width);
- }
-#endif
-
g_signal_connect (vs, "activate",
G_CALLBACK (var_sheet_change_active_cell),
NULL);
psppire_var_sheet_new (void)
{
gint i;
- PsppireAxis *a = psppire_axis_new ();
+ PsppireAxisHetero *ha = psppire_axis_hetero_new ();
+ PsppireAxisHetero *va = psppire_axis_hetero_new ();
+
GtkWidget *w = g_object_new (psppire_var_sheet_get_type (), NULL);
for (i = 0 ; i < 10 ; ++i)
- psppire_axis_append (a, column_def[i].width);
+ psppire_axis_hetero_append (ha, column_def[i].width);
+
+
+ g_object_set (va,
+ "default-size", 25,
+ NULL);
+
+ g_object_set (ha, "minimum-extent", 0,
+ NULL);
g_object_set (w,
- "horizontal-axis", a,
+ "horizontal-axis", ha,
+ "vertical-axis", va,
NULL);
return w;
#include <gtksheet/gsheetmodel.h>
#include "psppire-var-store.h"
-#include <gtksheet/gsheet-row-iface.h>
#include "helper.h"
#include <data/dictionary.h>
static gchar *text_for_column (const struct variable *pv, gint c, GError **err);
-static void psppire_var_store_sheet_row_init (GSheetRowIface *iface);
-
-
-
static GObjectClass *parent_class = NULL;
GType
NULL
};
- static const GInterfaceInfo sheet_row_info =
- {
- (GInterfaceInitFunc) psppire_var_store_sheet_row_init,
- NULL,
- NULL
- };
-
var_store_type = g_type_register_static (G_TYPE_OBJECT, "PsppireVarStore", &var_store_info, 0);
g_type_add_interface_static (var_store_type,
G_TYPE_SHEET_MODEL,
&sheet_model_info);
-
- g_type_add_interface_static (var_store_type,
- G_TYPE_SHEET_ROW,
- &sheet_row_info);
-
-
}
return var_store_type;
return store->font_desc;
}
-
static gchar *get_column_title (const GSheetModel *model, gint col);
+static gchar *get_row_title (const GSheetModel *model, gint row);
+static gboolean get_row_sensitivity (const GSheetModel *model, gint row);
static void
psppire_var_store_sheet_model_init (GSheetModelIface *iface)
iface->get_justification = NULL;
iface->get_column_title = get_column_title;
+
+ iface->get_row_title = get_row_title;
+ iface->get_row_sensitivity = get_row_sensitivity;
}
/**
return PSPPIRE_VAR_STORE_n_COLS ;
}
+\f
/* Row related funcs */
-static glong
-geometry_get_row_count (const GSheetRow *geom)
-{
- gint rows = 0;
- PsppireVarStore *vs = PSPPIRE_VAR_STORE (geom);
-
- if (vs->dict)
- rows = psppire_dict_get_var_cnt (vs->dict);
-
- return rows + vs->trailing_rows;
-}
-
-
-static gint
-geometry_get_height (const GSheetRow *geom, glong row)
-{
- return 25;
-}
-
static gboolean
-geometry_is_sensitive (const GSheetRow *geom, glong row)
+get_row_sensitivity (const GSheetModel *model, gint row)
{
- PsppireVarStore *vs = PSPPIRE_VAR_STORE (geom);
+ PsppireVarStore *vs = PSPPIRE_VAR_STORE (model);
if ( ! vs->dict)
return FALSE;
return row < psppire_dict_get_var_cnt (vs->dict);
}
-static gchar *
-geometry_get_button_label (const GSheetRow *geom, glong unit)
-{
- gchar *label = g_strdup_printf (_("%ld"), unit + 1);
- return label;
-}
-
-static void
-psppire_var_store_sheet_row_init (GSheetRowIface *iface)
+static gchar *
+get_row_title (const GSheetModel *model, gint unit)
{
- iface->get_row_count = geometry_get_row_count;
- iface->get_height = geometry_get_height;
- iface->set_height = NULL;
- iface->get_sensitivity = geometry_is_sensitive;
-
- iface->get_button_label = geometry_get_button_label;
+ return g_strdup_printf (_("%d"), unit + 1);
}