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