Protect against NULL pointer dereference
[platform/upstream/atk.git] / atk / atkcomponent.h
1 /* ATK -  Accessibility Toolkit
2  * Copyright 2001 Sun Microsystems Inc.
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Library General Public
6  * License as published by the Free Software Foundation; either
7  * version 2 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * Library General Public License for more details.
13  *
14  * You should have received a copy of the GNU Library General Public
15  * License along with this library; if not, write to the
16  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17  * Boston, MA 02111-1307, USA.
18  */
19
20 #ifndef __ATK_COMPONENT_H__
21 #define __ATK_COMPONENT_H__
22
23 #if defined(ATK_DISABLE_SINGLE_INCLUDES) && !defined (__ATK_H_INSIDE__) && !defined (ATK_COMPILATION)
24 #error "Only <atk/atk.h> can be included directly."
25 #endif
26
27 #include <atk/atkobject.h>
28 #include <atk/atkutil.h>
29
30 G_BEGIN_DECLS
31
32 /**
33  * AtkScrollType:
34  * @ATK_SCROLL_TOP_LEFT: Scroll the object vertically and horizontally to bring
35  *   its top left corner to the top left corner of the window.
36  * @ATK_SCROLL_BOTTOM_RIGHT: Scroll the object vertically and horizontally to
37  *   bring its bottom right corner to the bottom right corner of the window.
38  * @ATK_SCROLL_TOP_EDGE: Scroll the object vertically to bring its top edge to
39  *   the top edge of the window.
40  * @ATK_SCROLL_BOTTOM_EDGE: Scroll the object vertically to bring its bottom
41  *   edge to the bottom edge of the window.
42  * @ATK_SCROLL_LEFT_EDGE: Scroll the object vertically and horizontally to bring
43  *   its left edge to the left edge of the window.
44  * @ATK_SCROLL_RIGHT_EDGE: Scroll the object vertically and horizontally to
45  *   bring its right edge to the right edge of the window.
46  * @ATK_SCROLL_ANYWHERE: Scroll the object vertically and horizontally so that
47  *   as much as possible of the object becomes visible. The exact placement is
48  *   determined by the application.
49  *
50  * Specifies where an object should be placed on the screen when using scroll_to.
51  *
52  * Since: 2.30
53  */
54 typedef enum {
55   ATK_SCROLL_TOP_LEFT,
56   ATK_SCROLL_BOTTOM_RIGHT,
57   ATK_SCROLL_TOP_EDGE,
58   ATK_SCROLL_BOTTOM_EDGE,
59   ATK_SCROLL_LEFT_EDGE,
60   ATK_SCROLL_RIGHT_EDGE,
61   ATK_SCROLL_ANYWHERE
62 } AtkScrollType;
63
64 #define ATK_TYPE_COMPONENT                    (atk_component_get_type ())
65 #define ATK_IS_COMPONENT(obj)                 G_TYPE_CHECK_INSTANCE_TYPE ((obj), ATK_TYPE_COMPONENT)
66 #define ATK_COMPONENT(obj)                    G_TYPE_CHECK_INSTANCE_CAST ((obj), ATK_TYPE_COMPONENT, AtkComponent)
67 #define ATK_COMPONENT_GET_IFACE(obj)          (G_TYPE_INSTANCE_GET_INTERFACE ((obj), ATK_TYPE_COMPONENT, AtkComponentIface))
68
69 #ifndef _TYPEDEF_ATK_COMPONENT_
70 #define _TYPEDEF_ATK_COMPONENT_
71 typedef struct _AtkComponent AtkComponent;
72 #endif
73 typedef struct _AtkComponentIface  AtkComponentIface;
74
75 /**
76  * AtkFocusHandler:
77  * @object: the #AtkObject that receives/lose the focus
78  * @focus_in: TRUE if the object receives the focus
79  *
80  * The type of callback function used for
81  * atk_component_add_focus_handler() and
82  * atk_component_remove_focus_handler()
83  *
84  * Deprecated: 2.9.4: Deprecated with atk_component_add_focus_handler()
85  * and atk_component_remove_focus_handler(). See those
86  * methods for more information.
87  */
88 typedef void (*AtkFocusHandler) (AtkObject* object, gboolean focus_in);
89
90 typedef struct _AtkRectangle       AtkRectangle;
91
92 /**
93  * AtkRectangle:
94  * @x: X coordinate of the left side of the rectangle.
95  * @y: Y coordinate of the top side of the rectangle.
96  * @width: width of the rectangle.
97  * @height: height of the rectangle.
98  *
99  * A data structure for holding a rectangle. Those coordinates are
100  * relative to the component top-level parent.
101  */
102 struct _AtkRectangle
103 {
104   gint x;
105   gint y;
106   gint width;
107   gint height;
108 };
109
110 ATK_AVAILABLE_IN_ALL
111 GType atk_rectangle_get_type (void);
112
113 #define ATK_TYPE_RECTANGLE (atk_rectangle_get_type ())
114
115 /**
116  * AtkComponentIface:
117  * @add_focus_handler: This virtual function is deprecated since 2.9.4
118  *   and it should not be overriden. See atk_component_add_focus_handler()
119  *   for more information.
120  * @get_position: This virtual function is deprecated since 2.12 and
121  *   it should not be overriden. Use @AtkComponentIface.get_extents instead.
122  * @get_size: This virtual function is deprecated since 2.12 and it
123  *   should not be overriden. Use @AtkComponentIface.get_extents instead.
124  * @remove_focus_handler: This virtual function is deprecated since
125  *   2.9.4 and it should not be overriden. See atk_component_remove_focus_handler()
126  *   for more information.
127  * @contains:
128  * @ref_accessible_at_point:
129  * @get_extents:
130  * @grab_focus:
131  * @set_extents:
132  * @set_position:
133  * @set_size:
134  * @get_layer:
135  * @get_mdi_zorder:
136  * @bounds_changed:
137  * @get_alpha:
138  * @scroll_to:
139  * @scroll_to_point:
140  *
141  * The AtkComponent interface should be supported by any object that is
142  * rendered on the screen. The interface provides the standard mechanism
143  * for an assistive technology to determine and set the graphical
144  * representation of an object.
145  */
146 struct _AtkComponentIface
147 {
148   /*< private >*/
149   GTypeInterface parent;
150
151   /*< public >*/
152   guint          (* add_focus_handler)  (AtkComponent          *component,
153                                          AtkFocusHandler        handler);
154
155   gboolean       (* contains)           (AtkComponent          *component,
156                                          gint                   x,
157                                          gint                   y,
158                                          AtkCoordType           coord_type);
159
160   AtkObject*    (* ref_accessible_at_point)  (AtkComponent     *component,
161                                          gint                   x,
162                                          gint                   y,
163                                          AtkCoordType           coord_type);
164   void          (* get_extents)         (AtkComponent          *component,
165                                          gint                  *x,
166                                          gint                  *y,
167                                          gint                  *width,
168                                          gint                  *height,
169                                          AtkCoordType          coord_type);
170   void                     (* get_position)     (AtkComponent   *component,
171                                                  gint           *x,
172                                                  gint           *y,
173                                                  AtkCoordType   coord_type);
174   void                     (* get_size)                 (AtkComponent   *component,
175                                                          gint           *width,
176                                                          gint           *height);
177   gboolean                 (* grab_focus)               (AtkComponent   *component);
178   gboolean                 (* grab_highlight)           (AtkComponent   *component);
179   gboolean                 (* clear_highlight)          (AtkComponent   *component);
180   gint                     (* get_highlight_index)      (AtkComponent   *component);
181
182   void                     (* remove_focus_handler)      (AtkComponent  *component,
183                                                           guint         handler_id);
184   gboolean                 (* set_extents)      (AtkComponent   *component,
185                                                  gint           x,
186                                                  gint           y,
187                                                  gint           width,
188                                                  gint           height,
189                                                  AtkCoordType   coord_type);
190   gboolean                 (* set_position)     (AtkComponent   *component,
191                                                  gint           x,
192                                                  gint           y,
193                                                  AtkCoordType   coord_type);
194   gboolean                 (* set_size)         (AtkComponent   *component,
195                                                  gint           width,
196                                                  gint           height);
197
198   AtkLayer                 (* get_layer)        (AtkComponent   *component);
199   gint                     (* get_mdi_zorder)   (AtkComponent   *component);
200
201   /*
202    * signal handlers
203    */
204   void                     (* bounds_changed)   (AtkComponent   *component,
205                                                  AtkRectangle   *bounds);
206   gdouble                  (* get_alpha)        (AtkComponent   *component);
207
208   /*
209    * Scrolls this object so it becomes visible on the screen.
210    *
211    * scroll_to lets the implementation compute an appropriate target
212    * position on the screen, with type used as a positioning hint.
213    *
214    * scroll_to_point lets the client specify a precise target position
215    * on the screen for the top-left of the object.
216    *
217    * Since ATK 2.30
218    */
219   gboolean                (*scroll_to)          (AtkComponent   *component,
220                                                  AtkScrollType   type);
221
222   gboolean                (*scroll_to_point)    (AtkComponent   *component,
223                                                  AtkCoordType    coords,
224                                                  gint            x,
225                                                  gint            y);
226 };
227
228 ATK_AVAILABLE_IN_ALL
229 GType atk_component_get_type (void);
230
231 /* convenience functions */
232 ATK_DEPRECATED_IN_2_10
233 guint                atk_component_add_focus_handler      (AtkComponent    *component,
234                                                            AtkFocusHandler handler);
235 ATK_AVAILABLE_IN_ALL
236 gboolean              atk_component_contains               (AtkComponent    *component,
237                                                             gint            x,
238                                                             gint            y,
239                                                             AtkCoordType    coord_type);
240 ATK_AVAILABLE_IN_ALL
241 AtkObject*            atk_component_ref_accessible_at_point(AtkComponent    *component,
242                                                             gint            x,
243                                                             gint            y,
244                                                             AtkCoordType    coord_type);
245 ATK_AVAILABLE_IN_ALL
246 void                  atk_component_get_extents            (AtkComponent    *component,
247                                                             gint            *x,
248                                                             gint            *y,
249                                                             gint            *width,
250                                                             gint            *height,
251                                                             AtkCoordType    coord_type);
252 ATK_DEPRECATED_IN_2_12_FOR(atk_component_get_extents)
253 void                  atk_component_get_position           (AtkComponent    *component,
254                                                             gint            *x,
255                                                             gint            *y,
256                                                             AtkCoordType    coord_type);
257 ATK_DEPRECATED_IN_2_12_FOR(atk_component_get_extents)
258 void                  atk_component_get_size               (AtkComponent    *component,
259                                                             gint            *width,
260                                                             gint            *height);
261 ATK_AVAILABLE_IN_ALL
262 AtkLayer              atk_component_get_layer              (AtkComponent    *component);
263 ATK_AVAILABLE_IN_ALL
264 gint                  atk_component_get_mdi_zorder         (AtkComponent    *component);
265 ATK_AVAILABLE_IN_ALL
266 gboolean              atk_component_grab_focus             (AtkComponent    *component);
267 ATK_AVAILABLE_IN_ALL
268 gboolean              atk_component_grab_highlight         (AtkComponent    *component);
269 ATK_AVAILABLE_IN_ALL
270 gboolean              atk_component_clear_highlight        (AtkComponent    *component);
271 ATK_AVAILABLE_IN_ALL
272 gint                  atk_component_get_highlight_index    (AtkComponent    *component);
273 ATK_DEPRECATED_IN_2_10
274 void                  atk_component_remove_focus_handler   (AtkComponent    *component,
275                                                             guint           handler_id);
276 ATK_AVAILABLE_IN_ALL
277 gboolean              atk_component_set_extents            (AtkComponent    *component,
278                                                             gint            x,
279                                                             gint            y,
280                                                             gint            width,
281                                                             gint            height,
282                                                             AtkCoordType    coord_type);
283 ATK_AVAILABLE_IN_ALL
284 gboolean              atk_component_set_position           (AtkComponent    *component,
285                                                             gint            x,
286                                                             gint            y,
287                                                             AtkCoordType    coord_type);
288 ATK_AVAILABLE_IN_ALL
289 gboolean              atk_component_set_size               (AtkComponent    *component,
290                                                             gint            width,
291                                                             gint            height);
292 ATK_AVAILABLE_IN_ALL
293 gdouble               atk_component_get_alpha              (AtkComponent    *component);
294
295 ATK_AVAILABLE_IN_2_30
296 gboolean              atk_component_scroll_to              (AtkComponent    *component,
297                                                             AtkScrollType   type);
298
299 ATK_AVAILABLE_IN_2_30
300 gboolean              atk_component_scroll_to_point        (AtkComponent    *component,
301                                                             AtkCoordType    coords,
302                                                             gint            x,
303                                                             gint            y);
304
305 G_END_DECLS
306
307 #endif /* __ATK_COMPONENT_H__ */