aboutsummaryrefslogtreecommitdiffstats
path: root/legacy/elementary/src/bin/test_layout.c
diff options
context:
space:
mode:
authorcnook <kimcinoo@gmail.com>2012-03-19 06:57:39 +0000
committerCarsten Haitzler <raster@rasterman.com>2012-03-19 06:57:39 +0000
commit6468430ffa800fb98df576fd8398945d225426e2 (patch)
treef930e2a6d5e94bbd28638274c011823ed00186f7 /legacy/elementary/src/bin/test_layout.c
parentelementary/test_gengrid : fix a bug :) (diff)
downloadefl-6468430ffa800fb98df576fd8398945d225426e2.tar.gz
From: cnook <kimcinoo@gmail.com>
Subject: [E-devel] [Patch][elementary_test] test_layout I have attached a patch for test_layout. Please review this and give any feedbacks. Thanks. SVN revision: 69501
Diffstat (limited to 'legacy/elementary/src/bin/test_layout.c')
-rw-r--r--legacy/elementary/src/bin/test_layout.c180
1 files changed, 180 insertions, 0 deletions
diff --git a/legacy/elementary/src/bin/test_layout.c b/legacy/elementary/src/bin/test_layout.c
index b4720eba85..8b5248d6c7 100644
--- a/legacy/elementary/src/bin/test_layout.c
+++ b/legacy/elementary/src/bin/test_layout.c
@@ -5,6 +5,29 @@
#ifndef ELM_LIB_QUICKLAUNCH
#include <Elementary_Cursor.h>
+struct _api_data
+{
+ unsigned int state; /* What state we are testing */
+ Evas_Object *box_layout;
+ Evas_Object *table_layout;
+ Evas_Object *ref;
+ Evas_Object *ref2;
+};
+typedef struct _api_data api_data;
+
+enum _api_state
+{
+ LAYOUT_BOX_INSERT_AT,
+ LAYOUT_BOX_INSERT_BEFORE,
+ LAYOUT_BOX_PREPEND,
+ LAYOUT_BOX_REMOVE,
+ LAYOUT_BOX_REMOVE_ALL,
+ LAYOUT_TABLE_UNPACK,
+ LAYOUT_TABLE_CLEAR,
+ API_STATE_LAST
+};
+
+typedef enum _api_state api_state;
static void
_clicked_cb(void *data, Evas_Object *obj, void *event_info __UNUSED__)
{
@@ -80,4 +103,161 @@ test_layout(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info
evas_object_show(win);
}
+
+static void
+set_api_state(api_data *api)
+{
+ Evas_Object *box_layout = api->box_layout;
+ Evas_Object *table_layout = api->table_layout;
+ Evas_Object *obj;
+
+ /* use elm_box_children_get() to get list of children */
+ switch (api->state)
+ { /* Put all api-changes under switch */
+ case LAYOUT_BOX_INSERT_AT:
+ {
+ obj = elm_label_add(box_layout);
+ elm_object_text_set(obj, "elm_layout_box_insert_at(); is called");
+ evas_object_size_hint_weight_set(obj, EVAS_HINT_EXPAND,
+ EVAS_HINT_EXPAND);
+ elm_layout_box_insert_at(box_layout, "elm.box.content", obj, 0);
+ evas_object_show(obj);
+ break;
+ }
+
+ case LAYOUT_BOX_INSERT_BEFORE:
+ {
+ obj = elm_label_add(box_layout);
+ elm_object_text_set(obj, "elm_layout_box_insert_before(); is called");
+ evas_object_size_hint_weight_set(obj, EVAS_HINT_EXPAND,
+ EVAS_HINT_EXPAND);
+ elm_layout_box_insert_before(box_layout, "elm.box.content",
+ obj, api->ref);
+ evas_object_show(obj);
+ break;
+ }
+
+ case LAYOUT_BOX_PREPEND:
+ {
+ obj = elm_label_add(box_layout);
+ elm_object_text_set(obj, "elm_layout_box_prepend(); is called");
+ evas_object_size_hint_weight_set(obj, EVAS_HINT_EXPAND,
+ EVAS_HINT_EXPAND);
+ elm_layout_box_prepend(box_layout, "elm.box.content", obj);
+ evas_object_show(obj);
+ break;
+ }
+
+ case LAYOUT_BOX_REMOVE:
+ {
+ elm_layout_box_remove(box_layout, "elm.box.content", api->ref);
+ evas_object_del(api->ref);
+ break;
+ }
+
+ case LAYOUT_BOX_REMOVE_ALL:
+ {
+ elm_layout_box_remove_all(box_layout, "elm.box.content", EINA_TRUE);
+ break;
+ }
+
+ case LAYOUT_TABLE_UNPACK:
+ {
+ elm_layout_table_unpack(table_layout, "elm.table.content", api->ref2);
+ evas_object_del(api->ref2);
+ break;
+ }
+
+ case LAYOUT_TABLE_CLEAR:
+ {
+ elm_layout_table_clear(table_layout, "elm.table.content", EINA_TRUE);
+ break;
+ }
+
+ default: return;
+ }
+}
+
+static void
+_api_bt_clicked(void *data, Evas_Object *obj, void *event_info __UNUSED__)
+{ /* Will add here a SWITCH command containing code to modify test-object */
+ /* in accordance a->state value. */
+ api_data *a = data;
+ char str[128];
+
+ printf("clicked event on API Button: api_state=<%d>\n", a->state);
+ set_api_state(a);
+ a->state++;
+ sprintf(str, "Next API function (%u)", a->state);
+ elm_object_text_set(obj, str);
+ elm_object_disabled_set(obj, a->state == API_STATE_LAST);
+}
+
+static void
+_cleanup_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
+{
+ free(data);
+}
+
+void
+test_layout2(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
+{
+ Evas_Object *win, *box, *bt, *ly, *lb;
+ api_data *api = calloc(1, sizeof(api_data));
+
+ win = elm_win_util_standard_add("layout2", "Layout 2");
+ elm_win_autodel_set(win, EINA_TRUE);
+ evas_object_event_callback_add(win, EVAS_CALLBACK_FREE, _cleanup_cb, api);
+
+ box = elm_box_add(win);
+ evas_object_size_hint_weight_set(box, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+ elm_win_resize_object_add(win, box);
+ evas_object_show(box);
+
+ bt = elm_button_add(win);
+ elm_object_text_set(bt, "Next API function");
+ evas_object_smart_callback_add(bt, "clicked", _api_bt_clicked,
+ (void *)api);
+ elm_box_pack_end(box, bt);
+ elm_object_disabled_set(bt, api->state == API_STATE_LAST);
+ evas_object_show(bt);
+
+ /* Layout Box Test */
+ api->box_layout = ly = elm_layout_add(win);
+ elm_layout_theme_set(ly, "layout", "application", "toolbar-vbox");
+ evas_object_size_hint_weight_set(ly, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+ evas_object_size_hint_align_set(ly, EVAS_HINT_FILL, EVAS_HINT_FILL);
+ elm_box_pack_end(box, ly);
+ evas_object_show(ly);
+
+ api->ref = lb = elm_label_add(win);
+ elm_object_text_set(lb, "This is a label for the box content");
+ evas_object_size_hint_weight_set(lb, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+ evas_object_show(lb);
+
+ elm_layout_box_append(ly, "elm.box.content", lb);
+
+ /* Layout Table Test */
+ api->table_layout = ly = elm_layout_add(win);
+ elm_layout_theme_set(ly, "layout", "application", "toolbar-table");
+ evas_object_size_hint_weight_set(ly, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+ evas_object_size_hint_align_set(ly, EVAS_HINT_FILL, EVAS_HINT_FILL);
+ elm_box_pack_end(box, ly);
+ evas_object_show(ly);
+
+ lb = elm_label_add(win);
+ elm_object_text_set(lb, "This is a label for the table content");
+ evas_object_size_hint_weight_set(lb, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+ evas_object_show(lb);
+ elm_layout_table_pack(ly, "elm.table.content", lb, 0, 0, 1, 1);
+
+ api->ref2 = lb = elm_label_add(win);
+ elm_object_text_set(lb, "col = 0, row = 1");
+ evas_object_size_hint_weight_set(lb, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+ evas_object_show(lb);
+ elm_layout_table_pack(ly, "elm.table.content", lb, 0, 1, 1, 1);
+
+ evas_object_resize(win, 320, 320);
+ evas_object_show(win);
+}
#endif