* Boston, MA 02111-1307, USA.
*/
-/*
- * component.c : bonobo wrapper for accessible component implementation
- *
- */
-#include <config.h>
-#include <bonobo/Bonobo.h>
+/* component.c : implements the Component interface */
+#include <config.h>
#include <stdio.h>
+#include <libspi/accessible.h>
+#include <libspi/component.h>
-/*
- * This pulls the CORBA definitions for the "Accessibility::Accessible" server
- */
-#include <libspi/Accessibility.h>
+/* Our parent Gtk object type */
+#define PARENT_TYPE SPI_TYPE_BASE
+
+/* A pointer to our parent object class */
+static GObjectClass *spi_component_parent_class;
+
+static AtkComponent *
+get_component_from_servant (PortableServer_Servant servant)
+{
+ SpiBase *object = SPI_BASE (bonobo_object_from_servant (servant));
+ g_return_val_if_fail (object != NULL, NULL);
+ g_return_val_if_fail (ATK_IS_OBJECT(object->gobj), NULL);
+ return ATK_COMPONENT (object->gobj);
+}
/*
- * This pulls the definition for the BonoboObject (Gtk Type)
+ * CORBA Accessibility::Component::contains method implementation
*/
-#include "component.h"
+static CORBA_boolean
+impl_accessibility_component_contains (PortableServer_Servant servant,
+ const CORBA_long x,
+ const CORBA_long y,
+ CORBA_short coord_type,
+ CORBA_Environment *ev)
+{
+ CORBA_boolean retval;
+ AtkComponent *component = get_component_from_servant (servant);
+
+ g_return_val_if_fail (component != NULL, FALSE);
+
+ retval = atk_component_contains (component, (gint) x, (gint) y,
+ (AtkCoordType) coord_type);
+ return retval;
+}
/*
- * Our parent Gtk object type
+ * CORBA Accessibility::Component::getAccessibleAtPoint method implementation
*/
-#define PARENT_TYPE BONOBO_OBJECT_TYPE
+static Accessibility_Accessible
+impl_accessibility_component_get_accessible_at_point (PortableServer_Servant servant,
+ const CORBA_long x,
+ const CORBA_long y,
+ CORBA_short coord_type,
+ CORBA_Environment *ev)
+{
+ AtkObject *child;
+ AtkComponent *component = get_component_from_servant (servant);
+
+ g_return_val_if_fail (component != NULL, FALSE);
+
+ child = atk_component_ref_accessible_at_point (component,
+ (gint) x, (gint) y,
+ (AtkCoordType) coord_type);
+ return spi_accessible_new_return (child, TRUE, ev);
+}
/*
- * A pointer to our parent object class
+ * CORBA Accessibility::Component::getExtents method implementation
*/
-static GObjectClass *component_parent_class;
+static Accessibility_BoundingBox
+impl_accessibility_component_get_extents (PortableServer_Servant servant,
+ const CORBA_short coord_type,
+ CORBA_Environment *ev)
+{
+ gint ix, iy, iw, ih;
+ Accessibility_BoundingBox retval;
+ AtkComponent *component = get_component_from_servant (servant);
+
+ atk_component_get_extents (component, &ix, &iy, &iw, &ih,
+ (AtkCoordType) coord_type);
+
+ retval.x = ix;
+ retval.y = iy;
+ retval.width = iw;
+ retval.height = ih;
+
+ return retval;
+}
/*
- * Implemented GObject::finalize
+ * CORBA Accessibility::Component::getPosition method implementation
*/
static void
-accessibility_component_object_finalize (GObject *object)
+impl_accessibility_component_get_position (PortableServer_Servant servant,
+ CORBA_long * x,
+ CORBA_long * y,
+ const CORBA_short coord_type,
+ CORBA_Environment *ev)
{
- Component *component = COMPONENT (object);
+ gint ix, iy;
+ AtkComponent *component = get_component_from_servant (servant);
- printf("accessible_component_object_finalize called\n");
- component->atko = NULL;
+ g_return_if_fail (component != NULL);
- printf("atko freed, calling parent finalize\n");
- component_parent_class->finalize (object);
+ atk_component_get_position (component, &ix, &iy,
+ (AtkCoordType) coord_type);
+ *x = (CORBA_long) ix;
+ *y = (CORBA_long) iy;
}
/*
- * CORBA Accessibility::Component::contains method implementation
+ * CORBA Accessibility::Component::getSize method implementation
*/
-static CORBA_boolean
-impl_accessibility_component_contains (PortableServer_Servant servant,
- const CORBA_long x,
- const CORBA_long y,
- CORBA_short coord_type,
+static void
+impl_accessibility_component_get_size (PortableServer_Servant servant,
+ CORBA_long * width,
+ CORBA_long * height,
CORBA_Environment *ev)
{
- CORBA_boolean retval;
- Component *component = COMPONENT (bonobo_object_from_servant (servant));
- retval = atk_component_contains (ATK_COMPONENT (component->atko), (gint) x, (gint) y,
- (AtkCoordType) coord_type);
- fprintf (stderr, "Component contains() called: %s\n", retval ? "true" : "false" );
- return retval;
+ gint iw, ih;
+ AtkComponent *component = get_component_from_servant (servant);
+
+ g_return_if_fail (component != NULL);
+
+ atk_component_get_size (component, &iw, &ih);
+ *width = (CORBA_long) iw;
+ *height = (CORBA_long) ih;
}
-static void
-accessibility_component_class_init (ComponentClass *klass)
+static Accessibility_ComponentLayer
+impl_accessibility_component_get_layer (PortableServer_Servant servant,
+ CORBA_Environment *ev)
{
- GObjectClass * object_class = (GObjectClass *) klass;
- POA_Accessibility_Component__epv *epv = &klass->epv;
- component_parent_class = g_type_class_peek_parent (klass);
+ AtkLayer atklayer;
+ AtkComponent *component = get_component_from_servant (servant);
+
+ g_return_val_if_fail (component != NULL, Accessibility_LAYER_INVALID);
+
+ atklayer = atk_object_get_layer (ATK_OBJECT (component));
+ switch (atklayer)
+ {
+ case ATK_LAYER_BACKGROUND:
+ return Accessibility_LAYER_BACKGROUND;
+ case ATK_LAYER_CANVAS:
+ return Accessibility_LAYER_CANVAS;
+ case ATK_LAYER_WIDGET:
+ return Accessibility_LAYER_WIDGET;
+ case ATK_LAYER_MDI:
+ return Accessibility_LAYER_MDI;
+ case ATK_LAYER_POPUP:
+ return Accessibility_LAYER_POPUP;
+ case ATK_LAYER_OVERLAY:
+ return Accessibility_LAYER_OVERLAY;
+ default:
+ break;
+ }
+ return Accessibility_LAYER_INVALID;
+}
+
+static CORBA_short
+impl_accessibility_component_get_mdi_z_order (PortableServer_Servant servant,
+ CORBA_Environment *ev)
+{
+ AtkComponent *component = get_component_from_servant (servant);
- object_class->finalize = accessibility_component_object_finalize;
+ g_return_val_if_fail (component != NULL, -1);
- epv->contains = impl_accessibility_component_contains;
+ return (CORBA_short) atk_object_get_mdi_zorder (ATK_OBJECT (component));
}
static void
-accessibility_component_init (Component *component)
+spi_component_class_init (SpiComponentClass *klass)
{
+ POA_Accessibility_Component__epv *epv = &klass->epv;
+ spi_component_parent_class = g_type_class_peek_parent (klass);
+
+ epv->contains = impl_accessibility_component_contains;
+ epv->getAccessibleAtPoint = impl_accessibility_component_get_accessible_at_point;
+ epv->getExtents = impl_accessibility_component_get_extents;
+ epv->getPosition = impl_accessibility_component_get_position;
+ epv->getSize = impl_accessibility_component_get_size;
+ epv->getLayer = impl_accessibility_component_get_layer;
+ epv->getMDIZOrder = impl_accessibility_component_get_mdi_z_order;
}
-GType
-accessibility_component_get_type (void)
+static void
+spi_component_init (SpiComponent *component)
{
- static GType type = 0;
-
- if (!type) {
- static const GTypeInfo tinfo = {
- sizeof (ComponentClass),
- (GBaseInitFunc) NULL,
- (GBaseFinalizeFunc) NULL,
- (GClassInitFunc) accessibility_component_class_init,
- (GClassFinalizeFunc) NULL,
- NULL, /* class data */
- sizeof (Component),
- 0, /* n preallocs */
- (GInstanceInitFunc) accessibility_component_init,
- NULL /* value table */
- };
- /*
- * Bonobo_type_unique auto-generates a load of
- * CORBA structures for us. All derived types must
- * use bonobo_type_unique.
- */
- type = bonobo_type_unique (
- PARENT_TYPE,
- POA_Accessibility_Component__init,
- NULL,
- G_STRUCT_OFFSET (ComponentClass, epv),
- &tinfo,
- "AccessibleComponent");
- }
-
- return type;
}
-Component *
-component_interface_new (AtkObject *o)
+BONOBO_TYPE_FUNC_FULL (SpiComponent,
+ Accessibility_Component,
+ PARENT_TYPE,
+ spi_component);
+
+SpiComponent *
+spi_component_interface_new (AtkObject *o)
{
- Component *retval =
- COMPONENT (g_object_new (accessibility_component_get_type (), NULL));
- /* don't increment AtkObject refcount, ref is held by containing Accessible instance */
- retval->atko = ATK_OBJECT (o);
+ SpiComponent *retval = g_object_new (SPI_COMPONENT_TYPE, NULL);
+
+ spi_base_construct (SPI_BASE (retval), G_OBJECT(o));
+
return retval;
}