]> Pileus Git - ~andy/gtk/blob - gtk/gtkcellarea.h
Merge branch 'master' into treeview-refactor
[~andy/gtk] / gtk / gtkcellarea.h
1 /* gtkcellarea.h
2  *
3  * Copyright (C) 2010 Openismus GmbH
4  *
5  * Authors:
6  *      Tristan Van Berkom <tristanvb@openismus.com>
7  *
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.
12  *
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.
17  *
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.
22  */
23
24 #if !defined (__GTK_H_INSIDE__) && !defined (GTK_COMPILATION)
25 #error "Only <gtk/gtk.h> can be included directly."
26 #endif
27
28 #ifndef __GTK_CELL_AREA_H__
29 #define __GTK_CELL_AREA_H__
30
31 #include <gtk/gtkcellrenderer.h>
32 #include <gtk/gtkwidget.h>
33 #include <gtk/gtktreemodel.h>
34
35 G_BEGIN_DECLS
36
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))
43
44 typedef struct _GtkCellArea              GtkCellArea;
45 typedef struct _GtkCellAreaClass         GtkCellAreaClass;
46 typedef struct _GtkCellAreaPrivate       GtkCellAreaPrivate;
47 typedef struct _GtkCellAreaContext       GtkCellAreaContext;
48
49 /**
50  * GtkCellCallback:
51  * @renderer: the cell renderer to operate on
52  * @data: user-supplied data
53  *
54  * The type of the callback functions used for iterating over
55  * the cell renderers of a #GtkCellArea, see gtk_cell_area_forall().
56  */
57 typedef void    (*GtkCellCallback)     (GtkCellRenderer  *renderer,
58                                         gpointer          data);
59
60
61 struct _GtkCellArea
62 {
63   GInitiallyUnowned parent_instance;
64
65   GtkCellAreaPrivate *priv;
66 };
67
68 struct _GtkCellAreaClass
69 {
70   GInitiallyUnownedClass parent_class;
71
72   /* vtable - not signals */
73
74   /* Basic methods */
75   void               (* add)                             (GtkCellArea             *area,
76                                                           GtkCellRenderer         *renderer);
77   void               (* remove)                          (GtkCellArea             *area,
78                                                           GtkCellRenderer         *renderer);
79   void               (* forall)                          (GtkCellArea             *area,
80                                                           GtkCellCallback          callback,
81                                                           gpointer                 callback_data);
82   void               (* get_cell_allocation)             (GtkCellArea             *area,
83                                                           GtkCellAreaContext      *context,
84                                                           GtkWidget               *widget,
85                                                           GtkCellRenderer         *renderer,
86                                                           const GdkRectangle      *cell_area,
87                                                           GdkRectangle            *allocation);
88   gint               (* event)                           (GtkCellArea             *area,
89                                                           GtkCellAreaContext      *context,
90                                                           GtkWidget               *widget,
91                                                           GdkEvent                *event,
92                                                           const GdkRectangle      *cell_area,
93                                                           GtkCellRendererState     flags);
94   void               (* render)                          (GtkCellArea             *area,
95                                                           GtkCellAreaContext      *context,
96                                                           GtkWidget               *widget,
97                                                           cairo_t                 *cr,
98                                                           const GdkRectangle      *background_area,
99                                                           const GdkRectangle      *cell_area,
100                                                           GtkCellRendererState     flags,
101                                                           gboolean                 paint_focus);
102   void               (* apply_attributes)                (GtkCellArea             *area,
103                                                           GtkTreeModel            *tree_model,
104                                                           GtkTreeIter             *iter,
105                                                           gboolean                 is_expander,
106                                                           gboolean                 is_expanded);
107
108   /* Geometry */
109   GtkCellAreaContext *(* create_context)                 (GtkCellArea             *area);
110   GtkSizeRequestMode (* get_request_mode)                (GtkCellArea             *area);
111   void               (* get_preferred_width)             (GtkCellArea             *area,
112                                                           GtkCellAreaContext      *context,
113                                                           GtkWidget               *widget,
114                                                           gint                    *minimum_width,
115                                                           gint                    *natural_width);
116   void               (* get_preferred_height_for_width)  (GtkCellArea             *area,
117                                                           GtkCellAreaContext      *context,
118                                                           GtkWidget               *widget,
119                                                           gint                     width,
120                                                           gint                    *minimum_height,
121                                                           gint                    *natural_height);
122   void               (* get_preferred_height)            (GtkCellArea             *area,
123                                                           GtkCellAreaContext      *context,
124                                                           GtkWidget               *widget,
125                                                           gint                    *minimum_height,
126                                                           gint                    *natural_height);
127   void               (* get_preferred_width_for_height)  (GtkCellArea             *area,
128                                                           GtkCellAreaContext      *context,
129                                                           GtkWidget               *widget,
130                                                           gint                     height,
131                                                           gint                    *minimum_width,
132                                                           gint                    *natural_width);
133
134   /* Cell Properties */
135   void               (* set_cell_property)               (GtkCellArea             *area,
136                                                           GtkCellRenderer         *renderer,
137                                                           guint                    property_id,
138                                                           const GValue            *value,
139                                                           GParamSpec              *pspec);
140   void               (* get_cell_property)               (GtkCellArea             *area,
141                                                           GtkCellRenderer         *renderer,
142                                                           guint                    property_id,
143                                                           GValue                  *value,
144                                                           GParamSpec              *pspec);
145
146   /* Focus */
147   gboolean           (* can_focus)                       (GtkCellArea             *area);
148   gboolean           (* focus)                           (GtkCellArea             *area,
149                                                           GtkDirectionType         direction);
150   gboolean           (* activate)                        (GtkCellArea             *area,
151                                                           GtkCellAreaContext      *context,
152                                                           GtkWidget               *widget,
153                                                           const GdkRectangle      *cell_area,
154                                                           GtkCellRendererState     flags);
155
156
157   /* Padding for future expansion */
158   void (*_gtk_reserved1) (void);
159   void (*_gtk_reserved2) (void);
160   void (*_gtk_reserved3) (void);
161   void (*_gtk_reserved4) (void);
162   void (*_gtk_reserved5) (void);
163   void (*_gtk_reserved6) (void);
164   void (*_gtk_reserved7) (void);
165   void (*_gtk_reserved8) (void);
166 };
167
168 GType                 gtk_cell_area_get_type                       (void) G_GNUC_CONST;
169
170 /* Basic methods */
171 void                  gtk_cell_area_add                            (GtkCellArea          *area,
172                                                                     GtkCellRenderer      *renderer);
173 void                  gtk_cell_area_remove                         (GtkCellArea          *area,
174                                                                     GtkCellRenderer      *renderer);
175 gboolean              gtk_cell_area_has_renderer                   (GtkCellArea          *area,
176                                                                     GtkCellRenderer      *renderer);
177 void                  gtk_cell_area_forall                         (GtkCellArea          *area,
178                                                                     GtkCellCallback       callback,
179                                                                     gpointer              callback_data);
180 void                  gtk_cell_area_get_cell_allocation            (GtkCellArea          *area,
181                                                                     GtkCellAreaContext   *context,
182                                                                     GtkWidget            *widget,
183                                                                     GtkCellRenderer      *renderer,
184                                                                     const GdkRectangle   *cell_area,
185                                                                     GdkRectangle         *allocation);
186 gint                  gtk_cell_area_event                          (GtkCellArea          *area,
187                                                                     GtkCellAreaContext   *context,
188                                                                     GtkWidget            *widget,
189                                                                     GdkEvent             *event,
190                                                                     const GdkRectangle   *cell_area,
191                                                                     GtkCellRendererState  flags);
192 void                  gtk_cell_area_render                         (GtkCellArea          *area,
193                                                                     GtkCellAreaContext   *context,
194                                                                     GtkWidget            *widget,
195                                                                     cairo_t              *cr,
196                                                                     const GdkRectangle   *background_area,
197                                                                     const GdkRectangle   *cell_area,
198                                                                     GtkCellRendererState  flags,
199                                                                     gboolean              paint_focus);
200 void                  gtk_cell_area_set_style_detail               (GtkCellArea          *area,
201                                                                     const gchar          *detail);
202 G_CONST_RETURN gchar *gtk_cell_area_get_style_detail               (GtkCellArea          *area);
203
204 /* Geometry */
205 GtkCellAreaContext   *gtk_cell_area_create_context                 (GtkCellArea        *area);
206 GtkSizeRequestMode    gtk_cell_area_get_request_mode               (GtkCellArea        *area);
207 void                  gtk_cell_area_get_preferred_width            (GtkCellArea        *area,
208                                                                     GtkCellAreaContext *context,
209                                                                     GtkWidget          *widget,
210                                                                     gint               *minimum_size,
211                                                                     gint               *natural_size);
212 void                  gtk_cell_area_get_preferred_height_for_width (GtkCellArea        *area,
213                                                                     GtkCellAreaContext *context,
214                                                                     GtkWidget          *widget,
215                                                                     gint                width,
216                                                                     gint               *minimum_height,
217                                                                     gint               *natural_height);
218 void                  gtk_cell_area_get_preferred_height           (GtkCellArea        *area,
219                                                                     GtkCellAreaContext *context,
220                                                                     GtkWidget          *widget,
221                                                                     gint               *minimum_size,
222                                                                     gint               *natural_size);
223 void                  gtk_cell_area_get_preferred_width_for_height (GtkCellArea        *area,
224                                                                     GtkCellAreaContext *context,
225                                                                     GtkWidget          *widget,
226                                                                     gint                height,
227                                                                     gint               *minimum_width,
228                                                                     gint               *natural_width);
229 G_CONST_RETURN gchar *gtk_cell_area_get_current_path_string        (GtkCellArea        *area);
230
231
232 /* Attributes */
233 void                  gtk_cell_area_apply_attributes               (GtkCellArea        *area,
234                                                                     GtkTreeModel       *tree_model,
235                                                                     GtkTreeIter        *iter,
236                                                                     gboolean            is_expander,
237                                                                     gboolean            is_expanded);
238 void                  gtk_cell_area_attribute_connect              (GtkCellArea        *area,
239                                                                     GtkCellRenderer    *renderer,
240                                                                     const gchar        *attribute,
241                                                                     gint                column); 
242 void                  gtk_cell_area_attribute_disconnect           (GtkCellArea        *area,
243                                                                     GtkCellRenderer    *renderer,
244                                                                     const gchar        *attribute);
245
246 /* Cell Properties */
247 void                  gtk_cell_area_class_install_cell_property    (GtkCellAreaClass   *aclass,
248                                                                     guint               property_id,
249                                                                     GParamSpec         *pspec);
250 GParamSpec*           gtk_cell_area_class_find_cell_property       (GtkCellAreaClass   *aclass,
251                                                                     const gchar        *property_name);
252 GParamSpec**          gtk_cell_area_class_list_cell_properties     (GtkCellAreaClass   *aclass,
253                                                                     guint                   *n_properties);
254 void                  gtk_cell_area_add_with_properties            (GtkCellArea        *area,
255                                                                     GtkCellRenderer    *renderer,
256                                                                     const gchar     *first_prop_name,
257                                                                     ...) G_GNUC_NULL_TERMINATED;
258 void                  gtk_cell_area_cell_set                       (GtkCellArea        *area,
259                                                                     GtkCellRenderer    *renderer,
260                                                                     const gchar        *first_prop_name,
261                                                                     ...) G_GNUC_NULL_TERMINATED;
262 void                  gtk_cell_area_cell_get                       (GtkCellArea        *area,
263                                                                     GtkCellRenderer    *renderer,
264                                                                     const gchar        *first_prop_name,
265                                                                     ...) G_GNUC_NULL_TERMINATED;
266 void                  gtk_cell_area_cell_set_valist                (GtkCellArea        *area,
267                                                                     GtkCellRenderer    *renderer,
268                                                                     const gchar        *first_property_name,
269                                                                     va_list             var_args);
270 void                  gtk_cell_area_cell_get_valist                (GtkCellArea        *area,
271                                                                     GtkCellRenderer    *renderer,
272                                                                     const gchar        *first_property_name,
273                                                                     va_list             var_args);
274 void                  gtk_cell_area_cell_set_property              (GtkCellArea        *area,
275                                                                     GtkCellRenderer    *renderer,
276                                                                     const gchar        *property_name,
277                                                                     const GValue       *value);
278 void                  gtk_cell_area_cell_get_property              (GtkCellArea        *area,
279                                                                     GtkCellRenderer    *renderer,
280                                                                     const gchar        *property_name,
281                                                                     GValue             *value);
282
283 #define GTK_CELL_AREA_WARN_INVALID_CHILD_PROPERTY_ID(object, property_id, pspec) \
284   G_OBJECT_WARN_INVALID_PSPEC ((object), "cell property id", (property_id), (pspec))
285
286
287 /* Focus */
288 gboolean              gtk_cell_area_can_focus                      (GtkCellArea         *area);
289 gboolean              gtk_cell_area_focus                          (GtkCellArea         *area,
290                                                                     GtkDirectionType     direction);
291 gboolean              gtk_cell_area_activate                       (GtkCellArea         *area,
292                                                                     GtkCellAreaContext  *context,
293                                                                     GtkWidget           *widget,
294                                                                     const GdkRectangle  *cell_area,
295                                                                     GtkCellRendererState flags);
296 void                  gtk_cell_area_set_focus_cell                 (GtkCellArea          *area,
297                                                                     GtkCellRenderer      *renderer);
298 GtkCellRenderer      *gtk_cell_area_get_focus_cell                 (GtkCellArea          *area);
299
300
301 /* Focus siblings */
302 void                  gtk_cell_area_add_focus_sibling              (GtkCellArea          *area,
303                                                                     GtkCellRenderer      *renderer,
304                                                                     GtkCellRenderer      *sibling);
305 void                  gtk_cell_area_remove_focus_sibling           (GtkCellArea          *area,
306                                                                     GtkCellRenderer      *renderer,
307                                                                     GtkCellRenderer      *sibling);
308 gboolean              gtk_cell_area_is_focus_sibling               (GtkCellArea          *area,
309                                                                     GtkCellRenderer      *renderer,
310                                                                     GtkCellRenderer      *sibling);
311 G_CONST_RETURN GList *gtk_cell_area_get_focus_siblings             (GtkCellArea          *area,
312                                                                     GtkCellRenderer      *renderer);
313 GtkCellRenderer      *gtk_cell_area_get_focus_from_sibling         (GtkCellArea          *area,
314                                                                     GtkCellRenderer      *renderer);
315
316 /* Cell Activation/Editing */
317 GtkCellRenderer      *gtk_cell_area_get_edited_cell                (GtkCellArea          *area);
318 GtkCellEditable      *gtk_cell_area_get_edit_widget                (GtkCellArea          *area);
319 gboolean              gtk_cell_area_activate_cell                  (GtkCellArea          *area,
320                                                                     GtkWidget            *widget,
321                                                                     GtkCellRenderer      *renderer,
322                                                                     GdkEvent             *event,
323                                                                     const GdkRectangle   *cell_area,
324                                                                     GtkCellRendererState  flags);
325 void                  gtk_cell_area_stop_editing                   (GtkCellArea          *area,
326                                                                     gboolean              canceled);
327
328 /* Functions for area implementations */
329
330 /* Distinguish the inner cell area from the whole requested area including margins */
331 void                  gtk_cell_area_inner_cell_area                (GtkCellArea        *area,
332                                                                     GtkWidget          *widget,
333                                                                     const GdkRectangle *cell_area,
334                                                                     GdkRectangle       *inner_area);
335
336 /* Aligns a cell renderer into cell_area by requesting it's size ... used for focus and cell edit areas */
337 void                  gtk_cell_area_aligned_cell_area              (GtkCellArea        *area,
338                                                                     GtkWidget          *widget,
339                                                                     GtkCellRenderer    *renderer,
340                                                                     const GdkRectangle *cell_area,
341                                                                     GdkRectangle       *aligned_area);
342
343
344 /* Request the size of a cell while respecting the cell margins (requests are margin inclusive) */
345 void                  gtk_cell_area_request_renderer               (GtkCellArea        *area,
346                                                                     GtkCellRenderer    *renderer,
347                                                                     GtkOrientation      orientation,
348                                                                     GtkWidget          *widget,
349                                                                     gint                for_size,
350                                                                     gint               *minimum_size,
351                                                                     gint               *natural_size);
352
353 G_END_DECLS
354
355 #endif /* __GTK_CELL_AREA_H__ */