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 atk_component_get_extents (component, &ix, &iy, &iw, &ih,
98 (AtkCoordType) coord_type);
109 * CORBA Accessibility::Component::getPosition method implementation
112 impl_accessibility_component_get_position (PortableServer_Servant servant,
115 const CORBA_short coord_type,
116 CORBA_Environment *ev)
119 AtkComponent *component = get_component_from_servant (servant);
121 g_return_if_fail (component != NULL);
123 atk_component_get_position (component, &ix, &iy,
124 (AtkCoordType) coord_type);
125 *x = (CORBA_long) ix;
126 *y = (CORBA_long) iy;
130 * CORBA Accessibility::Component::getSize method implementation
133 impl_accessibility_component_get_size (PortableServer_Servant servant,
136 CORBA_Environment *ev)
139 AtkComponent *component = get_component_from_servant (servant);
141 g_return_if_fail (component != NULL);
143 atk_component_get_size (component, &iw, &ih);
144 *width = (CORBA_long) iw;
145 *height = (CORBA_long) ih;
148 static Accessibility_ComponentLayer
149 impl_accessibility_component_get_layer (PortableServer_Servant servant,
150 CORBA_Environment *ev)
153 AtkComponent *component = get_component_from_servant (servant);
155 g_return_val_if_fail (component != NULL, Accessibility_LAYER_INVALID);
157 atklayer = atk_object_get_layer (ATK_OBJECT (component));
160 case ATK_LAYER_BACKGROUND:
161 return Accessibility_LAYER_BACKGROUND;
162 case ATK_LAYER_CANVAS:
163 return Accessibility_LAYER_CANVAS;
164 case ATK_LAYER_WIDGET:
165 return Accessibility_LAYER_WIDGET;
167 return Accessibility_LAYER_MDI;
168 case ATK_LAYER_POPUP:
169 return Accessibility_LAYER_POPUP;
170 case ATK_LAYER_OVERLAY:
171 return Accessibility_LAYER_OVERLAY;
175 return Accessibility_LAYER_INVALID;
179 impl_accessibility_component_get_mdi_z_order (PortableServer_Servant servant,
180 CORBA_Environment *ev)
182 AtkComponent *component = get_component_from_servant (servant);
184 g_return_val_if_fail (component != NULL, -1);
186 return (CORBA_short) atk_object_get_mdi_zorder (ATK_OBJECT (component));
190 spi_component_class_init (SpiComponentClass *klass)
192 POA_Accessibility_Component__epv *epv = &klass->epv;
193 spi_component_parent_class = g_type_class_peek_parent (klass);
195 epv->contains = impl_accessibility_component_contains;
196 epv->getAccessibleAtPoint = impl_accessibility_component_get_accessible_at_point;
197 epv->getExtents = impl_accessibility_component_get_extents;
198 epv->getPosition = impl_accessibility_component_get_position;
199 epv->getSize = impl_accessibility_component_get_size;
200 epv->getLayer = impl_accessibility_component_get_layer;
201 epv->getMDIZOrder = impl_accessibility_component_get_mdi_z_order;
205 spi_component_init (SpiComponent *component)
209 BONOBO_TYPE_FUNC_FULL (SpiComponent,
210 Accessibility_Component,
215 spi_component_interface_new (AtkObject *o)
217 SpiComponent *retval = g_object_new (SPI_COMPONENT_TYPE, NULL);
219 spi_base_construct (SPI_BASE (retval), o);