]> Pileus Git - ~andy/gtk/blob - gtk/gtkcellarea.h
Made progress on focus handling.
[~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 _GtkCellAreaIter          GtkCellAreaIter;
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                                                           GtkCellAreaIter         *iter,
84                                                           GtkWidget               *widget,
85                                                           GtkCellRenderer         *renderer,
86                                                           const GdkRectangle      *cell_area,
87                                                           GdkRectangle            *allocation);
88   gint               (* event)                           (GtkCellArea             *area,
89                                                           GtkCellAreaIter         *iter,
90                                                           GtkWidget               *widget,
91                                                           GdkEvent                *event,
92                                                           const GdkRectangle      *cell_area,
93                                                           GtkCellRendererState     flags);
94   void               (* render)                          (GtkCellArea             *area,
95                                                           GtkCellAreaIter         *iter,
96                                                           GtkWidget               *widget,
97                                                           cairo_t                 *cr,
98                                                           const GdkRectangle      *cell_area,
99                                                           GtkCellRendererState     flags);
100
101   /* Geometry */
102   GtkCellAreaIter   *(* create_iter)                     (GtkCellArea             *area);
103   GtkSizeRequestMode (* get_request_mode)                (GtkCellArea             *area);
104   void               (* get_preferred_width)             (GtkCellArea             *area,
105                                                           GtkCellAreaIter         *iter,
106                                                           GtkWidget               *widget,
107                                                           gint                    *minimum_size,
108                                                           gint                    *natural_size);
109   void               (* get_preferred_height_for_width)  (GtkCellArea             *area,
110                                                           GtkCellAreaIter         *iter,
111                                                           GtkWidget               *widget,
112                                                           gint                     width,
113                                                           gint                    *minimum_height,
114                                                           gint                    *natural_height);
115   void               (* get_preferred_height)            (GtkCellArea             *area,
116                                                           GtkCellAreaIter         *iter,
117                                                           GtkWidget               *widget,
118                                                           gint                    *minimum_size,
119                                                           gint                    *natural_size);
120   void               (* get_preferred_width_for_height)  (GtkCellArea             *area,
121                                                           GtkCellAreaIter         *iter,
122                                                           GtkWidget               *widget,
123                                                           gint                     height,
124                                                           gint                    *minimum_width,
125                                                           gint                    *natural_width);
126
127   /* Cell Properties */
128   void               (* set_cell_property)               (GtkCellArea             *area,
129                                                           GtkCellRenderer         *renderer,
130                                                           guint                    property_id,
131                                                           const GValue            *value,
132                                                           GParamSpec              *pspec);
133   void               (* get_cell_property)               (GtkCellArea             *area,
134                                                           GtkCellRenderer         *renderer,
135                                                           guint                    property_id,
136                                                           GValue                  *value,
137                                                           GParamSpec              *pspec);
138
139   /* Focus */
140   void               (* grab_focus)                      (GtkCellArea             *area,
141                                                           GtkDirectionType         direction);
142   void               (* update_focus)                    (GtkCellArea             *area);
143
144   /* Padding for future expansion */
145   void (*_gtk_reserved1) (void);
146   void (*_gtk_reserved2) (void);
147   void (*_gtk_reserved3) (void);
148   void (*_gtk_reserved4) (void);
149   void (*_gtk_reserved5) (void);
150   void (*_gtk_reserved6) (void);
151   void (*_gtk_reserved7) (void);
152   void (*_gtk_reserved8) (void);
153 };
154
155 GType              gtk_cell_area_get_type                       (void) G_GNUC_CONST;
156
157 /* Basic methods */
158 void               gtk_cell_area_add                            (GtkCellArea          *area,
159                                                                  GtkCellRenderer      *renderer);
160 void               gtk_cell_area_remove                         (GtkCellArea          *area,
161                                                                  GtkCellRenderer      *renderer);
162 void               gtk_cell_area_forall                         (GtkCellArea          *area,
163                                                                  GtkCellCallback       callback,
164                                                                  gpointer              callback_data);
165 void               gtk_cell_area_get_cell_allocation            (GtkCellArea          *area,
166                                                                  GtkCellAreaIter      *iter,
167                                                                  GtkWidget            *widget,
168                                                                  GtkCellRenderer      *renderer,
169                                                                  const GdkRectangle   *cell_area,
170                                                                  GdkRectangle         *allocation);
171 gint               gtk_cell_area_event                          (GtkCellArea          *area,
172                                                                  GtkCellAreaIter      *iter,
173                                                                  GtkWidget            *widget,
174                                                                  GdkEvent             *event,
175                                                                  const GdkRectangle   *cell_area,
176                                                                  GtkCellRendererState  flags);
177 void               gtk_cell_area_render                         (GtkCellArea          *area,
178                                                                  GtkCellAreaIter      *iter,
179                                                                  GtkWidget            *widget,
180                                                                  cairo_t              *cr,
181                                                                  const GdkRectangle   *cell_area,
182                                                                  GtkCellRendererState  flags);
183
184 /* Geometry */
185 GtkCellAreaIter   *gtk_cell_area_create_iter                    (GtkCellArea        *area);
186 GtkSizeRequestMode gtk_cell_area_get_request_mode               (GtkCellArea        *area);
187 void               gtk_cell_area_get_preferred_width            (GtkCellArea        *area,
188                                                                  GtkCellAreaIter    *iter,
189                                                                  GtkWidget          *widget,
190                                                                  gint               *minimum_size,
191                                                                  gint               *natural_size);
192 void               gtk_cell_area_get_preferred_height_for_width (GtkCellArea        *area,
193                                                                  GtkCellAreaIter    *iter,
194                                                                  GtkWidget          *widget,
195                                                                  gint                width,
196                                                                  gint               *minimum_height,
197                                                                  gint               *natural_height);
198 void               gtk_cell_area_get_preferred_height           (GtkCellArea        *area,
199                                                                  GtkCellAreaIter    *iter,
200                                                                  GtkWidget          *widget,
201                                                                  gint               *minimum_size,
202                                                                  gint               *natural_size);
203 void               gtk_cell_area_get_preferred_width_for_height (GtkCellArea        *area,
204                                                                  GtkCellAreaIter    *iter,
205                                                                  GtkWidget          *widget,
206                                                                  gint                height,
207                                                                  gint               *minimum_width,
208                                                                  gint               *natural_width);
209 G_CONST_RETURN gchar *gtk_cell_area_get_current_path_string     (GtkCellArea        *area);
210
211
212 /* Attributes */
213 void               gtk_cell_area_apply_attributes               (GtkCellArea        *area,
214                                                                  GtkTreeModel       *tree_model,
215                                                                  GtkTreeIter        *iter,
216                                                                  gboolean            is_expander,
217                                                                  gboolean            is_expanded);
218 void               gtk_cell_area_attribute_connect              (GtkCellArea        *area,
219                                                                  GtkCellRenderer    *renderer,
220                                                                  const gchar        *attribute,
221                                                                  gint                column); 
222 void               gtk_cell_area_attribute_disconnect           (GtkCellArea        *area,
223                                                                  GtkCellRenderer    *renderer,
224                                                                  const gchar        *attribute);
225
226 /* Cell Properties */
227 void               gtk_cell_area_class_install_cell_property    (GtkCellAreaClass   *aclass,
228                                                                  guint               property_id,
229                                                                  GParamSpec         *pspec);
230 GParamSpec*        gtk_cell_area_class_find_cell_property       (GtkCellAreaClass   *aclass,
231                                                                  const gchar        *property_name);
232 GParamSpec**       gtk_cell_area_class_list_cell_properties     (GtkCellAreaClass   *aclass,
233                                                                  guint              *n_properties);
234 void               gtk_cell_area_add_with_properties            (GtkCellArea        *area,
235                                                                  GtkCellRenderer    *renderer,
236                                                                  const gchar        *first_prop_name,
237                                                                  ...) G_GNUC_NULL_TERMINATED;
238 void               gtk_cell_area_cell_set                       (GtkCellArea        *area,
239                                                                  GtkCellRenderer    *renderer,
240                                                                  const gchar        *first_prop_name,
241                                                                  ...) G_GNUC_NULL_TERMINATED;
242 void               gtk_cell_area_cell_get                       (GtkCellArea        *area,
243                                                                  GtkCellRenderer    *renderer,
244                                                                  const gchar        *first_prop_name,
245                                                                  ...) G_GNUC_NULL_TERMINATED;
246 void               gtk_cell_area_cell_set_valist                (GtkCellArea        *area,
247                                                                  GtkCellRenderer    *renderer,
248                                                                  const gchar        *first_property_name,
249                                                                  va_list             var_args);
250 void               gtk_cell_area_cell_get_valist                (GtkCellArea        *area,
251                                                                  GtkCellRenderer    *renderer,
252                                                                  const gchar        *first_property_name,
253                                                                  va_list             var_args);
254 void               gtk_cell_area_cell_set_property              (GtkCellArea        *area,
255                                                                  GtkCellRenderer    *renderer,
256                                                                  const gchar        *property_name,
257                                                                  const GValue       *value);
258 void               gtk_cell_area_cell_get_property              (GtkCellArea        *area,
259                                                                  GtkCellRenderer    *renderer,
260                                                                  const gchar        *property_name,
261                                                                  GValue             *value);
262
263 #define GTK_CELL_AREA_WARN_INVALID_CHILD_PROPERTY_ID(object, property_id, pspec) \
264   G_OBJECT_WARN_INVALID_PSPEC ((object), "cell property id", (property_id), (pspec))
265
266
267 /* Focus */
268 void               gtk_cell_area_grab_focus                     (GtkCellArea        *area,
269                                                                  GtkDirectionType    direction);
270 void               gtk_cell_area_focus_leave                    (GtkCellArea        *area,
271                                                                  GtkDirectionType    direction,
272                                                                  const gchar        *path);
273 void               gtk_cell_area_update_focus                   (GtkCellArea        *area);
274 void               gtk_cell_area_set_can_focus                  (GtkCellArea        *area,
275                                                                  gboolean            can_focus);
276 gboolean           gtk_cell_area_get_can_focus                  (GtkCellArea        *area);
277 void               gtk_cell_area_set_focus_cell                 (GtkCellArea        *area,
278                                                                  GtkCellRenderer    *renderer);
279 GtkCellRenderer   *gtk_cell_area_get_focus_cell                 (GtkCellArea        *area);
280 void               gtk_cell_area_set_edited_cell                (GtkCellArea        *area,
281                                                                  GtkCellRenderer    *renderer);
282 GtkCellRenderer   *gtk_cell_area_get_edited_cell                (GtkCellArea        *area);
283
284
285
286 /* Margins */
287 gint               gtk_cell_area_get_cell_margin_left           (GtkCellArea        *area);
288 void               gtk_cell_area_set_cell_margin_left           (GtkCellArea        *area,
289                                                                  gint                margin);
290 gint               gtk_cell_area_get_cell_margin_right          (GtkCellArea        *area);
291 void               gtk_cell_area_set_cell_margin_right          (GtkCellArea        *area,
292                                                                  gint                margin);
293 gint               gtk_cell_area_get_cell_margin_top            (GtkCellArea        *area);
294 void               gtk_cell_area_set_cell_margin_top            (GtkCellArea        *area,
295                                                                  gint                margin);
296 gint               gtk_cell_area_get_cell_margin_bottom         (GtkCellArea        *area);
297 void               gtk_cell_area_set_cell_margin_bottom         (GtkCellArea        *area,
298                                                                  gint                margin);
299
300 /* Functions for area implementations */
301
302 /* Signal that editing started on the area (fires the "editing-started" signal) */
303 void               gtk_cell_area_editing_started                (GtkCellArea        *area,
304                                                                  GtkCellRenderer    *renderer,
305                                                                  GtkCellEditable    *editable);
306
307 /* Distinguish the inner cell area from the whole requested area including margins */
308 void               gtk_cell_area_inner_cell_area                (GtkCellArea        *area,
309                                                                  GdkRectangle       *cell_area,
310                                                                  GdkRectangle       *inner_cell_area);
311
312 /* Request the size of a cell while respecting the cell margins (requests are margin inclusive) */
313 void               gtk_cell_area_request_renderer               (GtkCellArea        *area,
314                                                                  GtkCellRenderer    *renderer,
315                                                                  GtkOrientation      orientation,
316                                                                  GtkWidget          *widget,
317                                                                  gint                for_size,
318                                                                  gint               *minimum_size,
319                                                                  gint               *natural_size);
320
321 G_END_DECLS
322
323 #endif /* __GTK_CELL_AREA_H__ */