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 * @area: the area allocated to @renderer inside the rectangle provided to gtk_cell_area_foreach_alloc().
79 * @data: user-supplied data
81 * The type of the callback functions used for iterating over
82 * the cell renderers and their allocated areas inside a #GtkCellArea,
83 * see gtk_cell_area_foreach_alloc().
85 * Return value: %TRUE to stop iterating over cells.
87 typedef gboolean (*GtkCellAllocCallback) (GtkCellRenderer *renderer,
88 const GdkRectangle *cell_area,
95 GInitiallyUnowned parent_instance;
97 GtkCellAreaPrivate *priv;
103 * @add: adds a #GtkCellRenderer to the area.
104 * @remove: removes a #GtkCellRenderer from the area.
105 * @foreach: Calls the #GtkCellCallback function on every #GtkCellRenderer in the area
106 * with the provided user data until the callback returns %TRUE.
107 * @foreach_alloc: Calls the #GtkCellAllocCallback function on every #GtkCellRenderer in the area
108 * with the allocated area for the cell and the provided user data until the callback returns %TRUE.
109 * @event: Handle an event in the area, this is generally used to activate a cell
110 * at the event location for button events but can also be used to generically pass
111 * events to #GtkWidgets drawn onto the area.
112 * @render: Actually render the area's cells to the specified rectangle, @background_area
113 * should be correctly distributed to the cells coresponding background areas.
114 * @apply_attributes: Apply the cell attributes to the cells. This is implemented as a signal and
115 * generally #GtkCellArea subclasses dont need to implement this since it's handled by the base
116 * class but can be overridden to apply some custom attributes.
117 * @create_context: Creates and returns a class specific #GtkCellAreaContext to store cell
118 * alignment and allocation details for a said #GtkCellArea class.
119 * @get_request_mode: This allows an area to tell its layouting widget whether it prefers to
120 * be allocated in %GTK_SIZE_REQUEST_HEIGHT_FOR_WIDTH or %GTK_SIZE_REQUEST_WIDTH_FOR_HEIGHT mode.
121 * @get_preferred_width: Calculates the minimum and natural width of the area's cells
122 * with the current attributes applied while considering the particular layouting details
123 * of the said #GtkCellArea. While requests are performed over a series of rows, alignments
124 * and overall minimum and natural sizes should be stored in the corresponding #GtkCellAreaContext.
125 * @get_preferred_height_for_width: Calculates the minimum and natural height for the area
126 * if the passed @context would be allocated the given width. When implementing this virtual
127 * method it is safe to assume that @context has already stored the aligned cell widths
128 * for every #GtkTreeModel row that @context will be allocated for since this information
129 * was stored at #GtkCellAreaClass.get_preferred_width() time. This virtual method should
130 * also store any necessary alignments of cell heights for the case that the context is
131 * allocated a height.
132 * @get_preferred_height: Calculates the minimum and natural height of the area's cells
133 * with the current attributes applied. Essentially this is the same as
134 * #GtkCellAreaClass.get_preferred_width() only for areas that are being requested as
135 * %GTK_SIZE_REQUEST_WIDTH_FOR_HEIGHT.
136 * @get_preferred_width_for_height: Calculates the minimum and natural width for the area
137 * if the passed @context would be allocated the given height. The same as
138 * #GtkCellAreaClass.get_preferred_height_for_width() only for handling requests in the
139 * %GTK_SIZE_REQUEST_WIDTH_FOR_HEIGHT mode.
140 * @set_cell_property: This should be implemented to handle changes in child cell properties
141 * for a given #GtkCellRenderer that were previously installed on the #GtkCellAreaClass with
142 * gtk_cell_area_class_install_cell_property().
143 * @get_cell_property: This should be implemented to report the values of child cell properties
144 * for a given child #GtkCellRenderer.
145 * @focus: This virtual method should be implemented to navigate focus from cell to cell
146 * inside the #GtkCellArea. The #GtkCellArea should move focus from cell to cell inside
147 * the area and return %FALSE if focus logically leaves the area with the following exceptions:
148 * When the area contains no activatable cells, the entire area recieves focus. Focus should not
149 * be given to cells that are actually "focus siblings" of other sibling cells
150 * (see gtk_cell_area_get_focus_from_sibling()). Focus is set by calling gtk_cell_area_set_focus_cell().
151 * @is_activatable: Returns whether the #GtkCellArea can respond to #GtkCellAreaClass.activate(),
152 * usually this does not need to be implemented since the base class takes care of this however
153 * it can be enhanced if the #GtkCellArea subclass can handle activation in other ways than
154 * activating its #GtkCellRenderers.
155 * @activate: This is called when the layouting widget rendering the #GtkCellArea activates
156 * the focus cell (see gtk_cell_area_get_focus_cell()).
158 struct _GtkCellAreaClass
161 GInitiallyUnownedClass parent_class;
166 void (* add) (GtkCellArea *area,
167 GtkCellRenderer *renderer);
168 void (* remove) (GtkCellArea *area,
169 GtkCellRenderer *renderer);
170 void (* foreach) (GtkCellArea *area,
171 GtkCellCallback callback,
172 gpointer callback_data);
173 void (* foreach_alloc) (GtkCellArea *area,
174 GtkCellAreaContext *context,
176 const GdkRectangle *cell_area,
177 GtkCellAllocCallback callback,
178 gpointer callback_data);
179 gint (* event) (GtkCellArea *area,
180 GtkCellAreaContext *context,
183 const GdkRectangle *cell_area,
184 GtkCellRendererState flags);
185 void (* render) (GtkCellArea *area,
186 GtkCellAreaContext *context,
189 const GdkRectangle *background_area,
190 const GdkRectangle *cell_area,
191 GtkCellRendererState flags,
192 gboolean paint_focus);
193 void (* apply_attributes) (GtkCellArea *area,
194 GtkTreeModel *tree_model,
196 gboolean is_expander,
197 gboolean is_expanded);
200 GtkCellAreaContext *(* create_context) (GtkCellArea *area);
201 GtkSizeRequestMode (* get_request_mode) (GtkCellArea *area);
202 void (* get_preferred_width) (GtkCellArea *area,
203 GtkCellAreaContext *context,
206 gint *natural_width);
207 void (* get_preferred_height_for_width) (GtkCellArea *area,
208 GtkCellAreaContext *context,
211 gint *minimum_height,
212 gint *natural_height);
213 void (* get_preferred_height) (GtkCellArea *area,
214 GtkCellAreaContext *context,
216 gint *minimum_height,
217 gint *natural_height);
218 void (* get_preferred_width_for_height) (GtkCellArea *area,
219 GtkCellAreaContext *context,
223 gint *natural_width);
225 /* Cell Properties */
226 void (* set_cell_property) (GtkCellArea *area,
227 GtkCellRenderer *renderer,
231 void (* get_cell_property) (GtkCellArea *area,
232 GtkCellRenderer *renderer,
238 gboolean (* focus) (GtkCellArea *area,
239 GtkDirectionType direction);
240 gboolean (* is_activatable) (GtkCellArea *area);
241 gboolean (* activate) (GtkCellArea *area,
242 GtkCellAreaContext *context,
244 const GdkRectangle *cell_area,
245 GtkCellRendererState flags);
249 /* Padding for future expansion */
250 void (*_gtk_reserved1) (void);
251 void (*_gtk_reserved2) (void);
252 void (*_gtk_reserved3) (void);
253 void (*_gtk_reserved4) (void);
254 void (*_gtk_reserved5) (void);
255 void (*_gtk_reserved6) (void);
256 void (*_gtk_reserved7) (void);
257 void (*_gtk_reserved8) (void);
260 GType gtk_cell_area_get_type (void) G_GNUC_CONST;
263 void gtk_cell_area_add (GtkCellArea *area,
264 GtkCellRenderer *renderer);
265 void gtk_cell_area_remove (GtkCellArea *area,
266 GtkCellRenderer *renderer);
267 gboolean gtk_cell_area_has_renderer (GtkCellArea *area,
268 GtkCellRenderer *renderer);
269 void gtk_cell_area_foreach (GtkCellArea *area,
270 GtkCellCallback callback,
271 gpointer callback_data);
272 void gtk_cell_area_foreach_alloc (GtkCellArea *area,
273 GtkCellAreaContext *context,
275 const GdkRectangle *cell_area,
276 GtkCellAllocCallback callback,
277 gpointer callback_data);
278 gint gtk_cell_area_event (GtkCellArea *area,
279 GtkCellAreaContext *context,
282 const GdkRectangle *cell_area,
283 GtkCellRendererState flags);
284 void gtk_cell_area_render (GtkCellArea *area,
285 GtkCellAreaContext *context,
288 const GdkRectangle *background_area,
289 const GdkRectangle *cell_area,
290 GtkCellRendererState flags,
291 gboolean paint_focus);
292 void gtk_cell_area_set_style_detail (GtkCellArea *area,
293 const gchar *detail);
294 G_CONST_RETURN gchar *gtk_cell_area_get_style_detail (GtkCellArea *area);
297 void gtk_cell_area_get_cell_allocation (GtkCellArea *area,
298 GtkCellAreaContext *context,
300 GtkCellRenderer *renderer,
301 const GdkRectangle *cell_area,
302 GdkRectangle *allocation);
303 GtkCellRenderer *gtk_cell_area_get_cell_at_position (GtkCellArea *area,
304 GtkCellAreaContext *context,
306 const GdkRectangle *cell_area,
309 GdkRectangle *alloc_area);
313 GtkCellAreaContext *gtk_cell_area_create_context (GtkCellArea *area);
314 GtkSizeRequestMode gtk_cell_area_get_request_mode (GtkCellArea *area);
315 void gtk_cell_area_get_preferred_width (GtkCellArea *area,
316 GtkCellAreaContext *context,
320 void gtk_cell_area_get_preferred_height_for_width (GtkCellArea *area,
321 GtkCellAreaContext *context,
324 gint *minimum_height,
325 gint *natural_height);
326 void gtk_cell_area_get_preferred_height (GtkCellArea *area,
327 GtkCellAreaContext *context,
331 void gtk_cell_area_get_preferred_width_for_height (GtkCellArea *area,
332 GtkCellAreaContext *context,
336 gint *natural_width);
337 G_CONST_RETURN gchar *gtk_cell_area_get_current_path_string (GtkCellArea *area);
341 void gtk_cell_area_apply_attributes (GtkCellArea *area,
342 GtkTreeModel *tree_model,
344 gboolean is_expander,
345 gboolean is_expanded);
346 void gtk_cell_area_attribute_connect (GtkCellArea *area,
347 GtkCellRenderer *renderer,
348 const gchar *attribute,
350 void gtk_cell_area_attribute_disconnect (GtkCellArea *area,
351 GtkCellRenderer *renderer,
352 const gchar *attribute);
354 /* Cell Properties */
355 void gtk_cell_area_class_install_cell_property (GtkCellAreaClass *aclass,
358 GParamSpec* gtk_cell_area_class_find_cell_property (GtkCellAreaClass *aclass,
359 const gchar *property_name);
360 GParamSpec** gtk_cell_area_class_list_cell_properties (GtkCellAreaClass *aclass,
361 guint *n_properties);
362 void gtk_cell_area_add_with_properties (GtkCellArea *area,
363 GtkCellRenderer *renderer,
364 const gchar *first_prop_name,
365 ...) G_GNUC_NULL_TERMINATED;
366 void gtk_cell_area_cell_set (GtkCellArea *area,
367 GtkCellRenderer *renderer,
368 const gchar *first_prop_name,
369 ...) G_GNUC_NULL_TERMINATED;
370 void gtk_cell_area_cell_get (GtkCellArea *area,
371 GtkCellRenderer *renderer,
372 const gchar *first_prop_name,
373 ...) G_GNUC_NULL_TERMINATED;
374 void gtk_cell_area_cell_set_valist (GtkCellArea *area,
375 GtkCellRenderer *renderer,
376 const gchar *first_property_name,
378 void gtk_cell_area_cell_get_valist (GtkCellArea *area,
379 GtkCellRenderer *renderer,
380 const gchar *first_property_name,
382 void gtk_cell_area_cell_set_property (GtkCellArea *area,
383 GtkCellRenderer *renderer,
384 const gchar *property_name,
385 const GValue *value);
386 void gtk_cell_area_cell_get_property (GtkCellArea *area,
387 GtkCellRenderer *renderer,
388 const gchar *property_name,
392 gboolean gtk_cell_area_is_activatable (GtkCellArea *area);
393 gboolean gtk_cell_area_activate (GtkCellArea *area,
394 GtkCellAreaContext *context,
396 const GdkRectangle *cell_area,
397 GtkCellRendererState flags);
398 gboolean gtk_cell_area_focus (GtkCellArea *area,
399 GtkDirectionType direction);
400 void gtk_cell_area_set_focus_cell (GtkCellArea *area,
401 GtkCellRenderer *renderer);
402 GtkCellRenderer *gtk_cell_area_get_focus_cell (GtkCellArea *area);
406 void gtk_cell_area_add_focus_sibling (GtkCellArea *area,
407 GtkCellRenderer *renderer,
408 GtkCellRenderer *sibling);
409 void gtk_cell_area_remove_focus_sibling (GtkCellArea *area,
410 GtkCellRenderer *renderer,
411 GtkCellRenderer *sibling);
412 gboolean gtk_cell_area_is_focus_sibling (GtkCellArea *area,
413 GtkCellRenderer *renderer,
414 GtkCellRenderer *sibling);
415 G_CONST_RETURN GList *gtk_cell_area_get_focus_siblings (GtkCellArea *area,
416 GtkCellRenderer *renderer);
417 GtkCellRenderer *gtk_cell_area_get_focus_from_sibling (GtkCellArea *area,
418 GtkCellRenderer *renderer);
420 /* Cell Activation/Editing */
421 GtkCellRenderer *gtk_cell_area_get_edited_cell (GtkCellArea *area);
422 GtkCellEditable *gtk_cell_area_get_edit_widget (GtkCellArea *area);
423 gboolean gtk_cell_area_activate_cell (GtkCellArea *area,
425 GtkCellRenderer *renderer,
427 const GdkRectangle *cell_area,
428 GtkCellRendererState flags);
429 void gtk_cell_area_stop_editing (GtkCellArea *area,
432 /* Functions for area implementations */
434 /* Distinguish the inner cell area from the whole requested area including margins */
435 void gtk_cell_area_inner_cell_area (GtkCellArea *area,
437 const GdkRectangle *cell_area,
438 GdkRectangle *inner_area);
440 /* Request the size of a cell while respecting the cell margins (requests are margin inclusive) */
441 void gtk_cell_area_request_renderer (GtkCellArea *area,
442 GtkCellRenderer *renderer,
443 GtkOrientation orientation,
451 #endif /* __GTK_CELL_AREA_H__ */