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 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 <FUiCtrlITableViewItemEventListener.h>
29 #include "FUiCtrl_TableViewImpl.h"
31 using namespace Tizen::Base;
32 using namespace Tizen::Graphics;
34 namespace Tizen { namespace Ui { namespace Controls
37 ////////////////////////////////////////////////////////////////////////////////
40 TableView::TableView(void)
44 TableView::~TableView(void)
49 TableView::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_SIMPLE, 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 TableView::SetItemProvider(ITableViewItemProvider* pProvider)
77 _TableViewImpl* pImpl = _TableViewImpl::GetInstance(*this);
78 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
80 pImpl->SetSimpleStyleItemProvider(pProvider);
84 TableView::AddTableViewItemEventListener(ITableViewItemEventListener& listener)
86 _TableViewImpl* pImpl = _TableViewImpl::GetInstance(*this);
87 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
89 return pImpl->AddTableViewItemEventListener(listener);
93 TableView::RemoveTableViewItemEventListener(ITableViewItemEventListener& listener)
95 _TableViewImpl* pImpl = _TableViewImpl::GetInstance(*this);
96 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
98 return pImpl->RemoveTableViewItemEventListener(listener);
102 TableView::AddFastScrollListener(IFastScrollListener& listener)
104 _TableViewImpl* pImpl = _TableViewImpl::GetInstance(*this);
105 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
107 return pImpl->AddFastScrollListener(listener);
111 TableView::RemoveFastScrollListener(IFastScrollListener& listener)
113 _TableViewImpl* pImpl = _TableViewImpl::GetInstance(*this);
114 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
116 return pImpl->RemoveFastScrollListener(listener);
120 TableView::AddScrollEventListener(IScrollEventListener& listener)
122 _TableViewImpl* pImpl = _TableViewImpl::GetInstance(*this);
123 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
125 return pImpl->AddScrollEventListener(listener);
129 TableView::RemoveScrollEventListener(IScrollEventListener& listener)
131 _TableViewImpl* pImpl = _TableViewImpl::GetInstance(*this);
132 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
134 return pImpl->RemoveScrollEventListener(listener);
138 TableView::SetFastScrollIndex(const String& text, bool useSearchIcon)
140 _TableViewImpl* pImpl = _TableViewImpl::GetInstance(*this);
141 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
143 return pImpl->SetFastScrollIndex(text, useSearchIcon);
147 TableView::GetTopDrawnItemIndex(void) const
149 const _TableViewImpl* pImpl = _TableViewImpl::GetInstance(*this);
150 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
154 pImpl->GetTopDrawnItemIndex(groupIndex, itemIndex);
160 TableView::GetBottomDrawnItemIndex(void) const
162 const _TableViewImpl* pImpl = _TableViewImpl::GetInstance(*this);
163 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
167 pImpl->GetBottomDrawnItemIndex(groupIndex, itemIndex);
173 TableView::ScrollToItem(int itemIndex, TableViewScrollItemAlignment itemAlignment)
175 _TableViewImpl* pImpl = _TableViewImpl::GetInstance(*this);
176 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
178 result r = pImpl->ScrollToItem(0, itemIndex, itemAlignment);
179 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
185 TableView::SetItemChecked(int itemIndex, bool check)
187 _TableViewImpl* pImpl = _TableViewImpl::GetInstance(*this);
188 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
190 return pImpl->SetItemChecked(0, itemIndex, check);
194 TableView::IsItemChecked(int itemIndex) const
196 const _TableViewImpl* pImpl = _TableViewImpl::GetInstance(*this);
197 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
199 return pImpl->IsItemChecked(0, itemIndex);
203 TableView::SetItemEnabled(int itemIndex, bool enable)
205 _TableViewImpl* pImpl = _TableViewImpl::GetInstance(*this);
206 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
208 return pImpl->SetItemEnabled(0, itemIndex, enable);
212 TableView::IsItemEnabled(int itemIndex) const
214 const _TableViewImpl* pImpl = _TableViewImpl::GetInstance(*this);
215 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
217 return pImpl->IsItemEnabled(0, itemIndex);
221 TableView::GetItemCount(void) const
223 const _TableViewImpl* pImpl = _TableViewImpl::GetInstance(*this);
224 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
226 return pImpl->GetItemCountAt(0);
230 TableView::RefreshItem(int itemIndex, TableViewRefreshType type)
232 _TableViewImpl* pImpl = _TableViewImpl::GetInstance(*this);
233 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
235 return pImpl->RefreshTableView(0, itemIndex, type);
239 TableView::UpdateTableView(void)
241 _TableViewImpl* pImpl = _TableViewImpl::GetInstance(*this);
242 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
244 pImpl->UpdateTableView();
248 TableView::GetItemIndexFromPosition(const Point& position) const
250 const _TableViewImpl* pImpl = _TableViewImpl::GetInstance(*this);
251 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
256 pImpl->GetItemIndexFromPosition(position, groupIndex, itemIndex);
262 TableView::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 TableView::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 TableView::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 TableView::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 TableView::BeginReorderingMode(void)
302 _TableViewImpl* pImpl = _TableViewImpl::GetInstance(*this);
303 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
305 pImpl->BeginReorderingMode();
309 TableView::EndReorderingMode(void)
311 _TableViewImpl* pImpl = _TableViewImpl::GetInstance(*this);
312 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
314 pImpl->EndReorderingMode();
318 TableView::IsInReorderingMode(void) const
320 const _TableViewImpl* pImpl = _TableViewImpl::GetInstance(*this);
321 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
323 return pImpl->IsInReorderingMode();
327 TableView::ScrollByPixel(int scrollDistance)
329 _TableViewImpl* pImpl = _TableViewImpl::GetInstance(*this);
330 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
332 result r = pImpl->ScrollByPixel(scrollDistance);
333 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
339 TableView::GetCurrentScrollPosition(void) const
341 const _TableViewImpl* pImpl = _TableViewImpl::GetInstance(*this);
342 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
344 return pImpl->GetCurrentScrollPosition();
348 TableView::SetScrollEnabled(bool enable)
350 _TableViewImpl* pImpl = _TableViewImpl::GetInstance(*this);
351 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
353 pImpl->SetScrollEnabled(enable);
359 TableView::IsScrollEnabled(void) const
361 const _TableViewImpl* pImpl = _TableViewImpl::GetInstance(*this);
362 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
364 return pImpl->IsScrollEnabled();
368 TableView::SetScrollInputMode(ScrollInputMode mode)
370 _TableViewImpl* pImpl = _TableViewImpl::GetInstance(*this);
371 SysAssertf(pImpl != null, "Not-yet constructed! Construct() should be called before use.");
373 pImpl->SetScrollInputMode(mode);
377 TableView::GetScrollInputMode(void) const
379 const _TableViewImpl* pImpl = _TableViewImpl::GetInstance(*this);
380 SysAssertf(pImpl != null, "Not-yet constructed! Construct() should be called before use.");
382 return pImpl->GetScrollInputMode();
386 }}} //Tizen::Ui::Controls