2 * Copyright (c) 2013 Samsung Electronics Co., Ltd.
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public License
15 * along with this library; see the file COPYING.LIB. If not, write to
16 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 * Boston, MA 02110-1301, USA.
21 * @file eail_item_parent.c
22 * @brief Implementation of interface that is used by EailItem implementation
23 * to allow special behavior of wide range item-objects
26 #include "eail_item_parent.h"
29 * @brief Gets GType for initialized interface
31 * @returns GType for initialized interface
34 eail_item_parent_get_type(void)
36 static volatile GType type_id__volatile = 0;
38 if (g_once_init_enter(&type_id__volatile))
40 GType type_id = g_type_register_static_simple(
43 sizeof(EailItemParentIface),
49 g_once_init_leave(&type_id__volatile, type_id);
52 return type_id__volatile;
56 * @brief Gets the name of item
58 * @param parent object that holds EailItem in its content
59 * @param item EailItem instance
61 * @return string representing the name of item or NULL if the name is not available
64 eail_item_parent_get_item_name(EailItemParent *parent,
67 EailItemParentIface *iface;
69 g_return_val_if_fail(EAIL_IS_ITEM_PARENT(parent), NULL);
71 iface = EAIL_ITEM_PARENT_GET_IFACE(parent);
73 if (iface->get_item_name)
74 return iface->get_item_name(parent, item);
80 * @brief Gets the role of item
82 * @param parent object that holds EailItem in its content
83 * @param item EailItem object
85 * @returns AtkRole representing the role of the specified EailItem
88 eail_item_parent_get_item_role(EailItemParent *parent,
91 EailItemParentIface *iface;
93 g_return_val_if_fail(EAIL_IS_ITEM_PARENT(parent), ATK_ROLE_INVALID);
95 iface = EAIL_ITEM_PARENT_GET_IFACE(parent);
97 if (iface->get_item_role)
98 return iface->get_item_role(parent, item);
100 return ATK_OBJECT(item)->role;
104 * @brief Gets the index of item in parent object
106 * @param parent object that holds EailItem in its content
107 * @param item EailItem instance
109 * @returns integer representing the index of item in parent object
112 eail_item_parent_get_item_index_in_parent(EailItemParent *parent,
115 EailItemParentIface *iface;
117 g_return_val_if_fail(EAIL_IS_ITEM_PARENT(parent), -1);
119 iface = EAIL_ITEM_PARENT_GET_IFACE(parent);
121 if (iface->get_item_index_in_parent)
122 return iface->get_item_index_in_parent(parent, item);
128 * @brief Gets the number of accessible children
130 * @param parent object that holds EailItem in its content
131 * @param item EailItem instance
133 * @returns integer representing the number of accessible children or -1 if
137 eail_item_parent_get_n_children(EailItemParent *parent,
140 EailItemParentIface *iface;
142 g_return_val_if_fail(EAIL_IS_ITEM_PARENT(parent), -1);
144 iface = EAIL_ITEM_PARENT_GET_IFACE(parent);
146 if (iface->get_n_children)
147 return iface->get_n_children(parent, item);
153 * @brief Gets a reference to the specified accessible child of the object.
155 * The accessible children are 0-based so the first accessible child
156 * is at index 0, the second at index 1 and so on.
158 * @param parent object that holds EailItem in its content
159 * @param item EailItem instance
160 * @param index gint representing index of child to ref
162 * @returns AtkObject representing the specified accessible child
163 * or NULL if not implemented
166 eail_item_parent_ref_n_child(EailItemParent *parent,
170 EailItemParentIface *iface;
172 g_return_val_if_fail(EAIL_IS_ITEM_PARENT(parent), NULL);
174 iface = EAIL_ITEM_PARENT_GET_IFACE(parent);
176 if (iface->ref_n_child)
177 return iface->ref_n_child(parent, item, index);
183 * @brief Gets a reference to the state set of EailItem
185 * @param parent object that holds EailItem in its content
186 * @param item EailItem instance
187 * @param state_set current state set
189 * @returns AtkStateSet representing the state set of given EailItem
192 eail_item_parent_ref_item_state_set(EailItemParent *parent,
194 AtkStateSet *state_set)
196 EailItemParentIface *iface;
198 g_return_val_if_fail(EAIL_IS_ITEM_PARENT(parent), NULL);
200 iface = EAIL_ITEM_PARENT_GET_IFACE(parent);
202 if (iface->ref_item_state_set)
203 return iface->ref_item_state_set(parent, item, state_set);
209 * @brief Grabs focus of EailItem
211 * @param parent object that holds EailItem in its content
212 * @param item EailItem instance
214 * @returns TRUE on success, FALSE otherwise
217 eail_item_parent_grab_item_focus(EailItemParent *parent,
220 EailItemParentIface *iface;
222 g_return_val_if_fail(EAIL_IS_ITEM_PARENT(parent), FALSE);
224 iface = EAIL_ITEM_PARENT_GET_IFACE(parent);
226 if (iface->grab_item_focus)
227 return iface->grab_item_focus(parent, item);
233 * @brief Gets the rectangle which gives the extent of the component
235 * Implementation of atk_component_get_extents.
237 * @param parent object that holds EailItem in its content
238 * @param item EailItem object
239 * @param [out] x x coordinate
240 * @param [out] y y coordinate
241 * @param [out] width width of the rectangle
242 * @param [out] height height of the rectangle
243 * @param coord_type specifies whether the coordinates are relative to the
244 * screen or to the components top level window
247 eail_item_parent_get_item_extents(EailItemParent *parent,
253 AtkCoordType coord_type)
255 EailItemParentIface *iface;
257 g_return_if_fail(EAIL_IS_ITEM_PARENT(parent));
259 iface = EAIL_ITEM_PARENT_GET_IFACE(parent);
261 if (iface->get_item_extents)
262 iface->get_item_extents(parent, item, x, y, width, height, coord_type);
266 * @brief Gets nested Evas_Object of given EailItem
268 * @param parent object that holds EailItem in its content
269 * @param item EailItem instance
271 * @returns nested Evas_Object representing the given EailItem
273 Evas_Object * eail_item_parent_get_evas_obj(EailItemParent *parent,
276 EailItemParentIface *iface;
278 g_return_val_if_fail(EAIL_IS_ITEM_PARENT(parent), NULL);
280 iface = EAIL_ITEM_PARENT_GET_IFACE(parent);
282 if (iface->get_evas_obj)
283 return iface->get_evas_obj(parent, item);
289 * @brief Gets supported actions
291 * @param parent object that holds EailItem in its content
292 * @param item EailItem instance
294 * @returns integer representing supported actions
297 eail_item_parent_get_actions_supported(EailItemParent *parent,
300 EailItemParentIface *iface;
302 g_return_val_if_fail(EAIL_IS_ITEM_PARENT(parent), FALSE);
304 iface = EAIL_ITEM_PARENT_GET_IFACE(parent);
306 if (iface->get_actions_supported)
307 return iface->get_actions_supported(parent, item);
309 return EAIL_ACTION_SUPPORTED_NONE;
313 * @brief Checks if content get is supported
315 * @param parent object that holds EailItem in its content
316 * @param item EailItem instance
318 * @returns TRUE if content get is supported, FALSE otherwise. Default
319 * implementation returns TRUE (used if no redefinition in EailItemParent
320 * interface implementation is defined)
323 eail_item_parent_is_is_content_get_supported(EailItemParent *parent,
326 EailItemParentIface *iface;
328 g_return_val_if_fail(EAIL_IS_ITEM_PARENT(parent), FALSE);
330 iface = EAIL_ITEM_PARENT_GET_IFACE(parent);
332 if (iface->is_content_get_supported)
333 return iface->is_content_get_supported(parent, item);