eail_app.h \
eail_widget.c \
eail_widget.h \
+ eail_custom_widget.c \
+ eail_custom_widget.h \
eail_action_widget.c \
eail_action_widget.h \
eail_scrollable_widget.c \
eail_factory.h \
eail_app.h \
eail_widget.h \
+ eail_custom_widget.h \
eail_action_widget.h \
eail_scrollable_widget.h \
eail_window.h \
--- /dev/null
+ /*
+ * Copyright (c) 2013 Samsung Electronics Co., Ltd.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+/**
+ * @file eail_custom_widget.c
+ * @brief EailCustomWidget implementation
+ */
+
+#include <Ecore.h>
+#include <Ecore_Evas.h>
+#include <Elementary.h>
+
+#include "eail_custom_widget.h"
+#include "eail_factory.h"
+#include "eail_utils.h"
+#include "eail_priv.h"
+
+/**
+ * @brief EailCustomWidget type definition
+ */
+
+G_DEFINE_TYPE(EailCustomWidget, eail_custom_widget, EAIL_TYPE_WIDGET);
+
+AtkObject *
+eail_custom_widget_create(Evas_Object *widget)
+{
+ AtkObject *accessible = NULL;
+ if (!widget)
+ {
+ ERR("Cannot create accessible for NULL-widget");
+ return NULL;
+ }
+ accessible = g_object_new(EAIL_TYPE_CUSTOM_WIDGET, NULL);
+ if (accessible) {
+ atk_object_initialize(accessible, widget);
+
+ return accessible;
+ }
+
+ DBG("No atk obj created");
+ return accessible;
+}
+
+/**
+ * @brief Destroyed event handler for customwidget
+ *
+ * @param data passed to callback
+ * @param obj object that raised event
+ * @param event_info additional event info
+ */
+
+void
+eail_custom_widget_handle_delete_event(void *data, Evas *e, Evas_Object *obj, void *event_info)
+{
+ g_return_if_fail(ATK_IS_OBJECT(data));
+ AtkObject *parent = atk_object_get_parent(ATK_OBJECT(data));
+ EailWidget *widget = EAIL_WIDGET(parent);
+ g_return_if_fail(EAIL_IS_WIDGET(data));
+
+ widget->custom_children = eina_list_remove(widget->custom_children, ATK_OBJECT(data));
+
+ DBG("delete event\n");
+ atk_object_notify_state_change(ATK_OBJECT(data), ATK_STATE_DEFUNCT, TRUE);
+ eail_emit_atk_signal(ATK_OBJECT(data), "visible-data-changed", EAIL_TYPE_CUSTOM_WIDGET);
+}
+
+void
+eail_custom_widget_on_focused_in(void *data, Evas *e, Evas_Object *obj, void *event_info)
+{
+ g_return_if_fail(ATK_IS_OBJECT(data));
+ DBG("focus in on custom widget\n");
+ atk_object_notify_state_change(ATK_OBJECT(data), ATK_STATE_FOCUSED, TRUE);
+}
+
+void
+eail_custom_widget_on_focused_out(void *data, Evas *e, Evas_Object *obj, void *event_info)
+{
+ g_return_if_fail(ATK_IS_OBJECT(data));
+ DBG("focus out from custom widget\n");
+ atk_object_notify_state_change(ATK_OBJECT(data), ATK_STATE_FOCUSED, FALSE);
+}
+
+static void
+eail_custom_widget_initialize(AtkObject *obj, gpointer data)
+{
+ ATK_OBJECT_CLASS(eail_custom_widget_parent_class)->initialize(obj, data);
+
+ if (!data) {
+ ERR("No evas object inside EailCustomWidget was found");
+ return;
+ }
+
+ evas_object_event_callback_add ((Evas_Object *)data, EVAS_CALLBACK_DEL, eail_custom_widget_handle_delete_event, obj);
+ evas_object_event_callback_add ((Evas_Object *)data, EVAS_CALLBACK_FOCUS_IN , eail_custom_widget_on_focused_in, obj);
+ evas_object_event_callback_add ((Evas_Object *)data, EVAS_CALLBACK_FOCUS_OUT, eail_custom_widget_on_focused_out, obj);
+
+}
+
+/**
+ * @brief EailCustomWidget instance initializer
+ *
+ * @param widget EailCustomWidget instance
+ */
+static void
+eail_custom_widget_init(EailCustomWidget *widget)
+{
+}
+
+/**
+ * @brief EailCustomWidget class initializer
+ *
+ * Function called upon instance creation. It initializes AtkObject class
+ * callbacks for EailCustomWidget.
+ *
+ * @param klass EailCustomWidgetClass instance
+ */
+static void
+eail_custom_widget_class_init(EailCustomWidgetClass *klass)
+{
+ AtkObjectClass *atk_class = ATK_OBJECT_CLASS(klass);
+ atk_class->initialize = eail_custom_widget_initialize;
+}
+
--- /dev/null
+/*
+ * Copyright (c) 2013 Samsung Electronics Co., Ltd.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+/**
+ * @file eail_custom_widget.h
+ *
+ * @brief Header for EailCustomWidget implementation
+ */
+
+#ifndef EAIL_CUSTOM_WIDGET_H
+#define EAIL_CUSTOM_WIDGET_H
+
+#include "eail_widget.h"
+
+/**
+ * @brief Returns a value corresponding to the type of EailCustomWidget class
+ */
+#define EAIL_TYPE_CUSTOM_WIDGET (eail_custom_widget_get_type())
+
+/**
+ * @brief Macro upcasts an instance (obj) of a subclass to the EailCustomWidget
+ * type
+ *
+ * @param obj AtkObject instance
+ */
+#define EAIL_CUSTOM_WIDGET(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), \
+ EAIL_TYPE_CUSTOM_WIDGET, EailCustomWidget))
+
+/**
+ * @brief Macro upcasts a subclass (klass) to the EailCustomWidget class
+ *
+ * @param klass subclass object
+ */
+#define EAIL_CUSTOM_WIDGET_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), \
+ EAIL_TYPE_CUSTOM_WIDGET, EailCustomWidgetClass))
+
+/**
+ * @brief Tests whether object (obj) is an instance of EailCustomWidget class
+ *
+ * @param obj AtkObject instance
+ */
+#define EAIL_IS_CUSTOM_WIDGET(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), \
+ EAIL_TYPE_CUSTOM_WIDGET))
+
+/**
+ * @brief Tests whether given klass is a subclass of EailCustomWidget
+ *
+ * @param klass klass object
+ */
+#define EAIL_IS_CUSTOM_WIDGET_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), \
+ EAIL_TYPE_CUSTOM_WIDGET))
+
+/**
+ * @brief Gets EailCustomWidget class structure from an obj (class instance)
+ *
+ * @param obj object instance to get EailCustomWidget class from
+ */
+#define EAIL_CUSTOM_WIDGET_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), \
+ EAIL_TYPE_CUSTOM_WIDGET, EailCustomWidgetClass))
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/** @brief Definition of object structure for Atk EailCustomWidget*/
+typedef struct _EailCustomWidget EailCustomWidget;
+
+/** @brief Definition of object class for Atk EailCustomWidget*/
+typedef struct _EailCustomWidgetClass EailCustomWidgetClass;
+
+/** @brief Definition of object structure for Atk EailCustomWidget*/
+struct _EailCustomWidget
+{
+ EailWidget parent;/**< @brief Parent AtkObject whose functionality is being extended*/
+};
+
+/** @brief Definition of object class for Atk EailCustomWidget*/
+struct _EailCustomWidgetClass
+{
+ EailWidgetClass parent_class;/**< @brief class that is being extended*/
+
+ /** @brief callback definition for eail_widget_get_widget_children func*/
+ Eina_List * (*get_custom_widget_children) (EailCustomWidget *widget);
+};
+
+/**
+ * @brief Getter for widget GType
+ *
+ * @returns GType for EailCustomWidget implementation
+ */
+GType eail_custom_widget_get_type (void);
+AtkObject * eail_custom_widget_create (Evas_Object *widget);
+Evas_Object * eail_custom_widget_get_widget(EailCustomWidget *widget);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
atk_component_interface_init));
/**
- * @brief Gets Evas_Object from EailWidget
+ * @brief Add custom widget to given parent object
*
- * @param widget EailWidget instance
- * @return Evas_Object widget representing the EailWidget
+ * @param parent parent object instance
+ * @param custom_widget parent object instance
+ * @return Eina_Bool result of the operation
+ */
+
+Eina_Bool
+eail_widget_add_custom_widget_child(AtkObject *parent, AtkObject *custom_widget)
+{
+ if (!custom_widget || !parent)
+ return EINA_FALSE;
+
+ EailWidget *widget = EAIL_WIDGET(parent);
+
+ if (!widget)
+ return EINA_FALSE;
+
+ widget->custom_children = eina_list_append(widget->custom_children, custom_widget);
+
+ atk_object_set_parent(custom_widget, parent);
+ eail_emit_children_changed_obj(TRUE, parent, custom_widget);
+
+ return EINA_TRUE;
+}
+
+/**
+ * @brief deletes all cutom widgets from given parent widget
+ *
+ * @param widget parent widget instance
+ * @return Eina_Bool result of the operation
+ */
+
+Eina_Bool
+eail_widget_del_custom_widgets(AtkObject *parent) {
+
+ if (!parent)
+ return EINA_FALSE;
+
+ EailWidget *widget = EAIL_WIDGET(parent);
+
+ if (!widget)
+ return EINA_FALSE;
+
+ const Eina_List *l = NULL;
+ AtkObject *cw = NULL;
+ int i=0;
+
+ EINA_LIST_FOREACH(widget->custom_children, l, cw)
+ {
+ eail_emit_children_changed(FALSE, parent, i);
+ atk_object_set_parent(cw, NULL);
+ g_object_unref(cw);
+ ++i;
+ }
+
+ eina_list_free(widget->custom_children);
+ return EINA_TRUE;
+}
+
+/**
+ * @brief gets evas_object from eailwidget
+ *
+ * @param widget eailwidget instance
+ * @return evas_object widget representing the eailwidget
*/
Evas_Object *
eail_widget_get_widget(EailWidget *widget)
}
/**
+ * @brief Gets EailWidget's custom children
+ *
+ * @param widget EailWidget instance
+ * @return Eina_List representing the EailWidget's custom children list
+ */
+Eina_List *
+eail_widget_get_widget_custom_children(EailWidget *widget)
+{
+ return widget->custom_children;
+}
+
+/**
* @brief Gets EailWidget's children
*
* @param widget EailWidget instance
eail_widget_on_bounds_change, widget);
evas_object_event_callback_add(widget->widget, EVAS_CALLBACK_MOVE,
eail_widget_on_bounds_change, widget);
+
+ if (elm_object_widget_check(widget->widget)) {
+
/* for window don't need that event, it would result double generating
* focus-in event*/
- if (!ATK_IS_WINDOW(obj))
- evas_object_smart_callback_add
- (widget->widget, "focused", eail_widget_on_focused_smart, widget);
-
- evas_object_smart_callback_add
- (widget->widget, "unfocused", eail_widget_on_focused_out_smart, widget);
+ if (!ATK_IS_WINDOW(obj))
+ evas_object_smart_callback_add
+ (widget->widget, "focused", eail_widget_on_focused_smart, widget);
+ evas_object_smart_callback_add
+ (widget->widget, "unfocused", eail_widget_on_focused_out_smart, widget);
+ }
}
/**
static gint
eail_widget_get_n_children(AtkObject *obj)
{
- gint n_children;
+ gint n_children, c_n_children;
Eina_List *children;
children = eail_widget_get_widget_children(EAIL_WIDGET(obj));
n_children = eina_list_count(children);
+ EailWidget *c = EAIL_WIDGET(obj);
+ c_n_children = eina_list_count(c->custom_children);
+
eina_list_free(children);
- return n_children;
+ return n_children+c_n_children;
}
/**
{
Eina_List *children;
AtkObject *child = NULL;
+ EailWidget *c = EAIL_WIDGET(obj);
+ g_return_val_if_fail(EAIL_IS_WIDGET(c), NULL);
children = eail_widget_get_widget_children(EAIL_WIDGET(obj));
+ unsigned int schild = eina_list_count(children);
+
if (eina_list_count(children) > i) {
child = eail_factory_get_accessible(eina_list_nth(children, i));
g_object_ref(child);
+ return child;
}
-
eina_list_free(children);
- return child;
+ if (eina_list_count(c->custom_children) > 0) {
+ child = eina_list_nth(c->custom_children, i-schild);
+ g_object_ref(child);
+ return child;
+ }
+
+ return NULL;
+
}
/**
static gint
eail_widget_get_index_in_parent(AtkObject *obj)
{
- gint index;
- Eina_List *l, *children;
- AtkObject *parent;
- Evas_Object *child;
- Evas_Object *widget = eail_widget_get_widget(EAIL_WIDGET(obj));
-
- if (!widget) {
- return -1;
- }
+ gint index = -1;
+ Eina_List *l, *children, *custom_c;
+ Evas_Object *child = NULL;
+ AtkObject *cchild = NULL;
+ AtkObject *parent = NULL;
+ Evas_Object *widget = NULL;
if (obj->accessible_parent)
- {
parent = obj->accessible_parent;
- } else {
+ else
parent = atk_object_get_parent(obj);
- }
- if (!parent) {
- return -1;
- }
+ g_return_val_if_fail(parent, -1);
- index = -1;
children = eail_widget_get_widget_children(EAIL_WIDGET(parent));
- EINA_LIST_FOREACH(children, l, child) {
+ custom_c = eail_widget_get_widget_custom_children(EAIL_WIDGET(parent));
+ unsigned int schild = eina_list_count(children);
+
+ child = eail_widget_get_widget(EAIL_WIDGET(obj));
+ if (elm_object_widget_check(child)) {
+ EINA_LIST_FOREACH(children, l, widget) {
+ ++index;
+ if (child == widget)
+ break;
+ }
+ return index;
+ }
+ index += schild;
+ EINA_LIST_FOREACH(custom_c, l, cchild) {
++index;
- if (child == widget) {
+ if (cchild == obj)
break;
- }
}
-
- eina_list_free(children);
-
return index;
}
AtkStateSet *state_set;
Evas_Object *widget = eail_widget_get_widget(EAIL_WIDGET(obj));
- state_set= ATK_OBJECT_CLASS(eail_widget_parent_class)->ref_state_set(obj);
+ state_set = ATK_OBJECT_CLASS(eail_widget_parent_class)->ref_state_set(obj);
return eail_evas_obj_ref_state_set(widget, state_set);
}
Evas_Object *widget;/**< @brief Internal widget that is represented by EailWidget */
AtkLayer layer;/**< @brief Describes layer of a component (eg. ATK_LAYER_WIDGET) */
+ Eina_List *custom_children;
};
/** @brief Definition of object class for Atk EailWidget*/
*
* @returns GType for EailWidget implementation
*/
-GType eail_widget_get_type (void);
-Evas_Object * eail_widget_get_widget (EailWidget *widget);
-Eina_List * eail_widget_get_widget_children (EailWidget *widget);
-
+GType eail_widget_get_type (void);
+Evas_Object * eail_widget_get_widget (EailWidget *widget);
+Eina_List * eail_widget_get_widget_children (EailWidget *widget);
+Eina_Bool eail_widget_add_custom_widget_child (AtkObject *parent,
+ AtkObject *custom_widget);
+Eina_Bool eail_widget_del_custom_widgets (AtkObject *parent);
+Eina_List * eail_widget_get_widget_custom_children (EailWidget *widget);
#ifdef __cplusplus
}
#endif
%setup -q
%build
-(if ! test -x configure; then ./autogen.sh; fi;
- %configure )
+%autogen
+%configure
make %{?_smp_mflags}
%install
eail_label_tc2 \
eail_slider_tc1 \
eail_slider_tc2 \
- eail_prefs_tc1 \
eail_background_tc1 \
eail_background_tc2 \
eail_table_tc1 \
eail_photo_tc3 \
eail_photocam_tc1 \
eail_photocam_tc2 \
- eail_photocam_tc3
+ eail_photocam_tc3 \
+ eail_custom_widgets_tc1
TESTS = $(check_PROGRAMS)
eail_datetime_tc2_CFLAGS = $(test_cflags)
eail_datetime_tc2_LDADD = $(test_libs)
-
eail_panel_tc1_SOURCES = eail_panel_tc1.c
eail_panel_tc1_CFLAGS = $(test_cflags)
eail_panel_tc1_LDADD = $(test_libs)
eail_photocam_tc3_CFLAGS = $(test_cflags)
eail_photocam_tc3_LDADD = $(test_libs)
+eail_custom_widgets_tc1_SOURCES = eail_custom_widgets_tc1.c
+eail_custom_widgets_tc1_CFLAGS = $(test_cflags) -I$(top_builddir)/eail/
+eail_custom_widgets_tc1_LDADD = $(test_libs) $(top_builddir)/eail/libeail.la
+
libeail_test_utils_la_SOURCES = eail_test_utils.c eail_test_utils.h
libeail_test_utils_la_CFLAGS = $(TEST_DEPS_CFLAGS)
libeail_test_utils_la_LIBADD = $(TEST_DEPS_LIBS)
--- /dev/null
+/*
+ * Tested interface:
+ *
+ * Tested AtkObject:
+ *
+ * Description:
+ *
+ * Test input:
+ *
+ * Expected test result:
+ */
+
+#include <Elementary.h>
+#include <atk/atk.h>
+
+#include "eail_custom_widget.h"
+#include "eail_factory.h"
+#include "eail_widget.h"
+#include "eail_test_utils.h"
+
+INIT_TEST("EailCustomWidget")
+
+static void
+_init_custom_widget(Evas_Object *win)
+{
+ Evas_Object *bg, *rectangle;
+ AtkObject *ao, *wgt;
+
+ bg = elm_bg_add(win);
+ if(!bg) return;
+ evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+ elm_win_resize_object_add(win, bg);
+ evas_object_show(bg);
+
+ Evas_Object *label = elm_label_add(win);
+ if(!label) return;
+ elm_object_text_set(label, "This is the CONTENT");
+ evas_object_show(label);
+
+ rectangle = evas_object_rectangle_add(evas_object_evas_get(win));
+ evas_object_resize(rectangle, 10, 10);
+ evas_object_show(rectangle);
+
+ ao = eail_custom_widget_create(rectangle);
+
+ g_assert(ao);
+
+ wgt = eail_factory_get_accessible(label);
+ eail_widget_add_custom_widget_child(wgt, ao);
+
+ g_assert(1 == atk_object_get_n_accessible_children(wgt));
+ g_assert(wgt == atk_object_get_parent(ao));
+
+ g_assert(0 == atk_object_get_index_in_parent(ao));
+
+ evas_object_del(rectangle);
+
+ g_assert(0 == atk_object_get_n_accessible_children(wgt));
+
+}
+
+static void
+_do_test(AtkObject *obj)
+{
+ eailu_test_code_called = 1;
+}
+
+EAPI_MAIN int
+elm_main(int argc, char **argv)
+{
+ Evas_Object *win;
+
+ win = eailu_create_test_window_with_glib_init(_on_done, _on_focus_in);
+ g_assert(win);
+ _init_custom_widget(win);
+ evas_object_show(win);
+ elm_run();
+ elm_shutdown();
+
+ return 0;
+}
+ELM_MAIN()
+