fix conflict test_focus.c
[framework/uifw/elementary.git] / src / bin / test_layout.c
1 #include <Elementary.h>
2 #ifdef HAVE_CONFIG_H
3 # include "elementary_config.h"
4 #endif
5 #ifndef ELM_LIB_QUICKLAUNCH
6 #include <Elementary_Cursor.h>
7
8 static void
9 _clicked_cb(void *data, Evas_Object *obj, void *event_info __UNUSED__)
10 {
11    elm_object_part_text_set(data, "text", elm_object_text_get(obj));
12 }
13
14 void
15 test_layout(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
16 {
17    Evas_Object *win, *bg, *box, *ly, *bt;
18    char buf[PATH_MAX];
19
20    win = elm_win_add(NULL, "layout", ELM_WIN_BASIC);
21    elm_win_title_set(win, "Layout");
22    elm_win_autodel_set(win, EINA_TRUE);
23
24    bg = elm_bg_add(win);
25    elm_win_resize_object_add(win, bg);
26    evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
27    evas_object_show(bg);
28
29    box = elm_box_add(win);
30    evas_object_size_hint_weight_set(box, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
31    evas_object_size_hint_align_set(box, EVAS_HINT_FILL, EVAS_HINT_FILL);
32    elm_win_resize_object_add(win, box);
33    evas_object_show(box);
34
35    ly = elm_layout_add(win);
36    elm_layout_theme_set(ly, "layout", "application", "titlebar");
37    elm_object_text_set(ly, "Some title");
38    evas_object_size_hint_weight_set(ly, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
39    evas_object_size_hint_align_set(ly, EVAS_HINT_FILL, EVAS_HINT_FILL);
40    elm_box_pack_end(box, ly);
41    evas_object_show(ly);
42
43    bt = elm_icon_add(win);
44    elm_icon_standard_set(bt, "chat");
45    evas_object_size_hint_min_set(bt, 20, 20);
46    elm_layout_icon_set(ly, bt);
47
48    bt = elm_icon_add(win);
49    elm_icon_standard_set(bt, "close");
50    evas_object_size_hint_min_set(bt, 20, 20);
51    elm_layout_end_set(ly, bt);
52
53    ly = elm_layout_add(win);
54    snprintf(buf, sizeof(buf), "%s/objects/test.edj", elm_app_data_dir_get());
55    elm_layout_file_set(ly, buf, "layout");
56    evas_object_size_hint_weight_set(ly, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
57    elm_box_pack_end(box, ly);
58    //elm_win_resize_object_add(win, ly);
59    evas_object_show(ly);
60
61    bt = elm_button_add(win);
62    elm_object_text_set(bt, "Button 1");
63    elm_object_part_content_set(ly, "element1", bt);
64    evas_object_smart_callback_add(bt, "clicked", _clicked_cb, ly);
65    evas_object_show(bt);
66
67    bt = elm_button_add(win);
68    elm_object_text_set(bt, "Button 2");
69    elm_object_part_content_set(ly, "element2", bt);
70    evas_object_smart_callback_add(bt, "clicked", _clicked_cb, ly);
71    evas_object_show(bt);
72
73    bt = elm_button_add(win);
74    elm_object_text_set(bt, "Button 3");
75    elm_object_part_content_set(ly, "element3", bt);
76    evas_object_smart_callback_add(bt, "clicked", _clicked_cb, ly);
77    evas_object_show(bt);
78
79    elm_layout_part_cursor_set(ly, "text", ELM_CURSOR_WATCH);
80
81    evas_object_show(win);
82 }
83 #endif