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 FUiCtrlCustomListItem.cpp
20 * @brief This file contains implementation of CustomListItem class
23 #include <FGrpBitmap.h>
24 #include <FGrpRectangle.h>
25 #include <FUiCtrlCustomListItem.h>
26 #include <FUiCtrlCustomListItemFormat.h>
27 #include <FBaseSysLog.h>
28 #include "FUiCtrl_CustomListItemImpl.h"
30 using namespace Tizen::Base;
31 using namespace Tizen::Graphics;
33 namespace Tizen { namespace Ui { namespace Controls
36 CustomListItem::CustomListItem(void)
37 : __pCustomListItemFormat(null)
38 , __pCustomListItemImpl(null)
42 CustomListItem::~CustomListItem(void)
44 delete __pCustomListItemImpl;
45 __pCustomListItemImpl = null;
49 CustomListItem::Construct(int itemHeight)
53 SysAssertf((__pCustomListItemImpl == null),
54 "Already constructed. Calling Construct() twice or more on a same instance is not allowed for thisclass.");
56 __pCustomListItemImpl = _CustomListItemImpl::CreateInstanceN(itemHeight);
58 SysTryReturn(NID_UI_CTRL, __pCustomListItemImpl, r, r, "[%s] Propagating.", GetErrorMessage(r));
64 CustomListItem::SetItemFormat(const CustomListItemFormat& itemFormat)
66 SysAssertf((__pCustomListItemImpl != null), "Not yet constructed. Construct() should be called before use.");
67 __pCustomListItemFormat = const_cast< CustomListItemFormat* >(&itemFormat);
70 const CustomListItemFormat*
71 CustomListItem::GetItemFormat(void) const
73 return __pCustomListItemFormat;
77 CustomListItem::SetFocusedItemBackgroundBitmap(const Bitmap& bitmap)
79 SysAssertf((__pCustomListItemImpl != null), "Not yet constructed. Construct() should be called before use.");
80 __pCustomListItemImpl->SetFocusedItemBackgroundBitmap(bitmap);
84 CustomListItem::SetNormalItemBackgroundBitmap(const Bitmap& bitmap)
86 SysAssertf((__pCustomListItemImpl != null), "Not yet constructed. Construct() should be called before use.");
87 __pCustomListItemImpl->SetNormalItemBackgroundBitmap(bitmap);
91 CustomListItem::SetHighlightedItemBackgroundBitmap(const Bitmap& bitmap)
93 SysAssertf((__pCustomListItemImpl != null), "Not yet constructed. Construct() should be called before use.");
94 __pCustomListItemImpl->SetHighlightedItemBackgroundBitmap(bitmap);
98 CustomListItem::SetElement(int elementId, const String& text)
100 SysAssertf((__pCustomListItemImpl != null), "Not yet constructed. Construct() should be called before use.");
101 result r = __pCustomListItemImpl->SetElement(elementId, text);
102 SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Failed to Set an Element.", GetErrorMessage(r));
108 CustomListItem::SetElement(int elementId, const Bitmap& normalBitmap, const Bitmap* pFocusedBitmap)
110 SysAssertf((__pCustomListItemImpl != null), "Not yet constructed. Construct() should be called before use.");
112 result r = __pCustomListItemImpl->SetElement(elementId, normalBitmap, pFocusedBitmap);
113 SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Failed to Set an Element.", GetErrorMessage(r));
119 CustomListItem::SetElement(int elementId, const Bitmap& normalBitmap, const Bitmap* pFocusedBitmap, const Bitmap* pHighlightedBitmap)
121 SysAssertf((__pCustomListItemImpl != null), "Not yet constructed. Construct() should be called before use.");
123 result r = __pCustomListItemImpl->SetElement(elementId, normalBitmap, pFocusedBitmap, pHighlightedBitmap);
124 SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Failed to Set an Element.", GetErrorMessage(r));
130 CustomListItem::SetElement(int elementId, const ICustomListElement& element)
132 SysAssertf((__pCustomListItemImpl != null), "Not yet constructed. Construct() should be called before use.");
134 result r = __pCustomListItemImpl->SetElement(elementId, element);
135 SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Failed to Set an Element.", GetErrorMessage(r));
141 CustomListItem::SetCheckBox(int elementId)
143 SysAssertf((__pCustomListItemImpl != null), "Not yet constructed. Construct() should be called before use.");
145 SysTryReturnResult(NID_UI_CTRL, __pCustomListItemFormat, E_SYSTEM, "The CustomListItemFormat is not constructed.");
147 if (__pCustomListItemFormat->GetElement(elementId) == Rectangle(0, 0, -1, -1))
152 __pCustomListItemImpl->SetCheckBox(elementId);
158 CustomListItem::GetValue(void) const
160 SysAssertf((__pCustomListItemImpl != null), "Not yet constructed. Construct() should be called before use.");
164 }}} //Tizen::Ui::Controls