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
79 * provided to gtk_cell_area_foreach_alloc().
80 * @cell_background: the background area for @renderer inside the
81 * background area provided to gtk_cell_area_foreach_alloc().
82 * @data: user-supplied data
84 * The type of the callback functions used for iterating over the
85 * cell renderers and their allocated areas inside a #GtkCellArea,
86 * see gtk_cell_area_foreach_alloc().
88 * Return value: %TRUE to stop iterating over cells.
90 typedef gboolean (*GtkCellAllocCallback) (GtkCellRenderer *renderer,
91 const GdkRectangle *cell_area,
92 const GdkRectangle *cell_background,
99 GInitiallyUnowned parent_instance;
101 GtkCellAreaPrivate *priv;
107 * @add: adds a #GtkCellRenderer to the area.
108 * @remove: removes a #GtkCellRenderer from the area.
109 * @foreach: calls the #GtkCellCallback function on every #GtkCellRenderer in
110 * the area with the provided user data until the callback returns %TRUE.
111 * @foreach_alloc: Calls the #GtkCellAllocCallback function on every
112 * #GtkCellRenderer in the area with the allocated area for the cell
113 * and the provided user data until the callback returns %TRUE.
114 * @event: Handle an event in the area, this is generally used to activate
115 * a cell at the event location for button events but can also be used
116 * to generically pass events to #GtkWidgets drawn onto the area.
117 * @render: Actually render the area's cells to the specified rectangle,
118 * @background_area should be correctly distributed to the cells
119 * corresponding background areas.
120 * @apply_attributes: Apply the cell attributes to the cells. This is
121 * implemented as a signal and generally #GtkCellArea subclasses don't
122 * need to implement it since it is handled by the base class.
123 * @create_context: Creates and returns a class specific #GtkCellAreaContext
124 * to store cell alignment and allocation details for a said #GtkCellArea
126 * @copy_context: Creates a new #GtkCellAreaContext in the same state as
127 * the passed @context with any cell alignment data and allocations intact.
128 * @get_request_mode: This allows an area to tell its layouting widget whether
129 * it prefers to be allocated in %GTK_SIZE_REQUEST_HEIGHT_FOR_WIDTH or
130 * %GTK_SIZE_REQUEST_WIDTH_FOR_HEIGHT mode.
131 * @get_preferred_width: Calculates the minimum and natural width of the
132 * areas cells with the current attributes applied while considering
133 * the particular layouting details of the said #GtkCellArea. While
134 * requests are performed over a series of rows, alignments and overall
135 * minimum and natural sizes should be stored in the corresponding
136 * #GtkCellAreaContext.
137 * @get_preferred_height_for_width: Calculates the minimum and natural height
138 * for the area if the passed @context would be allocated the given width.
139 * When implementing this virtual method it is safe to assume that @context
140 * has already stored the aligned cell widths for every #GtkTreeModel row
141 * that @context will be allocated for since this information was stored
142 * at #GtkCellAreaClass.get_preferred_width() time. This virtual method
143 * should also store any necessary alignments of cell heights for the
144 * case that the context is allocated a height.
145 * @get_preferred_height: Calculates the minimum and natural height of the
146 * areas cells with the current attributes applied. Essentially this is
147 * the same as #GtkCellAreaClass.get_preferred_width() only for areas
148 * that are being requested as %GTK_SIZE_REQUEST_WIDTH_FOR_HEIGHT.
149 * @get_preferred_width_for_height: Calculates the minimum and natural width
150 * for the area if the passed @context would be allocated the given
151 * height. The same as #GtkCellAreaClass.get_preferred_height_for_width()
152 * only for handling requests in the %GTK_SIZE_REQUEST_WIDTH_FOR_HEIGHT
154 * @set_cell_property: This should be implemented to handle changes in child
155 * cell properties for a given #GtkCellRenderer that were previously
156 * installed on the #GtkCellAreaClass with gtk_cell_area_class_install_cell_property().
157 * @get_cell_property: This should be implemented to report the values of
158 * child cell properties for a given child #GtkCellRenderer.
159 * @focus: This virtual method should be implemented to navigate focus from
160 * cell to cell inside the #GtkCellArea. The #GtkCellArea should move
161 * focus from cell to cell inside the area and return %FALSE if focus
162 * logically leaves the area with the following exceptions: When the
163 * area contains no activatable cells, the entire area recieves focus.
164 * Focus should not be given to cells that are actually "focus siblings"
165 * of other sibling cells (see gtk_cell_area_get_focus_from_sibling()).
166 * Focus is set by calling gtk_cell_area_set_focus_cell().
167 * @is_activatable: Returns whether the #GtkCellArea can respond to
168 * #GtkCellAreaClass.activate(), usually this does not need to be
169 * implemented since the base class takes care of this however it can
170 * be enhanced if the #GtkCellArea subclass can handle activation in
171 * other ways than activating its #GtkCellRenderers.
172 * @activate: This is called when the layouting widget rendering the
173 * #GtkCellArea activates the focus cell (see gtk_cell_area_get_focus_cell()).
175 struct _GtkCellAreaClass
178 GInitiallyUnownedClass parent_class;
183 void (* add) (GtkCellArea *area,
184 GtkCellRenderer *renderer);
185 void (* remove) (GtkCellArea *area,
186 GtkCellRenderer *renderer);
187 void (* foreach) (GtkCellArea *area,
188 GtkCellCallback callback,
189 gpointer callback_data);
190 void (* foreach_alloc) (GtkCellArea *area,
191 GtkCellAreaContext *context,
193 const GdkRectangle *cell_area,
194 const GdkRectangle *background_area,
195 GtkCellAllocCallback callback,
196 gpointer callback_data);
197 gint (* event) (GtkCellArea *area,
198 GtkCellAreaContext *context,
201 const GdkRectangle *cell_area,
202 GtkCellRendererState flags);
203 void (* render) (GtkCellArea *area,
204 GtkCellAreaContext *context,
207 const GdkRectangle *background_area,
208 const GdkRectangle *cell_area,
209 GtkCellRendererState flags,
210 gboolean paint_focus);
211 void (* apply_attributes) (GtkCellArea *area,
212 GtkTreeModel *tree_model,
214 gboolean is_expander,
215 gboolean is_expanded);
218 GtkCellAreaContext *(* create_context) (GtkCellArea *area);
219 GtkCellAreaContext *(* copy_context) (GtkCellArea *area,
220 GtkCellAreaContext *context);
221 GtkSizeRequestMode (* get_request_mode) (GtkCellArea *area);
222 void (* get_preferred_width) (GtkCellArea *area,
223 GtkCellAreaContext *context,
226 gint *natural_width);
227 void (* get_preferred_height_for_width) (GtkCellArea *area,
228 GtkCellAreaContext *context,
231 gint *minimum_height,
232 gint *natural_height);
233 void (* get_preferred_height) (GtkCellArea *area,
234 GtkCellAreaContext *context,
236 gint *minimum_height,
237 gint *natural_height);
238 void (* get_preferred_width_for_height) (GtkCellArea *area,
239 GtkCellAreaContext *context,
243 gint *natural_width);
245 /* Cell Properties */
246 void (* set_cell_property) (GtkCellArea *area,
247 GtkCellRenderer *renderer,
251 void (* get_cell_property) (GtkCellArea *area,
252 GtkCellRenderer *renderer,
258 gboolean (* focus) (GtkCellArea *area,
259 GtkDirectionType direction);
260 gboolean (* is_activatable) (GtkCellArea *area);
261 gboolean (* activate) (GtkCellArea *area,
262 GtkCellAreaContext *context,
264 const GdkRectangle *cell_area,
265 GtkCellRendererState flags,
270 /* Padding for future expansion */
271 void (*_gtk_reserved1) (void);
272 void (*_gtk_reserved2) (void);
273 void (*_gtk_reserved3) (void);
274 void (*_gtk_reserved4) (void);
275 void (*_gtk_reserved5) (void);
276 void (*_gtk_reserved6) (void);
277 void (*_gtk_reserved7) (void);
278 void (*_gtk_reserved8) (void);
281 GType gtk_cell_area_get_type (void) G_GNUC_CONST;
284 void gtk_cell_area_add (GtkCellArea *area,
285 GtkCellRenderer *renderer);
286 void gtk_cell_area_remove (GtkCellArea *area,
287 GtkCellRenderer *renderer);
288 gboolean gtk_cell_area_has_renderer (GtkCellArea *area,
289 GtkCellRenderer *renderer);
290 void gtk_cell_area_foreach (GtkCellArea *area,
291 GtkCellCallback callback,
292 gpointer callback_data);
293 void gtk_cell_area_foreach_alloc (GtkCellArea *area,
294 GtkCellAreaContext *context,
296 const GdkRectangle *cell_area,
297 const GdkRectangle *background_area,
298 GtkCellAllocCallback callback,
299 gpointer callback_data);
300 gint gtk_cell_area_event (GtkCellArea *area,
301 GtkCellAreaContext *context,
304 const GdkRectangle *cell_area,
305 GtkCellRendererState flags);
306 void gtk_cell_area_render (GtkCellArea *area,
307 GtkCellAreaContext *context,
310 const GdkRectangle *background_area,
311 const GdkRectangle *cell_area,
312 GtkCellRendererState flags,
313 gboolean paint_focus);
314 void gtk_cell_area_set_style_detail (GtkCellArea *area,
315 const gchar *detail);
316 G_CONST_RETURN gchar *gtk_cell_area_get_style_detail (GtkCellArea *area);
319 void gtk_cell_area_get_cell_allocation (GtkCellArea *area,
320 GtkCellAreaContext *context,
322 GtkCellRenderer *renderer,
323 const GdkRectangle *cell_area,
324 GdkRectangle *allocation);
325 GtkCellRenderer *gtk_cell_area_get_cell_at_position (GtkCellArea *area,
326 GtkCellAreaContext *context,
328 const GdkRectangle *cell_area,
331 GdkRectangle *alloc_area);
334 GtkCellAreaContext *gtk_cell_area_create_context (GtkCellArea *area);
335 GtkCellAreaContext *gtk_cell_area_copy_context (GtkCellArea *area,
336 GtkCellAreaContext *context);
337 GtkSizeRequestMode gtk_cell_area_get_request_mode (GtkCellArea *area);
338 void gtk_cell_area_get_preferred_width (GtkCellArea *area,
339 GtkCellAreaContext *context,
342 gint *natural_width);
343 void gtk_cell_area_get_preferred_height_for_width (GtkCellArea *area,
344 GtkCellAreaContext *context,
347 gint *minimum_height,
348 gint *natural_height);
349 void gtk_cell_area_get_preferred_height (GtkCellArea *area,
350 GtkCellAreaContext *context,
352 gint *minimum_height,
353 gint *natural_height);
354 void gtk_cell_area_get_preferred_width_for_height (GtkCellArea *area,
355 GtkCellAreaContext *context,
359 gint *natural_width);
360 G_CONST_RETURN gchar *gtk_cell_area_get_current_path_string (GtkCellArea *area);
364 void gtk_cell_area_apply_attributes (GtkCellArea *area,
365 GtkTreeModel *tree_model,
367 gboolean is_expander,
368 gboolean is_expanded);
369 void gtk_cell_area_attribute_connect (GtkCellArea *area,
370 GtkCellRenderer *renderer,
371 const gchar *attribute,
373 void gtk_cell_area_attribute_disconnect (GtkCellArea *area,
374 GtkCellRenderer *renderer,
375 const gchar *attribute);
377 /* Cell Properties */
378 void gtk_cell_area_class_install_cell_property (GtkCellAreaClass *aclass,
381 GParamSpec* gtk_cell_area_class_find_cell_property (GtkCellAreaClass *aclass,
382 const gchar *property_name);
383 GParamSpec** gtk_cell_area_class_list_cell_properties (GtkCellAreaClass *aclass,
384 guint *n_properties);
385 void gtk_cell_area_add_with_properties (GtkCellArea *area,
386 GtkCellRenderer *renderer,
387 const gchar *first_prop_name,
388 ...) G_GNUC_NULL_TERMINATED;
389 void gtk_cell_area_cell_set (GtkCellArea *area,
390 GtkCellRenderer *renderer,
391 const gchar *first_prop_name,
392 ...) G_GNUC_NULL_TERMINATED;
393 void gtk_cell_area_cell_get (GtkCellArea *area,
394 GtkCellRenderer *renderer,
395 const gchar *first_prop_name,
396 ...) G_GNUC_NULL_TERMINATED;
397 void gtk_cell_area_cell_set_valist (GtkCellArea *area,
398 GtkCellRenderer *renderer,
399 const gchar *first_property_name,
401 void gtk_cell_area_cell_get_valist (GtkCellArea *area,
402 GtkCellRenderer *renderer,
403 const gchar *first_property_name,
405 void gtk_cell_area_cell_set_property (GtkCellArea *area,
406 GtkCellRenderer *renderer,
407 const gchar *property_name,
408 const GValue *value);
409 void gtk_cell_area_cell_get_property (GtkCellArea *area,
410 GtkCellRenderer *renderer,
411 const gchar *property_name,
415 gboolean gtk_cell_area_is_activatable (GtkCellArea *area);
416 gboolean gtk_cell_area_activate (GtkCellArea *area,
417 GtkCellAreaContext *context,
419 const GdkRectangle *cell_area,
420 GtkCellRendererState flags,
422 gboolean gtk_cell_area_focus (GtkCellArea *area,
423 GtkDirectionType direction);
424 void gtk_cell_area_set_focus_cell (GtkCellArea *area,
425 GtkCellRenderer *renderer);
426 GtkCellRenderer *gtk_cell_area_get_focus_cell (GtkCellArea *area);
430 void gtk_cell_area_add_focus_sibling (GtkCellArea *area,
431 GtkCellRenderer *renderer,
432 GtkCellRenderer *sibling);
433 void gtk_cell_area_remove_focus_sibling (GtkCellArea *area,
434 GtkCellRenderer *renderer,
435 GtkCellRenderer *sibling);
436 gboolean gtk_cell_area_is_focus_sibling (GtkCellArea *area,
437 GtkCellRenderer *renderer,
438 GtkCellRenderer *sibling);
439 G_CONST_RETURN GList *gtk_cell_area_get_focus_siblings (GtkCellArea *area,
440 GtkCellRenderer *renderer);
441 GtkCellRenderer *gtk_cell_area_get_focus_from_sibling (GtkCellArea *area,
442 GtkCellRenderer *renderer);
444 /* Cell Activation/Editing */
445 GtkCellRenderer *gtk_cell_area_get_edited_cell (GtkCellArea *area);
446 GtkCellEditable *gtk_cell_area_get_edit_widget (GtkCellArea *area);
447 gboolean gtk_cell_area_activate_cell (GtkCellArea *area,
449 GtkCellRenderer *renderer,
451 const GdkRectangle *cell_area,
452 GtkCellRendererState flags);
453 void gtk_cell_area_stop_editing (GtkCellArea *area,
456 /* Functions for area implementations */
458 /* Distinguish the inner cell area from the whole requested area including margins */
459 void gtk_cell_area_inner_cell_area (GtkCellArea *area,
461 const GdkRectangle *cell_area,
462 GdkRectangle *inner_area);
464 /* Request the size of a cell while respecting the cell margins (requests are margin inclusive) */
465 void gtk_cell_area_request_renderer (GtkCellArea *area,
466 GtkCellRenderer *renderer,
467 GtkOrientation orientation,
473 /* For api stability, this is called from gtkcelllayout.c in order to ensure the correct
474 * object is passed to the user function in gtk_cell_layout_set_cell_data_func.
476 * This private api takes gpointer & GFunc arguments to circumvent circular header file
479 void _gtk_cell_area_set_cell_data_func_with_proxy (GtkCellArea *area,
480 GtkCellRenderer *cell,
483 GDestroyNotify destroy,
488 #endif /* __GTK_CELL_AREA_H__ */