3 * Copyright (C) 2010 Openismus GmbH
6 * Tristan Van Berkom <tristanvb@openismus.com>
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Library General Public
10 * License as published by the Free Software Foundation; either
11 * version 2 of the License, or (at your option) any later version.
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Library General Public License for more details.
18 * You should have received a copy of the GNU Library General Public
19 * License along with this library; if not, write to the
20 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
21 * Boston, MA 02111-1307, USA.
24 #if !defined (__GTK_H_INSIDE__) && !defined (GTK_COMPILATION)
25 #error "Only <gtk/gtk.h> can be included directly."
28 #ifndef __GTK_CELL_AREA_H__
29 #define __GTK_CELL_AREA_H__
31 #include <gtk/gtkcellrenderer.h>
32 #include <gtk/gtkwidget.h>
33 #include <gtk/gtktreemodel.h>
37 #define GTK_TYPE_CELL_AREA (gtk_cell_area_get_type ())
38 #define GTK_CELL_AREA(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_CELL_AREA, GtkCellArea))
39 #define GTK_CELL_AREA_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_CELL_AREA, GtkCellAreaClass))
40 #define GTK_IS_CELL_AREA(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_CELL_AREA))
41 #define GTK_IS_CELL_AREA_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_CELL_AREA))
42 #define GTK_CELL_AREA_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_CELL_AREA, GtkCellAreaClass))
44 typedef struct _GtkCellArea GtkCellArea;
45 typedef struct _GtkCellAreaClass GtkCellAreaClass;
46 typedef struct _GtkCellAreaPrivate GtkCellAreaPrivate;
47 typedef struct _GtkCellAreaContext GtkCellAreaContext;
50 * GTK_CELL_AREA_WARN_INVALID_CELL_PROPERTY_ID:
51 * @object: the #GObject on which set_cell_property() or get_get_property()
53 * @property_id: the numeric id of the property
54 * @pspec: the #GParamSpec of the property
56 * This macro should be used to emit a standard warning about unexpected
57 * properties in set_cell_property() and get_cell_property() implementations.
59 #define GTK_CELL_AREA_WARN_INVALID_CELL_PROPERTY_ID(object, property_id, pspec) \
60 G_OBJECT_WARN_INVALID_PSPEC ((object), "cell property id", (property_id), (pspec))
64 * @renderer: the cell renderer to operate on
65 * @data: user-supplied data
67 * The type of the callback functions used for iterating over
68 * the cell renderers of a #GtkCellArea, see gtk_cell_area_foreach().
70 * Return value: %TRUE to stop iterating over cells.
72 typedef gboolean (*GtkCellCallback) (GtkCellRenderer *renderer,
76 * GtkCellAllocCallback:
77 * @renderer: the cell renderer to operate on
78 * @cell_area: the area allocated to @renderer inside the rectangle provided to gtk_cell_area_foreach_alloc().
79 * @cell_background: the background area for @renderer inside the background
80 * area provided to gtk_cell_area_foreach_alloc().
81 * @data: user-supplied data
83 * The type of the callback functions used for iterating over
84 * the cell renderers and their allocated areas inside a #GtkCellArea,
85 * see gtk_cell_area_foreach_alloc().
87 * Return value: %TRUE to stop iterating over cells.
89 typedef gboolean (*GtkCellAllocCallback) (GtkCellRenderer *renderer,
90 const GdkRectangle *cell_area,
91 const GdkRectangle *cell_background,
98 GInitiallyUnowned parent_instance;
100 GtkCellAreaPrivate *priv;
106 * @add: adds a #GtkCellRenderer to the area.
107 * @remove: removes a #GtkCellRenderer from the area.
108 * @foreach: Calls the #GtkCellCallback function on every #GtkCellRenderer in the area
109 * with the provided user data until the callback returns %TRUE.
110 * @foreach_alloc: Calls the #GtkCellAllocCallback function on every #GtkCellRenderer in the area
111 * with the allocated area for the cell and the provided user data until the callback returns %TRUE.
112 * @event: Handle an event in the area, this is generally used to activate a cell
113 * at the event location for button events but can also be used to generically pass
114 * events to #GtkWidgets drawn onto the area.
115 * @render: Actually render the area's cells to the specified rectangle, @background_area
116 * should be correctly distributed to the cells coresponding background areas.
117 * @apply_attributes: Apply the cell attributes to the cells. This is implemented as a signal and
118 * generally #GtkCellArea subclasses dont need to implement this since it's handled by the base
119 * class but can be overridden to apply some custom attributes.
120 * @create_context: Creates and returns a class specific #GtkCellAreaContext to store cell
121 * alignment and allocation details for a said #GtkCellArea class.
122 * @copy_context: Creates a new #GtkCellAreaContext in the same state as the passed @context
123 * with any cell alignment data and allocations in tact.
124 * @get_request_mode: This allows an area to tell its layouting widget whether it prefers to
125 * be allocated in %GTK_SIZE_REQUEST_HEIGHT_FOR_WIDTH or %GTK_SIZE_REQUEST_WIDTH_FOR_HEIGHT mode.
126 * @get_preferred_width: Calculates the minimum and natural width of the area's cells
127 * with the current attributes applied while considering the particular layouting details
128 * of the said #GtkCellArea. While requests are performed over a series of rows, alignments
129 * and overall minimum and natural sizes should be stored in the corresponding #GtkCellAreaContext.
130 * @get_preferred_height_for_width: Calculates the minimum and natural height for the area
131 * if the passed @context would be allocated the given width. When implementing this virtual
132 * method it is safe to assume that @context has already stored the aligned cell widths
133 * for every #GtkTreeModel row that @context will be allocated for since this information
134 * was stored at #GtkCellAreaClass.get_preferred_width() time. This virtual method should
135 * also store any necessary alignments of cell heights for the case that the context is
136 * allocated a height.
137 * @get_preferred_height: Calculates the minimum and natural height of the area's cells
138 * with the current attributes applied. Essentially this is the same as
139 * #GtkCellAreaClass.get_preferred_width() only for areas that are being requested as
140 * %GTK_SIZE_REQUEST_WIDTH_FOR_HEIGHT.
141 * @get_preferred_width_for_height: Calculates the minimum and natural width for the area
142 * if the passed @context would be allocated the given height. The same as
143 * #GtkCellAreaClass.get_preferred_height_for_width() only for handling requests in the
144 * %GTK_SIZE_REQUEST_WIDTH_FOR_HEIGHT mode.
145 * @set_cell_property: This should be implemented to handle changes in child cell properties
146 * for a given #GtkCellRenderer that were previously installed on the #GtkCellAreaClass with
147 * gtk_cell_area_class_install_cell_property().
148 * @get_cell_property: This should be implemented to report the values of child cell properties
149 * for a given child #GtkCellRenderer.
150 * @focus: This virtual method should be implemented to navigate focus from cell to cell
151 * inside the #GtkCellArea. The #GtkCellArea should move focus from cell to cell inside
152 * the area and return %FALSE if focus logically leaves the area with the following exceptions:
153 * When the area contains no activatable cells, the entire area recieves focus. Focus should not
154 * be given to cells that are actually "focus siblings" of other sibling cells
155 * (see gtk_cell_area_get_focus_from_sibling()). Focus is set by calling gtk_cell_area_set_focus_cell().
156 * @is_activatable: Returns whether the #GtkCellArea can respond to #GtkCellAreaClass.activate(),
157 * usually this does not need to be implemented since the base class takes care of this however
158 * it can be enhanced if the #GtkCellArea subclass can handle activation in other ways than
159 * activating its #GtkCellRenderers.
160 * @activate: This is called when the layouting widget rendering the #GtkCellArea activates
161 * the focus cell (see gtk_cell_area_get_focus_cell()).
163 struct _GtkCellAreaClass
166 GInitiallyUnownedClass parent_class;
171 void (* add) (GtkCellArea *area,
172 GtkCellRenderer *renderer);
173 void (* remove) (GtkCellArea *area,
174 GtkCellRenderer *renderer);
175 void (* foreach) (GtkCellArea *area,
176 GtkCellCallback callback,
177 gpointer callback_data);
178 void (* foreach_alloc) (GtkCellArea *area,
179 GtkCellAreaContext *context,
181 const GdkRectangle *cell_area,
182 const GdkRectangle *background_area,
183 GtkCellAllocCallback callback,
184 gpointer callback_data);
185 gint (* event) (GtkCellArea *area,
186 GtkCellAreaContext *context,
189 const GdkRectangle *cell_area,
190 GtkCellRendererState flags);
191 void (* render) (GtkCellArea *area,
192 GtkCellAreaContext *context,
195 const GdkRectangle *background_area,
196 const GdkRectangle *cell_area,
197 GtkCellRendererState flags,
198 gboolean paint_focus);
199 void (* apply_attributes) (GtkCellArea *area,
200 GtkTreeModel *tree_model,
202 gboolean is_expander,
203 gboolean is_expanded);
206 GtkCellAreaContext *(* create_context) (GtkCellArea *area);
207 GtkCellAreaContext *(* copy_context) (GtkCellArea *area,
208 GtkCellAreaContext *context);
209 GtkSizeRequestMode (* get_request_mode) (GtkCellArea *area);
210 void (* get_preferred_width) (GtkCellArea *area,
211 GtkCellAreaContext *context,
214 gint *natural_width);
215 void (* get_preferred_height_for_width) (GtkCellArea *area,
216 GtkCellAreaContext *context,
219 gint *minimum_height,
220 gint *natural_height);
221 void (* get_preferred_height) (GtkCellArea *area,
222 GtkCellAreaContext *context,
224 gint *minimum_height,
225 gint *natural_height);
226 void (* get_preferred_width_for_height) (GtkCellArea *area,
227 GtkCellAreaContext *context,
231 gint *natural_width);
233 /* Cell Properties */
234 void (* set_cell_property) (GtkCellArea *area,
235 GtkCellRenderer *renderer,
239 void (* get_cell_property) (GtkCellArea *area,
240 GtkCellRenderer *renderer,
246 gboolean (* focus) (GtkCellArea *area,
247 GtkDirectionType direction);
248 gboolean (* is_activatable) (GtkCellArea *area);
249 gboolean (* activate) (GtkCellArea *area,
250 GtkCellAreaContext *context,
252 const GdkRectangle *cell_area,
253 GtkCellRendererState flags,
258 /* Padding for future expansion */
259 void (*_gtk_reserved1) (void);
260 void (*_gtk_reserved2) (void);
261 void (*_gtk_reserved3) (void);
262 void (*_gtk_reserved4) (void);
263 void (*_gtk_reserved5) (void);
264 void (*_gtk_reserved6) (void);
265 void (*_gtk_reserved7) (void);
266 void (*_gtk_reserved8) (void);
269 GType gtk_cell_area_get_type (void) G_GNUC_CONST;
272 void gtk_cell_area_add (GtkCellArea *area,
273 GtkCellRenderer *renderer);
274 void gtk_cell_area_remove (GtkCellArea *area,
275 GtkCellRenderer *renderer);
276 gboolean gtk_cell_area_has_renderer (GtkCellArea *area,
277 GtkCellRenderer *renderer);
278 void gtk_cell_area_foreach (GtkCellArea *area,
279 GtkCellCallback callback,
280 gpointer callback_data);
281 void gtk_cell_area_foreach_alloc (GtkCellArea *area,
282 GtkCellAreaContext *context,
284 const GdkRectangle *cell_area,
285 const GdkRectangle *background_area,
286 GtkCellAllocCallback callback,
287 gpointer callback_data);
288 gint gtk_cell_area_event (GtkCellArea *area,
289 GtkCellAreaContext *context,
292 const GdkRectangle *cell_area,
293 GtkCellRendererState flags);
294 void gtk_cell_area_render (GtkCellArea *area,
295 GtkCellAreaContext *context,
298 const GdkRectangle *background_area,
299 const GdkRectangle *cell_area,
300 GtkCellRendererState flags,
301 gboolean paint_focus);
302 void gtk_cell_area_set_style_detail (GtkCellArea *area,
303 const gchar *detail);
304 G_CONST_RETURN gchar *gtk_cell_area_get_style_detail (GtkCellArea *area);
307 void gtk_cell_area_get_cell_allocation (GtkCellArea *area,
308 GtkCellAreaContext *context,
310 GtkCellRenderer *renderer,
311 const GdkRectangle *cell_area,
312 GdkRectangle *allocation);
313 GtkCellRenderer *gtk_cell_area_get_cell_at_position (GtkCellArea *area,
314 GtkCellAreaContext *context,
316 const GdkRectangle *cell_area,
319 GdkRectangle *alloc_area);
322 GtkCellAreaContext *gtk_cell_area_create_context (GtkCellArea *area);
323 GtkCellAreaContext *gtk_cell_area_copy_context (GtkCellArea *area,
324 GtkCellAreaContext *context);
325 GtkSizeRequestMode gtk_cell_area_get_request_mode (GtkCellArea *area);
326 void gtk_cell_area_get_preferred_width (GtkCellArea *area,
327 GtkCellAreaContext *context,
331 void gtk_cell_area_get_preferred_height_for_width (GtkCellArea *area,
332 GtkCellAreaContext *context,
335 gint *minimum_height,
336 gint *natural_height);
337 void gtk_cell_area_get_preferred_height (GtkCellArea *area,
338 GtkCellAreaContext *context,
342 void gtk_cell_area_get_preferred_width_for_height (GtkCellArea *area,
343 GtkCellAreaContext *context,
347 gint *natural_width);
348 G_CONST_RETURN gchar *gtk_cell_area_get_current_path_string (GtkCellArea *area);
352 void gtk_cell_area_apply_attributes (GtkCellArea *area,
353 GtkTreeModel *tree_model,
355 gboolean is_expander,
356 gboolean is_expanded);
357 void gtk_cell_area_attribute_connect (GtkCellArea *area,
358 GtkCellRenderer *renderer,
359 const gchar *attribute,
361 void gtk_cell_area_attribute_disconnect (GtkCellArea *area,
362 GtkCellRenderer *renderer,
363 const gchar *attribute);
365 /* Cell Properties */
366 void gtk_cell_area_class_install_cell_property (GtkCellAreaClass *aclass,
369 GParamSpec* gtk_cell_area_class_find_cell_property (GtkCellAreaClass *aclass,
370 const gchar *property_name);
371 GParamSpec** gtk_cell_area_class_list_cell_properties (GtkCellAreaClass *aclass,
372 guint *n_properties);
373 void gtk_cell_area_add_with_properties (GtkCellArea *area,
374 GtkCellRenderer *renderer,
375 const gchar *first_prop_name,
376 ...) G_GNUC_NULL_TERMINATED;
377 void gtk_cell_area_cell_set (GtkCellArea *area,
378 GtkCellRenderer *renderer,
379 const gchar *first_prop_name,
380 ...) G_GNUC_NULL_TERMINATED;
381 void gtk_cell_area_cell_get (GtkCellArea *area,
382 GtkCellRenderer *renderer,
383 const gchar *first_prop_name,
384 ...) G_GNUC_NULL_TERMINATED;
385 void gtk_cell_area_cell_set_valist (GtkCellArea *area,
386 GtkCellRenderer *renderer,
387 const gchar *first_property_name,
389 void gtk_cell_area_cell_get_valist (GtkCellArea *area,
390 GtkCellRenderer *renderer,
391 const gchar *first_property_name,
393 void gtk_cell_area_cell_set_property (GtkCellArea *area,
394 GtkCellRenderer *renderer,
395 const gchar *property_name,
396 const GValue *value);
397 void gtk_cell_area_cell_get_property (GtkCellArea *area,
398 GtkCellRenderer *renderer,
399 const gchar *property_name,
403 gboolean gtk_cell_area_is_activatable (GtkCellArea *area);
404 gboolean gtk_cell_area_activate (GtkCellArea *area,
405 GtkCellAreaContext *context,
407 const GdkRectangle *cell_area,
408 GtkCellRendererState flags,
410 gboolean gtk_cell_area_focus (GtkCellArea *area,
411 GtkDirectionType direction);
412 void gtk_cell_area_set_focus_cell (GtkCellArea *area,
413 GtkCellRenderer *renderer);
414 GtkCellRenderer *gtk_cell_area_get_focus_cell (GtkCellArea *area);
418 void gtk_cell_area_add_focus_sibling (GtkCellArea *area,
419 GtkCellRenderer *renderer,
420 GtkCellRenderer *sibling);
421 void gtk_cell_area_remove_focus_sibling (GtkCellArea *area,
422 GtkCellRenderer *renderer,
423 GtkCellRenderer *sibling);
424 gboolean gtk_cell_area_is_focus_sibling (GtkCellArea *area,
425 GtkCellRenderer *renderer,
426 GtkCellRenderer *sibling);
427 G_CONST_RETURN GList *gtk_cell_area_get_focus_siblings (GtkCellArea *area,
428 GtkCellRenderer *renderer);
429 GtkCellRenderer *gtk_cell_area_get_focus_from_sibling (GtkCellArea *area,
430 GtkCellRenderer *renderer);
432 /* Cell Activation/Editing */
433 GtkCellRenderer *gtk_cell_area_get_edited_cell (GtkCellArea *area);
434 GtkCellEditable *gtk_cell_area_get_edit_widget (GtkCellArea *area);
435 gboolean gtk_cell_area_activate_cell (GtkCellArea *area,
437 GtkCellRenderer *renderer,
439 const GdkRectangle *cell_area,
440 GtkCellRendererState flags);
441 void gtk_cell_area_stop_editing (GtkCellArea *area,
444 /* Functions for area implementations */
446 /* Distinguish the inner cell area from the whole requested area including margins */
447 void gtk_cell_area_inner_cell_area (GtkCellArea *area,
449 const GdkRectangle *cell_area,
450 GdkRectangle *inner_area);
452 /* Request the size of a cell while respecting the cell margins (requests are margin inclusive) */
453 void gtk_cell_area_request_renderer (GtkCellArea *area,
454 GtkCellRenderer *renderer,
455 GtkOrientation orientation,
463 #endif /* __GTK_CELL_AREA_H__ */