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 FUiCtrlTableView.cpp
20 * @brief This is the implementation file for TableView class.
22 * This header file contains the implementation of TableView class.
25 #include <FUiContainer.h>
26 #include <FUiCtrlTableView.h>
27 #include <FUiCtrlITableViewItemProvider.h>
28 #include <FUiCtrlITableViewItemProviderF.h>
29 #include <FUiCtrlITableViewItemEventListener.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 ////////////////////////////////////////////////////////////////////////////////
42 TableView::TableView(void)
46 TableView::~TableView(void)
51 TableView::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_SIMPLE, 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 TableView::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_SIMPLE, 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 TableView::SetItemProvider(ITableViewItemProvider* pProvider)
105 _TableViewImpl* pImpl = _TableViewImpl::GetInstance(*this);
106 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
108 pImpl->SetSimpleStyleItemProvider(pProvider);
112 TableView::SetItemProviderF(ITableViewItemProviderF* pProvider)
114 _TableViewImpl* pImpl = _TableViewImpl::GetInstance(*this);
115 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
117 pImpl->SetSimpleStyleItemProviderF(pProvider);
121 TableView::AddTableViewItemEventListener(ITableViewItemEventListener& listener)
123 _TableViewImpl* pImpl = _TableViewImpl::GetInstance(*this);
124 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
126 return pImpl->AddTableViewItemEventListener(listener);
130 TableView::RemoveTableViewItemEventListener(ITableViewItemEventListener& listener)
132 _TableViewImpl* pImpl = _TableViewImpl::GetInstance(*this);
133 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
135 return pImpl->RemoveTableViewItemEventListener(listener);
139 TableView::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 TableView::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 TableView::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 TableView::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 TableView::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 TableView::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 TableView::SetFastScrollIndex(const String& text, bool useSearchIcon)
195 _TableViewImpl* pImpl = _TableViewImpl::GetInstance(*this);
196 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
198 return pImpl->SetFastScrollIndex(text, useSearchIcon);
202 TableView::GetTopDrawnItemIndex(void) const
204 const _TableViewImpl* pImpl = _TableViewImpl::GetInstance(*this);
205 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
209 pImpl->GetTopDrawnItemIndex(groupIndex, itemIndex);
215 TableView::GetBottomDrawnItemIndex(void) const
217 const _TableViewImpl* pImpl = _TableViewImpl::GetInstance(*this);
218 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
222 pImpl->GetBottomDrawnItemIndex(groupIndex, itemIndex);
228 TableView::ScrollToItem(int itemIndex, TableViewScrollItemAlignment itemAlignment)
230 _TableViewImpl* pImpl = _TableViewImpl::GetInstance(*this);
231 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
233 result r = pImpl->ScrollToItem(0, itemIndex, itemAlignment);
234 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
240 TableView::SetItemChecked(int itemIndex, bool check)
242 _TableViewImpl* pImpl = _TableViewImpl::GetInstance(*this);
243 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
245 return pImpl->SetItemChecked(0, itemIndex, check);
249 TableView::IsItemChecked(int itemIndex) const
251 const _TableViewImpl* pImpl = _TableViewImpl::GetInstance(*this);
252 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
254 return pImpl->IsItemChecked(0, itemIndex);
258 TableView::SetItemEnabled(int itemIndex, bool enable)
260 _TableViewImpl* pImpl = _TableViewImpl::GetInstance(*this);
261 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
263 return pImpl->SetItemEnabled(0, itemIndex, enable);
267 TableView::IsItemEnabled(int itemIndex) const
269 const _TableViewImpl* pImpl = _TableViewImpl::GetInstance(*this);
270 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
272 return pImpl->IsItemEnabled(0, itemIndex);
276 TableView::GetItemCount(void) const
278 const _TableViewImpl* pImpl = _TableViewImpl::GetInstance(*this);
279 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
281 return pImpl->GetItemCountAt(0);
285 TableView::RefreshItem(int itemIndex, TableViewRefreshType type)
287 _TableViewImpl* pImpl = _TableViewImpl::GetInstance(*this);
288 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
290 return pImpl->RefreshTableView(0, itemIndex, type);
294 TableView::RefreshAllItems(void)
296 _TableViewImpl* pImpl = _TableViewImpl::GetInstance(*this);
297 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
299 return pImpl->RefreshAllItems();
303 TableView::UpdateTableView(void)
305 _TableViewImpl* pImpl = _TableViewImpl::GetInstance(*this);
306 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
308 pImpl->UpdateTableView();
312 TableView::GetItemIndexFromPosition(const Point& position) const
314 const _TableViewImpl* pImpl = _TableViewImpl::GetInstance(*this);
315 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
320 pImpl->GetItemIndexFromPosition(position, groupIndex, itemIndex);
326 TableView::GetItemIndexFromPosition(const Tizen::Graphics::FloatPoint& position) const
328 const _TableViewImpl* pImpl = _TableViewImpl::GetInstance(*this);
329 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
334 pImpl->GetItemIndexFromPosition(position, groupIndex, itemIndex);
341 TableView::SetItemDividerColor(const Color& color)
343 _TableViewImpl* pImpl = _TableViewImpl::GetInstance(*this);
344 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
346 pImpl->SetItemDividerColor(color);
350 TableView::GetItemDividerColor(void) const
352 const _TableViewImpl* pImpl = _TableViewImpl::GetInstance(*this);
353 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
355 return pImpl->GetItemDividerColor();
359 TableView::SetBackgroundColor(const Color& color)
361 _TableViewImpl* pImpl = _TableViewImpl::GetInstance(*this);
362 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
364 pImpl->SetBackgroundColor(color);
370 TableView::GetBackgroundColor(void) const
372 const _TableViewImpl* pImpl = _TableViewImpl::GetInstance(*this);
373 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
375 return pImpl->GetBackgroundColor();
379 TableView::BeginReorderingMode(void)
381 _TableViewImpl* pImpl = _TableViewImpl::GetInstance(*this);
382 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
384 pImpl->BeginReorderingMode();
388 TableView::EndReorderingMode(void)
390 _TableViewImpl* pImpl = _TableViewImpl::GetInstance(*this);
391 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
393 pImpl->EndReorderingMode();
397 TableView::IsInReorderingMode(void) const
399 const _TableViewImpl* pImpl = _TableViewImpl::GetInstance(*this);
400 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
402 return pImpl->IsInReorderingMode();
406 TableView::ScrollByPixel(int pixel)
408 _TableViewImpl* pImpl = _TableViewImpl::GetInstance(*this);
409 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
411 result r = pImpl->ScrollByPixel(_CoordinateSystemUtils::ConvertToFloat(pixel));
412 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
418 TableView::ScrollByPixel(float pixel)
420 _TableViewImpl* pImpl = _TableViewImpl::GetInstance(*this);
421 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
423 result r = pImpl->ScrollByPixel(pixel);
424 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
430 TableView::GetCurrentScrollPosition(void) const
432 const _TableViewImpl* pImpl = _TableViewImpl::GetInstance(*this);
433 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
435 return _CoordinateSystemUtils::ConvertToInteger(pImpl->GetCurrentScrollPosition());
439 TableView::GetCurrentScrollPositionF(void) const
441 const _TableViewImpl* pImpl = _TableViewImpl::GetInstance(*this);
442 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
444 return pImpl->GetCurrentScrollPosition();
449 TableView::SetScrollEnabled(bool enable)
451 _TableViewImpl* pImpl = _TableViewImpl::GetInstance(*this);
452 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
454 pImpl->SetScrollEnabled(enable);
460 TableView::IsScrollEnabled(void) const
462 const _TableViewImpl* pImpl = _TableViewImpl::GetInstance(*this);
463 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
465 return pImpl->IsScrollEnabled();
469 TableView::SetScrollInputMode(ScrollInputMode mode)
471 _TableViewImpl* pImpl = _TableViewImpl::GetInstance(*this);
472 SysAssertf(pImpl != null, "Not-yet constructed! Construct() should be called before use.");
474 pImpl->SetScrollInputMode(mode);
478 TableView::GetScrollInputMode(void) const
480 const _TableViewImpl* pImpl = _TableViewImpl::GetInstance(*this);
481 SysAssertf(pImpl != null, "Not-yet constructed! Construct() should be called before use.");
483 return pImpl->GetScrollInputMode();
487 TableView::OpenContextItem(int itemIndex)
489 _TableViewImpl* pImpl = _TableViewImpl::GetInstance(*this);
490 SysAssertf(pImpl != null, "Not-yet constructed! Construct() should be called before use.");
492 return pImpl->OpenContextItem(0, itemIndex);
496 TableView::CloseContextItem(int itemIndex)
498 _TableViewImpl* pImpl = _TableViewImpl::GetInstance(*this);
499 SysAssertf(pImpl != null, "Not-yet constructed! Construct() should be called before use.");
501 return pImpl->CloseContextItem(0, itemIndex);
505 TableView::IsContextItemOpened(int itemIndex) const
507 const _TableViewImpl* pImpl = _TableViewImpl::GetInstance(*this);
508 SysAssertf(pImpl != null, "Not-yet constructed! Construct() should be called before use.");
510 return pImpl->IsContextItemOpened(0, itemIndex);
513 }}} //Tizen::Ui::Controls