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, *bg, *bx, *lb;
20 win = elm_win_add(NULL, "label", ELM_WIN_BASIC);
21 elm_win_title_set(win, "Label");
22 elm_win_autodel_set(win, EINA_TRUE);
25 elm_win_resize_object_add(win, bg);
26 evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
29 bx = elm_box_add(win);
30 evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
31 evas_object_size_hint_align_set(bx, EVAS_HINT_FILL, EVAS_HINT_FILL);
33 lb = elm_label_add(win);
34 elm_object_text_set(lb,
35 "<b>This is a small label</b>"
37 evas_object_size_hint_weight_set(lb, 0.0, 0.0);
38 evas_object_size_hint_align_set(lb, EVAS_HINT_FILL, EVAS_HINT_FILL);
39 elm_box_pack_end(bx, lb);
42 lb = elm_label_add(win);
43 elm_object_text_set(lb,
44 "This is a larger label with newlines<br/>"
45 "to make it bigger, bit it won't expand or wrap<br/>"
46 "just be a block of text that can't change its<br/>"
47 "formatting as it's fixed based on text<br/>"
49 evas_object_size_hint_weight_set(lb, 0.0, 0.0);
50 evas_object_size_hint_align_set(lb, EVAS_HINT_FILL, EVAS_HINT_FILL);
51 elm_box_pack_end(bx, lb);
54 lb = elm_label_add(win);
55 elm_label_line_wrap_set(lb, ELM_WRAP_CHAR);
56 elm_object_text_set(lb,
58 "This is more text designed to line-wrap here as "
59 "This object is resized horizontally. As it is "
60 "resized vertically though, nothing should change. "
61 "The amount of space allocated vertically should "
62 "change as horizontal size changes."
65 evas_object_size_hint_weight_set(lb, EVAS_HINT_EXPAND, 0.0);
66 evas_object_size_hint_align_set(lb, EVAS_HINT_FILL, EVAS_HINT_FILL);
67 elm_box_pack_end(bx, lb);
70 lb = elm_label_add(win);
71 elm_object_text_set(lb,
72 "This small label set to wrap"
74 evas_object_size_hint_weight_set(lb, EVAS_HINT_EXPAND, 0.0);
75 evas_object_size_hint_align_set(lb, EVAS_HINT_FILL, EVAS_HINT_FILL);
76 elm_box_pack_end(bx, lb);
80 evas_object_resize(win, 320, 300);
83 evas_object_show(win);
84 elm_win_resize_object_add(win, bx);
88 _cb_size_radio_changed(void *data, Evas_Object *obj, void *event __UNUSED__)
90 Evas_Object *lb = (Evas_Object *)data;
91 int style = elm_radio_value_get((Evas_Object *)obj);
95 elm_object_style_set(lb, "slide_short");
99 elm_object_style_set(lb, "slide_long");
103 elm_object_style_set(lb, "slide_bounce");
112 _change_cb(void *data, Evas_Object *obj, void *event_info __UNUSED__)
114 Evas_Object *lb = (Evas_Object *)data;
115 double val = elm_slider_value_get(obj);
116 elm_label_slide_set(lb, EINA_FALSE);
117 elm_label_slide_duration_set(lb, val);
118 elm_label_slide_set(lb, EINA_TRUE);
122 test_label2(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
124 Evas_Object *win, *gd, *rect, *lb, *rd, *rdg, *sl;
126 win = elm_win_util_standard_add("label2", "Label 2");
127 elm_win_autodel_set(win, EINA_TRUE);
129 gd = elm_grid_add(win);
130 elm_grid_size_set(gd, 100, 100);
131 evas_object_size_hint_weight_set(gd, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
132 elm_win_resize_object_add(win, gd);
133 evas_object_show(gd);
135 /* Test Label Ellipsis */
136 lb = elm_label_add(win);
137 elm_object_text_set(lb, "Test Label Ellipsis:");
138 elm_label_slide_set(lb, EINA_TRUE);
139 elm_grid_pack(gd, lb, 5, 5, 90, 10);
140 evas_object_show(lb);
142 rect = evas_object_rectangle_add(evas_object_evas_get(win));
143 elm_grid_pack(gd, rect, 5, 15, 90, 10);
144 evas_object_color_set(rect, 255, 125, 125, 255);
145 evas_object_show(rect);
147 lb = elm_label_add(win);
148 elm_object_text_set(lb,
149 "This is a label set to ellipsis. "
150 "If set ellipsis to true and the text doesn't fit "
151 "in the label an ellipsis(\"...\") will be shown "
152 "at the end of the widget."
154 elm_label_ellipsis_set(lb, EINA_TRUE);
155 elm_grid_pack(gd, lb, 5, 15, 90, 10);
156 evas_object_show(lb);
158 /* Test Label Slide */
159 lb = elm_label_add(win);
160 elm_object_text_set(lb, "Test Label Slide:");
161 elm_label_slide_set(lb, EINA_TRUE);
162 elm_grid_pack(gd, lb, 5, 30, 90, 10);
163 evas_object_show(lb);
165 rect = evas_object_rectangle_add(evas_object_evas_get(win));
166 elm_grid_pack(gd, rect, 5, 40, 90, 10);
167 evas_object_color_set(rect, 255, 125, 125, 255);
168 evas_object_show(rect);
170 lb = elm_label_add(win);
171 elm_object_style_set(lb, "slide_short");
172 elm_object_text_set(lb,
173 "This is a label set to slide. "
174 "If set slide to true the text of the label "
175 "will slide/scroll through the length of label."
176 "This only works with the themes \"slide_short\", "
177 "\"slide_long\" and \"slide_bounce\"."
179 elm_label_slide_set(lb, EINA_TRUE);
180 elm_grid_pack(gd, lb, 5, 40, 90, 10);
181 evas_object_show(lb);
183 rd = elm_radio_add(win);
184 elm_radio_state_value_set(rd, SLIDE_SHORT);
185 elm_object_text_set(rd, "slide_short");
186 evas_object_size_hint_weight_set(rd, EVAS_HINT_EXPAND, EVAS_HINT_FILL);
187 evas_object_smart_callback_add(rd, "changed", _cb_size_radio_changed, lb);
188 elm_grid_pack(gd, rd, 5, 50, 30, 10);
189 evas_object_show(rd);
192 rd = elm_radio_add(win);
193 elm_radio_state_value_set(rd, SLIDE_LONG);
194 elm_radio_group_add(rd, rdg);
195 elm_object_text_set(rd, "slide_long");
196 evas_object_size_hint_weight_set(rd, EVAS_HINT_EXPAND, EVAS_HINT_FILL);
197 evas_object_smart_callback_add(rd, "changed", _cb_size_radio_changed, lb);
198 elm_grid_pack(gd, rd, 35, 50, 30, 10);
199 evas_object_show(rd);
201 rd = elm_radio_add(win);
202 elm_radio_state_value_set(rd, SLIDE_BOUNCE);
203 elm_radio_group_add(rd, rdg);
204 elm_object_text_set(rd, "slide_bounce");
205 evas_object_size_hint_weight_set(rd, EVAS_HINT_EXPAND, EVAS_HINT_FILL);
206 evas_object_smart_callback_add(rd, "changed", _cb_size_radio_changed, lb);
207 elm_grid_pack(gd, rd, 65, 50, 30, 10);
208 evas_object_show(rd);
210 sl = elm_slider_add(win);
211 elm_object_text_set(sl, "Slide Duration");
212 elm_slider_unit_format_set(sl, "%1.1f units");
213 elm_slider_min_max_set(sl, 1, 20);
214 elm_slider_value_set(sl, 10);
215 evas_object_size_hint_align_set(sl, EVAS_HINT_FILL, 0.5);
216 evas_object_size_hint_weight_set(sl, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
217 evas_object_smart_callback_add(sl, "changed", _change_cb, lb);
218 elm_grid_pack(gd, sl, 5, 60, 90, 10);
219 evas_object_show(sl);
221 evas_object_resize(win, 320, 320);
222 evas_object_show(win);