1 | /* gtkcellrenderer.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_CELL_RENDERER_H__ |
19 | #define __GTK_CELL_RENDERER_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/gtkcelleditable.h> |
26 | |
27 | G_BEGIN_DECLS |
28 | |
29 | |
30 | /** |
31 | * GtkCellRendererState: |
32 | * @GTK_CELL_RENDERER_SELECTED: The cell is currently selected, and |
33 | * probably has a selection colored background to render to. |
34 | * @GTK_CELL_RENDERER_PRELIT: The mouse is hovering over the cell. |
35 | * @GTK_CELL_RENDERER_INSENSITIVE: The cell is drawn in an insensitive manner |
36 | * @GTK_CELL_RENDERER_SORTED: The cell is in a sorted row |
37 | * @GTK_CELL_RENDERER_FOCUSED: The cell is in the focus row. |
38 | * @GTK_CELL_RENDERER_EXPANDABLE: The cell is in a row that can be expanded. Since 3.4 |
39 | * @GTK_CELL_RENDERER_EXPANDED: The cell is in a row that is expanded. Since 3.4 |
40 | * |
41 | * Tells how a cell is to be rendered. |
42 | */ |
43 | typedef enum |
44 | { |
45 | GTK_CELL_RENDERER_SELECTED = 1 << 0, |
46 | GTK_CELL_RENDERER_PRELIT = 1 << 1, |
47 | GTK_CELL_RENDERER_INSENSITIVE = 1 << 2, |
48 | /* this flag means the cell is in the sort column/row */ |
49 | GTK_CELL_RENDERER_SORTED = 1 << 3, |
50 | GTK_CELL_RENDERER_FOCUSED = 1 << 4, |
51 | GTK_CELL_RENDERER_EXPANDABLE = 1 << 5, |
52 | GTK_CELL_RENDERER_EXPANDED = 1 << 6 |
53 | } GtkCellRendererState; |
54 | |
55 | /** |
56 | * GtkCellRendererMode: |
57 | * @GTK_CELL_RENDERER_MODE_INERT: The cell is just for display |
58 | * and cannot be interacted with. Note that this doesn’t mean that eg. the |
59 | * row being drawn can’t be selected -- just that a particular element of |
60 | * it cannot be individually modified. |
61 | * @GTK_CELL_RENDERER_MODE_ACTIVATABLE: The cell can be clicked. |
62 | * @GTK_CELL_RENDERER_MODE_EDITABLE: The cell can be edited or otherwise modified. |
63 | * |
64 | * Identifies how the user can interact with a particular cell. |
65 | */ |
66 | typedef enum |
67 | { |
68 | GTK_CELL_RENDERER_MODE_INERT, |
69 | GTK_CELL_RENDERER_MODE_ACTIVATABLE, |
70 | GTK_CELL_RENDERER_MODE_EDITABLE |
71 | } GtkCellRendererMode; |
72 | |
73 | #define GTK_TYPE_CELL_RENDERER (gtk_cell_renderer_get_type ()) |
74 | #define GTK_CELL_RENDERER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_CELL_RENDERER, GtkCellRenderer)) |
75 | #define GTK_CELL_RENDERER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_CELL_RENDERER, GtkCellRendererClass)) |
76 | #define GTK_IS_CELL_RENDERER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_CELL_RENDERER)) |
77 | #define GTK_IS_CELL_RENDERER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_CELL_RENDERER)) |
78 | #define GTK_CELL_RENDERER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_CELL_RENDERER, GtkCellRendererClass)) |
79 | |
80 | typedef struct _GtkCellRenderer GtkCellRenderer; |
81 | typedef struct _GtkCellRendererPrivate GtkCellRendererPrivate; |
82 | typedef struct _GtkCellRendererClass GtkCellRendererClass; |
83 | typedef struct _GtkCellRendererClassPrivate GtkCellRendererClassPrivate; |
84 | |
85 | struct _GtkCellRenderer |
86 | { |
87 | GInitiallyUnowned parent_instance; |
88 | |
89 | /*< private >*/ |
90 | GtkCellRendererPrivate *priv; |
91 | }; |
92 | |
93 | /** |
94 | * GtkCellRendererClass: |
95 | * @get_request_mode: Called to gets whether the cell renderer prefers |
96 | * a height-for-width layout or a width-for-height layout. |
97 | * @get_preferred_width: Called to get a renderer’s natural width. |
98 | * @get_preferred_height_for_width: Called to get a renderer’s natural height for width. |
99 | * @get_preferred_height: Called to get a renderer’s natural height. |
100 | * @get_preferred_width_for_height: Called to get a renderer’s natural width for height. |
101 | * @get_aligned_area: Called to get the aligned area used by @cell inside @cell_area. |
102 | * @get_size: Called to get the width and height needed to render the cell. Deprecated: 3.0. |
103 | * @render: Called to render the content of the #GtkCellRenderer. |
104 | * @activate: Called to activate the content of the #GtkCellRenderer. |
105 | * @start_editing: Called to initiate editing the content of the #GtkCellRenderer. |
106 | * @editing_canceled: Signal gets emitted when the user cancels the process of editing a cell. |
107 | * @editing_started: Signal gets emitted when a cell starts to be edited. |
108 | */ |
109 | struct _GtkCellRendererClass |
110 | { |
111 | /*< private >*/ |
112 | GInitiallyUnownedClass parent_class; |
113 | |
114 | /*< public >*/ |
115 | |
116 | /* vtable - not signals */ |
117 | GtkSizeRequestMode (* get_request_mode) (GtkCellRenderer *cell); |
118 | void (* get_preferred_width) (GtkCellRenderer *cell, |
119 | GtkWidget *widget, |
120 | gint *minimum_size, |
121 | gint *natural_size); |
122 | void (* get_preferred_height_for_width) (GtkCellRenderer *cell, |
123 | GtkWidget *widget, |
124 | gint width, |
125 | gint *minimum_height, |
126 | gint *natural_height); |
127 | void (* get_preferred_height) (GtkCellRenderer *cell, |
128 | GtkWidget *widget, |
129 | gint *minimum_size, |
130 | gint *natural_size); |
131 | void (* get_preferred_width_for_height) (GtkCellRenderer *cell, |
132 | GtkWidget *widget, |
133 | gint height, |
134 | gint *minimum_width, |
135 | gint *natural_width); |
136 | void (* get_aligned_area) (GtkCellRenderer *cell, |
137 | GtkWidget *widget, |
138 | GtkCellRendererState flags, |
139 | const GdkRectangle *cell_area, |
140 | GdkRectangle *aligned_area); |
141 | void (* get_size) (GtkCellRenderer *cell, |
142 | GtkWidget *widget, |
143 | const GdkRectangle *cell_area, |
144 | gint *x_offset, |
145 | gint *y_offset, |
146 | gint *width, |
147 | gint *height); |
148 | void (* render) (GtkCellRenderer *cell, |
149 | cairo_t *cr, |
150 | GtkWidget *widget, |
151 | const GdkRectangle *background_area, |
152 | const GdkRectangle *cell_area, |
153 | GtkCellRendererState flags); |
154 | gboolean (* activate) (GtkCellRenderer *cell, |
155 | GdkEvent *event, |
156 | GtkWidget *widget, |
157 | const gchar *path, |
158 | const GdkRectangle *background_area, |
159 | const GdkRectangle *cell_area, |
160 | GtkCellRendererState flags); |
161 | GtkCellEditable * (* start_editing) (GtkCellRenderer *cell, |
162 | GdkEvent *event, |
163 | GtkWidget *widget, |
164 | const gchar *path, |
165 | const GdkRectangle *background_area, |
166 | const GdkRectangle *cell_area, |
167 | GtkCellRendererState flags); |
168 | |
169 | /* Signals */ |
170 | void (* editing_canceled) (GtkCellRenderer *cell); |
171 | void (* editing_started) (GtkCellRenderer *cell, |
172 | GtkCellEditable *editable, |
173 | const gchar *path); |
174 | |
175 | /*< private >*/ |
176 | |
177 | GtkCellRendererClassPrivate *priv; |
178 | |
179 | /* Padding for future expansion */ |
180 | void (*_gtk_reserved2) (void); |
181 | void (*_gtk_reserved3) (void); |
182 | void (*_gtk_reserved4) (void); |
183 | }; |
184 | |
185 | GDK_AVAILABLE_IN_ALL |
186 | GType gtk_cell_renderer_get_type (void) G_GNUC_CONST; |
187 | |
188 | GDK_AVAILABLE_IN_ALL |
189 | GtkSizeRequestMode gtk_cell_renderer_get_request_mode (GtkCellRenderer *cell); |
190 | GDK_AVAILABLE_IN_ALL |
191 | void gtk_cell_renderer_get_preferred_width (GtkCellRenderer *cell, |
192 | GtkWidget *widget, |
193 | gint *minimum_size, |
194 | gint *natural_size); |
195 | GDK_AVAILABLE_IN_ALL |
196 | void gtk_cell_renderer_get_preferred_height_for_width (GtkCellRenderer *cell, |
197 | GtkWidget *widget, |
198 | gint width, |
199 | gint *minimum_height, |
200 | gint *natural_height); |
201 | GDK_AVAILABLE_IN_ALL |
202 | void gtk_cell_renderer_get_preferred_height (GtkCellRenderer *cell, |
203 | GtkWidget *widget, |
204 | gint *minimum_size, |
205 | gint *natural_size); |
206 | GDK_AVAILABLE_IN_ALL |
207 | void gtk_cell_renderer_get_preferred_width_for_height (GtkCellRenderer *cell, |
208 | GtkWidget *widget, |
209 | gint height, |
210 | gint *minimum_width, |
211 | gint *natural_width); |
212 | GDK_AVAILABLE_IN_ALL |
213 | void gtk_cell_renderer_get_preferred_size (GtkCellRenderer *cell, |
214 | GtkWidget *widget, |
215 | GtkRequisition *minimum_size, |
216 | GtkRequisition *natural_size); |
217 | GDK_AVAILABLE_IN_ALL |
218 | void gtk_cell_renderer_get_aligned_area (GtkCellRenderer *cell, |
219 | GtkWidget *widget, |
220 | GtkCellRendererState flags, |
221 | const GdkRectangle *cell_area, |
222 | GdkRectangle *aligned_area); |
223 | |
224 | GDK_DEPRECATED_IN_3_0_FOR(gtk_cell_renderer_get_preferred_size) |
225 | void gtk_cell_renderer_get_size (GtkCellRenderer *cell, |
226 | GtkWidget *widget, |
227 | const GdkRectangle *cell_area, |
228 | gint *x_offset, |
229 | gint *y_offset, |
230 | gint *width, |
231 | gint *height); |
232 | GDK_AVAILABLE_IN_ALL |
233 | void gtk_cell_renderer_render (GtkCellRenderer *cell, |
234 | cairo_t *cr, |
235 | GtkWidget *widget, |
236 | const GdkRectangle *background_area, |
237 | const GdkRectangle *cell_area, |
238 | GtkCellRendererState flags); |
239 | GDK_AVAILABLE_IN_ALL |
240 | gboolean gtk_cell_renderer_activate (GtkCellRenderer *cell, |
241 | GdkEvent *event, |
242 | GtkWidget *widget, |
243 | const gchar *path, |
244 | const GdkRectangle *background_area, |
245 | const GdkRectangle *cell_area, |
246 | GtkCellRendererState flags); |
247 | GDK_AVAILABLE_IN_ALL |
248 | GtkCellEditable *gtk_cell_renderer_start_editing (GtkCellRenderer *cell, |
249 | GdkEvent *event, |
250 | GtkWidget *widget, |
251 | const gchar *path, |
252 | const GdkRectangle *background_area, |
253 | const GdkRectangle *cell_area, |
254 | GtkCellRendererState flags); |
255 | |
256 | GDK_AVAILABLE_IN_ALL |
257 | void gtk_cell_renderer_set_fixed_size (GtkCellRenderer *cell, |
258 | gint width, |
259 | gint height); |
260 | GDK_AVAILABLE_IN_ALL |
261 | void gtk_cell_renderer_get_fixed_size (GtkCellRenderer *cell, |
262 | gint *width, |
263 | gint *height); |
264 | |
265 | GDK_AVAILABLE_IN_ALL |
266 | void gtk_cell_renderer_set_alignment (GtkCellRenderer *cell, |
267 | gfloat xalign, |
268 | gfloat yalign); |
269 | GDK_AVAILABLE_IN_ALL |
270 | void gtk_cell_renderer_get_alignment (GtkCellRenderer *cell, |
271 | gfloat *xalign, |
272 | gfloat *yalign); |
273 | |
274 | GDK_AVAILABLE_IN_ALL |
275 | void gtk_cell_renderer_set_padding (GtkCellRenderer *cell, |
276 | gint xpad, |
277 | gint ypad); |
278 | GDK_AVAILABLE_IN_ALL |
279 | void gtk_cell_renderer_get_padding (GtkCellRenderer *cell, |
280 | gint *xpad, |
281 | gint *ypad); |
282 | |
283 | GDK_AVAILABLE_IN_ALL |
284 | void gtk_cell_renderer_set_visible (GtkCellRenderer *cell, |
285 | gboolean visible); |
286 | GDK_AVAILABLE_IN_ALL |
287 | gboolean gtk_cell_renderer_get_visible (GtkCellRenderer *cell); |
288 | |
289 | GDK_AVAILABLE_IN_ALL |
290 | void gtk_cell_renderer_set_sensitive (GtkCellRenderer *cell, |
291 | gboolean sensitive); |
292 | GDK_AVAILABLE_IN_ALL |
293 | gboolean gtk_cell_renderer_get_sensitive (GtkCellRenderer *cell); |
294 | |
295 | GDK_AVAILABLE_IN_ALL |
296 | gboolean gtk_cell_renderer_is_activatable (GtkCellRenderer *cell); |
297 | |
298 | /* For use by cell renderer implementations only */ |
299 | GDK_AVAILABLE_IN_ALL |
300 | void gtk_cell_renderer_stop_editing (GtkCellRenderer *cell, |
301 | gboolean canceled); |
302 | |
303 | |
304 | void _gtk_cell_renderer_calc_offset (GtkCellRenderer *cell, |
305 | const GdkRectangle *cell_area, |
306 | GtkTextDirection direction, |
307 | gint width, |
308 | gint height, |
309 | gint *x_offset, |
310 | gint *y_offset); |
311 | |
312 | GDK_AVAILABLE_IN_ALL |
313 | GtkStateFlags gtk_cell_renderer_get_state (GtkCellRenderer *cell, |
314 | GtkWidget *widget, |
315 | GtkCellRendererState cell_state); |
316 | |
317 | GDK_AVAILABLE_IN_ALL |
318 | void gtk_cell_renderer_class_set_accessible_type |
319 | (GtkCellRendererClass *renderer_class, |
320 | GType type); |
321 | GType _gtk_cell_renderer_get_accessible_type |
322 | (GtkCellRenderer * renderer); |
323 | |
324 | G_END_DECLS |
325 | |
326 | #endif /* __GTK_CELL_RENDERER_H__ */ |
327 | |