1 | /* gtktreeviewcolumn.h |
2 | * Copyright (C) 2000 Red Hat, Inc., Jonathan Blandford <jrb@redhat.com> |
3 | * |
4 | * This library is free software; you can redistribute it and/or |
5 | * modify it under the terms of the GNU Library General Public |
6 | * License as published by the Free Software Foundation; either |
7 | * version 2 of the License, or (at your option) any later version. |
8 | * |
9 | * This library 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 GNU |
12 | * Library General Public License for more details. |
13 | * |
14 | * You should have received a copy of the GNU Library General Public |
15 | * License along with this library. If not, see <http://www.gnu.org/licenses/>. |
16 | */ |
17 | |
18 | #ifndef __GTK_TREE_VIEW_COLUMN_H__ |
19 | #define __GTK_TREE_VIEW_COLUMN_H__ |
20 | |
21 | #if !defined (__GTK_H_INSIDE__) && !defined (GTK_COMPILATION) |
22 | #error "Only <gtk/gtk.h> can be included directly." |
23 | #endif |
24 | |
25 | #include <gtk/gtkcellrenderer.h> |
26 | #include <gtk/gtktreemodel.h> |
27 | #include <gtk/gtktreesortable.h> |
28 | #include <gtk/gtkcellarea.h> |
29 | |
30 | |
31 | G_BEGIN_DECLS |
32 | |
33 | |
34 | #define GTK_TYPE_TREE_VIEW_COLUMN (gtk_tree_view_column_get_type ()) |
35 | #define GTK_TREE_VIEW_COLUMN(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_TREE_VIEW_COLUMN, GtkTreeViewColumn)) |
36 | #define GTK_TREE_VIEW_COLUMN_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_TREE_VIEW_COLUMN, GtkTreeViewColumnClass)) |
37 | #define GTK_IS_TREE_VIEW_COLUMN(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_TREE_VIEW_COLUMN)) |
38 | #define GTK_IS_TREE_VIEW_COLUMN_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_TREE_VIEW_COLUMN)) |
39 | #define GTK_TREE_VIEW_COLUMN_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_TREE_VIEW_COLUMN, GtkTreeViewColumnClass)) |
40 | |
41 | typedef struct _GtkTreeViewColumn GtkTreeViewColumn; |
42 | typedef struct _GtkTreeViewColumnClass GtkTreeViewColumnClass; |
43 | typedef struct _GtkTreeViewColumnPrivate GtkTreeViewColumnPrivate; |
44 | |
45 | /** |
46 | * GtkTreeViewColumnSizing: |
47 | * @GTK_TREE_VIEW_COLUMN_GROW_ONLY: Columns only get bigger in reaction to changes in the model |
48 | * @GTK_TREE_VIEW_COLUMN_AUTOSIZE: Columns resize to be the optimal size everytime the model changes. |
49 | * @GTK_TREE_VIEW_COLUMN_FIXED: Columns are a fixed numbers of pixels wide. |
50 | * |
51 | * The sizing method the column uses to determine its width. Please note |
52 | * that @GTK_TREE_VIEW_COLUMN_AUTOSIZE are inefficient for large views, and |
53 | * can make columns appear choppy. |
54 | */ |
55 | typedef enum |
56 | { |
57 | GTK_TREE_VIEW_COLUMN_GROW_ONLY, |
58 | GTK_TREE_VIEW_COLUMN_AUTOSIZE, |
59 | GTK_TREE_VIEW_COLUMN_FIXED |
60 | } GtkTreeViewColumnSizing; |
61 | |
62 | /** |
63 | * GtkTreeCellDataFunc: |
64 | * @tree_column: A #GtkTreeViewColumn |
65 | * @cell: The #GtkCellRenderer that is being rendered by @tree_column |
66 | * @tree_model: The #GtkTreeModel being rendered |
67 | * @iter: A #GtkTreeIter of the current row rendered |
68 | * @data: (closure): user data |
69 | * |
70 | * A function to set the properties of a cell instead of just using the |
71 | * straight mapping between the cell and the model. This is useful for |
72 | * customizing the cell renderer. For example, a function might get an |
73 | * integer from the @tree_model, and render it to the “text” attribute of |
74 | * “cell” by converting it to its written equivalent. This is set by |
75 | * calling gtk_tree_view_column_set_cell_data_func() |
76 | */ |
77 | typedef void (* GtkTreeCellDataFunc) (GtkTreeViewColumn *tree_column, |
78 | GtkCellRenderer *cell, |
79 | GtkTreeModel *tree_model, |
80 | GtkTreeIter *iter, |
81 | gpointer data); |
82 | |
83 | |
84 | struct _GtkTreeViewColumn |
85 | { |
86 | GInitiallyUnowned parent_instance; |
87 | |
88 | GtkTreeViewColumnPrivate *priv; |
89 | }; |
90 | |
91 | struct _GtkTreeViewColumnClass |
92 | { |
93 | GInitiallyUnownedClass parent_class; |
94 | |
95 | void (*clicked) (GtkTreeViewColumn *tree_column); |
96 | |
97 | /* Padding for future expansion */ |
98 | void (*_gtk_reserved1) (void); |
99 | void (*_gtk_reserved2) (void); |
100 | void (*_gtk_reserved3) (void); |
101 | void (*_gtk_reserved4) (void); |
102 | }; |
103 | |
104 | GDK_AVAILABLE_IN_ALL |
105 | GType gtk_tree_view_column_get_type (void) G_GNUC_CONST; |
106 | GDK_AVAILABLE_IN_ALL |
107 | GtkTreeViewColumn *gtk_tree_view_column_new (void); |
108 | GDK_AVAILABLE_IN_ALL |
109 | GtkTreeViewColumn *gtk_tree_view_column_new_with_area (GtkCellArea *area); |
110 | GDK_AVAILABLE_IN_ALL |
111 | GtkTreeViewColumn *gtk_tree_view_column_new_with_attributes (const gchar *title, |
112 | GtkCellRenderer *cell, |
113 | ...) G_GNUC_NULL_TERMINATED; |
114 | GDK_AVAILABLE_IN_ALL |
115 | void gtk_tree_view_column_pack_start (GtkTreeViewColumn *tree_column, |
116 | GtkCellRenderer *cell, |
117 | gboolean expand); |
118 | GDK_AVAILABLE_IN_ALL |
119 | void gtk_tree_view_column_pack_end (GtkTreeViewColumn *tree_column, |
120 | GtkCellRenderer *cell, |
121 | gboolean expand); |
122 | GDK_AVAILABLE_IN_ALL |
123 | void gtk_tree_view_column_clear (GtkTreeViewColumn *tree_column); |
124 | GDK_AVAILABLE_IN_ALL |
125 | void gtk_tree_view_column_add_attribute (GtkTreeViewColumn *tree_column, |
126 | GtkCellRenderer *cell_renderer, |
127 | const gchar *attribute, |
128 | gint column); |
129 | GDK_AVAILABLE_IN_ALL |
130 | void gtk_tree_view_column_set_attributes (GtkTreeViewColumn *tree_column, |
131 | GtkCellRenderer *cell_renderer, |
132 | ...) G_GNUC_NULL_TERMINATED; |
133 | GDK_AVAILABLE_IN_ALL |
134 | void gtk_tree_view_column_set_cell_data_func (GtkTreeViewColumn *tree_column, |
135 | GtkCellRenderer *cell_renderer, |
136 | GtkTreeCellDataFunc func, |
137 | gpointer func_data, |
138 | GDestroyNotify destroy); |
139 | GDK_AVAILABLE_IN_ALL |
140 | void gtk_tree_view_column_clear_attributes (GtkTreeViewColumn *tree_column, |
141 | GtkCellRenderer *cell_renderer); |
142 | GDK_AVAILABLE_IN_ALL |
143 | void gtk_tree_view_column_set_spacing (GtkTreeViewColumn *tree_column, |
144 | gint spacing); |
145 | GDK_AVAILABLE_IN_ALL |
146 | gint gtk_tree_view_column_get_spacing (GtkTreeViewColumn *tree_column); |
147 | GDK_AVAILABLE_IN_ALL |
148 | void gtk_tree_view_column_set_visible (GtkTreeViewColumn *tree_column, |
149 | gboolean visible); |
150 | GDK_AVAILABLE_IN_ALL |
151 | gboolean gtk_tree_view_column_get_visible (GtkTreeViewColumn *tree_column); |
152 | GDK_AVAILABLE_IN_ALL |
153 | void gtk_tree_view_column_set_resizable (GtkTreeViewColumn *tree_column, |
154 | gboolean resizable); |
155 | GDK_AVAILABLE_IN_ALL |
156 | gboolean gtk_tree_view_column_get_resizable (GtkTreeViewColumn *tree_column); |
157 | GDK_AVAILABLE_IN_ALL |
158 | void gtk_tree_view_column_set_sizing (GtkTreeViewColumn *tree_column, |
159 | GtkTreeViewColumnSizing type); |
160 | GDK_AVAILABLE_IN_ALL |
161 | GtkTreeViewColumnSizing gtk_tree_view_column_get_sizing (GtkTreeViewColumn *tree_column); |
162 | GDK_AVAILABLE_IN_3_2 |
163 | gint gtk_tree_view_column_get_x_offset (GtkTreeViewColumn *tree_column); |
164 | GDK_AVAILABLE_IN_ALL |
165 | gint gtk_tree_view_column_get_width (GtkTreeViewColumn *tree_column); |
166 | GDK_AVAILABLE_IN_ALL |
167 | gint gtk_tree_view_column_get_fixed_width (GtkTreeViewColumn *tree_column); |
168 | GDK_AVAILABLE_IN_ALL |
169 | void gtk_tree_view_column_set_fixed_width (GtkTreeViewColumn *tree_column, |
170 | gint fixed_width); |
171 | GDK_AVAILABLE_IN_ALL |
172 | void gtk_tree_view_column_set_min_width (GtkTreeViewColumn *tree_column, |
173 | gint min_width); |
174 | GDK_AVAILABLE_IN_ALL |
175 | gint gtk_tree_view_column_get_min_width (GtkTreeViewColumn *tree_column); |
176 | GDK_AVAILABLE_IN_ALL |
177 | void gtk_tree_view_column_set_max_width (GtkTreeViewColumn *tree_column, |
178 | gint max_width); |
179 | GDK_AVAILABLE_IN_ALL |
180 | gint gtk_tree_view_column_get_max_width (GtkTreeViewColumn *tree_column); |
181 | GDK_AVAILABLE_IN_ALL |
182 | void gtk_tree_view_column_clicked (GtkTreeViewColumn *tree_column); |
183 | |
184 | |
185 | |
186 | /* Options for manipulating the column headers |
187 | */ |
188 | GDK_AVAILABLE_IN_ALL |
189 | void gtk_tree_view_column_set_title (GtkTreeViewColumn *tree_column, |
190 | const gchar *title); |
191 | GDK_AVAILABLE_IN_ALL |
192 | const gchar * gtk_tree_view_column_get_title (GtkTreeViewColumn *tree_column); |
193 | GDK_AVAILABLE_IN_ALL |
194 | void gtk_tree_view_column_set_expand (GtkTreeViewColumn *tree_column, |
195 | gboolean expand); |
196 | GDK_AVAILABLE_IN_ALL |
197 | gboolean gtk_tree_view_column_get_expand (GtkTreeViewColumn *tree_column); |
198 | GDK_AVAILABLE_IN_ALL |
199 | void gtk_tree_view_column_set_clickable (GtkTreeViewColumn *tree_column, |
200 | gboolean clickable); |
201 | GDK_AVAILABLE_IN_ALL |
202 | gboolean gtk_tree_view_column_get_clickable (GtkTreeViewColumn *tree_column); |
203 | GDK_AVAILABLE_IN_ALL |
204 | void gtk_tree_view_column_set_widget (GtkTreeViewColumn *tree_column, |
205 | GtkWidget *widget); |
206 | GDK_AVAILABLE_IN_ALL |
207 | GtkWidget *gtk_tree_view_column_get_widget (GtkTreeViewColumn *tree_column); |
208 | GDK_AVAILABLE_IN_ALL |
209 | void gtk_tree_view_column_set_alignment (GtkTreeViewColumn *tree_column, |
210 | gfloat xalign); |
211 | GDK_AVAILABLE_IN_ALL |
212 | gfloat gtk_tree_view_column_get_alignment (GtkTreeViewColumn *tree_column); |
213 | GDK_AVAILABLE_IN_ALL |
214 | void gtk_tree_view_column_set_reorderable (GtkTreeViewColumn *tree_column, |
215 | gboolean reorderable); |
216 | GDK_AVAILABLE_IN_ALL |
217 | gboolean gtk_tree_view_column_get_reorderable (GtkTreeViewColumn *tree_column); |
218 | |
219 | |
220 | |
221 | /* You probably only want to use gtk_tree_view_column_set_sort_column_id. The |
222 | * other sorting functions exist primarily to let others do their own custom sorting. |
223 | */ |
224 | GDK_AVAILABLE_IN_ALL |
225 | void gtk_tree_view_column_set_sort_column_id (GtkTreeViewColumn *tree_column, |
226 | gint sort_column_id); |
227 | GDK_AVAILABLE_IN_ALL |
228 | gint gtk_tree_view_column_get_sort_column_id (GtkTreeViewColumn *tree_column); |
229 | GDK_AVAILABLE_IN_ALL |
230 | void gtk_tree_view_column_set_sort_indicator (GtkTreeViewColumn *tree_column, |
231 | gboolean setting); |
232 | GDK_AVAILABLE_IN_ALL |
233 | gboolean gtk_tree_view_column_get_sort_indicator (GtkTreeViewColumn *tree_column); |
234 | GDK_AVAILABLE_IN_ALL |
235 | void gtk_tree_view_column_set_sort_order (GtkTreeViewColumn *tree_column, |
236 | GtkSortType order); |
237 | GDK_AVAILABLE_IN_ALL |
238 | GtkSortType gtk_tree_view_column_get_sort_order (GtkTreeViewColumn *tree_column); |
239 | |
240 | |
241 | /* These functions are meant primarily for interaction between the GtkTreeView and the column. |
242 | */ |
243 | GDK_AVAILABLE_IN_ALL |
244 | void gtk_tree_view_column_cell_set_cell_data (GtkTreeViewColumn *tree_column, |
245 | GtkTreeModel *tree_model, |
246 | GtkTreeIter *iter, |
247 | gboolean is_expander, |
248 | gboolean is_expanded); |
249 | GDK_AVAILABLE_IN_ALL |
250 | void gtk_tree_view_column_cell_get_size (GtkTreeViewColumn *tree_column, |
251 | const GdkRectangle *cell_area, |
252 | gint *x_offset, |
253 | gint *y_offset, |
254 | gint *width, |
255 | gint *height); |
256 | GDK_AVAILABLE_IN_ALL |
257 | gboolean gtk_tree_view_column_cell_is_visible (GtkTreeViewColumn *tree_column); |
258 | GDK_AVAILABLE_IN_ALL |
259 | void gtk_tree_view_column_focus_cell (GtkTreeViewColumn *tree_column, |
260 | GtkCellRenderer *cell); |
261 | GDK_AVAILABLE_IN_ALL |
262 | gboolean gtk_tree_view_column_cell_get_position (GtkTreeViewColumn *tree_column, |
263 | GtkCellRenderer *cell_renderer, |
264 | gint *x_offset, |
265 | gint *width); |
266 | GDK_AVAILABLE_IN_ALL |
267 | void gtk_tree_view_column_queue_resize (GtkTreeViewColumn *tree_column); |
268 | GDK_AVAILABLE_IN_ALL |
269 | GtkWidget *gtk_tree_view_column_get_tree_view (GtkTreeViewColumn *tree_column); |
270 | GDK_AVAILABLE_IN_ALL |
271 | GtkWidget *gtk_tree_view_column_get_button (GtkTreeViewColumn *tree_column); |
272 | |
273 | |
274 | G_END_DECLS |
275 | |
276 | |
277 | #endif /* __GTK_TREE_VIEW_COLUMN_H__ */ |
278 | |