2 // Open Service Platform
3 // Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
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
9 // http://www.apache.org/licenses/LICENSE-2.0/
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.
19 * @file FUiCtrlCustomItem.cpp
20 * @brief This is the implementation file for CustomItem class.
22 * This file contains the implementation of CustomItem class.
25 #include <FBaseSysLog.h>
26 #include <FUiCtrlCustomItem.h>
27 #include "FUiCtrl_CustomItemImpl.h"
28 #include "FUi_CoordinateSystemUtils.h"
30 using namespace Tizen::Base;
31 using namespace Tizen::Graphics;
33 namespace Tizen { namespace Ui { namespace Controls
36 CustomItem::CustomItem(void)
40 CustomItem::~CustomItem(void)
45 CustomItem::Construct(const Dimension& itemSize, ListAnnexStyle style)
47 return Construct(_CoordinateSystemUtils::ConvertToFloat(itemSize), style);
51 CustomItem::Construct(const FloatDimension& itemSize, ListAnnexStyle style)
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.");
59 pCustomImpl = _CustomItemImpl::CreateCustomItemImplN(this, itemSize, style);
60 SysTryReturn(NID_UI_CTRL, pCustomImpl != null, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
69 CustomItem::AddElement(const Rectangle& rect, int elementId, const EnrichedText& text)
71 _CustomItemImpl* pImpl = static_cast<_CustomItemImpl*>(_ListItemBaseImpl::GetInstance(*this));
72 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
74 return pImpl->AddElement(_CoordinateSystemUtils::ConvertToFloat(rect), elementId, text);
78 CustomItem::AddElement(const FloatRectangle& rect, int elementId, const EnrichedText& text)
80 _CustomItemImpl* pImpl = static_cast<_CustomItemImpl*>(_ListItemBaseImpl::GetInstance(*this));
81 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
83 return pImpl->AddElement(rect, elementId, text);
88 CustomItem::AddElement(const Rectangle& rect, int elementId, const String& text, bool textSliding)
90 _CustomItemImpl* pImpl = static_cast<_CustomItemImpl*>(_ListItemBaseImpl::GetInstance(*this));
91 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
93 return pImpl->AddElement(_CoordinateSystemUtils::ConvertToFloat(rect), elementId, text, textSliding);
97 CustomItem::AddElement(const FloatRectangle& rect, int elementId, const String& text, bool textSliding)
99 _CustomItemImpl* pImpl = static_cast<_CustomItemImpl*>(_ListItemBaseImpl::GetInstance(*this));
100 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
102 return pImpl->AddElement(rect, elementId, text, textSliding);
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)
109 _CustomItemImpl* pImpl = static_cast<_CustomItemImpl*>(_ListItemBaseImpl::GetInstance(*this));
110 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
112 return pImpl->AddElement(_CoordinateSystemUtils::ConvertToFloat(rect), elementId, text, textSize, normalTextColor,
113 pressedTextColor, highlightedTextColor, textSliding);
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)
120 _CustomItemImpl* pImpl = static_cast<_CustomItemImpl*>(_ListItemBaseImpl::GetInstance(*this));
121 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
123 return pImpl->AddElement(rect, elementId, text, textSize, normalTextColor,
124 pressedTextColor, highlightedTextColor, textSliding);
128 CustomItem::AddElement(const Rectangle& rect, int elementId, const Bitmap& normalBitmap, const Bitmap* pPressedBitmap,
129 const Bitmap* pHighlightedbitmap)
131 _CustomItemImpl* pImpl = static_cast<_CustomItemImpl*>(_ListItemBaseImpl::GetInstance(*this));
132 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
134 return pImpl->AddElement(_CoordinateSystemUtils::ConvertToFloat(rect), elementId, normalBitmap, pPressedBitmap, pHighlightedbitmap);
138 CustomItem::AddElement(const FloatRectangle& rect, int elementId, const Bitmap& normalBitmap, const Bitmap* pPressedBitmap,
139 const Bitmap* pHighlightedbitmap)
141 _CustomItemImpl* pImpl = static_cast<_CustomItemImpl*>(_ListItemBaseImpl::GetInstance(*this));
142 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
144 return pImpl->AddElement(rect, elementId, normalBitmap, pPressedBitmap, pHighlightedbitmap);
148 CustomItem::AddElement(const Rectangle& rect, int elementId, const ICustomElement& element)
150 _CustomItemImpl* pImpl = static_cast<_CustomItemImpl*>(_ListItemBaseImpl::GetInstance(*this));
151 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
153 return pImpl->AddElement(_CoordinateSystemUtils::ConvertToFloat(rect), elementId, element);
157 CustomItem::AddElement(const Rectangle& rect, int elementId, ICustomElement& element)
159 _CustomItemImpl* pImpl = static_cast<_CustomItemImpl*>(_ListItemBaseImpl::GetInstance(*this));
160 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
162 return pImpl->AddElement(_CoordinateSystemUtils::ConvertToFloat(rect), elementId, element);
166 CustomItem::AddElement(const FloatRectangle& rect, int elementId, ICustomElementF& element)
168 _CustomItemImpl* pImpl = static_cast<_CustomItemImpl*>(_ListItemBaseImpl::GetInstance(*this));
169 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
171 return pImpl->AddElement(rect, elementId, element);
175 CustomItem::RemoveAllElements(void)
177 _CustomItemImpl* pImpl = static_cast<_CustomItemImpl*>(_ListItemBaseImpl::GetInstance(*this));
178 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
180 return pImpl->RemoveAllElements();
184 CustomItem::RemoveElement(int elementId)
186 _CustomItemImpl* pImpl = static_cast<_CustomItemImpl*>(_ListItemBaseImpl::GetInstance(*this));
187 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
189 return pImpl->RemoveElement(elementId);
193 CustomItem::SetElementSelectionEnabled(int elementId, bool enable)
195 _CustomItemImpl* pImpl = static_cast<_CustomItemImpl*>(_ListItemBaseImpl::GetInstance(*this));
196 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
198 return pImpl->SetElementSelectionEnabled(elementId, enable);
202 CustomItem::SetElementTextHorizontalAlignment(int elementId, HorizontalAlignment alignment)
204 _CustomItemImpl* pImpl = static_cast<_CustomItemImpl*>(_ListItemBaseImpl::GetInstance(*this));
205 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
207 return pImpl->SetElementTextHorizontalAlignment(elementId, alignment);
211 CustomItem::SetElementTextVerticalAlignment(int elementId, VerticalAlignment alignment)
213 _CustomItemImpl* pImpl = static_cast<_CustomItemImpl*>(_ListItemBaseImpl::GetInstance(*this));
214 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
216 return pImpl->SetElementTextVerticalAlignment(elementId, alignment);
220 CustomItem::SetElementAutoLinkMask(int elementId, unsigned long mask)
222 _CustomItemImpl* pImpl = static_cast<_CustomItemImpl*>(_ListItemBaseImpl::GetInstance(*this));
223 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
225 return pImpl->SetElementAutoLinkMask(elementId, mask);
228 }}} // Tizen::Ui::Controls