95ba779508dacfd376c3bffc233eda5537640e1f
[pspp] / src / ui / gui / pspp-sheet-view-column.h
1 /* PSPPIRE - a graphical user interface for PSPP.
2    Copyright (C) 2011, 2012 Free Software Foundation, Inc.
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 /* gtktreeviewcolumn.h
18  * Copyright (C) 2000  Red Hat, Inc.,  Jonathan Blandford <jrb@redhat.com>
19  *
20  * This library is free software; you can redistribute it and/or
21  * modify it under the terms of the GNU Library General Public
22  * License as published by the Free Software Foundation; either
23  * version 2 of the License, or (at your option) any later version.
24  *
25  * This library is distributed in the hope that it will be useful,
26  * but WITHOUT ANY WARRANTY; without even the implied warranty of
27  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
28  * Library General Public License for more details.
29  *
30  * You should have received a copy of the GNU Library General Public
31  * License along with this library; if not, write to the
32  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
33  * Boston, MA 02111-1307, USA.
34  */
35
36 #ifndef __PSPP_SHEET_VIEW_COLUMN_H__
37 #define __PSPP_SHEET_VIEW_COLUMN_H__
38
39 #include <gtk/gtk.h>
40
41 G_BEGIN_DECLS
42
43 #define PSPP_TYPE_SHEET_VIEW_COLUMN          (pspp_sheet_view_column_get_type ())
44 #define PSPP_SHEET_VIEW_COLUMN(obj)          (G_TYPE_CHECK_INSTANCE_CAST ((obj), PSPP_TYPE_SHEET_VIEW_COLUMN, PsppSheetViewColumn))
45 #define PSPP_SHEET_VIEW_COLUMN_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass), PSPP_TYPE_SHEET_VIEW_COLUMN, PsppSheetViewColumnClass))
46 #define PSPP_IS_SHEET_VIEW_COLUMN(obj)       (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PSPP_TYPE_SHEET_VIEW_COLUMN))
47 #define PSPP_IS_SHEET_VIEW_COLUMN_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), PSPP_TYPE_SHEET_VIEW_COLUMN))
48 #define PSPP_SHEET_VIEW_COLUMN_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS ((obj), PSPP_TYPE_SHEET_VIEW_COLUMN, PsppSheetViewColumnClass))
49
50 typedef struct _PsppSheetViewColumn      PsppSheetViewColumn;
51 typedef struct _PsppSheetViewColumnClass PsppSheetViewColumnClass;
52
53 typedef void (* PsppSheetCellDataFunc) (PsppSheetViewColumn *tree_column,
54                                         GtkCellRenderer   *cell,
55                                         GtkTreeModel      *tree_model,
56                                         GtkTreeIter       *iter,
57                                         gpointer           data);
58
59
60 struct _PsppSheetViewColumn
61 {
62   GObject parent;
63
64   GtkWidget *PSEAL (tree_view);
65   GtkWidget *PSEAL (button);
66   GtkWidget *PSEAL (child);
67   GtkWidget *PSEAL (arrow);
68   GtkWidget *PSEAL (alignment);
69   GdkWindow *PSEAL (window);
70   GtkCellEditable *PSEAL (editable_widget);
71   gfloat PSEAL (xalign);
72   guint PSEAL (property_changed_signal);
73   gint PSEAL (spacing);
74   GtkAllocation PSEAL (allocation);
75
76   /* Sizing fields */
77   /* see gtk+/doc/tree-column-sizing.txt for more information on them */
78   gint PSEAL (requested_width);
79   gint PSEAL (button_request);
80   gint PSEAL (resized_width);
81   gint PSEAL (width);
82   gint PSEAL (fixed_width);
83   gint PSEAL (min_width);
84   gint PSEAL (max_width);
85
86   /* dragging columns */
87   gint PSEAL (drag_x);
88   gint PSEAL (drag_y);
89
90   gchar *PSEAL (title);
91   GList *PSEAL (cell_list);
92
93   /* Sorting */
94   guint PSEAL (sort_clicked_signal);
95   guint PSEAL (sort_column_changed_signal);
96   gint PSEAL (sort_column_id);
97   GtkSortType PSEAL (sort_order);
98
99   /* Flags */
100   guint PSEAL (visible)             : 1;
101   guint PSEAL (resizable)           : 1;
102   guint PSEAL (clickable)           : 1;
103   guint PSEAL (dirty)               : 1;
104   guint PSEAL (show_sort_indicator) : 1;
105   guint PSEAL (maybe_reordered)     : 1;
106   guint PSEAL (reorderable)         : 1;
107   guint PSEAL (use_resized_width)   : 1;
108   guint PSEAL (expand)              : 1;
109   guint PSEAL (quick_edit)          : 1;
110   guint PSEAL (selected)            : 1;
111   guint PSEAL (selectable)          : 1;
112   guint PSEAL (row_head)            : 1;
113   guint PSEAL (tabbable)            : 1;
114 };
115
116 struct _PsppSheetViewColumnClass
117 {
118   GObjectClass parent_class;
119
120   gboolean (*clicked) (PsppSheetViewColumn *tree_column);
121   gboolean (*button_press_event) (PsppSheetViewColumn *,
122                                   GdkEventButton *);
123
124   /* Padding for future expansion */
125   void (*_gtk_reserved1) (void);
126   void (*_gtk_reserved2) (void);
127   void (*_gtk_reserved3) (void);
128   void (*_gtk_reserved4) (void);
129 };
130
131 GType                   pspp_sheet_view_column_get_type            (void) G_GNUC_CONST;
132 PsppSheetViewColumn      *pspp_sheet_view_column_new                 (void);
133 PsppSheetViewColumn      *pspp_sheet_view_column_new_with_attributes (const gchar             *title,
134                                                                   GtkCellRenderer         *cell,
135                                                                   ...) G_GNUC_NULL_TERMINATED;
136 void                    pspp_sheet_view_column_pack_start          (PsppSheetViewColumn       *tree_column,
137                                                                   GtkCellRenderer         *cell,
138                                                                   gboolean                 expand);
139 void                    pspp_sheet_view_column_pack_end            (PsppSheetViewColumn       *tree_column,
140                                                                   GtkCellRenderer         *cell,
141                                                                   gboolean                 expand);
142 void                    pspp_sheet_view_column_clear               (PsppSheetViewColumn       *tree_column);
143
144 GList                  *pspp_sheet_view_column_get_cell_renderers  (PsppSheetViewColumn       *tree_column);
145
146 void                    pspp_sheet_view_column_add_attribute       (PsppSheetViewColumn       *tree_column,
147                                                                   GtkCellRenderer         *cell_renderer,
148                                                                   const gchar             *attribute,
149                                                                   gint                     column);
150 void                    pspp_sheet_view_column_set_attributes      (PsppSheetViewColumn       *tree_column,
151                                                                   GtkCellRenderer         *cell_renderer,
152                                                                   ...) G_GNUC_NULL_TERMINATED;
153 void                    pspp_sheet_view_column_set_cell_data_func  (PsppSheetViewColumn       *tree_column,
154                                                                   GtkCellRenderer         *cell_renderer,
155                                                                   PsppSheetCellDataFunc      func,
156                                                                   gpointer                 func_data,
157                                                                   GDestroyNotify           destroy);
158 void                    pspp_sheet_view_column_clear_attributes    (PsppSheetViewColumn       *tree_column,
159                                                                   GtkCellRenderer         *cell_renderer);
160 void                    pspp_sheet_view_column_set_spacing         (PsppSheetViewColumn       *tree_column,
161                                                                   gint                     spacing);
162 gint                    pspp_sheet_view_column_get_spacing         (PsppSheetViewColumn       *tree_column);
163 void                    pspp_sheet_view_column_set_visible         (PsppSheetViewColumn       *tree_column,
164                                                                   gboolean                 visible);
165 gboolean                pspp_sheet_view_column_get_visible         (PsppSheetViewColumn       *tree_column);
166 void                    pspp_sheet_view_column_set_resizable       (PsppSheetViewColumn       *tree_column,
167                                                                   gboolean                 resizable);
168 gboolean                pspp_sheet_view_column_get_resizable       (PsppSheetViewColumn       *tree_column);
169 gint                    pspp_sheet_view_column_get_width           (PsppSheetViewColumn       *tree_column);
170 gint                    pspp_sheet_view_column_get_fixed_width     (PsppSheetViewColumn       *tree_column);
171 void                    pspp_sheet_view_column_set_fixed_width     (PsppSheetViewColumn       *tree_column,
172                                                                   gint                     fixed_width);
173 void                    pspp_sheet_view_column_set_min_width       (PsppSheetViewColumn       *tree_column,
174                                                                   gint                     min_width);
175 gint                    pspp_sheet_view_column_get_min_width       (PsppSheetViewColumn       *tree_column);
176 void                    pspp_sheet_view_column_set_max_width       (PsppSheetViewColumn       *tree_column,
177                                                                   gint                     max_width);
178 gint                    pspp_sheet_view_column_get_max_width       (PsppSheetViewColumn       *tree_column);
179 void                    pspp_sheet_view_column_clicked             (PsppSheetViewColumn       *tree_column);
180
181
182
183 /* Options for manipulating the column headers
184  */
185 void                    pspp_sheet_view_column_set_title           (PsppSheetViewColumn       *tree_column,
186                                                                   const gchar             *title);
187 const gchar   *         pspp_sheet_view_column_get_title           (PsppSheetViewColumn       *tree_column);
188 void                    pspp_sheet_view_column_set_expand          (PsppSheetViewColumn       *tree_column,
189                                                                   gboolean                 expand);
190 gboolean                pspp_sheet_view_column_get_expand          (PsppSheetViewColumn       *tree_column);
191 void                    pspp_sheet_view_column_set_clickable       (PsppSheetViewColumn       *tree_column,
192                                                                   gboolean                 clickable);
193 gboolean                pspp_sheet_view_column_get_clickable       (PsppSheetViewColumn       *tree_column);
194 void                    pspp_sheet_view_column_set_widget          (PsppSheetViewColumn       *tree_column,
195                                                                   GtkWidget               *widget);
196 GtkWidget              *pspp_sheet_view_column_get_widget          (PsppSheetViewColumn       *tree_column);
197 void                    pspp_sheet_view_column_set_alignment       (PsppSheetViewColumn       *tree_column,
198                                                                   gfloat                   xalign);
199 gfloat                  pspp_sheet_view_column_get_alignment       (PsppSheetViewColumn       *tree_column);
200 void                    pspp_sheet_view_column_set_reorderable     (PsppSheetViewColumn       *tree_column,
201                                                                   gboolean                 reorderable);
202 gboolean                pspp_sheet_view_column_get_reorderable     (PsppSheetViewColumn       *tree_column);
203
204 void                    pspp_sheet_view_column_set_quick_edit     (PsppSheetViewColumn       *tree_column,
205                                                                   gboolean                 quick_edit);
206 gboolean                pspp_sheet_view_column_get_quick_edit     (PsppSheetViewColumn       *tree_column);
207 void                    pspp_sheet_view_column_set_selected     (PsppSheetViewColumn       *tree_column,
208                                                                   gboolean                 selected);
209 gboolean                pspp_sheet_view_column_get_selected     (PsppSheetViewColumn       *tree_column);
210
211 void                    pspp_sheet_view_column_set_selectable     (PsppSheetViewColumn       *tree_column,
212                                                                   gboolean                 selectable);
213 gboolean                pspp_sheet_view_column_get_selectable     (PsppSheetViewColumn       *tree_column);
214 void                    pspp_sheet_view_column_set_row_head     (PsppSheetViewColumn       *tree_column,
215                                                                   gboolean                 row_head);
216 gboolean                pspp_sheet_view_column_get_row_head     (PsppSheetViewColumn       *tree_column);
217 void                    pspp_sheet_view_column_set_tabbable     (PsppSheetViewColumn       *tree_column,
218                                                                  gboolean                 tabbable);
219 gboolean                pspp_sheet_view_column_get_tabbable     (PsppSheetViewColumn       *tree_column);
220
221
222
223 /* You probably only want to use pspp_sheet_view_column_set_sort_column_id.  The
224  * other sorting functions exist primarily to let others do their own custom sorting.
225  */
226 void                    pspp_sheet_view_column_set_sort_column_id  (PsppSheetViewColumn       *tree_column,
227                                                                   gint                     sort_column_id);
228 gint                    pspp_sheet_view_column_get_sort_column_id  (PsppSheetViewColumn       *tree_column);
229 void                    pspp_sheet_view_column_set_sort_indicator  (PsppSheetViewColumn       *tree_column,
230                                                                   gboolean                 setting);
231 gboolean                pspp_sheet_view_column_get_sort_indicator  (PsppSheetViewColumn       *tree_column);
232 void                    pspp_sheet_view_column_set_sort_order      (PsppSheetViewColumn       *tree_column,
233                                                                   GtkSortType              order);
234 GtkSortType             pspp_sheet_view_column_get_sort_order      (PsppSheetViewColumn       *tree_column);
235
236
237 /* These functions are meant primarily for interaction between the PsppSheetView and the column.
238  */
239 void                    pspp_sheet_view_column_cell_set_cell_data  (PsppSheetViewColumn       *tree_column,
240                                                                   GtkTreeModel            *tree_model,
241                                                                   GtkTreeIter             *iter);
242 void                    pspp_sheet_view_column_cell_get_size       (PsppSheetViewColumn       *tree_column,
243                                                                   const GdkRectangle      *cell_area,
244                                                                   gint                    *x_offset,
245                                                                   gint                    *y_offset,
246                                                                   gint                    *width,
247                                                                   gint                    *height);
248 gboolean                pspp_sheet_view_column_cell_is_visible     (PsppSheetViewColumn       *tree_column);
249 void                    pspp_sheet_view_column_focus_cell          (PsppSheetViewColumn       *tree_column,
250                                                                   GtkCellRenderer         *cell);
251 gboolean                pspp_sheet_view_column_cell_get_position   (PsppSheetViewColumn       *tree_column,
252                                                                   GtkCellRenderer         *cell_renderer,
253                                                                   gint                    *start_pos,
254                                                                   gint                    *width);
255 void                    pspp_sheet_view_column_queue_resize        (PsppSheetViewColumn       *tree_column);
256 GtkWidget              *pspp_sheet_view_column_get_tree_view       (PsppSheetViewColumn       *tree_column);
257
258 void                    pspp_sheet_view_column_size_request       (PsppSheetViewColumn       *tree_column,
259                                                                     GtkRequisition             *requisition);
260
261 void                    pspp_sheet_view_column_size_allocate       (PsppSheetViewColumn       *tree_column,
262                                                                     GtkAllocation             *allocation);
263 gboolean                pspp_sheet_view_column_can_focus           (PsppSheetViewColumn       *tree_column);
264
265 G_END_DECLS
266
267
268 #endif /* __PSPP_SHEET_VIEW_COLUMN_H__ */