summaryrefslogtreecommitdiff
path: root/lib/common/Ui/Genlist/Item.cpp
blob: c43982f804d2c7cb1bd51de81c89f154c4354a9a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
/*
 * Copyright 2012-2013 Samsung Electronics Co., Ltd
 *
 * Licensed under the Flora License, Version 1.1 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://floralicense.org/license/
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#include "Item.h"
#include "phone.h"

namespace Ui
{
    namespace Genlist
    {
        Item::Item(Elm_Genlist_Item_Type type)
            : m_Type(type)
        {
            PH_TRACE;
        }

        Item::~Item()
        {
            PH_TRACE;
        }

        Elm_Genlist_Item_Class * Item::createClass(const char *style, const char *decorateStyle, const char *editStyle)
        {
            PH_TRACE;
            Elm_Genlist_Item_Class *itemClass = elm_genlist_item_class_new();
            check_if(!itemClass, return NULL);
            itemClass->item_style = style;
            itemClass->decorate_item_style = decorateStyle;
            itemClass->decorate_all_item_style = editStyle;
            itemClass->func.text_get = Item::getText;
            itemClass->func.content_get = Item::getContent;
            itemClass->func.state_get = Item::getState;
            itemClass->func.del = Item::onDestroy;
            return itemClass;
        }

        char * Item::getText(void *data, Evas_Object *obj, const char *part)
        {
            PH_TRACE;
            if(data)
            {
                return static_cast<Item *>(data)->getText(part);
            }

            return NULL;
        }

        Evas_Object * Item::getContent(void *data, Evas_Object *obj, const char *part)
        {
            PH_TRACE;
            if(data)
            {
                return static_cast<Item *>(data)->getContent(part, obj);
            }

            return NULL;
        }

        Eina_Bool Item::getState(void *data, Evas_Object *obj, const char *part)
        {
            PH_TRACE;
            if(data)
            {
                return static_cast<Item *>(data)->getState(part);
            }

            return EINA_FALSE;
        }

        void Genlist::Item::onDestroy(void *data, Evas_Object *obj)
        {
            PH_TRACE;
            if(data)
            {
                delete static_cast<Item *>(data);
            }
        }
    }
}