summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorChunEon Park <hermet@hermet.pe.kr>2012-01-02 09:03:02 +0000
committerChunEon Park <hermet@hermet.pe.kr>2012-01-02 09:03:02 +0000
commit61ac28c312bc0b8c28e2451bf4eeced879309813 (patch)
treef68b48d3d7b225b96f47441aff742be7eaec31da /src
parent35356124b2fcf7605ff850953cc87dae14d039eb (diff)
elementary/multibuttonentry - refactoring.
removed unnecessary lines and made more proper as a elm_widget_item type. SVN revision: 66736
Diffstat (limited to 'src')
-rw-r--r--src/lib/elc_multibuttonentry.c122
1 files changed, 35 insertions, 87 deletions
diff --git a/src/lib/elc_multibuttonentry.c b/src/lib/elc_multibuttonentry.c
index 7b195a76b..0f4ca9bb1 100644
--- a/src/lib/elc_multibuttonentry.c
+++ b/src/lib/elc_multibuttonentry.c
@@ -38,7 +38,6 @@ struct _Multibuttonentry_Item
38 { 38 {
39 ELM_WIDGET_ITEM; 39 ELM_WIDGET_ITEM;
40 Evas_Object *button; 40 Evas_Object *button;
41 void *data;
42 Evas_Coord vw, rw; // vw: visual width, real width 41 Evas_Coord vw, rw; // vw: visual width, real width
43 Eina_Bool visible: 1; 42 Eina_Bool visible: 1;
44 }; 43 };
@@ -793,10 +792,10 @@ _add_button_item(Evas_Object *obj, const char *str, Multibuttonentry_Pos pos, co
793 item = elm_widget_item_new(obj, Elm_Multibuttonentry_Item); 792 item = elm_widget_item_new(obj, Elm_Multibuttonentry_Item);
794 if (item) 793 if (item)
795 { 794 {
795 elm_widget_item_data_set(item, data);
796 Evas_Coord rw, vw; 796 Evas_Coord rw, vw;
797 _resize_button(btn, &rw, &vw); 797 _resize_button(btn, &rw, &vw);
798 item->button = btn; 798 item->button = btn;
799 item->data = data;
800 item->rw = rw; 799 item->rw = rw;
801 item->vw = vw; 800 item->vw = vw;
802 item->visible = EINA_TRUE; 801 item->visible = EINA_TRUE;
@@ -1427,10 +1426,8 @@ EAPI Elm_Multibuttonentry_Item *
1427elm_multibuttonentry_item_prepend(Evas_Object *obj, const char *label, void *data) 1426elm_multibuttonentry_item_prepend(Evas_Object *obj, const char *label, void *data)
1428{ 1427{
1429 ELM_CHECK_WIDTYPE(obj, widtype) NULL; 1428 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1430 Widget_Data *wd = elm_widget_data_get(obj);
1431 Elm_Multibuttonentry_Item *item; 1429 Elm_Multibuttonentry_Item *item;
1432 1430 if (!label) return NULL;
1433 if (!wd || !label) return NULL;
1434 item = _add_button_item(obj, label, MULTIBUTTONENTRY_POS_START, NULL, data); 1431 item = _add_button_item(obj, label, MULTIBUTTONENTRY_POS_START, NULL, data);
1435 return item; 1432 return item;
1436} 1433}
@@ -1439,10 +1436,8 @@ EAPI Elm_Multibuttonentry_Item *
1439elm_multibuttonentry_item_append(Evas_Object *obj, const char *label, void *data) 1436elm_multibuttonentry_item_append(Evas_Object *obj, const char *label, void *data)
1440{ 1437{
1441 ELM_CHECK_WIDTYPE(obj, widtype) NULL; 1438 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1442 Widget_Data *wd = elm_widget_data_get(obj);
1443 Elm_Multibuttonentry_Item *item; 1439 Elm_Multibuttonentry_Item *item;
1444 1440 if (!label) return NULL;
1445 if (!wd || !label) return NULL;
1446 item = _add_button_item(obj, label, MULTIBUTTONENTRY_POS_END, NULL, data); 1441 item = _add_button_item(obj, label, MULTIBUTTONENTRY_POS_END, NULL, data);
1447 return item; 1442 return item;
1448} 1443}
@@ -1451,10 +1446,8 @@ EAPI Elm_Multibuttonentry_Item *
1451elm_multibuttonentry_item_insert_before(Evas_Object *obj, Elm_Multibuttonentry_Item *before, const char *label, void *data) 1446elm_multibuttonentry_item_insert_before(Evas_Object *obj, Elm_Multibuttonentry_Item *before, const char *label, void *data)
1452{ 1447{
1453 ELM_CHECK_WIDTYPE(obj, widtype) NULL; 1448 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1454 Widget_Data *wd = elm_widget_data_get(obj);
1455 Elm_Multibuttonentry_Item *item; 1449 Elm_Multibuttonentry_Item *item;
1456 1450 if (!label) return NULL;
1457 if (!wd || !label) return NULL;
1458 item = _add_button_item(obj, label, MULTIBUTTONENTRY_POS_BEFORE, before, data); 1451 item = _add_button_item(obj, label, MULTIBUTTONENTRY_POS_BEFORE, before, data);
1459 return item; 1452 return item;
1460} 1453}
@@ -1463,10 +1456,8 @@ EAPI Elm_Multibuttonentry_Item *
1463elm_multibuttonentry_item_insert_after(Evas_Object *obj, Elm_Multibuttonentry_Item *after, const char *label, void *data) 1456elm_multibuttonentry_item_insert_after(Evas_Object *obj, Elm_Multibuttonentry_Item *after, const char *label, void *data)
1464{ 1457{
1465 ELM_CHECK_WIDTYPE(obj, widtype) NULL; 1458 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1466 Widget_Data *wd = elm_widget_data_get(obj);
1467 Elm_Multibuttonentry_Item *item; 1459 Elm_Multibuttonentry_Item *item;
1468 1460 if (!label) return NULL;
1469 if (!wd || !label) return NULL;
1470 item = _add_button_item(obj, label, MULTIBUTTONENTRY_POS_AFTER, after, data); 1461 item = _add_button_item(obj, label, MULTIBUTTONENTRY_POS_AFTER, after, data);
1471 return item; 1462 return item;
1472} 1463}
@@ -1476,7 +1467,6 @@ elm_multibuttonentry_items_get(const Evas_Object *obj)
1476{ 1467{
1477 ELM_CHECK_WIDTYPE(obj, widtype) NULL; 1468 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1478 Widget_Data *wd = elm_widget_data_get(obj); 1469 Widget_Data *wd = elm_widget_data_get(obj);
1479
1480 if (!wd) return NULL; 1470 if (!wd) return NULL;
1481 return wd->items; 1471 return wd->items;
1482} 1472}
@@ -1486,8 +1476,7 @@ elm_multibuttonentry_first_item_get(const Evas_Object *obj)
1486{ 1476{
1487 ELM_CHECK_WIDTYPE(obj, widtype) NULL; 1477 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1488 Widget_Data *wd = elm_widget_data_get(obj); 1478 Widget_Data *wd = elm_widget_data_get(obj);
1489 1479 if (!wd) return NULL;
1490 if (!wd || !wd->items) return NULL;
1491 return eina_list_data_get(wd->items); 1480 return eina_list_data_get(wd->items);
1492} 1481}
1493 1482
@@ -1496,8 +1485,7 @@ elm_multibuttonentry_last_item_get(const Evas_Object *obj)
1496{ 1485{
1497 ELM_CHECK_WIDTYPE(obj, widtype) NULL; 1486 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1498 Widget_Data *wd = elm_widget_data_get(obj); 1487 Widget_Data *wd = elm_widget_data_get(obj);
1499 1488 if (!wd) return NULL;
1500 if (!wd || !wd->items) return NULL;
1501 return eina_list_data_get(eina_list_last(wd->items)); 1489 return eina_list_data_get(eina_list_last(wd->items));
1502} 1490}
1503 1491
@@ -1506,33 +1494,16 @@ elm_multibuttonentry_selected_item_get(const Evas_Object *obj)
1506{ 1494{
1507 ELM_CHECK_WIDTYPE(obj, widtype) NULL; 1495 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1508 Widget_Data *wd = elm_widget_data_get(obj); 1496 Widget_Data *wd = elm_widget_data_get(obj);
1509 1497 if (!wd) return NULL;
1510 if (!wd || !wd->current) return NULL;
1511 return eina_list_data_get(wd->current); 1498 return eina_list_data_get(wd->current);
1512} 1499}
1513 1500
1514EAPI void 1501EAPI void
1515elm_multibuttonentry_item_select(Elm_Multibuttonentry_Item *item, Eina_Bool selected) 1502elm_multibuttonentry_item_select(Elm_Multibuttonentry_Item *item, Eina_Bool selected)
1516{ 1503{
1517 Widget_Data *wd;
1518 Eina_List *l;
1519 Elm_Multibuttonentry_Item *_item;
1520
1521 if (!item) return; 1504 if (!item) return;
1522 ELM_CHECK_WIDTYPE(WIDGET(item), widtype); 1505 if (selected) _select_button(WIDGET(item), item->button);
1523 wd = elm_widget_data_get(WIDGET(item)); 1506 else _select_button(WIDGET(item), NULL);
1524 if (!wd) return;
1525
1526 EINA_LIST_FOREACH(wd->items, l, _item)
1527 {
1528 if (_item == item)
1529 {
1530 if (selected)
1531 _select_button(WIDGET(item), item->button);
1532 else
1533 _select_button(WIDGET(item), NULL);
1534 }
1535 }
1536} 1507}
1537 1508
1538EAPI void 1509EAPI void
@@ -1541,7 +1512,6 @@ elm_multibuttonentry_item_unselect_all(Evas_Object *obj)
1541 ELM_CHECK_WIDTYPE(obj, widtype); 1512 ELM_CHECK_WIDTYPE(obj, widtype);
1542 Widget_Data *wd = elm_widget_data_get(obj); 1513 Widget_Data *wd = elm_widget_data_get(obj);
1543 if (!wd) return; 1514 if (!wd) return;
1544
1545 _select_button(obj, NULL); 1515 _select_button(obj, NULL);
1546} 1516}
1547 1517
@@ -1549,12 +1519,12 @@ EAPI void
1549elm_multibuttonentry_clear(Evas_Object *obj) 1519elm_multibuttonentry_clear(Evas_Object *obj)
1550{ 1520{
1551 ELM_CHECK_WIDTYPE(obj, widtype); 1521 ELM_CHECK_WIDTYPE(obj, widtype);
1522 Elm_Multibuttonentry_Item *item;
1552 Widget_Data *wd = elm_widget_data_get(obj); 1523 Widget_Data *wd = elm_widget_data_get(obj);
1553 if (!wd) return; 1524 if (!wd) return;
1554 1525
1555 if (wd->items) 1526 if (wd->items)
1556 { 1527 {
1557 Elm_Multibuttonentry_Item *item;
1558 EINA_LIST_FREE(wd->items, item) 1528 EINA_LIST_FREE(wd->items, item)
1559 { 1529 {
1560 elm_box_unpack(wd->box, item->button); 1530 elm_box_unpack(wd->box, item->button);
@@ -1577,41 +1547,16 @@ elm_multibuttonentry_item_del(Elm_Multibuttonentry_Item *item)
1577EAPI const char * 1547EAPI const char *
1578elm_multibuttonentry_item_label_get(const Elm_Multibuttonentry_Item *item) 1548elm_multibuttonentry_item_label_get(const Elm_Multibuttonentry_Item *item)
1579{ 1549{
1580 Widget_Data *wd;
1581 Eina_List *l;
1582 Elm_Multibuttonentry_Item *_item;
1583 if (!item) return NULL; 1550 if (!item) return NULL;
1584 ELM_CHECK_WIDTYPE(WIDGET(item), widtype) NULL; 1551 return edje_object_part_text_get(item->button, "elm.btn.text");
1585 wd = elm_widget_data_get(WIDGET(item));
1586 if (!wd || !wd->items) return NULL;
1587
1588 EINA_LIST_FOREACH(wd->items, l, _item)
1589 {
1590 if (_item == item)
1591 return edje_object_part_text_get(_item->button, "elm.btn.text");
1592 }
1593
1594 return NULL;
1595} 1552}
1596 1553
1597EAPI void 1554EAPI void
1598elm_multibuttonentry_item_label_set(Elm_Multibuttonentry_Item *item, const char *str) 1555elm_multibuttonentry_item_label_set(Elm_Multibuttonentry_Item *item, const char *str)
1599{ 1556{
1600 Widget_Data *wd;
1601 Eina_List *l;
1602 Elm_Multibuttonentry_Item *_item;
1603 if (!item || !str) return; 1557 if (!item || !str) return;
1604 ELM_CHECK_WIDTYPE(WIDGET(item), widtype); 1558 edje_object_part_text_set(item->button, "elm.btn.text", str);
1605 wd = elm_widget_data_get(WIDGET(item)); 1559 _resize_button(item->button, &item->rw, &item->vw);
1606 if (!wd || !wd->items) return;
1607
1608 EINA_LIST_FOREACH(wd->items, l, _item)
1609 if (_item == item)
1610 {
1611 edje_object_part_text_set(_item->button, "elm.btn.text", str);
1612 _resize_button(_item->button, &_item->rw, &_item->vw);
1613 break;
1614 }
1615} 1560}
1616 1561
1617EAPI Elm_Multibuttonentry_Item * 1562EAPI Elm_Multibuttonentry_Item *
@@ -1620,18 +1565,20 @@ elm_multibuttonentry_item_prev_get(const Elm_Multibuttonentry_Item *item)
1620 Widget_Data *wd; 1565 Widget_Data *wd;
1621 Eina_List *l; 1566 Eina_List *l;
1622 Elm_Multibuttonentry_Item *_item; 1567 Elm_Multibuttonentry_Item *_item;
1568
1623 if (!item) return NULL; 1569 if (!item) return NULL;
1624 ELM_CHECK_WIDTYPE(WIDGET(item), widtype) NULL;
1625 wd = elm_widget_data_get(WIDGET(item)); 1570 wd = elm_widget_data_get(WIDGET(item));
1626 if (!wd || !wd->items) return NULL; 1571 ELM_CHECK_WIDTYPE(WIDGET(item), widtype) NULL;
1627 1572
1628 EINA_LIST_FOREACH(wd->items, l, _item) 1573 EINA_LIST_FOREACH(wd->items, l, _item)
1629 if (_item == item) 1574 {
1630 { 1575 if (_item == item)
1631 l = eina_list_prev(l); 1576 {
1632 if (!l) return NULL; 1577 l = eina_list_prev(l);
1633 return eina_list_data_get(l); 1578 if (!l) return NULL;
1634 } 1579 return eina_list_data_get(l);
1580 }
1581 }
1635 return NULL; 1582 return NULL;
1636} 1583}
1637 1584
@@ -1643,17 +1590,18 @@ elm_multibuttonentry_item_next_get(const Elm_Multibuttonentry_Item *item)
1643 Elm_Multibuttonentry_Item *_item; 1590 Elm_Multibuttonentry_Item *_item;
1644 1591
1645 if (!item) return NULL; 1592 if (!item) return NULL;
1646 ELM_CHECK_WIDTYPE(WIDGET(item), widtype) NULL;
1647 wd = elm_widget_data_get(WIDGET(item)); 1593 wd = elm_widget_data_get(WIDGET(item));
1648 if (!wd || !wd->items) return NULL; 1594 ELM_CHECK_WIDTYPE(WIDGET(item), widtype) NULL;
1649 1595
1650 EINA_LIST_FOREACH(wd->items, l, _item) 1596 EINA_LIST_FOREACH(wd->items, l, _item)
1651 if (_item == item) 1597 {
1652 { 1598 if (_item == item)
1653 l = eina_list_next(l); 1599 {
1654 if (!l) return NULL; 1600 l = eina_list_next(l);
1655 return eina_list_data_get(l); 1601 if (!l) return NULL;
1656 } 1602 return eina_list_data_get(l);
1603 }
1604 }
1657 return NULL; 1605 return NULL;
1658} 1606}
1659 1607
@@ -1661,14 +1609,14 @@ EAPI void *
1661elm_multibuttonentry_item_data_get(const Elm_Multibuttonentry_Item *item) 1609elm_multibuttonentry_item_data_get(const Elm_Multibuttonentry_Item *item)
1662{ 1610{
1663 if (!item) return NULL; 1611 if (!item) return NULL;
1664 return item->data; 1612 return elm_widget_item_data_get(item);
1665} 1613}
1666 1614
1667EAPI void 1615EAPI void
1668elm_multibuttonentry_item_data_set(Elm_Multibuttonentry_Item *item, void *data) 1616elm_multibuttonentry_item_data_set(Elm_Multibuttonentry_Item *item, void *data)
1669{ 1617{
1670 if (!item) return; 1618 if (!item) return;
1671 item->data = data; 1619 return elm_widget_item_data_set(item, data);
1672} 1620}
1673 1621
1674EAPI void 1622EAPI void