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 * @get_request_mode: This allows an area to tell its layouting widget whether it prefers to
123 * be allocated in %GTK_SIZE_REQUEST_HEIGHT_FOR_WIDTH or %GTK_SIZE_REQUEST_WIDTH_FOR_HEIGHT mode.
124 * @get_preferred_width: Calculates the minimum and natural width of the area's cells
125 * with the current attributes applied while considering the particular layouting details
126 * of the said #GtkCellArea. While requests are performed over a series of rows, alignments
127 * and overall minimum and natural sizes should be stored in the corresponding #GtkCellAreaContext.
128 * @get_preferred_height_for_width: Calculates the minimum and natural height for the area
129 * if the passed @context would be allocated the given width. When implementing this virtual
130 * method it is safe to assume that @context has already stored the aligned cell widths
131 * for every #GtkTreeModel row that @context will be allocated for since this information
132 * was stored at #GtkCellAreaClass.get_preferred_width() time. This virtual method should
133 * also store any necessary alignments of cell heights for the case that the context is
134 * allocated a height.
135 * @get_preferred_height: Calculates the minimum and natural height of the area's cells
136 * with the current attributes applied. Essentially this is the same as
137 * #GtkCellAreaClass.get_preferred_width() only for areas that are being requested as
138 * %GTK_SIZE_REQUEST_WIDTH_FOR_HEIGHT.
139 * @get_preferred_width_for_height: Calculates the minimum and natural width for the area
140 * if the passed @context would be allocated the given height. The same as
141 * #GtkCellAreaClass.get_preferred_height_for_width() only for handling requests in the
142 * %GTK_SIZE_REQUEST_WIDTH_FOR_HEIGHT mode.
143 * @set_cell_property: This should be implemented to handle changes in child cell properties
144 * for a given #GtkCellRenderer that were previously installed on the #GtkCellAreaClass with
145 * gtk_cell_area_class_install_cell_property().
146 * @get_cell_property: This should be implemented to report the values of child cell properties
147 * for a given child #GtkCellRenderer.
148 * @focus: This virtual method should be implemented to navigate focus from cell to cell
149 * inside the #GtkCellArea. The #GtkCellArea should move focus from cell to cell inside
150 * the area and return %FALSE if focus logically leaves the area with the following exceptions:
151 * When the area contains no activatable cells, the entire area recieves focus. Focus should not
152 * be given to cells that are actually "focus siblings" of other sibling cells
153 * (see gtk_cell_area_get_focus_from_sibling()). Focus is set by calling gtk_cell_area_set_focus_cell().
154 * @is_activatable: Returns whether the #GtkCellArea can respond to #GtkCellAreaClass.activate(),
155 * usually this does not need to be implemented since the base class takes care of this however
156 * it can be enhanced if the #GtkCellArea subclass can handle activation in other ways than
157 * activating its #GtkCellRenderers.
158 * @activate: This is called when the layouting widget rendering the #GtkCellArea activates
159 * the focus cell (see gtk_cell_area_get_focus_cell()).
161 struct _GtkCellAreaClass
164 GInitiallyUnownedClass parent_class;
169 void (* add) (GtkCellArea *area,
170 GtkCellRenderer *renderer);
171 void (* remove) (GtkCellArea *area,
172 GtkCellRenderer *renderer);
173 void (* foreach) (GtkCellArea *area,
174 GtkCellCallback callback,
175 gpointer callback_data);
176 void (* foreach_alloc) (GtkCellArea *area,
177 GtkCellAreaContext *context,
179 const GdkRectangle *cell_area,
180 const GdkRectangle *background_area,
181 GtkCellAllocCallback callback,
182 gpointer callback_data);
183 gint (* event) (GtkCellArea *area,
184 GtkCellAreaContext *context,
187 const GdkRectangle *cell_area,
188 GtkCellRendererState flags);
189 void (* render) (GtkCellArea *area,
190 GtkCellAreaContext *context,
193 const GdkRectangle *background_area,
194 const GdkRectangle *cell_area,
195 GtkCellRendererState flags,
196 gboolean paint_focus);
197 void (* apply_attributes) (GtkCellArea *area,
198 GtkTreeModel *tree_model,
200 gboolean is_expander,
201 gboolean is_expanded);
204 GtkCellAreaContext *(* create_context) (GtkCellArea *area);
205 GtkSizeRequestMode (* get_request_mode) (GtkCellArea *area);
206 void (* get_preferred_width) (GtkCellArea *area,
207 GtkCellAreaContext *context,
210 gint *natural_width);
211 void (* get_preferred_height_for_width) (GtkCellArea *area,
212 GtkCellAreaContext *context,
215 gint *minimum_height,
216 gint *natural_height);
217 void (* get_preferred_height) (GtkCellArea *area,
218 GtkCellAreaContext *context,
220 gint *minimum_height,
221 gint *natural_height);
222 void (* get_preferred_width_for_height) (GtkCellArea *area,
223 GtkCellAreaContext *context,
227 gint *natural_width);
229 /* Cell Properties */
230 void (* set_cell_property) (GtkCellArea *area,
231 GtkCellRenderer *renderer,
235 void (* get_cell_property) (GtkCellArea *area,
236 GtkCellRenderer *renderer,
242 gboolean (* focus) (GtkCellArea *area,
243 GtkDirectionType direction);
244 gboolean (* is_activatable) (GtkCellArea *area);
245 gboolean (* activate) (GtkCellArea *area,
246 GtkCellAreaContext *context,
248 const GdkRectangle *cell_area,
249 GtkCellRendererState flags);
253 /* Padding for future expansion */
254 void (*_gtk_reserved1) (void);
255 void (*_gtk_reserved2) (void);
256 void (*_gtk_reserved3) (void);
257 void (*_gtk_reserved4) (void);
258 void (*_gtk_reserved5) (void);
259 void (*_gtk_reserved6) (void);
260 void (*_gtk_reserved7) (void);
261 void (*_gtk_reserved8) (void);
264 GType gtk_cell_area_get_type (void) G_GNUC_CONST;
267 void gtk_cell_area_add (GtkCellArea *area,
268 GtkCellRenderer *renderer);
269 void gtk_cell_area_remove (GtkCellArea *area,
270 GtkCellRenderer *renderer);
271 gboolean gtk_cell_area_has_renderer (GtkCellArea *area,
272 GtkCellRenderer *renderer);
273 void gtk_cell_area_foreach (GtkCellArea *area,
274 GtkCellCallback callback,
275 gpointer callback_data);
276 void gtk_cell_area_foreach_alloc (GtkCellArea *area,
277 GtkCellAreaContext *context,
279 const GdkRectangle *cell_area,
280 const GdkRectangle *background_area,
281 GtkCellAllocCallback callback,
282 gpointer callback_data);
283 gint gtk_cell_area_event (GtkCellArea *area,
284 GtkCellAreaContext *context,
287 const GdkRectangle *cell_area,
288 GtkCellRendererState flags);
289 void gtk_cell_area_render (GtkCellArea *area,
290 GtkCellAreaContext *context,
293 const GdkRectangle *background_area,
294 const GdkRectangle *cell_area,
295 GtkCellRendererState flags,
296 gboolean paint_focus);
297 void gtk_cell_area_set_style_detail (GtkCellArea *area,
298 const gchar *detail);
299 G_CONST_RETURN gchar *gtk_cell_area_get_style_detail (GtkCellArea *area);
302 void gtk_cell_area_get_cell_allocation (GtkCellArea *area,
303 GtkCellAreaContext *context,
305 GtkCellRenderer *renderer,
306 const GdkRectangle *cell_area,
307 GdkRectangle *allocation);
308 GtkCellRenderer *gtk_cell_area_get_cell_at_position (GtkCellArea *area,
309 GtkCellAreaContext *context,
311 const GdkRectangle *cell_area,
314 GdkRectangle *alloc_area);
317 GtkCellAreaContext *gtk_cell_area_create_context (GtkCellArea *area);
318 GtkSizeRequestMode gtk_cell_area_get_request_mode (GtkCellArea *area);
319 void gtk_cell_area_get_preferred_width (GtkCellArea *area,
320 GtkCellAreaContext *context,
324 void gtk_cell_area_get_preferred_height_for_width (GtkCellArea *area,
325 GtkCellAreaContext *context,
328 gint *minimum_height,
329 gint *natural_height);
330 void gtk_cell_area_get_preferred_height (GtkCellArea *area,
331 GtkCellAreaContext *context,
335 void gtk_cell_area_get_preferred_width_for_height (GtkCellArea *area,
336 GtkCellAreaContext *context,
340 gint *natural_width);
341 G_CONST_RETURN gchar *gtk_cell_area_get_current_path_string (GtkCellArea *area);
345 void gtk_cell_area_apply_attributes (GtkCellArea *area,
346 GtkTreeModel *tree_model,
348 gboolean is_expander,
349 gboolean is_expanded);
350 void gtk_cell_area_attribute_connect (GtkCellArea *area,
351 GtkCellRenderer *renderer,
352 const gchar *attribute,
354 void gtk_cell_area_attribute_disconnect (GtkCellArea *area,
355 GtkCellRenderer *renderer,
356 const gchar *attribute);
358 /* Cell Properties */
359 void gtk_cell_area_class_install_cell_property (GtkCellAreaClass *aclass,
362 GParamSpec* gtk_cell_area_class_find_cell_property (GtkCellAreaClass *aclass,
363 const gchar *property_name);
364 GParamSpec** gtk_cell_area_class_list_cell_properties (GtkCellAreaClass *aclass,
365 guint *n_properties);
366 void gtk_cell_area_add_with_properties (GtkCellArea *area,
367 GtkCellRenderer *renderer,
368 const gchar *first_prop_name,
369 ...) G_GNUC_NULL_TERMINATED;
370 void gtk_cell_area_cell_set (GtkCellArea *area,
371 GtkCellRenderer *renderer,
372 const gchar *first_prop_name,
373 ...) G_GNUC_NULL_TERMINATED;
374 void gtk_cell_area_cell_get (GtkCellArea *area,
375 GtkCellRenderer *renderer,
376 const gchar *first_prop_name,
377 ...) G_GNUC_NULL_TERMINATED;
378 void gtk_cell_area_cell_set_valist (GtkCellArea *area,
379 GtkCellRenderer *renderer,
380 const gchar *first_property_name,
382 void gtk_cell_area_cell_get_valist (GtkCellArea *area,
383 GtkCellRenderer *renderer,
384 const gchar *first_property_name,
386 void gtk_cell_area_cell_set_property (GtkCellArea *area,
387 GtkCellRenderer *renderer,
388 const gchar *property_name,
389 const GValue *value);
390 void gtk_cell_area_cell_get_property (GtkCellArea *area,
391 GtkCellRenderer *renderer,
392 const gchar *property_name,
396 gboolean gtk_cell_area_is_activatable (GtkCellArea *area);
397 gboolean gtk_cell_area_activate (GtkCellArea *area,
398 GtkCellAreaContext *context,
400 const GdkRectangle *cell_area,
401 GtkCellRendererState flags);
402 gboolean gtk_cell_area_focus (GtkCellArea *area,
403 GtkDirectionType direction);
404 void gtk_cell_area_set_focus_cell (GtkCellArea *area,
405 GtkCellRenderer *renderer);
406 GtkCellRenderer *gtk_cell_area_get_focus_cell (GtkCellArea *area);
410 void gtk_cell_area_add_focus_sibling (GtkCellArea *area,
411 GtkCellRenderer *renderer,
412 GtkCellRenderer *sibling);
413 void gtk_cell_area_remove_focus_sibling (GtkCellArea *area,
414 GtkCellRenderer *renderer,
415 GtkCellRenderer *sibling);
416 gboolean gtk_cell_area_is_focus_sibling (GtkCellArea *area,
417 GtkCellRenderer *renderer,
418 GtkCellRenderer *sibling);
419 G_CONST_RETURN GList *gtk_cell_area_get_focus_siblings (GtkCellArea *area,
420 GtkCellRenderer *renderer);
421 GtkCellRenderer *gtk_cell_area_get_focus_from_sibling (GtkCellArea *area,
422 GtkCellRenderer *renderer);
424 /* Cell Activation/Editing */
425 GtkCellRenderer *gtk_cell_area_get_edited_cell (GtkCellArea *area);
426 GtkCellEditable *gtk_cell_area_get_edit_widget (GtkCellArea *area);
427 gboolean gtk_cell_area_activate_cell (GtkCellArea *area,
429 GtkCellRenderer *renderer,
431 const GdkRectangle *cell_area,
432 GtkCellRendererState flags);
433 void gtk_cell_area_stop_editing (GtkCellArea *area,
436 /* Functions for area implementations */
438 /* Distinguish the inner cell area from the whole requested area including margins */
439 void gtk_cell_area_inner_cell_area (GtkCellArea *area,
441 const GdkRectangle *cell_area,
442 GdkRectangle *inner_area);
444 /* Request the size of a cell while respecting the cell margins (requests are margin inclusive) */
445 void gtk_cell_area_request_renderer (GtkCellArea *area,
446 GtkCellRenderer *renderer,
447 GtkOrientation orientation,
455 #endif /* __GTK_CELL_AREA_H__ */