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