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 g_return_val_if_fail (ATK_IS_OBJECT(object->gobj), NULL);
42 return ATK_COMPONENT (object->gobj);
46 * CORBA Accessibility::Component::contains method implementation
49 impl_accessibility_component_contains (PortableServer_Servant servant,
52 CORBA_short coord_type,
53 CORBA_Environment *ev)
56 AtkComponent *component = get_component_from_servant (servant);
58 g_return_val_if_fail (component != NULL, FALSE);
60 retval = atk_component_contains (component, (gint) x, (gint) y,
61 (AtkCoordType) coord_type);
66 * CORBA Accessibility::Component::getAccessibleAtPoint method implementation
68 static Accessibility_Accessible
69 impl_accessibility_component_get_accessible_at_point (PortableServer_Servant servant,
72 CORBA_short coord_type,
73 CORBA_Environment *ev)
76 AtkComponent *component = get_component_from_servant (servant);
78 g_return_val_if_fail (component != NULL, FALSE);
80 child = atk_component_ref_accessible_at_point (component,
82 (AtkCoordType) coord_type);
83 return spi_accessible_new_return (child, TRUE, ev);
87 * CORBA Accessibility::Component::getExtents method implementation
89 static Accessibility_BoundingBox
90 impl_accessibility_component_get_extents (PortableServer_Servant servant,
91 const CORBA_short coord_type,
92 CORBA_Environment *ev)
95 Accessibility_BoundingBox retval;
96 AtkComponent *component = get_component_from_servant (servant);
98 atk_component_get_extents (component, &ix, &iy, &iw, &ih,
99 (AtkCoordType) coord_type);
110 * CORBA Accessibility::Component::getPosition method implementation
113 impl_accessibility_component_get_position (PortableServer_Servant servant,
116 const CORBA_short coord_type,
117 CORBA_Environment *ev)
120 AtkComponent *component = get_component_from_servant (servant);
122 g_return_if_fail (component != NULL);
124 atk_component_get_position (component, &ix, &iy,
125 (AtkCoordType) coord_type);
126 *x = (CORBA_long) ix;
127 *y = (CORBA_long) iy;
131 * CORBA Accessibility::Component::getSize method implementation
134 impl_accessibility_component_get_size (PortableServer_Servant servant,
137 CORBA_Environment *ev)
140 AtkComponent *component = get_component_from_servant (servant);
142 g_return_if_fail (component != NULL);
144 atk_component_get_size (component, &iw, &ih);
145 *width = (CORBA_long) iw;
146 *height = (CORBA_long) ih;
149 static Accessibility_ComponentLayer
150 impl_accessibility_component_get_layer (PortableServer_Servant servant,
151 CORBA_Environment *ev)
154 AtkComponent *component = get_component_from_servant (servant);
156 g_return_val_if_fail (component != NULL, Accessibility_LAYER_INVALID);
158 atklayer = atk_object_get_layer (ATK_OBJECT (component));
161 case ATK_LAYER_BACKGROUND:
162 return Accessibility_LAYER_BACKGROUND;
163 case ATK_LAYER_CANVAS:
164 return Accessibility_LAYER_CANVAS;
165 case ATK_LAYER_WIDGET:
166 return Accessibility_LAYER_WIDGET;
168 return Accessibility_LAYER_MDI;
169 case ATK_LAYER_POPUP:
170 return Accessibility_LAYER_POPUP;
171 case ATK_LAYER_OVERLAY:
172 return Accessibility_LAYER_OVERLAY;
176 return Accessibility_LAYER_INVALID;
180 impl_accessibility_component_get_mdi_z_order (PortableServer_Servant servant,
181 CORBA_Environment *ev)
183 AtkComponent *component = get_component_from_servant (servant);
185 g_return_val_if_fail (component != NULL, -1);
187 return (CORBA_short) atk_object_get_mdi_zorder (ATK_OBJECT (component));
191 spi_component_class_init (SpiComponentClass *klass)
193 POA_Accessibility_Component__epv *epv = &klass->epv;
194 spi_component_parent_class = g_type_class_peek_parent (klass);
196 epv->contains = impl_accessibility_component_contains;
197 epv->getAccessibleAtPoint = impl_accessibility_component_get_accessible_at_point;
198 epv->getExtents = impl_accessibility_component_get_extents;
199 epv->getPosition = impl_accessibility_component_get_position;
200 epv->getSize = impl_accessibility_component_get_size;
201 epv->getLayer = impl_accessibility_component_get_layer;
202 epv->getMDIZOrder = impl_accessibility_component_get_mdi_z_order;
206 spi_component_init (SpiComponent *component)
210 BONOBO_TYPE_FUNC_FULL (SpiComponent,
211 Accessibility_Component,
216 spi_component_interface_new (AtkObject *o)
218 SpiComponent *retval = g_object_new (SPI_COMPONENT_TYPE, NULL);
220 spi_base_construct (SPI_BASE (retval), G_OBJECT(o));