summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordavemds <dave@gurumeditation.it>2014-02-10 22:31:58 +0100
committerdavemds <dave@gurumeditation.it>2014-02-10 22:31:58 +0100
commit22eb42b3673db2b6e8af08f695e122ccd2a8687e (patch)
treea1014ac4ab97ee3e89e96391775ce011d6207d60
parent82ae642408bbf1ac43a8825f8c51a36c27d9b597 (diff)
Label: formatting
-rw-r--r--src/lib/elm_label.c68
1 files changed, 24 insertions, 44 deletions
diff --git a/src/lib/elm_label.c b/src/lib/elm_label.c
index 10d4c6aa5..96591a4b8 100644
--- a/src/lib/elm_label.c
+++ b/src/lib/elm_label.c
@@ -40,13 +40,11 @@ _recalc(void *data)
40 Evas_Coord resw; 40 Evas_Coord resw;
41 41
42 evas_event_freeze(evas_object_evas_get(data)); 42 evas_event_freeze(evas_object_evas_get(data));
43 evas_object_geometry_get 43 evas_object_geometry_get(wd->resize_obj, NULL, NULL, &resw, NULL);
44 (wd->resize_obj, NULL, NULL, &resw, NULL);
45 if (sd->wrap_w > resw) 44 if (sd->wrap_w > resw)
46 resw = sd->wrap_w; 45 resw = sd->wrap_w;
47 46
48 edje_object_size_min_restricted_calc 47 edje_object_size_min_restricted_calc(wd->resize_obj, &minw, &minh, resw, 0);
49 (wd->resize_obj, &minw, &minh, resw, 0);
50 48
51 /* This is a hack to workaround the way min size hints are treated. 49 /* This is a hack to workaround the way min size hints are treated.
52 * If the minimum width is smaller than the restricted width, it means 50 * If the minimum width is smaller than the restricted width, it means
@@ -65,8 +63,7 @@ _recalc(void *data)
65} 63}
66 64
67static void 65static void
68_label_format_set(Evas_Object *obj, 66_label_format_set(Evas_Object *obj, const char *format)
69 const char *format)
70{ 67{
71 if (format) 68 if (format)
72 edje_object_part_text_style_user_push(obj, "elm.text", format); 69 edje_object_part_text_style_user_push(obj, "elm.text", format);
@@ -150,8 +147,7 @@ _label_slide_change(Evas_Object *obj)
150 msg->count = 1; 147 msg->count = 1;
151 msg->val[0] = sd->slide_duration; 148 msg->val[0] = sd->slide_duration;
152 149
153 edje_object_message_send 150 edje_object_message_send(wd->resize_obj, EDJE_MESSAGE_FLOAT_SET, 0, msg);
154 (wd->resize_obj, EDJE_MESSAGE_FLOAT_SET, 0, msg);
155 edje_object_signal_emit(wd->resize_obj, "elm,state,slide,start", "elm"); 151 edje_object_signal_emit(wd->resize_obj, "elm,state,slide,start", "elm");
156 } 152 }
157 //no slide effect. 153 //no slide effect.
@@ -200,8 +196,7 @@ _elm_label_smart_sizing_eval(Eo *obj, void *_pd EINA_UNUSED, va_list *list EINA_
200 196
201 if (sd->linewrap) 197 if (sd->linewrap)
202 { 198 {
203 evas_object_geometry_get 199 evas_object_geometry_get(wd->resize_obj, NULL, NULL, &resw, &resh);
204 (wd->resize_obj, NULL, NULL, &resw, &resh);
205 if (resw == sd->lastw) return; 200 if (resw == sd->lastw) return;
206 sd->lastw = resw; 201 sd->lastw = resw;
207 _recalc(obj); 202 _recalc(obj);
@@ -218,10 +213,7 @@ _elm_label_smart_sizing_eval(Eo *obj, void *_pd EINA_UNUSED, va_list *list EINA_
218} 213}
219 214
220static void 215static void
221_on_label_resize(void *data, 216_on_label_resize(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
222 Evas *e EINA_UNUSED,
223 Evas_Object *obj EINA_UNUSED,
224 void *event_info EINA_UNUSED)
225{ 217{
226 ELM_LABEL_DATA_GET(data, sd); 218 ELM_LABEL_DATA_GET(data, sd);
227 219
@@ -230,9 +222,7 @@ _on_label_resize(void *data,
230} 222}
231 223
232static int 224static int
233_get_value_in_key_string(const char *oldstring, 225_get_value_in_key_string(const char *oldstring, const char *key, char **value)
234 const char *key,
235 char **value)
236{ 226{
237 char *curlocater, *endtag; 227 char *curlocater, *endtag;
238 int firstindex = 0, foundflag = -1; 228 int firstindex = 0, foundflag = -1;
@@ -264,10 +254,7 @@ _get_value_in_key_string(const char *oldstring,
264} 254}
265 255
266static int 256static int
267_strbuf_key_value_replace(Eina_Strbuf *srcbuf, 257_strbuf_key_value_replace(Eina_Strbuf *srcbuf, const char *key, const char *value, int deleteflag)
268 const char *key,
269 const char *value,
270 int deleteflag)
271{ 258{
272 char *kvalue; 259 char *kvalue;
273 const char *srcstring = NULL; 260 const char *srcstring = NULL;
@@ -300,9 +287,8 @@ _strbuf_key_value_replace(Eina_Strbuf *srcbuf,
300 if (*srcstring) 287 if (*srcstring)
301 { 288 {
302 /* -1 because we want it before the ' */ 289 /* -1 because we want it before the ' */
303 eina_strbuf_insert_printf 290 eina_strbuf_insert_printf (srcbuf, " %s=%s",
304 (srcbuf, " %s=%s", eina_strbuf_length_get(srcbuf) - 1, key, 291 eina_strbuf_length_get(srcbuf) - 1, key, value);
305 value);
306 } 292 }
307 else 293 else
308 { 294 {
@@ -314,10 +300,7 @@ _strbuf_key_value_replace(Eina_Strbuf *srcbuf,
314} 300}
315 301
316static int 302static int
317_stringshare_key_value_replace(const char **srcstring, 303_stringshare_key_value_replace(const char **srcstring, const char *key, const char *value, int deleteflag)
318 const char *key,
319 const char *value,
320 int deleteflag)
321{ 304{
322 Eina_Strbuf *sharebuf = NULL; 305 Eina_Strbuf *sharebuf = NULL;
323 306
@@ -339,9 +322,10 @@ _elm_label_smart_text_set(Eo *obj, void *_pd, va_list *list)
339 const char *part = va_arg(*list, const char *); 322 const char *part = va_arg(*list, const char *);
340 const char *label = va_arg(*list, const char *); 323 const char *label = va_arg(*list, const char *);
341 Eina_Bool *ret = va_arg(*list, Eina_Bool *); 324 Eina_Bool *ret = va_arg(*list, Eina_Bool *);
342 if (ret) *ret = EINA_FALSE;
343 Eina_Bool int_ret = EINA_FALSE; 325 Eina_Bool int_ret = EINA_FALSE;
344 326
327 if (ret) *ret = EINA_FALSE;
328
345 if (!label) label = ""; 329 if (!label) label = "";
346 _label_format_set(wd->resize_obj, sd->format); 330 _label_format_set(wd->resize_obj, sd->format);
347 331
@@ -394,9 +378,8 @@ _elm_label_smart_add(Eo *obj, void *_pd, va_list *list EINA_UNUSED)
394 priv->format = eina_stringshare_add(""); 378 priv->format = eina_stringshare_add("");
395 _label_format_set(wd->resize_obj, priv->format); 379 _label_format_set(wd->resize_obj, priv->format);
396 380
397 evas_object_event_callback_add 381 evas_object_event_callback_add(wd->resize_obj, EVAS_CALLBACK_RESIZE,
398 (wd->resize_obj, EVAS_CALLBACK_RESIZE, 382 _on_label_resize, obj);
399 _on_label_resize, obj);
400 383
401 edje_object_signal_callback_add(wd->resize_obj, "elm,state,slide,end", "", 384 edje_object_signal_callback_add(wd->resize_obj, "elm,state,slide,end", "",
402 _on_slide_end, obj); 385 _on_slide_end, obj);
@@ -405,10 +388,10 @@ _elm_label_smart_add(Eo *obj, void *_pd, va_list *list EINA_UNUSED)
405 elm_widget_can_focus_set(obj, _elm_config->access_mode); 388 elm_widget_can_focus_set(obj, _elm_config->access_mode);
406 389
407 _elm_access_object_register(obj, wd->resize_obj); 390 _elm_access_object_register(obj, wd->resize_obj);
408 _elm_access_text_set 391 _elm_access_text_set(_elm_access_info_get(obj), ELM_ACCESS_TYPE,
409 (_elm_access_info_get(obj), ELM_ACCESS_TYPE, E_("Label")); 392 E_("Label"));
410 _elm_access_callback_set 393 _elm_access_callback_set(_elm_access_info_get(obj), ELM_ACCESS_INFO,
411 (_elm_access_info_get(obj), ELM_ACCESS_INFO, _access_info_cb, NULL); 394 _access_info_cb, NULL);
412 395
413 if (!elm_layout_theme_set(obj, "label", "base", elm_widget_style_get(obj))) 396 if (!elm_layout_theme_set(obj, "label", "base", elm_widget_style_get(obj)))
414 CRI("Failed to set layout!"); 397 CRI("Failed to set layout!");
@@ -422,6 +405,7 @@ elm_label_add(Evas_Object *parent)
422{ 405{
423 EINA_SAFETY_ON_NULL_RETURN_VAL(parent, NULL); 406 EINA_SAFETY_ON_NULL_RETURN_VAL(parent, NULL);
424 Evas_Object *obj = eo_add(MY_CLASS, parent); 407 Evas_Object *obj = eo_add(MY_CLASS, parent);
408
425 eo_unref(obj); 409 eo_unref(obj);
426 return obj; 410 return obj;
427} 411}
@@ -436,8 +420,7 @@ _constructor(Eo *obj, void *_pd EINA_UNUSED, va_list *list EINA_UNUSED)
436} 420}
437 421
438EAPI void 422EAPI void
439elm_label_line_wrap_set(Evas_Object *obj, 423elm_label_line_wrap_set(Evas_Object *obj, Elm_Wrap_Type wrap)
440 Elm_Wrap_Type wrap)
441{ 424{
442 ELM_LABEL_CHECK(obj); 425 ELM_LABEL_CHECK(obj);
443 eo_do(obj, elm_obj_label_line_wrap_set(wrap)); 426 eo_do(obj, elm_obj_label_line_wrap_set(wrap));
@@ -506,8 +489,7 @@ _line_wrap_get(Eo *obj EINA_UNUSED, void *_pd, va_list *list)
506} 489}
507 490
508EAPI void 491EAPI void
509elm_label_wrap_width_set(Evas_Object *obj, 492elm_label_wrap_width_set(Evas_Object *obj, Evas_Coord w)
510 Evas_Coord w)
511{ 493{
512 ELM_LABEL_CHECK(obj); 494 ELM_LABEL_CHECK(obj);
513 eo_do(obj, elm_obj_label_wrap_width_set(w)); 495 eo_do(obj, elm_obj_label_wrap_width_set(w));
@@ -549,8 +531,7 @@ _wrap_width_get(Eo *obj EINA_UNUSED, void *_pd, va_list *list)
549} 531}
550 532
551EAPI void 533EAPI void
552elm_label_ellipsis_set(Evas_Object *obj, 534elm_label_ellipsis_set(Evas_Object *obj, Eina_Bool ellipsis)
553 Eina_Bool ellipsis)
554{ 535{
555 ELM_LABEL_CHECK(obj); 536 ELM_LABEL_CHECK(obj);
556 eo_do(obj, elm_obj_label_ellipsis_set(ellipsis)); 537 eo_do(obj, elm_obj_label_ellipsis_set(ellipsis));
@@ -641,8 +622,7 @@ _slide_mode_get(Eo *obj EINA_UNUSED, void *_pd, va_list *list)
641} 622}
642 623
643EINA_DEPRECATED EAPI void 624EINA_DEPRECATED EAPI void
644elm_label_slide_set(Evas_Object *obj, 625elm_label_slide_set(Evas_Object *obj, Eina_Bool slide)
645 Eina_Bool slide)
646{ 626{
647 if (slide) 627 if (slide)
648 elm_label_slide_mode_set(obj, ELM_LABEL_SLIDE_MODE_ALWAYS); 628 elm_label_slide_mode_set(obj, ELM_LABEL_SLIDE_MODE_ALWAYS);