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;
51 * @renderer: the cell renderer to operate on
52 * @data: user-supplied data
54 * The type of the callback functions used for iterating over
55 * the cell renderers of a #GtkCellArea, see gtk_cell_area_forall().
57 typedef void (*GtkCellCallback) (GtkCellRenderer *renderer,
64 GInitiallyUnowned parent_instance;
66 GtkCellAreaPrivate *priv;
72 * @add: adds a #GtkCellRenderer to the area.
73 * @remove: removes a #GtkCellRenderer from the area.
74 * @forall: Calls the #GtkCellCallback function on every #GtkCellRenderer in the area
75 * with the provided user data.
76 * @get_cell_allocation: Gets the position (relative to the passed @cell_area rectangle)
77 * and size of a #GtkCellRenderer.
78 * @event: Handle an event in the area, this is generally used to activate a cell
79 * at the event location for button events but can also be used to generically pass
80 * events to #GtkWidgets drawn onto the area.
81 * @render: Actually render the area's cells to the specified rectangle, @background_area
82 * should be correctly distributed to the cells coresponding background areas.
83 * @apply_attributes: Apply the cell attributes to the cells. This is implemented as a signal and
84 * generally #GtkCellArea subclasses dont need to implement this since it's handled by the base
85 * class but can be overridden to apply some custom attributes.
86 * @create_context: Creates and returns a class specific #GtkCellAreaContext to store cell
87 * alignment and allocation details for a said #GtkCellArea class.
88 * @get_request_mode: This allows an area to tell its layouting widget whether it prefers to
89 * be allocated in %GTK_SIZE_REQUEST_HEIGHT_FOR_WIDTH or %GTK_SIZE_REQUEST_WIDTH_FOR_HEIGHT mode.
90 * @get_preferred_width: Calculates the minimum and natural width of the area's cells
91 * with the current attributes applied while considering the particular layouting details
92 * of the said #GtkCellArea. While requests are performed over a series of rows, alignments
93 * and overall minimum and natural sizes should be stored in the corresponding #GtkCellAreaContext.
94 * @get_preferred_height_for_width: Calculates the minimum and natural height for the area
95 * if the passed @context would be allocated the given width. When implementing this virtual
96 * method it is safe to assume that @context has already stored the aligned cell widths
97 * for every #GtkTreeModel row that @context will be allocated for since this information
98 * was stored at #GtkCellAreaClass.get_preferred_width() time. This virtual method should
99 * also store any necessary alignments of cell heights for the case that the context is
100 * allocated a height.
101 * @get_preferred_height: Calculates the minimum and natural height of the area's cells
102 * with the current attributes applied. Essentially this is the same as
103 * #GtkCellAreaClass.get_preferred_width() only for areas that are being requested as
104 * %GTK_SIZE_REQUEST_WIDTH_FOR_HEIGHT.
105 * @get_preferred_width_for_height: Calculates the minimum and natural width for the area
106 * if the passed @context would be allocated the given height. The same as
107 * #GtkCellAreaClass.get_preferred_height_for_width() only for handling requests in the
108 * %GTK_SIZE_REQUEST_WIDTH_FOR_HEIGHT mode.
109 * @set_cell_property: This should be implemented to handle changes in child cell properties
110 * for a given #GtkCellRenderer that were previously installed on the #GtkCellAreaClass with
111 * gtk_cell_area_class_install_cell_property().
112 * @get_cell_property: This should be implemented to report the values of child cell properties
113 * for a given child #GtkCellRenderer.
114 * @focus: This virtual method should be implemented to navigate focus from cell to cell
115 * inside the #GtkCellArea. The #GtkCellArea should move focus from cell to cell inside
116 * the area and return %FALSE if focus logically leaves the area with the following exceptions:
117 * When the area contains no activatable cells, the entire area recieves focus. Focus should not
118 * be given to cells that are actually "focus siblings" of other sibling cells
119 * (see gtk_cell_area_get_focus_from_sibling()). Focus is set by calling gtk_cell_area_set_focus_cell().
120 * @is_activatable: Returns whether the #GtkCellArea can respond to #GtkCellAreaClass.activate(),
121 * usually this does not need to be implemented since the base class takes care of this however
122 * it can be enhanced if the #GtkCellArea subclass can handle activation in other ways than
123 * activating its #GtkCellRenderers.
124 * @activate: This is called when the layouting widget rendering the #GtkCellArea activates
125 * the focus cell (see gtk_cell_area_get_focus_cell()).
127 struct _GtkCellAreaClass
130 GInitiallyUnownedClass parent_class;
135 void (* add) (GtkCellArea *area,
136 GtkCellRenderer *renderer);
137 void (* remove) (GtkCellArea *area,
138 GtkCellRenderer *renderer);
139 void (* forall) (GtkCellArea *area,
140 GtkCellCallback callback,
141 gpointer callback_data);
142 void (* get_cell_allocation) (GtkCellArea *area,
143 GtkCellAreaContext *context,
145 GtkCellRenderer *renderer,
146 const GdkRectangle *cell_area,
147 GdkRectangle *allocation);
148 gint (* event) (GtkCellArea *area,
149 GtkCellAreaContext *context,
152 const GdkRectangle *cell_area,
153 GtkCellRendererState flags);
154 void (* render) (GtkCellArea *area,
155 GtkCellAreaContext *context,
158 const GdkRectangle *background_area,
159 const GdkRectangle *cell_area,
160 GtkCellRendererState flags,
161 gboolean paint_focus);
162 void (* apply_attributes) (GtkCellArea *area,
163 GtkTreeModel *tree_model,
165 gboolean is_expander,
166 gboolean is_expanded);
169 GtkCellAreaContext *(* create_context) (GtkCellArea *area);
170 GtkSizeRequestMode (* get_request_mode) (GtkCellArea *area);
171 void (* get_preferred_width) (GtkCellArea *area,
172 GtkCellAreaContext *context,
175 gint *natural_width);
176 void (* get_preferred_height_for_width) (GtkCellArea *area,
177 GtkCellAreaContext *context,
180 gint *minimum_height,
181 gint *natural_height);
182 void (* get_preferred_height) (GtkCellArea *area,
183 GtkCellAreaContext *context,
185 gint *minimum_height,
186 gint *natural_height);
187 void (* get_preferred_width_for_height) (GtkCellArea *area,
188 GtkCellAreaContext *context,
192 gint *natural_width);
194 /* Cell Properties */
195 void (* set_cell_property) (GtkCellArea *area,
196 GtkCellRenderer *renderer,
200 void (* get_cell_property) (GtkCellArea *area,
201 GtkCellRenderer *renderer,
207 gboolean (* focus) (GtkCellArea *area,
208 GtkDirectionType direction);
209 gboolean (* is_activatable) (GtkCellArea *area);
210 gboolean (* activate) (GtkCellArea *area,
211 GtkCellAreaContext *context,
213 const GdkRectangle *cell_area,
214 GtkCellRendererState flags);
218 /* Padding for future expansion */
219 void (*_gtk_reserved1) (void);
220 void (*_gtk_reserved2) (void);
221 void (*_gtk_reserved3) (void);
222 void (*_gtk_reserved4) (void);
223 void (*_gtk_reserved5) (void);
224 void (*_gtk_reserved6) (void);
225 void (*_gtk_reserved7) (void);
226 void (*_gtk_reserved8) (void);
229 GType gtk_cell_area_get_type (void) G_GNUC_CONST;
232 void gtk_cell_area_add (GtkCellArea *area,
233 GtkCellRenderer *renderer);
234 void gtk_cell_area_remove (GtkCellArea *area,
235 GtkCellRenderer *renderer);
236 gboolean gtk_cell_area_has_renderer (GtkCellArea *area,
237 GtkCellRenderer *renderer);
238 void gtk_cell_area_forall (GtkCellArea *area,
239 GtkCellCallback callback,
240 gpointer callback_data);
241 void gtk_cell_area_get_cell_allocation (GtkCellArea *area,
242 GtkCellAreaContext *context,
244 GtkCellRenderer *renderer,
245 const GdkRectangle *cell_area,
246 GdkRectangle *allocation);
247 gint gtk_cell_area_event (GtkCellArea *area,
248 GtkCellAreaContext *context,
251 const GdkRectangle *cell_area,
252 GtkCellRendererState flags);
253 void gtk_cell_area_render (GtkCellArea *area,
254 GtkCellAreaContext *context,
257 const GdkRectangle *background_area,
258 const GdkRectangle *cell_area,
259 GtkCellRendererState flags,
260 gboolean paint_focus);
261 void gtk_cell_area_set_style_detail (GtkCellArea *area,
262 const gchar *detail);
263 G_CONST_RETURN gchar *gtk_cell_area_get_style_detail (GtkCellArea *area);
266 GtkCellAreaContext *gtk_cell_area_create_context (GtkCellArea *area);
267 GtkSizeRequestMode gtk_cell_area_get_request_mode (GtkCellArea *area);
268 void gtk_cell_area_get_preferred_width (GtkCellArea *area,
269 GtkCellAreaContext *context,
273 void gtk_cell_area_get_preferred_height_for_width (GtkCellArea *area,
274 GtkCellAreaContext *context,
277 gint *minimum_height,
278 gint *natural_height);
279 void gtk_cell_area_get_preferred_height (GtkCellArea *area,
280 GtkCellAreaContext *context,
284 void gtk_cell_area_get_preferred_width_for_height (GtkCellArea *area,
285 GtkCellAreaContext *context,
289 gint *natural_width);
290 G_CONST_RETURN gchar *gtk_cell_area_get_current_path_string (GtkCellArea *area);
294 void gtk_cell_area_apply_attributes (GtkCellArea *area,
295 GtkTreeModel *tree_model,
297 gboolean is_expander,
298 gboolean is_expanded);
299 void gtk_cell_area_attribute_connect (GtkCellArea *area,
300 GtkCellRenderer *renderer,
301 const gchar *attribute,
303 void gtk_cell_area_attribute_disconnect (GtkCellArea *area,
304 GtkCellRenderer *renderer,
305 const gchar *attribute);
307 /* Cell Properties */
308 void gtk_cell_area_class_install_cell_property (GtkCellAreaClass *aclass,
311 GParamSpec* gtk_cell_area_class_find_cell_property (GtkCellAreaClass *aclass,
312 const gchar *property_name);
313 GParamSpec** gtk_cell_area_class_list_cell_properties (GtkCellAreaClass *aclass,
314 guint *n_properties);
315 void gtk_cell_area_add_with_properties (GtkCellArea *area,
316 GtkCellRenderer *renderer,
317 const gchar *first_prop_name,
318 ...) G_GNUC_NULL_TERMINATED;
319 void gtk_cell_area_cell_set (GtkCellArea *area,
320 GtkCellRenderer *renderer,
321 const gchar *first_prop_name,
322 ...) G_GNUC_NULL_TERMINATED;
323 void gtk_cell_area_cell_get (GtkCellArea *area,
324 GtkCellRenderer *renderer,
325 const gchar *first_prop_name,
326 ...) G_GNUC_NULL_TERMINATED;
327 void gtk_cell_area_cell_set_valist (GtkCellArea *area,
328 GtkCellRenderer *renderer,
329 const gchar *first_property_name,
331 void gtk_cell_area_cell_get_valist (GtkCellArea *area,
332 GtkCellRenderer *renderer,
333 const gchar *first_property_name,
335 void gtk_cell_area_cell_set_property (GtkCellArea *area,
336 GtkCellRenderer *renderer,
337 const gchar *property_name,
338 const GValue *value);
339 void gtk_cell_area_cell_get_property (GtkCellArea *area,
340 GtkCellRenderer *renderer,
341 const gchar *property_name,
344 #define GTK_CELL_AREA_WARN_INVALID_CHILD_PROPERTY_ID(object, property_id, pspec) \
345 G_OBJECT_WARN_INVALID_PSPEC ((object), "cell property id", (property_id), (pspec))
349 gboolean gtk_cell_area_is_activatable (GtkCellArea *area);
350 gboolean gtk_cell_area_activate (GtkCellArea *area,
351 GtkCellAreaContext *context,
353 const GdkRectangle *cell_area,
354 GtkCellRendererState flags);
355 gboolean gtk_cell_area_focus (GtkCellArea *area,
356 GtkDirectionType direction);
357 void gtk_cell_area_set_focus_cell (GtkCellArea *area,
358 GtkCellRenderer *renderer);
359 GtkCellRenderer *gtk_cell_area_get_focus_cell (GtkCellArea *area);
363 void gtk_cell_area_add_focus_sibling (GtkCellArea *area,
364 GtkCellRenderer *renderer,
365 GtkCellRenderer *sibling);
366 void gtk_cell_area_remove_focus_sibling (GtkCellArea *area,
367 GtkCellRenderer *renderer,
368 GtkCellRenderer *sibling);
369 gboolean gtk_cell_area_is_focus_sibling (GtkCellArea *area,
370 GtkCellRenderer *renderer,
371 GtkCellRenderer *sibling);
372 G_CONST_RETURN GList *gtk_cell_area_get_focus_siblings (GtkCellArea *area,
373 GtkCellRenderer *renderer);
374 GtkCellRenderer *gtk_cell_area_get_focus_from_sibling (GtkCellArea *area,
375 GtkCellRenderer *renderer);
377 /* Cell Activation/Editing */
378 GtkCellRenderer *gtk_cell_area_get_edited_cell (GtkCellArea *area);
379 GtkCellEditable *gtk_cell_area_get_edit_widget (GtkCellArea *area);
380 gboolean gtk_cell_area_activate_cell (GtkCellArea *area,
382 GtkCellRenderer *renderer,
384 const GdkRectangle *cell_area,
385 GtkCellRendererState flags);
386 void gtk_cell_area_stop_editing (GtkCellArea *area,
389 /* Functions for area implementations */
391 /* Distinguish the inner cell area from the whole requested area including margins */
392 void gtk_cell_area_inner_cell_area (GtkCellArea *area,
394 const GdkRectangle *cell_area,
395 GdkRectangle *inner_area);
397 /* Request the size of a cell while respecting the cell margins (requests are margin inclusive) */
398 void gtk_cell_area_request_renderer (GtkCellArea *area,
399 GtkCellRenderer *renderer,
400 GtkOrientation orientation,
408 #endif /* __GTK_CELL_AREA_H__ */