bg_example_03.c
//Compile with:
//gcc -o bg_example_03 bg_example_03.c -g `pkg-config --cflags --libs elementary`
//where directory is the a path where images/plant_01.jpg can be found.
#include <Elementary.h>
static void
_cb_radio_changed(void *data, Evas_Object *obj, void *event EINA_UNUSED)
{
Evas_Object *o_bg = data;
elm_bg_option_set(o_bg, elm_radio_value_get((Evas_Object *)obj));
}
static void
_cb_overlay_changed(void *data, Evas_Object *obj, void *event EINA_UNUSED)
{
Evas_Object *o_bg = data;
if (elm_check_state_get(obj))
{
Evas_Object *parent, *over;
char buff[PATH_MAX];
snprintf(buff, sizeof(buff), "%s/objects/test.edj", elm_app_data_dir_get());
parent = elm_object_parent_widget_get(o_bg);
over = edje_object_add(evas_object_evas_get(parent));
edje_object_file_set(over, buff, "bg_overlay");
elm_object_part_content_set(o_bg, "overlay", over);
}
else
elm_object_part_content_set(o_bg, "overlay", NULL);
}
static void
_cb_color_changed(void *data, Evas_Object *obj, void *event EINA_UNUSED)
{
Evas_Object *o_bg = data;
double val = 0.0;
val = elm_spinner_value_get(obj);
if (EINA_DBL_EQ(val, 1.0))
elm_bg_color_set(o_bg, 255, 255, 255);
else if (EINA_DBL_EQ(val, 2.0))
elm_bg_color_set(o_bg, 255, 0, 0);
else if (EINA_DBL_EQ(val, 3.0))
elm_bg_color_set(o_bg, 0, 0, 255);
else if (EINA_DBL_EQ(val, 4.0))
elm_bg_color_set(o_bg, 0, 255, 0);
}
EAPI_MAIN int
elm_main(int argc EINA_UNUSED, char **argv EINA_UNUSED)
{
Evas_Object *win;
Evas_Object *box, *hbox, *o_bg;
Evas_Object *rd, *rdg;
char buf[PATH_MAX];
elm_policy_set(ELM_POLICY_QUIT, ELM_POLICY_QUIT_LAST_WINDOW_CLOSED);
elm_app_info_set(elm_main, "elementary", "objects/test.edj");
win = elm_win_util_standard_add("bg-options", "Bg Options");
elm_win_autodel_set(win, EINA_TRUE);
box = elm_box_add(win);
evas_object_size_hint_weight_set(box, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
elm_win_resize_object_add(win, box);
evas_object_show(box);
o_bg = elm_bg_add(win);
snprintf(buf, sizeof(buf), "%s/images/plant_01.jpg", elm_app_data_dir_get());
elm_bg_file_set(o_bg, buf, NULL);
evas_object_size_hint_weight_set(o_bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
evas_object_size_hint_align_set(o_bg, EVAS_HINT_FILL, EVAS_HINT_FILL);
elm_box_pack_end(box, o_bg);
evas_object_show(o_bg);
hbox = elm_box_add(win);
elm_box_horizontal_set(hbox, EINA_TRUE);
evas_object_size_hint_weight_set(hbox, EVAS_HINT_EXPAND, EVAS_HINT_FILL);
evas_object_size_hint_align_set(hbox, EVAS_HINT_FILL, EVAS_HINT_FILL);
rd = elm_radio_add(win);
elm_radio_state_value_set(rd, ELM_BG_OPTION_CENTER);
elm_object_text_set(rd, "Center");
evas_object_size_hint_weight_set(rd, EVAS_HINT_EXPAND, EVAS_HINT_FILL);
evas_object_smart_callback_add(rd, "changed", _cb_radio_changed, o_bg);
elm_box_pack_end(hbox, rd);
evas_object_show(rd);
rdg = rd;
rd = elm_radio_add(win);
elm_radio_state_value_set(rd, ELM_BG_OPTION_SCALE);
elm_radio_group_add(rd, rdg);
elm_object_text_set(rd, "Scale");
evas_object_size_hint_weight_set(rd, EVAS_HINT_EXPAND, EVAS_HINT_FILL);
evas_object_smart_callback_add(rd, "changed", _cb_radio_changed, o_bg);
elm_box_pack_end(hbox, rd);
evas_object_show(rd);
rd = elm_radio_add(win);
elm_radio_state_value_set(rd, ELM_BG_OPTION_STRETCH);
elm_radio_group_add(rd, rdg);
elm_object_text_set(rd, "Stretch");
evas_object_size_hint_weight_set(rd, EVAS_HINT_EXPAND, EVAS_HINT_FILL);
evas_object_smart_callback_add(rd, "changed", _cb_radio_changed, o_bg);
elm_box_pack_end(hbox, rd);
evas_object_show(rd);
rd = elm_radio_add(win);
elm_radio_state_value_set(rd, ELM_BG_OPTION_TILE);
elm_radio_group_add(rd, rdg);
elm_object_text_set(rd, "Tile");
evas_object_size_hint_weight_set(rd, EVAS_HINT_EXPAND, EVAS_HINT_FILL);
evas_object_smart_callback_add(rd, "changed", _cb_radio_changed, o_bg);
elm_box_pack_end(hbox, rd);
evas_object_show(rd);
elm_radio_value_set(rdg, ELM_BG_OPTION_SCALE);
rd = elm_check_add(win);
elm_object_text_set(rd, "Show Overlay");
evas_object_size_hint_weight_set(rd, EVAS_HINT_EXPAND, EVAS_HINT_FILL);
evas_object_smart_callback_add(rd, "changed", _cb_overlay_changed, o_bg);
elm_box_pack_end(hbox, rd);
evas_object_show(rd);
/* color choices ... this is ghetto, but we don't have a 'colorpicker'
* widget yet :( */
rd = elm_spinner_add(win);
elm_object_style_set(rd, "vertical");
elm_spinner_min_max_set(rd, 1, 4);
elm_spinner_label_format_set(rd, "%.0f");
elm_spinner_editable_set(rd, EINA_FALSE);
elm_spinner_special_value_add(rd, 1, "White");
elm_spinner_special_value_add(rd, 2, "Red");
elm_spinner_special_value_add(rd, 3, "Blue");
elm_spinner_special_value_add(rd, 4, "Green");
evas_object_size_hint_weight_set(rd, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
evas_object_size_hint_align_set(rd, EVAS_HINT_FILL, EVAS_HINT_FILL);
evas_object_smart_callback_add(rd, "changed", _cb_color_changed, o_bg);
elm_box_pack_end(hbox, rd);
evas_object_show(rd);
elm_box_pack_end(box, hbox);
evas_object_show(hbox);
evas_object_resize(win, 460, 320);
evas_object_show(win);
elm_run();
return 0;
}
ELM_MAIN()
EVAS_HINT_EXPAND
#define EVAS_HINT_EXPAND
Use with evas_object_size_hint_weight_set(), evas_object_size_hint_weight_get(), evas_object_size_hin...
Definition Evas_Common.h:297
EVAS_HINT_FILL
#define EVAS_HINT_FILL
Use with evas_object_size_hint_align_set(), evas_object_size_hint_align_get(), evas_object_size_hint_...
Definition Evas_Common.h:298
edje_object_add
Evas_Object * edje_object_add(Evas *evas)
Instantiates a new Edje object.
Definition edje_smart.c:22
edje_object_file_set
Eina_Bool edje_object_file_set(Evas_Object *obj, const char *file, const char *group)
Sets the EDJ file (and group within it) to load an Edje object's contents from.
Definition edje_smart.c:467
EINA_DBL_EQ
#define EINA_DBL_EQ(a, b)
Safe comparison of double.
Definition eina_util.h:100
EINA_TRUE
#define EINA_TRUE
boolean value TRUE (numerical value 1)
Definition eina_types.h:539
EINA_FALSE
#define EINA_FALSE
boolean value FALSE (numerical value 0)
Definition eina_types.h:533
EINA_UNUSED
#define EINA_UNUSED
Used to indicate that a function parameter is purposely unused.
Definition eina_types.h:339
elm_app_info_set
void elm_app_info_set(void *mainfunc, const char *dom, const char *checkfile)
Re-locate the application somewhere else after compilation, if the developer wishes for easier distri...
Definition elm_main.c:496
elm_app_data_dir_get
const char * elm_app_data_dir_get(void)
Get the application's run time data prefix directory, as set by elm_app_info_set() and the way (envir...
Definition elm_main.c:586
elm_bg_file_set
Eina_Bool elm_bg_file_set(Eo *obj, const char *file, const char *group)
Sets the file (image or edje collection) to give life for the background.
Definition efl_ui_bg.c:188
elm_bg_option_set
void elm_bg_option_set(Evas_Object *obj, Elm_Bg_Option option)
Sets the mode of display for a given background widget's image.
Definition efl_ui_bg.c:82
elm_bg_color_set
void elm_bg_color_set(Evas_Object *obj, int r, int g, int b)
Sets the color on a given background widget.
Definition efl_ui_bg.c:138
elm_bg_add
Evas_Object * elm_bg_add(Evas_Object *parent)
Adds a new background to the parent.
Definition efl_ui_bg.c:304
ELM_BG_OPTION_SCALE
@ ELM_BG_OPTION_SCALE
Scale the background image, retaining aspect ratio (default).
Definition elm_bg_legacy.h:13
ELM_BG_OPTION_CENTER
@ ELM_BG_OPTION_CENTER
Center the background image.
Definition elm_bg_legacy.h:12
ELM_BG_OPTION_TILE
@ ELM_BG_OPTION_TILE
Tile background image at its original size.
Definition elm_bg_legacy.h:17
ELM_BG_OPTION_STRETCH
@ ELM_BG_OPTION_STRETCH
Stretch the background image to fill the widget's area.
Definition elm_bg_legacy.h:15
elm_box_horizontal_set
void elm_box_horizontal_set(Elm_Box *obj, Eina_Bool horizontal)
Set the horizontal orientation.
Definition elm_box_eo.legacy.c:27
elm_box_add
Evas_Object * elm_box_add(Evas_Object *parent)
Add a new box to the parent.
Definition elm_box.c:363
elm_box_pack_end
void elm_box_pack_end(Elm_Box *obj, Efl_Canvas_Object *subobj)
Add an object at the end of the pack list.
Definition elm_box_eo.legacy.c:57
elm_check_state_get
Eina_Bool elm_check_state_get(const Evas_Object *obj)
Get the state of the check object.
Definition efl_ui_check.c:381
elm_check_add
Evas_Object * elm_check_add(Evas_Object *parent)
Add a new Check object.
Definition efl_ui_check.c:516
elm_object_part_content_set
void elm_object_part_content_set(Evas_Object *obj, const char *part, Evas_Object *content)
Set the content on part of a given container widget.
Definition elm_main.c:1562
ELM_MAIN
#define ELM_MAIN()
macro to be used after the elm_main() function
Definition elm_general.h:556
elm_policy_set
Eina_Bool elm_policy_set(unsigned int policy, int value)
Set a new policy's value (for a given policy group/identifier).
Definition elm_main.c:1380
elm_run
void elm_run(void)
Run Elementary's main loop.
Definition elm_main.c:1357
ELM_POLICY_QUIT_LAST_WINDOW_CLOSED
@ ELM_POLICY_QUIT_LAST_WINDOW_CLOSED
quit when the application's last window is closed
Definition elm_general.h:248
ELM_POLICY_QUIT
@ ELM_POLICY_QUIT
under which circumstances the application should quit automatically.
Definition elm_general.h:227
elm_radio_add
Evas_Object * elm_radio_add(Evas_Object *parent)
Add a new radio to the parent.
Definition efl_ui_radio.c:401
elm_radio_value_set
void elm_radio_value_set(Evas_Object *obj, int value)
Set the value of the radio group.
Definition efl_ui_radio.c:408
elm_radio_group_add
void elm_radio_group_add(Efl_Ui_Radio *obj, Efl_Ui_Radio *group)
Add this radio to a group of other radio objects.
Definition efl_ui_radio.c:465
elm_radio_value_get
int elm_radio_value_get(const Evas_Object *obj)
Get the value of the radio group.
Definition efl_ui_radio.c:420
elm_radio_state_value_set
void elm_radio_state_value_set(Efl_Ui_Radio *obj, int value)
Set the integer value that this radio object represents.
Definition efl_ui_radio_eo.legacy.c:3
elm_spinner_value_get
double elm_spinner_value_get(const Evas_Object *obj)
Control the value the spinner displays.
Definition elm_spinner.c:1387
elm_spinner_special_value_add
void elm_spinner_special_value_add(Elm_Spinner *obj, double value, const char *label)
Control special string to display in the place of the numerical value.
Definition elm_spinner_eo.legacy.c:75
elm_spinner_add
Evas_Object * elm_spinner_add(Evas_Object *parent)
Add a new spinner widget to the given parent Elementary (container) object.
Definition elm_spinner.c:1350
elm_spinner_label_format_set
void elm_spinner_label_format_set(Elm_Spinner *obj, const char *fmt)
Control the format string of the displayed label.
Definition elm_spinner_eo.legacy.c:63
elm_spinner_editable_set
void elm_spinner_editable_set(Elm_Spinner *obj, Eina_Bool editable)
Control whether the spinner can be directly edited by the user or not.
Definition elm_spinner_eo.legacy.c:39
elm_spinner_min_max_set
void elm_spinner_min_max_set(Evas_Object *obj, double min, double max)
Control the minimum and maximum values for the spinner.
Definition elm_spinner.c:1357
elm_object_style_set
Eina_Bool elm_object_style_set(Evas_Object *obj, const char *style)
Set the style to used by a given widget.
Definition elm_main.c:1583
elm_win_util_standard_add
Evas_Object * elm_win_util_standard_add(const char *name, const char *title)
Adds a window object with standard setup.
Definition efl_ui_win.c:9587
elm_win_resize_object_add
void elm_win_resize_object_add(Eo *obj, Evas_Object *subobj)
Add subobj as a resize object of window obj.
Definition efl_ui_win.c:9002
elm_win_autodel_set
void elm_win_autodel_set(Eo *obj, Eina_Bool autodel)
Set the window's autodel state.
Definition efl_ui_win.c:6199
evas_object_show
EVAS_API void evas_object_show(Evas_Object *eo_obj)
Makes the given Evas object visible.
Definition evas_object_main.c:1814
evas_object_evas_get
EVAS_API Evas * evas_object_evas_get(const Eo *eo_obj)
Get the Evas to which this object belongs to.
Definition evas_object_main.c:2662
evas_object_size_hint_weight_set
EVAS_API void evas_object_size_hint_weight_set(Evas_Object *obj, double x, double y)
Sets the hints for an object's weight.
Definition evas_object_main.c:2638
evas_object_size_hint_align_set
EVAS_API void evas_object_size_hint_align_set(Evas_Object *obj, double x, double y)
Sets the hints for an object's alignment.
Definition evas_object_main.c:2650
Evas_Object
Efl_Canvas_Object Evas_Object
An Evas Object handle.
Definition Evas_Common.h:185
evas_object_resize
EVAS_API void evas_object_resize(Evas_Object *obj, Evas_Coord w, Evas_Coord h)
Changes the size of the given Evas object.
Definition evas_object_main.c:1236
evas_object_smart_callback_add
EVAS_API void evas_object_smart_callback_add(Evas_Object *eo_obj, const char *event, Evas_Smart_Cb func, const void *data)
Add (register) a callback function to the smart event specified by event on the smart object obj.
Definition evas_object_smart.c:1040