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 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 <FUiCtrlIGroupedTableViewItemEventListener.h>
29 #include "FUiCtrl_TableViewImpl.h"
31 using namespace Tizen::Base;
32 using namespace Tizen::Graphics;
34 namespace Tizen { namespace Ui { namespace Controls
37 ////////////////////////////////////////////////////////////////////////////////
38 /// GroupedTableView class
40 GroupedTableView::GroupedTableView(void)
44 GroupedTableView::~GroupedTableView(void)
49 GroupedTableView::Construct(const Tizen::Graphics::Rectangle& rect, bool itemDivider, TableViewScrollBarStyle scrollStyle)
53 _TableViewImpl* pImpl = _TableViewImpl::GetInstance(*this);
54 SysAssertf(pImpl == null, "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class.");
56 pImpl = _TableViewImpl::CreateTableViewImplN(this, rect, TABLE_VIEW_STYLE_GROUPED, itemDivider, scrollStyle);
59 SysTryReturn(NID_UI_CTRL, pImpl != null, r, r, "[%s] Propagating.", GetErrorMessage(r));
61 _pControlImpl = pImpl;
64 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating", GetErrorMessage(r));
75 GroupedTableView::SetItemProvider(IGroupedTableViewItemProvider* pProvider)
77 _TableViewImpl* pImpl = _TableViewImpl::GetInstance(*this);
78 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
80 pImpl->SetGroupedStyleItemProvider(pProvider);
85 GroupedTableView::AddGroupedTableViewItemEventListener(IGroupedTableViewItemEventListener& listener)
87 _TableViewImpl* pImpl = _TableViewImpl::GetInstance(*this);
88 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
90 return pImpl->AddGroupedTableViewItemEventListener(listener);
94 GroupedTableView::RemoveGroupedTableViewItemEventListener(IGroupedTableViewItemEventListener& listener)
96 _TableViewImpl* pImpl = _TableViewImpl::GetInstance(*this);
97 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
99 return pImpl->RemoveGroupedTableViewItemEventListener(listener);
103 GroupedTableView::AddFastScrollListener(IFastScrollListener& listener)
105 _TableViewImpl* pImpl = _TableViewImpl::GetInstance(*this);
106 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
108 return pImpl->AddFastScrollListener(listener);
112 GroupedTableView::RemoveFastScrollListener(IFastScrollListener& listener)
114 _TableViewImpl* pImpl = _TableViewImpl::GetInstance(*this);
115 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
117 return pImpl->RemoveFastScrollListener(listener);
121 GroupedTableView::AddScrollEventListener(IScrollEventListener& listener)
123 _TableViewImpl* pImpl = _TableViewImpl::GetInstance(*this);
124 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
126 return pImpl->AddScrollEventListener(listener);
130 GroupedTableView::RemoveScrollEventListener(IScrollEventListener& listener)
132 _TableViewImpl* pImpl = _TableViewImpl::GetInstance(*this);
133 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
135 return pImpl->RemoveScrollEventListener(listener);
139 GroupedTableView::SetCollapseByPinchGestureEnabled(bool enable)
146 GroupedTableView::IsCollapseByPinchGestureEnabled(void) const
153 GroupedTableView::SetFastScrollIndex(const String& text, bool useSearchIcon)
155 _TableViewImpl* pImpl = _TableViewImpl::GetInstance(*this);
156 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
158 return pImpl->SetFastScrollIndex(text, useSearchIcon);
162 GroupedTableView::GetTopDrawnItemIndex(int& groupIndex, int& itemIndex) const
164 const _TableViewImpl* pImpl = _TableViewImpl::GetInstance(*this);
165 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
167 return pImpl->GetTopDrawnItemIndex(groupIndex, itemIndex);
171 GroupedTableView::GetBottomDrawnItemIndex(int& groupIndex, int& itemIndex) const
173 const _TableViewImpl* pImpl = _TableViewImpl::GetInstance(*this);
174 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
177 return pImpl->GetBottomDrawnItemIndex(groupIndex, itemIndex);
181 GroupedTableView::SetItemChecked(int groupIndex, int itemIndex, bool check)
183 _TableViewImpl* pImpl = _TableViewImpl::GetInstance(*this);
184 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
186 return pImpl->SetItemChecked(groupIndex, itemIndex, check);
190 GroupedTableView::IsItemChecked(int groupIndex, int itemIndex) const
192 const _TableViewImpl* pImpl = _TableViewImpl::GetInstance(*this);
193 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
195 return pImpl->IsItemChecked(groupIndex, itemIndex);
199 GroupedTableView::SetItemEnabled(int groupIndex, int itemIndex, bool enable)
201 _TableViewImpl* pImpl = _TableViewImpl::GetInstance(*this);
202 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
204 return pImpl->SetItemEnabled(groupIndex, itemIndex, enable);
208 GroupedTableView::IsItemEnabled(int groupIndex, int itemIndex) const
210 const _TableViewImpl* pImpl = _TableViewImpl::GetInstance(*this);
211 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
213 return pImpl->IsItemEnabled(groupIndex, itemIndex);
217 GroupedTableView::GetGroupCount(void) const
219 const _TableViewImpl* pImpl = _TableViewImpl::GetInstance(*this);
220 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
222 return pImpl->GetGroupCount();
226 GroupedTableView::GetItemCountAt(int groupIndex) const
228 const _TableViewImpl* pImpl = _TableViewImpl::GetInstance(*this);
229 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
231 return pImpl->GetItemCountAt(groupIndex);
235 GroupedTableView::RefreshItem(int groupIndex, int itemIndex, TableViewRefreshType type)
237 _TableViewImpl* pImpl = _TableViewImpl::GetInstance(*this);
238 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
240 return pImpl->RefreshTableView(groupIndex, itemIndex, type);
244 GroupedTableView::UpdateTableView(void)
246 _TableViewImpl* pImpl = _TableViewImpl::GetInstance(*this);
247 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
249 pImpl->UpdateTableView();
253 GroupedTableView::GetItemIndexFromPosition(const Tizen::Graphics::Point& position, int& groupIndex, int& itemIndex) const
255 const _TableViewImpl* pImpl = _TableViewImpl::GetInstance(*this);
256 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
258 pImpl->GetItemIndexFromPosition(position, groupIndex, itemIndex);
262 GroupedTableView::SetItemDividerColor(const Color& color)
264 _TableViewImpl* pImpl = _TableViewImpl::GetInstance(*this);
265 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
267 pImpl->SetItemDividerColor(color);
271 GroupedTableView::GetItemDividerColor(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->GetItemDividerColor();
280 GroupedTableView::SetBackgroundColor(const Color& color)
282 _TableViewImpl* pImpl = _TableViewImpl::GetInstance(*this);
283 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
285 pImpl->SetBackgroundColor(color);
291 GroupedTableView::GetBackgroundColor(void) const
293 const _TableViewImpl* pImpl = _TableViewImpl::GetInstance(*this);
294 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
296 return pImpl->GetBackgroundColor();
300 GroupedTableView::ExpandGroup(int groupIndex)
302 _TableViewImpl* pImpl = _TableViewImpl::GetInstance(*this);
303 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
305 return pImpl->ExpandGroup(groupIndex);
309 GroupedTableView::CollapseGroup(int groupIndex)
311 _TableViewImpl* pImpl = _TableViewImpl::GetInstance(*this);
312 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
314 return pImpl->CollapseGroup(groupIndex);
318 GroupedTableView::ExpandAllGroup(void)
320 _TableViewImpl* pImpl = _TableViewImpl::GetInstance(*this);
321 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
323 pImpl->ExpandAllGroup();
327 GroupedTableView::CollapseAllGroup(void)
329 _TableViewImpl* pImpl = _TableViewImpl::GetInstance(*this);
330 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
332 pImpl->CollapseAllGroup();
336 GroupedTableView::IsGroupExpanded(int groupIndex) const
338 const _TableViewImpl* pImpl = _TableViewImpl::GetInstance(*this);
339 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
341 return pImpl->IsGroupExpanded(groupIndex);
345 GroupedTableView::SetGroupedLookEnabled(bool enable)
347 _TableViewImpl* pImpl = _TableViewImpl::GetInstance(*this);
348 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
350 pImpl->SetGroupedLookEnabled(enable);
354 GroupedTableView::IsGroupedLookEnabled(void) const
356 const _TableViewImpl* pImpl = _TableViewImpl::GetInstance(*this);
357 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
359 return pImpl->IsGroupedLookEnabled();
363 GroupedTableView::ScrollToItem(int groupIndex, int itemIndex, TableViewScrollItemAlignment itemAlignment)
365 _TableViewImpl* pImpl = _TableViewImpl::GetInstance(*this);
366 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
368 result r = pImpl->ScrollToItem(groupIndex, itemIndex, itemAlignment);
369 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
375 GroupedTableView::ScrollByPixel(int scrollDistance)
377 _TableViewImpl* pImpl = _TableViewImpl::GetInstance(*this);
378 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
380 result r = pImpl->ScrollByPixel(scrollDistance);
381 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
387 GroupedTableView::SetScrollInputMode(ScrollInputMode mode)
389 _TableViewImpl* pImpl = _TableViewImpl::GetInstance(*this);
390 SysAssertf(pImpl != null, "Not-yet constructed! Construct() should be called before use.");
392 pImpl->SetScrollInputMode(mode);
396 GroupedTableView::GetScrollInputMode(void) const
398 const _TableViewImpl* pImpl = _TableViewImpl::GetInstance(*this);
399 SysAssertf(pImpl != null, "Not-yet constructed! Construct() should be called before use.");
401 return pImpl->GetScrollInputMode();
405 //GroupedTableView::BeginReorderingMode(void)
407 // _TableViewImpl* pImpl = _TableViewImpl::GetInstance(*this);
408 // SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
410 // pImpl->BeginReorderingMode();
414 //GroupedTableView::EndReorderingMode(void)
416 // _TableViewImpl* pImpl = _TableViewImpl::GetInstance(*this);
417 // SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
419 // pImpl->EndReorderingMode();
423 //GroupedTableView::IsInReorderingMode(void) const
425 // const _TableViewImpl* pImpl = _TableViewImpl::GetInstance(*this);
426 // SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
428 // return pImpl->IsInReorderingMode();
432 GroupedTableView::GetCurrentScrollPosition(void) const
434 const _TableViewImpl* pImpl = _TableViewImpl::GetInstance(*this);
435 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
437 return pImpl->GetCurrentScrollPosition();
441 GroupedTableView::SetScrollEnabled(bool enable)
443 _TableViewImpl* pImpl = _TableViewImpl::GetInstance(*this);
444 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
446 pImpl->SetScrollEnabled(enable);
452 GroupedTableView::IsScrollEnabled(void) const
454 const _TableViewImpl* pImpl = _TableViewImpl::GetInstance(*this);
455 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
457 return pImpl->IsScrollEnabled();
460 }}} //Tizen::Ui::Controls