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 FUiCtrlGroupedListView.cpp
20 * @brief This is the implementation file for GroupedListView class.
22 * This header file contains the implementation of GroupedListView class.
25 #include <FBaseSysLog.h>
26 #include <FUiCtrlGroupedListView.h>
27 #include "FUiCtrl_GroupedListViewImpl.h"
29 using namespace Tizen::Base;
30 using namespace Tizen::Graphics;
32 namespace Tizen { namespace Ui { namespace Controls
35 GroupedListView::GroupedListView(void)
39 GroupedListView::~GroupedListView(void)
44 GroupedListView::Construct(const Rectangle& rect, GroupedListViewStyle style, bool itemDivider, bool fastScroll)
48 _GroupedListViewImpl* pImpl = _GroupedListViewImpl::GetInstance(*this);
49 SysAssertf(pImpl == null,
50 "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class.");
52 if (fastScroll == true)
54 pImpl = _GroupedListViewImpl::CreateGroupedListViewImplN(this, style, itemDivider, SCROLL_STYLE_FAST_SCROLL);
58 pImpl = _GroupedListViewImpl::CreateGroupedListViewImplN(this, style, itemDivider, SCROLL_STYLE_FADE_OUT);
60 SysTryReturn(NID_UI_CTRL, pImpl != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
62 _pControlImpl = pImpl;
64 r = Control::SetBounds(rect.x, rect.y, rect.width, rect.height);
65 SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r));
75 GroupedListView::Construct(const Rectangle& rect, GroupedListViewStyle style, bool itemDivider, ListScrollStyle scrollStyle)
79 SysAssertf((_GroupedListViewImpl::GetInstance(*this) == null),
80 "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class.");
82 _GroupedListViewImpl* pImpl = _GroupedListViewImpl::CreateGroupedListViewImplN(this, style, itemDivider, scrollStyle);
83 SysTryReturn(NID_UI_CTRL, (pImpl != null), GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
85 _pControlImpl = pImpl;
87 r = Control::SetBounds(rect.x, rect.y, rect.width, rect.height);
88 SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r));
98 GroupedListView::SetItemProvider(IGroupedListViewItemProvider& provider)
100 _GroupedListViewImpl* pImpl = _GroupedListViewImpl::GetInstance(*this);
101 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
103 return pImpl->SetItemProvider(provider);
107 GroupedListView::AddGroupedListViewItemEventListener(IGroupedListViewItemEventListener& listener)
109 _GroupedListViewImpl* pImpl = _GroupedListViewImpl::GetInstance(*this);
110 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
112 pImpl->AddGroupedListViewItemEventListener(listener);
113 SysTryReturnVoidResult(NID_UI_CTRL, GetLastResult() == E_SUCCESS, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
117 GroupedListView::RemoveGroupedListViewItemEventListener(IGroupedListViewItemEventListener& listener)
119 _GroupedListViewImpl* pImpl = _GroupedListViewImpl::GetInstance(*this);
120 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
122 pImpl->RemoveGroupedListViewItemEventListener(listener);
123 SysTryReturnVoidResult(NID_UI_CTRL, GetLastResult() == E_SUCCESS, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
127 GroupedListView::AddFastScrollListener(IFastScrollListener& listener)
129 _GroupedListViewImpl* pImpl = _GroupedListViewImpl::GetInstance(*this);
130 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
132 pImpl->AddFastScrollListener(listener);
133 SysTryReturnVoidResult(NID_UI_CTRL, GetLastResult() == E_SUCCESS, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
137 GroupedListView::RemoveFastScrollListener(IFastScrollListener& listener)
139 _GroupedListViewImpl* pImpl = _GroupedListViewImpl::GetInstance(*this);
140 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
142 pImpl->RemoveFastScrollListener(listener);
143 SysTryReturnVoidResult(NID_UI_CTRL, GetLastResult() == E_SUCCESS, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
147 GroupedListView::AddScrollEventListener(IScrollEventListener& listener)
149 _GroupedListViewImpl* pImpl = _GroupedListViewImpl::GetInstance(*this);
150 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
152 pImpl->AddScrollEventListener(listener);
153 SysTryReturnVoidResult(NID_UI_CTRL, GetLastResult() == E_SUCCESS, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
157 GroupedListView::RemoveScrollEventListener(IScrollEventListener& listener)
159 _GroupedListViewImpl* pImpl = _GroupedListViewImpl::GetInstance(*this);
160 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
162 pImpl->RemoveScrollEventListener(listener);
163 SysTryReturnVoidResult(NID_UI_CTRL, GetLastResult() == E_SUCCESS, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
167 GroupedListView::AddUiLinkEventListener(IUiLinkEventListener& listener)
169 _GroupedListViewImpl* pImpl = _GroupedListViewImpl::GetInstance(*this);
170 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
172 pImpl->AddUiLinkEventListener(listener);
173 SysTryReturnVoidResult(NID_UI_CTRL, GetLastResult() == E_SUCCESS, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
177 GroupedListView::RemoveUiLinkEventListener(IUiLinkEventListener& listener)
179 _GroupedListViewImpl* pImpl = _GroupedListViewImpl::GetInstance(*this);
180 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
182 pImpl->RemoveUiLinkEventListener(listener);
183 SysTryReturnVoidResult(NID_UI_CTRL, GetLastResult() == E_SUCCESS, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
187 GroupedListView::SetSweepEnabled(bool enable)
189 _GroupedListViewImpl* pImpl = _GroupedListViewImpl::GetInstance(*this);
190 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
192 return pImpl->SetSweepEnabled(enable);
196 GroupedListView::SetFastScrollIndex(const String& text, bool useSearchIcon)
198 _GroupedListViewImpl* pImpl = _GroupedListViewImpl::GetInstance(*this);
199 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
201 return pImpl->SetFastScrollIndex(text, useSearchIcon);
205 GroupedListView::GetTopDrawnItemIndex(int& groupIndex, int& itemIndex) const
207 const _GroupedListViewImpl* pImpl = _GroupedListViewImpl::GetInstance(*this);
208 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
210 return pImpl->GetTopDrawnItemIndex(groupIndex, itemIndex);
214 GroupedListView::GetBottomDrawnItemIndex(int& groupIndex, int& itemIndex) const
216 const _GroupedListViewImpl* pImpl = _GroupedListViewImpl::GetInstance(*this);
217 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
219 return pImpl->GetBottomDrawnItemIndex(groupIndex, itemIndex);
223 GroupedListView::ScrollToItem(int groupIndex, int itemIndex)
225 return ScrollToItem(groupIndex, itemIndex, LIST_SCROLL_ITEM_ALIGNMENT_TOP);
229 GroupedListView::ScrollToItem(int groupIndex, int itemIndex, ListScrollItemAlignment itemAlignment)
231 _GroupedListViewImpl* pImpl = _GroupedListViewImpl::GetInstance(*this);
232 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
234 return pImpl->ScrollToItem(groupIndex, itemIndex, itemAlignment);
238 GroupedListView::SetItemChecked(int groupIndex, int itemIndex, bool check)
240 _GroupedListViewImpl* pImpl = _GroupedListViewImpl::GetInstance(*this);
241 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
243 return pImpl->SetItemChecked(groupIndex, itemIndex, check);
247 GroupedListView::IsItemChecked(int groupIndex, int itemIndex) const
249 const _GroupedListViewImpl* pImpl = _GroupedListViewImpl::GetInstance(*this);
250 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
252 return pImpl->IsItemChecked(groupIndex, itemIndex);
256 GroupedListView::SetItemEnabled(int groupIndex, int itemIndex, bool enable)
258 _GroupedListViewImpl* pImpl = _GroupedListViewImpl::GetInstance(*this);
259 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
261 return pImpl->SetItemEnabled(groupIndex, itemIndex, enable);
265 GroupedListView::IsItemEnabled(int groupIndex, int itemIndex) const
267 const _GroupedListViewImpl* pImpl = _GroupedListViewImpl::GetInstance(*this);
268 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
270 return pImpl->IsItemEnabled(groupIndex, itemIndex);
274 GroupedListView::GetGroupCount(void) const
276 const _GroupedListViewImpl* pImpl = _GroupedListViewImpl::GetInstance(*this);
277 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
279 return pImpl->GetGroupCount();
283 GroupedListView::GetItemCountAt(int groupIndex) const
285 const _GroupedListViewImpl* pImpl = _GroupedListViewImpl::GetInstance(*this);
286 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
288 return pImpl->GetItemCountAt(groupIndex);
292 GroupedListView::ShowItemDescriptionText(int groupIndex, int itemIndex)
294 _GroupedListViewImpl* pImpl = _GroupedListViewImpl::GetInstance(*this);
295 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
297 return pImpl->ShowItemDescriptionText(groupIndex, itemIndex);
301 GroupedListView::HideItemDescriptionText(int groupIndex, int itemIndex)
303 _GroupedListViewImpl* pImpl = _GroupedListViewImpl::GetInstance(*this);
304 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
306 return pImpl->HideItemDescriptionText(groupIndex, itemIndex);
310 GroupedListView::RefreshList(int groupIndex, int itemIndex, ListRefreshType type)
312 _GroupedListViewImpl* pImpl = _GroupedListViewImpl::GetInstance(*this);
313 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
315 return pImpl->RefreshList(groupIndex, itemIndex, type);
319 GroupedListView::RefreshList(int groupIndex, int itemIndex, int elementId)
321 _GroupedListViewImpl* pImpl = _GroupedListViewImpl::GetInstance(*this);
322 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
324 return pImpl->RefreshList(groupIndex, itemIndex, elementId);
328 GroupedListView::UpdateList(void)
330 _GroupedListViewImpl* pImpl = _GroupedListViewImpl::GetInstance(*this);
331 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
333 return pImpl->UpdateList();
337 GroupedListView::GetItemIndexFromPosition(int x, int y, int& groupIndex, int& itemIndex) const
339 return GetItemIndexFromPosition(Point(x, y), groupIndex, itemIndex);
343 GroupedListView::GetItemIndexFromPosition(const Point& position, int& groupIndex, int& itemIndex) const
345 const _GroupedListViewImpl* pImpl = _GroupedListViewImpl::GetInstance(*this);
346 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
348 return pImpl->GetItemIndexFromPosition(position, groupIndex, itemIndex);
352 GroupedListView::GetItemIndexFromPosition(int x, int y, int& groupIndex, int& itemIndex, int& elementId) const
354 return GetItemIndexFromPosition(Point(x, y), groupIndex, itemIndex, elementId);
358 GroupedListView::GetItemIndexFromPosition(const Point& position, int& groupIndex, int& itemIndex, int& elementId) const
360 const _GroupedListViewImpl* pImpl = _GroupedListViewImpl::GetInstance(*this);
361 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
363 return pImpl->GetItemIndexFromPosition(position, groupIndex, itemIndex, elementId);
367 GroupedListView::SetSectionColor(const Color& color)
369 _GroupedListViewImpl* pImpl = _GroupedListViewImpl::GetInstance(*this);
370 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
372 return pImpl->SetSectionColor(color);
376 GroupedListView::GetSectionColor(void) const
378 const _GroupedListViewImpl* pImpl = _GroupedListViewImpl::GetInstance(*this);
379 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
381 return pImpl->GetSectionColor();
385 GroupedListView::SetItemDividerColor(const Color& color)
387 _GroupedListViewImpl* pImpl = _GroupedListViewImpl::GetInstance(*this);
388 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
390 return pImpl->SetItemDividerColor(color);
394 GroupedListView::GetItemDividerColor(void) const
396 const _GroupedListViewImpl* pImpl = _GroupedListViewImpl::GetInstance(*this);
397 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
399 return pImpl->GetItemDividerColor();
403 GroupedListView::SetBackgroundColor(const Color& color)
405 _GroupedListViewImpl* pImpl = _GroupedListViewImpl::GetInstance(*this);
406 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
408 pImpl->SetListBackgroundColor(color);
414 GroupedListView::GetBackgroundColor(void) const
416 const _GroupedListViewImpl* pImpl = _GroupedListViewImpl::GetInstance(*this);
417 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
419 return pImpl->GetBackgroundColor();
423 GroupedListView::SetBackgroundBitmap(const Bitmap* pBitmap)
425 _GroupedListViewImpl* pImpl = _GroupedListViewImpl::GetInstance(*this);
426 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
428 return pImpl->SetBackgroundBitmap(pBitmap);
432 GroupedListView::SetBitmapOfEmptyList(const Bitmap* pBitmap)
434 _GroupedListViewImpl* pImpl = _GroupedListViewImpl::GetInstance(*this);
435 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
437 return pImpl->SetBitmapOfEmptyList(pBitmap);
441 GroupedListView::SetTextOfEmptyList(const String& text)
443 _GroupedListViewImpl* pImpl = _GroupedListViewImpl::GetInstance(*this);
444 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
446 return pImpl->SetTextOfEmptyList(text);
450 GroupedListView::GetTextOfEmptyList(void) const
452 const _GroupedListViewImpl* pImpl = _GroupedListViewImpl::GetInstance(*this);
453 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
455 return pImpl->GetTextOfEmptyList();
459 GroupedListView::SetTextColorOfEmptyList(const Color& color)
461 _GroupedListViewImpl* pImpl = _GroupedListViewImpl::GetInstance(*this);
462 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
464 return pImpl->SetTextColorOfEmptyList(color);
468 GroupedListView::GetTextColorOfEmptyList(void) const
470 const _GroupedListViewImpl* pImpl = _GroupedListViewImpl::GetInstance(*this);
471 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
473 return pImpl->GetTextColorOfEmptyList();
477 GroupedListView::ExpandGroup(int groupIndex)
479 _GroupedListViewImpl* pImpl = _GroupedListViewImpl::GetInstance(*this);
480 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
482 return pImpl->ExpandGroup(groupIndex);
486 GroupedListView::CollapseGroup(int groupIndex)
488 _GroupedListViewImpl* pImpl = _GroupedListViewImpl::GetInstance(*this);
489 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
491 return pImpl->CollapseGroup(groupIndex);
495 GroupedListView::IsGroupExpanded(int groupIndex) const
497 const _GroupedListViewImpl* pImpl = _GroupedListViewImpl::GetInstance(*this);
498 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
500 return pImpl->IsGroupExpanded(groupIndex);
504 GroupedListView::BeginReorderingMode(void)
506 _GroupedListViewImpl* pImpl = _GroupedListViewImpl::GetInstance(*this);
507 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
509 return pImpl->BeginReorderingMode();
513 GroupedListView::EndReorderingMode(void)
515 _GroupedListViewImpl* pImpl = _GroupedListViewImpl::GetInstance(*this);
516 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
518 return pImpl->EndReorderingMode();
522 GroupedListView::IsInReorderingMode(void) const
524 const _GroupedListViewImpl* pImpl = _GroupedListViewImpl::GetInstance(*this);
525 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
527 return pImpl->IsInReorderingMode();
530 }}} //Tizen::Ui::Controls