tizen 2.4 release
[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, *popup, *btn1, *btn2, *btn3, *icon1;
12    char buf[256];
13
14    elm_app_info_set(elm_main, "elementary", "images/logo_small.png");
15    elm_policy_set(ELM_POLICY_QUIT, ELM_POLICY_QUIT_LAST_WINDOW_CLOSED);
16
17    win = elm_win_util_standard_add("popup", "Popup");
18    elm_win_autodel_set(win, EINA_TRUE);
19
20    popup = elm_popup_add(win);
21
22    // Setting popup content-text
23    elm_object_text_set(popup, "This is the Content-Text for popup. The wrap"
24                        "for the content-text is character wrapping");
25    // Setting the wrapping type to character wrapping
26    elm_popup_content_text_wrap_type_set(popup, ELM_WRAP_CHAR);
27
28    // Seting popup title-text
29    elm_object_part_text_set(popup, "title,text", "Title");
30
31    icon1 = elm_icon_add(popup);
32    snprintf(buf, sizeof(buf), "%s/images/logo_small.png", elm_app_data_dir_get());
33    elm_image_file_set(icon1, buf, NULL);
34    //Setting popup title-icon
35    elm_object_part_content_set(popup, "title,icon", icon1);
36
37    // Creating the first action button
38    btn1 = elm_button_add(popup);
39    elm_object_text_set(btn1, "OK");
40
41    // Setting the fist action button
42    elm_object_part_content_set(popup, "button1", btn1);
43    evas_object_smart_callback_add(btn1, "clicked", _response_cb, popup);
44
45    // Creating the second action button
46    btn2 = elm_button_add(popup);
47    elm_object_text_set(btn2, "Cancel");
48
49    // Setting the second action button
50    elm_object_part_content_set(popup, "button2", btn2);
51    evas_object_smart_callback_add(btn2, "clicked", _response_cb, popup);
52
53    btn3 = elm_button_add(popup);
54    elm_object_text_set(btn3, "Close");
55    // Setting this action button
56    elm_object_part_content_set(popup, "button3", btn3);
57    evas_object_smart_callback_add(btn3, "clicked", _response_cb, popup);
58    // Setting the orientation of popup to Top
59    elm_popup_orient_set(popup, ELM_POPUP_ORIENT_TOP);
60    // Display the popup object
61    evas_object_show(popup);
62
63    evas_object_resize(win, 480, 800);
64    evas_object_show(win);
65
66    elm_run();
67
68    return 0;
69 }
70 ELM_MAIN()
71
72 static void
73 _response_cb(void *data, Evas_Object *obj,
74              void *event_info)
75 {
76    evas_object_del(data);
77 }