f3aa94f6e5fd02f4081ee89e27ee0c45bd75b926
[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 (alignment);
68   GdkWindow *PSEAL (window);
69   GtkCellEditable *PSEAL (editable_widget);
70   gfloat PSEAL (xalign);
71   guint PSEAL (property_changed_signal);
72   gint PSEAL (spacing);
73   GtkAllocation PSEAL (allocation);
74
75   /* Sizing fields */
76   /* see gtk+/doc/tree-column-sizing.txt for more information on them */
77   gint PSEAL (requested_width);
78   gint PSEAL (button_request);
79   gint PSEAL (resized_width);
80   gint PSEAL (width);
81   gint PSEAL (fixed_width);
82   gint PSEAL (min_width);
83   gint PSEAL (max_width);
84
85   /* dragging columns */
86   gint PSEAL (drag_x);
87   gint PSEAL (drag_y);
88
89   gchar *PSEAL (title);
90   GList *PSEAL (cell_list);
91
92   /* Sorting */
93   guint PSEAL (sort_clicked_signal);
94   guint PSEAL (sort_column_changed_signal);
95   gint PSEAL (sort_column_id);
96   GtkSortType PSEAL (sort_order);
97
98   /* Flags */
99   guint PSEAL (visible)             : 1;
100   guint PSEAL (resizable)           : 1;
101   guint PSEAL (clickable)           : 1;
102   guint PSEAL (dirty)               : 1;
103   guint PSEAL (show_sort_indicator) : 1;
104   guint PSEAL (maybe_reordered)     : 1;
105   guint PSEAL (reorderable)         : 1;
106   guint PSEAL (use_resized_width)   : 1;
107   guint PSEAL (expand)              : 1;
108   guint PSEAL (quick_edit)          : 1;
109   guint PSEAL (selected)            : 1;
110   guint PSEAL (selectable)          : 1;
111   guint PSEAL (row_head)            : 1;
112   guint PSEAL (tabbable)            : 1;
113 };
114
115 struct _PsppSheetViewColumnClass
116 {
117   GObjectClass parent_class;
118
119   gboolean (*clicked) (PsppSheetViewColumn *tree_column);
120   gboolean (*button_press_event) (PsppSheetViewColumn *,
121                                   GdkEventButton *);
122
123   /* Padding for future expansion */
124   void (*_gtk_reserved1) (void);
125   void (*_gtk_reserved2) (void);
126   void (*_gtk_reserved3) (void);
127   void (*_gtk_reserved4) (void);
128 };
129
130 GType                   pspp_sheet_view_column_get_type            (void) G_GNUC_CONST;
131 PsppSheetViewColumn      *pspp_sheet_view_column_new                 (void);
132 PsppSheetViewColumn      *pspp_sheet_view_column_new_with_attributes (const gchar             *title,
133                                                                   GtkCellRenderer         *cell,
134                                                                   ...) G_GNUC_NULL_TERMINATED;
135 void                    pspp_sheet_view_column_pack_start          (PsppSheetViewColumn       *tree_column,
136                                                                   GtkCellRenderer         *cell,
137                                                                   gboolean                 expand);
138 void                    pspp_sheet_view_column_pack_end            (PsppSheetViewColumn       *tree_column,
139                                                                   GtkCellRenderer         *cell,
140                                                                   gboolean                 expand);
141 void                    pspp_sheet_view_column_clear               (PsppSheetViewColumn       *tree_column);
142
143 GList                  *pspp_sheet_view_column_get_cell_renderers  (PsppSheetViewColumn       *tree_column);
144
145 void                    pspp_sheet_view_column_add_attribute       (PsppSheetViewColumn       *tree_column,
146                                                                   GtkCellRenderer         *cell_renderer,
147                                                                   const gchar             *attribute,
148                                                                   gint                     column);
149 void                    pspp_sheet_view_column_set_attributes      (PsppSheetViewColumn       *tree_column,
150                                                                   GtkCellRenderer         *cell_renderer,
151                                                                   ...) G_GNUC_NULL_TERMINATED;
152 void                    pspp_sheet_view_column_set_cell_data_func  (PsppSheetViewColumn       *tree_column,
153                                                                   GtkCellRenderer         *cell_renderer,
154                                                                   PsppSheetCellDataFunc      func,
155                                                                   gpointer                 func_data,
156                                                                   GDestroyNotify           destroy);
157 void                    pspp_sheet_view_column_clear_attributes    (PsppSheetViewColumn       *tree_column,
158                                                                   GtkCellRenderer         *cell_renderer);
159 void                    pspp_sheet_view_column_set_spacing         (PsppSheetViewColumn       *tree_column,
160                                                                   gint                     spacing);
161 gint                    pspp_sheet_view_column_get_spacing         (PsppSheetViewColumn       *tree_column);
162 void                    pspp_sheet_view_column_set_visible         (PsppSheetViewColumn       *tree_column,
163                                                                   gboolean                 visible);
164 gboolean                pspp_sheet_view_column_get_visible         (PsppSheetViewColumn       *tree_column);
165 void                    pspp_sheet_view_column_set_resizable       (PsppSheetViewColumn       *tree_column,
166                                                                   gboolean                 resizable);
167 gboolean                pspp_sheet_view_column_get_resizable       (PsppSheetViewColumn       *tree_column);
168 gint                    pspp_sheet_view_column_get_width           (PsppSheetViewColumn       *tree_column);
169 gint                    pspp_sheet_view_column_get_fixed_width     (PsppSheetViewColumn       *tree_column);
170 void                    pspp_sheet_view_column_set_fixed_width     (PsppSheetViewColumn       *tree_column,
171                                                                   gint                     fixed_width);
172 void                    pspp_sheet_view_column_set_min_width       (PsppSheetViewColumn       *tree_column,
173                                                                   gint                     min_width);
174 gint                    pspp_sheet_view_column_get_min_width       (PsppSheetViewColumn       *tree_column);
175 void                    pspp_sheet_view_column_set_max_width       (PsppSheetViewColumn       *tree_column,
176                                                                   gint                     max_width);
177 gint                    pspp_sheet_view_column_get_max_width       (PsppSheetViewColumn       *tree_column);
178 void                    pspp_sheet_view_column_clicked             (PsppSheetViewColumn       *tree_column);
179
180
181
182 /* Options for manipulating the column headers
183  */
184 void                    pspp_sheet_view_column_set_title           (PsppSheetViewColumn       *tree_column,
185                                                                   const gchar             *title);
186 const gchar   *         pspp_sheet_view_column_get_title           (PsppSheetViewColumn       *tree_column);
187 void                    pspp_sheet_view_column_set_expand          (PsppSheetViewColumn       *tree_column,
188                                                                   gboolean                 expand);
189 gboolean                pspp_sheet_view_column_get_expand          (PsppSheetViewColumn       *tree_column);
190 void                    pspp_sheet_view_column_set_clickable       (PsppSheetViewColumn       *tree_column,
191                                                                   gboolean                 clickable);
192 gboolean                pspp_sheet_view_column_get_clickable       (PsppSheetViewColumn       *tree_column);
193 void                    pspp_sheet_view_column_set_widget          (PsppSheetViewColumn       *tree_column,
194                                                                   GtkWidget               *widget);
195 GtkWidget              *pspp_sheet_view_column_get_widget          (PsppSheetViewColumn       *tree_column);
196 void                    pspp_sheet_view_column_set_alignment       (PsppSheetViewColumn       *tree_column,
197                                                                   gfloat                   xalign);
198 gfloat                  pspp_sheet_view_column_get_alignment       (PsppSheetViewColumn       *tree_column);
199 void                    pspp_sheet_view_column_set_reorderable     (PsppSheetViewColumn       *tree_column,
200                                                                   gboolean                 reorderable);
201 gboolean                pspp_sheet_view_column_get_reorderable     (PsppSheetViewColumn       *tree_column);
202
203 void                    pspp_sheet_view_column_set_quick_edit     (PsppSheetViewColumn       *tree_column,
204                                                                   gboolean                 quick_edit);
205 gboolean                pspp_sheet_view_column_get_quick_edit     (PsppSheetViewColumn       *tree_column);
206 void                    pspp_sheet_view_column_set_selected     (PsppSheetViewColumn       *tree_column,
207                                                                   gboolean                 selected);
208 gboolean                pspp_sheet_view_column_get_selected     (PsppSheetViewColumn       *tree_column);
209
210 void                    pspp_sheet_view_column_set_selectable     (PsppSheetViewColumn       *tree_column,
211                                                                   gboolean                 selectable);
212 gboolean                pspp_sheet_view_column_get_selectable     (PsppSheetViewColumn       *tree_column);
213 void                    pspp_sheet_view_column_set_row_head     (PsppSheetViewColumn       *tree_column,
214                                                                   gboolean                 row_head);
215 gboolean                pspp_sheet_view_column_get_row_head     (PsppSheetViewColumn       *tree_column);
216 void                    pspp_sheet_view_column_set_tabbable     (PsppSheetViewColumn       *tree_column,
217                                                                  gboolean                 tabbable);
218 gboolean                pspp_sheet_view_column_get_tabbable     (PsppSheetViewColumn       *tree_column);
219
220
221
222 /* You probably only want to use pspp_sheet_view_column_set_sort_column_id.  The
223  * other sorting functions exist primarily to let others do their own custom sorting.
224  */
225 void                    pspp_sheet_view_column_set_sort_column_id  (PsppSheetViewColumn       *tree_column,
226                                                                   gint                     sort_column_id);
227 gint                    pspp_sheet_view_column_get_sort_column_id  (PsppSheetViewColumn       *tree_column);
228 void                    pspp_sheet_view_column_set_sort_indicator  (PsppSheetViewColumn       *tree_column,
229                                                                   gboolean                 setting);
230 gboolean                pspp_sheet_view_column_get_sort_indicator  (PsppSheetViewColumn       *tree_column);
231 void                    pspp_sheet_view_column_set_sort_order      (PsppSheetViewColumn       *tree_column,
232                                                                   GtkSortType              order);
233 GtkSortType             pspp_sheet_view_column_get_sort_order      (PsppSheetViewColumn       *tree_column);
234
235
236 /* These functions are meant primarily for interaction between the PsppSheetView and the column.
237  */
238 void                    pspp_sheet_view_column_cell_set_cell_data  (PsppSheetViewColumn       *tree_column,
239                                                                   GtkTreeModel            *tree_model,
240                                                                   GtkTreeIter             *iter);
241 void                    pspp_sheet_view_column_cell_get_size       (PsppSheetViewColumn       *tree_column,
242                                                                   const GdkRectangle      *cell_area,
243                                                                   gint                    *x_offset,
244                                                                   gint                    *y_offset,
245                                                                   gint                    *width,
246                                                                   gint                    *height);
247 gboolean                pspp_sheet_view_column_cell_is_visible     (PsppSheetViewColumn       *tree_column);
248 void                    pspp_sheet_view_column_focus_cell          (PsppSheetViewColumn       *tree_column,
249                                                                   GtkCellRenderer         *cell);
250 gboolean                pspp_sheet_view_column_cell_get_position   (PsppSheetViewColumn       *tree_column,
251                                                                   GtkCellRenderer         *cell_renderer,
252                                                                   gint                    *start_pos,
253                                                                   gint                    *width);
254 void                    pspp_sheet_view_column_queue_resize        (PsppSheetViewColumn       *tree_column);
255 GtkWidget              *pspp_sheet_view_column_get_tree_view       (PsppSheetViewColumn       *tree_column);
256
257 void                    pspp_sheet_view_column_size_request       (PsppSheetViewColumn       *tree_column,
258                                                                     GtkRequisition             *requisition);
259
260 void                    pspp_sheet_view_column_size_allocate       (PsppSheetViewColumn       *tree_column,
261                                                                     GtkAllocation             *allocation);
262 gboolean                pspp_sheet_view_column_can_focus           (PsppSheetViewColumn       *tree_column);
263
264 G_END_DECLS
265
266
267 #endif /* __PSPP_SHEET_VIEW_COLUMN_H__ */