2 * AT-SPI - Assistive Technology Service Provider Interface
3 * (Gnome Accessibility Project; http://developer.gnome.org/projects/gap)
5 * Copyright 2001 Sun Microsystems Inc.
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Library General Public
9 * License as published by the Free Software Foundation; either
10 * version 2 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Library General Public License for more details.
17 * You should have received a copy of the GNU Library General Public
18 * License along with this library; if not, write to the
19 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
20 * Boston, MA 02111-1307, USA.
23 /* component.c : implements the Component interface */
27 #include <libspi/accessible.h>
28 #include <libspi/component.h>
30 /* Our parent Gtk object type */
31 #define PARENT_TYPE SPI_TYPE_BASE
33 /* A pointer to our parent object class */
34 static GObjectClass *spi_component_parent_class;
37 get_component_from_servant (PortableServer_Servant servant)
39 SpiBase *object = SPI_BASE (bonobo_object_from_servant (servant));
40 g_return_val_if_fail (object != NULL, NULL);
41 return ATK_COMPONENT (object->atko);
45 * CORBA Accessibility::Component::contains method implementation
48 impl_accessibility_component_contains (PortableServer_Servant servant,
51 CORBA_short coord_type,
52 CORBA_Environment *ev)
55 AtkComponent *component = get_component_from_servant (servant);
57 g_return_val_if_fail (component != NULL, FALSE);
59 retval = atk_component_contains (component, (gint) x, (gint) y,
60 (AtkCoordType) coord_type);
65 * CORBA Accessibility::Component::getAccessibleAtPoint method implementation
67 static Accessibility_Accessible
68 impl_accessibility_component_get_accessible_at_point (PortableServer_Servant servant,
71 CORBA_short coord_type,
72 CORBA_Environment *ev)
75 AtkComponent *component = get_component_from_servant (servant);
77 g_return_val_if_fail (component != NULL, FALSE);
79 child = atk_component_ref_accessible_at_point (component,
81 (AtkCoordType) coord_type);
82 return spi_accessible_new_return (child, TRUE, ev);
86 * CORBA Accessibility::Component::getExtents method implementation
88 static Accessibility_BoundingBox
89 impl_accessibility_component_get_extents (PortableServer_Servant servant,
90 const CORBA_short coord_type,
91 CORBA_Environment *ev)
94 Accessibility_BoundingBox retval;
95 AtkComponent *component = get_component_from_servant (servant);
97 g_return_if_fail (component != NULL);
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);
127 *x = (CORBA_long) ix;
128 *y = (CORBA_long) iy;
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);
146 *width = (CORBA_long) iw;
147 *height = (CORBA_long) 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_object_get_layer (ATK_OBJECT (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;
177 return Accessibility_LAYER_INVALID;
181 impl_accessibility_component_get_mdi_z_order (PortableServer_Servant servant,
182 CORBA_Environment *ev)
184 AtkComponent *component = get_component_from_servant (servant);
186 g_return_val_if_fail (component != NULL, -1);
188 return (CORBA_short) atk_object_get_mdi_zorder (ATK_OBJECT (component));
192 spi_component_class_init (SpiComponentClass *klass)
194 POA_Accessibility_Component__epv *epv = &klass->epv;
195 spi_component_parent_class = g_type_class_peek_parent (klass);
197 epv->contains = impl_accessibility_component_contains;
198 epv->getAccessibleAtPoint = impl_accessibility_component_get_accessible_at_point;
199 epv->getExtents = impl_accessibility_component_get_extents;
200 epv->getPosition = impl_accessibility_component_get_position;
201 epv->getSize = impl_accessibility_component_get_size;
202 epv->getLayer = impl_accessibility_component_get_layer;
203 epv->getMDIZOrder = impl_accessibility_component_get_mdi_z_order;
207 spi_component_init (SpiComponent *component)
211 BONOBO_TYPE_FUNC_FULL (SpiComponent,
212 Accessibility_Component,
217 spi_component_interface_new (AtkObject *o)
219 SpiComponent *retval = g_object_new (SPI_COMPONENT_TYPE, NULL);
221 spi_base_construct (SPI_BASE (retval), o);