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
31G_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
41typedef struct _GtkTreeViewColumn GtkTreeViewColumn;
42typedef struct _GtkTreeViewColumnClass GtkTreeViewColumnClass;
43typedef 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 */
55typedef 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 */
77typedef void (* GtkTreeCellDataFunc) (GtkTreeViewColumn *tree_column,
78 GtkCellRenderer *cell,
79 GtkTreeModel *tree_model,
80 GtkTreeIter *iter,
81 gpointer data);
82
83
84struct _GtkTreeViewColumn
85{
86 GInitiallyUnowned parent_instance;
87
88 GtkTreeViewColumnPrivate *priv;
89};
90
91struct _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
104GDK_AVAILABLE_IN_ALL
105GType gtk_tree_view_column_get_type (void) G_GNUC_CONST;
106GDK_AVAILABLE_IN_ALL
107GtkTreeViewColumn *gtk_tree_view_column_new (void);
108GDK_AVAILABLE_IN_ALL
109GtkTreeViewColumn *gtk_tree_view_column_new_with_area (GtkCellArea *area);
110GDK_AVAILABLE_IN_ALL
111GtkTreeViewColumn *gtk_tree_view_column_new_with_attributes (const gchar *title,
112 GtkCellRenderer *cell,
113 ...) G_GNUC_NULL_TERMINATED;
114GDK_AVAILABLE_IN_ALL
115void gtk_tree_view_column_pack_start (GtkTreeViewColumn *tree_column,
116 GtkCellRenderer *cell,
117 gboolean expand);
118GDK_AVAILABLE_IN_ALL
119void gtk_tree_view_column_pack_end (GtkTreeViewColumn *tree_column,
120 GtkCellRenderer *cell,
121 gboolean expand);
122GDK_AVAILABLE_IN_ALL
123void gtk_tree_view_column_clear (GtkTreeViewColumn *tree_column);
124GDK_AVAILABLE_IN_ALL
125void gtk_tree_view_column_add_attribute (GtkTreeViewColumn *tree_column,
126 GtkCellRenderer *cell_renderer,
127 const gchar *attribute,
128 gint column);
129GDK_AVAILABLE_IN_ALL
130void gtk_tree_view_column_set_attributes (GtkTreeViewColumn *tree_column,
131 GtkCellRenderer *cell_renderer,
132 ...) G_GNUC_NULL_TERMINATED;
133GDK_AVAILABLE_IN_ALL
134void 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);
139GDK_AVAILABLE_IN_ALL
140void gtk_tree_view_column_clear_attributes (GtkTreeViewColumn *tree_column,
141 GtkCellRenderer *cell_renderer);
142GDK_AVAILABLE_IN_ALL
143void gtk_tree_view_column_set_spacing (GtkTreeViewColumn *tree_column,
144 gint spacing);
145GDK_AVAILABLE_IN_ALL
146gint gtk_tree_view_column_get_spacing (GtkTreeViewColumn *tree_column);
147GDK_AVAILABLE_IN_ALL
148void gtk_tree_view_column_set_visible (GtkTreeViewColumn *tree_column,
149 gboolean visible);
150GDK_AVAILABLE_IN_ALL
151gboolean gtk_tree_view_column_get_visible (GtkTreeViewColumn *tree_column);
152GDK_AVAILABLE_IN_ALL
153void gtk_tree_view_column_set_resizable (GtkTreeViewColumn *tree_column,
154 gboolean resizable);
155GDK_AVAILABLE_IN_ALL
156gboolean gtk_tree_view_column_get_resizable (GtkTreeViewColumn *tree_column);
157GDK_AVAILABLE_IN_ALL
158void gtk_tree_view_column_set_sizing (GtkTreeViewColumn *tree_column,
159 GtkTreeViewColumnSizing type);
160GDK_AVAILABLE_IN_ALL
161GtkTreeViewColumnSizing gtk_tree_view_column_get_sizing (GtkTreeViewColumn *tree_column);
162GDK_AVAILABLE_IN_3_2
163gint gtk_tree_view_column_get_x_offset (GtkTreeViewColumn *tree_column);
164GDK_AVAILABLE_IN_ALL
165gint gtk_tree_view_column_get_width (GtkTreeViewColumn *tree_column);
166GDK_AVAILABLE_IN_ALL
167gint gtk_tree_view_column_get_fixed_width (GtkTreeViewColumn *tree_column);
168GDK_AVAILABLE_IN_ALL
169void gtk_tree_view_column_set_fixed_width (GtkTreeViewColumn *tree_column,
170 gint fixed_width);
171GDK_AVAILABLE_IN_ALL
172void gtk_tree_view_column_set_min_width (GtkTreeViewColumn *tree_column,
173 gint min_width);
174GDK_AVAILABLE_IN_ALL
175gint gtk_tree_view_column_get_min_width (GtkTreeViewColumn *tree_column);
176GDK_AVAILABLE_IN_ALL
177void gtk_tree_view_column_set_max_width (GtkTreeViewColumn *tree_column,
178 gint max_width);
179GDK_AVAILABLE_IN_ALL
180gint gtk_tree_view_column_get_max_width (GtkTreeViewColumn *tree_column);
181GDK_AVAILABLE_IN_ALL
182void gtk_tree_view_column_clicked (GtkTreeViewColumn *tree_column);
183
184
185
186/* Options for manipulating the column headers
187 */
188GDK_AVAILABLE_IN_ALL
189void gtk_tree_view_column_set_title (GtkTreeViewColumn *tree_column,
190 const gchar *title);
191GDK_AVAILABLE_IN_ALL
192const gchar * gtk_tree_view_column_get_title (GtkTreeViewColumn *tree_column);
193GDK_AVAILABLE_IN_ALL
194void gtk_tree_view_column_set_expand (GtkTreeViewColumn *tree_column,
195 gboolean expand);
196GDK_AVAILABLE_IN_ALL
197gboolean gtk_tree_view_column_get_expand (GtkTreeViewColumn *tree_column);
198GDK_AVAILABLE_IN_ALL
199void gtk_tree_view_column_set_clickable (GtkTreeViewColumn *tree_column,
200 gboolean clickable);
201GDK_AVAILABLE_IN_ALL
202gboolean gtk_tree_view_column_get_clickable (GtkTreeViewColumn *tree_column);
203GDK_AVAILABLE_IN_ALL
204void gtk_tree_view_column_set_widget (GtkTreeViewColumn *tree_column,
205 GtkWidget *widget);
206GDK_AVAILABLE_IN_ALL
207GtkWidget *gtk_tree_view_column_get_widget (GtkTreeViewColumn *tree_column);
208GDK_AVAILABLE_IN_ALL
209void gtk_tree_view_column_set_alignment (GtkTreeViewColumn *tree_column,
210 gfloat xalign);
211GDK_AVAILABLE_IN_ALL
212gfloat gtk_tree_view_column_get_alignment (GtkTreeViewColumn *tree_column);
213GDK_AVAILABLE_IN_ALL
214void gtk_tree_view_column_set_reorderable (GtkTreeViewColumn *tree_column,
215 gboolean reorderable);
216GDK_AVAILABLE_IN_ALL
217gboolean 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 */
224GDK_AVAILABLE_IN_ALL
225void gtk_tree_view_column_set_sort_column_id (GtkTreeViewColumn *tree_column,
226 gint sort_column_id);
227GDK_AVAILABLE_IN_ALL
228gint gtk_tree_view_column_get_sort_column_id (GtkTreeViewColumn *tree_column);
229GDK_AVAILABLE_IN_ALL
230void gtk_tree_view_column_set_sort_indicator (GtkTreeViewColumn *tree_column,
231 gboolean setting);
232GDK_AVAILABLE_IN_ALL
233gboolean gtk_tree_view_column_get_sort_indicator (GtkTreeViewColumn *tree_column);
234GDK_AVAILABLE_IN_ALL
235void gtk_tree_view_column_set_sort_order (GtkTreeViewColumn *tree_column,
236 GtkSortType order);
237GDK_AVAILABLE_IN_ALL
238GtkSortType 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 */
243GDK_AVAILABLE_IN_ALL
244void 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);
249GDK_AVAILABLE_IN_ALL
250void 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);
256GDK_AVAILABLE_IN_ALL
257gboolean gtk_tree_view_column_cell_is_visible (GtkTreeViewColumn *tree_column);
258GDK_AVAILABLE_IN_ALL
259void gtk_tree_view_column_focus_cell (GtkTreeViewColumn *tree_column,
260 GtkCellRenderer *cell);
261GDK_AVAILABLE_IN_ALL
262gboolean gtk_tree_view_column_cell_get_position (GtkTreeViewColumn *tree_column,
263 GtkCellRenderer *cell_renderer,
264 gint *x_offset,
265 gint *width);
266GDK_AVAILABLE_IN_ALL
267void gtk_tree_view_column_queue_resize (GtkTreeViewColumn *tree_column);
268GDK_AVAILABLE_IN_ALL
269GtkWidget *gtk_tree_view_column_get_tree_view (GtkTreeViewColumn *tree_column);
270GDK_AVAILABLE_IN_ALL
271GtkWidget *gtk_tree_view_column_get_button (GtkTreeViewColumn *tree_column);
272
273
274G_END_DECLS
275
276
277#endif /* __GTK_TREE_VIEW_COLUMN_H__ */
278

source code of include/gtk-3.0/gtk/gtktreeviewcolumn.h