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 FUiCtrlGroupedTableView.cpp
20 * @brief This is the implementation file for GroupedTableView class.
22 * This header file contains the implementation of GroupedTableView class.
25 #include <FUiContainer.h>
26 #include <FUiCtrlGroupedTableView.h>
27 #include <FUiCtrlIGroupedTableViewItemProvider.h>
28 #include <FUiCtrlIGroupedTableViewItemProviderF.h>
29 #include <FUiCtrlIGroupedTableViewItemEventListener.h>
30 #include "FUiCtrl_TableViewImpl.h"
31 #include "FUi_CoordinateSystemUtils.h"
33 using namespace Tizen::Base;
34 using namespace Tizen::Graphics;
36 namespace Tizen { namespace Ui { namespace Controls
39 ////////////////////////////////////////////////////////////////////////////////
40 /// GroupedTableView class
42 GroupedTableView::GroupedTableView(void)
46 GroupedTableView::~GroupedTableView(void)
51 GroupedTableView::Construct(const Tizen::Graphics::Rectangle& rect, bool itemDivider, TableViewScrollBarStyle scrollStyle)
55 _TableViewImpl* pImpl = _TableViewImpl::GetInstance(*this);
56 SysAssertf(pImpl == null, "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class.");
58 pImpl = _TableViewImpl::CreateTableViewImplN(this, _CoordinateSystemUtils::ConvertToFloat(rect), TABLE_VIEW_STYLE_GROUPED, itemDivider, scrollStyle);
61 SysTryReturn(NID_UI_CTRL, pImpl != null, r, r, "[%s] Propagating.", GetErrorMessage(r));
63 _pControlImpl = pImpl;
66 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating", GetErrorMessage(r));
77 GroupedTableView::Construct(const Tizen::Graphics::FloatRectangle& rect, bool itemDivider, TableViewScrollBarStyle scrollStyle)
81 _TableViewImpl* pImpl = _TableViewImpl::GetInstance(*this);
82 SysAssertf(pImpl == null, "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class.");
84 pImpl = _TableViewImpl::CreateTableViewImplN(this, rect, TABLE_VIEW_STYLE_GROUPED, itemDivider, scrollStyle);
87 SysTryReturn(NID_UI_CTRL, pImpl != null, r, r, "[%s] Propagating.", GetErrorMessage(r));
89 _pControlImpl = pImpl;
92 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating", GetErrorMessage(r));
103 GroupedTableView::SetItemProvider(IGroupedTableViewItemProvider* pProvider)
105 _TableViewImpl* pImpl = _TableViewImpl::GetInstance(*this);
106 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
108 pImpl->SetGroupedStyleItemProvider(pProvider);
112 GroupedTableView::SetItemProviderF(IGroupedTableViewItemProviderF* pProvider)
114 _TableViewImpl* pImpl = _TableViewImpl::GetInstance(*this);
115 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
117 pImpl->SetGroupedStyleItemProviderF(pProvider);
121 GroupedTableView::AddGroupedTableViewItemEventListener(IGroupedTableViewItemEventListener& listener)
123 _TableViewImpl* pImpl = _TableViewImpl::GetInstance(*this);
124 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
126 return pImpl->AddGroupedTableViewItemEventListener(listener);
130 GroupedTableView::RemoveGroupedTableViewItemEventListener(IGroupedTableViewItemEventListener& listener)
132 _TableViewImpl* pImpl = _TableViewImpl::GetInstance(*this);
133 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
135 return pImpl->RemoveGroupedTableViewItemEventListener(listener);
139 GroupedTableView::AddFastScrollListener(IFastScrollListener& listener)
141 _TableViewImpl* pImpl = _TableViewImpl::GetInstance(*this);
142 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
144 return pImpl->AddFastScrollListener(listener);
148 GroupedTableView::RemoveFastScrollListener(IFastScrollListener& listener)
150 _TableViewImpl* pImpl = _TableViewImpl::GetInstance(*this);
151 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
153 return pImpl->RemoveFastScrollListener(listener);
157 GroupedTableView::AddScrollEventListener(IScrollEventListener& listener)
159 _TableViewImpl* pImpl = _TableViewImpl::GetInstance(*this);
160 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
162 return pImpl->AddScrollEventListener(listener);
166 GroupedTableView::RemoveScrollEventListener(IScrollEventListener& listener)
168 _TableViewImpl* pImpl = _TableViewImpl::GetInstance(*this);
169 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
171 return pImpl->RemoveScrollEventListener(listener);
175 GroupedTableView::AddScrollEventListener(IScrollEventListenerF& listener)
177 _TableViewImpl* pImpl = _TableViewImpl::GetInstance(*this);
178 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
180 return pImpl->AddScrollEventListener(listener);
184 GroupedTableView::RemoveScrollEventListener(IScrollEventListenerF& listener)
186 _TableViewImpl* pImpl = _TableViewImpl::GetInstance(*this);
187 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
189 return pImpl->RemoveScrollEventListener(listener);
193 GroupedTableView::SetCollapseByPinchGestureEnabled(bool enable)
200 GroupedTableView::IsCollapseByPinchGestureEnabled(void) const
207 GroupedTableView::SetFastScrollIndex(const String& text, bool useSearchIcon)
209 _TableViewImpl* pImpl = _TableViewImpl::GetInstance(*this);
210 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
212 return pImpl->SetFastScrollIndex(text, useSearchIcon);
216 GroupedTableView::GetTopDrawnItemIndex(int& groupIndex, int& itemIndex) const
218 const _TableViewImpl* pImpl = _TableViewImpl::GetInstance(*this);
219 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
221 return pImpl->GetTopDrawnItemIndex(groupIndex, itemIndex);
225 GroupedTableView::GetBottomDrawnItemIndex(int& groupIndex, int& itemIndex) const
227 const _TableViewImpl* pImpl = _TableViewImpl::GetInstance(*this);
228 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
231 return pImpl->GetBottomDrawnItemIndex(groupIndex, itemIndex);
235 GroupedTableView::SetItemChecked(int groupIndex, int itemIndex, bool check)
237 _TableViewImpl* pImpl = _TableViewImpl::GetInstance(*this);
238 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
240 return pImpl->SetItemChecked(groupIndex, itemIndex, check);
244 GroupedTableView::IsItemChecked(int groupIndex, int itemIndex) const
246 const _TableViewImpl* pImpl = _TableViewImpl::GetInstance(*this);
247 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
249 return pImpl->IsItemChecked(groupIndex, itemIndex);
253 GroupedTableView::SetItemEnabled(int groupIndex, int itemIndex, bool enable)
255 _TableViewImpl* pImpl = _TableViewImpl::GetInstance(*this);
256 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
258 return pImpl->SetItemEnabled(groupIndex, itemIndex, enable);
262 GroupedTableView::IsItemEnabled(int groupIndex, int itemIndex) const
264 const _TableViewImpl* pImpl = _TableViewImpl::GetInstance(*this);
265 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
267 return pImpl->IsItemEnabled(groupIndex, itemIndex);
271 GroupedTableView::GetGroupCount(void) const
273 const _TableViewImpl* pImpl = _TableViewImpl::GetInstance(*this);
274 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
276 return pImpl->GetGroupCount();
280 GroupedTableView::GetItemCountAt(int groupIndex) const
282 const _TableViewImpl* pImpl = _TableViewImpl::GetInstance(*this);
283 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
285 return pImpl->GetItemCountAt(groupIndex);
289 GroupedTableView::RefreshItem(int groupIndex, int itemIndex, TableViewRefreshType type)
291 _TableViewImpl* pImpl = _TableViewImpl::GetInstance(*this);
292 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
294 return pImpl->RefreshTableView(groupIndex, itemIndex, type);
298 GroupedTableView::RefreshAllItems(void)
300 _TableViewImpl* pImpl = _TableViewImpl::GetInstance(*this);
301 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
303 return pImpl->RefreshAllItems();
307 GroupedTableView::UpdateTableView(void)
309 _TableViewImpl* pImpl = _TableViewImpl::GetInstance(*this);
310 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
312 pImpl->UpdateTableView();
316 GroupedTableView::GetItemIndexFromPosition(const Tizen::Graphics::Point& position, int& groupIndex, int& itemIndex) const
318 const _TableViewImpl* pImpl = _TableViewImpl::GetInstance(*this);
319 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
321 pImpl->GetItemIndexFromPosition(position, groupIndex, itemIndex);
325 GroupedTableView::GetItemIndexFromPosition(const Tizen::Graphics::FloatPoint& position, int& groupIndex, int& itemIndex) const
327 const _TableViewImpl* pImpl = _TableViewImpl::GetInstance(*this);
328 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
330 pImpl->GetItemIndexFromPosition(position, groupIndex, itemIndex);
334 GroupedTableView::SetItemDividerColor(const Color& color)
336 _TableViewImpl* pImpl = _TableViewImpl::GetInstance(*this);
337 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
339 pImpl->SetItemDividerColor(color);
343 GroupedTableView::GetItemDividerColor(void) const
345 const _TableViewImpl* pImpl = _TableViewImpl::GetInstance(*this);
346 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
348 return pImpl->GetItemDividerColor();
352 GroupedTableView::SetBackgroundColor(const Color& color)
354 _TableViewImpl* pImpl = _TableViewImpl::GetInstance(*this);
355 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
357 pImpl->SetBackgroundColor(color);
363 GroupedTableView::GetBackgroundColor(void) const
365 const _TableViewImpl* pImpl = _TableViewImpl::GetInstance(*this);
366 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
368 return pImpl->GetBackgroundColor();
372 GroupedTableView::ExpandGroup(int groupIndex)
374 _TableViewImpl* pImpl = _TableViewImpl::GetInstance(*this);
375 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
377 return pImpl->ExpandGroup(groupIndex);
381 GroupedTableView::CollapseGroup(int groupIndex)
383 _TableViewImpl* pImpl = _TableViewImpl::GetInstance(*this);
384 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
386 return pImpl->CollapseGroup(groupIndex);
390 GroupedTableView::ExpandAllGroups(void)
392 _TableViewImpl* pImpl = _TableViewImpl::GetInstance(*this);
393 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
395 return pImpl->ExpandAllGroup();
399 GroupedTableView::CollapseAllGroups(void)
401 _TableViewImpl* pImpl = _TableViewImpl::GetInstance(*this);
402 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
404 return pImpl->CollapseAllGroup();
408 GroupedTableView::IsGroupExpanded(int groupIndex) const
410 const _TableViewImpl* pImpl = _TableViewImpl::GetInstance(*this);
411 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
413 return pImpl->IsGroupExpanded(groupIndex);
417 GroupedTableView::SetGroupedLookEnabled(bool enable)
419 _TableViewImpl* pImpl = _TableViewImpl::GetInstance(*this);
420 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
422 pImpl->SetGroupedLookEnabled(enable);
426 GroupedTableView::IsGroupedLookEnabled(void) const
428 const _TableViewImpl* pImpl = _TableViewImpl::GetInstance(*this);
429 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
431 return pImpl->IsGroupedLookEnabled();
435 GroupedTableView::ScrollToItem(int groupIndex, int itemIndex, TableViewScrollItemAlignment itemAlignment)
437 _TableViewImpl* pImpl = _TableViewImpl::GetInstance(*this);
438 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
440 result r = pImpl->ScrollToItem(groupIndex, itemIndex, itemAlignment);
441 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
447 GroupedTableView::ScrollByPixel(int pixel)
449 _TableViewImpl* pImpl = _TableViewImpl::GetInstance(*this);
450 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
452 result r = pImpl->ScrollByPixel(_CoordinateSystemUtils::ConvertToFloat(pixel));
453 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
459 GroupedTableView::ScrollByPixel(float pixel)
461 _TableViewImpl* pImpl = _TableViewImpl::GetInstance(*this);
462 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
464 result r = pImpl->ScrollByPixel(pixel);
465 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
471 GroupedTableView::GetCurrentScrollPosition(void) const
473 const _TableViewImpl* pImpl = _TableViewImpl::GetInstance(*this);
474 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
476 return _CoordinateSystemUtils::ConvertToInteger(pImpl->GetCurrentScrollPosition());
480 GroupedTableView::GetCurrentScrollPositionF(void) const
482 const _TableViewImpl* pImpl = _TableViewImpl::GetInstance(*this);
483 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
485 return pImpl->GetCurrentScrollPosition();
489 GroupedTableView::SetScrollInputMode(ScrollInputMode mode)
491 _TableViewImpl* pImpl = _TableViewImpl::GetInstance(*this);
492 SysAssertf(pImpl != null, "Not-yet constructed! Construct() should be called before use.");
494 pImpl->SetScrollInputMode(mode);
498 GroupedTableView::GetScrollInputMode(void) const
500 const _TableViewImpl* pImpl = _TableViewImpl::GetInstance(*this);
501 SysAssertf(pImpl != null, "Not-yet constructed! Construct() should be called before use.");
503 return pImpl->GetScrollInputMode();
507 //GroupedTableView::BeginReorderingMode(void)
509 // _TableViewImpl* pImpl = _TableViewImpl::GetInstance(*this);
510 // SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
512 // pImpl->BeginReorderingMode();
516 //GroupedTableView::EndReorderingMode(void)
518 // _TableViewImpl* pImpl = _TableViewImpl::GetInstance(*this);
519 // SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
521 // pImpl->EndReorderingMode();
525 //GroupedTableView::IsInReorderingMode(void) const
527 // const _TableViewImpl* pImpl = _TableViewImpl::GetInstance(*this);
528 // SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
530 // return pImpl->IsInReorderingMode();
534 GroupedTableView::SetScrollEnabled(bool enable)
536 _TableViewImpl* pImpl = _TableViewImpl::GetInstance(*this);
537 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
539 pImpl->SetScrollEnabled(enable);
543 GroupedTableView::IsScrollEnabled(void) const
545 const _TableViewImpl* pImpl = _TableViewImpl::GetInstance(*this);
546 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
548 return pImpl->IsScrollEnabled();
552 GroupedTableView::BeginReorderingMode(void)
554 _TableViewImpl* pImpl = _TableViewImpl::GetInstance(*this);
555 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
557 pImpl->BeginReorderingMode();
561 GroupedTableView::EndReorderingMode(void)
563 _TableViewImpl* pImpl = _TableViewImpl::GetInstance(*this);
564 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
566 pImpl->EndReorderingMode();
570 GroupedTableView::IsInReorderingMode(void) const
572 const _TableViewImpl* pImpl = _TableViewImpl::GetInstance(*this);
573 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
575 return pImpl->IsInReorderingMode();
579 GroupedTableView::OpenContextItem(int groupIndex, int itemIndex)
581 _TableViewImpl* pImpl = _TableViewImpl::GetInstance(*this);
582 SysAssertf(pImpl != null, "Not-yet constructed! Construct() should be called before use.");
584 return pImpl->OpenContextItem(groupIndex, itemIndex);
588 GroupedTableView::CloseContextItem(int groupIndex, int itemIndex)
590 _TableViewImpl* pImpl = _TableViewImpl::GetInstance(*this);
591 SysAssertf(pImpl != null, "Not-yet constructed! Construct() should be called before use.");
593 return pImpl->CloseContextItem(groupIndex, itemIndex);
597 GroupedTableView::IsContextItemOpened(int groupIndex, int itemIndex) const
599 const _TableViewImpl* pImpl = _TableViewImpl::GetInstance(*this);
600 SysAssertf(pImpl != null, "Not-yet constructed! Construct() should be called before use.");
602 return pImpl->IsContextItemOpened(groupIndex, itemIndex);
605 }}} //Tizen::Ui::Controls