Tizen 2.1 base
[framework/osp/uifw.git] / src / ui / controls / FUiCtrl_CustomElement.cpp
1 //
2 // Open Service Platform
3 // Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
4 //
5 // Licensed under the Flora License, Version 1.0 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
8 //
9 //     http://floralicense.org/license/
10 //
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an AS IS BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
16 //
17
18 /**
19  * @file        FUiCtrl_CustomElement.cpp
20  * @brief       This is the implementation file for _CustomElement class.
21  *
22  * This file contains the implementation of _CustomElement class.
23  */
24
25 #include <FBaseSysLog.h>
26 #include <FUiCtrlICustomElement.h>
27 #include "FUiCtrl_CustomElement.h"
28
29 #ifdef MEMORY_LEAK_CHECK
30 #include "mem_leak_check.h"
31 #endif
32
33 using namespace Tizen::Graphics;
34
35 namespace Tizen { namespace Ui { namespace Controls
36 {
37
38 _CustomElement::_CustomElement(int elementId)
39         : __pElement(null)
40         , __elementId(elementId)
41 {
42 }
43
44 _CustomElement::~_CustomElement(void)
45 {
46 }
47
48 int
49 _CustomElement::GetElementId(void) const
50 {
51         return __elementId;
52 }
53
54 bool
55 _CustomElement::DrawElement(Canvas* pCanvas, Rectangle& rect, ListViewItemDrawingStatus status)
56 {
57         bool result = true;
58         switch (status)
59         {
60         case LISTVIEW_ITEM_STATUS_NORMAL:
61                 result = __pElement->OnDraw(*pCanvas, rect, LIST_ITEM_DRAWING_STATUS_NORMAL);
62                 break;
63
64         case LISTVIEW_ITEM_STATUS_PRESSED:
65                 result = __pElement->OnDraw(*pCanvas, rect, LIST_ITEM_DRAWING_STATUS_PRESSED);
66                 break;
67
68         case LISTVIEW_ITEM_STATUS_HIGHLIGHTED:
69                 result = __pElement->OnDraw(*pCanvas, rect, LIST_ITEM_DRAWING_STATUS_HIGHLIGHTED);
70                 break;
71
72         default:
73                 result = __pElement->OnDraw(*pCanvas, rect, LIST_ITEM_DRAWING_STATUS_NORMAL);
74                 break;
75         }
76
77         return result;
78 }
79
80 void
81 _CustomElement::SetElement(const ICustomElement& element)
82 {
83         __pElement = const_cast <ICustomElement*>(&element);
84 }
85
86 }}} // Tizen::Ui::Controls