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 FUiCtrlSectionTableView.cpp
20 * @brief This is the implementation file for SectionTableView class.
22 * This header file contains the implementation of SectionTableView class.
25 #include <FUiContainer.h>
26 #include <FUiCtrlSectionTableView.h>
27 #include <FUiCtrlISectionTableViewItemProvider.h>
28 #include <FUiCtrlISectionTableViewItemEventListener.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 /// SectionTableView class
40 SectionTableView::SectionTableView(void)
44 SectionTableView::~SectionTableView(void)
49 SectionTableView::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_SECTION, 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 SectionTableView::SetItemProvider(ISectionTableViewItemProvider* pProvider)
77 _TableViewImpl* pImpl = _TableViewImpl::GetInstance(*this);
78 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
80 pImpl->SetSectionStyleItemProvider(pProvider);
85 SectionTableView::AddSectionTableViewItemEventListener(ISectionTableViewItemEventListener& listener)
87 _TableViewImpl* pImpl = _TableViewImpl::GetInstance(*this);
88 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
90 return pImpl->AddSectionTableViewItemEventListener(listener);
94 SectionTableView::RemoveSectionTableViewItemEventListener(ISectionTableViewItemEventListener& listener)
96 _TableViewImpl* pImpl = _TableViewImpl::GetInstance(*this);
97 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
99 return pImpl->RemoveSectionTableViewItemEventListener(listener);
103 SectionTableView::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 SectionTableView::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 SectionTableView::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 SectionTableView::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 SectionTableView::SetFastScrollIndex(const String& text, bool useSearchIcon)
141 _TableViewImpl* pImpl = _TableViewImpl::GetInstance(*this);
142 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
144 return pImpl->SetFastScrollIndex(text, useSearchIcon);
148 SectionTableView::GetTopDrawnItemIndex(int& sectionIndex, int& itemIndex) const
150 const _TableViewImpl* pImpl = _TableViewImpl::GetInstance(*this);
151 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
153 return pImpl->GetTopDrawnItemIndex(sectionIndex, itemIndex);
157 SectionTableView::GetBottomDrawnItemIndex(int& sectionIndex, int& itemIndex) const
159 const _TableViewImpl* pImpl = _TableViewImpl::GetInstance(*this);
160 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
163 return pImpl->GetBottomDrawnItemIndex(sectionIndex, itemIndex);
167 SectionTableView::SetItemChecked(int sectionIndex, int itemIndex, bool check)
169 _TableViewImpl* pImpl = _TableViewImpl::GetInstance(*this);
170 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
172 return pImpl->SetItemChecked(sectionIndex, itemIndex, check);
176 SectionTableView::IsItemChecked(int sectionIndex, int itemIndex) const
178 const _TableViewImpl* pImpl = _TableViewImpl::GetInstance(*this);
179 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
181 return pImpl->IsItemChecked(sectionIndex, itemIndex);
185 SectionTableView::SetItemEnabled(int sectionIndex, int itemIndex, bool enable)
187 _TableViewImpl* pImpl = _TableViewImpl::GetInstance(*this);
188 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
190 return pImpl->SetItemEnabled(sectionIndex, itemIndex, enable);
194 SectionTableView::IsItemEnabled(int sectionIndex, 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->IsItemEnabled(sectionIndex, itemIndex);
203 SectionTableView::GetSectionCount(void) const
205 const _TableViewImpl* pImpl = _TableViewImpl::GetInstance(*this);
206 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
208 return pImpl->GetGroupCount();
212 SectionTableView::GetItemCountAt(int sectionIndex) const
214 const _TableViewImpl* pImpl = _TableViewImpl::GetInstance(*this);
215 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
217 return pImpl->GetItemCountAt(sectionIndex);
221 SectionTableView::RefreshItem(int sectionIndex, int itemIndex, TableViewRefreshType type)
223 _TableViewImpl* pImpl = _TableViewImpl::GetInstance(*this);
224 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
226 return pImpl->RefreshTableView(sectionIndex, itemIndex, type);
230 SectionTableView::UpdateTableView(void)
232 _TableViewImpl* pImpl = _TableViewImpl::GetInstance(*this);
233 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
235 pImpl->UpdateTableView();
239 SectionTableView::GetItemIndexFromPosition(const Tizen::Graphics::Point& position, int& sectionIndex, int& itemIndex) const
241 const _TableViewImpl* pImpl = _TableViewImpl::GetInstance(*this);
242 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
244 return pImpl->GetItemIndexFromPosition(position, sectionIndex, itemIndex);
248 SectionTableView::SetSectionColor(const Color& color)
250 _TableViewImpl* pImpl = _TableViewImpl::GetInstance(*this);
251 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
253 pImpl->SetSectionColor(color);
257 SectionTableView::GetSectionColor(void) const
259 const _TableViewImpl* pImpl = _TableViewImpl::GetInstance(*this);
260 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
262 return pImpl->GetSectionColor();
266 SectionTableView::SetItemDividerColor(const Color& color)
268 _TableViewImpl* pImpl = _TableViewImpl::GetInstance(*this);
269 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
271 pImpl->SetItemDividerColor(color);
275 SectionTableView::GetItemDividerColor(void) const
277 const _TableViewImpl* pImpl = _TableViewImpl::GetInstance(*this);
278 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
280 return pImpl->GetItemDividerColor();
284 SectionTableView::SetBackgroundColor(const Color& color)
286 _TableViewImpl* pImpl = _TableViewImpl::GetInstance(*this);
287 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
289 pImpl->SetBackgroundColor(color);
295 SectionTableView::GetBackgroundColor(void) const
297 const _TableViewImpl* pImpl = _TableViewImpl::GetInstance(*this);
298 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
300 return pImpl->GetBackgroundColor();
304 SectionTableView::SetGroupedLookEnabled(bool enable)
306 _TableViewImpl* pImpl = _TableViewImpl::GetInstance(*this);
307 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
309 pImpl->SetGroupedLookEnabled(enable);
313 SectionTableView::IsGroupedLookEnabled(void) const
315 const _TableViewImpl* pImpl = _TableViewImpl::GetInstance(*this);
316 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
318 return pImpl->IsGroupedLookEnabled();
322 SectionTableView::ScrollToItem(int sectionIndex, int itemIndex, TableViewScrollItemAlignment itemAlignment)
324 _TableViewImpl* pImpl = _TableViewImpl::GetInstance(*this);
325 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
327 result r = pImpl->ScrollToItem(sectionIndex, itemIndex, itemAlignment);
328 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
334 SectionTableView::ScrollByPixel(int scrollDistance)
336 _TableViewImpl* pImpl = _TableViewImpl::GetInstance(*this);
337 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
339 result r = pImpl->ScrollByPixel(scrollDistance);
340 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
346 SectionTableView::GetCurrentScrollPosition(void) const
348 const _TableViewImpl* pImpl = _TableViewImpl::GetInstance(*this);
349 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
351 return pImpl->GetCurrentScrollPosition();
355 SectionTableView::SetScrollEnabled(bool enable)
357 _TableViewImpl* pImpl = _TableViewImpl::GetInstance(*this);
358 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
360 pImpl->SetScrollEnabled(enable);
366 SectionTableView::IsScrollEnabled(void) const
368 const _TableViewImpl* pImpl = _TableViewImpl::GetInstance(*this);
369 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
371 return pImpl->IsScrollEnabled();
375 SectionTableView::SetScrollInputMode(ScrollInputMode mode)
377 _TableViewImpl* pImpl = _TableViewImpl::GetInstance(*this);
378 SysAssertf(pImpl != null, "Not-yet constructed! Construct() should be called before use.");
380 pImpl->SetScrollInputMode(mode);
384 SectionTableView::GetScrollInputMode(void) const
386 const _TableViewImpl* pImpl = _TableViewImpl::GetInstance(*this);
387 SysAssertf(pImpl != null, "Not-yet constructed! Construct() should be called before use.");
389 return pImpl->GetScrollInputMode();
392 }}} //Tizen::Ui::Controls