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 FUiCtrlCustomList.cpp
20 * @brief This file contains implementation of CustomList class
24 #include <FUiCtrlCustomList.h>
25 #include <FBaseSysLog.h>
26 #include "FUiCtrl_CustomListImpl.h"
28 using namespace Tizen::Ui;
29 using namespace Tizen::Base;
30 using namespace Tizen::Graphics;
32 namespace Tizen { namespace Ui { namespace Controls
35 CustomList::CustomList(void)
39 CustomList::~CustomList(void)
44 CustomList::Construct(const Rectangle& rect, CustomListStyle style, bool itemDivider)
48 _CustomListImpl* pCustomListImpl = _CustomListImpl::GetInstance(*this);
49 SysAssertf((pCustomListImpl == null), "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class.");
51 pCustomListImpl = _CustomListImpl::CreateCustomListImplN(this, rect, itemDivider);
53 SysTryReturn(NID_UI_CTRL, pCustomListImpl, r, r, "[%s] Propagating.", GetErrorMessage(r));
55 _pControlImpl = pCustomListImpl;
57 r = pCustomListImpl->InitializeBounds(rect);
58 SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r));
60 r = pCustomListImpl->SetListStyle(style);
61 SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , E_SYSTEM, "[E_SYSTEM] A system error occurred.");
63 r = pCustomListImpl->Initialize();
64 SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , E_SYSTEM, "[E_SYSTEM] A system error occurred.");
66 r = pCustomListImpl->LoadDefaultBitmap();
67 SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , E_SYSTEM, "[E_SYSTEM] A system error occurred.");
77 CustomList::AddCustomItemEventListener(ICustomItemEventListener& listener)
79 _CustomListImpl* pImpl = _CustomListImpl::GetInstance(*this);
80 SysAssertf((pImpl != null), "Not yet constructed. Construct() should be called before use.");
82 result r = pImpl->AddCustomItemEventListener(listener);
83 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
87 CustomList::RemoveCustomItemEventListener(ICustomItemEventListener& listener)
89 _CustomListImpl* pImpl = _CustomListImpl::GetInstance(*this);
90 SysAssertf((pImpl != null), "Not yet constructed. Construct() should be called before use.");
92 result r = pImpl->RemoveCustomItemEventListener(listener);
93 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
97 CustomList::AddItem(const CustomListItem& item, int itemId)
99 _CustomListImpl* pImpl = _CustomListImpl::GetInstance(*this);
100 SysAssertf((pImpl != null), "Not yet constructed. Construct() should be called before use.");
102 result r = pImpl->AddItem(item, itemId);
103 SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Failed to add an item.", GetErrorMessage(r));
109 CustomList::InsertItemAt(int index, const CustomListItem& item, int itemId)
111 _CustomListImpl* pImpl = _CustomListImpl::GetInstance(*this);
112 SysAssertf((pImpl != null), "Not yet constructed. Construct() should be called before use.");
114 result r = pImpl->InsertItemAt(index, item, itemId);
115 SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Failed to insert an item.", GetErrorMessage(r));
121 CustomList::SetItemAt(int index, const CustomListItem& item, int itemId)
123 _CustomListImpl* pImpl = _CustomListImpl::GetInstance(*this);
124 SysAssertf((pImpl != null), "Not yet constructed. Construct() should be called before use.");
126 result r = pImpl->SetItemAt(index, item, itemId);
127 SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Failed to set an item.", GetErrorMessage(r));
133 CustomList::RemoveItemAt(int index)
135 _CustomListImpl* pImpl = _CustomListImpl::GetInstance(*this);
136 SysAssertf((pImpl != null), "Not yet constructed. Construct() should be called before use.");
138 result r = pImpl->RemoveItemAt(index);
139 SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Failed to remove an item.", GetErrorMessage(r));
145 CustomList::RemoveAllItems(void)
147 _CustomListImpl* pImpl = _CustomListImpl::GetInstance(*this);
148 SysAssertf((pImpl != null), "Not yet constructed. Construct() should be called before use.");
150 result r = pImpl->RemoveAllItems();
151 SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Failed to remove all items.", GetErrorMessage(r));
156 const CustomListItem*
157 CustomList::GetItemAt(int index) const
159 const _CustomListImpl* pImpl = _CustomListImpl::GetInstance(*this);
160 SysAssertf((pImpl != null), "Not yet constructed. Construct() should be called before use.");
162 const CustomListItem* pItem = pImpl->GetCustomListItemAt(-1, index);
167 CustomList::GetItemCount(void) const
169 const _CustomListImpl* pImpl = _CustomListImpl::GetInstance(*this);
170 SysAssertf((pImpl != null), "Not yet constructed. Construct() should be called before use.");
172 return pImpl->GetItemCount();
176 CustomList::SetItemEnabled(int index, bool enable)
178 _CustomListImpl* pImpl = _CustomListImpl::GetInstance(*this);
179 SysAssertf((pImpl != null), "Not yet constructed. Construct() should be called before use.");
181 result r = pImpl->SetItemEnabled(index, enable);
182 SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Failed to SetItemEnabled.", GetErrorMessage(r));
188 CustomList::IsItemEnabled(int index) const
190 const _CustomListImpl* pImpl = _CustomListImpl::GetInstance(*this);
191 SysAssertf((pImpl != null), "Not yet constructed. Construct() should be called before use.");
193 return pImpl->IsItemEnabled(index);
197 CustomList::SetItemChecked(int index, bool check)
199 _CustomListImpl* pImpl = _CustomListImpl::GetInstance(*this);
200 SysAssertf((pImpl != null), "Not yet constructed. Construct() should be called before use.");
202 result r = pImpl->SetItemChecked(index, check);
203 SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Failed to SetItemChecked.", GetErrorMessage(r));
209 CustomList::IsItemChecked(int index) const
211 const _CustomListImpl* pImpl = _CustomListImpl::GetInstance(*this);
212 SysAssertf((pImpl != null), "Not yet constructed. Construct() should be called before use.");
214 return pImpl->IsItemChecked(index);
218 CustomList::SetAllItemsChecked(bool check)
220 _CustomListImpl* pImpl = _CustomListImpl::GetInstance(*this);
221 SysAssertf((pImpl != null), "Not yet constructed. Construct() should be called before use.");
223 result r = pImpl->SetAllItemsChecked(check);
224 SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Failed to SetAllItemsChecked.", GetErrorMessage(r));
230 CustomList::RemoveAllCheckedItems(void)
232 _CustomListImpl* pImpl = _CustomListImpl::GetInstance(*this);
233 SysAssertf((pImpl != null), "Not yet constructed. Construct() should be called before use.");
235 result r = pImpl->RemoveAllCheckedItems();
236 SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Failed to SetAllItemsChecked.", GetErrorMessage(r));
242 CustomList::GetFirstCheckedItemIndex(void) const
244 const _CustomListImpl* pImpl = _CustomListImpl::GetInstance(*this);
245 SysAssertf((pImpl != null), "Not yet constructed. Construct() should be called before use.");
247 return pImpl->GetFirstCheckedItemIndex();
251 CustomList::GetLastCheckedItemIndex(void) const
253 const _CustomListImpl* pImpl = _CustomListImpl::GetInstance(*this);
254 SysAssertf((pImpl != null), "Not yet constructed. Construct() should be called before use.");
256 return pImpl->GetLastCheckedItemIndex();
260 CustomList::GetNextCheckedItemIndexAfter(int index) const
262 const _CustomListImpl* pImpl = _CustomListImpl::GetInstance(*this);
263 SysAssertf((pImpl != null), "Not yet constructed. Construct() should be called before use.");
265 return pImpl->GetNextCheckedItemIndexAfter(index);
269 CustomList::GetItemIndexFromPosition(int x, int y) const
271 const _CustomListImpl* pImpl = _CustomListImpl::GetInstance(*this);
272 SysAssertf((pImpl != null), "Not yet constructed. Construct() should be called before use.");
277 result r = pImpl->GetItemIndexFromPosition(Point(x, y), groupIndex, itemIndex);
278 SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), -1, E_SYSTEM, "[%s] Propagating.", GetErrorMessage(r));
284 CustomList::GetItemIndexFromPosition(const Point& position) const
286 const _CustomListImpl* pImpl = _CustomListImpl::GetInstance(*this);
287 SysAssertf((pImpl != null), "Not yet constructed. Construct() should be called before use.");
292 result r = pImpl->GetItemIndexFromPosition(position, groupIndex, itemIndex);
293 SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), -1, E_SYSTEM, "[%s] Propagating.", GetErrorMessage(r));
299 CustomList::GetTopDrawnItemIndex(void) const
301 const _CustomListImpl* pImpl = _CustomListImpl::GetInstance(*this);
302 SysAssertf((pImpl != null), "Not yet constructed. Construct() should be called before use.");
307 result r = pImpl->GetTopDrawnItemIndex(groupIndex, itemIndex);
308 SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), -1, E_SYSTEM, "[%s] Propagating.", GetErrorMessage(r));
314 CustomList::GetBottomDrawnItemIndex(void) const
316 const _CustomListImpl* pImpl = _CustomListImpl::GetInstance(*this);
317 SysAssertf((pImpl != null), "Not yet constructed. Construct() should be called before use.");
322 result r = pImpl->GetBottomDrawnItemIndex(groupIndex, itemIndex);
323 SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), -1, E_SYSTEM, "[%s] Propagating.", GetErrorMessage(r));
329 CustomList::SetBackgroundColor(const Color& color)
331 _CustomListImpl* pImpl = _CustomListImpl::GetInstance(*this);
332 SysAssertf((pImpl != null), "Not yet constructed. Construct() should be called before use.");
334 pImpl->SetBackgroundColor(color);
338 CustomList::SetTextOfEmptyList(const String& text)
340 _CustomListImpl* pImpl = _CustomListImpl::GetInstance(*this);
341 SysAssertf((pImpl != null), "Not yet constructed. Construct() should be called before use.");
343 pImpl->SetTextOfEmptyList(text);
347 CustomList::SetTextColorOfEmptyList(const Color& color)
349 _CustomListImpl* pImpl = _CustomListImpl::GetInstance(*this);
350 SysAssertf((pImpl != null), "Not yet constructed. Construct() should be called before use.");
352 pImpl->SetTextColorOfEmptyList(color);
356 CustomList::GetTextColorOfEmptyList(void) const
358 const _CustomListImpl* pImpl = _CustomListImpl::GetInstance(*this);
359 SysAssertf((pImpl != null), "Not yet constructed. Construct() should be called before use.");
361 return pImpl->GetTextColorOfEmptyList();
365 CustomList::GetItemIndexFromItemId(int itemId) const
367 const _CustomListImpl* pImpl = _CustomListImpl::GetInstance(*this);
368 SysAssertf((pImpl != null), "Not yet constructed. Construct() should be called before use.");
370 return pImpl->GetItemIndexFromItemId(itemId);
374 CustomList::GetItemIdAt(int index) const
376 const _CustomListImpl* pImpl = _CustomListImpl::GetInstance(*this);
377 SysAssertf((pImpl != null), "Not yet constructed. Construct() should be called before use.");
379 return pImpl->GetItemIdAt(index);
383 CustomList::ScrollToBottom(void)
385 _CustomListImpl* pImpl = _CustomListImpl::GetInstance(*this);
386 SysAssertf((pImpl != null), "Not yet constructed. Construct() should be called before use.");
388 pImpl->ScrollToBottom();
392 CustomList::ScrollToTop(void)
394 _CustomListImpl* pImpl = _CustomListImpl::GetInstance(*this);
395 SysAssertf((pImpl != null), "Not yet constructed. Construct() should be called before use.");
397 pImpl->ScrollToTop();
401 CustomList::ScrollToTop(int index)
403 _CustomListImpl* pImpl = _CustomListImpl::GetInstance(*this);
404 SysAssertf((pImpl != null), "Not yet constructed. Construct() should be called before use.");
406 result r = pImpl->ScrollToTop(index);
407 SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Failed to ScrollToTop.", GetErrorMessage(r));
413 CustomList::RefreshItem(int index)
415 _CustomListImpl* pImpl = _CustomListImpl::GetInstance(*this);
416 SysAssertf((pImpl != null), "Not yet constructed. Construct() should be called before use.");
418 result r = pImpl->RefreshItem(index);
419 SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Failed to Refresh an item.", GetErrorMessage(r));
424 }}} // Tizen::Controls::Ui