1 | /* |
---|
2 | * AT-SPI - Assistive Technology Service Provider Interface |
---|
3 | * (Gnome Accessibility Project; http://developer.gnome.org/projects/gap) |
---|
4 | * |
---|
5 | * Copyright 2001, 2002 Sun Microsystems Inc., |
---|
6 | * Copyright 2001, 2002 Ximian, Inc. |
---|
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 | /* component.c : implements the Component interface */ |
---|
25 | |
---|
26 | #include <config.h> |
---|
27 | #include <stdio.h> |
---|
28 | #include <libspi/accessible.h> |
---|
29 | #include <libspi/component.h> |
---|
30 | |
---|
31 | /* Our parent Gtk object type */ |
---|
32 | #define PARENT_TYPE SPI_TYPE_BASE |
---|
33 | |
---|
34 | /* A pointer to our parent object class */ |
---|
35 | static GObjectClass *spi_component_parent_class; |
---|
36 | |
---|
37 | static AtkComponent * |
---|
38 | get_component_from_servant (PortableServer_Servant servant) |
---|
39 | { |
---|
40 | SpiBase *object = SPI_BASE (bonobo_object_from_servant (servant)); |
---|
41 | g_return_val_if_fail (object != NULL, NULL); |
---|
42 | g_return_val_if_fail (ATK_IS_OBJECT(object->gobj), NULL); |
---|
43 | return ATK_COMPONENT (object->gobj); |
---|
44 | } |
---|
45 | |
---|
46 | /* |
---|
47 | * CORBA Accessibility::Component::contains method implementation |
---|
48 | */ |
---|
49 | static CORBA_boolean |
---|
50 | impl_accessibility_component_contains (PortableServer_Servant servant, |
---|
51 | const CORBA_long x, |
---|
52 | const CORBA_long y, |
---|
53 | CORBA_short coord_type, |
---|
54 | CORBA_Environment *ev) |
---|
55 | { |
---|
56 | CORBA_boolean retval; |
---|
57 | AtkComponent *component = get_component_from_servant (servant); |
---|
58 | |
---|
59 | g_return_val_if_fail (component != NULL, FALSE); |
---|
60 | |
---|
61 | retval = atk_component_contains (component, x, y, |
---|
62 | (AtkCoordType) coord_type); |
---|
63 | return retval; |
---|
64 | } |
---|
65 | |
---|
66 | /* |
---|
67 | * CORBA Accessibility::Component::getAccessibleAtPoint method implementation |
---|
68 | */ |
---|
69 | static Accessibility_Accessible |
---|
70 | impl_accessibility_component_get_accessible_at_point (PortableServer_Servant servant, |
---|
71 | const CORBA_long x, |
---|
72 | const CORBA_long y, |
---|
73 | CORBA_short coord_type, |
---|
74 | CORBA_Environment *ev) |
---|
75 | { |
---|
76 | AtkObject *child; |
---|
77 | AtkComponent *component = get_component_from_servant (servant); |
---|
78 | |
---|
79 | g_return_val_if_fail (component != NULL, FALSE); |
---|
80 | |
---|
81 | child = atk_component_ref_accessible_at_point (component, |
---|
82 | x, y, |
---|
83 | (AtkCoordType) coord_type); |
---|
84 | return spi_accessible_new_return (child, TRUE, ev); |
---|
85 | } |
---|
86 | |
---|
87 | /* |
---|
88 | * CORBA Accessibility::Component::getExtents method implementation |
---|
89 | */ |
---|
90 | static Accessibility_BoundingBox |
---|
91 | impl_accessibility_component_get_extents (PortableServer_Servant servant, |
---|
92 | const CORBA_short coord_type, |
---|
93 | CORBA_Environment *ev) |
---|
94 | { |
---|
95 | gint ix, iy, iw, ih; |
---|
96 | Accessibility_BoundingBox retval; |
---|
97 | AtkComponent *component = get_component_from_servant (servant); |
---|
98 | |
---|
99 | atk_component_get_extents (component, &ix, &iy, &iw, &ih, |
---|
100 | (AtkCoordType) coord_type); |
---|
101 | |
---|
102 | retval.x = ix; |
---|
103 | retval.y = iy; |
---|
104 | retval.width = iw; |
---|
105 | retval.height = ih; |
---|
106 | |
---|
107 | return retval; |
---|
108 | } |
---|
109 | |
---|
110 | /* |
---|
111 | * CORBA Accessibility::Component::getPosition method implementation |
---|
112 | */ |
---|
113 | static void |
---|
114 | impl_accessibility_component_get_position (PortableServer_Servant servant, |
---|
115 | CORBA_long * x, |
---|
116 | CORBA_long * y, |
---|
117 | const CORBA_short coord_type, |
---|
118 | CORBA_Environment *ev) |
---|
119 | { |
---|
120 | gint ix, iy; |
---|
121 | AtkComponent *component = get_component_from_servant (servant); |
---|
122 | |
---|
123 | g_return_if_fail (component != NULL); |
---|
124 | |
---|
125 | atk_component_get_position (component, &ix, &iy, |
---|
126 | (AtkCoordType) coord_type); |
---|
127 | *x = ix; |
---|
128 | *y = iy; |
---|
129 | } |
---|
130 | |
---|
131 | /* |
---|
132 | * CORBA Accessibility::Component::getSize method implementation |
---|
133 | */ |
---|
134 | static void |
---|
135 | impl_accessibility_component_get_size (PortableServer_Servant servant, |
---|
136 | CORBA_long * width, |
---|
137 | CORBA_long * height, |
---|
138 | CORBA_Environment *ev) |
---|
139 | { |
---|
140 | gint iw, ih; |
---|
141 | AtkComponent *component = get_component_from_servant (servant); |
---|
142 | |
---|
143 | g_return_if_fail (component != NULL); |
---|
144 | |
---|
145 | atk_component_get_size (component, &iw, &ih); |
---|
146 | *width = iw; |
---|
147 | *height = ih; |
---|
148 | } |
---|
149 | |
---|
150 | static Accessibility_ComponentLayer |
---|
151 | impl_accessibility_component_get_layer (PortableServer_Servant servant, |
---|
152 | CORBA_Environment *ev) |
---|
153 | { |
---|
154 | AtkLayer atklayer; |
---|
155 | AtkComponent *component = get_component_from_servant (servant); |
---|
156 | |
---|
157 | g_return_val_if_fail (component != NULL, Accessibility_LAYER_INVALID); |
---|
158 | |
---|
159 | atklayer = atk_component_get_layer (component); |
---|
160 | switch (atklayer) |
---|
161 | { |
---|
162 | case ATK_LAYER_BACKGROUND: |
---|
163 | return Accessibility_LAYER_BACKGROUND; |
---|
164 | case ATK_LAYER_CANVAS: |
---|
165 | return Accessibility_LAYER_CANVAS; |
---|
166 | case ATK_LAYER_WIDGET: |
---|
167 | return Accessibility_LAYER_WIDGET; |
---|
168 | case ATK_LAYER_MDI: |
---|
169 | return Accessibility_LAYER_MDI; |
---|
170 | case ATK_LAYER_POPUP: |
---|
171 | return Accessibility_LAYER_POPUP; |
---|
172 | case ATK_LAYER_OVERLAY: |
---|
173 | return Accessibility_LAYER_OVERLAY; |
---|
174 | case ATK_LAYER_WINDOW: |
---|
175 | return Accessibility_LAYER_WINDOW; |
---|
176 | default: |
---|
177 | break; |
---|
178 | } |
---|
179 | return Accessibility_LAYER_INVALID; |
---|
180 | } |
---|
181 | |
---|
182 | static CORBA_short |
---|
183 | impl_accessibility_component_get_mdi_z_order (PortableServer_Servant servant, |
---|
184 | CORBA_Environment *ev) |
---|
185 | { |
---|
186 | AtkComponent *component = get_component_from_servant (servant); |
---|
187 | |
---|
188 | g_return_val_if_fail (component != NULL, -1); |
---|
189 | |
---|
190 | return atk_component_get_mdi_zorder (component); |
---|
191 | } |
---|
192 | |
---|
193 | static CORBA_boolean |
---|
194 | impl_accessibility_component_grab_focus (PortableServer_Servant servant, |
---|
195 | CORBA_Environment *ev) |
---|
196 | { |
---|
197 | AtkComponent *component = get_component_from_servant (servant); |
---|
198 | |
---|
199 | g_return_val_if_fail (component != NULL, FALSE); |
---|
200 | |
---|
201 | return atk_component_grab_focus (component); |
---|
202 | } |
---|
203 | |
---|
204 | static void |
---|
205 | spi_component_class_init (SpiComponentClass *klass) |
---|
206 | { |
---|
207 | POA_Accessibility_Component__epv *epv = &klass->epv; |
---|
208 | spi_component_parent_class = g_type_class_peek_parent (klass); |
---|
209 | |
---|
210 | epv->contains = impl_accessibility_component_contains; |
---|
211 | epv->getAccessibleAtPoint = impl_accessibility_component_get_accessible_at_point; |
---|
212 | epv->getExtents = impl_accessibility_component_get_extents; |
---|
213 | epv->getPosition = impl_accessibility_component_get_position; |
---|
214 | epv->getSize = impl_accessibility_component_get_size; |
---|
215 | epv->getLayer = impl_accessibility_component_get_layer; |
---|
216 | epv->getMDIZOrder = impl_accessibility_component_get_mdi_z_order; |
---|
217 | epv->grabFocus = impl_accessibility_component_grab_focus; |
---|
218 | } |
---|
219 | |
---|
220 | static void |
---|
221 | spi_component_init (SpiComponent *component) |
---|
222 | { |
---|
223 | } |
---|
224 | |
---|
225 | BONOBO_TYPE_FUNC_FULL (SpiComponent, |
---|
226 | Accessibility_Component, |
---|
227 | PARENT_TYPE, |
---|
228 | spi_component); |
---|
229 | |
---|
230 | SpiComponent * |
---|
231 | spi_component_interface_new (AtkObject *o) |
---|
232 | { |
---|
233 | SpiComponent *retval = g_object_new (SPI_COMPONENT_TYPE, NULL); |
---|
234 | |
---|
235 | spi_base_construct (SPI_BASE (retval), G_OBJECT(o)); |
---|
236 | |
---|
237 | return retval; |
---|
238 | } |
---|