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 FUiCtrlIconListView.cpp
20 * @brief This is the implementation file for the IconListView class.
24 #include <FBaseSysLog.h>
25 #include <FUiCtrlIconListView.h>
26 #include <FUiCtrlIconListViewItem.h>
28 #include "FUiCtrl_IconListViewImpl.h"
30 using namespace Tizen::Base;
31 using namespace Tizen::Graphics;
33 namespace Tizen { namespace Ui { namespace Controls
38 * @brief This class defines common behavior for a %IconListView control.
45 * @image html GUI_IconListView.png
47 * This is the simple UI application which uses a IconListView control.
55 IconListView::IconListView(void)
60 IconListView::~IconListView(void)
66 IconListView::Construct(const Rectangle& rect, const Dimension& itemBitmapSize, IconListViewStyle style,
67 IconListViewScrollDirection scrollDirection, IconListViewScrollStyle scrollStyle)
69 // Check whether _pControlImpl has been set, that is, "already constructed" condition.
70 SysAssertf(_pControlImpl == null,
71 "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class.");
73 // Create _IconListViewImpl
74 _IconListViewImpl* pImpl = _IconListViewImpl::CreateIconListViewImplN(this);
75 SysTryReturn(NID_UI_CTRL, (pImpl != null), GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
77 // Set _IconListViewImpl
78 _pControlImpl = pImpl;
81 result r = Control::SetBounds(rect.x, rect.y, rect.width, rect.height);
89 // Set Initial Parameters
90 r = pImpl->Initialize(this, itemBitmapSize, style, scrollDirection, scrollStyle);
101 IconListView::SetItemProvider(IIconListViewItemProvider& provider)
103 // Check whether _pControlImpl has not been set as a precondition of this method, that is, "not-yet constructed" condition.
104 SysAssertf(_pControlImpl != null, "Not yet constructed. Construct() should be called before use.");
106 _IconListViewImpl* pImpl = _IconListViewImpl::GetInstance(*this);
107 return pImpl->SetItemProvider(provider);
111 IconListView::AddIconListViewItemEventListener(IIconListViewItemEventListener& listener)
113 // Check whether _pControlImpl has not been set as a precondition of this method, that is, "not-yet constructed" condition.
114 SysAssertf(_pControlImpl != null, "Not yet constructed. Construct() should be called before use.");
116 _IconListViewImpl* pImpl = _IconListViewImpl::GetInstance(*this);
117 pImpl->AddIconListViewItemEventListener(listener);
121 IconListView::RemoveIconListViewItemEventListener(IIconListViewItemEventListener& listener)
123 // Check whether _pControlImpl has not been set as a precondition of this method, that is, "not-yet constructed" condition.
124 SysAssertf(_pControlImpl != null, "Not yet constructed. Construct() should be called before use.");
126 _IconListViewImpl* pImpl = _IconListViewImpl::GetInstance(*this);
127 pImpl->RemoveIconListViewItemEventListener(listener);
131 IconListView::AddScrollEventListener(IScrollEventListener& listener)
133 // Check whether _pControlImpl has not been set as a precondition of this method, that is, "not-yet constructed" condition.
134 SysAssertf(_pControlImpl != null, "Not yet constructed. Construct() should be called before use.");
136 _IconListViewImpl* pImpl = _IconListViewImpl::GetInstance(*this);
137 pImpl->AddScrollEventListener(listener);
141 IconListView::RemoveScrollEventListener(IScrollEventListener& listener)
143 // Check whether _pControlImpl has not been set as a precondition of this method, that is, "not-yet constructed" condition.
144 SysAssertf(_pControlImpl != null, "Not yet constructed. Construct() should be called before use.");
146 _IconListViewImpl* pImpl = _IconListViewImpl::GetInstance(*this);
147 pImpl->RemoveScrollEventListener(listener);
151 IconListView::SetBackgroundBitmap(const Bitmap* pBitmap)
153 // Check whether _pControlImpl has not been set as a precondition of this method, that is, "not-yet constructed" condition.
154 SysAssertf(_pControlImpl != null, "Not yet constructed. Construct() should be called before use.");
156 _IconListViewImpl* pImpl = _IconListViewImpl::GetInstance(*this);
157 return pImpl->SetBackgroundBitmap(pBitmap);
161 IconListView::SetBackgroundColor(const Color& color)
163 // Check whether _pControlImpl has not been set as a precondition of this method, that is, "not-yet constructed" condition.
164 SysAssertf(_pControlImpl != null, "Not yet constructed. Construct() should be called before use.");
166 _IconListViewImpl* pImpl = _IconListViewImpl::GetInstance(*this);
167 pImpl->SetBackgroundColor(color);
169 result r = GetLastResult();
172 SysLogException(NID_UI_CTRL, r, "[%s] Propagating.", GetErrorMessage(r));
179 IconListView::GetBackgroundColor(void) const
181 // Check whether _pControlImpl has not been set as a precondition of this method, that is, "not-yet constructed" condition.
182 SysAssertf(_pControlImpl != null, "Not yet constructed. Construct() should be called before use.");
184 const _IconListViewImpl* pImpl = _IconListViewImpl::GetInstance(*this);
185 return pImpl->GetBackgroundColor();
189 IconListView::SetMargin(MarginType type, int value)
191 // Check whether _pControlImpl has not been set as a precondition of this method, that is, "not-yet constructed" condition.
192 SysAssertf(_pControlImpl != null, "Not yet constructed. Construct() should be called before use.");
194 _IconListViewImpl* pImpl = _IconListViewImpl::GetInstance(*this);
195 return pImpl->SetMargin(type, value);
199 IconListView::GetMargin(MarginType type) const
201 // Check whether _pControlImpl has not been set as a precondition of this method, that is, "not-yet constructed" condition.
202 SysAssertf(_pControlImpl != null, "Not yet constructed. Construct() should be called before use.");
204 const _IconListViewImpl* pImpl = _IconListViewImpl::GetInstance(*this);
205 return pImpl->GetMargin(type);
209 IconListView::SetItemSpacing(int horizontalSpacing, int verticalSpacing)
211 // Check whether _pControlImpl has not been set as a precondition of this method, that is, "not-yet constructed" condition.
212 SysAssertf(_pControlImpl != null, "Not yet constructed. Construct() should be called before use.");
214 _IconListViewImpl* pImpl = _IconListViewImpl::GetInstance(*this);
215 return pImpl->SetItemSpacing(horizontalSpacing, verticalSpacing);
219 IconListView::GetItemHorizontalSpacing(void) const
221 // Check whether _pControlImpl has not been set as a precondition of this method, that is, "not-yet constructed" condition.
222 SysAssertf(_pControlImpl != null, "Not yet constructed. Construct() should be called before use.");
224 const _IconListViewImpl* pImpl = _IconListViewImpl::GetInstance(*this);
225 return pImpl->GetItemHorizontalSpacing();
229 IconListView::GetItemVerticalSpacing(void) const
231 // Check whether _pControlImpl has not been set as a precondition of this method, that is, "not-yet constructed" condition.
232 SysAssertf(_pControlImpl != null, "Not yet constructed. Construct() should be called before use.");
234 const _IconListViewImpl* pImpl = _IconListViewImpl::GetInstance(*this);
235 return pImpl->GetItemVerticalSpacing();
239 IconListView::SetItemChecked(int index, bool check)
241 // Check whether _pControlImpl has not been set as a precondition of this method, that is, "not-yet constructed" condition.
242 SysAssertf(_pControlImpl != null, "Not yet constructed. Construct() should be called before use.");
244 _IconListViewImpl* pImpl = _IconListViewImpl::GetInstance(*this);
245 return pImpl->SetItemChecked(index, check);
249 IconListView::IsItemChecked(int index) const
251 // Check whether _pControlImpl has not been set as a precondition of this method, that is, "not-yet constructed" condition.
252 SysAssertf(_pControlImpl != null, "Not yet constructed. Construct() should be called before use.");
254 const _IconListViewImpl* pImpl = _IconListViewImpl::GetInstance(*this);
255 return pImpl->IsItemChecked(index);
259 IconListView::GetItemIndexFromPosition(int x, int y) const
261 // Check whether _pControlImpl has not been set as a precondition of this method, that is, "not-yet constructed" condition.
262 SysAssertf(_pControlImpl != null, "Not yet constructed. Construct() should be called before use.");
264 const _IconListViewImpl* pImpl = _IconListViewImpl::GetInstance(*this);
265 return pImpl->GetItemIndexFromPosition(x, y);
269 IconListView::GetItemIndexFromPosition(const Point& position) const
271 // Check whether _pControlImpl has not been set as a precondition of this method, that is, "not-yet constructed" condition.
272 SysAssertf(_pControlImpl != null, "Not yet constructed. Construct() should be called before use.");
274 const _IconListViewImpl* pImpl = _IconListViewImpl::GetInstance(*this);
275 return pImpl->GetItemIndexFromPosition(position);
279 IconListView::SetTextHorizontalAlignment(HorizontalAlignment alignment)
281 // Check whether _pControlImpl has not been set as a precondition of this method, that is, "not-yet constructed" condition.
282 SysAssertf(_pControlImpl != null, "Not yet constructed. Construct() should be called before use.");
284 _IconListViewImpl* pImpl = _IconListViewImpl::GetInstance(*this);
285 return pImpl->SetTextHorizontalAlignment(alignment);
289 IconListView::SetTextVerticalAlignment(IconListViewItemTextVerticalAlignment alignment)
291 // Check whether _pControlImpl has not been set as a precondition of this method, that is, "not-yet constructed" condition.
292 SysAssertf(_pControlImpl != null, "Not yet constructed. Construct() should be called before use.");
294 _IconListViewImpl* pImpl = _IconListViewImpl::GetInstance(*this);
295 return pImpl->SetTextVerticalAlignment(alignment);
299 IconListView::GetTextHorizontalAlignment(void) const
301 // Check whether _pControlImpl has not been set as a precondition of this method, that is, "not-yet constructed" condition.
302 SysAssertf(_pControlImpl != null, "Not yet constructed. Construct() should be called before use.");
304 const _IconListViewImpl* pImpl = _IconListViewImpl::GetInstance(*this);
305 return pImpl->GetTextHorizontalAlignment();
308 IconListViewItemTextVerticalAlignment
309 IconListView::GetTextVerticalAlignment(void) const
311 // Check whether _pControlImpl has not been set as a precondition of this method, that is, "not-yet constructed" condition.
312 SysAssertf(_pControlImpl != null, "Not yet constructed. Construct() should be called before use.");
314 const _IconListViewImpl* pImpl = _IconListViewImpl::GetInstance(*this);
315 return pImpl->GetTextVerticalAlignment();
319 IconListView::SetTextOfEmptyList(const String& text)
321 // Check whether _pControlImpl has not been set as a precondition of this method, that is, "not-yet constructed" condition.
322 SysAssertf(_pControlImpl != null, "Not yet constructed. Construct() should be called before use.");
324 _IconListViewImpl* pImpl = _IconListViewImpl::GetInstance(*this);
325 return pImpl->SetTextOfEmptyList(text);
329 IconListView::GetTextOfEmptyList(void) const
331 // Check whether _pControlImpl has not been set as a precondition of this method, that is, "not-yet constructed" condition.
332 SysAssertf(_pControlImpl != null, "Not yet constructed. Construct() should be called before use.");
334 const _IconListViewImpl* pImpl = _IconListViewImpl::GetInstance(*this);
335 return pImpl->GetTextOfEmptyList();
339 IconListView::SetTextColorOfEmptyList(const Color& color)
341 // Check whether _pControlImpl has not been set as a precondition of this method, that is, "not-yet constructed" condition.
342 SysAssertf(_pControlImpl != null, "Not yet constructed. Construct() should be called before use.");
344 _IconListViewImpl* pImpl = _IconListViewImpl::GetInstance(*this);
345 return pImpl->SetTextColorOfEmptyList(color);
349 IconListView::GetTextColorOfEmptyList(void) const
351 // Check whether _pControlImpl has not been set as a precondition of this method, that is, "not-yet constructed" condition.
352 SysAssertf(_pControlImpl != null, "Not yet constructed. Construct() should be called before use.");
354 const _IconListViewImpl* pImpl = _IconListViewImpl::GetInstance(*this);
355 return pImpl->GetTextColorOfEmptyList();
359 IconListView::SetItemTextColor(IconListViewItemDrawingStatus status, const Color& color)
361 // Check whether _pControlImpl has not been set as a precondition of this method, that is, "not-yet constructed" condition.
362 SysAssertf(_pControlImpl != null, "Not yet constructed. Construct() should be called before use.");
364 _IconListViewImpl* pImpl = _IconListViewImpl::GetInstance(*this);
365 return pImpl->SetItemTextColor(status, color);
369 IconListView::GetItemTextColor(IconListViewItemDrawingStatus status) const
371 // Check whether _pControlImpl has not been set as a precondition of this method, that is, "not-yet constructed" condition.
372 SysAssertf(_pControlImpl != null, "Not yet constructed. Construct() should be called before use.");
374 const _IconListViewImpl* pImpl = _IconListViewImpl::GetInstance(*this);
375 return pImpl->GetItemTextColor(status);
379 IconListView::SetItemTextSize(int size)
381 // Check whether _pControlImpl has not been set as a precondition of this method, that is, "not-yet constructed" condition.
382 SysAssertf(_pControlImpl != null, "Not yet constructed. Construct() should be called before use.");
384 _IconListViewImpl* pImpl = _IconListViewImpl::GetInstance(*this);
385 return pImpl->SetItemTextSize(size);
389 IconListView::GetItemTextSize(void) const
391 // Check whether _pControlImpl has not been set as a precondition of this method, that is, "not-yet constructed" condition.
392 SysAssertf(_pControlImpl != null, "Not yet constructed. Construct() should be called before use.");
394 const _IconListViewImpl* pImpl = _IconListViewImpl::GetInstance(*this);
395 return pImpl->GetItemTextSize();
399 IconListView::SetCheckBoxPosition(IconListViewCheckBoxPosition position)
401 // Check whether _pControlImpl has not been set as a precondition of this method, that is, "not-yet constructed" condition.
402 SysAssertf(_pControlImpl != null, "Not yet constructed. Construct() should be called before use.");
404 _IconListViewImpl* pImpl = _IconListViewImpl::GetInstance(*this);
405 return pImpl->SetCheckBoxPosition(position);
408 IconListViewCheckBoxPosition
409 IconListView::GetCheckBoxPosition(void) const
411 // Check whether _pControlImpl has not been set as a precondition of this method, that is, "not-yet constructed" condition.
412 SysAssertf(_pControlImpl != null, "Not yet constructed. Construct() should be called before use.");
414 const _IconListViewImpl* pImpl = _IconListViewImpl::GetInstance(*this);
415 return pImpl->GetCheckBoxPosition();
419 IconListView::SetTouchAnimationEnabled(bool enable)
421 // Check whether _pControlImpl has not been set as a precondition of this method, that is, "not-yet constructed" condition.
422 SysAssertf(_pControlImpl != null, "Not yet constructed. Construct() should be called before use.");
424 _IconListViewImpl* pImpl = _IconListViewImpl::GetInstance(*this);
425 return pImpl->SetTouchAnimationEnabled(enable);
429 IconListView::IsTouchAnimationEnabled(void) const
431 // Check whether _pControlImpl has not been set as a precondition of this method, that is, "not-yet constructed" condition.
432 SysAssertf(_pControlImpl != null, "Not yet constructed. Construct() should be called before use.");
434 const _IconListViewImpl* pImpl = _IconListViewImpl::GetInstance(*this);
435 return pImpl->IsTouchAnimationEnabled();
439 IconListView::ScrollToItem(int index)
441 // Check whether _pControlImpl has not been set as a precondition of this method, that is, "not-yet constructed" condition.
442 SysAssertf(_pControlImpl != null, "Not yet constructed. Construct() should be called before use.");
444 _IconListViewImpl* pImpl = _IconListViewImpl::GetInstance(*this);
445 return pImpl->ScrollToItem(index);
449 IconListView::RefreshList(int index, ListRefreshType type)
451 // Check whether _pControlImpl has not been set as a precondition of this method, that is, "not-yet constructed" condition.
452 SysAssertf(_pControlImpl != null, "Not yet constructed. Construct() should be called before use.");
454 _IconListViewImpl* pImpl = _IconListViewImpl::GetInstance(*this);
455 return pImpl->RefreshList(index, type);
459 IconListView::UpdateList(void)
461 // Check whether _pControlImpl has not been set as a precondition of this method, that is, "not-yet constructed" condition.
462 SysAssertf(_pControlImpl != null, "Not yet constructed. Construct() should be called before use.");
464 _IconListViewImpl* pImpl = _IconListViewImpl::GetInstance(*this);
465 return pImpl->UpdateList();
469 IconListView::GetItemBitmapSize(int& width, int& height) const
471 // Check whether _pControlImpl has not been set as a precondition of this method, that is, "not-yet constructed" condition.
472 SysAssertf(_pControlImpl != null, "Not yet constructed. Construct() should be called before use.");
474 const _IconListViewImpl* pImpl = _IconListViewImpl::GetInstance(*this);
475 return pImpl->GetItemBitmapSize(width, height);
479 IconListView::GetItemBitmapSize(void) const
481 // Check whether _pControlImpl has not been set as a precondition of this method, that is, "not-yet constructed" condition.
482 SysAssertf(_pControlImpl != null, "Not yet constructed. Construct() should be called before use.");
484 const _IconListViewImpl* pImpl = _IconListViewImpl::GetInstance(*this);
485 return pImpl->GetItemBitmapSize();
489 IconListView::GetItemSize(int& width, int& height) const
491 // Check whether _pControlImpl has not been set as a precondition of this method, that is, "not-yet constructed" condition.
492 SysAssertf(_pControlImpl != null, "Not yet constructed. Construct() should be called before use.");
494 const _IconListViewImpl* pImpl = _IconListViewImpl::GetInstance(*this);
495 return pImpl->GetItemSize(width, height);
499 IconListView::GetItemSize(void) const
501 // Check whether _pControlImpl has not been set as a precondition of this method, that is, "not-yet constructed" condition.
502 SysAssertf(_pControlImpl != null, "Not yet constructed. Construct() should be called before use.");
504 const _IconListViewImpl* pImpl = _IconListViewImpl::GetInstance(*this);
505 return pImpl->GetItemSize();
509 IconListView::SetMagneticScrollSize(int scrollSize)
511 // Check whether _pControlImpl has not been set as a precondition of this method, that is, "not-yet constructed" condition.
512 SysAssertf(_pControlImpl != null, "Not yet constructed. Construct() should be called before use.");
514 _IconListViewImpl* pImpl = _IconListViewImpl::GetInstance(*this);
515 return pImpl->SetMagneticScrollSize(scrollSize);
519 IconListView::GetMagneticScrollSize(void) const
521 // Check whether _pControlImpl has not been set as a precondition of this method, that is, "not-yet constructed" condition.
522 SysAssertf(_pControlImpl != null, "Not yet constructed. Construct() should be called before use.");
524 const _IconListViewImpl* pImpl = _IconListViewImpl::GetInstance(*this);
525 return pImpl->GetMagneticScrollSize();
529 IconListView::GetItemCountPerAxis(void) const
531 // Check whether _pControlImpl has not been set as a precondition of this method, that is, "not-yet constructed" condition.
532 SysAssertf(_pControlImpl != null, "Not yet constructed. Construct() should be called before use.");
534 const _IconListViewImpl* pImpl = _IconListViewImpl::GetInstance(*this);
535 return pImpl->GetItemCountPerAxis();
539 IconListView::SetItemLayoutHorizontalAlignment(HorizontalAlignment alignment)
541 // Check whether _pControlImpl has not been set as a precondition of this method, that is, "not-yet constructed" condition.
542 SysAssertf(_pControlImpl != null, "Not yet constructed. Construct() should be called before use.");
544 _IconListViewImpl* pImpl = _IconListViewImpl::GetInstance(*this);
545 return pImpl->SetItemLayoutHorizontalAlignment(alignment);
549 IconListView::SetItemLayoutVerticalAlignment(VerticalAlignment alignment)
551 // Check whether _pControlImpl has not been set as a precondition of this method, that is, "not-yet constructed" condition.
552 SysAssertf(_pControlImpl != null, "Not yet constructed. Construct() should be called before use.");
554 _IconListViewImpl* pImpl = _IconListViewImpl::GetInstance(*this);
555 return pImpl->SetItemLayoutVerticalAlignment(alignment);
559 IconListView::GetItemLayoutHorizontalAlignment(void) const
561 // Check whether _pControlImpl has not been set as a precondition of this method, that is, "not-yet constructed" condition.
562 SysAssertf(_pControlImpl != null, "Not yet constructed. Construct() should be called before use.");
564 const _IconListViewImpl* pImpl = _IconListViewImpl::GetInstance(*this);
565 return pImpl->GetItemLayoutHorizontalAlignment();
569 IconListView::GetItemLayoutVerticalAlignment(void) const
571 // Check whether _pControlImpl has not been set as a precondition of this method, that is, "not-yet constructed" condition.
572 SysAssertf(_pControlImpl != null, "Not yet constructed. Construct() should be called before use.");
574 const _IconListViewImpl* pImpl = _IconListViewImpl::GetInstance(*this);
575 return pImpl->GetItemLayoutVerticalAlignment();
579 IconListView::SetItemBorderStyle(IconListViewItemBorderStyle borderStyle)
581 // Check whether _pControlImpl has not been set as a precondition of this method, that is, "not-yet constructed" condition.
582 SysAssertf(_pControlImpl != null, "Not yet constructed. Construct() should be called before use.");
584 _IconListViewImpl* pImpl = _IconListViewImpl::GetInstance(*this);
585 return pImpl->SetItemBorderStyle(borderStyle);
588 IconListViewItemBorderStyle
589 IconListView::GetItemBorderStyle(void) const
591 // Check whether _pControlImpl has not been set as a precondition of this method, that is, "not-yet constructed" condition.
592 SysAssertf(_pControlImpl != null, "Not yet constructed. Construct() should be called before use.");
594 const _IconListViewImpl* pImpl = _IconListViewImpl::GetInstance(*this);
595 return pImpl->GetItemBorderStyle();
599 IconListView::SetBitmapOfEmptyList(const Bitmap* pBitmap)
601 // Check whether _pControlImpl has not been set as a precondition of this method, that is, "not-yet constructed" condition.
602 SysAssertf(_pControlImpl != null, "Not yet constructed. Construct() should be called before use.");
604 _IconListViewImpl* pImpl = _IconListViewImpl::GetInstance(*this);
605 return pImpl->SetBitmapOfEmptyList(pBitmap);
609 IconListView::BeginReorderingMode(void)
611 // Check whether _pControlImpl has not been set as a precondition of this method, that is, "not-yet constructed" condition.
612 SysAssertf(_pControlImpl != null, "Not yet constructed. Construct() should be called before use.");
614 _IconListViewImpl* pImpl = _IconListViewImpl::GetInstance(*this);
615 return pImpl->BeginReorderingMode();
619 IconListView::EndReorderingMode(void)
621 // Check whether _pControlImpl has not been set as a precondition of this method, that is, "not-yet constructed" condition.
622 SysAssertf(_pControlImpl != null, "Not yet constructed. Construct() should be called before use.");
624 _IconListViewImpl* pImpl = _IconListViewImpl::GetInstance(*this);
625 return pImpl->EndReorderingMode();
629 IconListView::IsInReorderingMode(void) const
631 // Check whether _pControlImpl has not been set as a precondition of this method, that is, "not-yet constructed" condition.
632 SysAssertf(_pControlImpl != null, "Not yet constructed. Construct() should be called before use.");
634 const _IconListViewImpl* pImpl = _IconListViewImpl::GetInstance(*this);
635 return pImpl->IsInReorderingMode();
638 }}} //Tizen::Ui::Controls