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_forall().
70 typedef void (*GtkCellCallback) (GtkCellRenderer *renderer,
77 GInitiallyUnowned parent_instance;
79 GtkCellAreaPrivate *priv;
85 * @add: adds a #GtkCellRenderer to the area.
86 * @remove: removes a #GtkCellRenderer from the area.
87 * @forall: Calls the #GtkCellCallback function on every #GtkCellRenderer in the area
88 * with the provided user data.
89 * @get_cell_allocation: Gets the position (relative to the passed @cell_area rectangle)
90 * and size of a #GtkCellRenderer.
91 * @event: Handle an event in the area, this is generally used to activate a cell
92 * at the event location for button events but can also be used to generically pass
93 * events to #GtkWidgets drawn onto the area.
94 * @render: Actually render the area's cells to the specified rectangle, @background_area
95 * should be correctly distributed to the cells coresponding background areas.
96 * @apply_attributes: Apply the cell attributes to the cells. This is implemented as a signal and
97 * generally #GtkCellArea subclasses dont need to implement this since it's handled by the base
98 * class but can be overridden to apply some custom attributes.
99 * @create_context: Creates and returns a class specific #GtkCellAreaContext to store cell
100 * alignment and allocation details for a said #GtkCellArea class.
101 * @get_request_mode: This allows an area to tell its layouting widget whether it prefers to
102 * be allocated in %GTK_SIZE_REQUEST_HEIGHT_FOR_WIDTH or %GTK_SIZE_REQUEST_WIDTH_FOR_HEIGHT mode.
103 * @get_preferred_width: Calculates the minimum and natural width of the area's cells
104 * with the current attributes applied while considering the particular layouting details
105 * of the said #GtkCellArea. While requests are performed over a series of rows, alignments
106 * and overall minimum and natural sizes should be stored in the corresponding #GtkCellAreaContext.
107 * @get_preferred_height_for_width: Calculates the minimum and natural height for the area
108 * if the passed @context would be allocated the given width. When implementing this virtual
109 * method it is safe to assume that @context has already stored the aligned cell widths
110 * for every #GtkTreeModel row that @context will be allocated for since this information
111 * was stored at #GtkCellAreaClass.get_preferred_width() time. This virtual method should
112 * also store any necessary alignments of cell heights for the case that the context is
113 * allocated a height.
114 * @get_preferred_height: Calculates the minimum and natural height of the area's cells
115 * with the current attributes applied. Essentially this is the same as
116 * #GtkCellAreaClass.get_preferred_width() only for areas that are being requested as
117 * %GTK_SIZE_REQUEST_WIDTH_FOR_HEIGHT.
118 * @get_preferred_width_for_height: Calculates the minimum and natural width for the area
119 * if the passed @context would be allocated the given height. The same as
120 * #GtkCellAreaClass.get_preferred_height_for_width() only for handling requests in the
121 * %GTK_SIZE_REQUEST_WIDTH_FOR_HEIGHT mode.
122 * @set_cell_property: This should be implemented to handle changes in child cell properties
123 * for a given #GtkCellRenderer that were previously installed on the #GtkCellAreaClass with
124 * gtk_cell_area_class_install_cell_property().
125 * @get_cell_property: This should be implemented to report the values of child cell properties
126 * for a given child #GtkCellRenderer.
127 * @focus: This virtual method should be implemented to navigate focus from cell to cell
128 * inside the #GtkCellArea. The #GtkCellArea should move focus from cell to cell inside
129 * the area and return %FALSE if focus logically leaves the area with the following exceptions:
130 * When the area contains no activatable cells, the entire area recieves focus. Focus should not
131 * be given to cells that are actually "focus siblings" of other sibling cells
132 * (see gtk_cell_area_get_focus_from_sibling()). Focus is set by calling gtk_cell_area_set_focus_cell().
133 * @is_activatable: Returns whether the #GtkCellArea can respond to #GtkCellAreaClass.activate(),
134 * usually this does not need to be implemented since the base class takes care of this however
135 * it can be enhanced if the #GtkCellArea subclass can handle activation in other ways than
136 * activating its #GtkCellRenderers.
137 * @activate: This is called when the layouting widget rendering the #GtkCellArea activates
138 * the focus cell (see gtk_cell_area_get_focus_cell()).
140 struct _GtkCellAreaClass
143 GInitiallyUnownedClass parent_class;
148 void (* add) (GtkCellArea *area,
149 GtkCellRenderer *renderer);
150 void (* remove) (GtkCellArea *area,
151 GtkCellRenderer *renderer);
152 void (* forall) (GtkCellArea *area,
153 GtkCellCallback callback,
154 gpointer callback_data);
155 void (* get_cell_allocation) (GtkCellArea *area,
156 GtkCellAreaContext *context,
158 GtkCellRenderer *renderer,
159 const GdkRectangle *cell_area,
160 GdkRectangle *allocation);
161 gint (* event) (GtkCellArea *area,
162 GtkCellAreaContext *context,
165 const GdkRectangle *cell_area,
166 GtkCellRendererState flags);
167 void (* render) (GtkCellArea *area,
168 GtkCellAreaContext *context,
171 const GdkRectangle *background_area,
172 const GdkRectangle *cell_area,
173 GtkCellRendererState flags,
174 gboolean paint_focus);
175 void (* apply_attributes) (GtkCellArea *area,
176 GtkTreeModel *tree_model,
178 gboolean is_expander,
179 gboolean is_expanded);
182 GtkCellAreaContext *(* create_context) (GtkCellArea *area);
183 GtkSizeRequestMode (* get_request_mode) (GtkCellArea *area);
184 void (* get_preferred_width) (GtkCellArea *area,
185 GtkCellAreaContext *context,
188 gint *natural_width);
189 void (* get_preferred_height_for_width) (GtkCellArea *area,
190 GtkCellAreaContext *context,
193 gint *minimum_height,
194 gint *natural_height);
195 void (* get_preferred_height) (GtkCellArea *area,
196 GtkCellAreaContext *context,
198 gint *minimum_height,
199 gint *natural_height);
200 void (* get_preferred_width_for_height) (GtkCellArea *area,
201 GtkCellAreaContext *context,
205 gint *natural_width);
207 /* Cell Properties */
208 void (* set_cell_property) (GtkCellArea *area,
209 GtkCellRenderer *renderer,
213 void (* get_cell_property) (GtkCellArea *area,
214 GtkCellRenderer *renderer,
220 gboolean (* focus) (GtkCellArea *area,
221 GtkDirectionType direction);
222 gboolean (* is_activatable) (GtkCellArea *area);
223 gboolean (* activate) (GtkCellArea *area,
224 GtkCellAreaContext *context,
226 const GdkRectangle *cell_area,
227 GtkCellRendererState flags);
231 /* Padding for future expansion */
232 void (*_gtk_reserved1) (void);
233 void (*_gtk_reserved2) (void);
234 void (*_gtk_reserved3) (void);
235 void (*_gtk_reserved4) (void);
236 void (*_gtk_reserved5) (void);
237 void (*_gtk_reserved6) (void);
238 void (*_gtk_reserved7) (void);
239 void (*_gtk_reserved8) (void);
242 GType gtk_cell_area_get_type (void) G_GNUC_CONST;
245 void gtk_cell_area_add (GtkCellArea *area,
246 GtkCellRenderer *renderer);
247 void gtk_cell_area_remove (GtkCellArea *area,
248 GtkCellRenderer *renderer);
249 gboolean gtk_cell_area_has_renderer (GtkCellArea *area,
250 GtkCellRenderer *renderer);
251 void gtk_cell_area_forall (GtkCellArea *area,
252 GtkCellCallback callback,
253 gpointer callback_data);
254 void gtk_cell_area_get_cell_allocation (GtkCellArea *area,
255 GtkCellAreaContext *context,
257 GtkCellRenderer *renderer,
258 const GdkRectangle *cell_area,
259 GdkRectangle *allocation);
260 gint gtk_cell_area_event (GtkCellArea *area,
261 GtkCellAreaContext *context,
264 const GdkRectangle *cell_area,
265 GtkCellRendererState flags);
266 void gtk_cell_area_render (GtkCellArea *area,
267 GtkCellAreaContext *context,
270 const GdkRectangle *background_area,
271 const GdkRectangle *cell_area,
272 GtkCellRendererState flags,
273 gboolean paint_focus);
274 void gtk_cell_area_set_style_detail (GtkCellArea *area,
275 const gchar *detail);
276 G_CONST_RETURN gchar *gtk_cell_area_get_style_detail (GtkCellArea *area);
279 GtkCellAreaContext *gtk_cell_area_create_context (GtkCellArea *area);
280 GtkSizeRequestMode gtk_cell_area_get_request_mode (GtkCellArea *area);
281 void gtk_cell_area_get_preferred_width (GtkCellArea *area,
282 GtkCellAreaContext *context,
286 void gtk_cell_area_get_preferred_height_for_width (GtkCellArea *area,
287 GtkCellAreaContext *context,
290 gint *minimum_height,
291 gint *natural_height);
292 void gtk_cell_area_get_preferred_height (GtkCellArea *area,
293 GtkCellAreaContext *context,
297 void gtk_cell_area_get_preferred_width_for_height (GtkCellArea *area,
298 GtkCellAreaContext *context,
302 gint *natural_width);
303 G_CONST_RETURN gchar *gtk_cell_area_get_current_path_string (GtkCellArea *area);
307 void gtk_cell_area_apply_attributes (GtkCellArea *area,
308 GtkTreeModel *tree_model,
310 gboolean is_expander,
311 gboolean is_expanded);
312 void gtk_cell_area_attribute_connect (GtkCellArea *area,
313 GtkCellRenderer *renderer,
314 const gchar *attribute,
316 void gtk_cell_area_attribute_disconnect (GtkCellArea *area,
317 GtkCellRenderer *renderer,
318 const gchar *attribute);
320 /* Cell Properties */
321 void gtk_cell_area_class_install_cell_property (GtkCellAreaClass *aclass,
324 GParamSpec* gtk_cell_area_class_find_cell_property (GtkCellAreaClass *aclass,
325 const gchar *property_name);
326 GParamSpec** gtk_cell_area_class_list_cell_properties (GtkCellAreaClass *aclass,
327 guint *n_properties);
328 void gtk_cell_area_add_with_properties (GtkCellArea *area,
329 GtkCellRenderer *renderer,
330 const gchar *first_prop_name,
331 ...) G_GNUC_NULL_TERMINATED;
332 void gtk_cell_area_cell_set (GtkCellArea *area,
333 GtkCellRenderer *renderer,
334 const gchar *first_prop_name,
335 ...) G_GNUC_NULL_TERMINATED;
336 void gtk_cell_area_cell_get (GtkCellArea *area,
337 GtkCellRenderer *renderer,
338 const gchar *first_prop_name,
339 ...) G_GNUC_NULL_TERMINATED;
340 void gtk_cell_area_cell_set_valist (GtkCellArea *area,
341 GtkCellRenderer *renderer,
342 const gchar *first_property_name,
344 void gtk_cell_area_cell_get_valist (GtkCellArea *area,
345 GtkCellRenderer *renderer,
346 const gchar *first_property_name,
348 void gtk_cell_area_cell_set_property (GtkCellArea *area,
349 GtkCellRenderer *renderer,
350 const gchar *property_name,
351 const GValue *value);
352 void gtk_cell_area_cell_get_property (GtkCellArea *area,
353 GtkCellRenderer *renderer,
354 const gchar *property_name,
358 gboolean gtk_cell_area_is_activatable (GtkCellArea *area);
359 gboolean gtk_cell_area_activate (GtkCellArea *area,
360 GtkCellAreaContext *context,
362 const GdkRectangle *cell_area,
363 GtkCellRendererState flags);
364 gboolean gtk_cell_area_focus (GtkCellArea *area,
365 GtkDirectionType direction);
366 void gtk_cell_area_set_focus_cell (GtkCellArea *area,
367 GtkCellRenderer *renderer);
368 GtkCellRenderer *gtk_cell_area_get_focus_cell (GtkCellArea *area);
372 void gtk_cell_area_add_focus_sibling (GtkCellArea *area,
373 GtkCellRenderer *renderer,
374 GtkCellRenderer *sibling);
375 void gtk_cell_area_remove_focus_sibling (GtkCellArea *area,
376 GtkCellRenderer *renderer,
377 GtkCellRenderer *sibling);
378 gboolean gtk_cell_area_is_focus_sibling (GtkCellArea *area,
379 GtkCellRenderer *renderer,
380 GtkCellRenderer *sibling);
381 G_CONST_RETURN GList *gtk_cell_area_get_focus_siblings (GtkCellArea *area,
382 GtkCellRenderer *renderer);
383 GtkCellRenderer *gtk_cell_area_get_focus_from_sibling (GtkCellArea *area,
384 GtkCellRenderer *renderer);
386 /* Cell Activation/Editing */
387 GtkCellRenderer *gtk_cell_area_get_edited_cell (GtkCellArea *area);
388 GtkCellEditable *gtk_cell_area_get_edit_widget (GtkCellArea *area);
389 gboolean gtk_cell_area_activate_cell (GtkCellArea *area,
391 GtkCellRenderer *renderer,
393 const GdkRectangle *cell_area,
394 GtkCellRendererState flags);
395 void gtk_cell_area_stop_editing (GtkCellArea *area,
398 /* Functions for area implementations */
400 /* Distinguish the inner cell area from the whole requested area including margins */
401 void gtk_cell_area_inner_cell_area (GtkCellArea *area,
403 const GdkRectangle *cell_area,
404 GdkRectangle *inner_area);
406 /* Request the size of a cell while respecting the cell margins (requests are margin inclusive) */
407 void gtk_cell_area_request_renderer (GtkCellArea *area,
408 GtkCellRenderer *renderer,
409 GtkOrientation orientation,
417 #endif /* __GTK_CELL_AREA_H__ */