8f30afa448f6b4df49b4cb9248232933ecdf3614
[pspp-builds.git] / src / ui / gui / psppire-data-store.h
1 /* PSPPIRE - a graphical user interface for PSPP.
2    Copyright (C) 2006  Free Software Foundation
3
4    This program is free software: you can redistribute it and/or modify
5    it under the terms of the GNU General Public License as published by
6    the Free Software Foundation, either version 3 of the License, or
7    (at your option) any later version.
8
9    This program is distributed in the hope that it will be useful,
10    but WITHOUT ANY WARRANTY; without even the implied warranty of
11    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12    GNU General Public License for more details.
13
14    You should have received a copy of the GNU General Public License
15    along with this program.  If not, see <http://www.gnu.org/licenses/>. */
16
17 #ifndef __PSPPIRE_DATA_STORE_H__
18 #define __PSPPIRE_DATA_STORE_H__
19
20 #include "psppire-dict.h"
21 #include "psppire-case-file.h"
22
23 #define FIRST_CASE_NUMBER 1
24
25
26 #ifdef __cplusplus
27 extern "C" {
28 #endif /* __cplusplus */
29
30 #define GTK_TYPE_DATA_STORE            (psppire_data_store_get_type ())
31
32 #define PSPPIRE_DATA_STORE(obj) \
33                      (G_TYPE_CHECK_INSTANCE_CAST ((obj), \
34                                                                     GTK_TYPE_DATA_STORE, PsppireDataStore))
35
36 #define PSPPIRE_DATA_STORE_CLASS(klass) \
37                      (G_TYPE_CHECK_CLASS_CAST ((klass), \
38                                                                  GTK_TYPE_DATA_STORE, \
39                                                                  PsppireDataStoreClass))
40
41
42 #define PSPPIRE_IS_DATA_STORE(obj) \
43                      (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_DATA_STORE))
44
45 #define PSPPIRE_IS_DATA_STORE_CLASS(klass) \
46                      (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_DATA_STORE))
47
48 #define PSPPIRE_DATA_STORE_GET_CLASS(obj) \
49                      (G_TYPE_INSTANCE_GET_CLASS ((obj), \
50                                                                    GTK_TYPE_DATA_STORE, \
51                                                                    PsppireDataStoreClass))
52
53 typedef struct _PsppireDataStore       PsppireDataStore;
54 typedef struct _PsppireDataStoreClass  PsppireDataStoreClass;
55
56 struct dictionary;
57
58
59 enum cf_signal_handler {
60   CASES_DELETED,
61   CASE_INSERTED,
62   CASE_CHANGED,
63   n_cf_signals
64 };
65
66
67 enum dict_signal_handler {
68   VARIABLE_INSERTED,
69   VARIABLE_CHANGED,
70   VARIABLE_DELETED,
71   SIZE_CHANGED,
72   n_dict_signals
73 };
74
75 void do_this_thing (PsppireDict *, struct dictionary *, void *);
76
77
78 struct _PsppireDataStore
79 {
80   GObject parent;
81
82   /*< private >*/
83   gboolean dispose_has_run ;
84   PsppireDict *dict;
85   PsppireCaseFile *case_file;
86   const PangoFontDescription *font_desc;
87
88   /* The width of an upper case 'M' rendered in the current font */
89   gint width_of_m ;
90
91   gboolean show_labels;
92
93   /* Geometry */
94   gint margin_width;
95
96   gint cf_handler_id [n_cf_signals];
97   gint dict_handler_id [n_dict_signals];
98 };
99
100 struct _PsppireDataStoreClass
101 {
102   GObjectClass parent_class;
103
104   /* Padding for future expansion */
105   void (*_gtk_reserved1) (void);
106   void (*_gtk_reserved2) (void);
107   void (*_gtk_reserved3) (void);
108   void (*_gtk_reserved4) (void);
109 };
110
111
112 GType psppire_data_store_get_type (void) G_GNUC_CONST;
113 PsppireDataStore *psppire_data_store_new     (PsppireDict *dict);
114
115 void psppire_data_store_set_case_file (PsppireDataStore *data_store,
116                                        PsppireCaseFile *cf);
117
118 void psppire_data_store_set_dictionary (PsppireDataStore *data_store,
119                                         PsppireDict *dict);
120
121 void psppire_data_store_set_font (PsppireDataStore *store,
122                                  const PangoFontDescription *fd);
123
124 void psppire_data_store_show_labels (PsppireDataStore *store,
125                                     gboolean show_labels);
126
127 void psppire_data_store_clear (PsppireDataStore *data_store);
128
129 gboolean psppire_data_store_insert_new_case (PsppireDataStore *ds, casenumber posn);
130
131
132 gboolean psppire_data_store_delete_cases (PsppireDataStore *ds, casenumber first, casenumber count);
133
134
135 struct casereader * psppire_data_store_get_reader (PsppireDataStore *ds);
136
137 gchar * psppire_data_store_get_string (PsppireDataStore *ds,
138                                        casenumber row, glong column);
139
140 gboolean psppire_data_store_set_string (PsppireDataStore *ds,
141                                         const gchar *text,
142                                         glong row, glong column);
143
144 casenumber psppire_data_store_get_case_count (const PsppireDataStore *ds);
145 size_t psppire_data_store_get_value_count (const PsppireDataStore *ds);
146
147 #ifdef __cplusplus
148 }
149 #endif /* __cplusplus */
150
151
152 #endif /* __PSPPIRE_DATA_STORE_H__ */