tizen 2.3 release
[framework/uifw/elementary.git] / src / examples / button_example_00.c
1 /*
2  * gcc -o button_example_00 button_example_00.c `pkg-config --cflags --libs elementary`
3  */
4 #include <Elementary.h>
5
6 static void
7 on_click(void *data, Evas_Object *obj, void *event_info)
8 {
9    elm_exit();
10 }
11
12 EAPI_MAIN int
13 elm_main(int argc, char **argv)
14 {
15    Evas_Object *win = NULL;
16    Evas_Object *bg  = NULL;
17    Evas_Object *btn = NULL;
18
19    /* Create an win, associate it with a canvas and */
20    /* turn it visible on WM (Window Manager).       */
21    win = elm_win_add(NULL, "Greetings", ELM_WIN_BASIC);
22    elm_win_title_set(win, "Hello, World!");
23    elm_win_autodel_set(win, EINA_TRUE);
24    elm_policy_set(ELM_POLICY_QUIT, ELM_POLICY_QUIT_LAST_WINDOW_CLOSED);
25    evas_object_resize(win, 240, 60);
26    evas_object_show(win);
27
28    /* Create a bg, associate it to an win */
29    /* and turn it visible on WM.          */
30    bg = elm_bg_add(win);
31    evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
32    elm_win_resize_object_add(win, bg);
33    evas_object_show(bg);
34
35    /* Create a btn, associate to a function, associate */
36    /* to win,  give a dimension and position.          */
37    btn = elm_button_add(win);
38    elm_object_text_set(btn, "Good-Bye, World!");
39    evas_object_smart_callback_add(btn, "clicked", on_click, NULL);
40    evas_object_resize(btn, 120, 30);
41    evas_object_move(btn, 60, 15);
42    evas_object_show(btn);
43
44    elm_run();
45    elm_shutdown();
46
47    return 0;
48 }
49 ELM_MAIN()