2 * AT-SPI - Assistive Technology Service Provider Interface
3 * (Gnome Accessibility Project; https://wiki.gnome.org/Accessibility)
5 * Copyright (c) 2015 Samsung Electronics Co., Ltd.
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 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 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the
19 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
20 * Boston, MA 02110-1301, USA.
27 #include "my-atk-object.h"
28 #include "my-atk-component.h"
30 typedef struct _MyAtkComponentInfo MyAtkComponentInfo;
32 static void atk_component_interface_init (AtkComponentIface *iface);
34 G_DEFINE_TYPE_WITH_CODE (MyAtkComponent,
37 G_IMPLEMENT_INTERFACE (ATK_TYPE_COMPONENT,
38 atk_component_interface_init));
41 my_atk_component_set_layer (AtkComponent *component,
44 g_return_if_fail (MY_IS_ATK_COMPONENT (component));
46 MyAtkComponent *self = MY_ATK_COMPONENT (component);
51 my_atk_component_set_mdi_zorder (AtkComponent *component,
54 g_return_if_fail (MY_IS_ATK_COMPONENT (component));
56 MyAtkComponent *self = MY_ATK_COMPONENT (component);
57 self->zorder = mdi_zorder;
61 my_atk_component_set_alpha (AtkComponent *component,
65 g_return_if_fail (MY_IS_ATK_COMPONENT (component));
67 MyAtkComponent *self = MY_ATK_COMPONENT (component);
72 my_atk_component_get_extents (AtkComponent *component,
77 AtkCoordType coord_type)
79 g_return_if_fail (MY_IS_ATK_COMPONENT (component));
81 MyAtkComponent *self = MY_ATK_COMPONENT (component);
82 *width = self->extent.width;
83 *height = self->extent.height;
89 my_atk_component_set_extents (AtkComponent *component,
94 AtkCoordType coord_type)
96 g_return_val_if_fail (MY_IS_ATK_COMPONENT (component), FALSE);
98 MyAtkComponent *self = MY_ATK_COMPONENT (component);
100 if (self->extent_may_change) {
101 self->extent.width = width;
102 self->extent.height = height;
111 my_atk_component_contains (AtkComponent *component,
114 AtkCoordType coord_type)
116 g_return_val_if_fail (MY_IS_ATK_COMPONENT (component), FALSE);
119 my_atk_component_get_extents (component, &x, &y, &w, &h, coord_type);
121 if ((c_x >= x) && (c_y >= y) && (c_x < x + w) && (c_y < y + h))
128 my_atk_component_ref_accessible_at_point (AtkComponent *component,
131 AtkCoordType coord_type)
133 g_return_val_if_fail (MY_IS_ATK_COMPONENT (component), NULL);
136 count = atk_object_get_n_accessible_children (ATK_OBJECT (component));
138 for (i = 0; i < count; i++) {
140 obj = atk_object_ref_accessible_child (ATK_OBJECT (component), i);
143 if (atk_component_contains (ATK_COMPONENT (obj), x, y, coord_type))
146 g_object_unref (obj);
153 my_atk_component_grab_focus (AtkComponent *component)
159 my_atk_component_get_layer (AtkComponent *component)
161 g_return_val_if_fail (MY_IS_ATK_COMPONENT (component), -1);
163 return MY_ATK_COMPONENT (component)->layer;
167 my_atk_component_get_mdi_zorder (AtkComponent *component)
169 g_return_val_if_fail (MY_IS_ATK_COMPONENT (component), -1);
171 return MY_ATK_COMPONENT (component)->zorder;
175 my_atk_component_get_alpha (AtkComponent *component)
177 g_return_val_if_fail (MY_IS_ATK_COMPONENT (component), -1);
179 return MY_ATK_COMPONENT (component)->alpha;
183 atk_component_interface_init (AtkComponentIface *iface)
185 g_return_if_fail (iface);
187 iface->add_focus_handler = NULL;
188 iface->contains = my_atk_component_contains;
189 iface->ref_accessible_at_point = my_atk_component_ref_accessible_at_point;
190 iface->get_extents = my_atk_component_get_extents;
191 iface->get_position = NULL;
192 iface->get_size = NULL;
193 iface->grab_focus = my_atk_component_grab_focus;
194 iface->remove_focus_handler = NULL;
195 iface->set_extents = my_atk_component_set_extents;
196 iface->set_position = NULL;
197 iface->set_size = NULL;
198 iface->get_layer = my_atk_component_get_layer;
199 iface->get_mdi_zorder = my_atk_component_get_mdi_zorder;
200 iface->bounds_changed = NULL;
201 iface->get_alpha = my_atk_component_get_alpha;
205 my_atk_component_initialize (AtkObject *obj, gpointer data)
210 my_atk_component_finalize (GObject *object)
215 my_atk_component_init(MyAtkComponent *obj)
219 obj->extent.width = 0;
220 obj->extent.height = 0;
221 obj->extent_may_change = TRUE;
222 obj->layer = ATK_LAYER_BACKGROUND;
228 my_atk_component_class_init (MyAtkComponentClass *my_class)
230 AtkObjectClass *atk_class = ATK_OBJECT_CLASS (my_class);
231 GObjectClass *gobject_class = G_OBJECT_CLASS (my_class);
233 gobject_class->finalize = my_atk_component_finalize;
235 atk_class->initialize = my_atk_component_initialize;