Changed indicator bg color.
[platform/framework/native/uifw.git] / src / ui / controls / FUiCtrlCustomItem.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        FUiCtrlCustomItem.cpp
20  * @brief       This is the implementation file for CustomItem class.
21  *
22  * This file contains the implementation of CustomItem class.
23  */
24
25 #include <FBaseSysLog.h>
26 #include <FUiCtrlCustomItem.h>
27 #include "FUiCtrl_CustomItemImpl.h"
28 #include "FUi_CoordinateSystemUtils.h"
29
30 using namespace Tizen::Base;
31 using namespace Tizen::Graphics;
32
33 namespace Tizen { namespace Ui { namespace Controls
34 {
35
36 CustomItem::CustomItem(void)
37 {
38 }
39
40 CustomItem::~CustomItem(void)
41 {
42 }
43
44 result
45 CustomItem::Construct(const Dimension& itemSize, ListAnnexStyle style)
46 {
47         return Construct(_CoordinateSystemUtils::ConvertToFloat(itemSize), style);
48 }
49
50 result
51 CustomItem::Construct(const FloatDimension& itemSize, ListAnnexStyle style)
52 {
53         result r = E_SUCCESS;
54
55         _CustomItemImpl* pCustomImpl = static_cast<_CustomItemImpl*>(_ListItemBaseImpl::GetInstance(*this));
56         SysAssertf(pCustomImpl == null,
57                                   "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class.");
58
59         pCustomImpl = _CustomItemImpl::CreateCustomItemImplN(this, itemSize, style);
60         SysTryReturn(NID_UI_CTRL, pCustomImpl != null, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
61
62         _pImpl = pCustomImpl;
63
64         return r;
65
66 }
67
68 result
69 CustomItem::AddElement(const Rectangle& rect, int elementId, const EnrichedText& text)
70 {
71         _CustomItemImpl* pImpl = static_cast<_CustomItemImpl*>(_ListItemBaseImpl::GetInstance(*this));
72         SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
73
74         return pImpl->AddElement(_CoordinateSystemUtils::ConvertToFloat(rect), elementId, text);
75 }
76
77 result
78 CustomItem::AddElement(const FloatRectangle& rect, int elementId, const EnrichedText& text)
79 {
80         _CustomItemImpl* pImpl = static_cast<_CustomItemImpl*>(_ListItemBaseImpl::GetInstance(*this));
81         SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
82
83         return pImpl->AddElement(rect, elementId, text);
84
85 }
86
87 result
88 CustomItem::AddElement(const Rectangle& rect, int elementId, const String& text, bool textSliding)
89 {
90         _CustomItemImpl* pImpl = static_cast<_CustomItemImpl*>(_ListItemBaseImpl::GetInstance(*this));
91         SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
92
93         return pImpl->AddElement(_CoordinateSystemUtils::ConvertToFloat(rect), elementId, text, textSliding);
94 }
95
96 result
97 CustomItem::AddElement(const FloatRectangle& rect, int elementId, const String& text, bool textSliding)
98 {
99         _CustomItemImpl* pImpl = static_cast<_CustomItemImpl*>(_ListItemBaseImpl::GetInstance(*this));
100         SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
101
102         return pImpl->AddElement(rect, elementId, text, textSliding);
103 }
104
105 result
106 CustomItem::AddElement(const Rectangle& rect, int elementId, const String& text, int textSize, const Color& normalTextColor,
107                 const Color& pressedTextColor, const Color& highlightedTextColor, bool textSliding)
108 {
109         _CustomItemImpl* pImpl = static_cast<_CustomItemImpl*>(_ListItemBaseImpl::GetInstance(*this));
110         SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
111
112         return pImpl->AddElement(_CoordinateSystemUtils::ConvertToFloat(rect), elementId, text, textSize, normalTextColor,
113                                                          pressedTextColor, highlightedTextColor, textSliding);
114 }
115
116 result
117 CustomItem::AddElement(const FloatRectangle& rect, int elementId, const String& text, float textSize,
118                 const Color& normalTextColor, const Color& pressedTextColor, const Color& highlightedTextColor, bool textSliding)
119 {
120         _CustomItemImpl* pImpl = static_cast<_CustomItemImpl*>(_ListItemBaseImpl::GetInstance(*this));
121         SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
122
123         return pImpl->AddElement(rect, elementId, text, textSize, normalTextColor,
124                                                          pressedTextColor, highlightedTextColor, textSliding);
125 }
126
127 result
128 CustomItem::AddElement(const Rectangle& rect, int elementId, const Bitmap& normalBitmap, const Bitmap* pPressedBitmap,
129                 const Bitmap* pHighlightedbitmap)
130 {
131         _CustomItemImpl* pImpl = static_cast<_CustomItemImpl*>(_ListItemBaseImpl::GetInstance(*this));
132         SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
133
134         return pImpl->AddElement(_CoordinateSystemUtils::ConvertToFloat(rect), elementId, normalBitmap, pPressedBitmap, pHighlightedbitmap);
135 }
136
137 result
138 CustomItem::AddElement(const FloatRectangle& rect, int elementId, const Bitmap& normalBitmap, const Bitmap* pPressedBitmap,
139                 const Bitmap* pHighlightedbitmap)
140 {
141         _CustomItemImpl* pImpl = static_cast<_CustomItemImpl*>(_ListItemBaseImpl::GetInstance(*this));
142         SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
143
144         return pImpl->AddElement(rect, elementId, normalBitmap, pPressedBitmap, pHighlightedbitmap);
145 }
146
147 result
148 CustomItem::AddElement(const Rectangle& rect, int elementId, const ICustomElement& element)
149 {
150         _CustomItemImpl* pImpl = static_cast<_CustomItemImpl*>(_ListItemBaseImpl::GetInstance(*this));
151         SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
152
153         return pImpl->AddElement(_CoordinateSystemUtils::ConvertToFloat(rect), elementId, element);
154 }
155
156 result
157 CustomItem::AddElement(const Rectangle& rect, int elementId, ICustomElement& element)
158 {
159         _CustomItemImpl* pImpl = static_cast<_CustomItemImpl*>(_ListItemBaseImpl::GetInstance(*this));
160         SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
161
162         return pImpl->AddElement(_CoordinateSystemUtils::ConvertToFloat(rect), elementId, element);
163 }
164
165 result
166 CustomItem::AddElement(const FloatRectangle& rect, int elementId, ICustomElementF& element)
167 {
168         _CustomItemImpl* pImpl = static_cast<_CustomItemImpl*>(_ListItemBaseImpl::GetInstance(*this));
169         SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
170
171         return pImpl->AddElement(rect, elementId, element);
172 }
173
174 result
175 CustomItem::RemoveAllElements(void)
176 {
177         _CustomItemImpl* pImpl = static_cast<_CustomItemImpl*>(_ListItemBaseImpl::GetInstance(*this));
178         SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
179
180         return pImpl->RemoveAllElements();
181 }
182
183 result
184 CustomItem::RemoveElement(int elementId)
185 {
186         _CustomItemImpl* pImpl = static_cast<_CustomItemImpl*>(_ListItemBaseImpl::GetInstance(*this));
187         SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
188
189         return pImpl->RemoveElement(elementId);
190 }
191
192 result
193 CustomItem::SetElementSelectionEnabled(int elementId, bool enable)
194 {
195         _CustomItemImpl* pImpl = static_cast<_CustomItemImpl*>(_ListItemBaseImpl::GetInstance(*this));
196         SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
197
198         return pImpl->SetElementSelectionEnabled(elementId, enable);
199 }
200
201 result
202 CustomItem::SetElementTextHorizontalAlignment(int elementId, HorizontalAlignment alignment)
203 {
204         _CustomItemImpl* pImpl = static_cast<_CustomItemImpl*>(_ListItemBaseImpl::GetInstance(*this));
205         SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
206
207         return pImpl->SetElementTextHorizontalAlignment(elementId, alignment);
208 }
209
210 result
211 CustomItem::SetElementTextVerticalAlignment(int elementId, VerticalAlignment alignment)
212 {
213         _CustomItemImpl* pImpl = static_cast<_CustomItemImpl*>(_ListItemBaseImpl::GetInstance(*this));
214         SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
215
216         return pImpl->SetElementTextVerticalAlignment(elementId, alignment);
217 }
218
219 result
220 CustomItem::SetElementAutoLinkMask(int elementId, unsigned long mask)
221 {
222         _CustomItemImpl* pImpl = static_cast<_CustomItemImpl*>(_ListItemBaseImpl::GetInstance(*this));
223         SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
224
225         return pImpl->SetElementAutoLinkMask(elementId, mask);
226 }
227
228 }}} // Tizen::Ui::Controls