Changed indicator bg color.
[platform/framework/native/uifw.git] / src / ui / controls / FUiCtrl_IconListView.cpp
1 //
2 // Open Service Platform
3 // Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
4 //
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
8 //
9 //     http://www.apache.org/licenses/LICENSE-2.0/
10 //
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.
16 //
17
18 /**
19  * @file                FUiCtrl_IconListView.cpp
20  * @brief               This is the implementation file for the _IconListView class.
21  */
22
23 //Includes
24 #include <FUiCtrlIIconListViewItemProvider.h>
25 #include <FGrp_BitmapImpl.h>
26
27 #include "FUi_AccessibilityContainer.h"
28 #include "FUi_CoordinateSystemUtils.h"
29 #include "FUi_Math.h"
30 #include "FUi_ResourceManager.h"
31 #include "FUiAnim_VisualElement.h"
32 #include "FUiCtrl_IconListItem.h"
33 #include "FUiCtrl_IconListPresenter.h"
34 #include "FUiCtrl_IconListView.h"
35 #include "FUiCtrl_IconListViewItemEventArg.h"
36 #include "FUiCtrl_IIconListItemEventListener.h"
37 #include "FUiCtrl_IScrollEventListener.h"
38 #include "FUiCtrl_UiIconListItemEvent.h"
39 #include "FUiCtrl_UiScrollEvent.h"
40 #include "FUiCtrl_UiScrollEventArg.h"
41
42 using namespace Tizen::Base;
43 using namespace Tizen::Graphics;
44 using namespace Tizen::Ui;
45 using namespace Tizen::Ui::Animations;
46
47 namespace Tizen { namespace Ui { namespace Controls
48 {
49
50 IMPLEMENT_PROPERTY(_IconListView);
51
52 _IconListView::_IconListView(void)
53         : _Control()
54         , __pIconListPresenter(null)
55         , __pScroll(null)
56         , __pIconListItemEvent(null)
57         , __pScrollEvent(null)
58         , __pGestureFlick(null)
59         , __pGestureLongPress(null)
60         , __style(ICON_LIST_VIEW_STYLE_NORMAL)
61         , __scrollStyle(ICON_LIST_SCROLL_STYLE_FADE_OUT)
62         , __pBackgroundBitmap(null)
63         , __textOfEmptyList(L"")
64         , __textColorOfEmptyList(0)
65         , __textSizeOfEmptyList(0)
66         , __pBitmapOfEmptyList(null)
67         , __reorderEnabled(false)
68         , __pScrollingAnimation(null)
69         , __scrollInputMode(SCROLL_INPUT_MODE_ALLOW_ANY_DIRECTION)
70 {
71         SetControlDelegate(*this);
72         AddPropertyChangeEventListener(*this);
73
74         _AccessibilityContainer* pContainer = GetAccessibilityContainer();
75         if (pContainer != null)
76         {
77                 pContainer->Activate(true);
78         }
79 }
80
81 _IconListView::~_IconListView(void)
82 {
83         Dispose();
84 }
85
86 result
87 _IconListView::Dispose(void)
88 {
89         AnimationTransaction::SetTransactionEventListener(null);
90
91         if (__pScrollingAnimation != null)
92         {
93                 __pScrollingAnimation->SetVisualElementAnimationTickEventListener(null);
94                 __pScrollingAnimation->SetVisualElementAnimationStatusEventListener(null);
95
96                 GetVisualElement()->RemoveAllAnimations();
97
98                 delete __pScrollingAnimation;
99                 __pScrollingAnimation = null;
100         }
101
102         delete __pIconListPresenter;
103         __pIconListPresenter = null;
104
105         delete __pBackgroundBitmap;
106         __pBackgroundBitmap = null;
107
108         delete __pBitmapOfEmptyList;
109         __pBitmapOfEmptyList = null;
110
111         delete  __pIconListItemEvent;
112         __pIconListItemEvent = null;
113
114         delete __pScrollEvent;
115         __pScrollEvent = null;
116
117         if (__pScroll != null)
118         {
119                 DetachSystemChild(*__pScroll);
120                 delete __pScroll;
121                 __pScroll = null;
122         }
123
124         if (__pGestureFlick != null)
125         {
126                 _ITouchFlickGestureEventListener* pListener = dynamic_cast<_ITouchFlickGestureEventListener*>(this);
127                 __pGestureFlick->RemoveGestureListener(*pListener);
128                 RemoveGestureDetector(*__pGestureFlick);
129                 delete __pGestureFlick;
130                 __pGestureFlick = null;
131         }
132
133         if (__pGestureLongPress != null)
134         {
135                 _ITouchLongPressGestureEventListener* pListener = dynamic_cast<_ITouchLongPressGestureEventListener*>(this);
136                 __pGestureLongPress->RemoveGestureListener(*pListener);
137                 RemoveGestureDetector(*__pGestureLongPress);
138                 delete __pGestureLongPress;
139                 __pGestureLongPress = null;
140         }
141
142         return E_SUCCESS;
143 }
144
145 _IconListView*
146 _IconListView::CreateIconListViewN(IconListViewStyle style)
147 {
148         result r = E_SUCCESS;
149         _IconListView* pCore = null;
150         _IconListPresenter* pIconListPresenter = null;
151
152         ClearLastResult();
153
154         // Create _IconListView
155         pCore = new (std::nothrow) _IconListView;
156         SysTryReturn(NID_UI_CTRL, (pCore != null), null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
157
158         pCore->AcquireHandle();
159
160         // Create _IconListPresenter
161         pIconListPresenter = _IconListPresenter::CreateInstanceN(*pCore);
162         SysTryCatch(NID_UI_CTRL, (pIconListPresenter != null), , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
163
164         r = pCore->Initialize(*pIconListPresenter);
165         SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r));
166
167         r = pCore->SetStyle(style);
168         SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r));
169
170         pCore->__pGestureFlick = new (std::nothrow) _TouchFlickGestureDetector();
171
172         pCore->AddGestureDetector(*(pCore->__pGestureFlick));
173         SysTryCatch(NID_UI_CTRL, (GetLastResult() == E_SUCCESS), , r = E_SYSTEM, "[E_SYSTEM] A system error has been occurred. AddGestureDetector failed.");
174
175         r = pCore->__pGestureFlick->AddGestureListener(*pCore);
176         SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r = E_SYSTEM, "[E_SYSTEM] A system error has been occurred. AddGestureListener failed.");
177
178         pCore->__pGestureLongPress = new (std::nothrow) _TouchLongPressGestureDetector();
179         pCore->AddGestureDetector(*(pCore->__pGestureLongPress));
180         SysTryCatch(NID_UI_CTRL, (GetLastResult() == E_SUCCESS), , r = E_SYSTEM, "[E_SYSTEM] A system error has been occurred. AddGestureDetector failed.");
181
182         r = pCore->__pGestureLongPress->AddGestureListener(*pCore);
183         SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r = E_SYSTEM, "[E_SYSTEM] A system error has been occurred. AddGestureListener failed.");
184
185         return pCore;
186
187 CATCH:
188         delete pCore;
189
190         return null;
191 }
192
193 result
194 _IconListView::Initialize(_IconListPresenter& presenter)
195 {
196         result r = E_SUCCESS;
197         Color color;
198         float textSize = 0.0f;
199
200         // Set _IconListPresenter
201         __pIconListPresenter = &presenter;
202
203         // Check _VisualElement
204         SysTryCatch(NID_UI_CTRL, (GetVisualElement() != null), r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Unable to initialize IconList.");
205
206         // Create _UiIconListItemEvent
207         __pIconListItemEvent = new (std::nothrow) _UiIconListItemEvent;
208         SysTryCatch(NID_UI_CTRL, (__pIconListItemEvent != null), r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY,
209                         "[E_OUT_OF_MEMORY] Memory allocation failed.");
210
211         r = __pIconListItemEvent->Construct(*this);
212         SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Unable to construct Event.");
213
214         // Create _UiScrollEvent
215         __pScrollEvent = new (std::nothrow) _UiScrollEvent;
216         SysTryCatch(NID_UI_CTRL, (__pScrollEvent != null), r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY,
217                         "[E_OUT_OF_MEMORY] Memory allocation failed.");
218
219         r = __pScrollEvent->Construct(*this);
220         SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Unable to construct Scroll Event.");
221
222         SetBackgroundColor(Color(0, 0, 0, 0));
223
224         // Load emtpy content properties
225         GET_SHAPE_CONFIG(ICONLIST::EMPTY_FONT_SIZE, GetOrientation(), textSize);
226         SetTextSizeOfEmptyList(textSize);
227
228         GET_COLOR_CONFIG(ICONLIST::EMPTY_TEXT_NORMAL, color);
229         SetTextColorOfEmptyList(color);
230
231         // Set Touch move allowance config
232         SetTouchPressThreshold(0.08);
233
234         AnimationTransaction::SetTransactionEventListener(this);
235
236         __pScrollingAnimation = new (std::nothrow) VisualElementValueAnimation;
237         SysTryCatch(NID_UI_CTRL, (__pScrollEvent != null), r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY,
238                         "[E_OUT_OF_MEMORY] Memory allocation failed.");
239
240         __pScrollingAnimation->SetRepeatCount(SCROLL_ANIMATION_DEFAULT_REPEAT_COUNT);
241         __pScrollingAnimation->SetTimingFunction(VisualElementAnimation::GetTimingFunctionByName("EaseOut"));
242         r = GetLastResult();
243         SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
244
245         __pScrollingAnimation->SetVisualElementAnimationTickEventListener(this);
246         r = GetLastResult();
247         SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
248
249         __pScrollingAnimation->SetVisualElementAnimationStatusEventListener(this);
250         r = GetLastResult();
251         SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
252
253         return r;
254
255 CATCH:
256         Dispose();
257         return r;
258 }
259
260 result
261 _IconListView::SetItemProvider(const IIconListViewItemProvider& provider)
262 {
263         return __pIconListPresenter->SetItemProvider(provider);
264 }
265
266 result
267 _IconListView::RegisterItemProviderAdaptor(_IListItemProviderAdaptor* pItemProviderAdaptor)
268 {
269         return __pIconListPresenter->RegisterItemProviderAdaptor(pItemProviderAdaptor);
270 }
271
272 result
273 _IconListView::AddIconListItemEventListener(const _IIconListItemEventListener& listener)
274 {
275         result r = __pIconListItemEvent->AddListener(listener);
276         if (r == E_OBJ_ALREADY_EXIST)
277         {
278                 SysLogException(NID_UI_CTRL, (r = E_SYSTEM), "[E_SYSTEM] A system error has been occurred. The same instance already exists in the event listener list.");
279         }
280         return r;
281 }
282
283 result
284 _IconListView::RemoveIconListItemEventListener(const _IIconListItemEventListener& listener)
285 {
286         return __pIconListItemEvent->RemoveListener(listener);
287 }
288
289 result
290 _IconListView::AddScrollEventListener(const _IScrollEventListener& listener)
291 {
292         result r = __pScrollEvent->AddListener(listener);
293         if (r == E_OBJ_ALREADY_EXIST)
294         {
295                 SysLogException(NID_UI_CTRL, (r = E_SYSTEM), "[E_SYSTEM] A system error has been occurred. The same instance already exists in the event listener list.");
296         }
297         return r;
298 }
299
300 result
301 _IconListView::RemoveScrollEventListener(const _IScrollEventListener& listener)
302 {
303         return __pScrollEvent->RemoveListener(listener);
304 }
305
306 result
307 _IconListView::SetStyle(IconListViewStyle style)
308 {
309         SysTryReturn(NID_UI_CTRL, (style >= ICON_LIST_VIEW_STYLE_NORMAL && style <= ICON_LIST_VIEW_STYLE_MARK), E_INVALID_ARG,
310                         E_INVALID_ARG, "[E_INVALID_ARG] Invalid style is used.");
311
312         __style = style;
313         __pIconListPresenter->SetUseCheckedStyle(__style == ICON_LIST_VIEW_STYLE_NORMAL ? false : true);
314
315         return E_SUCCESS;
316 }
317
318 IconListViewStyle
319 _IconListView::GetStyle(void) const
320 {
321         return __style;
322 }
323
324 result
325 _IconListView::SetScrollDirection(IconListViewScrollDirection scrollDirection)
326 {
327         return __pIconListPresenter->SetScrollDirection(scrollDirection);
328 }
329
330 result
331 _IconListView::SetScrollStyle(IconListViewScrollStyle scrollStyle)
332 {
333         SysTryReturn(NID_UI_CTRL, scrollStyle >= ICON_LIST_SCROLL_STYLE_FADE_OUT && scrollStyle <= ICON_LIST_SCROLL_STYLE_THUMB,
334                         E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] Invalid scrollStyle is used.");
335
336         __scrollStyle = scrollStyle;
337         return E_SUCCESS;
338 }
339
340 result
341 _IconListView::SetBackgroundBitmap(const Bitmap* pBitmap)
342 {
343         result r = E_SUCCESS;
344
345         Bitmap* pCopiedBitmap = null;
346         if (pBitmap != null)
347         {
348                 pCopiedBitmap = _BitmapImpl::CloneN(*pBitmap);
349                 r = GetLastResult();
350         }
351
352         if (r == E_SUCCESS)
353         {
354                 delete __pBackgroundBitmap;
355                 __pBackgroundBitmap = pCopiedBitmap;
356         }
357         else
358         {
359                 delete pCopiedBitmap;
360         }
361
362         __pIconListPresenter->ClearVisualElement();
363
364         return r;
365 }
366
367 const Bitmap*
368 _IconListView::GetBackgroundBitmap(void) const
369 {
370         return __pBackgroundBitmap;
371 }
372
373 result
374 _IconListView::SetMargin(MarginType type, float value)
375 {
376         return __pIconListPresenter->SetMargin(type, value);
377 }
378
379 float
380 _IconListView::GetMargin(MarginType type) const
381 {
382         return __pIconListPresenter->GetMargin(type);
383 }
384
385 result
386 _IconListView::SetItemSpacing(float horizontalSpacing, float verticalSpacing)
387 {
388         return __pIconListPresenter->SetItemSpacing(horizontalSpacing, verticalSpacing);
389 }
390
391 float
392 _IconListView::GetItemHorizontalSpacing(void) const
393 {
394         return __pIconListPresenter->GetItemHorizontalSpacing();
395 }
396
397 float
398 _IconListView::GetItemVerticalSpacing(void) const
399 {
400         return __pIconListPresenter->GetItemVerticalSpacing();
401 }
402
403 result
404 _IconListView::SetItemChecked(int index, bool check)
405 {
406         SysTryReturn(NID_UI_CTRL, (__style == ICON_LIST_VIEW_STYLE_RADIO || __style == ICON_LIST_VIEW_STYLE_MARK), E_SYSTEM, E_SYSTEM,
407                         "[E_SYSTEM] A system error has been occurred. The style of IconListView is not available to check.");
408
409         return __pIconListPresenter->SetItemChecked(index, check);
410 }
411
412 bool
413 _IconListView::IsItemChecked(int index) const
414 {
415         SysTryReturn(NID_UI_CTRL, (__style == ICON_LIST_VIEW_STYLE_RADIO || __style == ICON_LIST_VIEW_STYLE_MARK), false, E_SYSTEM,
416                         "[E_SYSTEM] A system error has been occurred. The style of IconListView is not available to check.");
417
418         return __pIconListPresenter->IsItemChecked(index);
419 }
420
421 int
422 _IconListView::GetItemIndexFromPosition(float x, float y) const
423 {
424         return __pIconListPresenter->GetItemIndexFromPosition(x, y);
425 }
426
427 int
428 _IconListView::GetItemIndexFromPosition(const Point& position) const
429 {
430         return GetItemIndexFromPosition(_CoordinateSystemUtils::ConvertToFloat(position));
431 }
432
433 int
434 _IconListView::GetItemIndexFromPosition(const FloatPoint& position) const
435 {
436         return __pIconListPresenter->GetItemIndexFromPosition(position);
437 }
438
439 result
440 _IconListView::SetPropertyTextHorizontalAlignment(const Variant& alignment)
441 {
442         return __pIconListPresenter->SetTextHorizontalAlignment(static_cast<HorizontalAlignment>(alignment.ToInt()));
443 }
444
445 result
446 _IconListView::SetTextHorizontalAlignment(HorizontalAlignment alignment)
447 {
448         return SetProperty("textHorizontalAlignment", Variant(static_cast<int>(alignment)));
449 }
450
451 result
452 _IconListView::SetPropertyTextVerticalAlignment(const Variant& alignment)
453 {
454         return __pIconListPresenter->SetTextVerticalAlignment(static_cast<IconListViewItemTextVerticalAlignment>(alignment.ToInt()));
455 }
456
457 result
458 _IconListView::SetTextVerticalAlignment(IconListViewItemTextVerticalAlignment alignment)
459 {
460         return SetProperty("textVerticalAlignment", Variant(static_cast<int>(alignment)));
461 }
462
463 Variant
464 _IconListView::GetPropertyTextHorizontalAlignment(void) const
465 {
466         return Variant(static_cast<int>(__pIconListPresenter->GetTextHorizontalAlignment()));
467 }
468
469 HorizontalAlignment
470 _IconListView::GetTextHorizontalAlignment(void) const
471 {
472         Variant alignment = GetProperty("textHorizontalAlignment");
473         return static_cast<HorizontalAlignment> (alignment.ToInt());
474 }
475
476 Variant
477 _IconListView::GetPropertyTextVerticalAlignment(void) const
478 {
479         return Variant(static_cast<int>(__pIconListPresenter->GetTextVerticalAlignment()));
480 }
481
482 IconListViewItemTextVerticalAlignment
483 _IconListView::GetTextVerticalAlignment(void) const
484 {
485         Variant alignment = GetProperty("textVerticalAlignment");
486         return static_cast<IconListViewItemTextVerticalAlignment> (alignment.ToInt());
487 }
488
489 result
490 _IconListView::SetPropertyTextOfEmptyList(const Variant& text)
491 {
492         __textOfEmptyList = text.ToString();
493
494         __pIconListPresenter->ClearVisualElement();
495
496         return E_SUCCESS;
497 }
498
499 result
500 _IconListView::SetTextOfEmptyList(const String& text)
501 {
502         return SetProperty("textOfEmptyList", Variant(text));
503 }
504
505 Variant
506 _IconListView::GetPropertyTextOfEmptyList(void) const
507 {
508         return Variant(__textOfEmptyList);
509 }
510
511 const String
512 _IconListView::GetTextOfEmptyList(void) const
513 {
514         Variant text = GetProperty("textOfEmptyList");
515         return text.ToString();
516 }
517
518 result
519 _IconListView::SetPropertyTextColorOfEmptyList(const Variant& color)
520 {
521         __textColorOfEmptyList = color.ToColor();
522         __pIconListPresenter->ClearVisualElement();
523
524         return E_SUCCESS;
525 }
526 result
527 _IconListView::SetTextColorOfEmptyList(const Color& color)
528 {
529         return SetProperty("textColorOfEmptyList", Variant(color));
530 }
531
532 Variant
533 _IconListView::GetPropertyTextColorOfEmptyList(void) const
534 {
535         return Variant(__textColorOfEmptyList);
536 }
537
538 const Color
539 _IconListView::GetTextColorOfEmptyList(void) const
540 {
541         Variant color = GetProperty("textColorOfEmptyList");
542         return color.ToColor();
543 }
544
545 result
546 _IconListView::SetTextSizeOfEmptyList(float size)
547 {
548         float minSize = 0.0f;
549         GET_FIXED_VALUE_CONFIG(ICONLIST::MINIMUM_FONT_SIZE, GetOrientation(), minSize);
550         SysTryReturn(NID_UI_CTRL, _FloatCompareGE(size, minSize), E_INVALID_ARG, E_INVALID_ARG,
551                         "[E_INVALID_ARG] Invalid argument is used. Font size should be greater than or equal to the minimum size.");
552
553         __textSizeOfEmptyList = size;
554
555         return E_SUCCESS;
556 }
557
558 float
559 _IconListView::GetTextSizeOfEmptyList(void) const
560 {
561         return __textSizeOfEmptyList;
562 }
563
564 result
565 _IconListView::SetItemTextColor(IconListViewItemDrawingStatus status, const Color& color)
566 {
567         return __pIconListPresenter->SetItemTextColor(status, color);
568 }
569
570 const Color
571 _IconListView::GetItemTextColor(IconListViewItemDrawingStatus status) const
572 {
573         return __pIconListPresenter->GetItemTextColor(status);
574 }
575
576 result
577 _IconListView::SetPropertyItemTextSize(const Variant& size)
578 {
579         return __pIconListPresenter->SetItemTextSize(size.ToFloat());
580 }
581
582 result
583 _IconListView::SetItemTextSize(float size)
584 {
585         return SetProperty("itemTextSize", Variant((size)));
586 }
587
588 Variant
589 _IconListView::GetPropertyItemTextSize(void) const
590 {
591         return Variant(__pIconListPresenter->GetItemTextSize());
592 }
593
594 float
595 _IconListView::GetItemTextSize(void) const
596 {
597         Variant size = GetProperty("itemTextSize");
598         return size.ToFloat();
599 }
600
601 result
602 _IconListView::SetPropertyCheckBoxPosition(const Variant& position)
603 {
604         SysTryReturn(NID_UI_CTRL, (__style == ICON_LIST_VIEW_STYLE_RADIO || __style == ICON_LIST_VIEW_STYLE_MARK), E_INVALID_OPERATION,
605                         E_INVALID_OPERATION, "[E_INVALID_OPERATION] The current style of IconListView is not available to check. So can not set position of check box.");
606
607         return __pIconListPresenter->SetCheckBoxPosition(static_cast<IconListViewCheckBoxPosition>(position.ToInt()));
608 }
609
610 result
611 _IconListView::SetCheckBoxPosition(IconListViewCheckBoxPosition position)
612 {
613         return SetProperty("checkBoxPosition", Variant(static_cast<int>(position)));
614 }
615
616 Variant
617 _IconListView::GetPropertyCheckBoxPosition(void) const
618 {
619         SysTryReturn(NID_UI_CTRL, (__style == ICON_LIST_VIEW_STYLE_RADIO || __style == ICON_LIST_VIEW_STYLE_MARK),
620                         Variant(static_cast<int>(ICON_LIST_VIEW_CHECK_BOX_POSITION_TOP_LEFT)), E_INVALID_OPERATION,
621                         "[E_INVALID_OPERATION] The current style of IconListView is not available to check. So can not get position of check box.");
622
623         return Variant(static_cast<int>(__pIconListPresenter->GetCheckBoxPosition()));
624 }
625
626 IconListViewCheckBoxPosition
627 _IconListView::GetCheckBoxPosition(void) const
628 {
629         Variant position = GetProperty("checkBoxPosition");
630         return static_cast<IconListViewCheckBoxPosition>(position.ToInt());
631 }
632
633 result
634 _IconListView::SetPropertyTouchAnimationEnabled(const Variant& enabled)
635 {
636         return __pIconListPresenter->SetTouchAnimationEnabled(enabled.ToBool());
637 }
638
639 result
640 _IconListView::SetTouchAnimationEnabled(bool enable)
641 {
642         return SetProperty("touchAnimationEnabled", Variant(enable));
643 }
644
645 Variant
646 _IconListView::GetPropertyTouchAnimationEnabled(void) const
647 {
648         return Variant(__pIconListPresenter->IsTouchAnimationEnabled());
649 }
650
651 bool
652 _IconListView::IsTouchAnimationEnabled(void) const
653 {
654         Variant enabled = GetProperty("touchAnimationEnabled");
655         return enabled.ToBool();
656 }
657
658 result
659 _IconListView::ScrollToItem(int index)
660 {
661         return __pIconListPresenter->ScrollToItem(index);
662 }
663
664 result
665 _IconListView::ScrollByPixel(float pixel)
666 {
667         return __pIconListPresenter->ScrollByPixel(pixel);
668 }
669
670 result
671 _IconListView::RefreshList(int index, ListRefreshType type)
672 {
673         return __pIconListPresenter->RefreshList(index, type);
674 }
675
676 result
677 _IconListView::UpdateList(void)
678 {
679         return __pIconListPresenter->UpdateList();
680 }
681
682 result
683 _IconListView::SetItemBitmapBounds(const Rectangle& bounds)
684 {
685         return SetItemBitmapBounds(_CoordinateSystemUtils::ConvertToFloat(bounds));
686 }
687
688 result
689 _IconListView::SetItemBitmapBounds(const FloatRectangle& bounds)
690 {
691         return __pIconListPresenter->SetItemBitmapBounds(bounds);
692 }
693
694 const FloatRectangle
695 _IconListView::GetItemBitmapBounds(void) const
696 {
697         return __pIconListPresenter->GetItemBitmapBounds();
698 }
699
700 result
701 _IconListView::GetItemBitmapSize(float& width, float& height) const
702 {
703         return __pIconListPresenter->GetItemBitmapSize(width, height);
704 }
705
706 const FloatDimension
707 _IconListView::GetItemBitmapSize(void) const
708 {
709         return __pIconListPresenter->GetItemBitmapSize();
710 }
711
712 result
713 _IconListView::SetItemSize(const FloatDimension& size)
714 {
715         return __pIconListPresenter->SetItemSize(size);
716 }
717
718 result
719 _IconListView::GetItemSize(float& width, float& height) const
720 {
721         return __pIconListPresenter->GetItemSize(width, height);
722 }
723
724 const FloatDimension
725 _IconListView::GetItemSize(void) const
726 {
727         return __pIconListPresenter->GetItemSize();
728 }
729
730 result
731 _IconListView::SetPropertyMagneticScrollSize(const Variant& size)
732 {
733         return __pIconListPresenter->SetMagneticScrollSize(size.ToInt());
734 }
735
736 result
737 _IconListView::SetMagneticScrollSize(int scrollSize)
738 {
739         return SetProperty("magneticScrollSize", Variant(scrollSize));
740 }
741
742 Variant
743 _IconListView::GetPropertyMagneticScrollSize(void) const
744 {
745         return Variant(__pIconListPresenter->GetMagneticScrollSize());
746 }
747
748 int
749 _IconListView::GetMagneticScrollSize(void) const
750 {
751         Variant size = GetProperty("magneticScrollSize");
752         return size.ToInt();
753 }
754
755 int
756 _IconListView::GetItemCountPerAxis(void) const
757 {
758         return __pIconListPresenter->GetItemCountPerAxis();
759 }
760
761 result
762 _IconListView::SetPropertyItemLayoutHorizontalAlignment(const Variant& alignment)
763 {
764         return __pIconListPresenter->SetItemLayoutHorizontalAlignment(static_cast<HorizontalAlignment>(alignment.ToInt()));
765 }
766
767 result
768 _IconListView::SetItemLayoutHorizontalAlignment(HorizontalAlignment alignment)
769 {
770         return SetProperty("itemLayoutHorizontalAlignment", Variant(static_cast<int>(alignment)));
771 }
772
773 result
774 _IconListView::SetPropertyItemLayoutVerticalAlignment(const Variant& alignment)
775 {
776         return __pIconListPresenter->SetItemLayoutVerticalAlignment(static_cast<VerticalAlignment>(alignment.ToInt()));
777 }
778
779 result
780 _IconListView::SetItemLayoutVerticalAlignment(VerticalAlignment alignment)
781 {
782         return SetProperty("itemLayoutVerticalAlignment", Variant(static_cast<int>(alignment)));
783 }
784
785 Variant
786 _IconListView::GetPropertyItemLayoutHorizontalAlignment(void) const
787 {
788         return Variant(static_cast<int>(__pIconListPresenter->GetItemLayoutHorizontalAlignment()));
789 }
790
791 HorizontalAlignment
792 _IconListView::GetItemLayoutHorizontalAlignment(void) const
793 {
794         Variant alignment = GetProperty("itemLayoutHorizontalAlignment");
795         return  static_cast<HorizontalAlignment>(alignment.ToInt());
796 }
797
798 Variant
799 _IconListView::GetPropertyItemLayoutVerticalAlignment(void) const
800 {
801         return Variant(static_cast<int>(__pIconListPresenter->GetItemLayoutVerticalAlignment()));
802 }
803
804 VerticalAlignment
805 _IconListView::GetItemLayoutVerticalAlignment(void) const
806 {
807         Variant alignment = GetProperty("itemLayoutVerticalAlignment");
808         return static_cast<VerticalAlignment>(alignment.ToInt());
809 }
810
811 result
812 _IconListView::SetPropertyItemBorderStyle(const Variant& style)
813 {
814         return __pIconListPresenter->SetItemBorderStyle(static_cast<IconListViewItemBorderStyle>(style.ToInt()));
815 }
816
817 result
818 _IconListView::SetItemBorderStyle(IconListViewItemBorderStyle borderStyle)
819 {
820         return SetProperty("itemBorderStyle", Variant(static_cast<int>(borderStyle)));
821 }
822
823 Variant
824 _IconListView::GetPropertyItemBorderStyle(void) const
825 {
826         return Variant(static_cast<int>(__pIconListPresenter->GetItemBorderStyle()));
827 }
828
829 IconListViewItemBorderStyle
830 _IconListView::GetItemBorderStyle(void) const
831 {
832         Variant style = GetProperty("itemBorderStyle");
833         return static_cast<IconListViewItemBorderStyle>(style.ToInt());
834 }
835
836 result
837 _IconListView::SetBitmapOfEmptyList(const Bitmap* pBitmap)
838 {
839         result r = E_SUCCESS;
840         Bitmap* pCopiedBitmap = null;
841         if (pBitmap != null)
842         {
843                 pCopiedBitmap = _BitmapImpl::CloneN(*pBitmap);
844                 r = GetLastResult();
845         }
846
847         if (r == E_SUCCESS)
848         {
849                 delete __pBitmapOfEmptyList;
850                 __pBitmapOfEmptyList = pCopiedBitmap;
851         }
852         else
853         {
854                 delete pCopiedBitmap;
855         }
856
857         __pIconListPresenter->ClearVisualElement();
858
859         return r;
860 }
861
862 const Bitmap*
863 _IconListView::GetBitmapOfEmptyList(void) const
864 {
865         return __pBitmapOfEmptyList;
866 }
867
868 result
869 _IconListView::SetNonSlidableList(void)
870 {
871         return __pIconListPresenter->SetNonSlidableList();
872 }
873
874 result
875 _IconListView::AddItem(_IconListItem* pItem)
876 {
877         return __pIconListPresenter->AddItem(pItem);
878 }
879
880 result
881 _IconListView::InsertItemAt(int index, _IconListItem* pItem)
882 {
883         return __pIconListPresenter->InsertItemAt(index, pItem);
884 }
885
886 result
887 _IconListView::SetItemAt(int index, _IconListItem* pItem)
888 {
889         return __pIconListPresenter->SetItemAt(index, pItem);
890 }
891
892 result
893 _IconListView::RemoveItemAt(int index)
894 {
895         return __pIconListPresenter->RemoveItemAt(index);
896 }
897
898 result
899 _IconListView::RemoveAllItems(void)
900 {
901         return __pIconListPresenter->RemoveAllItems();
902 }
903
904 result
905 _IconListView::SetScroll(const FloatRectangle& bounds, _ScrollDirection scrollDirection)
906 {
907         if (__pScroll == null)
908         {
909                 __pScroll = _Scroll::CreateScrollN(*this, scrollDirection,
910                                 (((__scrollStyle == ICON_LIST_SCROLL_STYLE_FIXED) || (__scrollStyle == ICON_LIST_SCROLL_STYLE_THUMB)) ? false : true),
911                                 ((__scrollStyle == ICON_LIST_SCROLL_STYLE_JUMP_TO_TOP) ? true : false),
912                                 ((__scrollStyle == ICON_LIST_SCROLL_STYLE_THUMB) ? true : false),
913                                 (((__scrollStyle == ICON_LIST_SCROLL_STYLE_FIXED) || (__scrollStyle == ICON_LIST_SCROLL_STYLE_THUMB)) ? true : false), 1, 1, 0);
914
915                 SysTryReturn(NID_UI_CTRL, __pScroll != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
916
917                 __pScroll->EnableScrollingEffect(true);
918                 __pScroll->SetParentUsingViewport(false);
919                 __pScroll->AddScrollEventListener(*__pIconListPresenter);
920
921                 AttachSystemChild(*__pScroll);
922         }
923
924         return E_SUCCESS;
925 }
926
927 _Scroll*
928 _IconListView::GetScroll(void) const
929 {
930         return __pScroll;
931 }
932
933 void
934 _IconListView::SetItemBitmapAsAspectRatio(bool isAspect)
935 {
936         __pIconListPresenter->SetItemBitmapAsAspectRatio(isAspect);
937 }
938
939 bool
940 _IconListView::IsItemBitmapAsAspectRatio(void) const
941 {
942         return __pIconListPresenter->IsItemBitmapAsAspectRatio();
943 }
944
945 _UiIconListItemEvent*
946 _IconListView::GetIconListItemEvent(void) const
947 {
948         return __pIconListItemEvent;
949 }
950
951 _UiScrollEvent*
952 _IconListView::GetScrollEvent(void) const
953 {
954         return __pScrollEvent;
955 }
956
957 _TouchLongPressGestureDetector*
958 _IconListView::GetLongPressGesture(void) const
959 {
960         return __pGestureLongPress;
961 }
962
963 result
964 _IconListView::SetLongPressGesture(_TouchLongPressGestureDetector* pLongPress)
965 {
966         __pGestureLongPress = pLongPress;
967         return E_SUCCESS;
968 }
969
970 _TouchFlickGestureDetector*
971 _IconListView::GetFlickGesture(void) const
972 {
973         return __pGestureFlick;
974 }
975
976 result
977 _IconListView::SetFlickGesture(_TouchFlickGestureDetector* pFlick)
978 {
979         __pGestureFlick = pFlick;
980         return E_SUCCESS;
981 }
982
983 result
984 _IconListView::SetReorderModeEnabled(bool enable)
985 {
986         if (__reorderEnabled != enable)
987         {
988                 __reorderEnabled = enable;
989                 return __pIconListPresenter->SetReorderModeEnabled(enable);
990         }
991         return E_SUCCESS;
992 }
993
994 bool
995 _IconListView::IsInReorderingMode(void) const
996 {
997         return __reorderEnabled;
998 }
999
1000 void
1001 _IconListView::SetScrollInputMode(ScrollInputMode mode)
1002 {
1003         __scrollInputMode = mode;
1004 }
1005
1006 ScrollInputMode
1007 _IconListView::GetScrollInputMode(void) const
1008 {
1009         return __scrollInputMode;
1010 }
1011
1012 void
1013 _IconListView::OnBoundsChanged(void)
1014 {
1015         __pIconListPresenter->OnBoundsChanged();
1016 }
1017
1018 void
1019 _IconListView::OnDraw(void)
1020 {
1021         __pIconListPresenter->Draw();
1022 }
1023
1024 void
1025 _IconListView::OnAncestorVisibleStateChanged(const _Control& control)
1026 {
1027         _Control::OnAncestorVisibleStateChanged(control);
1028
1029         OnVisibleStateChanged();
1030 }
1031
1032 void
1033 _IconListView::OnAncestorEnableStateChanged(const _Control& control)
1034 {
1035         _Control::OnAncestorEnableStateChanged(control);
1036
1037         OnVisibleStateChanged();
1038 }
1039
1040 void
1041 _IconListView::OnAncestorInputEnableStateChanged(const _Control& control)
1042 {
1043         __pIconListPresenter->OnInputEnableStateChanged();
1044 }
1045
1046 void
1047 _IconListView::OnChangeLayout(_ControlOrientation orientation)
1048 {
1049         _Control::OnChangeLayout(orientation);
1050
1051         __pIconListPresenter->ClearVisualElement();
1052 }
1053
1054 void
1055 _IconListView::OnFontInfoRequested(unsigned long& style, int& size)
1056 {
1057         float floatSize = 0.0f;
1058         __pIconListPresenter->OnFontInfoRequested(style, floatSize);
1059         size = _CoordinateSystemUtils::ConvertToInteger(floatSize);
1060 }
1061
1062 void
1063 _IconListView::OnFontInfoRequested(unsigned long& style, float& size)
1064 {
1065         __pIconListPresenter->OnFontInfoRequested(style, size);
1066 }
1067
1068 void
1069 _IconListView::OnFontChanged(Font* pFont)
1070 {
1071         __pIconListPresenter->OnFontChanged(pFont);
1072 }
1073
1074 void
1075 _IconListView::OnFocusModeStateChanged(void)
1076 {
1077         __pIconListPresenter->OnFocusModeStateChanged();
1078 }
1079
1080 void
1081 _IconListView::OnDrawFocus(void)
1082 {
1083         __pIconListPresenter->OnDrawFocus();
1084 }
1085
1086 Canvas*
1087 _IconListView::OnCanvasRequestedN(const FloatRectangle& bounds)
1088 {
1089         return __pIconListPresenter->OnCanvasRequestedN(bounds);
1090 }
1091
1092
1093 // Tizen::Ui::_IPreviewKeyEventListener
1094 bool
1095 _IconListView::OnPreviewKeyPressed(const _Control& source, const _KeyInfo& keyInfo)
1096 {
1097         return __pIconListPresenter->OnPreviewKeyPressed(source, keyInfo);
1098 }
1099
1100 bool
1101 _IconListView::OnPreviewKeyReleased(const _Control& source, const _KeyInfo& keyInfo)
1102 {
1103         return __pIconListPresenter->OnPreviewKeyReleased(source, keyInfo);
1104 }
1105
1106 // Tizen::Ui::_IKeyEventListener
1107 bool
1108 _IconListView::OnKeyPressed(const _Control& source, const _KeyInfo& keyInfo)
1109 {
1110         return __pIconListPresenter->OnKeyPressed(source, keyInfo);
1111 }
1112
1113 bool
1114 _IconListView::OnKeyReleased(const _Control& source, const _KeyInfo& keyInfo)
1115 {
1116         return __pIconListPresenter->OnKeyReleased(source, keyInfo);
1117 }
1118
1119 // Tizen::Ui::_IPreviewNotificationEventListener
1120 bool
1121 _IconListView::OnPreviewNotifiedN(const _Control& source, Collection::IList* pArgs)
1122 {
1123         return __pIconListPresenter->OnPreviewNotifiedN(source, pArgs);
1124 }
1125
1126 // Tizen::Ui::_INotificationEventListener
1127 bool
1128 _IconListView::OnNotifiedN(const _Control& source, Collection::IList* pArgs)
1129 {
1130         return __pIconListPresenter->OnNotifiedN(source, pArgs);
1131 }
1132
1133 // Tizen::Ui::_ITouchEventPreviewer
1134 _UiTouchEventDelivery
1135 _IconListView::OnPreviewTouchReleased(const _Control& source, const _TouchInfo& touchinfo)
1136 {
1137         return __pIconListPresenter->OnPreviewTouchReleased(source, touchinfo);
1138 }
1139
1140 // Tizen::Ui::_ITouchEventListener
1141 bool
1142 _IconListView::OnTouchPressed(const _Control& source, const _TouchInfo& touchinfo)
1143 {
1144         return __pIconListPresenter->OnTouchPressed(source, touchinfo);
1145 }
1146
1147 bool
1148 _IconListView::OnTouchReleased(const _Control& source, const _TouchInfo& touchinfo)
1149 {
1150         return __pIconListPresenter->OnTouchReleased(source, touchinfo);
1151 }
1152
1153 bool
1154 _IconListView::OnTouchMoved(const _Control& source, const _TouchInfo& touchinfo)
1155 {
1156         return __pIconListPresenter->OnTouchMoved(source, touchinfo);
1157 }
1158
1159 bool
1160 _IconListView::OnTouchCanceled(const _Control& source, const _TouchInfo& touchinfo)
1161 {
1162         return __pIconListPresenter->OnTouchCanceled(source, touchinfo);
1163 }
1164
1165 bool
1166 _IconListView::OnFlickGestureDetected(_TouchFlickGestureDetector& gesture)
1167 {
1168         int xDistance = 0;
1169         int yDistance = 0;
1170         gesture.GetDistance(xDistance, yDistance);
1171         Point flickPoint(xDistance, yDistance);
1172
1173         return __pIconListPresenter->OnFlickGestureDetected(true, flickPoint, gesture.GetDuration());
1174 }
1175
1176 bool
1177 _IconListView::OnFlickGestureCanceled(_TouchFlickGestureDetector& gesture)
1178 {
1179         return false;
1180 }
1181
1182 bool
1183 _IconListView::OnLongPressGestureDetected(_TouchLongPressGestureDetector& gesture)
1184 {
1185         return __pIconListPresenter->OnLongPressGestureDetected();
1186 }
1187
1188 bool
1189 _IconListView::OnLongPressGestureCanceled(_TouchLongPressGestureDetector& gesture)
1190 {
1191         return false;
1192 }
1193
1194 void
1195 _IconListView::OnPropertyChanging(_PropertyBase& source, const String& name, const Variant& oldValue, const Variant& newValue)
1196 {
1197 }
1198
1199 void
1200 _IconListView::OnPropertyChanged(_PropertyBase& source, const String& name, const Variant& oldValue, const Variant& newValue)
1201 {
1202 }
1203
1204 void
1205 _IconListView::OnVisibleStateChanged(void)
1206 {
1207         if (__pScroll != null)
1208         {
1209                 bool enableFadeEffect = __pScroll->IsEnabledFadeEffect();
1210                 if (GetVisibleState() == false)
1211                 {
1212                         if (enableFadeEffect)
1213                         {
1214                                 __pScroll->SetScrollVisibility(false);
1215                         }
1216                 }
1217                 else if (enableFadeEffect)
1218                 {
1219                         float scrollViewRange = 0.0f;
1220                         float scrollRange = 0.0f;
1221                         __pScroll->GetScrollRange(&scrollViewRange, &scrollRange);
1222
1223                         if (!_FloatCompareGE(scrollViewRange, scrollRange))
1224                         {
1225                                 __pIconListPresenter->ScrollFadeOut();
1226                         }
1227                 }
1228         }
1229
1230         __pIconListPresenter->OnVisibleStateChanged();
1231 }
1232
1233 // Tizen::Ui::_IScrollEventListener
1234 void
1235 _IconListView::OnScrollEndReached(_Control& source, ScrollEndEvent type)
1236 {
1237         __pIconListPresenter->OnScrollEndReached(source, type);
1238 }
1239
1240 void
1241 _IconListView::OnScrollPositionChanged(_Control& source, float scrollPosition)
1242 {
1243         __pIconListPresenter->OnScrollPositionChanged(source, scrollPosition);
1244 }
1245
1246 void
1247 _IconListView::OnScrollStopped(_Control& source)
1248 {
1249         __pIconListPresenter->OnScrollStopped(source);
1250 }
1251
1252 // Tizen::Ui::Animations::IAnimationTransactionEventListener
1253 void
1254 _IconListView::OnAnimationTransactionStarted(int transactionId)
1255 {
1256 }
1257
1258 void
1259 _IconListView::OnAnimationTransactionStopped(int transactionId)
1260 {
1261         __pIconListPresenter->OnAnimationTransactionStopped(transactionId);
1262 }
1263
1264 void
1265 _IconListView::OnAnimationTransactionFinished(int transactionId)
1266 {
1267         __pIconListPresenter->OnAnimationTransactionFinished(transactionId);
1268 }
1269
1270 // Tizen::Ui::Animations::IVisualElementAnimationTickEventListener
1271 void
1272 _IconListView::OnTickOccurred(const VisualElementAnimation& animation, const String& keyName, VisualElement& target, const Variant& currentValue)
1273 {
1274         __pIconListPresenter->OnTickOccurred(animation, keyName, target, currentValue);
1275 }
1276
1277 // Tizen::Ui::Animations::IVisualElementAnimationStatusEventListener
1278 void
1279 _IconListView::OnVisualElementAnimationStarted(const VisualElementAnimation& animation, const String& keyName, VisualElement& target)
1280 {
1281         __pIconListPresenter->OnVisualElementAnimationStarted(animation, keyName, target);
1282 }
1283
1284 void
1285 _IconListView::OnVisualElementAnimationRepeated(const VisualElementAnimation& animation, const String& keyName, VisualElement& target, long currentRepeatCount)
1286 {
1287         __pIconListPresenter->OnVisualElementAnimationRepeated(animation, keyName, target, currentRepeatCount);
1288 }
1289
1290 void
1291 _IconListView::OnVisualElementAnimationFinished(const VisualElementAnimation& animation, const String& keyName, VisualElement& target, bool completedNormally)
1292 {
1293         __pIconListPresenter->OnVisualElementAnimationFinished(animation, keyName, target, completedNormally);
1294 }
1295
1296 VisualElementValueAnimation*
1297 _IconListView::GetScrollingAnimation(void) const
1298 {
1299         return __pScrollingAnimation;
1300 }
1301
1302 }}} // Tizen::Ui::Controls