Fixed bug reporting the significance of paired value t-test.
[pspp-builds.git] / lib / gtksheet / gsheet-uniform-row.c
1 /* gsheet-uniform-row.c
2  *
3  *  PSPPIRE --- A Graphical User Interface for PSPP
4  * Copyright (C) 2006  Free Software Foundation
5  *
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.
10  *
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.
15  *
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
19  */
20
21 #include <config.h>
22
23 #include "gsheet-row-iface.h"
24 #include "gsheet-uniform-row.h"
25
26
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);
30
31 static void g_sheet_row_init (GSheetRowIface *iface);
32
33
34 static GObjectClass *parent_class = NULL;
35
36 GType
37 g_sheet_uniform_row_get_type (void)
38 {
39   static GType uniform_row_type = 0;
40
41   if (!uniform_row_type)
42     {
43       static const GTypeInfo uniform_row_info =
44       {
45         sizeof (GSheetUniformRowClass),
46         NULL,           /* base_init */
47         NULL,           /* base_finalize */
48         (GClassInitFunc) g_sheet_uniform_row_class_init,
49         NULL,           /* class_finalize */
50         NULL,           /* class_data */
51         sizeof (GSheetUniformRow),
52         0,
53         (GInstanceInitFunc) g_sheet_uniform_row_init,
54       };
55
56       static const GInterfaceInfo row_info =
57       {
58         (GInterfaceInitFunc) g_sheet_row_init,
59         NULL,
60         NULL
61       };
62
63       uniform_row_type =
64         g_type_register_static (G_TYPE_OBJECT, "g_sheet_uniform_row",
65                                 &uniform_row_info, 0);
66
67       g_type_add_interface_static (uniform_row_type,
68                                    G_TYPE_SHEET_ROW,
69                                    &row_info);
70     }
71
72   return uniform_row_type;
73 }
74
75
76 /**
77  * g_sheet_uniform_row_new:
78  * @height: The size of rows in this uniform row
79  *
80  * Return value: a new #g_sheet_uniform_row
81  **/
82 GObject *
83 g_sheet_uniform_row_new (gint height, gint n_rows)
84 {
85   GSheetUniformRow *ug;
86   GObject *retval;
87
88   retval = g_object_new (G_TYPE_SHEET_UNIFORM_ROW, NULL);
89
90   ug = G_SHEET_UNIFORM_ROW(retval);
91   ug->n_rows = n_rows;
92   ug->height = height;
93   ug->is_visible = TRUE;
94
95   return retval;
96 }
97
98 static gint
99 g_sheet_uniform_row_get_height (const GSheetRow *geom, glong u)
100 {
101   GSheetUniformRow *ug = G_SHEET_UNIFORM_ROW(geom);
102
103   return ug->height;
104 }
105
106 static gboolean
107 g_sheet_uniform_row_get_sensitivity (const GSheetRow *geom, glong u)
108 {
109   GSheetUniformRow *ug = G_SHEET_UNIFORM_ROW(geom);
110
111   return (u < ug->n_rows);
112 }
113
114
115 static gboolean
116 g_sheet_uniform_row_get_visibility (const GSheetRow *geom, glong u)
117 {
118   GSheetUniformRow *ug = G_SHEET_UNIFORM_ROW (geom);
119
120   return ug->is_visible;
121 }
122
123
124 static gchar *
125 g_sheet_uniform_row_get_button_label (const GSheetRow *geom, glong u)
126 {
127   gchar *label = g_strdup_printf("%ld", u);
128
129   return label;
130 }
131
132
133
134 static glong
135 g_sheet_uniform_row_get_row_count (const GSheetRow *geom)
136 {
137   GSheetUniformRow *ug = G_SHEET_UNIFORM_ROW(geom);
138
139   return ug->n_rows;
140 }
141
142
143 static void
144 g_sheet_uniform_row_class_init (GSheetUniformRowClass *class)
145 {
146   GObjectClass *object_class;
147
148   parent_class = g_type_class_peek_parent (class);
149   object_class = (GObjectClass*) class;
150
151   object_class->finalize = g_sheet_uniform_row_finalize;
152
153 }
154
155
156 static void
157 g_sheet_uniform_row_init (GSheetUniformRow *o)
158 {
159 }
160
161 static void
162 g_sheet_uniform_row_finalize (GObject *object)
163 {
164 }
165
166
167 static guint
168 g_sheet_uniform_row_top_ypixel (const GSheetRow *geo, glong row)
169 {
170   GSheetUniformRow *ug = G_SHEET_UNIFORM_ROW(geo);
171
172   return row * ug->height;
173 }
174
175 static glong
176 g_sheet_uniform_row_pixel_to_row (const GSheetRow *geo, guint pixel)
177 {
178   GSheetUniformRow *ug = G_SHEET_UNIFORM_ROW(geo);
179
180   gint row = pixel / ug->height;
181
182   if (row >= g_sheet_uniform_row_get_row_count(geo))
183     row = g_sheet_uniform_row_get_row_count(geo) - 1;
184
185   return row;
186 }
187
188
189
190 static void
191 g_sheet_row_init (GSheetRowIface *iface)
192 {
193   iface->get_height = g_sheet_uniform_row_get_height;
194   iface->get_sensitivity = g_sheet_uniform_row_get_sensitivity ;
195   iface->get_visibility = g_sheet_uniform_row_get_visibility;
196   iface->get_row_count = g_sheet_uniform_row_get_row_count;
197   iface->get_button_label = g_sheet_uniform_row_get_button_label;
198   iface->top_ypixel = g_sheet_uniform_row_top_ypixel;
199   iface->pixel_to_row = g_sheet_uniform_row_pixel_to_row;
200 }
201