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