29bc2a41fd25c889cb9696ffbaf02b9eae8b0d91
[framework/uifw/elementary.git] / src / bin / test_toolbar.c
1 #include <Elementary.h>
2 #ifndef ELM_LIB_QUICKLAUNCH
3 static void
4 tb_1(void *data, Evas_Object *obj, void *event_info)
5 {
6    char buf[PATH_MAX];
7    snprintf(buf, sizeof(buf), "%s/images/panel_01.jpg", PACKAGE_DATA_DIR);
8    elm_photo_file_set(data, buf);
9 }
10
11 static void
12 tb_2(void *data, Evas_Object *obj, void *event_info)
13 {
14    char buf[PATH_MAX];
15    snprintf(buf, sizeof(buf), "%s/images/rock_01.jpg", PACKAGE_DATA_DIR);
16    elm_photo_file_set(data, buf);
17 }
18
19 static void
20 tb_3(void *data, Evas_Object *obj, void *event_info)
21 {
22    char buf[PATH_MAX];
23    snprintf(buf, sizeof(buf), "%s/images/wood_01.jpg", PACKAGE_DATA_DIR);
24    elm_photo_file_set(data, buf);
25 }
26
27 static void
28 tb_4(void *data, Evas_Object *obj, void *event_info)
29 {
30    char buf[PATH_MAX];
31    snprintf(buf, sizeof(buf), "%s/images/sky_03.jpg", PACKAGE_DATA_DIR);
32    elm_photo_file_set(data, buf);
33 }
34
35 static void
36 tb_5(void *data, Evas_Object *obj, void *event_info)
37 {
38    elm_photo_file_set(data, NULL);
39 }
40
41 void
42 test_toolbar(void *data, Evas_Object *obj, void *event_info)
43 {
44    Evas_Object *win, *bg, *bx, *tb, *ic, *ph, *menu;
45    Evas_Object *ph1, *ph2, *ph3, *ph4;
46    Elm_Toolbar_Item *item;
47    Elm_Menu_Item *menu_item;
48    char buf[PATH_MAX];
49
50    win = elm_win_add(NULL, "toolbar", ELM_WIN_BASIC);
51    elm_win_title_set(win, "Toolbar");
52    elm_win_autodel_set(win, 1);
53
54    bg = elm_bg_add(win);
55    elm_win_resize_object_add(win, bg);
56    evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
57    evas_object_show(bg);
58
59    bx = elm_box_add(win);
60    elm_win_resize_object_add(win, bx);
61    evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
62    evas_object_show(bx);
63
64    tb = elm_toolbar_add(win);
65    elm_toolbar_homogenous_set(tb, 0);
66    evas_object_size_hint_weight_set(tb, 0.0, 0.0);
67    evas_object_size_hint_align_set(tb, EVAS_HINT_FILL, 0.0);
68    
69    ph1 = elm_photo_add(win);
70    ph2 = elm_photo_add(win);
71    ph3 = elm_photo_add(win);
72    ph4 = elm_photo_add(win);
73
74    ic = elm_icon_add(win);
75    snprintf(buf, sizeof(buf), "%s/images/logo_small.png", PACKAGE_DATA_DIR);
76    elm_icon_file_set(ic, buf, NULL);
77    item = elm_toolbar_item_add(tb, ic, "Hello", tb_1, ph1);
78    elm_toolbar_item_disabled_set(item, EINA_TRUE);
79
80    ic = elm_icon_add(win);
81    snprintf(buf, sizeof(buf), "%s/images/logo_small.png", PACKAGE_DATA_DIR);
82    elm_icon_file_set(ic, buf, NULL);
83    elm_toolbar_item_add(tb, ic, "World", tb_2, ph1);
84
85    ic = elm_icon_add(win);
86    snprintf(buf, sizeof(buf), "%s/images/logo_small.png", PACKAGE_DATA_DIR);
87    elm_icon_file_set(ic, buf, NULL);
88    elm_toolbar_item_add(tb, ic, "H", tb_3, ph4);
89
90    ic = elm_icon_add(win);
91    snprintf(buf, sizeof(buf), "%s/images/logo_small.png", PACKAGE_DATA_DIR);
92    elm_icon_file_set(ic, buf, NULL);
93    elm_toolbar_item_add(tb, ic, "Comes", tb_4, ph4);
94
95    ic = elm_icon_add(win);
96    snprintf(buf, sizeof(buf), "%s/images/logo_small.png", PACKAGE_DATA_DIR);
97    elm_icon_file_set(ic, buf, NULL);
98    elm_toolbar_item_add(tb, ic, "Elementary", tb_5, ph4);
99
100    ic = elm_icon_add(win);
101    snprintf(buf, sizeof(buf), "%s/images/logo_small.png", PACKAGE_DATA_DIR);
102    elm_icon_file_set(ic, buf, NULL);
103    item = elm_toolbar_item_add(tb, ic, "Menu", NULL, NULL);
104    elm_toolbar_item_menu_set(item, 1);
105    elm_toolbar_menu_parent_set(tb, win);
106    menu = elm_toolbar_item_menu_get(item);
107  
108    ic = elm_icon_add(win);
109    snprintf(buf, sizeof(buf), "%s/images/logo_small.png", PACKAGE_DATA_DIR);
110    elm_icon_file_set(ic, buf, NULL);
111    elm_menu_item_add(menu, NULL, ic, "Here", tb_3, ph4);
112
113    ic = elm_icon_add(win);
114    snprintf(buf, sizeof(buf), "%s/images/logo_small.png", PACKAGE_DATA_DIR);
115    elm_icon_file_set(ic, buf, NULL);
116    menu_item = elm_menu_item_add(menu, NULL, ic, "Comes", tb_4, ph4);
117
118    ic = elm_icon_add(win);
119    snprintf(buf, sizeof(buf), "%s/images/logo_small.png", PACKAGE_DATA_DIR);
120    elm_icon_file_set(ic, buf, NULL);
121    elm_menu_item_add(menu, menu_item, ic, "hey ho", tb_4, ph4);
122
123    ic = elm_icon_add(win);
124    snprintf(buf, sizeof(buf), "%s/images/logo_small.png", PACKAGE_DATA_DIR);
125    elm_icon_file_set(ic, buf, NULL);
126    menu_item = elm_menu_item_add(menu, NULL, ic, "Elementary", tb_5, ph4);
127
128    elm_box_pack_end(bx, tb);
129    evas_object_show(tb);
130
131    tb = elm_table_add(win);
132    //elm_table_homogenous_set(tb, 1);
133    evas_object_size_hint_weight_set(tb, 0.0, EVAS_HINT_EXPAND);
134    evas_object_size_hint_fill_set(tb, EVAS_HINT_FILL, EVAS_HINT_FILL);
135
136    ph = ph1;
137    elm_photo_size_set(ph, 40);
138    snprintf(buf, sizeof(buf), "%s/images/plant_01.jpg", PACKAGE_DATA_DIR);
139    elm_photo_file_set(ph, buf);
140    evas_object_size_hint_weight_set(ph, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
141    evas_object_size_hint_align_set(ph, 0.5, 0.5);
142    elm_table_pack(tb, ph, 0, 0, 1, 1);
143    evas_object_show(ph);
144
145    ph = ph2;
146    elm_photo_size_set(ph, 80);
147    evas_object_size_hint_weight_set(ph, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
148    evas_object_size_hint_align_set(ph, 0.5, 0.5);
149    elm_table_pack(tb, ph, 1, 0, 1, 1);
150    evas_object_show(ph);
151
152    ph = ph3;
153    elm_photo_size_set(ph, 20);
154    snprintf(buf, sizeof(buf), "%s/images/sky_01.jpg", PACKAGE_DATA_DIR);
155    elm_photo_file_set(ph, buf);
156    evas_object_size_hint_weight_set(ph, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
157    evas_object_size_hint_align_set(ph, 0.5, 0.5);
158    elm_table_pack(tb, ph, 0, 1, 1, 1);
159    evas_object_show(ph);
160
161    ph = ph4;
162    elm_photo_size_set(ph, 60);
163    snprintf(buf, sizeof(buf), "%s/images/sky_02.jpg", PACKAGE_DATA_DIR);
164    elm_photo_file_set(ph, buf);
165    evas_object_size_hint_weight_set(ph, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
166    evas_object_size_hint_align_set(ph, 0.5, 0.5);
167    elm_table_pack(tb, ph, 1, 1, 1, 1);
168    evas_object_show(ph);
169
170    elm_box_pack_end(bx, tb);
171    evas_object_show(tb);
172
173    evas_object_resize(win, 320, 300);
174
175    evas_object_show(win);
176 }
177 #endif