Initial revision
[platform/upstream/atk.git] / atk / atkcomponent.c
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 Lesser 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  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser 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
21 #include "atkcomponent.h"
22
23 GType
24 atk_component_get_type ()
25 {
26   static GType type = 0;
27
28   if (!type) {
29     static const GTypeInfo tinfo =
30     {
31       sizeof (AtkComponentIface),
32       NULL,
33       NULL,
34
35     };
36
37     type = g_type_register_static (G_TYPE_INTERFACE, "AtkComponent", &tinfo, 0);
38   }
39
40   return type;
41 }
42
43 /**
44  *
45  **/
46 guint
47 atk_component_add_focus_handler (AtkComponent    *component,
48                                  AtkFocusHandler handler)
49 {
50   AtkComponentIface *iface = NULL;
51   g_return_val_if_fail (component != NULL, 0);
52   g_return_val_if_fail (ATK_IS_COMPONENT (component), 0);
53
54   iface = ATK_COMPONENT_GET_IFACE (component);
55
56   if (iface->add_focus_handler)
57     return (iface->add_focus_handler) (component, handler);
58   else
59     return 0;
60 }
61
62 /**
63  *
64  **/
65 void
66 atk_component_remove_focus_handler (AtkComponent    *component,
67                                     guint           handler_id)
68 {
69   AtkComponentIface *iface = NULL;
70   g_return_if_fail (component != NULL);
71   g_return_if_fail (ATK_IS_COMPONENT (component));
72
73   iface = ATK_COMPONENT_GET_IFACE (component);
74
75   if (iface->remove_focus_handler)
76     (iface->remove_focus_handler) (component, handler_id);
77 }
78
79 gboolean
80 atk_component_contains (AtkComponent    *component,
81                         gint            x,
82                         gint            y)
83 {
84   AtkComponentIface *iface = NULL;
85   g_return_val_if_fail (component != NULL, FALSE);
86   g_return_val_if_fail (ATK_IS_COMPONENT (component), FALSE);
87
88   iface = ATK_COMPONENT_GET_IFACE (component);
89
90   if (iface->contains)
91     return (iface->contains) (component, x, y);
92   else
93     return FALSE;
94 }
95
96 AtkObject*
97 atk_component_get_accessible_at_point (AtkComponent    *component,
98                                        gint            x,
99                                        gint            y)
100 {
101   AtkComponentIface *iface = NULL;
102   g_return_val_if_fail (component != NULL, FALSE);
103   g_return_val_if_fail (ATK_IS_COMPONENT (component), FALSE);
104
105   iface = ATK_COMPONENT_GET_IFACE (component);
106
107   if (iface->get_accessible_at_point)
108     return (iface->get_accessible_at_point) (component, x, y);
109   else
110     return FALSE;
111 }
112
113 void
114 atk_component_get_extents    (AtkComponent    *component,
115                               gint            *x,
116                               gint            *y,
117                               gint            *width,
118                               gint            *height)
119 {
120   AtkComponentIface *iface = NULL;
121   g_return_if_fail (component != NULL);
122   g_return_if_fail (ATK_IS_COMPONENT (component));
123
124   iface = ATK_COMPONENT_GET_IFACE (component);
125
126   if (iface->get_extents)
127     (iface->get_extents) (component, x, y, width, height);
128 }
129
130 void
131 atk_component_get_position   (AtkComponent    *component,
132                               gint            *x,
133                               gint            *y)
134 {
135   AtkComponentIface *iface = NULL;
136   g_return_if_fail (component != NULL);
137   g_return_if_fail (ATK_IS_COMPONENT (component));
138
139   iface = ATK_COMPONENT_GET_IFACE (component);
140
141   if (iface->get_position)
142     (iface->get_position) (component, x, y);
143 }
144
145 void
146 atk_component_get_position_on_screen (AtkComponent    *component,
147                                       gint            *x,
148                                       gint            *y)
149 {
150   AtkComponentIface *iface = NULL;
151   g_return_if_fail (component != NULL);
152   g_return_if_fail (ATK_IS_COMPONENT (component));
153
154   iface = ATK_COMPONENT_GET_IFACE (component);
155
156   if (iface->get_position_on_screen)
157     return (iface->get_position_on_screen) (component, x, y);
158 }
159
160 void
161 atk_component_get_size       (AtkComponent    *component,
162                               gint            *x,
163                               gint            *y)
164 {
165   AtkComponentIface *iface = NULL;
166   g_return_if_fail (component != NULL);
167   g_return_if_fail (ATK_IS_COMPONENT (component));
168
169   iface = ATK_COMPONENT_GET_IFACE (component);
170
171   if (iface->get_size)
172     (iface->get_size) (component, x, y);
173 }
174
175 void
176 atk_component_grab_focus (AtkComponent    *component)
177 {
178   AtkComponentIface *iface = NULL;
179   g_return_if_fail (component != NULL);
180   g_return_if_fail (ATK_IS_COMPONENT (component));
181
182   iface = ATK_COMPONENT_GET_IFACE (component);
183
184   if (iface->grab_focus)
185     (iface->grab_focus) (component);
186 }
187
188 void
189 atk_component_set_extents   (AtkComponent    *component,
190                              gint            x,
191                              gint            y,
192                              gint            width,
193                              gint            height)
194 {
195   AtkComponentIface *iface = NULL;
196   g_return_if_fail (component != NULL);
197   g_return_if_fail (ATK_IS_COMPONENT (component));
198
199   iface = ATK_COMPONENT_GET_IFACE (component);
200
201   if (iface->set_extents)
202     (iface->set_extents) (component, x, y, width, height);
203 }
204
205 void
206 atk_component_set_position   (AtkComponent    *component,
207                               gint            x,
208                               gint            y)
209 {
210   AtkComponentIface *iface = NULL;
211   g_return_if_fail (component != NULL);
212   g_return_if_fail (ATK_IS_COMPONENT (component));
213
214   iface = ATK_COMPONENT_GET_IFACE (component);
215
216   if (iface->set_position)
217     (iface->set_position) (component, x, y);
218 }
219
220 void
221 atk_component_set_size       (AtkComponent    *component,
222                               gint            x,
223                               gint            y)
224 {
225   AtkComponentIface *iface = NULL;
226   g_return_if_fail (component != NULL);
227   g_return_if_fail (ATK_IS_COMPONENT (component));
228
229   iface = ATK_COMPONENT_GET_IFACE (component);
230
231   if (iface->set_size)
232     (iface->set_size) (component, x, y);
233 }