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
21 #include "gsheet-row-iface.h"
22 #include "gsheet-uniform-row.h"
25 static void g_sheet_uniform_row_init (GSheetUniformRow *ug);
26 static void g_sheet_uniform_row_class_init (GSheetUniformRowClass *class);
27 static void g_sheet_uniform_row_finalize (GObject *object);
29 static void g_sheet_row_init (GSheetRowIface *iface);
32 static GObjectClass *parent_class = NULL;
35 g_sheet_uniform_row_get_type (void)
37 static GType uniform_row_type = 0;
39 if (!uniform_row_type)
41 static const GTypeInfo uniform_row_info =
43 sizeof (GSheetUniformRowClass),
45 NULL, /* base_finalize */
46 (GClassInitFunc) g_sheet_uniform_row_class_init,
47 NULL, /* class_finalize */
48 NULL, /* class_data */
49 sizeof (GSheetUniformRow),
51 (GInstanceInitFunc) g_sheet_uniform_row_init,
54 static const GInterfaceInfo row_info =
56 (GInterfaceInitFunc) g_sheet_row_init,
62 g_type_register_static (G_TYPE_OBJECT, "g_sheet_uniform_row",
63 &uniform_row_info, 0);
65 g_type_add_interface_static (uniform_row_type,
70 return uniform_row_type;
75 * g_sheet_uniform_row_new:
76 * @height: The size of rows in this uniform row
78 * Return value: a new #g_sheet_uniform_row
81 g_sheet_uniform_row_new (gint height, gint n_rows)
86 retval = g_object_new (G_TYPE_SHEET_UNIFORM_ROW, NULL);
88 ug = G_SHEET_UNIFORM_ROW(retval);
91 ug->is_visible = TRUE;
97 g_sheet_uniform_row_get_height(const GSheetRow *geom, gint u, gpointer data)
99 GSheetUniformRow *ug = G_SHEET_UNIFORM_ROW(geom);
105 g_sheet_uniform_row_get_sensitivity(const GSheetRow *geom, gint u, gpointer data)
107 GSheetUniformRow *ug = G_SHEET_UNIFORM_ROW(geom);
109 return (u < ug->n_rows);
114 g_sheet_uniform_row_get_visibility(const GSheetRow *geom, gint u, gpointer data)
116 GSheetUniformRow *ug = G_SHEET_UNIFORM_ROW(geom);
118 return ug->is_visible;
123 g_sheet_uniform_row_get_button_label(const GSheetRow *geom, gint u, gpointer data)
125 gchar *label = g_strdup_printf("%d", u);
133 g_sheet_uniform_row_get_row_count(const GSheetRow *geom, gpointer data)
135 GSheetUniformRow *ug = G_SHEET_UNIFORM_ROW(geom);
142 g_sheet_uniform_row_class_init (GSheetUniformRowClass *class)
144 GObjectClass *object_class;
146 parent_class = g_type_class_peek_parent (class);
147 object_class = (GObjectClass*) class;
149 object_class->finalize = g_sheet_uniform_row_finalize;
155 g_sheet_uniform_row_init (GSheetUniformRow *o)
160 g_sheet_uniform_row_finalize (GObject *object)
166 g_sheet_uniform_row_top_ypixel(const GSheetRow *geo, gint row, gpointer data)
168 GSheetUniformRow *ug = G_SHEET_UNIFORM_ROW(geo);
170 return row * ug->height;
174 g_sheet_uniform_row_pixel_to_row(const GSheetRow *geo, guint pixel,
177 GSheetUniformRow *ug = G_SHEET_UNIFORM_ROW(geo);
179 gint row = pixel / ug->height;
181 if (row >= g_sheet_uniform_row_get_row_count(geo, data))
182 row = g_sheet_uniform_row_get_row_count(geo, data) -1;
190 g_sheet_row_init (GSheetRowIface *iface)
192 iface->get_height = g_sheet_uniform_row_get_height;
193 iface->get_sensitivity = g_sheet_uniform_row_get_sensitivity ;
194 iface->get_visibility = g_sheet_uniform_row_get_visibility;
195 iface->get_row_count = g_sheet_uniform_row_get_row_count;
196 iface->get_button_label = g_sheet_uniform_row_get_button_label;
197 iface->top_ypixel = g_sheet_uniform_row_top_ypixel;
198 iface->pixel_to_row = g_sheet_uniform_row_pixel_to_row;