2 // Open Service Platform
3 // Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
5 // Licensed under the Flora License, Version 1.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://floralicense.org/license/
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 FUiCtrlSlidableGroupedList.cpp
20 * @brief This is the implementation file for SlidableGroupedList class.
22 * This file contains the implementation of SlidableGroupedList class.
25 #include <FUiCtrlSlidableGroupedList.h>
26 #include <FBaseSysLog.h>
27 #include "FUiCtrl_SlidableGroupedListImpl.h"
28 #include "FUiCtrl_CustomListImpl.h"
30 using namespace Tizen::Base;
31 using namespace Tizen::App;
32 using namespace Tizen::Ui;
33 using namespace Tizen::Ui::Controls;
34 using namespace Tizen::Graphics;
35 using namespace Tizen::Media;
36 using namespace Tizen::Base::Collection;
39 namespace Tizen { namespace Ui { namespace Controls
42 SlidableGroupedList::SlidableGroupedList(void)
46 SlidableGroupedList::~SlidableGroupedList(void)
51 SlidableGroupedList::Construct(const Rectangle& rect, CustomListStyle style, bool itemDivider, bool bFastScroll)
55 SysAssertf((_SlidableGroupedListImpl::GetInstance(*this) == null), "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class.");
57 _SlidableGroupedListImpl* pImpl = _SlidableGroupedListImpl::CreateSlidableGroupedListImplN(this, itemDivider, bFastScroll);
59 SysTryReturn(NID_UI_CTRL, pImpl, r, r, "[%s] Propagating.", GetErrorMessage(r));
61 _pControlImpl = pImpl;
63 r = Control::SetBounds(rect.x, rect.y, rect.width, rect.height);
64 SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r));
66 r = pImpl->SetListStyle(style);
67 SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r));
69 r = pImpl->LoadDefaultBitmap();
70 SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r));
83 SlidableGroupedList::AddSlidableGroupedListEventListener(ISlidableGroupedListEventListener& listener)
85 _SlidableGroupedListImpl* pImpl = _SlidableGroupedListImpl::GetInstance(*this);
87 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
89 pImpl->AddSlidableGroupedListEventListener(listener);
93 SlidableGroupedList::RemoveSlidableGroupedListEventListener(ISlidableGroupedListEventListener& listener)
95 _SlidableGroupedListImpl* pImpl = _SlidableGroupedListImpl::GetInstance(*this);
97 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
99 pImpl->RemoveSlidableGroupedListEventListener(listener);
103 SlidableGroupedList::LoadItemToTop(const CustomListItem& item, int itemId)
105 _SlidableGroupedListImpl* pImpl = _SlidableGroupedListImpl::GetInstance(*this);
107 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
109 result r = pImpl->LoadItemToTop(item, itemId);
110 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
116 SlidableGroupedList::LoadItemToBottom(const CustomListItem& item, int itemId)
118 _SlidableGroupedListImpl* pImpl = _SlidableGroupedListImpl::GetInstance(*this);
120 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
122 result r = pImpl->LoadItemToBottom(item, itemId);
123 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
129 SlidableGroupedList::UnloadAllItems(void)
131 _SlidableGroupedListImpl* pImpl = _SlidableGroupedListImpl::GetInstance(*this);
132 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
134 return pImpl->UnloadAllItems();
138 SlidableGroupedList::RemoveAllItemsAt(int groupIndex)
140 _SlidableGroupedListImpl* pImpl = _SlidableGroupedListImpl::GetInstance(*this);
142 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
144 return pImpl->RemoveAllItemsAt(groupIndex);
148 SlidableGroupedList::RemoveAllItems(void)
150 _SlidableGroupedListImpl* pImpl = _SlidableGroupedListImpl::GetInstance(*this);
152 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
154 return pImpl->RemoveAllItems();
158 SlidableGroupedList::RemoveFastScrollEventListener(IFastScrollEventListener& listener)
160 _SlidableGroupedListImpl* pImpl = _SlidableGroupedListImpl::GetInstance(*this);
162 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
164 pImpl->RemoveFastScrollEventListener(listener);
168 SlidableGroupedList::RemoveGroupedItemEventListener(IGroupedItemEventListener& listener)
170 _SlidableGroupedListImpl* pImpl = _SlidableGroupedListImpl::GetInstance(*this);
172 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
174 pImpl->RemoveGroupedItemEventListener(listener);
178 SlidableGroupedList::ScrollToBottom(void)
180 _SlidableGroupedListImpl* pImpl = _SlidableGroupedListImpl::GetInstance(*this);
182 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
184 pImpl->ScrollToBottom();
188 SlidableGroupedList::ScrollToTop(void)
190 _SlidableGroupedListImpl* pImpl = _SlidableGroupedListImpl::GetInstance(*this);
192 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
194 pImpl->ScrollToTop();
198 SlidableGroupedList::ScrollToTop(int groupIndex, int itemIndex)
200 _SlidableGroupedListImpl* pImpl = _SlidableGroupedListImpl::GetInstance(*this);
202 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
204 return pImpl->ScrollToTop(groupIndex, itemIndex);
208 SlidableGroupedList::ScrollToTop(int groupIndex)
210 _SlidableGroupedListImpl* pImpl = _SlidableGroupedListImpl::GetInstance(*this);
212 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
214 return pImpl->ScrollToTop(groupIndex);
218 SlidableGroupedList::SetAllItemsChecked(int groupIndex, bool check)
220 _SlidableGroupedListImpl* pImpl = _SlidableGroupedListImpl::GetInstance(*this);
222 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
224 return pImpl->SetAllItemsChecked(groupIndex, check);
228 SlidableGroupedList::SetGroupAt(int groupIndex, const String& text, const Bitmap* pBackgroundBitmap, int groupId)
230 _SlidableGroupedListImpl* pImpl = _SlidableGroupedListImpl::GetInstance(*this);
232 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
234 return pImpl->SetGroupAt(groupIndex, text, pBackgroundBitmap, groupId);
239 SlidableGroupedList::SetItemChecked(int groupIndex, int index, bool check)
241 _SlidableGroupedListImpl* pImpl = _SlidableGroupedListImpl::GetInstance(*this);
243 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
245 return pImpl->SetItemChecked(groupIndex, index, check);
249 SlidableGroupedList::SetLoadedItemEnabled(int groupIndex, int index, bool enable)
251 _SlidableGroupedListImpl* pImpl = _SlidableGroupedListImpl::GetInstance(*this);
253 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
255 return pImpl->SetLoadedItemEnabled(groupIndex, index, enable);
259 SlidableGroupedList::RemoveAllCheckedItemsAt(int groupIndex, int itemHeight)
261 _SlidableGroupedListImpl* pImpl = _SlidableGroupedListImpl::GetInstance(*this);
263 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
265 return pImpl->RemoveAllCheckedItemsAt(groupIndex, itemHeight);
270 SlidableGroupedList::RemoveItemAt(int groupIndex, int index, int itemHeight)
272 _SlidableGroupedListImpl* pImpl = _SlidableGroupedListImpl::GetInstance(*this);
274 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
276 return pImpl->RemoveItemAt(groupIndex, index, itemHeight);
280 SlidableGroupedList::RemoveGroupAt(int groupIndex)
282 _SlidableGroupedListImpl* pImpl = _SlidableGroupedListImpl::GetInstance(*this);
284 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
286 return pImpl->RemoveGroupAt(groupIndex);
289 const CustomListItem*
290 SlidableGroupedList::GetLoadedItemAt(int groupIndex, int index) const
292 const _SlidableGroupedListImpl* pImpl = _SlidableGroupedListImpl::GetInstance(*this);
294 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
296 return pImpl->GetLoadedItemAt(groupIndex, index);
300 SlidableGroupedList::GetLoadedItemIdAt(int groupIndex, int index) const
302 const _SlidableGroupedListImpl* pImpl = _SlidableGroupedListImpl::GetInstance(*this);
304 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
306 return pImpl->GetLoadedItemIdAt(groupIndex, index);
310 SlidableGroupedList::GetLoadedItemIndexFromItemId(int itemId, int& groupIndex, int& itemIndex) const
312 const _SlidableGroupedListImpl* pImpl = _SlidableGroupedListImpl::GetInstance(*this);
314 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
316 return pImpl->GetLoadedItemIndexFromItemId(itemId, groupIndex, itemIndex);
320 SlidableGroupedList::RemoveAllCheckedItems(int height)
322 _SlidableGroupedListImpl* pImpl = _SlidableGroupedListImpl::GetInstance(*this);
324 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
326 return pImpl->RemoveAllCheckedItems(height);
330 SlidableGroupedList::GetFirstLoadedItemIndex(int& groupIndex, int& itemIndex) const
332 const _SlidableGroupedListImpl* pImpl = _SlidableGroupedListImpl::GetInstance(*this);
334 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
336 return pImpl->GetFirstLoadedItemIndex(groupIndex, itemIndex);
340 SlidableGroupedList::GetLastLoadedItemIndex(int& groupIndex, int& itemIndex) const
342 const _SlidableGroupedListImpl* pImpl = _SlidableGroupedListImpl::GetInstance(*this);
344 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
346 return pImpl->GetLastLoadedItemIndex(groupIndex, itemIndex);
350 SlidableGroupedList::SetFastScrollMainIndex(const String& text)
352 _SlidableGroupedListImpl* pImpl = _SlidableGroupedListImpl::GetInstance(*this);
354 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
356 return pImpl->SetFastScrollMainIndex(text);
360 SlidableGroupedList::SetBackgroundColor(const Color& color)
362 _SlidableGroupedListImpl* pImpl = _SlidableGroupedListImpl::GetInstance(*this);
364 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
366 pImpl->SetBackgroundColor(color);
370 SlidableGroupedList::SetTextOfEmptyList(const String& text)
372 _SlidableGroupedListImpl* pImpl = _SlidableGroupedListImpl::GetInstance(*this);
374 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
376 pImpl->SetTextOfEmptyList(text);
380 SlidableGroupedList::SetTextColorOfEmptyList(const Color& color)
382 _SlidableGroupedListImpl* pImpl = _SlidableGroupedListImpl::GetInstance(*this);
384 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
386 pImpl->SetTextColorOfEmptyList(color);
390 SlidableGroupedList::GetTextColorOfEmptyList(void) const
392 const _SlidableGroupedListImpl* pImpl = _SlidableGroupedListImpl::GetInstance(*this);
394 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
396 return pImpl->GetTextColorOfEmptyList();
400 SlidableGroupedList::SetItemAt(int groupIndex, int itemIndex, const CustomListItem& item, int itemId)
402 _SlidableGroupedListImpl* pImpl = _SlidableGroupedListImpl::GetInstance(*this);
404 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
406 return pImpl->SetItemAt(groupIndex, itemIndex, item, itemId);
410 SlidableGroupedList::AddFastScrollEventListener(IFastScrollEventListener& listener)
412 _SlidableGroupedListImpl* pImpl = _SlidableGroupedListImpl::GetInstance(*this);
414 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
416 pImpl->AddFastScrollEventListener(listener);
420 SlidableGroupedList::AddGroup(const String& text, const Bitmap* pBackgroundBitmap, int itemCount, int groupHeight, int groupId)
422 _SlidableGroupedListImpl* pImpl = _SlidableGroupedListImpl::GetInstance(*this);
424 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
426 return pImpl->AddGroup(text, pBackgroundBitmap, itemCount, groupHeight, groupId);
430 SlidableGroupedList::AddGroupedItemEventListener(IGroupedItemEventListener& listener)
432 _SlidableGroupedListImpl* pImpl = _SlidableGroupedListImpl::GetInstance(*this);
434 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
436 pImpl->AddGroupedItemEventListener(listener);
440 SlidableGroupedList::AddItem(int groupIndex, const CustomListItem& item, int itemId)
442 _SlidableGroupedListImpl* pImpl = _SlidableGroupedListImpl::GetInstance(*this);
444 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
446 return pImpl->AddItem(groupIndex, item, itemId);
450 SlidableGroupedList::GetBottomDrawnItemIndex(int& groupIndex, int& itemIndex) const
452 const _SlidableGroupedListImpl* pImpl = _SlidableGroupedListImpl::GetInstance(*this);
454 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
456 return pImpl->GetBottomDrawnItemIndex(groupIndex, itemIndex);
460 SlidableGroupedList::GetFirstCheckedItemIndex(int& groupIndex, int& itemIndex) const
462 const _SlidableGroupedListImpl* pImpl = _SlidableGroupedListImpl::GetInstance(*this);
464 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
466 return pImpl->GetFirstCheckedItemIndex(groupIndex, itemIndex);
470 SlidableGroupedList::GetGroupIdAt(int groupIndex) const
472 const _SlidableGroupedListImpl* pImpl = _SlidableGroupedListImpl::GetInstance(*this);
474 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
476 return pImpl->GetGroupIdAt(groupIndex);
480 SlidableGroupedList::GetGroupIndexFromGroupId(int groupId) const
482 const _SlidableGroupedListImpl* pImpl = _SlidableGroupedListImpl::GetInstance(*this);
484 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
486 return pImpl->GetGroupIndexFromGroupId(groupId);
490 SlidableGroupedList::GetLastCheckedItemIndex(int& groupIndex, int& itemIndex) const
492 const _SlidableGroupedListImpl* pImpl = _SlidableGroupedListImpl::GetInstance(*this);
494 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
496 return pImpl->GetLastCheckedItemIndex(groupIndex, itemIndex);
500 SlidableGroupedList::GetNextCheckedItemIndexAfter(int& groupIndex, int& index) const
502 const _SlidableGroupedListImpl* pImpl = _SlidableGroupedListImpl::GetInstance(*this);
504 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
506 return pImpl->GetNextCheckedItemIndexAfter(groupIndex, index);
510 SlidableGroupedList::GetTopDrawnItemIndex(int& groupIndex, int& itemIndex) const
512 const _SlidableGroupedListImpl* pImpl = _SlidableGroupedListImpl::GetInstance(*this);
514 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
516 return pImpl->GetTopDrawnItemIndex(groupIndex, itemIndex);
520 SlidableGroupedList::GetItemIndexFromPosition(int x, int y, int& groupIndex, int& itemIndex) const
522 const _SlidableGroupedListImpl* pImpl = _SlidableGroupedListImpl::GetInstance(*this);
524 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
526 return pImpl->GetItemIndexFromPosition(x, y, groupIndex, itemIndex);
530 SlidableGroupedList::GetItemIndexFromPosition(const Point& position, int& groupIndex, int& itemIndex) const
532 const _SlidableGroupedListImpl* pImpl = _SlidableGroupedListImpl::GetInstance(*this);
534 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
536 return pImpl->GetItemIndexFromPosition(position, groupIndex, itemIndex);
540 SlidableGroupedList::InsertGroupAt(int groupIndex, const String& text, const Bitmap* pBackgroundBitmap, int itemCount, int groupHeight, int groupId)
542 _SlidableGroupedListImpl* pImpl = _SlidableGroupedListImpl::GetInstance(*this);
544 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
546 return pImpl->InsertGroupAt(groupIndex, text, pBackgroundBitmap, itemCount, groupHeight, groupId);
550 SlidableGroupedList::IsItemChecked(int groupIndex, int index) const
552 const _SlidableGroupedListImpl* pImpl = _SlidableGroupedListImpl::GetInstance(*this);
554 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
556 return pImpl->IsItemChecked(groupIndex, index);
560 SlidableGroupedList::IsLoadedItemEnabled(int groupIndex, int index) const
562 const _SlidableGroupedListImpl* pImpl = _SlidableGroupedListImpl::GetInstance(*this);
564 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
566 return pImpl->IsLoadedItemEnabled(groupIndex, index);
570 SlidableGroupedList::IsItemLoaded(int groupIndex, int itemIndex) const
572 const _SlidableGroupedListImpl* pImpl = _SlidableGroupedListImpl::GetInstance(*this);
574 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
576 return pImpl->IsItemLoaded(groupIndex, itemIndex);
580 SlidableGroupedList::RemoveAllGroups(void)
582 _SlidableGroupedListImpl* pImpl = _SlidableGroupedListImpl::GetInstance(*this);
584 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
586 return pImpl->RemoveAllGroups();
590 SlidableGroupedList::GetGroupCount(void) const
592 const _SlidableGroupedListImpl* pImpl = _SlidableGroupedListImpl::GetInstance(*this);
594 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
596 return pImpl->GetGroupCount();
600 SlidableGroupedList::InsertItemAt(int groupIndex, int index, const CustomListItem& item, int itemId)
602 _SlidableGroupedListImpl* pImpl = _SlidableGroupedListImpl::GetInstance(*this);
604 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
606 return pImpl->InsertItemAt(groupIndex, index, item, itemId);
610 SlidableGroupedList::GetItemCountAt(int groupIndex) const
612 const _SlidableGroupedListImpl* pImpl = _SlidableGroupedListImpl::GetInstance(*this);
614 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
616 return pImpl->GetItemCountAt(groupIndex);
620 SlidableGroupedList::RefreshItem(int groupIndex, int index)
622 _SlidableGroupedListImpl* pImpl = _SlidableGroupedListImpl::GetInstance(*this);
624 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
626 return pImpl->RefreshItem(groupIndex, index);
630 SlidableGroupedList::RefreshGroup(int groupIndex)
632 _SlidableGroupedListImpl* pImpl = _SlidableGroupedListImpl::GetInstance(*this);
634 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
636 return pImpl->RefreshGroup(groupIndex);
639 }}} //Tizen::Ui::Controls