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,
254 /* Padding for future expansion */
255 void (*_gtk_reserved1) (void);
256 void (*_gtk_reserved2) (void);
257 void (*_gtk_reserved3) (void);
258 void (*_gtk_reserved4) (void);
259 void (*_gtk_reserved5) (void);
260 void (*_gtk_reserved6) (void);
261 void (*_gtk_reserved7) (void);
262 void (*_gtk_reserved8) (void);
265 GType gtk_cell_area_get_type (void) G_GNUC_CONST;
268 void gtk_cell_area_add (GtkCellArea *area,
269 GtkCellRenderer *renderer);
270 void gtk_cell_area_remove (GtkCellArea *area,
271 GtkCellRenderer *renderer);
272 gboolean gtk_cell_area_has_renderer (GtkCellArea *area,
273 GtkCellRenderer *renderer);
274 void gtk_cell_area_foreach (GtkCellArea *area,
275 GtkCellCallback callback,
276 gpointer callback_data);
277 void gtk_cell_area_foreach_alloc (GtkCellArea *area,
278 GtkCellAreaContext *context,
280 const GdkRectangle *cell_area,
281 const GdkRectangle *background_area,
282 GtkCellAllocCallback callback,
283 gpointer callback_data);
284 gint gtk_cell_area_event (GtkCellArea *area,
285 GtkCellAreaContext *context,
288 const GdkRectangle *cell_area,
289 GtkCellRendererState flags);
290 void gtk_cell_area_render (GtkCellArea *area,
291 GtkCellAreaContext *context,
294 const GdkRectangle *background_area,
295 const GdkRectangle *cell_area,
296 GtkCellRendererState flags,
297 gboolean paint_focus);
298 void gtk_cell_area_set_style_detail (GtkCellArea *area,
299 const gchar *detail);
300 G_CONST_RETURN gchar *gtk_cell_area_get_style_detail (GtkCellArea *area);
303 void gtk_cell_area_get_cell_allocation (GtkCellArea *area,
304 GtkCellAreaContext *context,
306 GtkCellRenderer *renderer,
307 const GdkRectangle *cell_area,
308 GdkRectangle *allocation);
309 GtkCellRenderer *gtk_cell_area_get_cell_at_position (GtkCellArea *area,
310 GtkCellAreaContext *context,
312 const GdkRectangle *cell_area,
315 GdkRectangle *alloc_area);
318 GtkCellAreaContext *gtk_cell_area_create_context (GtkCellArea *area);
319 GtkSizeRequestMode gtk_cell_area_get_request_mode (GtkCellArea *area);
320 void gtk_cell_area_get_preferred_width (GtkCellArea *area,
321 GtkCellAreaContext *context,
325 void gtk_cell_area_get_preferred_height_for_width (GtkCellArea *area,
326 GtkCellAreaContext *context,
329 gint *minimum_height,
330 gint *natural_height);
331 void gtk_cell_area_get_preferred_height (GtkCellArea *area,
332 GtkCellAreaContext *context,
336 void gtk_cell_area_get_preferred_width_for_height (GtkCellArea *area,
337 GtkCellAreaContext *context,
341 gint *natural_width);
342 G_CONST_RETURN gchar *gtk_cell_area_get_current_path_string (GtkCellArea *area);
346 void gtk_cell_area_apply_attributes (GtkCellArea *area,
347 GtkTreeModel *tree_model,
349 gboolean is_expander,
350 gboolean is_expanded);
351 void gtk_cell_area_attribute_connect (GtkCellArea *area,
352 GtkCellRenderer *renderer,
353 const gchar *attribute,
355 void gtk_cell_area_attribute_disconnect (GtkCellArea *area,
356 GtkCellRenderer *renderer,
357 const gchar *attribute);
359 /* Cell Properties */
360 void gtk_cell_area_class_install_cell_property (GtkCellAreaClass *aclass,
363 GParamSpec* gtk_cell_area_class_find_cell_property (GtkCellAreaClass *aclass,
364 const gchar *property_name);
365 GParamSpec** gtk_cell_area_class_list_cell_properties (GtkCellAreaClass *aclass,
366 guint *n_properties);
367 void gtk_cell_area_add_with_properties (GtkCellArea *area,
368 GtkCellRenderer *renderer,
369 const gchar *first_prop_name,
370 ...) G_GNUC_NULL_TERMINATED;
371 void gtk_cell_area_cell_set (GtkCellArea *area,
372 GtkCellRenderer *renderer,
373 const gchar *first_prop_name,
374 ...) G_GNUC_NULL_TERMINATED;
375 void gtk_cell_area_cell_get (GtkCellArea *area,
376 GtkCellRenderer *renderer,
377 const gchar *first_prop_name,
378 ...) G_GNUC_NULL_TERMINATED;
379 void gtk_cell_area_cell_set_valist (GtkCellArea *area,
380 GtkCellRenderer *renderer,
381 const gchar *first_property_name,
383 void gtk_cell_area_cell_get_valist (GtkCellArea *area,
384 GtkCellRenderer *renderer,
385 const gchar *first_property_name,
387 void gtk_cell_area_cell_set_property (GtkCellArea *area,
388 GtkCellRenderer *renderer,
389 const gchar *property_name,
390 const GValue *value);
391 void gtk_cell_area_cell_get_property (GtkCellArea *area,
392 GtkCellRenderer *renderer,
393 const gchar *property_name,
397 gboolean gtk_cell_area_is_activatable (GtkCellArea *area);
398 gboolean gtk_cell_area_activate (GtkCellArea *area,
399 GtkCellAreaContext *context,
401 const GdkRectangle *cell_area,
402 GtkCellRendererState flags,
404 gboolean gtk_cell_area_focus (GtkCellArea *area,
405 GtkDirectionType direction);
406 void gtk_cell_area_set_focus_cell (GtkCellArea *area,
407 GtkCellRenderer *renderer);
408 GtkCellRenderer *gtk_cell_area_get_focus_cell (GtkCellArea *area);
412 void gtk_cell_area_add_focus_sibling (GtkCellArea *area,
413 GtkCellRenderer *renderer,
414 GtkCellRenderer *sibling);
415 void gtk_cell_area_remove_focus_sibling (GtkCellArea *area,
416 GtkCellRenderer *renderer,
417 GtkCellRenderer *sibling);
418 gboolean gtk_cell_area_is_focus_sibling (GtkCellArea *area,
419 GtkCellRenderer *renderer,
420 GtkCellRenderer *sibling);
421 G_CONST_RETURN GList *gtk_cell_area_get_focus_siblings (GtkCellArea *area,
422 GtkCellRenderer *renderer);
423 GtkCellRenderer *gtk_cell_area_get_focus_from_sibling (GtkCellArea *area,
424 GtkCellRenderer *renderer);
426 /* Cell Activation/Editing */
427 GtkCellRenderer *gtk_cell_area_get_edited_cell (GtkCellArea *area);
428 GtkCellEditable *gtk_cell_area_get_edit_widget (GtkCellArea *area);
429 gboolean gtk_cell_area_activate_cell (GtkCellArea *area,
431 GtkCellRenderer *renderer,
433 const GdkRectangle *cell_area,
434 GtkCellRendererState flags);
435 void gtk_cell_area_stop_editing (GtkCellArea *area,
438 /* Functions for area implementations */
440 /* Distinguish the inner cell area from the whole requested area including margins */
441 void gtk_cell_area_inner_cell_area (GtkCellArea *area,
443 const GdkRectangle *cell_area,
444 GdkRectangle *inner_area);
446 /* Request the size of a cell while respecting the cell margins (requests are margin inclusive) */
447 void gtk_cell_area_request_renderer (GtkCellArea *area,
448 GtkCellRenderer *renderer,
449 GtkOrientation orientation,
457 #endif /* __GTK_CELL_AREA_H__ */