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