[access] support elm_access_action(); with ELM_ACCESS_ACTION_UNHIGHLIGHT
[framework/uifw/elementary.git] / src / examples / popup_example_02.c
1 //Compile with:
2 //gcc -o popup_example_02 popup_example_02.c -g `pkg-config --cflags --libs elementary`
3
4 #include <Elementary.h>
5
6 static void _response_cb(void *data, Evas_Object *obj, void *event_info);
7
8 EAPI_MAIN int
9 elm_main(int argc, char **argv)
10 {
11    Evas_Object *win, *bg, *popup, *btn1, *btn2, *btn3, *icon1;
12    char buf[256];
13
14    elm_app_info_set(elm_main, "elementary", "images/logo_small.png");
15    win = elm_win_add(NULL, "popup", ELM_WIN_BASIC);
16    elm_win_title_set(win, "Popup");
17    elm_win_autodel_set(win, EINA_TRUE);
18    elm_policy_set(ELM_POLICY_QUIT, ELM_POLICY_QUIT_LAST_WINDOW_CLOSED);
19
20    bg = elm_bg_add(win);
21    evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
22    elm_win_resize_object_add(win, bg);
23    evas_object_show(bg);
24
25    popup = elm_popup_add(win);
26
27    // Setting popup content-text
28    elm_object_text_set(popup, "This is the Content-Text for popup. The wrap"
29             "for the content-text is character wrapping");
30    // Setting the wrapping type to character wrapping
31    elm_popup_content_text_wrap_type_set(popup, ELM_WRAP_CHAR);
32
33    // Seting popup title-text
34    elm_object_part_text_set(popup, "title,text", "Title");
35
36    icon1 = elm_icon_add(popup);
37    snprintf(buf, sizeof(buf), "%s/images/logo_small.png", elm_app_data_dir_get());
38    elm_image_file_set(icon1, buf, NULL);
39    //Setting popup title-icon
40    elm_object_part_content_set(popup, "title,icon", icon1);
41
42    // Creating the first action button
43    btn1 = elm_button_add(popup);
44    elm_object_text_set(btn1, "OK");
45
46    // Setting the fist action button
47    elm_object_part_content_set(popup, "button1", btn1);
48    evas_object_smart_callback_add(btn1, "clicked", _response_cb, popup);
49
50    // Creating the second action button
51    btn2 = elm_button_add(popup);
52    elm_object_text_set(btn2, "Cancel");
53
54    // Setting the second action button
55    elm_object_part_content_set(popup, "button2", btn2);
56    evas_object_smart_callback_add(btn2, "clicked", _response_cb, popup);
57
58    btn3 = elm_button_add(popup);
59    elm_object_text_set(btn3, "Close");
60    // Setting this action button
61    elm_object_part_content_set(popup, "button3", btn3);
62    // Setting the orientation of popup to Top
63    elm_popup_orient_set(popup, ELM_POPUP_ORIENT_TOP);
64    // Display the popup object
65    evas_object_show(popup);
66
67    evas_object_resize(win, 480, 800);
68    evas_object_show(win);
69
70    elm_run();
71    elm_shutdown();
72
73    return 0;
74 }
75 ELM_MAIN()
76
77 static void
78 _response_cb(void *data, Evas_Object *obj,
79              void *event_info)
80 {
81    evas_object_del(data);
82 }
83