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 FUiCtrlSlidableList.cpp
20 * @brief This is the implementation file for SlidableList class.
23 #include <FUiCtrlSlidableList.h>
24 #include <FBaseSysLog.h>
25 #include "FUiCtrl_SlidableListImpl.h"
27 using namespace Tizen::Graphics;
29 namespace Tizen { namespace Ui { namespace Controls
32 SlidableList::SlidableList(void)
36 SlidableList::~SlidableList(void)
41 SlidableList::Construct(const Tizen::Graphics::Rectangle& rect, CustomListStyle style, bool itemDivider)
45 SysAssertf((_SlidableListImpl::GetInstance(*this) == null), "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class.");
47 _SlidableListImpl* pImpl = _SlidableListImpl::CreateSlidableListImplN(this, rect, itemDivider);
49 SysTryReturn(NID_UI_CTRL, pImpl, r, r, "[%s] Propagating.", GetErrorMessage(r));
51 _pControlImpl = pImpl;
53 r = pImpl->UpdateBounds(rect);
54 SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r));
56 r = pImpl->SetListStyle(style);
57 SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r));
59 r = pImpl->Initalize();
60 SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r));
62 r = pImpl->LoadDefaultBitmap();
63 SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r));
74 SlidableList::AddSlidableListEventListener(Tizen::Ui::ISlidableListEventListener& listener)
76 _SlidableListImpl* pImpl = _SlidableListImpl::GetInstance(*this);
78 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
80 pImpl->AddSlidableListEventListener(listener);
84 SlidableList::RemoveSlidableListEventListener(Tizen::Ui::ISlidableListEventListener& listener)
86 _SlidableListImpl* pImpl = _SlidableListImpl::GetInstance(*this);
88 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
90 pImpl->RemoveSlidableListEventListener(listener);
94 SlidableList::AddCustomItemEventListener(Tizen::Ui::ICustomItemEventListener& listener)
96 _SlidableListImpl* pImpl = _SlidableListImpl::GetInstance(*this);
98 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
100 pImpl->AddCustomItemEventListener(listener);
104 SlidableList::AddItem(const CustomListItem& item, int itemId)
106 _SlidableListImpl* pImpl = _SlidableListImpl::GetInstance(*this);
108 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
110 return pImpl->AddItem(item, itemId);
114 SlidableList::GetBottomDrawnItemIndex(void) const
116 const _SlidableListImpl* pImpl = _SlidableListImpl::GetInstance(*this);
118 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
120 return pImpl->GetBottomDrawnItemIndex();
124 SlidableList::GetFirstCheckedItemIndex(void) const
126 const _SlidableListImpl* pImpl = _SlidableListImpl::GetInstance(*this);
128 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
130 return pImpl->GetFirstCheckedItemIndex();
134 SlidableList::GetItemCount(void) const
136 const _SlidableListImpl* pImpl = _SlidableListImpl::GetInstance(*this);
138 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
140 return pImpl->GetItemCount();
144 SlidableList::GetLastCheckedItemIndex(void) const
146 const _SlidableListImpl* pImpl = _SlidableListImpl::GetInstance(*this);
148 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
150 return pImpl->GetLastCheckedItemIndex();
154 SlidableList::GetNextCheckedItemIndexAfter(int index) const
156 const _SlidableListImpl* pImpl = _SlidableListImpl::GetInstance(*this);
158 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
160 return pImpl->GetNextCheckedItemIndexAfter(index);
164 SlidableList::GetTopDrawnItemIndex(void) const
166 const _SlidableListImpl* pImpl = _SlidableListImpl::GetInstance(*this);
168 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
170 return pImpl->GetTopDrawnItemIndex();
174 SlidableList::InsertItemAt(int index, const CustomListItem& item, int itemId)
176 _SlidableListImpl* pImpl = _SlidableListImpl::GetInstance(*this);
178 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
180 return pImpl->InsertItemAt(index, item, itemId);
184 SlidableList::RemoveAllItems(void)
186 _SlidableListImpl* pImpl = _SlidableListImpl::GetInstance(*this);
188 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
190 return pImpl->RemoveAllItems();
194 SlidableList::RemoveCustomItemEventListener(Tizen::Ui::ICustomItemEventListener& listener)
196 _SlidableListImpl* pImpl = _SlidableListImpl::GetInstance(*this);
198 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
200 pImpl->RemoveCustomItemEventListener(listener);
204 SlidableList::ScrollToBottom(void)
206 _SlidableListImpl* pImpl = _SlidableListImpl::GetInstance(*this);
208 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
210 pImpl->ScrollToBottom();
214 SlidableList::ScrollToTop(void)
216 _SlidableListImpl* pImpl = _SlidableListImpl::GetInstance(*this);
218 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
220 pImpl->ScrollToTop();
224 SlidableList::ScrollToTop(int index)
226 _SlidableListImpl* pImpl = _SlidableListImpl::GetInstance(*this);
228 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
230 return pImpl->ScrollToTop(index);
234 SlidableList::SetAllItemsChecked(bool check)
236 _SlidableListImpl* pImpl = _SlidableListImpl::GetInstance(*this);
238 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
240 return pImpl->SetAllItemsChecked(check);
244 SlidableList::SetItemChecked(int index, bool check)
246 _SlidableListImpl* pImpl = _SlidableListImpl::GetInstance(*this);
248 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
250 return pImpl->SetItemChecked(index, check);
254 SlidableList::SetLoadedItemEnabled(int index, bool enable)
256 _SlidableListImpl* pImpl = _SlidableListImpl::GetInstance(*this);
258 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
260 return pImpl->SetLoadedItemEnabled(index, enable);
264 SlidableList::SetBackgroundColor(const Tizen::Graphics::Color& color)
266 _SlidableListImpl* pImpl = _SlidableListImpl::GetInstance(*this);
268 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
270 pImpl->SetBackgroundColor(color);
274 SlidableList::SetTextOfEmptyList(const Tizen::Base::String& text)
276 _SlidableListImpl* pImpl = _SlidableListImpl::GetInstance(*this);
278 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
280 pImpl->SetTextOfEmptyList(text);
284 SlidableList::SetTextColorOfEmptyList(const Tizen::Graphics::Color& color)
286 _SlidableListImpl* pImpl = _SlidableListImpl::GetInstance(*this);
288 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
290 pImpl->SetTextColorOfEmptyList(color);
293 Tizen::Graphics::Color
294 SlidableList::GetTextColorOfEmptyList(void) const
296 const _SlidableListImpl* pImpl = _SlidableListImpl::GetInstance(*this);
298 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
300 return pImpl->GetTextColorOfEmptyList();
303 const CustomListItem*
304 SlidableList::GetLoadedItemAt(int index) const
306 const _SlidableListImpl* pImpl = _SlidableListImpl::GetInstance(*this);
308 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
310 return pImpl->GetLoadedItemAt(index);
314 SlidableList::GetLoadedItemIdAt(int index) const
316 const _SlidableListImpl* pImpl = _SlidableListImpl::GetInstance(*this);
318 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
320 return pImpl->GetLoadedItemIdAt(index);
324 SlidableList::IsItemChecked(int index) const
326 const _SlidableListImpl* pImpl = _SlidableListImpl::GetInstance(*this);
328 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
330 return pImpl->IsItemChecked(index);
334 SlidableList::IsLoadedItemEnabled(int index) const
336 const _SlidableListImpl* pImpl = _SlidableListImpl::GetInstance(*this);
338 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
340 return pImpl->IsLoadedItemEnabled(index);
344 SlidableList::GetLoadedItemIndexFromItemId(int itemId) const
346 const _SlidableListImpl* pImpl = _SlidableListImpl::GetInstance(*this);
348 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
350 return pImpl->GetLoadedItemIndexFromItemId(itemId);
354 SlidableList::LoadItemToTop(const CustomListItem& item, int itemId)
356 _SlidableListImpl* pImpl = _SlidableListImpl::GetInstance(*this);
358 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
360 result r = pImpl->LoadItemToTop(item, itemId);
361 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Failed to load item at top", GetErrorMessage(r));
367 SlidableList::LoadItemToBottom(const CustomListItem& item, int itemId)
369 _SlidableListImpl* pImpl = _SlidableListImpl::GetInstance(*this);
371 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
373 result r = pImpl->LoadItemToBottom(item, itemId);
374 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Failed to load item at bottom", GetErrorMessage(r));
380 SlidableList::SetItemCountAndHeight(int count, int listHeight)
382 _SlidableListImpl* pImpl = _SlidableListImpl::GetInstance(*this);
384 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
386 pImpl->SetItemCountAndHeight(count, listHeight);
390 SlidableList::UnloadAllItems(void)
392 _SlidableListImpl* pImpl = _SlidableListImpl::GetInstance(*this);
394 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
396 return pImpl->UnloadAllItems();
400 SlidableList::SetItemAt(int index, const CustomListItem& item, int itemId)
402 _SlidableListImpl* pImpl = _SlidableListImpl::GetInstance(*this);
404 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
406 return pImpl->SetItemAt(index, item, itemId);
410 SlidableList::RemoveItemAt(int index, int itemHeight)
412 _SlidableListImpl* pImpl = _SlidableListImpl::GetInstance(*this);
414 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
416 return pImpl->RemoveItemAt(index, itemHeight);
420 SlidableList::RemoveAllCheckedItems(int itemHeight)
422 _SlidableListImpl* pImpl = _SlidableListImpl::GetInstance(*this);
424 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
426 return pImpl->RemoveAllCheckedItems(itemHeight);
430 SlidableList::IsItemLoaded(int index) const
432 const _SlidableListImpl* pImpl = _SlidableListImpl::GetInstance(*this);
434 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
436 return pImpl->IsItemLoaded(index);
440 SlidableList::GetFirstLoadedItemIndex(void) const
442 const _SlidableListImpl* pImpl = _SlidableListImpl::GetInstance(*this);
444 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
446 return pImpl->GetFirstLoadedItemIndex();
450 SlidableList::GetLastLoadedItemIndex(void) const
452 const _SlidableListImpl* pImpl = _SlidableListImpl::GetInstance(*this);
454 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
456 return pImpl->GetLastLoadedItemIndex();
460 SlidableList::GetItemIndexFromPosition(int x, int y) const
462 const _SlidableListImpl* pImpl = _SlidableListImpl::GetInstance(*this);
464 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
466 return pImpl->GetItemIndexFromPosition(x, y);
470 SlidableList::GetItemIndexFromPosition(const Tizen::Graphics::Point& position) const
472 const _SlidableListImpl* pImpl = _SlidableListImpl::GetInstance(*this);
474 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
476 return pImpl->GetItemIndexFromPosition(position);
480 SlidableList::RefreshItem(int index)
482 _SlidableListImpl* pImpl = _SlidableListImpl::GetInstance(*this);
484 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
486 return pImpl->RefreshItem(index);
489 }}} //Tizen::Ui::Controls