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 FUiCtrlList.cpp
20 * @brief This is the implementation file for List class.
22 * This file contains the implementation of List class.
25 #include <FUiCtrlList.h>
26 #include <FBaseSysLog.h>
27 #include "FUiCtrl_ListViewImpl.h"
28 #include "FUiCtrl_ListImpl.h"
30 using namespace Tizen::Graphics;
31 using namespace Tizen::Base;
33 namespace Tizen { namespace Ui { namespace Controls
47 List::Construct(const Rectangle& rect, ListStyle style, ListItemFormat itemFormat, int row1Height, int row2Height, int column1Width, int column2Width)
50 _ListImpl* pImpl = _ListImpl::GetInstance(*this);
52 SysAssertf((pImpl == null),
53 "Already constructed! Calling Construct() twice or more on a same instance is not allowed for this class");
55 SysTryReturn(NID_UI_CTRL, (row1Height > 0 && row2Height >= 0),
56 E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] row1Height must be greater than %d and row2Height must be greater than or equal to %d.", 0, 0);
58 SysTryReturn(NID_UI_CTRL, (column1Width > 0 && column2Width >= 0),
59 E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] column1Width must be greater than %d and column2Width must be greater than or equal to %d.", 0, 0);
61 pImpl = _ListImpl::CreateListImplN(this, rect);
63 SysTryReturn(NID_UI_CTRL, pImpl, r, r, "[%s] Propagating.", GetErrorMessage(r));
65 _pControlImpl = pImpl;
67 r = pImpl->UpdateBounds(rect);
68 SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r));
70 r = pImpl->SetStyle(style);
71 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] The current value of list style is invalid.", GetErrorMessage(r));
73 r = pImpl->Initialize(itemFormat, row1Height, row2Height, column1Width, column2Width);
74 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
76 r = pImpl->LoadDefaultBitmap();
77 SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r));
90 List::AddItemEventListener(IItemEventListener& listener)
92 _ListImpl* pImpl = _ListImpl::GetInstance(*this);
93 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
95 result r = pImpl->AddItemEventListener(listener);
96 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
98 SetLastResult(E_SUCCESS);
104 List::RemoveItemEventListener(IItemEventListener& listener)
106 _ListImpl* pImpl = _ListImpl::GetInstance(*this);
107 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
109 result r = pImpl->RemoveItemEventListener(listener);
110 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
112 SetLastResult(E_SUCCESS);
118 List::AddItem(const String* pText1, const String* pText2,
119 const Bitmap* pBitmap1, const Bitmap* pBitmap2, int itemId)
121 _ListImpl* pImpl = _ListImpl::GetInstance(*this);
122 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
124 result r = pImpl->AddItem(pText1, pText2, pBitmap1, pBitmap2, itemId);
125 SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r));
131 List::InsertItemAt(int index, const String* pText1, const String* pText2,
132 const Bitmap* pBitmap1, const Bitmap* pBitmap2, int itemId)
134 _ListImpl* pImpl = _ListImpl::GetInstance(*this);
135 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
137 result r = pImpl->InsertItemAt(index, pText1, pText2, pBitmap1, pBitmap2, itemId);
138 SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r));
144 List::SetItemAt(int index, const String* pText1, const String* pText2,
145 const Bitmap* pBitmap1, const Bitmap* pBitmap2, int itemId)
147 _ListImpl* pImpl = _ListImpl::GetInstance(*this);
148 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
150 result r = pImpl->SetItemAt(index, pText1, pText2, pBitmap1, pBitmap2, itemId);
151 SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r));
157 List::RemoveItemAt(int index)
159 _ListImpl* pImpl = _ListImpl::GetInstance(*this);
160 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
162 result r = pImpl->RemoveItemAt(index);
163 SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r));
169 List::RemoveAllItems(void)
171 _ListImpl* pImpl = _ListImpl::GetInstance(*this);
172 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
174 result r = pImpl->RemoveAllItems();
175 SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r));
181 List::GetItemCount(void) const
183 const _ListImpl* pImpl = _ListImpl::GetInstance(*this);
184 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
186 SetLastResult(E_SUCCESS);
188 return pImpl->GetItemCount();
192 List::SetItemEnabled(int index, bool enable)
194 _ListImpl* pImpl = _ListImpl::GetInstance(*this);
195 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
197 result r = pImpl->SetItemEnabled(index, enable);
198 SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r));
204 List::IsItemEnabled(int index) const
206 const _ListImpl* pImpl = _ListImpl::GetInstance(*this);
207 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
209 SetLastResult(E_SUCCESS);
210 return pImpl->IsItemEnabled(index);
214 List::SetFocusedItemBackgroundBitmap(const Bitmap& bitmap)
216 _ListImpl* pImpl = _ListImpl::GetInstance(*this);
217 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
219 pImpl->SetFocusedItemBackgroundBitmap(bitmap);
220 SetLastResult(E_SUCCESS);
226 List::SetHighlightedItemBackgroundBitmap(const Bitmap& bitmap)
228 _ListImpl* pImpl = _ListImpl::GetInstance(*this);
229 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
231 pImpl->SetHighlightedItemBackgroundBitmap(bitmap);
232 SetLastResult(E_SUCCESS);
238 List::SetNormalItemBackgroundBitmap(const Bitmap& bitmap)
240 _ListImpl* pImpl = _ListImpl::GetInstance(*this);
241 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
243 pImpl->SetNormalItemBackgroundBitmap(bitmap);
244 SetLastResult(E_SUCCESS);
250 List::GetTopDrawnItemIndex(void) const
252 const _ListImpl* pImpl = _ListImpl::GetInstance(*this);
253 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
258 result r = pImpl->GetTopDrawnItemIndex(groupIndex, itemIndex);
259 SysTryReturnResult(NID_UI_CTRL, (r == E_SUCCESS), E_SYSTEM, "[%s] Propagating.", GetErrorMessage(r));
265 List::GetBottomDrawnItemIndex(void) const
267 const _ListImpl* pImpl = _ListImpl::GetInstance(*this);
268 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
273 result r = pImpl->GetBottomDrawnItemIndex(groupIndex, itemIndex);
274 SysTryReturnResult(NID_UI_CTRL, (r == E_SUCCESS), E_SYSTEM, "[%s] Propagating.", GetErrorMessage(r));
280 List::SetTextOfEmptyList(const String& text)
282 _ListImpl* pImpl = _ListImpl::GetInstance(*this);
283 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
285 pImpl->SetTextOfEmptyList(text);
286 SetLastResult(E_SUCCESS);
292 List::SetTextColorOfEmptyList(const Color& color)
294 _ListImpl* pImpl = _ListImpl::GetInstance(*this);
295 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
297 pImpl->SetTextColorOfEmptyList(color);
298 SetLastResult(E_SUCCESS);
304 List::GetTextColorOfEmptyList(void) const
306 const _ListImpl* pImpl = _ListImpl::GetInstance(*this);
307 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
308 SetLastResult(E_SUCCESS);
310 return pImpl->GetTextColorOfEmptyList();
314 List::SetBackgroundColor(const Color& color)
316 _ListImpl* pImpl = _ListImpl::GetInstance(*this);
317 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
319 pImpl->SetBackgroundColor(color);
320 SetLastResult(E_SUCCESS);
326 List::SetItemTextColor(ListItemText textIndex, const Color& textColor)
328 _ListImpl* pImpl = _ListImpl::GetInstance(*this);
329 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
331 pImpl->SetItemTextColor(textIndex, textColor);
332 SetLastResult(E_SUCCESS);
338 List::GetItemTextColor(ListItemText textIndex) const
340 const _ListImpl* pImpl = _ListImpl::GetInstance(*this);
341 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
342 SetLastResult(E_SUCCESS);
344 return pImpl->GetItemTextColor(textIndex);
348 List::EnableTextSlide(ListItemText textIndex)
350 _ListImpl* pImpl = _ListImpl::GetInstance(*this);
351 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
353 pImpl->EnableTextSlide(textIndex);
354 SetLastResult(E_SUCCESS);
360 List::DisableTextSlide(void)
362 _ListImpl* pImpl = _ListImpl::GetInstance(*this);
363 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
365 pImpl->DisableTextSlide();
366 SetLastResult(E_SUCCESS);
372 List::GetItemHeight(void) const
374 const _ListImpl* pImpl = _ListImpl::GetInstance(*this);
375 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
376 SetLastResult(E_SUCCESS);
378 return pImpl->GetItemHeight();
382 List::GetRow1Height(void) const
384 const _ListImpl* pImpl = _ListImpl::GetInstance(*this);
385 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
386 SetLastResult(E_SUCCESS);
388 return pImpl->GetRow1Height();
392 List::GetRow2Height(void) const
394 const _ListImpl* pImpl = _ListImpl::GetInstance(*this);
395 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
396 SetLastResult(E_SUCCESS);
398 return pImpl->GetRow2Height();
402 List::GetColumn1Width(void) const
404 const _ListImpl* pImpl = _ListImpl::GetInstance(*this);
405 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
406 SetLastResult(E_SUCCESS);
408 return pImpl->GetColumn1Width();
412 List::GetColumn2Width(void) const
414 const _ListImpl* pImpl = _ListImpl::GetInstance(*this);
415 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
416 SetLastResult(E_SUCCESS);
418 return pImpl->GetColumn2Width();
422 List::SetRow1Height(int row1Height)
424 _ListImpl* pImpl = _ListImpl::GetInstance(*this);
425 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
427 SysTryReturn(NID_UI_CTRL, row1Height > 0,
428 E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] row1Height must be greater than 0.");
430 result r = pImpl->SetRow1Height(row1Height);
431 SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r));
437 List::SetRow2Height(int row2Height)
439 _ListImpl* pImpl = _ListImpl::GetInstance(*this);
440 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
442 SysTryReturn(NID_UI_CTRL, row2Height >= 0,
443 E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] row2Height must be greater than or equal to 0.");
445 result r = pImpl->SetRow2Height(row2Height);
446 SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r));
452 List::SetColumn1Width(int column1Width)
454 _ListImpl* pImpl = _ListImpl::GetInstance(*this);
455 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
457 SysTryReturn(NID_UI_CTRL, column1Width > 0,
458 E_SYSTEM, E_SYSTEM, "[E_SYSTEM] column1Width must be greater than 0.");
460 result r = pImpl->SetColumn1Width(column1Width);
461 SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r));
467 List::SetColumn2Width(int column2Width)
469 _ListImpl* pImpl = _ListImpl::GetInstance(*this);
470 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
472 SysTryReturn(NID_UI_CTRL, column2Width >= 0,
473 E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] column2Width must be greater than or equal to 0.");
475 result r = pImpl->SetColumn2Width(column2Width);
476 SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r));
482 List::SetItemChecked(int index, bool check)
484 _ListImpl* pImpl = _ListImpl::GetInstance(*this);
485 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
487 result r = pImpl->SetItemChecked(index, check);
488 SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r));
494 List::IsItemChecked(int index) const
496 const _ListImpl* pImpl = _ListImpl::GetInstance(*this);
497 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
498 SetLastResult(E_SUCCESS);
500 return pImpl->IsItemChecked(index);
504 List::SetAllItemsChecked(bool check)
506 _ListImpl* pImpl = _ListImpl::GetInstance(*this);
507 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
509 result r = pImpl->SetAllItemsChecked(check);
510 SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r));
516 List::RemoveAllCheckedItems(void)
518 _ListImpl* pImpl = _ListImpl::GetInstance(*this);
519 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
521 result r = pImpl->RemoveAllCheckedItems();
522 SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r));
528 List::GetFirstCheckedItemIndex(void) const
530 const _ListImpl* pImpl = _ListImpl::GetInstance(*this);
531 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
532 SetLastResult(E_SUCCESS);
534 return pImpl->GetFirstCheckedItemIndex();
538 List::GetLastCheckedItemIndex(void) const
540 const _ListImpl* pImpl = _ListImpl::GetInstance(*this);
541 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
542 SetLastResult(E_SUCCESS);
544 return pImpl->GetLastCheckedItemIndex();
548 List::GetNextCheckedItemIndexAfter(int index) const
550 const _ListImpl* pImpl = _ListImpl::GetInstance(*this);
551 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
552 SetLastResult(E_SUCCESS);
554 return pImpl->GetNextCheckedItemIndexAfter(index);
558 List::GetItemIndexFromItemId(int itemId) const
560 const _ListImpl* pImpl = _ListImpl::GetInstance(*this);
561 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
562 SetLastResult(E_SUCCESS);
564 return pImpl->GetItemIndexFromItemId(itemId);
568 List::GetItemIndexFromPosition(int x, int y) const
570 const _ListImpl* pImpl = _ListImpl::GetInstance(*this);
571 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
576 result r = pImpl->GetItemIndexFromPosition(Point(x, y), groupIndex, itemIndex);
577 SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), -1, E_SYSTEM, "[%s] Propagating.", GetErrorMessage(r));
583 List::GetItemIndexFromPosition(const Point& position) const
585 const _ListImpl* pImpl = _ListImpl::GetInstance(*this);
586 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
591 result r = pImpl->GetItemIndexFromPosition(position, groupIndex, itemIndex);
592 SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), -1, E_SYSTEM, "[%s] Propagating.", GetErrorMessage(r));
598 List::GetItemIdAt(int index) const
600 const _ListImpl* pImpl = _ListImpl::GetInstance(*this);
601 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
602 SetLastResult(E_SUCCESS);
604 return pImpl->GetItemIdAt(index);
608 List::ScrollToBottom(void)
610 _ListImpl* pImpl = _ListImpl::GetInstance(*this);
611 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
613 pImpl->ScrollToBottom();
614 SetLastResult(E_SUCCESS);
620 List::ScrollToTop(void)
622 _ListImpl* pImpl = _ListImpl::GetInstance(*this);
623 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
625 pImpl->ScrollToTop();
626 SetLastResult(E_SUCCESS);
632 List::ScrollToTop(int index)
634 _ListImpl* pImpl = _ListImpl::GetInstance(*this);
635 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
637 result r = pImpl->ScrollToTop(index);
638 SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r));
644 List::RefreshItem(int index)
646 _ListImpl* pImpl = _ListImpl::GetInstance(*this);
647 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
649 result r = pImpl->RefreshItem(index);
650 SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r));
655 }}} //Tizen::Ui::Controls