2 # include "elementary_config.h"
4 #include <Elementary.h>
5 #ifndef ELM_LIB_QUICKLAUNCH
16 test_label(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
18 Evas_Object *win, *bx, *lb;
20 win = elm_win_util_standard_add("label", "Label");
21 elm_win_autodel_set(win, EINA_TRUE);
23 bx = elm_box_add(win);
24 evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
25 evas_object_size_hint_align_set(bx, EVAS_HINT_FILL, EVAS_HINT_FILL);
27 lb = elm_label_add(win);
28 elm_object_text_set(lb,
29 "<b>This is a small label</b>"
31 evas_object_size_hint_weight_set(lb, 0.0, 0.0);
32 evas_object_size_hint_align_set(lb, EVAS_HINT_FILL, EVAS_HINT_FILL);
33 elm_box_pack_end(bx, lb);
36 lb = elm_label_add(win);
37 elm_object_text_set(lb,
38 "This is a larger label with newlines<br/>"
39 "to make it bigger, bit it won't expand or wrap<br/>"
40 "just be a block of text that can't change its<br/>"
41 "formatting as it's fixed based on text<br/>"
43 evas_object_size_hint_weight_set(lb, 0.0, 0.0);
44 evas_object_size_hint_align_set(lb, EVAS_HINT_FILL, EVAS_HINT_FILL);
45 elm_box_pack_end(bx, lb);
48 lb = elm_label_add(win);
49 elm_label_line_wrap_set(lb, ELM_WRAP_CHAR);
50 elm_object_text_set(lb,
52 "This is more text designed to line-wrap here as "
53 "This object is resized horizontally. As it is "
54 "resized vertically though, nothing should change. "
55 "The amount of space allocated vertically should "
56 "change as horizontal size changes."
59 evas_object_size_hint_weight_set(lb, EVAS_HINT_EXPAND, 0.0);
60 evas_object_size_hint_align_set(lb, EVAS_HINT_FILL, EVAS_HINT_FILL);
61 elm_box_pack_end(bx, lb);
64 lb = elm_label_add(win);
65 elm_object_text_set(lb,
66 "This small label set to wrap"
68 evas_object_size_hint_weight_set(lb, EVAS_HINT_EXPAND, 0.0);
69 evas_object_size_hint_align_set(lb, EVAS_HINT_FILL, EVAS_HINT_FILL);
70 elm_box_pack_end(bx, lb);
74 evas_object_resize(win, 320, 300);
77 evas_object_show(win);
78 elm_win_resize_object_add(win, bx);
82 _cb_size_radio_changed(void *data, Evas_Object *obj, void *event __UNUSED__)
84 Evas_Object *lb = (Evas_Object *)data;
85 int style = elm_radio_value_get((Evas_Object *)obj);
89 elm_object_style_set(lb, "slide_short");
93 elm_object_style_set(lb, "slide_long");
97 elm_object_style_set(lb, "slide_bounce");
106 _change_cb(void *data, Evas_Object *obj, void *event_info __UNUSED__)
108 Evas_Object *lb = (Evas_Object *)data;
109 double val = elm_slider_value_get(obj);
110 elm_label_slide_set(lb, EINA_FALSE);
111 elm_label_slide_duration_set(lb, val);
112 elm_label_slide_set(lb, EINA_TRUE);
116 test_label2(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
118 Evas_Object *win, *gd, *rect, *lb, *rd, *rdg, *sl;
120 win = elm_win_util_standard_add("label2", "Label 2");
121 elm_win_autodel_set(win, EINA_TRUE);
123 gd = elm_grid_add(win);
124 elm_grid_size_set(gd, 100, 100);
125 evas_object_size_hint_weight_set(gd, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
126 elm_win_resize_object_add(win, gd);
127 evas_object_show(gd);
129 /* Test Label Ellipsis */
130 lb = elm_label_add(win);
131 elm_object_text_set(lb, "Test Label Ellipsis:");
132 elm_label_slide_set(lb, EINA_TRUE);
133 elm_grid_pack(gd, lb, 5, 5, 90, 10);
134 evas_object_show(lb);
136 rect = evas_object_rectangle_add(evas_object_evas_get(win));
137 elm_grid_pack(gd, rect, 5, 15, 90, 10);
138 evas_object_color_set(rect, 255, 125, 125, 255);
139 evas_object_show(rect);
141 lb = elm_label_add(win);
142 elm_object_text_set(lb,
143 "This is a label set to ellipsis. "
144 "If set ellipsis to true and the text doesn't fit "
145 "in the label an ellipsis(\"...\") will be shown "
146 "at the end of the widget."
148 elm_label_ellipsis_set(lb, EINA_TRUE);
149 elm_grid_pack(gd, lb, 5, 15, 90, 10);
150 evas_object_show(lb);
152 /* Test Label Slide */
153 lb = elm_label_add(win);
154 elm_object_text_set(lb, "Test Label Slide:");
155 elm_label_slide_set(lb, EINA_TRUE);
156 elm_grid_pack(gd, lb, 5, 30, 90, 10);
157 evas_object_show(lb);
159 rect = evas_object_rectangle_add(evas_object_evas_get(win));
160 elm_grid_pack(gd, rect, 5, 40, 90, 10);
161 evas_object_color_set(rect, 255, 125, 125, 255);
162 evas_object_show(rect);
164 lb = elm_label_add(win);
165 elm_object_style_set(lb, "slide_short");
166 elm_object_text_set(lb,
167 "This is a label set to slide. "
168 "If set slide to true the text of the label "
169 "will slide/scroll through the length of label."
170 "This only works with the themes \"slide_short\", "
171 "\"slide_long\" and \"slide_bounce\"."
173 elm_label_slide_set(lb, EINA_TRUE);
174 elm_grid_pack(gd, lb, 5, 40, 90, 10);
175 evas_object_show(lb);
177 rd = elm_radio_add(win);
178 elm_radio_state_value_set(rd, SLIDE_SHORT);
179 elm_object_text_set(rd, "slide_short");
180 evas_object_size_hint_weight_set(rd, EVAS_HINT_EXPAND, EVAS_HINT_FILL);
181 evas_object_smart_callback_add(rd, "changed", _cb_size_radio_changed, lb);
182 elm_grid_pack(gd, rd, 5, 50, 30, 10);
183 evas_object_show(rd);
186 rd = elm_radio_add(win);
187 elm_radio_state_value_set(rd, SLIDE_LONG);
188 elm_radio_group_add(rd, rdg);
189 elm_object_text_set(rd, "slide_long");
190 evas_object_size_hint_weight_set(rd, EVAS_HINT_EXPAND, EVAS_HINT_FILL);
191 evas_object_smart_callback_add(rd, "changed", _cb_size_radio_changed, lb);
192 elm_grid_pack(gd, rd, 35, 50, 30, 10);
193 evas_object_show(rd);
195 rd = elm_radio_add(win);
196 elm_radio_state_value_set(rd, SLIDE_BOUNCE);
197 elm_radio_group_add(rd, rdg);
198 elm_object_text_set(rd, "slide_bounce");
199 evas_object_size_hint_weight_set(rd, EVAS_HINT_EXPAND, EVAS_HINT_FILL);
200 evas_object_smart_callback_add(rd, "changed", _cb_size_radio_changed, lb);
201 elm_grid_pack(gd, rd, 65, 50, 30, 10);
202 evas_object_show(rd);
204 sl = elm_slider_add(win);
205 elm_object_text_set(sl, "Slide Duration");
206 elm_slider_unit_format_set(sl, "%1.1f units");
207 elm_slider_min_max_set(sl, 1, 20);
208 elm_slider_value_set(sl, 10);
209 evas_object_size_hint_align_set(sl, EVAS_HINT_FILL, 0.5);
210 evas_object_size_hint_weight_set(sl, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
211 evas_object_smart_callback_add(sl, "changed", _change_cb, lb);
212 elm_grid_pack(gd, sl, 5, 60, 90, 10);
213 evas_object_show(sl);
215 evas_object_resize(win, 320, 320);
216 evas_object_show(win);