summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorChunEon Park <hermet@hermet.pe.kr>2012-01-02 06:54:18 +0000
committerChunEon Park <hermet@hermet.pe.kr>2012-01-02 06:54:18 +0000
commit53058c8062338d9b9aa31f075d246ffddc966e34 (patch)
treefe76a7c26188dcec1646080d08713b1bad4909ef /src
parent383965d5c91b098f25c52c71ace9e3ea7e0175d3 (diff)
elementary/segment_control - deprecates 2 APIs and supports elm_object_common APIs.
*deprecated elm_segment_control_item_label_set elm_segment_control_item_icon_set SVN revision: 66731
Diffstat (limited to 'src')
-rw-r--r--src/examples/segment_control_example.c2
-rw-r--r--src/lib/elm_deprecated.h48
-rw-r--r--src/lib/elm_segment_control.c120
-rw-r--r--src/lib/elm_segment_control.h45
4 files changed, 126 insertions, 89 deletions
diff --git a/src/examples/segment_control_example.c b/src/examples/segment_control_example.c
index dcc97cd59..185aa7bc2 100644
--- a/src/examples/segment_control_example.c
+++ b/src/examples/segment_control_example.c
@@ -69,7 +69,7 @@ elm_main(int argc __UNUSED__, char **argv __UNUSED__)
69 elm_segment_control_item_del_at(sc, 2); 69 elm_segment_control_item_del_at(sc, 2);
70 70
71 seg_it = elm_segment_control_item_get(sc, 0); 71 seg_it = elm_segment_control_item_get(sc, 0);
72 elm_segment_control_item_label_set(seg_it, "Only Text"); 72 elm_object_item_text_set(seg_it, "Only Text");
73 73
74 count = elm_segment_control_item_count_get(sc); 74 count = elm_segment_control_item_count_get(sc);
75 seg_it = elm_segment_control_item_get(sc, count / 2); 75 seg_it = elm_segment_control_item_get(sc, count / 2);
diff --git a/src/lib/elm_deprecated.h b/src/lib/elm_deprecated.h
index 3d3133526..cbb558ab9 100644
--- a/src/lib/elm_deprecated.h
+++ b/src/lib/elm_deprecated.h
@@ -2496,3 +2496,51 @@ EINA_DEPRECATED EAPI Eina_Bool elm_toolbar_orientation_get(const Evas_Object
2496 * @ingroup Video 2496 * @ingroup Video
2497 */ 2497 */
2498EINA_DEPRECATED EAPI void elm_player_video_set(Evas_Object *player, Evas_Object *video); 2498EINA_DEPRECATED EAPI void elm_player_video_set(Evas_Object *player, Evas_Object *video);
2499
2500/**
2501 * Set the label of item.
2502 *
2503 * @param it The item of segment control.
2504 * @param text The label of item.
2505 *
2506 * The label to be displayed by the item.
2507 * Label will be at right of the icon (if set).
2508 *
2509 * If a label was passed as argument on item creation, with function
2510 * elm_control_segment_item_add(), it will be already
2511 * displayed by the item.
2512 *
2513 * @see elm_segment_control_item_label_get()
2514 * @see elm_segment_control_item_add()
2515 * @deprecated Use elm_object_item_text_set() instead
2516 *
2517 * @ingroup SegmentControl
2518 */
2519EINA_DEPRECATED EAPI void elm_segment_control_item_label_set(Elm_Object_Item *it, const char *label);
2520
2521
2522/**
2523 * Set the icon associated to the item.
2524 *
2525 * @param it The segment control item.
2526 * @param icon The icon object to associate with @p it.
2527 *
2528 * The icon object to use at left side of the item. An
2529 * icon can be any Evas object, but usually it is an icon created
2530 * with elm_icon_add().
2531 *
2532 * Once the icon object is set, a previously set one will be deleted.
2533 * @warning Setting the same icon for two items will cause the icon to
2534 * dissapear from the first item.
2535 *
2536 * If an icon was passed as argument on item creation, with function
2537 * elm_segment_control_item_add(), it will be already
2538 * associated to the item.
2539 *
2540 * @see elm_segment_control_item_add()
2541 * @see elm_segment_control_item_icon_get()
2542 * @deprecated Use elm_object_item_part_content_set() instead
2543 *
2544 * @ingroup SegmentControl
2545 */
2546EINA_DEPRECATED EAPI void elm_segment_control_item_icon_set(Elm_Object_Item *it, Evas_Object *icon);
diff --git a/src/lib/elm_segment_control.c b/src/lib/elm_segment_control.c
index b73ec4759..b8d88b1b1 100644
--- a/src/lib/elm_segment_control.c
+++ b/src/lib/elm_segment_control.c
@@ -434,6 +434,75 @@ _item_find(const Evas_Object *obj, int idx)
434 return it; 434 return it;
435} 435}
436 436
437static void
438_item_text_set_hook(Elm_Object_Item *it, const char *part, const char *label)
439{
440 ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
441 Widget_Data *wd;
442 Elm_Segment_Item *item;
443
444 if (part && strcmp(part, "default")) return;
445
446 item = (Elm_Segment_Item *) it;
447 wd = elm_widget_item_data_get(item);
448 if (!wd) return;
449
450 eina_stringshare_replace(&item->label, label);
451 if (item->label)
452 edje_object_signal_emit(VIEW(item), "elm,state,text,visible", "elm");
453 else
454 edje_object_signal_emit(VIEW(item), "elm,state,text,hidden", "elm");
455 edje_object_message_signal_process(VIEW(item));
456 //label can be NULL also.
457 edje_object_part_text_set(VIEW(item), "elm.text", item->label);
458}
459
460static const char *
461_item_text_get_hook(const Elm_Object_Item *it, const char *part)
462{
463 ELM_OBJ_ITEM_CHECK_OR_RETURN(it, NULL);
464 if (part && strcmp(part, "default")) return NULL;
465 return ((Elm_Segment_Item *) it)->label;
466}
467
468static void
469_item_content_set_hook(Elm_Object_Item *it,
470 const char *part,
471 Evas_Object *content)
472{
473 ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
474 Elm_Segment_Item *item;
475
476 if (part && strcmp(part, "icon")) return;
477
478 item = (Elm_Segment_Item *) it;
479
480 //Remove the existing icon
481 if (item->icon)
482 {
483 edje_object_part_unswallow(VIEW(item), item->icon);
484 evas_object_del(item->icon);
485 item->icon = NULL;
486 }
487 item->icon = content;
488 if (item->icon)
489 {
490 elm_widget_sub_object_add(VIEW(item), item->icon);
491 edje_object_part_swallow(VIEW(item), "elm.swallow.icon", item->icon);
492 edje_object_signal_emit(VIEW(item), "elm,state,icon,visible", "elm");
493 }
494 else
495 edje_object_signal_emit(VIEW(item), "elm,state,icon,hidden", "elm");
496}
497
498static Evas_Object *
499_item_content_get_hook(const Elm_Object_Item *it, const char *part)
500{
501 ELM_OBJ_ITEM_CHECK_OR_RETURN(it, NULL);
502 if (part && strcmp(part, "icon")) return NULL;
503 return ((Elm_Segment_Item *) it)->icon;
504}
505
437static Elm_Segment_Item* 506static Elm_Segment_Item*
438_item_new(Evas_Object *obj, Evas_Object *icon, const char *label) 507_item_new(Evas_Object *obj, Evas_Object *icon, const char *label)
439{ 508{
@@ -446,6 +515,10 @@ _item_new(Evas_Object *obj, Evas_Object *icon, const char *label)
446 it = elm_widget_item_new(obj, Elm_Segment_Item); 515 it = elm_widget_item_new(obj, Elm_Segment_Item);
447 if (!it) return NULL; 516 if (!it) return NULL;
448 elm_widget_item_data_set(it, wd); 517 elm_widget_item_data_set(it, wd);
518 elm_widget_item_text_set_hook_set(it, _item_text_set_hook);
519 elm_widget_item_text_get_hook_set(it, _item_text_get_hook);
520 elm_widget_item_content_set_hook_set(it, _item_content_set_hook);
521 elm_widget_item_content_get_hook_set(it, _item_content_get_hook);
449 522
450 VIEW(it) = edje_object_add(evas_object_evas_get(obj)); 523 VIEW(it) = edje_object_add(evas_object_evas_get(obj));
451 edje_object_scale_set(VIEW(it), elm_widget_scale_get(VIEW(it)) 524 edje_object_scale_set(VIEW(it), elm_widget_scale_get(VIEW(it))
@@ -598,69 +671,30 @@ EAPI const char*
598elm_segment_control_item_label_get(const Evas_Object *obj, int idx) 671elm_segment_control_item_label_get(const Evas_Object *obj, int idx)
599{ 672{
600 ELM_CHECK_WIDTYPE(obj, widtype) NULL; 673 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
601 Elm_Segment_Item *it; 674 Elm_Segment_Item *it = _item_find(obj, idx);
602
603 it = _item_find(obj, idx);
604 if (it) return it->label; 675 if (it) return it->label;
605
606 return NULL; 676 return NULL;
607} 677}
608 678
609EAPI void 679EAPI void
610elm_segment_control_item_label_set(Elm_Object_Item* it, const char* label) 680elm_segment_control_item_label_set(Elm_Object_Item* it, const char* label)
611{ 681{
612 ELM_OBJ_ITEM_CHECK_OR_RETURN(it); 682 _item_text_set_hook(it, NULL, label);
613 Widget_Data *wd;
614 Elm_Segment_Item *item = (Elm_Segment_Item *) it;
615
616 wd = elm_widget_item_data_get(item);
617 if (!wd) return;
618
619 eina_stringshare_replace(&item->label, label);
620 if (item->label)
621 edje_object_signal_emit(VIEW(item), "elm,state,text,visible", "elm");
622 else
623 edje_object_signal_emit(VIEW(item), "elm,state,text,hidden", "elm");
624 edje_object_message_signal_process(VIEW(item));
625 //label can be NULL also.
626 edje_object_part_text_set(VIEW(item), "elm.text", item->label);
627} 683}
628 684
629EAPI Evas_Object * 685EAPI Evas_Object *
630elm_segment_control_item_icon_get(const Evas_Object *obj, int idx) 686elm_segment_control_item_icon_get(const Evas_Object *obj, int idx)
631{ 687{
632 ELM_CHECK_WIDTYPE(obj, widtype) NULL; 688 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
633 Elm_Segment_Item *it; 689 Elm_Segment_Item *it = _item_find(obj, idx);
634
635 it = _item_find(obj, idx);
636 if (it) return it->icon; 690 if (it) return it->icon;
637
638 return NULL; 691 return NULL;
639} 692}
640 693
641EAPI void 694EAPI void
642elm_segment_control_item_icon_set(Elm_Object_Item *it, Evas_Object *icon) 695elm_segment_control_item_icon_set(Elm_Object_Item *it, Evas_Object *icon)
643{ 696{
644 ELM_OBJ_ITEM_CHECK_OR_RETURN(it); 697 _item_content_set_hook(it, NULL, icon);
645 Elm_Segment_Item *item = (Elm_Segment_Item *) it;
646
647 //Remove the existing icon
648 if (item->icon)
649 {
650 edje_object_part_unswallow(VIEW(item), item->icon);
651 evas_object_del(item->icon);
652 item->icon = NULL;
653 }
654
655 item->icon = icon;
656 if (item->icon)
657 {
658 elm_widget_sub_object_add(VIEW(item), item->icon);
659 edje_object_part_swallow(VIEW(item), "elm.swallow.icon", item->icon);
660 edje_object_signal_emit(VIEW(item), "elm,state,icon,visible", "elm");
661 }
662 else
663 edje_object_signal_emit(VIEW(item), "elm,state,icon,hidden", "elm");
664} 698}
665 699
666EAPI int 700EAPI int
diff --git a/src/lib/elm_segment_control.h b/src/lib/elm_segment_control.h
index 6e5b8efad..a297e3833 100644
--- a/src/lib/elm_segment_control.h
+++ b/src/lib/elm_segment_control.h
@@ -198,26 +198,6 @@ EAPI Elm_Object_Item *elm_segment_control_item_get(const Evas_Object *obj, int i
198EAPI const char *elm_segment_control_item_label_get(const Evas_Object *obj, int index); 198EAPI const char *elm_segment_control_item_label_get(const Evas_Object *obj, int index);
199 199
200/** 200/**
201 * Set the label of item.
202 *
203 * @param it The item of segment control.
204 * @param text The label of item.
205 *
206 * The label to be displayed by the item.
207 * Label will be at right of the icon (if set).
208 *
209 * If a label was passed as argument on item creation, with function
210 * elm_control_segment_item_add(), it will be already
211 * displayed by the item.
212 *
213 * @see elm_segment_control_item_label_get()
214 * @see elm_segment_control_item_add()
215 *
216 * @ingroup SegmentControl
217 */
218EAPI void elm_segment_control_item_label_set(Elm_Object_Item *it, const char *label);
219
220/**
221 * Get the icon associated to the item. 201 * Get the icon associated to the item.
222 * 202 *
223 * @param obj The segment control object. 203 * @param obj The segment control object.
@@ -237,31 +217,6 @@ EAPI void elm_segment_control_item_label_set(Elm_Object_Item *it, c
237EAPI Evas_Object *elm_segment_control_item_icon_get(const Evas_Object *obj, int index); 217EAPI Evas_Object *elm_segment_control_item_icon_get(const Evas_Object *obj, int index);
238 218
239/** 219/**
240 * Set the icon associated to the item.
241 *
242 * @param it The segment control item.
243 * @param icon The icon object to associate with @p it.
244 *
245 * The icon object to use at left side of the item. An
246 * icon can be any Evas object, but usually it is an icon created
247 * with elm_icon_add().
248 *
249 * Once the icon object is set, a previously set one will be deleted.
250 * @warning Setting the same icon for two items will cause the icon to
251 * dissapear from the first item.
252 *
253 * If an icon was passed as argument on item creation, with function
254 * elm_segment_control_item_add(), it will be already
255 * associated to the item.
256 *
257 * @see elm_segment_control_item_add()
258 * @see elm_segment_control_item_icon_get()
259 *
260 * @ingroup SegmentControl
261 */
262EAPI void elm_segment_control_item_icon_set(Elm_Object_Item *it, Evas_Object *icon);
263
264/**
265 * Get the index of an item. 220 * Get the index of an item.
266 * 221 *
267 * @param it The segment control item. 222 * @param it The segment control item.