2 * AT-SPI - Assistive Technology Service Provider Interface
3 * (Gnome Accessibility Project; http://developer.gnome.org/projects/gap)
5 * Copyright 2001, 2002 Sun Microsystems Inc.,
6 * Copyright 2001, 2002 Ximian, Inc.
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.
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.
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.
24 /* component.c : implements the Component interface */
28 #include <libspi/accessible.h>
29 #include <libspi/component.h>
31 /* Our parent Gtk object type */
32 #define PARENT_TYPE SPI_TYPE_BASE
34 /* A pointer to our parent object class */
35 static GObjectClass *spi_component_parent_class;
38 get_component_from_servant (PortableServer_Servant servant)
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);
47 * CORBA Accessibility::Component::contains method implementation
50 impl_accessibility_component_contains (PortableServer_Servant servant,
53 CORBA_short coord_type,
54 CORBA_Environment *ev)
57 AtkComponent *component = get_component_from_servant (servant);
59 g_return_val_if_fail (component != NULL, FALSE);
61 retval = atk_component_contains (component, x, y,
62 (AtkCoordType) coord_type);
67 * CORBA Accessibility::Component::getAccessibleAtPoint method implementation
69 static Accessibility_Accessible
70 impl_accessibility_component_get_accessible_at_point (PortableServer_Servant servant,
73 CORBA_short coord_type,
74 CORBA_Environment *ev)
77 AtkComponent *component = get_component_from_servant (servant);
79 g_return_val_if_fail (component != NULL, FALSE);
81 child = atk_component_ref_accessible_at_point (component,
83 (AtkCoordType) coord_type);
84 return spi_accessible_new_return (child, TRUE, ev);
88 * CORBA Accessibility::Component::getExtents method implementation
90 static Accessibility_BoundingBox
91 impl_accessibility_component_get_extents (PortableServer_Servant servant,
92 const CORBA_short coord_type,
93 CORBA_Environment *ev)
96 Accessibility_BoundingBox retval;
97 AtkComponent *component = get_component_from_servant (servant);
99 atk_component_get_extents (component, &ix, &iy, &iw, &ih,
100 (AtkCoordType) coord_type);
111 * CORBA Accessibility::Component::getPosition method implementation
114 impl_accessibility_component_get_position (PortableServer_Servant servant,
117 const CORBA_short coord_type,
118 CORBA_Environment *ev)
121 AtkComponent *component = get_component_from_servant (servant);
123 g_return_if_fail (component != NULL);
125 atk_component_get_position (component, &ix, &iy,
126 (AtkCoordType) coord_type);
132 * CORBA Accessibility::Component::getSize method implementation
135 impl_accessibility_component_get_size (PortableServer_Servant servant,
138 CORBA_Environment *ev)
141 AtkComponent *component = get_component_from_servant (servant);
143 g_return_if_fail (component != NULL);
145 atk_component_get_size (component, &iw, &ih);
150 static Accessibility_ComponentLayer
151 impl_accessibility_component_get_layer (PortableServer_Servant servant,
152 CORBA_Environment *ev)
155 AtkComponent *component = get_component_from_servant (servant);
157 g_return_val_if_fail (component != NULL, Accessibility_LAYER_INVALID);
159 atklayer = atk_component_get_layer (component);
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;
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;
179 return Accessibility_LAYER_INVALID;
183 impl_accessibility_component_get_mdi_z_order (PortableServer_Servant servant,
184 CORBA_Environment *ev)
186 AtkComponent *component = get_component_from_servant (servant);
188 g_return_val_if_fail (component != NULL, -1);
190 return atk_component_get_mdi_zorder (component);
194 impl_accessibility_component_grab_focus (PortableServer_Servant servant,
195 CORBA_Environment *ev)
197 AtkComponent *component = get_component_from_servant (servant);
199 g_return_val_if_fail (component != NULL, FALSE);
201 return atk_component_grab_focus (component);
205 spi_component_class_init (SpiComponentClass *klass)
207 POA_Accessibility_Component__epv *epv = &klass->epv;
208 spi_component_parent_class = g_type_class_peek_parent (klass);
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;
221 spi_component_init (SpiComponent *component)
225 BONOBO_TYPE_FUNC_FULL (SpiComponent,
226 Accessibility_Component,
231 spi_component_interface_new (AtkObject *o)
233 SpiComponent *retval = g_object_new (SPI_COMPONENT_TYPE, NULL);
235 spi_base_construct (SPI_BASE (retval), G_OBJECT(o));