COMMENT This program is useful for testing the behaviour of the Data and Variable Sheets.
input program.
- vector var(500 F8.3).
+vector var(500 F8.3).
loop #c = 1 to 1000.
loop #v = 1 to 500.
compute var(#v) = #v + #c / 1000.
end file.
end input program.
+variable label var1 'First variable' var2 'Second variable' var3 'Third variable'.
+
save outfile='grid.sav'.
execute.
lib_gtksheet_libgtksheet_a_SOURCES = \
- lib/gtksheet/gsheet-column-iface.c \
- lib/gtksheet/gsheet-column-iface.h \
- lib/gtksheet/gsheet-hetero-column.c \
- lib/gtksheet/gsheet-hetero-column.h \
lib/gtksheet/gsheetmodel.c \
lib/gtksheet/gsheetmodel.h \
lib/gtksheet/gsheet-row-iface.c \
lib/gtksheet/gsheet-row-iface.h \
- lib/gtksheet/gsheet-uniform-column.c \
- lib/gtksheet/gsheet-uniform-column.h \
lib/gtksheet/gsheet-uniform-row.c \
lib/gtksheet/gsheet-uniform-row.h \
lib/gtksheet/gtkextrafeatures.h \
lib/gtksheet/gtksheet.c \
lib/gtksheet/gtksheet.h \
lib/gtksheet/gtkxpaned.c \
- lib/gtksheet/gtkxpaned.h
+ lib/gtksheet/gtkxpaned.h \
+ lib/gtksheet/psppire-axis.c \
+ lib/gtksheet/psppire-axis.h
+
EXTRA_DIST += lib/gtksheet/OChangeLog \
lib/gtksheet/README
+++ /dev/null
-/* GSheetColumn --- an abstract model of the column 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-column-iface.h"
-#include "gtkextra-marshal.h"
-#include "gtkextra-sheet.h"
-
-enum {
- COLUMNS_CHANGED,
- LAST_SIGNAL
-};
-
-static guint sheet_column_signals[LAST_SIGNAL];
-
-static void g_sheet_column_base_init (gpointer g_class);
-
-GType
-g_sheet_column_get_type (void)
-{
- static GType sheet_column_type = 0;
-
- if (! sheet_column_type)
- {
- static const GTypeInfo sheet_column_info =
-
- {
- sizeof (GSheetColumnIface), /* class_size */
- g_sheet_column_base_init, /* base_init */
- NULL, /* base_finalize */
- NULL,
- NULL, /* class_finalize */
- NULL, /* class_data */
- 0,
- 0, /* n_preallocs */
- NULL
- };
-
- sheet_column_type =
- g_type_register_static (G_TYPE_INTERFACE, "GSheetColumn",
- &sheet_column_info, 0);
-
- g_assert (sheet_column_type);
-
- g_type_interface_add_prerequisite (sheet_column_type, G_TYPE_OBJECT);
- }
-
- return sheet_column_type;
-}
-
-
-static void
-g_sheet_column_base_init (gpointer g_class)
-{
- static gboolean initialized = FALSE;
-
- if (! initialized)
- {
-
- sheet_column_signals[COLUMNS_CHANGED] =
- g_signal_new ("columns_changed",
- G_TYPE_SHEET_COLUMN,
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (GSheetColumnIface, columns_changed),
- NULL, NULL,
- gtkextra_VOID__INT_INT,
- G_TYPE_NONE, 2,
- G_TYPE_INT,
- G_TYPE_INT);
-
-
- initialized = TRUE;
- }
-}
-
-
-void
-g_sheet_column_set_width (GSheetColumn *column, glong col, gint size)
-{
- g_return_if_fail (G_IS_SHEET_COLUMN (column));
-
- if ((G_SHEET_COLUMN_GET_IFACE (column)->set_width) )
- (G_SHEET_COLUMN_GET_IFACE (column)->set_width) (column, col, size);
-}
-
-
-gint
-g_sheet_column_get_width (const GSheetColumn *column, glong col)
-{
- g_return_val_if_fail (G_IS_SHEET_COLUMN (column), -1);
-
- g_assert (G_SHEET_COLUMN_GET_IFACE (column)->get_width);
-
- return (G_SHEET_COLUMN_GET_IFACE (column)->get_width) (column, col);
-}
-
-
-
-gboolean
-g_sheet_column_get_sensitivity (const GSheetColumn *column,
- glong col)
-{
- g_return_val_if_fail (G_IS_SHEET_COLUMN (column), FALSE);
-
- g_assert (G_SHEET_COLUMN_GET_IFACE (column)->get_sensitivity);
-
- return (G_SHEET_COLUMN_GET_IFACE (column)->get_sensitivity) (column,
- col);
-
-}
-
-
-GtkSheetButton *
-g_sheet_column_get_button (const GSheetColumn *column,
- glong col)
-{
- GtkSheetButton *button = gtk_sheet_button_new ();
-
- GSheetColumnIface *iface = G_SHEET_COLUMN_GET_IFACE (column);
-
- g_return_val_if_fail (G_IS_SHEET_COLUMN (column), FALSE);
-
- if ( iface->get_button_label)
- button->label = iface->get_button_label (column, col);
-
- return button;
-}
-
-GtkJustification
-g_sheet_column_get_justification (const GSheetColumn *column,
- glong col)
-{
- g_return_val_if_fail (G_IS_SHEET_COLUMN (column), FALSE);
-
- g_assert (G_SHEET_COLUMN_GET_IFACE (column)->get_justification);
-
- return (G_SHEET_COLUMN_GET_IFACE (column)->get_justification) (column, col);
-}
-
-gchar *
-g_sheet_column_get_subtitle (const GSheetColumn *column, glong col)
-{
- g_return_val_if_fail (G_IS_SHEET_COLUMN (column), NULL);
-
- if ( ! G_SHEET_COLUMN_GET_IFACE (column)->get_subtitle)
- return NULL;
-
- return (G_SHEET_COLUMN_GET_IFACE (column)->get_subtitle) (column, col);
-}
-
-
-
-glong
-g_sheet_column_get_column_count (const GSheetColumn *geo)
-{
- g_return_val_if_fail (G_IS_SHEET_COLUMN (geo), -1);
-
- g_assert ( G_SHEET_COLUMN_GET_IFACE (geo)->get_column_count);
-
- return (G_SHEET_COLUMN_GET_IFACE (geo)->get_column_count) (geo);
-}
-
-gint
-g_sheet_column_start_pixel (const GSheetColumn *geo, glong col)
-{
- gint i;
- gint start_pixel = 0;
-
- g_return_val_if_fail (G_IS_SHEET_COLUMN (geo), -1);
- g_return_val_if_fail (col <= g_sheet_column_get_column_count (geo), -1);
-
- for (i = 0; i < col; ++i)
- {
- start_pixel += g_sheet_column_get_width (geo, i);
- }
-
- return start_pixel;
-}
-
-
-
-void
-g_sheet_column_columns_changed (GSheetColumn *geo,
- glong first, glong n_columns)
-{
- g_return_if_fail (G_IS_SHEET_COLUMN (geo));
-
- g_signal_emit (geo, sheet_column_signals[COLUMNS_CHANGED], 0,
- first, n_columns);
-}
-
+++ /dev/null
-/* GSheetColumn --- an abstract model of the column 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 __GSHEET_COLUMN_IFACE_H
-#define __GSHEET_COLUMN_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_COLUMN (g_sheet_column_get_type ())
-#define G_SHEET_COLUMN(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), G_TYPE_SHEET_COLUMN, GSheetColumn))
-#define G_IS_SHEET_COLUMN(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), G_TYPE_SHEET_COLUMN))
-#define G_SHEET_COLUMN_GET_IFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), G_TYPE_SHEET_COLUMN, GSheetColumnIface))
-
-
-typedef struct _GSheetColumn GSheetColumn;
-typedef struct _GSheetColumnIface GSheetColumnIface;
-struct _GSheetColumnIface
-{
- GTypeInterface g_iface;
-
-
- /* Signals */
- void (* columns_changed) (GSheetColumn *geo,
- glong col, glong n_columns);
-
- /* Virtual Table */
- gint (* get_width) (const GSheetColumn *gcolumn, glong col);
- void (* set_width) (GSheetColumn *gcolumn, glong col, gint width);
-
- gboolean (* get_sensitivity) (const GSheetColumn *gcolumn, glong col);
- const GtkSheetButton * (* get_button) (const GSheetColumn *gcolumn, glong col);
- GtkJustification (* get_justification) (const GSheetColumn *gcolumn, glong col);
-
- glong (* get_column_count) (const GSheetColumn *geo);
-
-
- GtkStateType (*get_button_state)(const GSheetColumn *geo, glong col);
- gchar * (*get_button_label)(const GSheetColumn *geo, glong col);
- gchar * (*get_subtitle)(const GSheetColumn *geo, glong col);
-
- gboolean (*get_button_visibility)(const GSheetColumn *geo,
- glong col);
-
- GtkJustification * (*get_button_justification)(const GSheetColumn *geo,
- glong col);
-};
-
-
-GType g_sheet_column_get_type (void) G_GNUC_CONST;
-
-
-gint g_sheet_column_get_width (const GSheetColumn *gcolumn,
- glong col);
-
-
-void g_sheet_column_set_width (GSheetColumn *gcolumn,
- glong col, gint size);
-
-
-gboolean g_sheet_column_get_sensitivity (const GSheetColumn *gcolumn,
- glong col);
-
-
-GtkSheetButton *g_sheet_column_get_button (const GSheetColumn *gcolumn,
- glong col);
-
-gchar *g_sheet_column_get_subtitle (const GSheetColumn *, glong);
-
-GtkJustification g_sheet_column_get_justification (const GSheetColumn *gcolumn, glong col);
-
-
-glong g_sheet_column_get_column_count (const GSheetColumn *geo);
-
-gint g_sheet_column_start_pixel (const GSheetColumn *geo, glong col);
-
-void g_sheet_column_columns_changed (GSheetColumn *geo,
- glong first, glong n_columns);
-
-G_END_DECLS
-
-#endif /* __G_SHEET_COLUMN_IFACE_H__ */
+++ /dev/null
-/* gsheet-hetero-column.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-column-iface.h"
-#include "gsheet-hetero-column.h"
-#include <string.h>
-
-
-static void g_sheet_hetero_column_init (GSheetHeteroColumn *hg);
-static void g_sheet_hetero_column_class_init (GSheetHeteroColumnClass *class);
-static void g_sheet_hetero_column_finalize (GObject *object);
-
-static void g_sheet_column_init (GSheetColumnIface *iface);
-
-
-static GObjectClass *parent_class = NULL;
-
-GType
-g_sheet_hetero_column_get_type (void)
-{
- static GType hetero_column_type = 0;
-
- if (!hetero_column_type)
- {
- static const GTypeInfo hetero_column_info =
- {
- sizeof (GSheetHeteroColumnClass),
- NULL, /* base_init */
- NULL, /* base_finalize */
- (GClassInitFunc) g_sheet_hetero_column_class_init,
- NULL, /* class_finalize */
- NULL, /* class_data */
- sizeof (GSheetHeteroColumn),
- 0,
- (GInstanceInitFunc) g_sheet_hetero_column_init,
- };
-
- static const GInterfaceInfo column_info =
- {
- (GInterfaceInitFunc) g_sheet_column_init,
- NULL,
- NULL
- };
-
- hetero_column_type =
- g_type_register_static (G_TYPE_OBJECT, "g_sheet_hetero_column",
- &hetero_column_info, 0);
-
- g_type_add_interface_static (hetero_column_type,
- G_TYPE_SHEET_COLUMN,
- &column_info);
- }
-
- return hetero_column_type;
-}
-
-
-static GtkSheetButton default_button;
-
-
-
-/**
- * g_sheet_hetero_column_new:
- * @width: The size of columns in this hetero column
- *
- * Return value: a new #g_sheet_hetero_column
- **/
-GObject *
-g_sheet_hetero_column_new (gint default_width, gint n_columns)
-{
- gint i;
- GSheetHeteroColumn *hg;
- GObject *retval;
-
- retval = g_object_new (G_TYPE_SHEET_HETERO_COLUMN, NULL);
-
- hg = G_SHEET_HETERO_COLUMN (retval);
- hg->n_columns = n_columns;
- hg->default_width = default_width;
- hg->col = g_new0 (struct GSheetHeteroColumnUnit, n_columns);
-
- for (i = 0 ; i < hg->n_columns; ++i )
- {
- hg->col[i].button = default_button;
- }
-
- return retval;
-}
-
-static gint
-g_sheet_hetero_column_get_width (const GSheetColumn *geom, glong i)
-{
- GSheetHeteroColumn *hg = G_SHEET_HETERO_COLUMN (geom);
-
- g_return_val_if_fail (i < hg->n_columns, -1);
-
- return hg->col[i].width;
-}
-
-static gboolean
-g_sheet_hetero_column_get_sensitivity (const GSheetColumn *geom, glong u)
-{
- return TRUE;
-}
-
-
-static gchar *
-g_sheet_hetero_column_get_button_label (const GSheetColumn *geom, glong u)
-{
- GSheetHeteroColumn *hg = G_SHEET_HETERO_COLUMN (geom);
-
- return g_locale_to_utf8 (hg->col[u].button.label, -1, 0, 0, 0);
-}
-
-
-static GtkJustification
-g_sheet_hetero_column_get_justification (const GSheetColumn *geom, glong u)
-{
- return GTK_JUSTIFY_LEFT;
-}
-
-
-
-static glong
-g_sheet_hetero_column_get_column_count (const GSheetColumn *geom)
-{
- GSheetHeteroColumn *hg = G_SHEET_HETERO_COLUMN (geom);
-
- return hg->n_columns;
-}
-
-static void
-g_sheet_hetero_column_class_init (GSheetHeteroColumnClass *class)
-{
- GObjectClass *object_class;
-
- parent_class = g_type_class_peek_parent (class);
- object_class = (GObjectClass*) class;
-
- object_class->finalize = g_sheet_hetero_column_finalize;
-
- default_button.label=NULL;
- default_button.state=GTK_STATE_NORMAL;
- default_button.justification=GTK_JUSTIFY_CENTER;
- default_button.label_visible = TRUE;
-}
-
-
-static void
-g_sheet_hetero_column_init (GSheetHeteroColumn *o)
-{
-}
-
-static void
-g_sheet_hetero_column_finalize (GObject *object)
-{
- GSheetHeteroColumn *hg = G_SHEET_HETERO_COLUMN (object);
-
- g_free (hg->col);
-}
-
-static void
-hetero_column_set_width (GSheetColumn *geo, glong i, gint size)
-{
- GSheetHeteroColumn *hg = G_SHEET_HETERO_COLUMN (geo);
-
- g_return_if_fail (i < hg->n_columns);
-
- hg->col[i].width = size;
-}
-
-
-
-static void
-g_sheet_column_init (GSheetColumnIface *iface)
-{
- iface->get_width = g_sheet_hetero_column_get_width ;
- iface->set_width = hetero_column_set_width ;
- iface->get_sensitivity = g_sheet_hetero_column_get_sensitivity ;
- iface->get_justification = g_sheet_hetero_column_get_justification;
- iface->get_column_count = g_sheet_hetero_column_get_column_count;
-
- iface->get_button_label = g_sheet_hetero_column_get_button_label;
-}
-
-
-void
-g_sheet_hetero_column_set_button_label (GSheetHeteroColumn *geo,
- glong i, const gchar *label)
-{
- g_return_if_fail (i < geo->n_columns);
-
- g_free (geo->col[i].button.label);
- geo->col[i].button.label = g_malloc (strlen (label) + 1);
-
- g_stpcpy (geo->col[i].button.label, label);
-}
-
-
-
-
-void
-g_sheet_hetero_column_set_width (GSheetHeteroColumn *geo, glong i, gint size)
-{
- GSheetColumn *iface = G_SHEET_COLUMN (geo);
-
- hetero_column_set_width (iface, i, size);
-}
-
-
-
+++ /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_HETERO_COLUMN_H__
-#define __G_SHEET_HETERO_COLUMN_H__
-
-#include <glib-object.h>
-#include <glib.h>
-
-
-#ifdef __cplusplus
-extern "C" {
-#endif /* __cplusplus */
-
-
-#define G_TYPE_SHEET_HETERO_COLUMN (g_sheet_hetero_column_get_type ())
-
-#define G_SHEET_HETERO_COLUMN(obj) G_TYPE_CHECK_INSTANCE_CAST (obj, G_TYPE_SHEET_HETERO_COLUMN, GSheetHeteroColumn )
-#define G_SHEET_HETERO_COLUMN_CLASS(klass) G_TYPE_CHECK_CLASS_CAST (klass, g_sheet_hetero_column_get_type (), GSheetHeteroColumnClass)
-#define G_IS_SHEET_HETERO_COLUMN(obj) G_TYPE_CHECK_INSTANCE_TYPE (obj, G_TYPE_SHEET_HETERO_COLUMN)
-
-
- struct GSheetHeteroColumnUnit
- {
- GtkSheetButton button;
-
- gint width;
- gboolean is_sensitive;
- };
-
-
- struct _GSheetHeteroColumn{
- GObject parent;
-
- gint n_columns;
- gint default_width;
-
- struct GSheetHeteroColumnUnit *col;
-
- };
-
- struct _GSheetHeteroColumnClass
- {
- GObjectClass parent_class;
- };
-
-
-
-
- /* create a new column */
- GObject * g_sheet_hetero_column_new (gint default_width, gint n_columns);
-
- GType g_sheet_hetero_column_get_type (void);
-
-
- typedef struct _GSheetHeteroColumn GSheetHeteroColumn;
- typedef struct _GSheetHeteroColumnClass GSheetHeteroColumnClass;
-
-
- void g_sheet_hetero_column_set_button_label (GSheetHeteroColumn *geo,
- glong i, const gchar *label);
-
- void g_sheet_hetero_column_set_width (GSheetHeteroColumn *geo,
- glong i, gint size);
-
-#ifdef __cplusplus
-}
-#endif /* __cplusplus */
-
-#endif /* __G_SHEET_HETERO_COLUMN_H__ */
-
-
+++ /dev/null
-/* gsheet-uniform-column.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-column-iface.h"
-#include "gsheet-uniform-column.h"
-
-
-static void g_sheet_uniform_column_init (GSheetUniformColumn *ug);
-static void g_sheet_uniform_column_class_init (GSheetUniformColumnClass *class);
-static void g_sheet_uniform_column_finalize (GObject *object);
-
-static void g_sheet_column_init (GSheetColumnIface *iface);
-
-
-static GObjectClass *parent_class = NULL;
-
-GType
-g_sheet_uniform_column_get_type (void)
-{
- static GType uniform_column_type = 0;
-
- if (!uniform_column_type)
- {
- static const GTypeInfo uniform_column_info =
- {
- sizeof (GSheetUniformColumnClass),
- NULL, /* base_init */
- NULL, /* base_finalize */
- (GClassInitFunc) g_sheet_uniform_column_class_init,
- NULL, /* class_finalize */
- NULL, /* class_data */
- sizeof (GSheetUniformColumn),
- 0,
- (GInstanceInitFunc) g_sheet_uniform_column_init,
- };
-
- static const GInterfaceInfo column_info =
- {
- (GInterfaceInitFunc) g_sheet_column_init,
- NULL,
- NULL
- };
-
- uniform_column_type =
- g_type_register_static (G_TYPE_OBJECT, "g_sheet_uniform_column",
- &uniform_column_info, 0);
-
- g_type_add_interface_static (uniform_column_type,
- G_TYPE_SHEET_COLUMN,
- &column_info);
- }
-
- return uniform_column_type;
-}
-
-
-/**
- * g_sheet_uniform_column_new:
- * @width: The size of columns in this uniform column
- *
- * Return value: a new #g_sheet_uniform_column
- **/
-GObject *
-g_sheet_uniform_column_new (gint width, gint n_columns)
-{
- GSheetUniformColumn *ug;
- GObject *retval;
-
- retval = g_object_new (G_TYPE_SHEET_UNIFORM_COLUMN, NULL);
-
- ug = G_SHEET_UNIFORM_COLUMN(retval);
- ug->n_columns = n_columns;
- ug->width = width;
- ug->is_sensitive = FALSE;
-
- return retval;
-}
-
-static gint
-g_sheet_uniform_column_get_width (const GSheetColumn *geom, glong u)
-{
- GSheetUniformColumn *ug = G_SHEET_UNIFORM_COLUMN (geom);
-
- return ug->width;
-}
-
-static gboolean
-g_sheet_uniform_column_get_sensitivity (const GSheetColumn *geom, glong u)
-{
- GSheetUniformColumn *ug = G_SHEET_UNIFORM_COLUMN (geom);
-
- return ug->is_sensitive;
-}
-
-
-static gchar *
-g_sheet_uniform_column_get_button_label (const GSheetColumn *geom, glong u)
-{
- gchar *label = g_strdup_printf ("%ld", u);
-
- return label;
-}
-
-
-static GtkJustification
-g_sheet_uniform_column_get_justification (const GSheetColumn *geom, glong u)
-{
- return GTK_JUSTIFY_FILL;
-}
-
-
-
-static glong
-g_sheet_uniform_column_get_column_count (const GSheetColumn *geom)
-{
- GSheetUniformColumn *ug = G_SHEET_UNIFORM_COLUMN (geom);
-
- return ug->n_columns;
-}
-
-static void
-g_sheet_uniform_column_class_init (GSheetUniformColumnClass *class)
-{
- GObjectClass *object_class;
-
- parent_class = g_type_class_peek_parent (class);
- object_class = (GObjectClass*) class;
-
- object_class->finalize = g_sheet_uniform_column_finalize;
-
-}
-
-
-static void
-g_sheet_uniform_column_init (GSheetUniformColumn *o)
-{
-}
-
-static void
-g_sheet_uniform_column_finalize (GObject *object)
-{
-}
-
-
-static void
-g_sheet_column_init (GSheetColumnIface *iface)
-{
- iface->get_width = g_sheet_uniform_column_get_width ;
- iface->get_sensitivity = g_sheet_uniform_column_get_sensitivity ;
- iface->get_justification = g_sheet_uniform_column_get_justification;
- iface->get_column_count = g_sheet_uniform_column_get_column_count;
- iface->get_button_label = g_sheet_uniform_column_get_button_label;
-}
-
+++ /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_COLUMN_H__
-#define __G_SHEET_UNIFORM_COLUMN_H__
-
-
-#include <glib-object.h>
-#include <glib.h>
-
-
-#ifdef __cplusplus
-extern "C" {
-#endif /* __cplusplus */
-
-
-#define G_TYPE_SHEET_UNIFORM_COLUMN (g_sheet_uniform_column_get_type ())
-
-#define G_SHEET_UNIFORM_COLUMN(obj) G_TYPE_CHECK_INSTANCE_CAST (obj, G_TYPE_SHEET_UNIFORM_COLUMN, GSheetUniformColumn )
-#define G_SHEET_UNIFORM_COLUMN_CLASS(klass) G_TYPE_CHECK_CLASS_CAST (klass, g_sheet_uniform_column_get_type (), GSheetUniformColumnClass)
-#define G_IS_SHEET_UNIFORM_COLUMN(obj) G_TYPE_CHECK_INSTANCE_TYPE (obj, G_TYPE_SHEET_UNIFORM_COLUMN)
-
-
- struct _GSheetUniformColumn{
- GObject parent;
-
- gint n_columns;
- gint width;
- gboolean is_sensitive;
- };
-
- struct _GSheetUniformColumnClass
- {
- GObjectClass parent_class;
- };
-
- /* create a new column */
- GObject * g_sheet_uniform_column_new (gint width, gint n_columns);
-
- GType g_sheet_uniform_column_get_type (void);
-
-
- typedef struct _GSheetUniformColumn GSheetUniformColumn;
- typedef struct _GSheetUniformColumnClass GSheetUniformColumnClass;
-
-#ifdef __cplusplus
-}
-#endif /* __cplusplus */
-
-#endif /* __G_SHEET_UNIFORM_COLUMN_H__ */
-
-
return G_SHEET_MODEL_GET_IFACE (model)->get_row_count (model);
}
+
+\f
+
+/* New functions since AXIS_TRANSITION */
+gboolean
+g_sheet_model_get_column_sensitivity (const GSheetModel *model, gint col)
+{
+ if ( NULL == G_SHEET_MODEL_GET_IFACE (model)->get_column_sensitivity)
+ return TRUE;
+
+ return G_SHEET_MODEL_GET_IFACE (model)->get_column_sensitivity (model, col);
+}
+
+
+gchar *
+g_sheet_model_get_column_subtitle (const GSheetModel *model,
+ gint col)
+{
+ g_return_val_if_fail (G_IS_SHEET_MODEL (model), NULL);
+
+ if ( NULL == G_SHEET_MODEL_GET_IFACE (model)->get_column_subtitle)
+ return NULL;
+
+ return G_SHEET_MODEL_GET_IFACE (model)->get_column_subtitle (model, col);
+}
+
+
+GtkSheetButton *
+g_sheet_model_get_column_button (const GSheetModel *model,
+ gint col)
+{
+ 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_column_title)
+ button->label = G_SHEET_MODEL_GET_IFACE (model)->get_column_title (model, col);
+
+ return button;
+}
+
+GtkJustification
+g_sheet_model_get_column_justification (const GSheetModel *model,
+ gint col)
+{
+ if ( G_SHEET_MODEL_GET_IFACE (model)->get_column_justification)
+ return G_SHEET_MODEL_GET_IFACE (model)->get_column_justification (model, col);
+
+ return GTK_JUSTIFY_LEFT;
+}
+
#include <glib-object.h>
#include <gdk/gdk.h>
#include <gtk/gtk.h>
-
+#include "gtkextra-sheet.h"
G_BEGIN_DECLS
struct _GtkSheetRange
{
- glong row0,col0; /* upper-left cell */
- glong rowi,coli; /* lower-right cell */
+ glong row0, col0; /* upper-left cell */
+ glong rowi, coli; /* lower-right cell */
};
struct _GtkSheetCellBorder
+
+
/* Virtual Table */
gchar * (* get_string) (const GSheetModel *sheet_model,
glong row, glong column);
+
+ /* 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);
+ GtkJustification (*get_column_justification) (const GSheetModel *mode, gint col);
+ const GtkSheetButton * (* get_button) (const GSheetModel *model, gint col);
+
glong (*get_column_count) (const GSheetModel *model);
- glong (*get_row_count) (const GSheetModel *model);
+ /* row related metadata */
+ glong (*get_row_count) (const GSheetModel *model);
};
gint g_sheet_model_get_row_count (const GSheetModel *sheet_model);
+\f
+
+gboolean g_sheet_model_get_column_sensitivity (const GSheetModel *model,
+ gint col);
+
+gchar * g_sheet_model_get_column_subtitle (const GSheetModel *model,
+ gint col);
+
+GtkSheetButton * g_sheet_model_get_column_button (const GSheetModel *, gint);
+
+GtkJustification g_sheet_model_get_column_justification (const GSheetModel *,
+ gint);
+
+
G_END_DECLS
#endif /* __G_SHEET_MODEL_H__ */
glong row = max_visible_row (sheet);
if ( g_sheet_row_start_pixel (sheet->row_geometry, row)
- +
+ +
g_sheet_row_get_height (sheet->row_geometry, row)
> sheet->vadjustment->value)
row--;
}
-/* returns the column index from a x pixel location */
+/* returns the column index from a pixel location */
static inline gint
-column_from_xpixel (const GtkSheet *sheet, gint x)
+column_from_xpixel (const GtkSheet *sheet, gint pixel)
{
- gint i;
- gint cx = 0;
-
- if (x < 0) return -1;
- for (i = 0;
- i < g_sheet_column_get_column_count (sheet->column_geometry); i++)
- {
- if (x >= cx &&
- x <= (cx + g_sheet_column_get_width (sheet->column_geometry, i)))
- return i;
-
- cx += g_sheet_column_get_width (sheet->column_geometry, i);
- }
-
- /* no match */
- return g_sheet_column_get_column_count (sheet->column_geometry) - 1;
+ return psppire_axis_get_unit_at_pixel (sheet->haxis, pixel);
}
{
glong col = min_visible_column (sheet);
- if ( g_sheet_column_start_pixel (sheet->column_geometry, col) < sheet->hadjustment->value)
+ if ( psppire_axis_pixel_start (sheet->haxis, col) < sheet->hadjustment->value)
col++;
return col;
{
glong col = max_visible_column (sheet);
- if ( g_sheet_column_start_pixel (sheet->column_geometry, col)
+ if ( psppire_axis_pixel_start (sheet->haxis, col)
+
- g_sheet_column_get_width (sheet->column_geometry, col)
+ psppire_axis_unit_size (sheet->haxis, col)
> sheet->hadjustment->value)
col--;
*drag_column = column_from_xpixel (sheet, x);
*drag_row = yyy_row_ypixel_to_row (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);
if (y >= ydrag - DRAG_WIDTH / 2 && y <= ydrag + 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)
{
- 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 = g_sheet_row_start_pixel (sheet->row_geometry, 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);
{
g_return_val_if_fail (range, FALSE);
- r->x = g_sheet_column_start_pixel (sheet->column_geometry, range->col0);
+ r->x = psppire_axis_pixel_start (sheet->haxis, range->col0);
r->x -= round (sheet->hadjustment->value);
if ( sheet->row_titles_visible)
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) +
{
PROP_0,
PROP_ROW_GEO,
- PROP_COL_GEO,
+ PROP_HAXIS,
PROP_MODEL
};
}
static void
-gtk_sheet_set_column_geometry (GtkSheet *sheet, GSheetColumn *geo)
+gtk_sheet_set_horizontal_axis (GtkSheet *sheet, PsppireAxis *a)
{
- if ( sheet->column_geometry ) g_object_unref (sheet->column_geometry);
+ if ( sheet->haxis )
+ g_object_unref (sheet->haxis);
- sheet->column_geometry = geo;
+ sheet->haxis = a;
- if ( sheet->column_geometry ) g_object_ref (sheet->column_geometry);
+ if ( sheet->haxis )
+ g_object_ref (sheet->haxis);
}
case PROP_ROW_GEO:
gtk_sheet_set_row_geometry (sheet, g_value_get_pointer (value));
break;
- case PROP_COL_GEO:
- gtk_sheet_set_column_geometry (sheet, g_value_get_pointer (value));
- if ( sheet->column_geometry)
- g_signal_connect (sheet->column_geometry, "columns_changed",
- G_CALLBACK (column_titles_changed), sheet);
+ case PROP_HAXIS:
+ gtk_sheet_set_horizontal_axis (sheet, g_value_get_pointer (value));
break;
case PROP_MODEL:
gtk_sheet_set_model (sheet, g_value_get_pointer (value));
case PROP_ROW_GEO:
g_value_set_pointer (value, sheet->row_geometry);
break;
- case PROP_COL_GEO:
- g_value_set_pointer (value, sheet->column_geometry);
+ case PROP_HAXIS:
+ g_value_set_pointer (value, sheet->haxis);
break;
case PROP_MODEL:
g_value_set_pointer (value, sheet->model);
GObjectClass *object_class = G_OBJECT_CLASS (klass);
GParamSpec *row_geo_spec ;
- GParamSpec *col_geo_spec ;
+ GParamSpec *haxis_spec ;
GParamSpec *model_spec ;
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
"A pointer to the model of the row geometry",
G_PARAM_READABLE | G_PARAM_WRITABLE );
- col_geo_spec =
- g_param_spec_pointer ("column-geometry",
- "Column Geometry",
- "A pointer to the model of the column geometry",
+ haxis_spec =
+ g_param_spec_pointer ("horizontal-axis",
+ "Horizontal Axis",
+ "A pointer to the PsppireAxis object for the columns",
G_PARAM_READABLE | G_PARAM_WRITABLE );
model_spec =
row_geo_spec);
g_object_class_install_property (object_class,
- PROP_COL_GEO,
- col_geo_spec);
+ PROP_HAXIS,
+ haxis_spec);
g_object_class_install_property (object_class,
PROP_MODEL,
gtk_sheet_init (GtkSheet *sheet)
{
sheet->model = NULL;
- sheet->column_geometry = NULL;
+ sheet->haxis = NULL;
sheet->row_geometry = NULL;
sheet->flags = 0;
*/
range.col0 = first_column;
range.row0 = 0;
- range.coli = g_sheet_column_get_column_count (sheet->column_geometry) - 1;
+ range.coli = psppire_axis_unit_count (sheet->haxis) - 1;
range.rowi = g_sheet_row_get_row_count (sheet->row_geometry) - 1;
adjust_scrollbars (sheet);
range.row0 = first_row;
range.col0 = 0;
range.rowi = g_sheet_row_get_row_count (sheet->row_geometry) - 1;
- range.coli = g_sheet_column_get_column_count (sheet->column_geometry) - 1;
+ range.coli = psppire_axis_unit_count (sheet->haxis) - 1;
adjust_scrollbars (sheet);
* Returns: the new sheet widget
*/
GtkWidget *
-gtk_sheet_new (GSheetRow *vgeo, GSheetColumn *hgeo, GSheetModel *model)
+gtk_sheet_new (GSheetRow *vgeo, void *hgeo, GSheetModel *model)
{
GtkWidget *widget = g_object_new (GTK_TYPE_SHEET,
"row-geometry", vgeo,
- "column-geometry", hgeo,
"model", model,
NULL);
return widget;
if ( n_columns == -1 )
{
extremity = TRUE;
- n_columns = g_sheet_column_get_column_count (sheet->column_geometry) - 1 ;
+ n_columns = psppire_axis_unit_count (sheet->haxis) - 1 ;
}
if ( extremity)
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
g_return_if_fail (sheet != NULL);
g_return_if_fail (GTK_IS_SHEET (sheet));
- if (column >= g_sheet_column_get_column_count (sheet->column_geometry) || column < 0) return;
+ if (column >= psppire_axis_unit_count (sheet->haxis) || column < 0) return;
for (row = 0; row < g_sheet_row_get_row_count (sheet->row_geometry); row++)
{
dispose_string (sheet, text);
}
- if (text_width > g_sheet_column_get_width (sheet->column_geometry, column) )
+ if (text_width > psppire_axis_unit_size (sheet->haxis, column) )
{
gtk_sheet_set_column_width (sheet, column, text_width);
}
g_return_if_fail (col_align <= 1);
g_return_if_fail (col <
- g_sheet_column_get_column_count (sheet->column_geometry));
+ psppire_axis_unit_count (sheet->haxis));
g_return_if_fail (row <
g_sheet_row_get_row_count (sheet->row_geometry));
if (col >= 0)
{
- gint x = g_sheet_column_start_pixel (sheet->column_geometry, col);
+ gint x = psppire_axis_pixel_start (sheet->haxis, col);
gtk_adjustment_set_value (sheet->hadjustment, x - width * col_align);
}
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)
if (range.rowi < 0 || range.rowi >= g_sheet_row_get_row_count (sheet->row_geometry))
return FALSE;
- if (range.col0 < 0 || range.col0 >= g_sheet_column_get_column_count (sheet->column_geometry))
+ if (range.col0 < 0 || range.col0 >= psppire_axis_unit_count (sheet->haxis))
return FALSE;
- if (range.coli < 0 || range.coli >= g_sheet_column_get_column_count (sheet->column_geometry))
+ if (range.coli < 0 || range.coli >= psppire_axis_unit_count (sheet->haxis))
return FALSE;
if (range.rowi < min_visible_row (sheet))
if (sheet->model) g_object_unref (sheet->model);
if (sheet->row_geometry) g_object_unref (sheet->row_geometry);
- if (sheet->column_geometry) g_object_unref (sheet->column_geometry);
+ if (sheet->haxis) g_object_unref (sheet->haxis);
g_object_unref (sheet->entry_container);
sheet->entry_container = NULL;
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);
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)
+ if (col >= psppire_axis_unit_count (sheet->haxis)
|| row >= g_sheet_row_get_row_count (sheet->row_geometry))
return;
g_return_if_fail (sheet != NULL);
g_return_if_fail (GTK_IS_SHEET (sheet));
- if (column >= g_sheet_column_get_column_count (sheet->column_geometry) ||
+ if (column >= psppire_axis_unit_count (sheet->haxis) ||
row >= g_sheet_row_get_row_count (sheet->row_geometry)) return;
if (column < 0 || row < 0) return;
g_return_val_if_fail (sheet != NULL, NULL);
g_return_val_if_fail (GTK_IS_SHEET (sheet), NULL);
- if (col >= g_sheet_column_get_column_count (sheet->column_geometry) || row >= g_sheet_row_get_row_count (sheet->row_geometry))
+ if (col >= psppire_axis_unit_count (sheet->haxis) || row >= g_sheet_row_get_row_count (sheet->row_geometry))
return NULL;
if (col < 0 || row < 0) return NULL;
g_return_val_if_fail (sheet != NULL, 0);
g_return_val_if_fail (GTK_IS_SHEET (sheet), 0);
- if (col >= g_sheet_column_get_column_count (sheet->column_geometry) || row >= g_sheet_row_get_row_count (sheet->row_geometry)) return 0;
+ if (col >= psppire_axis_unit_count (sheet->haxis) || row >= g_sheet_row_get_row_count (sheet->row_geometry)) return 0;
if (col < 0 || row < 0) return 0;
state = sheet->state;
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 >= g_sheet_row_get_row_count (sheet->row_geometry) || column >= psppire_axis_unit_count (sheet->haxis))
return FALSE;
- area->x = (column == -1) ? 0 : g_sheet_column_start_pixel (sheet->column_geometry, column);
+ area->x = (column == -1) ? 0 : psppire_axis_pixel_start (sheet->haxis, column);
area->y = (row == -1) ? 0 : g_sheet_row_start_pixel (sheet->row_geometry, row);
area->width= (column == -1) ? sheet->row_title_area.width
- : g_sheet_column_get_width (sheet->column_geometry, column);
+ : psppire_axis_unit_size (sheet->haxis, column);
area->height= (row == -1) ? sheet->column_title_area.height
: g_sheet_row_get_height (sheet->row_geometry, row);
if (row >= g_sheet_row_get_row_count (sheet->row_geometry)
||
- col >= g_sheet_column_get_column_count (sheet->column_geometry))
+ col >= psppire_axis_unit_count (sheet->haxis))
return;
sheet->active_cell.row = row;
return;
if ( row > g_sheet_row_get_row_count (sheet->row_geometry)
- || col > g_sheet_column_get_column_count (sheet->column_geometry))
+ || col > psppire_axis_unit_count (sheet->haxis))
return;
if (sheet->state != GTK_SHEET_NORMAL)
if (mask1 != mask2)
{
- x = g_sheet_column_start_pixel (sheet->column_geometry, j);
+ x = psppire_axis_pixel_start (sheet->haxis, 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);
+ width = psppire_axis_pixel_start (sheet->haxis, j)- x+
+ psppire_axis_unit_size (sheet->haxis, j);
height = g_sheet_row_start_pixel (sheet->row_geometry, i) - y + g_sheet_row_get_height (sheet->row_geometry, i);
if (i == sheet->range.row0)
if (i != sheet->active_cell.row || j != sheet->active_cell.col)
{
- x = g_sheet_column_start_pixel (sheet->column_geometry, j);
+ x = psppire_axis_pixel_start (sheet->haxis, 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);
+ width = psppire_axis_pixel_start (sheet->haxis, j)- x+
+ psppire_axis_unit_size (sheet->haxis, j);
height = g_sheet_row_start_pixel (sheet->row_geometry, i) - y + g_sheet_row_get_height (sheet->row_geometry, i);
if (state == GTK_STATE_SELECTED && !selected)
{
- x = g_sheet_column_start_pixel (sheet->column_geometry, j);
+ x = psppire_axis_pixel_start (sheet->haxis, 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);
+ width = psppire_axis_pixel_start (sheet->haxis, j) - x + psppire_axis_unit_size (sheet->haxis, j);
height = g_sheet_row_start_pixel (sheet->row_geometry, i) - y + g_sheet_row_get_height (sheet->row_geometry, i);
if (i == sheet->range.row0)
(i != sheet->active_cell.row || j != sheet->active_cell.col))
{
- x = g_sheet_column_start_pixel (sheet->column_geometry, j);
+ x = psppire_axis_pixel_start (sheet->haxis, 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);
+ width = psppire_axis_pixel_start (sheet->haxis, j) - x + psppire_axis_unit_size (sheet->haxis, j);
height = g_sheet_row_start_pixel (sheet->row_geometry, i) - y + g_sheet_row_get_height (sheet->row_geometry, i);
if (i == new_range.row0)
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);
+ x = psppire_axis_pixel_start (sheet->haxis, j);
y = g_sheet_row_start_pixel (sheet->row_geometry, i);
- width = g_sheet_column_get_width (sheet->column_geometry, j);
+ width = psppire_axis_unit_size (sheet->haxis, j);
height = g_sheet_row_get_height (sheet->row_geometry, i);
if (mask2 & 1)
gdk_draw_rectangle (sheet->sheet_window,
sheet_signals[BUTTON_EVENT_COLUMN], 0,
column, event);
- if (g_sheet_column_get_sensitivity (sheet->column_geometry, column))
+ if (g_sheet_model_get_column_sensitivity (sheet->model, column))
{
if ( event->type == GDK_2BUTTON_PRESS && event->button == 1)
g_signal_emit (sheet,
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));
cell.col = column;
if (row >= g_sheet_row_get_row_count (sheet->row_geometry)
- || column >= g_sheet_column_get_column_count (sheet->column_geometry))
+ || column >= psppire_axis_unit_count (sheet->haxis))
{
return FALSE;
}
sheet->range.col0 = 0;
sheet->range.rowi = g_sheet_row_get_row_count (sheet->row_geometry) - 1;
sheet->range.coli =
- g_sheet_column_get_column_count (sheet->column_geometry) - 1;
+ psppire_axis_unit_count (sheet->haxis) - 1;
sheet->active_cell.row = 0;
sheet->active_cell.col = 0;
gtk_sheet_select_range (sheet, NULL);
if (sheet->row_title_under)
{
GSheetRow *row_geo = sheet->row_geometry;
- gchar *text;
-
- text = g_sheet_row_get_subtitle (row_geo, row);
+ gchar *text = g_sheet_row_get_subtitle (row_geo, row);
show_subtitle (sheet, row, -1, text);
g_free (text);
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);
sheet->y_drag = y;
aux = sheet->range;
if (aux.row0 + row >= 0 && aux.rowi + row < g_sheet_row_get_row_count (sheet->row_geometry) &&
- aux.col0 + column >= 0 && aux.coli + column < g_sheet_column_get_column_count (sheet->column_geometry))
+ aux.col0 + column >= 0 && aux.coli + column < psppire_axis_unit_count (sheet->haxis))
{
aux = sheet->drag_range;
sheet->drag_range.row0 = sheet->range.row0 + row;
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)) >
+ if (abs (x - psppire_axis_pixel_start (sheet->haxis, sheet->drag_cell.col)) >
abs (y - g_sheet_row_start_pixel (sheet->row_geometry, sheet->drag_cell.row))) v_h = 2;
current_col = column_from_xpixel (sheet, x);
/*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)
row = 0;
if (aux.row0 + row >= 0 && aux.rowi + row < g_sheet_row_get_row_count (sheet->row_geometry) &&
- aux.col0 + column >= 0 && aux.coli + column < g_sheet_column_get_column_count (sheet->column_geometry))
+ aux.col0 + column >= 0 && aux.coli + column < psppire_axis_unit_count (sheet->haxis))
{
aux = sheet->drag_range;
sheet->drag_range = sheet->range;
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;
g_sheet_row_get_row_count (sheet->row_geometry) - 1);
minimize_int (&new_cell.col,
- g_sheet_column_get_column_count (sheet->column_geometry) - 1);
+ psppire_axis_unit_count (sheet->haxis) - 1);
g_signal_emit (sheet, sheet_signals[TRAVERSE], 0,
&sheet->active_cell,
if ( new_cell.col > max_fully_visible_column (sheet))
{
glong hpos =
- g_sheet_column_start_pixel (sheet->column_geometry,
+ psppire_axis_pixel_start (sheet->haxis,
new_cell.col + 1);
hpos -= sheet->hadjustment->page_size;
else if ( new_cell.col < min_fully_visible_column (sheet))
{
glong hpos =
- g_sheet_column_start_pixel (sheet->column_geometry,
+ psppire_axis_pixel_start (sheet->haxis,
new_cell.col);
gtk_adjustment_set_value (sheet->hadjustment,
}
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,
if (column < min_visible_column (sheet)) return;
if (column > max_visible_column (sheet)) return;
- button = g_sheet_column_get_button (sheet->column_geometry, column);
+ button = g_sheet_model_get_column_button (sheet->model, column);
allocation.y = 0;
- allocation.x = g_sheet_column_start_pixel (sheet->column_geometry, column) + CELL_SPACING;
+ allocation.x = psppire_axis_pixel_start (sheet->haxis, column) + CELL_SPACING;
allocation.x -= sheet->hadjustment->value;
allocation.height = sheet->column_title_area.height;
- allocation.width = g_sheet_column_get_width (sheet->column_geometry, column);
- is_sensitive = g_sheet_column_get_sensitivity (sheet->column_geometry, column);
+ allocation.width = psppire_axis_unit_size (sheet->haxis, column);
+ is_sensitive = g_sheet_model_get_column_sensitivity (sheet->model, column);
gtk_sheet_button_draw (sheet, sheet->column_title_window,
button, is_sensitive, allocation);
sheet->hadjustment->page_increment = width;
- last_col = g_sheet_column_get_column_count (sheet->column_geometry) - 1;
+ last_col = psppire_axis_unit_count (sheet->haxis) - 1;
sheet->hadjustment->upper =
- g_sheet_column_start_pixel (sheet->column_geometry, last_col)
+ psppire_axis_pixel_start (sheet->haxis, last_col)
+
- g_sheet_column_get_width (sheet->column_geometry, last_col)
+ psppire_axis_unit_size (sheet->haxis, last_col)
;
sheet->hadjustment->lower = 0;
GdkRectangle clip_area, area;
GdkGCValues values;
- area.x = g_sheet_column_start_pixel (sheet->column_geometry, range.col0);
+ area.x = psppire_axis_pixel_start (sheet->haxis, range.col0);
area.y = g_sheet_row_start_pixel (sheet->row_geometry, range.row0);
- area.width = g_sheet_column_start_pixel (sheet->column_geometry, range.coli)- area.x+
- g_sheet_column_get_width (sheet->column_geometry, range.coli);
+ area.width = psppire_axis_pixel_start (sheet->haxis, range.coli)- area.x+
+ psppire_axis_unit_size (sheet->haxis, range.coli);
area.height = g_sheet_row_start_pixel (sheet->row_geometry, range.rowi)- area.y +
g_sheet_row_get_height (sheet->row_geometry, range.rowi);
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
draw_column_title_buttons (sheet);
g_return_if_fail (sheet != NULL);
g_return_if_fail (GTK_IS_SHEET (sheet));
- if (column < 0 || column >= g_sheet_column_get_column_count (sheet->column_geometry))
+ if (column < 0 || column >= psppire_axis_unit_count (sheet->haxis))
return;
gtk_sheet_column_size_request (sheet, column, &min_width);
if (width < min_width) return;
+#if AXIS_TRANSITION
g_sheet_column_set_width (sheet->column_geometry, column, width);
+#endif
if (GTK_WIDGET_REALIZED (GTK_WIDGET (sheet)))
{
}
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 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,
g_free (button);
}
-
static void
append_cell_text (GString *string, const GtkSheet *sheet, gint r, gint c)
{
#include "gtkextra-sheet.h"
#include "gsheetmodel.h"
-#include "gsheet-column-iface.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;
guint16 flags;
/* create a new sheet */
-GtkWidget * gtk_sheet_new (GSheetRow *vgeo, GSheetColumn *hgeo,
+GtkWidget * gtk_sheet_new (GSheetRow *vgeo, void *hgeo,
GSheetModel *model);
/* create a new sheet with custom entry */
GtkWidget *
gtk_sheet_new_with_custom_entry (GSheetRow *vgeo,
- GSheetColumn *hgeo,
+ void *hgeo,
GtkType entry_type);
void
gtk_sheet_construct_with_custom_entry (GtkSheet *sheet,
GSheetRow *vgeo,
- GSheetColumn *hgeo,
+ 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 "psppire-axis.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;
+
+/* --- functions --- */
+/**
+ * psppire_axis_get_type:
+ * @returns: the type ID for accelerator groups.
+ */
+GType
+psppire_axis_get_type (void)
+{
+ static GType object_type = 0;
+
+ if (!object_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,
+ };
+
+ object_type = g_type_register_static (G_TYPE_OBJECT,
+ "PsppireAxis",
+ &object_info, 0);
+ }
+
+ return object_type;
+}
+
+
+static void
+psppire_axis_class_init (PsppireAxisClass *class)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (class);
+
+ parent_class = g_type_class_peek_parent (class);
+
+ object_class->finalize = psppire_axis_finalize;
+}
+
+static void
+psppire_axis_init (PsppireAxis *axis)
+{
+ tower_init (&axis->tower);
+}
+
+
+static void
+psppire_axis_finalize (GObject *object)
+{
+ G_OBJECT_CLASS (parent_class)->finalize (object);
+}
+
+/**
+ * psppire_axis_new:
+ * @returns: a new #PsppireAxis object
+ *
+ * Creates a new #PsppireAxis.
+ */
+PsppireAxis*
+psppire_axis_new (gint w)
+{
+ PsppireAxis *new_axis = g_object_new (G_TYPE_PSPPIRE_AXIS, NULL);
+
+ new_axis->width = w;
+
+ return new_axis;
+}
+
+
+gint
+psppire_axis_unit_size (PsppireAxis *a, gint unit)
+{
+ if ( a->width == -1)
+ {
+ const struct tower_node *node;
+ if (unit >= tower_count (&a->tower))
+ return 0;
+
+ node = tower_get (&a->tower, unit);
+
+ return tower_node_get_size (node);
+ }
+
+ return a->width;
+}
+
+gint
+psppire_axis_unit_count (PsppireAxis *a)
+{
+ if (a->width == -1)
+ return tower_count (&a->tower);
+
+ return 600;
+}
+
+glong
+psppire_axis_pixel_start (PsppireAxis *a, gint unit)
+{
+ if ( a->width == -1 )
+ {
+ const struct tower_node *node;
+
+ if ( unit >= tower_count (&a->tower))
+ return tower_height (&a->tower);
+
+ node = tower_get (&a->tower, unit);
+
+ return tower_node_get_level (node);
+ }
+
+ return a->width * unit;
+}
+
+gint
+psppire_axis_get_unit_at_pixel (PsppireAxis *a, glong pixel)
+{
+ if (a->width == -1)
+ {
+ const struct tower_node *node;
+ unsigned long int node_start;
+
+ if (pixel >= tower_height (&a->tower))
+ return tower_count (&a->tower);
+
+ node = tower_lookup (&a->tower, pixel, &node_start);
+
+ return tower_node_get_index (node);
+ }
+
+ return pixel / a->width;
+}
+
+void
+psppire_axis_append (PsppireAxis *a, gint width)
+{
+ struct tower_node *new = g_slice_alloc0 (sizeof *new);
+ tower_insert (&a->tower, width, new, NULL);
+}
+
+
+
+
+
--- /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_H__
+#define PSPPIRE_AXIS_H__
+
+
+#include <glib-object.h>
+#include <glib.h>
+
+#include <libpspp/tower.h>
+
+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_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), G_TYPE_PSPPIRE_AXIS, PsppireAxisClass))
+#define PSPPIRE_IS_AXIS(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), G_TYPE_PSPPIRE_AXIS))
+#define PSPPIRE_IS_AXIS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), G_TYPE_PSPPIRE_AXIS))
+#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 _PsppireAxis
+{
+ GObject parent;
+ gint width ;
+
+ struct tower tower;
+};
+
+struct _PsppireAxisClass
+{
+ GObjectClass parent_class;
+
+};
+
+GType psppire_axis_get_type (void);
+
+PsppireAxis* psppire_axis_new (gint w);
+
+\f
+/* Interface between sheet and axis */
+
+gint psppire_axis_unit_size (PsppireAxis *a, gint unit);
+
+gint psppire_axis_unit_count (PsppireAxis *a);
+
+glong psppire_axis_pixel_start (PsppireAxis *a, gint unit);
+
+gint psppire_axis_get_unit_at_pixel (PsppireAxis *a, glong pixel);
+
+
+
+/* Interface between axis and model */
+
+void psppire_axis_append (PsppireAxis *a, gint width);
+
+G_END_DECLS
+
+#endif /* PSPPIRE_AXIS_H__ */
#include "psppire-data-editor.h"
#include "psppire-var-sheet.h"
-#include <gtksheet/gsheet-hetero-column.h>
#include <language/syntax-string-source.h>
#include "psppire-data-store.h"
#include "helper.h"
for (i = 0 ; i < 4 ; ++i )
g_object_set (de->data_sheet[i],
"row-geometry", de->data_store,
- "column-geometry", de->data_store,
"model", de->data_store,
NULL);
break;
init_sheet (PsppireDataEditor *de, int i,
GtkAdjustment *hadj, GtkAdjustment *vadj)
{
+ PsppireAxis *haxis = psppire_axis_new (100);
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 (de->data_sheet[i],
+ "horizontal-axis", haxis,
+ NULL);
+
gtk_container_add (GTK_CONTAINER (de->sheet_bin[i]), de->data_sheet[i]);
g_signal_connect (de->data_sheet[i], "traverse",
/* PSPPIRE - a graphical user interface for PSPP.
- Copyright (C) 2006 Free Software Foundation
+ Copyright (C) 2006, 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
#include <data/variable.h>
#include <gtksheet/gsheetmodel.h>
-#include <gtksheet/gsheet-column-iface.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_column_init (GSheetColumnIface *iface);
static void psppire_data_store_sheet_row_init (GSheetRowIface *iface);
static void psppire_data_store_finalize (GObject *object);
NULL
};
- static const GInterfaceInfo sheet_column_info =
- {
- (GInterfaceInitFunc) psppire_data_store_sheet_column_init,
- NULL,
- NULL
- };
-
static const GInterfaceInfo sheet_row_info =
{
(GInterfaceInitFunc) psppire_data_store_sheet_row_init,
G_TYPE_SHEET_MODEL,
&sheet_model_info);
- g_type_add_interface_static (data_store_type,
- G_TYPE_SHEET_COLUMN,
- &sheet_column_info);
-
g_type_add_interface_static (data_store_type,
G_TYPE_SHEET_ROW,
&sheet_row_info);
+static gchar * get_column_subtitle (const GSheetModel *model, gint col);
+static gchar * get_column_button_label (const GSheetModel *model, gint col);
+static gboolean get_column_sensitivity (const GSheetModel *model, gint col);
+static GtkJustification get_column_justification (const GSheetModel *model, gint col);
+
static void
psppire_data_store_sheet_model_init (GSheetModelIface *iface)
iface->get_cell_border = NULL;
iface->get_column_count = psppire_data_store_get_var_count;
iface->get_row_count = psppire_data_store_get_case_count_wrapper;
+
+ iface->get_column_subtitle = get_column_subtitle;
+ iface->get_column_title = get_column_button_label;
+ iface->get_column_sensitivity = get_column_sensitivity;
+ iface->get_column_justification = get_column_justification;
}
static void
{
PsppireDataStore *store = PSPPIRE_DATA_STORE (data);
+#if AXIS_TRANSITION
g_sheet_model_columns_deleted (G_SHEET_MODEL (store), dict_index, 1);
g_sheet_column_columns_changed (G_SHEET_COLUMN (store),
dict_index, -1);
+#endif
}
{
PsppireDataStore *store = PSPPIRE_DATA_STORE (data);
+#if AXIS_TRANSITION
g_sheet_column_columns_changed (G_SHEET_COLUMN (store),
var_num, 1);
g_sheet_model_range_changed (G_SHEET_MODEL (store),
-1, var_num,
-1, var_num);
+#endif
}
static void
psppire_case_file_insert_values (store->case_file, 1, posn);
+#if AXIS_TRANSITION
g_sheet_column_columns_changed (G_SHEET_COLUMN (store),
var_num, 1);
+#endif
g_sheet_model_columns_inserted (G_SHEET_MODEL (store), var_num, 1);
}
/* The entire model has changed */
g_sheet_model_range_changed (G_SHEET_MODEL (data_store), -1, -1, -1, -1);
+#if AXIS_TRANSITION
g_sheet_column_columns_changed (G_SHEET_COLUMN (data_store), 0, -1);
-
+#endif
if ( data_store->dict )
for (i = 0 ; i < n_dict_signals; ++i )
/* Column related funcs */
+#if AXIS_TRANSITION
static glong
geometry_get_column_count (const GSheetColumn *geom)
{
var_set_display_width (v, width / ds->width_of_m );
}
-
-
-static GtkJustification
-geometry_get_justification (const GSheetColumn *geom, glong unit)
-{
- PsppireDataStore *ds = PSPPIRE_DATA_STORE (geom);
- const struct variable *pv ;
-
-
- if ( unit >= psppire_dict_get_var_cnt (ds->dict) )
- return GTK_JUSTIFY_LEFT;
-
- pv = psppire_dict_get_variable (ds->dict, unit);
-
- return (var_get_alignment (pv) == ALIGN_LEFT ? GTK_JUSTIFY_LEFT
- : var_get_alignment (pv) == ALIGN_RIGHT ? GTK_JUSTIFY_RIGHT
- : GTK_JUSTIFY_CENTER);
-}
+#endif
static const gchar null_var_name[]=N_("var");
-static gchar *
-geometry_get_column_button_label (const GSheetColumn *geom, glong unit)
-{
- gchar *text;
- struct variable *pv ;
- PsppireDataStore *ds = PSPPIRE_DATA_STORE (geom);
-
- if ( unit >= psppire_dict_get_var_cnt (ds->dict) )
- return g_locale_to_utf8 (null_var_name, -1, 0, 0, 0);
-
- pv = psppire_dict_get_variable (ds->dict, unit);
-
- text = pspp_locale_to_utf8 (var_get_name (pv), -1, 0);
-
- return text;
-}
-
-
-static gchar *
-geometry_get_column_subtitle (const GSheetColumn *geom, glong unit)
-{
- gchar *text;
- const struct variable *v ;
- PsppireDataStore *ds = PSPPIRE_DATA_STORE (geom);
-
- if ( unit >= psppire_dict_get_var_cnt (ds->dict) )
- return NULL;
-
- v = psppire_dict_get_variable (ds->dict, unit);
-
- if ( ! var_has_label (v))
- return NULL;
-
- text = pspp_locale_to_utf8 (var_get_label (v), -1, 0);
-
- return text;
-}
-
-
-static gboolean
-geometry_get_sensitivity (const GSheetColumn *geom, glong unit)
-{
- PsppireDataStore *ds = PSPPIRE_DATA_STORE (geom);
-
- return (unit < psppire_dict_get_var_cnt (ds->dict));
-}
-
-
-static void
-psppire_data_store_sheet_column_init (GSheetColumnIface *iface)
-{
- iface->get_column_count = geometry_get_column_count;
- iface->get_width = geometry_get_width;
- iface->set_width = geometry_set_width;
- iface->get_sensitivity = geometry_get_sensitivity;
- iface->get_justification = geometry_get_justification;
- iface->get_button_label = geometry_get_column_button_label;
- iface->get_subtitle = geometry_get_column_subtitle;
-}
-
/* Row related funcs */
iface->pixel_to_row = geometry_pixel_to_row;
iface->get_button_label = geometry_get_row_button_label;
}
+
+
+\f
+
+/* Column related stuff */
+
+static gchar *
+get_column_subtitle (const GSheetModel *model, gint col)
+{
+ gchar *text;
+ const struct variable *v ;
+ PsppireDataStore *ds = PSPPIRE_DATA_STORE (model);
+
+ if ( col >= psppire_dict_get_var_cnt (ds->dict) )
+ return NULL;
+
+ v = psppire_dict_get_variable (ds->dict, col);
+
+ if ( ! var_has_label (v))
+ return NULL;
+
+ text = pspp_locale_to_utf8 (var_get_label (v), -1, 0);
+
+ return text;
+}
+
+static gchar *
+get_column_button_label (const GSheetModel *model, gint col)
+{
+ gchar *text;
+ struct variable *pv ;
+ PsppireDataStore *ds = PSPPIRE_DATA_STORE (model);
+
+ if ( col >= psppire_dict_get_var_cnt (ds->dict) )
+ return g_locale_to_utf8 (null_var_name, -1, 0, 0, 0);
+
+ pv = psppire_dict_get_variable (ds->dict, col);
+
+ text = pspp_locale_to_utf8 (var_get_name (pv), -1, 0);
+
+ return text;
+}
+
+static gboolean
+get_column_sensitivity (const GSheetModel *model, gint col)
+{
+ PsppireDataStore *ds = PSPPIRE_DATA_STORE (model);
+
+ return (col < psppire_dict_get_var_cnt (ds->dict));
+}
+
+
+
+static GtkJustification
+get_column_justification (const GSheetModel *model, gint col)
+{
+ PsppireDataStore *ds = PSPPIRE_DATA_STORE (model);
+ const struct variable *pv ;
+
+ if ( col >= psppire_dict_get_var_cnt (ds->dict) )
+ return GTK_JUSTIFY_LEFT;
+
+ pv = psppire_dict_get_variable (ds->dict, col);
+
+ return (var_get_alignment (pv) == ALIGN_LEFT ? GTK_JUSTIFY_LEFT
+ : var_get_alignment (pv) == ALIGN_RIGHT ? GTK_JUSTIFY_RIGHT
+ : GTK_JUSTIFY_CENTER);
+}
+
+
#ifndef __PSPPIRE_DATA_STORE_H__
#define __PSPPIRE_DATA_STORE_H__
-#include <gtksheet/gsheetmodel.h>
#include "psppire-dict.h"
#include "psppire-case-file.h"
#include <glade/glade.h>
#include "helper.h"
-#include <gtksheet/gsheet-hetero-column.h>
+
#include "customentry.h"
#include <data/variable.h>
#include "psppire-var-store.h"
gint width ;
};
-static const struct column_parameters column_def[] = {
- { N_("Name"), 80},
- { N_("Type"), 100},
- { N_("Width"), 57},
- { N_("Decimals"),91},
- { N_("Label"), 95},
- { N_("Values"), 103},
- { N_("Missing"), 95},
- { N_("Columns"), 80},
- { N_("Align"), 69},
- { N_("Measure"), 99},
-};
-
-
#define n_ALIGNMENTS 3
const gchar *const alignments[n_ALIGNMENTS + 1]={
static void
psppire_var_sheet_init (PsppireVarSheet *vs)
{
- gint i;
- GObject *geo = g_sheet_hetero_column_new (75, PSPPIRE_VAR_STORE_n_COLS);
+ // 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_button_label (G_SHEET_HETERO_COLUMN (geo), i,
- gettext (column_def[i].label));
-
g_sheet_hetero_column_set_width (G_SHEET_HETERO_COLUMN (geo), i,
column_def[i].width);
}
-
- g_object_set (vs, "column-geometry", geo, NULL);
+#endif
g_signal_connect (vs, "activate",
G_CALLBACK (var_sheet_change_active_cell),
}
+static const struct column_parameters column_def[] = {
+ { N_("Name"), 80},
+ { N_("Type"), 100},
+ { N_("Width"), 57},
+ { N_("Decimals"),91},
+ { N_("Label"), 95},
+ { N_("Values"), 103},
+ { N_("Missing"), 95},
+ { N_("Columns"), 80},
+ { N_("Align"), 69},
+ { N_("Measure"), 99},
+};
+
GtkWidget*
psppire_var_sheet_new (void)
{
- return GTK_WIDGET (g_object_new (psppire_var_sheet_get_type (), NULL));
+ gint i;
+ PsppireAxis *a = psppire_axis_new (-1);
+ 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);
+
+ g_object_set (w,
+ "horizontal-axis", a,
+ NULL);
+
+ return w;
}
}
-
+static gchar *get_column_title (const GSheetModel *model, gint col);
static void
psppire_var_store_sheet_model_init (GSheetModelIface *iface)
iface->get_font_desc = psppire_var_store_get_font_desc;
iface->get_cell_border = NULL;
iface->get_justification = NULL;
-}
-
+ iface->get_column_title = get_column_title;
+}
/**
* psppire_var_store_new:
iface->get_button_label = geometry_get_button_label;
}
+
+\f
+
+static const gchar *column_titles[] = {
+ N_("Name"),
+ N_("Type"),
+ N_("Width"),
+ N_("Decimals"),
+ N_("Label"),
+ N_("Values"),
+ N_("Missing"),
+ N_("Columns"),
+ N_("Align"),
+ N_("Measure"),
+};
+
+
+static gchar *
+get_column_title (const GSheetModel *model, gint col)
+{
+ if ( col >= 10)
+ return NULL;
+ return g_strdup (gettext (column_titles[col]));
+}
#ifndef __PSPPIRE_VAR_STORE_H__
#define __PSPPIRE_VAR_STORE_H__
-#include <gtksheet/gsheetmodel.h>
#include "psppire-dict.h"
#include <gdk/gdk.h>