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 FUiCtrlListView.cpp
20 * @brief This is the implementation file for ListView class.
22 * This file contains the implementation of ListView class.
25 #include <FBaseSysLog.h>
26 #include <FUiCtrlListView.h>
27 #include "FUiCtrl_ListViewImpl.h"
29 using namespace Tizen::Base;
30 using namespace Tizen::Graphics;
32 namespace Tizen { namespace Ui { namespace Controls
35 ListView::ListView(void)
39 ListView::~ListView(void)
44 ListView::Construct(const Rectangle& rect, bool itemDivider, bool fastScroll)
48 _ListViewImpl* pImpl = _ListViewImpl::GetInstance(*this);
49 SysAssertf(pImpl == null,
50 "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class.");
52 if (fastScroll == true)
54 pImpl = _ListViewImpl::CreateListViewImplN(this, itemDivider, SCROLL_STYLE_FAST_SCROLL);
58 pImpl = _ListViewImpl::CreateListViewImplN(this, itemDivider, SCROLL_STYLE_FADE_OUT);
60 SysTryReturn(NID_UI_CTRL, pImpl != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
62 _pControlImpl = pImpl;
63 r = Control::SetBounds(rect.x, rect.y, rect.width, rect.height);
64 SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r));
75 ListView::Construct(const Rectangle& rect, bool itemDivider, ListScrollStyle scrollStyle)
79 _ListViewImpl* pImpl = _ListViewImpl::GetInstance(*this);
80 SysAssertf(pImpl == null,
81 "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class.");
83 pImpl = _ListViewImpl::CreateListViewImplN(this, itemDivider, scrollStyle);
84 SysTryReturn(NID_UI_CTRL, pImpl != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
86 _pControlImpl = pImpl;
87 r = Control::SetBounds(rect.x, rect.y, rect.width, rect.height);
88 SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r));
99 ListView::SetItemProvider(IListViewItemProvider& provider)
101 _ListViewImpl* pImpl = _ListViewImpl::GetInstance(*this);
102 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
104 return pImpl->SetItemProvider(provider);
108 ListView::AddListViewItemEventListener(IListViewItemEventListener& listener)
110 _ListViewImpl* pImpl = _ListViewImpl::GetInstance(*this);
111 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
113 pImpl->AddListViewItemEventListener(listener);
114 SysTryReturnVoidResult(NID_UI_CTRL, GetLastResult() == E_SUCCESS, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
118 ListView::RemoveListViewItemEventListener(IListViewItemEventListener& listener)
120 _ListViewImpl* pImpl = _ListViewImpl::GetInstance(*this);
121 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
123 pImpl->RemoveListViewItemEventListener(listener);
124 SysTryReturnVoidResult(NID_UI_CTRL, GetLastResult() == E_SUCCESS, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
128 ListView::AddFastScrollListener(IFastScrollListener& listener)
130 _ListViewImpl* pImpl = _ListViewImpl::GetInstance(*this);
131 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
133 pImpl->AddFastScrollListener(listener);
134 SysTryReturnVoidResult(NID_UI_CTRL, GetLastResult() == E_SUCCESS, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
138 ListView::RemoveFastScrollListener(IFastScrollListener& listener)
140 _ListViewImpl* pImpl = _ListViewImpl::GetInstance(*this);
141 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
143 pImpl->RemoveFastScrollListener(listener);
144 SysTryReturnVoidResult(NID_UI_CTRL, GetLastResult() == E_SUCCESS, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
148 ListView::AddScrollEventListener(IScrollEventListener& listener)
150 _ListViewImpl* pImpl = _ListViewImpl::GetInstance(*this);
151 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
153 pImpl->AddScrollEventListener(listener);
154 SysTryReturnVoidResult(NID_UI_CTRL, GetLastResult() == E_SUCCESS, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
158 ListView::RemoveScrollEventListener(IScrollEventListener& listener)
160 _ListViewImpl* pImpl = _ListViewImpl::GetInstance(*this);
161 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
163 pImpl->RemoveScrollEventListener(listener);
164 SysTryReturnVoidResult(NID_UI_CTRL, GetLastResult() == E_SUCCESS, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
168 ListView::AddUiLinkEventListener(IUiLinkEventListener& listener)
170 _ListViewImpl* pImpl = _ListViewImpl::GetInstance(*this);
171 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
173 pImpl->AddUiLinkEventListener(listener);
174 SysTryReturnVoidResult(NID_UI_CTRL, GetLastResult() == E_SUCCESS, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
178 ListView::RemoveUiLinkEventListener(IUiLinkEventListener& listener)
180 _ListViewImpl* pImpl = _ListViewImpl::GetInstance(*this);
181 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
183 pImpl->RemoveUiLinkEventListener(listener);
184 SysTryReturnVoidResult(NID_UI_CTRL, GetLastResult() == E_SUCCESS, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
188 ListView::SetSweepEnabled(bool enable)
190 _ListViewImpl* pImpl = _ListViewImpl::GetInstance(*this);
191 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
193 return pImpl->SetSweepEnabled(enable);
197 ListView::SetFastScrollIndex(const String& text, bool useSearchIcon)
199 _ListViewImpl* pImpl = _ListViewImpl::GetInstance(*this);
200 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
202 return pImpl->SetFastScrollIndex(text, useSearchIcon);
206 ListView::GetTopDrawnItemIndex(void) const
208 const _ListViewImpl* pImpl = _ListViewImpl::GetInstance(*this);
209 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
211 return pImpl->GetTopDrawnItemIndex();
215 ListView::GetBottomDrawnItemIndex(void) const
217 const _ListViewImpl* pImpl = _ListViewImpl::GetInstance(*this);
218 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
220 return pImpl->GetBottomDrawnItemIndex();
224 ListView::ScrollToItem(int index)
226 return ScrollToItem(index, LIST_SCROLL_ITEM_ALIGNMENT_TOP);
230 ListView::ScrollToItem(int index, ListScrollItemAlignment itemAlignment)
232 _ListViewImpl* pImpl = _ListViewImpl::GetInstance(*this);
233 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
235 return pImpl->ScrollToItem(index, itemAlignment);
239 ListView::SetItemChecked(int index, bool check)
241 _ListViewImpl* pImpl = _ListViewImpl::GetInstance(*this);
242 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
244 return pImpl->SetItemChecked(index, check);
248 ListView::IsItemChecked(int index) const
250 const _ListViewImpl* pImpl = _ListViewImpl::GetInstance(*this);
251 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
253 return pImpl->IsItemChecked(index);
257 ListView::SetItemEnabled(int index, bool enable)
259 _ListViewImpl* pImpl = _ListViewImpl::GetInstance(*this);
260 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
262 return pImpl->SetItemEnabled(index, enable);
266 ListView::IsItemEnabled(int index) const
268 const _ListViewImpl* pImpl = _ListViewImpl::GetInstance(*this);
269 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
271 return pImpl->IsItemEnabled(index);
275 ListView::GetItemCount(void) const
277 const _ListViewImpl* pImpl = _ListViewImpl::GetInstance(*this);
278 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
280 return pImpl->GetItemCount();
284 ListView::ShowItemDescriptionText(int index)
286 _ListViewImpl* pImpl = _ListViewImpl::GetInstance(*this);
287 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
289 return pImpl->ShowItemDescriptionText(index);
293 ListView::HideItemDescriptionText(int index)
295 _ListViewImpl* pImpl = _ListViewImpl::GetInstance(*this);
296 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
298 return pImpl->HideItemDescriptionText(index);
302 ListView::RefreshList(int index, ListRefreshType type)
304 _ListViewImpl* pImpl = _ListViewImpl::GetInstance(*this);
305 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
307 return pImpl->RefreshList(index, type);
311 ListView::RefreshList(int index, int elementId)
313 _ListViewImpl* pImpl = _ListViewImpl::GetInstance(*this);
314 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
316 return pImpl->RefreshList(index, elementId);
320 ListView::UpdateList(void)
322 _ListViewImpl* pImpl = _ListViewImpl::GetInstance(*this);
323 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
325 return pImpl->UpdateList();
329 ListView::GetItemIndexFromPosition(int x, int y) const
331 return GetItemIndexFromPosition(Point(x, y));
335 ListView::GetItemIndexFromPosition(const Point& position) const
337 const _ListViewImpl* pImpl = _ListViewImpl::GetInstance(*this);
338 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
340 return pImpl->GetItemIndexFromPosition(position);
344 ListView::GetItemIndexFromPosition(int x, int y, int& itemIndex, int& elementId) const
346 return GetItemIndexFromPosition(Point(x, y), itemIndex, elementId);
350 ListView::GetItemIndexFromPosition(const Point& position, int& itemIndex, int& elementId) const
352 const _ListViewImpl* pImpl = _ListViewImpl::GetInstance(*this);
353 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
355 return pImpl->GetItemIndexFromPosition(position, itemIndex, elementId);
359 ListView::SetItemDividerColor(const Color& color)
361 _ListViewImpl* pImpl = _ListViewImpl::GetInstance(*this);
362 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
364 return pImpl->SetItemDividerColor(color);
368 ListView::GetItemDividerColor(void) const
370 const _ListViewImpl* pImpl = _ListViewImpl::GetInstance(*this);
371 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
373 return pImpl->GetItemDividerColor();
377 ListView::SetBackgroundColor(const Color& color)
379 _ListViewImpl* pImpl = _ListViewImpl::GetInstance(*this);
380 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
382 pImpl->SetListBackgroundColor(color);
388 ListView::GetBackgroundColor(void) const
390 const _ListViewImpl* pImpl = _ListViewImpl::GetInstance(*this);
391 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
393 return pImpl->GetBackgroundColor();
397 ListView::SetBackgroundBitmap(const Bitmap* pBitmap)
399 _ListViewImpl* pImpl = _ListViewImpl::GetInstance(*this);
400 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
402 return pImpl->SetBackgroundBitmap(pBitmap);
406 ListView::SetBitmapOfEmptyList(const Bitmap* pBitmap)
408 _ListViewImpl* pImpl = _ListViewImpl::GetInstance(*this);
409 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
411 return pImpl->SetBitmapOfEmptyList(pBitmap);
415 ListView::SetTextOfEmptyList(const String& text)
417 _ListViewImpl* pImpl = _ListViewImpl::GetInstance(*this);
418 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
420 return pImpl->SetTextOfEmptyList(text);
424 ListView::GetTextOfEmptyList(void) const
426 const _ListViewImpl* pImpl = _ListViewImpl::GetInstance(*this);
427 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
429 return pImpl->GetTextOfEmptyList();
433 ListView::SetTextColorOfEmptyList(const Color& color)
435 _ListViewImpl* pImpl = _ListViewImpl::GetInstance(*this);
436 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
438 return pImpl->SetTextColorOfEmptyList(color);
442 ListView::GetTextColorOfEmptyList(void) const
444 const _ListViewImpl* pImpl = _ListViewImpl::GetInstance(*this);
445 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
447 return pImpl->GetTextColorOfEmptyList();
451 ListView::BeginReorderingMode(void)
453 _ListViewImpl* pImpl = _ListViewImpl::GetInstance(*this);
454 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
456 return pImpl->BeginReorderingMode();
460 ListView::EndReorderingMode(void)
462 _ListViewImpl* pImpl = _ListViewImpl::GetInstance(*this);
463 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
465 return pImpl->EndReorderingMode();
469 ListView::IsInReorderingMode(void) const
471 const _ListViewImpl* pImpl = _ListViewImpl::GetInstance(*this);
472 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
474 return pImpl->IsInReorderingMode();