1 /* gsheet-uniform-row.c
3 * PSPPIRE --- A Graphical User Interface for PSPP
4 * Copyright (C) 2006 Free Software Foundation
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
23 #include "gsheet-row-iface.h"
24 #include "gsheet-uniform-row.h"
27 static void g_sheet_uniform_row_init (GSheetUniformRow *ug);
28 static void g_sheet_uniform_row_class_init (GSheetUniformRowClass *class);
29 static void g_sheet_uniform_row_finalize (GObject *object);
31 static void g_sheet_row_init (GSheetRowIface *iface);
34 static GObjectClass *parent_class = NULL;
37 g_sheet_uniform_row_get_type (void)
39 static GType uniform_row_type = 0;
41 if (!uniform_row_type)
43 static const GTypeInfo uniform_row_info =
45 sizeof (GSheetUniformRowClass),
47 NULL, /* base_finalize */
48 (GClassInitFunc) g_sheet_uniform_row_class_init,
49 NULL, /* class_finalize */
50 NULL, /* class_data */
51 sizeof (GSheetUniformRow),
53 (GInstanceInitFunc) g_sheet_uniform_row_init,
56 static const GInterfaceInfo row_info =
58 (GInterfaceInitFunc) g_sheet_row_init,
64 g_type_register_static (G_TYPE_OBJECT, "g_sheet_uniform_row",
65 &uniform_row_info, 0);
67 g_type_add_interface_static (uniform_row_type,
72 return uniform_row_type;
77 * g_sheet_uniform_row_new:
78 * @height: The size of rows in this uniform row
80 * Return value: a new #g_sheet_uniform_row
83 g_sheet_uniform_row_new (gint height, gint n_rows)
88 retval = g_object_new (G_TYPE_SHEET_UNIFORM_ROW, NULL);
90 ug = G_SHEET_UNIFORM_ROW(retval);
93 ug->is_visible = TRUE;
99 g_sheet_uniform_row_get_height (const GSheetRow *geom, glong u, gpointer data)
101 GSheetUniformRow *ug = G_SHEET_UNIFORM_ROW(geom);
107 g_sheet_uniform_row_get_sensitivity (const GSheetRow *geom, glong u,
110 GSheetUniformRow *ug = G_SHEET_UNIFORM_ROW(geom);
112 return (u < ug->n_rows);
117 g_sheet_uniform_row_get_visibility (const GSheetRow *geom, glong u,
120 GSheetUniformRow *ug = G_SHEET_UNIFORM_ROW (geom);
122 return ug->is_visible;
127 g_sheet_uniform_row_get_button_label(const GSheetRow *geom, glong u, gpointer data)
129 gchar *label = g_strdup_printf("%ld", u);
137 g_sheet_uniform_row_get_row_count (const GSheetRow *geom, gpointer data)
139 GSheetUniformRow *ug = G_SHEET_UNIFORM_ROW(geom);
146 g_sheet_uniform_row_class_init (GSheetUniformRowClass *class)
148 GObjectClass *object_class;
150 parent_class = g_type_class_peek_parent (class);
151 object_class = (GObjectClass*) class;
153 object_class->finalize = g_sheet_uniform_row_finalize;
159 g_sheet_uniform_row_init (GSheetUniformRow *o)
164 g_sheet_uniform_row_finalize (GObject *object)
170 g_sheet_uniform_row_top_ypixel (const GSheetRow *geo, glong row, gpointer data)
172 GSheetUniformRow *ug = G_SHEET_UNIFORM_ROW(geo);
174 return row * ug->height;
178 g_sheet_uniform_row_pixel_to_row (const GSheetRow *geo, guint pixel,
181 GSheetUniformRow *ug = G_SHEET_UNIFORM_ROW(geo);
183 gint row = pixel / ug->height;
185 if (row >= g_sheet_uniform_row_get_row_count(geo, data))
186 row = g_sheet_uniform_row_get_row_count(geo, data) -1;
194 g_sheet_row_init (GSheetRowIface *iface)
196 iface->get_height = g_sheet_uniform_row_get_height;
197 iface->get_sensitivity = g_sheet_uniform_row_get_sensitivity ;
198 iface->get_visibility = g_sheet_uniform_row_get_visibility;
199 iface->get_row_count = g_sheet_uniform_row_get_row_count;
200 iface->get_button_label = g_sheet_uniform_row_get_button_label;
201 iface->top_ypixel = g_sheet_uniform_row_top_ypixel;
202 iface->pixel_to_row = g_sheet_uniform_row_pixel_to_row;