Changed indicator bg color.
[platform/framework/native/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 Apache License, Version 2.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://www.apache.org/licenses/LICENSE-2.0/
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 <FUiCtrlICustomElementF.h>
28 #include "FUi_CoordinateSystemUtils.h"
29 #include "FUiCtrl_CustomElement.h"
30
31 #ifdef MEMORY_LEAK_CHECK
32 #include "mem_leak_check.h"
33 #endif
34
35 using namespace Tizen::Graphics;
36
37 namespace Tizen { namespace Ui { namespace Controls
38 {
39
40 _CustomElement::_CustomElement(int elementId)
41         : __pElement(null)
42         , __pElementF(null)
43         , __elementId(elementId)
44         , __usingFloatingPoint(false)
45 {
46 }
47
48 _CustomElement::~_CustomElement(void)
49 {
50 }
51
52 int
53 _CustomElement::GetElementId(void) const
54 {
55         return __elementId;
56 }
57
58 bool
59 _CustomElement::DrawElement(Canvas* pCanvas, FloatRectangle& rect, ListViewItemDrawingStatus status)
60 {
61         bool result = true;
62
63         if (__usingFloatingPoint)
64         {
65                 switch (status)
66                 {
67                 case LISTVIEW_ITEM_STATUS_NORMAL:
68                         result = __pElementF->OnDraw(*pCanvas, rect, LIST_ITEM_DRAWING_STATUS_NORMAL);
69                         break;
70
71                 case LISTVIEW_ITEM_STATUS_PRESSED:
72                         result = __pElementF->OnDraw(*pCanvas, rect, LIST_ITEM_DRAWING_STATUS_PRESSED);
73                         break;
74
75                 case LISTVIEW_ITEM_STATUS_HIGHLIGHTED:
76                         result = __pElementF->OnDraw(*pCanvas, rect, LIST_ITEM_DRAWING_STATUS_HIGHLIGHTED);
77                         break;
78
79                 default:
80                         result = __pElementF->OnDraw(*pCanvas, rect, LIST_ITEM_DRAWING_STATUS_NORMAL);
81                         break;
82                 }
83         }
84         else
85         {
86                 switch (status)
87                 {
88                 case LISTVIEW_ITEM_STATUS_NORMAL:
89                         result = __pElement->OnDraw(*pCanvas, _CoordinateSystemUtils::ConvertToInteger(rect), LIST_ITEM_DRAWING_STATUS_NORMAL);
90                         break;
91
92                 case LISTVIEW_ITEM_STATUS_PRESSED:
93                         result = __pElement->OnDraw(*pCanvas, _CoordinateSystemUtils::ConvertToInteger(rect), LIST_ITEM_DRAWING_STATUS_PRESSED);
94                         break;
95
96                 case LISTVIEW_ITEM_STATUS_HIGHLIGHTED:
97                         result = __pElement->OnDraw(*pCanvas, _CoordinateSystemUtils::ConvertToInteger(rect), LIST_ITEM_DRAWING_STATUS_HIGHLIGHTED);
98                         break;
99
100                 default:
101                         result = __pElement->OnDraw(*pCanvas, _CoordinateSystemUtils::ConvertToInteger(rect), LIST_ITEM_DRAWING_STATUS_NORMAL);
102                         break;
103                 }
104         }
105
106         return result;
107 }
108
109 void
110 _CustomElement::SetElement(const ICustomElement& element)
111 {
112         __usingFloatingPoint = false;
113         __pElement = const_cast <ICustomElement*>(&element);
114 }
115
116 void
117 _CustomElement::SetElement(const ICustomElementF& element)
118 {
119         __usingFloatingPoint = true;
120         __pElementF = const_cast <ICustomElementF*>(&element);
121 }
122
123 }}} // Tizen::Ui::Controls