38114295275463c31f310045aa49b0ec0e40b562
[framework/uifw/elementary.git] / src / examples / bg_example_01.c
1 //Compile with:
2 //gcc -g `pkg-config --cflags --libs elementary` bg_example_01.c -o bg_example_01
3
4 #include <Elementary.h>
5 #ifdef HAVE_CONFIG_H
6 # include "elementary_config.h"
7 #else
8 # define __UNUSED__
9 #endif
10
11 static void
12 on_done(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
13 {
14    /* quit the mainloop (elm_run) */
15    elm_exit();
16 }
17
18 int
19 elm_main(int argc __UNUSED__, char **argv __UNUSED__)
20 {
21    Evas_Object *win, *bg;
22
23    win = elm_win_add(NULL, "bg-plain", ELM_WIN_BASIC);
24    elm_win_title_set(win, "Bg Plain");
25    evas_object_smart_callback_add(win, "delete,request", on_done, NULL);
26    elm_win_autodel_set(win, EINA_TRUE);
27
28    bg = elm_bg_add(win);
29    /* allow bg to expand in x & y */
30    evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
31    elm_win_resize_object_add(win, bg);
32    evas_object_show(bg);
33
34    /* set size hints. a minimum size for the bg. this should propagate back
35     * to the window thus limiting its size based off the bg as the bg is one
36     * of the window's resize objects. */
37    evas_object_size_hint_min_set(bg, 160, 160);
38    /* and set a maximum size. not needed very often. normally used together
39     * with evas_object_size_hint_min_set() at the same size to make a
40     * window not resizable */
41    evas_object_size_hint_max_set(bg, 640, 640);
42    /* and now just resize the window to a size you want. normally widgets
43     * will determine the initial size though */
44    evas_object_resize(win, 320, 320);
45    /* and show the window */
46    evas_object_show(win);
47
48    elm_run(); /* and run the program now, starting to handle all
49                * events, etc. */
50    elm_shutdown(); /* clean up and shut down */
51
52    /* exit code */
53    return 0;
54 }
55
56 ELM_MAIN()