Changed indicator bg color.
[platform/framework/native/uifw.git] / src / ui / controls / FUiCtrl_ListViewImpl.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_ListViewImpl.cpp
20  * @brief   This is the implementation file for _ListViewImpl class.
21  *
22  * This file contains the implementation of _ListViewImpl class.
23  */
24
25 #include <FBaseSysLog.h>
26 #include <FApp_AppInfo.h>
27 #include <FGrp_TextTextSimple.h>
28 #include "FUi_AccessibilityContainer.h"
29 #include "FUi_AccessibilityElement.h"
30 #include "FUi_AccessibilityManager.h"
31 #include "FUi_CoordinateSystemUtils.h"
32 #include "FUi_Math.h"
33 #include "FUi_ITouchLongPressGestureEventListener.h"
34 #include "FUi_ResourceManager.h"
35 #include "FUi_TouchEventArg.h"
36 #include "FUi_TouchLongPressGestureDetector.h"
37 #include "FUi_TouchManager.h"
38 #include "FUi_UiBuilder.h"
39 #include "FUiCtrl_FastScrollEvent.h"
40 #include "FUiCtrl_FastScrollEventArg.h"
41 #include "FUiCtrl_Label.h"
42 #include "FUiCtrl_ListItemEvent.h"
43 #include "FUiCtrl_ListItemEventArg.h"
44 #include "FUiCtrl_ListViewImpl.h"
45 #include "FUiCtrl_ListViewItem.h"
46 #include "FUiCtrl_ListViewItemProviderAdaptor.h"
47 #include "FUiCtrl_PublicLinkEvent.h"
48 #include "FUiCtrl_ScrollEvent.h"
49 #include "FUiCtrl_ScrollEventArg.h"
50
51 using namespace Tizen::Base;
52 using namespace Tizen::Base::Collection;
53 using namespace Tizen::Base::Runtime;
54 using namespace Tizen::Base::Utility;
55 using namespace Tizen::Graphics;
56 using namespace Tizen::Graphics::_Text;
57
58 namespace Tizen { namespace Ui { namespace Controls
59 {
60
61 class _ListViewImpl::_ListViewPropagatedTouchEventListener
62         : public Tizen::Ui::_IPropagatedTouchEventListener
63         , public Tizen::Ui::_ITouchLongPressGestureEventListener
64 {
65 public:
66
67         _ListViewPropagatedTouchEventListener(_ListViewImpl& impl)
68                 : __impl(impl)
69                 , __core(impl.GetCore())
70                 , __public(impl.GetPublic())
71                 , __oldPreviousPressedTime(0)
72                 , __previousPressedTime(0)
73                 , __currentPressedTime(0)
74                 , __previousPressedPoint(0.0f, 0.0f)
75                 , __currentPressedPoint(0.0f, 0.0f)
76                 , __pLongPressedGesture(null)
77         {
78                 __pTouchManager = _TouchManager::GetInstance();
79                 SysTryReturnVoidResult(NID_UI_CTRL, (__pTouchManager != null), E_SYSTEM, "[E_SYSTEM] System error occurred.");
80
81                 // Add _TouchLongPressGestureDetector
82                 __pLongPressedGesture = new (std::nothrow) _TouchLongPressGestureDetector();
83                 SysTryReturnVoidResult(NID_UI_CTRL, (__pLongPressedGesture != null), E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
84
85                 __core.AddGestureDetector(*__pLongPressedGesture);
86                 result r = __pLongPressedGesture->AddGestureListener(*this);
87                 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] propagating.", GetErrorMessage(r));
88         }
89
90         virtual ~_ListViewPropagatedTouchEventListener(void)
91         {
92                 if (__pLongPressedGesture != null)
93                 {
94                         __pLongPressedGesture->RemoveGestureListener(*this);
95                         __core.RemoveGestureDetector(*__pLongPressedGesture);
96
97                         delete __pLongPressedGesture;
98                         __pLongPressedGesture = null;
99                 }
100         }
101
102         virtual bool OnTouchPressed(const _Control& source, const _TouchInfo& touchInfo)
103         {
104                 return __impl.CallOnTouchPressed(source, touchInfo);
105         }
106
107         virtual bool OnTouchReleased(const _Control& source, const _TouchInfo& touchInfo)
108         {
109                 return __impl.CallOnTouchReleased(source, touchInfo);
110         }
111
112         virtual bool OnTouchMoved(const _Control& source, const _TouchInfo& touchInfo)
113         {
114                 return __impl.CallOnTouchMoved(source, touchInfo);
115         }
116
117         virtual bool OnTouchCanceled(const _Control& source, const _TouchInfo& touchInfo)
118         {
119                 return __impl.CallOnTouchCanceled(source, touchInfo);
120         }
121
122         virtual _UiTouchEventDelivery OnPreviewTouchPressed(const _Control& source, const _TouchInfo& touchInfo)
123         {
124                 _UiTouchEventDelivery isFiltered = _UI_TOUCH_EVENT_DELIVERY_NO;
125                 IPropagatedTouchEventListener* pListener = __impl.GetPublicPropagatedTouchEventListener();
126
127                 if (pListener != null)
128                 {
129                         Control& control = __impl.GetPublic();
130
131                         TouchEventInfo publicTouchInfo;
132
133                         _TouchEventArg* pEventArg = GetTouchEventArgN(touchInfo);
134                         SysTryReturn(NID_UI, pEventArg, _UI_TOUCH_EVENT_DELIVERY_YES, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory shortage.");
135
136                         publicTouchInfo.Construct(*pEventArg);
137
138                         if (pEventArg)
139                         {
140                                 delete pEventArg;
141                                 pEventArg = null;
142                         }
143
144                         if (pListener->OnTouchPressed(control, publicTouchInfo) == true)
145                         {
146                                 return _UI_TOUCH_EVENT_DELIVERY_NO;
147                         }
148                 }
149
150                 // public TouchEventListener
151                 if (ProcessTouchEventListener(touchInfo) == true)
152                 {
153                         return _UI_TOUCH_EVENT_DELIVERY_NO;
154                 }
155
156                 if (__core.Equals(source))
157                 {
158                         return _UI_TOUCH_EVENT_DELIVERY_NO;
159                 }
160
161                 isFiltered = __impl.OnPreviewTouchPressed(__impl, touchInfo);
162                 if (isFiltered == _UI_TOUCH_EVENT_DELIVERY_NO)
163                 {
164                         return _UI_TOUCH_EVENT_DELIVERY_NO;
165                 }
166
167                 isFiltered = __core.OnPreviewTouchPressed(source, touchInfo);
168
169                 return isFiltered;
170         }
171
172         virtual _UiTouchEventDelivery OnPreviewTouchReleased(const _Control& source, const _TouchInfo& touchInfo)
173         {
174                 _UiTouchEventDelivery isFiltered = _UI_TOUCH_EVENT_DELIVERY_NO;
175                 IPropagatedTouchEventListener* pListener = __impl.GetPublicPropagatedTouchEventListener();
176
177                 if (pListener != null)
178                 {
179                         Control& control = __impl.GetPublic();
180
181                         TouchEventInfo publicTouchInfo;
182
183                         _TouchEventArg* pEventArg = GetTouchEventArgN(touchInfo);
184                         SysTryReturn(NID_UI, pEventArg, _UI_TOUCH_EVENT_DELIVERY_YES, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory shortage.");
185
186                         publicTouchInfo.Construct(*pEventArg);
187
188                         if (pEventArg)
189                         {
190                                 delete pEventArg;
191                                 pEventArg = null;
192                         }
193
194                         if (pListener->OnTouchReleased(control, publicTouchInfo) == true)
195                         {
196                                 return _UI_TOUCH_EVENT_DELIVERY_NO;
197                         }
198                 }
199
200                 // public TouchEventListener
201                 if (ProcessTouchEventListener(touchInfo) == true)
202                 {
203                         return _UI_TOUCH_EVENT_DELIVERY_NO;
204                 }
205
206                 if (__core.Equals(source))
207                 {
208                         return _UI_TOUCH_EVENT_DELIVERY_NO;
209                 }
210
211                 isFiltered = __impl.OnPreviewTouchReleased(__impl, touchInfo);
212                 if (isFiltered == _UI_TOUCH_EVENT_DELIVERY_NO)
213                 {
214                         return _UI_TOUCH_EVENT_DELIVERY_NO;
215                 }
216
217                 isFiltered = __core.OnPreviewTouchReleased(source, touchInfo);
218
219                 return isFiltered;
220         }
221
222         virtual _UiTouchEventDelivery OnPreviewTouchMoved(const _Control& source, const _TouchInfo& touchInfo)
223         {
224                 _UiTouchEventDelivery isFiltered = _UI_TOUCH_EVENT_DELIVERY_NO;
225                 IPropagatedTouchEventListener* pListener = __impl.GetPublicPropagatedTouchEventListener();
226
227                 if (pListener != null)
228                 {
229                         Control& control = __impl.GetPublic();
230
231                         TouchEventInfo publicTouchInfo;
232
233                         _TouchEventArg* pEventArg = GetTouchEventArgN(touchInfo);
234                         SysTryReturn(NID_UI, pEventArg, _UI_TOUCH_EVENT_DELIVERY_YES, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory shortage.");
235
236                         publicTouchInfo.Construct(*pEventArg);
237
238                         if (pEventArg)
239                         {
240                                 delete pEventArg;
241                                 pEventArg = null;
242                         }
243
244                         if (pListener->OnTouchMoved(control, publicTouchInfo) == true)
245                         {
246                                 return _UI_TOUCH_EVENT_DELIVERY_NO;
247                         }
248                 }
249
250                 // public TouchEventListener
251                 if (ProcessTouchEventListener(touchInfo) == true)
252                 {
253                         return _UI_TOUCH_EVENT_DELIVERY_NO;
254                 }
255
256                 if (__core.Equals(source))
257                 {
258                         return _UI_TOUCH_EVENT_DELIVERY_NO;
259                 }
260
261                 isFiltered = __impl.OnPreviewTouchMoved(__impl, touchInfo);
262                 if (isFiltered == _UI_TOUCH_EVENT_DELIVERY_NO)
263                 {
264                         return _UI_TOUCH_EVENT_DELIVERY_NO;
265                 }
266
267                 isFiltered = __core.OnPreviewTouchMoved(source, touchInfo);
268
269                 return isFiltered;
270         }
271
272         virtual _UiTouchEventDelivery OnPreviewTouchCanceled(const _Control& source, const _TouchInfo& touchInfo)
273         {
274                 IPropagatedTouchEventListener* pListener = __impl.GetPublicPropagatedTouchEventListener();
275
276                 if (pListener != null)
277                 {
278                         Control& control = __impl.GetPublic();
279
280                         TouchEventInfo publicTouchInfo;
281
282                         _TouchEventArg* pEventArg = GetTouchEventArgN(touchInfo);
283                         SysTryReturn(NID_UI, pEventArg, _UI_TOUCH_EVENT_DELIVERY_YES, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory shortage.");
284
285                         publicTouchInfo.Construct(*pEventArg);
286
287                         if (pEventArg)
288                         {
289                                 delete pEventArg;
290                                 pEventArg = null;
291                         }
292
293                         if (pListener->OnTouchCanceled(control, publicTouchInfo) == true)
294                         {
295                                 return _UI_TOUCH_EVENT_DELIVERY_NO;
296                         }
297                 }
298
299                 // public TouchEventListener
300                 if (ProcessTouchEventListener(touchInfo) == true)
301                 {
302                         return _UI_TOUCH_EVENT_DELIVERY_NO;
303                 }
304
305                 return _UI_TOUCH_EVENT_DELIVERY_YES;
306         }
307
308         virtual void OnTouchPressHandled(const _Control& source)
309         {
310                 __impl.OnTouchPressHandled(source);
311         }
312
313         virtual void OnTouchReleaseHandled(const _Control& source)
314         {
315                 __impl.OnTouchReleaseHandled(source);
316         }
317
318         virtual void OnTouchMoveHandled(const _Control& source)
319         {
320                 __impl.OnTouchMoveHandled(source);
321         }
322
323         virtual void OnTouchCancelHandled(const _Control& source)
324         {
325                 __impl.OnTouchCancelHandled(source);
326         }
327
328         bool OnLongPressGestureDetected(_TouchLongPressGestureDetector& gesture)
329         {
330                 bool filtered = ProcessTouchEventListener();
331
332                 if (!filtered)
333                 {
334                         __impl.FireListViewItemLongPressedEvent();
335                 }
336
337                 return filtered;
338         }
339
340         bool OnLongPressGestureCanceled(_TouchLongPressGestureDetector& gesture)
341         {
342                 return false;
343         }
344
345 private:
346
347         bool ProcessTouchEventListener(const _TouchInfo& touchInfo)
348         {
349                 bool filtered = false;
350
351                 if (touchInfo.GetTouchStatus() == _TOUCH_PRESSED)
352                 {
353                         filtered = ProcessTouchDoublePressed(touchInfo);
354                 }
355
356                 if (!filtered)
357                 {
358                         ProcessTouchEvent(touchInfo);
359                 }
360
361                 filtered = __impl.IsInputEventConsumed();
362
363                 if (filtered)
364                 {
365                         __impl.ResetInputEventConsumed();
366                 }
367
368                 return filtered;
369         }
370
371         bool ProcessTouchEventListener(void)
372         {
373                 // for TouchLongPressed
374                 _TouchInfo touchInfo(0, _TOUCH_LONG_PRESSED, __currentPressedPoint, false, 0);
375
376                 return ProcessTouchEventListener(touchInfo);
377         }
378
379         void ProcessTouchEvent(const _TouchInfo& touchInfo)
380         {
381                 TouchEventInfo publicTouchInfo;
382
383                 _TouchEventArg* pEventArg = GetTouchEventArgN(touchInfo);
384                 SysTryReturnVoidResult(NID_UI, pEventArg, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
385
386                 publicTouchInfo.Construct(*pEventArg);
387
388                 _Control* pDraggedControl = __pTouchManager->GetTouchControlSource();
389
390                 IEnumeratorT<IEventListener*>* pEnumerator = __impl.GetTouchEventListener()->GetEnumeratorN();
391                 if (pEnumerator)
392                 {
393                         while (pEnumerator->MoveNext() == E_SUCCESS)
394                         {
395                                 IEventListener* pListener = null;
396                                 pEnumerator->GetCurrent(pListener);
397
398                                 ITouchEventListener* pTouchEventListener = dynamic_cast <ITouchEventListener*>(pListener);
399                                 if (pTouchEventListener != null)
400                                 {
401                                         FirePublicListener(*pTouchEventListener, publicTouchInfo);
402
403                                         if (touchInfo.GetTouchStatus() == _TOUCH_RELEASED)
404                                         {
405                                                 if (pDraggedControl == null)    //if exist dragged control, don't send focus event
406                                                 {
407                                                         FireFocusListener(*pTouchEventListener, publicTouchInfo);
408                                                 }
409                                         }
410                                         else if (touchInfo.GetTouchStatus() == _TOUCH_MOVED)
411                                         {
412                                                 FireFocusListener(*pTouchEventListener, publicTouchInfo);
413                                         }
414                                 }
415                         }
416
417                         delete pEnumerator;
418                 }
419
420                 delete pEventArg;
421         }
422
423         bool ProcessTouchDoublePressed(const _TouchInfo& touchinfo)
424         {
425                 if (__pTouchManager->GetPointCount() == 1)
426                 {
427                         __oldPreviousPressedTime = __previousPressedTime;
428                         __previousPressedTime = __currentPressedTime;
429                         __currentPressedTime = touchinfo.GetTimeStamp();
430                         __previousPressedPoint.x = __currentPressedPoint.x;
431                         __previousPressedPoint.y = __currentPressedPoint.y;
432                         __currentPressedPoint.x = touchinfo.GetCurrentPosition().x;
433                         __currentPressedPoint.y = touchinfo.GetCurrentPosition().y;
434
435                         if (Math::Abs(__previousPressedTime - __currentPressedTime) < DOUBLE_PRESS_TIME)
436                         {
437                                 if (Math::Abs(__previousPressedTime - __oldPreviousPressedTime) > DOUBLE_PRESS_TIME)
438                                 {
439                                         if ((Math::Abs(__previousPressedPoint.x - __currentPressedPoint.x) < DOUBLE_PRESS_MOVE_ALLOWANCE)
440                                                 && (Math::Abs(__previousPressedPoint.y - __currentPressedPoint.y) < DOUBLE_PRESS_MOVE_ALLOWANCE))
441                                         {
442                                                 _TouchInfo touchInfo(0, _TOUCH_DOUBLE_PRESSED, __currentPressedPoint, false, 0);
443                                                 ProcessTouchEvent(touchInfo);
444
445                                                 return true;
446                                         }
447                                 }
448                         }
449                 }
450
451                 return false;
452         }
453
454         void FirePublicListener(ITouchEventListener& listener, const TouchEventInfo& touchEventInfo)
455         {
456                 switch (touchEventInfo.GetTouchStatus())
457                 {
458                 case TOUCH_PRESSED:
459                         listener.OnTouchPressed(__public, touchEventInfo.GetCurrentPosition(), touchEventInfo);
460                         break;
461                 case TOUCH_LONG_PRESSED:
462                         listener.OnTouchLongPressed(__public, touchEventInfo.GetCurrentPosition(), touchEventInfo);
463                         break;
464                 case TOUCH_RELEASED:
465                         listener.OnTouchReleased(__public, touchEventInfo.GetCurrentPosition(), touchEventInfo);
466                         break;
467                 case TOUCH_MOVED:
468                         listener.OnTouchMoved(__public, touchEventInfo.GetCurrentPosition(), touchEventInfo);
469                         break;
470                 case TOUCH_DOUBLE_PRESSED:
471                         listener.OnTouchDoublePressed(__public, touchEventInfo.GetCurrentPosition(), touchEventInfo);
472                         break;
473                 case TOUCH_FOCUS_IN:
474                         listener.OnTouchFocusIn(__public, touchEventInfo.GetCurrentPosition(), touchEventInfo);
475                         break;
476                 case TOUCH_FOCUS_OUT:
477                         listener.OnTouchFocusOut(__public, touchEventInfo.GetCurrentPosition(), touchEventInfo);
478                         break;
479                 case TOUCH_CANCELED:
480                         listener.OnTouchCanceled(__public, touchEventInfo.GetCurrentPosition(), touchEventInfo);
481                         break;
482                 default:
483                         break;
484                 }
485         }
486
487         void FireFocusListener(ITouchEventListener& listener, const TouchEventInfo& touchEventInfo)
488         {
489                 _ControlManager* pControlManager = _ControlManager::GetInstance();
490                 SysTryReturnVoidResult(NID_UI, pControlManager, E_SYSTEM, "[E_SYSTEM] System error occurred.");
491
492                 Point screenPoint(__pTouchManager->GetScreenPoint(touchEventInfo.GetPointId()).x,
493                                                   __pTouchManager->GetScreenPoint(touchEventInfo.GetPointId()).y);
494
495                 _Control* pTouchedControl = pControlManager->GetTopmostTouchedControl(screenPoint);
496                 SysTryReturnVoidResult(NID_UI, pTouchedControl, E_INVALID_CONDITION, "[E_INVALID_CONDITION] pTouchedControl is null.");
497
498                 if (__pTouchManager->GetFocusedControlSource() != pTouchedControl)
499                 {
500                         if (&(__core) != pTouchedControl)
501                         {
502                                 if (__pTouchManager->GetFocusedControlSource() == &(__core))
503                                 {
504                                         listener.OnTouchFocusOut(__public, touchEventInfo.GetCurrentPosition(), touchEventInfo);
505                                 }
506                         }
507                         else
508                         {
509                                 listener.OnTouchFocusIn(__public, touchEventInfo.GetCurrentPosition(), touchEventInfo);
510                         }
511
512                         __pTouchManager->SetFocusedControlSource(*pTouchedControl);
513                 }
514         }
515
516         _TouchEventArg* GetTouchEventArgN(const _TouchInfo& touchInfo)
517         {
518                 FloatPoint startPoint;
519
520                 _TouchEventArg* pEventArg = new (std::nothrow) _TouchEventArg(__public, touchInfo.GetTouchStatus());
521                 SysTryReturn(NID_UI, pEventArg, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
522
523                 startPoint.SetPosition(__pTouchManager->GetStartPoint(touchInfo.GetPointId()).x - __core.GetAbsoluteBoundsF().x,
524                                                            __pTouchManager->GetStartPoint(touchInfo.GetPointId()).y - __core.GetAbsoluteBoundsF().y);
525
526                 pEventArg->SetTouchPosition(touchInfo.GetPointId(), startPoint.x, startPoint.y,
527                                                                         touchInfo.GetCurrentPosition().x, touchInfo.GetCurrentPosition().y);
528
529                 // need to flick distance setting
530
531                 return pEventArg;
532         }
533
534 private:
535         static const int DOUBLE_PRESS_TIME = 500;
536         static const int DOUBLE_PRESS_MOVE_ALLOWANCE = 10;
537
538         _ListViewImpl& __impl;
539         _Control& __core;
540         Control& __public;
541         _TouchManager* __pTouchManager;
542
543         unsigned int __oldPreviousPressedTime;
544         unsigned int __previousPressedTime;
545         unsigned int __currentPressedTime;
546         Tizen::Graphics::FloatPoint __previousPressedPoint;
547         Tizen::Graphics::FloatPoint __currentPressedPoint;
548         _TouchLongPressGestureDetector* __pLongPressedGesture;
549 };
550
551 _ListViewImpl*
552 _ListViewImpl::GetInstance(ListView& listView)
553 {
554         return static_cast<_ListViewImpl*>(listView._pControlImpl);
555 }
556
557 const _ListViewImpl*
558 _ListViewImpl::GetInstance(const ListView& listView)
559 {
560         return static_cast<const _ListViewImpl*>(listView._pControlImpl);
561 }
562
563 _ListViewImpl::_ListViewImpl(ListView* pList, _TableView* pCore)
564         : _ControlImpl(pList, pCore)
565         , __pListItemEvent(null)
566         , __pLinkEvent(null)
567         , __pScrollEvent(null)
568         , __pFastScrollEvent(null)
569         , __pEmptyBitmap(null)
570         , __pEmptyText(null)
571         , __pAccessibilityElement(null)
572         , __redrawListView(true)
573         , __isOrientationChanged(false)
574         , __needReloadItems(false)
575         , __pPropagatedTouchEventListener(null)
576 {
577         GET_COLOR_CONFIG(TABLEVIEW::EMPTY_CONTENTS_TEXT_NORMAL, __emptyTextColor);
578 }
579
580 _ListViewImpl::~_ListViewImpl()
581 {
582         delete __pListItemEvent;
583         __pListItemEvent = null;
584
585         delete __pLinkEvent;
586         __pLinkEvent = null;
587
588         delete __pScrollEvent;
589         __pScrollEvent = null;
590
591         delete __pFastScrollEvent;
592         __pFastScrollEvent = null;
593
594         if (__pEmptyBitmap != null)
595         {
596                 GetCore().DetachChild(*__pEmptyBitmap);
597
598                 delete __pEmptyBitmap;
599                 __pEmptyBitmap = null;
600         }
601
602         if (__pEmptyText != null)
603         {
604                 GetCore().DetachChild(*__pEmptyText);
605
606                 delete __pEmptyText;
607                 __pEmptyText = null;
608         }
609
610         _AccessibilityContainer* pContainer = GetCore().GetAccessibilityContainer();
611
612         if ((__pAccessibilityElement != null) && (pContainer != null))
613         {
614                 pContainer->RemoveElement(__pAccessibilityElement);
615         }
616
617         delete __pPropagatedTouchEventListener;
618         __pPropagatedTouchEventListener = null;
619 }
620
621 const char*
622 _ListViewImpl::GetPublicClassName(void) const
623 {
624         return "Tizen::Ui::Controls::ListView";
625 }
626
627 const ListView&
628 _ListViewImpl::GetPublic(void) const
629 {
630         return static_cast <const ListView&>(_ControlImpl::GetPublic());
631 }
632
633 ListView&
634 _ListViewImpl::GetPublic(void)
635 {
636         return static_cast <ListView&>(_ControlImpl::GetPublic());
637 }
638
639 const _TableView&
640 _ListViewImpl::GetCore(void) const
641 {
642         return static_cast <const _TableView&>(_ControlImpl::GetCore());
643 }
644
645 _TableView&
646 _ListViewImpl::GetCore(void)
647 {
648         return static_cast <_TableView&>(_ControlImpl::GetCore());
649 }
650
651 _ListViewImpl*
652 _ListViewImpl::CreateListViewImplN(ListView* pControl, bool itemDivider, ListScrollStyle scrollStyle)
653 {
654         result r = E_SUCCESS;
655         TableViewScrollBarStyle scrollBarStyle;
656
657         switch (scrollStyle)
658         {
659         case SCROLL_STYLE_FADE_OUT:
660                 scrollBarStyle = TABLE_VIEW_SCROLL_BAR_STYLE_FADE_OUT;
661                 break;
662
663         case SCROLL_STYLE_FIXED:
664                 scrollBarStyle = TABLE_VIEW_SCROLL_BAR_STYLE_FIXED;
665                 break;
666
667         case SCROLL_STYLE_FAST_SCROLL:
668                 scrollBarStyle = TABLE_VIEW_SCROLL_BAR_STYLE_FAST_SCROLL;
669                 break;
670
671         case SCROLL_STYLE_JUMP_TO_TOP:
672                 scrollBarStyle = TABLE_VIEW_SCROLL_BAR_STYLE_JUMP_TO_TOP;
673                 break;
674
675         case SCROLL_STYLE_THUMB:
676                 scrollBarStyle = TABLE_VIEW_SCROLL_BAR_STYLE_THUMB;
677                 break;
678
679         case SCROLL_STYLE_FAST_SCROLL_FIXED:
680                 scrollBarStyle = TABLE_VIEW_SCROLL_BAR_STYLE_FAST_SCROLL_FIXED;
681                 break;
682
683         default:
684                 scrollBarStyle = TABLE_VIEW_SCROLL_BAR_STYLE_NONE;
685                 break;
686         }
687
688         _TableView* pCore = _TableView::CreateTableViewN(TABLE_VIEW_STYLE_SIMPLE, itemDivider, scrollBarStyle);
689
690         SysTryReturn(NID_UI_CTRL, (pCore != null), null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
691
692         _ListViewImpl* pImpl = new (std::nothrow) _ListViewImpl(pControl, pCore);
693
694         r = CheckConstruction(pCore, pImpl);
695         SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), null, r, "[%s] Propagating.", GetErrorMessage(GetLastResult()));
696
697         pImpl->__pPropagatedTouchEventListener = new (std::nothrow) _ListViewPropagatedTouchEventListener(*pImpl);
698
699         if (pImpl->__pPropagatedTouchEventListener != null)
700         {
701                 pCore->SetPropagatedTouchEventListener(pImpl->__pPropagatedTouchEventListener);
702         }
703
704         return pImpl;
705 }
706
707 result
708 _ListViewImpl::SetItemProvider(IListViewItemProvider& provider)
709 {
710         result r = E_SUCCESS;
711
712         _ListViewItemProviderAdaptor* pProviderAdaptor =
713                         static_cast <_ListViewItemProviderAdaptor*>(GetCore().GetItemProviderAdaptor());
714
715         if (pProviderAdaptor != null)
716         {
717                 IListViewItemProvider* pProvider = pProviderAdaptor->GetItemProvider();
718                 if (&provider == pProvider)
719                 {
720                         return r;
721                 }
722         }
723
724         if (pProviderAdaptor == null)
725         {
726                 pProviderAdaptor = new (std::nothrow) _ListViewItemProviderAdaptor(provider);
727                 SysTryReturn(NID_UI_CTRL, (pProviderAdaptor != null), E_OUT_OF_MEMORY, E_OUT_OF_MEMORY,
728                                 "[E_OUT_OF_MEMORY] The memory is insufficient.");
729
730                 pProviderAdaptor->SetListViewItemEventListener(*this);
731
732                 r = pProviderAdaptor->SetListWidth(GetBoundsF().width);
733                 GetCore().SetItemProviderAdaptor(pProviderAdaptor);
734         }
735         else
736         {
737                 pProviderAdaptor->SetItemProvider(provider);
738                 r = pProviderAdaptor->SetListWidth(GetBoundsF().width);
739
740                 UpdateList();
741         }
742
743         __redrawListView = true;
744
745         SetLastResultReturn(r);
746 }
747
748 result
749 _ListViewImpl::SetItemProvider(IListViewItemProviderF& provider)
750 {
751         // hmkim
752         result r = E_SUCCESS;
753
754         _ListViewItemProviderAdaptor* pProviderAdaptor =
755                         static_cast <_ListViewItemProviderAdaptor*>(GetCore().GetItemProviderAdaptor());
756
757         if (pProviderAdaptor != null)
758         {
759                 IListViewItemProviderF* pProvider = pProviderAdaptor->GetItemProviderF();
760                 if (&provider == pProvider)
761                 {
762                         return r;
763                 }
764         }
765
766         if (pProviderAdaptor == null)
767         {
768                 pProviderAdaptor = new (std::nothrow) _ListViewItemProviderAdaptor(provider);
769                 SysTryReturn(NID_UI_CTRL, (pProviderAdaptor != null), E_OUT_OF_MEMORY, E_OUT_OF_MEMORY,
770                                         "[E_OUT_OF_MEMORY] The memory is insufficient.");
771
772                 pProviderAdaptor->SetListViewItemEventListener(*this);
773
774                 r = pProviderAdaptor->SetListWidth(GetBoundsF().width);
775                 GetCore().SetItemProviderAdaptor(pProviderAdaptor);
776         }
777         else
778         {
779                 pProviderAdaptor->SetItemProvider(provider);
780                 r = pProviderAdaptor->SetListWidth(GetBoundsF().width);
781
782                 UpdateList();
783         }
784
785         __redrawListView = true;
786
787         SetLastResultReturn(r);
788
789         return E_SUCCESS;
790 }
791
792 void
793 _ListViewImpl::AddListViewItemEventListener(IListViewItemEventListener& listener)
794 {
795         result r = E_SUCCESS;
796
797         if (__pListItemEvent == null)
798         {
799                 __pListItemEvent = new (std::nothrow) _ListItemEvent();
800                 SysTryReturnVoidResult(NID_UI_CTRL, (__pListItemEvent != null), E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
801
802                 r = __pListItemEvent->Construct(GetPublic(), CLASSNAME_LISTVIEW);
803                 SysTryReturnVoidResult(NID_UI_CTRL, (r == E_SUCCESS), E_SYSTEM, "[E_SYSTEM] Unable to construct Item Event.");
804         }
805
806         __pListItemEvent->AddListener(listener);
807
808         r = GetCore().AddTableViewItemEventListener(*this);
809
810         SetLastResult(r);
811 }
812
813 void
814 _ListViewImpl::RemoveListViewItemEventListener(IListViewItemEventListener& listener)
815 {
816         result r = E_SUCCESS;
817
818         if (__pListItemEvent != null)
819         {
820                 r = __pListItemEvent->RemoveListener(listener);
821         }
822
823         SetLastResult(r);
824 }
825
826 void
827 _ListViewImpl::AddFastScrollListener(IFastScrollListener& listener)
828 {
829         result r = E_SUCCESS;
830
831         if (__pFastScrollEvent == null)
832         {
833                 __pFastScrollEvent = new (std::nothrow) _FastScrollEvent();
834                 SysTryReturnVoidResult(NID_UI_CTRL, (__pFastScrollEvent != null), E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
835
836                 r = __pFastScrollEvent->Construct(GetPublic());
837                 SysTryReturnVoidResult(NID_UI_CTRL, (r == E_SUCCESS), E_SYSTEM, "[E_SYSTEM] Unable to construct FastScroll Event.");
838         }
839
840         __pFastScrollEvent->AddListener(listener);
841
842         r = GetCore().AddFastScrollListener(*this);
843
844         SetLastResult(r);
845 }
846
847 void
848 _ListViewImpl::RemoveFastScrollListener(IFastScrollListener& listener)
849 {
850         result r = E_SUCCESS;
851
852         if (__pFastScrollEvent != null)
853         {
854                 r = __pFastScrollEvent->RemoveListener(listener);
855         }
856
857         SetLastResult(r);
858 }
859
860 void
861 _ListViewImpl::AddScrollEventListener(IScrollEventListener& listener)
862 {
863         result r = E_SUCCESS;
864
865         if (__pScrollEvent == null)
866         {
867                 __pScrollEvent = new (std::nothrow) _ScrollEvent();
868                 SysTryReturnVoidResult(NID_UI_CTRL, (__pScrollEvent != null), E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
869
870                 r = __pScrollEvent->Construct(GetPublic());
871                 SysTryReturnVoidResult(NID_UI_CTRL, (r == E_SUCCESS), E_SYSTEM, "[E_SYSTEM] Unable to construct Scroll Event.");
872         }
873
874         __pScrollEvent->AddListener(listener);
875
876         GetCore().AddScrollEventListener(*this);
877
878         SetLastResult(r);
879 }
880
881 void
882 _ListViewImpl::AddScrollEventListener(IScrollEventListenerF& listener)
883 {
884         result r = E_SUCCESS;
885
886         if (__pScrollEvent == null)
887         {
888                 __pScrollEvent = new (std::nothrow) _ScrollEvent();
889                 SysTryReturnVoidResult(NID_UI_CTRL, (__pScrollEvent != null), E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
890
891                 r = __pScrollEvent->Construct(GetPublic());
892                 SysTryReturnVoidResult(NID_UI_CTRL, (r == E_SUCCESS), E_SYSTEM, "[E_SYSTEM] Unable to construct Scroll Event.");
893         }
894
895         __pScrollEvent->AddListener(listener);
896
897         GetCore().AddScrollEventListener(*this);
898
899         SetLastResult(r);
900 }
901
902 void
903 _ListViewImpl::RemoveScrollEventListener(IScrollEventListener& listener)
904 {
905         result r = E_SUCCESS;
906
907         if (__pScrollEvent != null)
908         {
909                 r = __pScrollEvent->RemoveListener(listener);
910         }
911
912         SetLastResult(r);
913 }
914
915 void
916 _ListViewImpl::RemoveScrollEventListener(IScrollEventListenerF& listener)
917 {
918         result r = E_SUCCESS;
919
920         if (__pScrollEvent != null)
921         {
922                 r = __pScrollEvent->RemoveListener(listener);
923         }
924
925         SetLastResult(r);
926 }
927
928 void
929 _ListViewImpl::AddUiLinkEventListener(const IUiLinkEventListener& listener)
930 {
931         result r = E_SUCCESS;
932
933         if (__pLinkEvent == null)
934         {
935                 __pLinkEvent = _PublicLinkEvent::CreateInstanceN(GetPublic());
936                 SysTryReturnVoidResult(NID_UI_CTRL, (__pLinkEvent != null), E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
937         }
938
939         r = __pLinkEvent->AddListener(listener);
940
941         SetLastResult(r);
942 }
943
944
945 void
946 _ListViewImpl::RemoveUiLinkEventListener(const IUiLinkEventListener& listener)
947 {
948         result r = E_SUCCESS;
949
950         if (__pLinkEvent != null)
951         {
952                 r = __pLinkEvent->RemoveListener(listener);
953         }
954
955         SetLastResult(r);
956 }
957
958 result
959 _ListViewImpl::SetSweepEnabled(bool enable)
960 {
961         GetCore().SetSweepEnabled(enable);
962
963         SetLastResultReturn(E_SUCCESS);
964 }
965
966 result
967 _ListViewImpl::SetFastScrollIndex(const String& text, bool useSearchIcon)
968 {
969         result r = GetCore().SetFastScrollIndex(text, useSearchIcon);
970         SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS) || (r == E_SYSTEM), E_INVALID_STATE, E_INVALID_STATE,
971                         "[E_INVALID_STATE] This instance is in an invalid state.");
972
973         SetLastResultReturn(r);
974 }
975
976 int
977 _ListViewImpl::GetTopDrawnItemIndex(void) const
978 {
979         int groupIndex = -1;
980         int itemIndex = -1;
981
982         GetCore().GetTopDrawnItemIndex(groupIndex, itemIndex);
983
984         return itemIndex;
985 }
986
987 int
988 _ListViewImpl::GetBottomDrawnItemIndex(void) const
989 {
990         int groupIndex = -1;
991         int itemIndex = -1;
992
993         GetCore().GetBottomDrawnItemIndex(groupIndex, itemIndex);
994
995         return itemIndex;
996 }
997
998 result
999 _ListViewImpl::ScrollToItem(int index, ListScrollItemAlignment itemAlignment)
1000 {
1001         result r = E_SUCCESS;
1002
1003         if (itemAlignment == LIST_SCROLL_ITEM_ALIGNMENT_TOP)
1004         {
1005                 r = GetCore().SetTopDrawnItemIndex(0, index);
1006         }
1007         else if (itemAlignment == LIST_SCROLL_ITEM_ALIGNMENT_BOTTOM)
1008         {
1009                 r = GetCore().SetBottomDrawnItemIndex(0, index);
1010         }
1011         else
1012         {
1013                 SysTryReturn(NID_UI_CTRL, false, E_OUT_OF_RANGE, E_OUT_OF_RANGE,
1014                                 "[E_OUT_OF_RANGE] The specified itemAlignment is out of range.");
1015         }
1016
1017         SetLastResultReturn(r);
1018 }
1019
1020 result
1021 _ListViewImpl::SetItemChecked(int index, bool check)
1022 {
1023         return GetCore().SetItemChecked(0, index, check);
1024 }
1025
1026 bool
1027 _ListViewImpl::IsItemChecked(int index) const
1028 {
1029         return GetCore().IsItemChecked(0, index);
1030 }
1031
1032 result
1033 _ListViewImpl::SetItemEnabled(int index, bool enable)
1034 {
1035         return GetCore().SetItemEnabled(0, index, enable);
1036 }
1037
1038 bool
1039 _ListViewImpl::IsItemEnabled(int index) const
1040 {
1041         return GetCore().IsItemEnabled(0, index);
1042 }
1043
1044 int
1045 _ListViewImpl::GetItemCount(void) const
1046 {
1047         return GetCore().GetItemCountAt(0);
1048 }
1049
1050 result
1051 _ListViewImpl::ShowItemDescriptionText(int index)
1052 {
1053         return SetItemDescriptionTextShowState(index, true);
1054 }
1055
1056 result
1057 _ListViewImpl::HideItemDescriptionText(int index)
1058 {
1059         return SetItemDescriptionTextShowState(index, false);
1060 }
1061
1062 result
1063 _ListViewImpl::SetItemDescriptionTextShowState(int index, bool show)
1064 {
1065         result r = E_SUCCESS;
1066
1067         SysTryReturn(NID_UI_CTRL, (index >= 0) && (index < GetItemCount()), E_OUT_OF_RANGE, E_OUT_OF_RANGE,
1068                         "[E_OUT_OF_RANGE] The specified index is out of range.");
1069
1070         _ListViewItemProviderAdaptor* pProviderAdaptor =
1071                         static_cast <_ListViewItemProviderAdaptor*>(GetCore().GetItemProviderAdaptor());
1072         SysTryReturn(NID_UI_CTRL, (pProviderAdaptor != null), E_SYSTEM, E_SYSTEM, "[E_SYSTEM] _ListItemProviderAdaptor is not set.");
1073
1074         // Save description text show state to provider adaptor
1075         pProviderAdaptor->SetDescriptionTextShowState(index, show);
1076
1077         if (GetCore().FindItem(0, index) != null)
1078         {
1079                 r = GetCore().RefreshTableView(0, index, TABLE_VIEW_REFRESH_TYPE_ITEM_MODIFY);
1080         }
1081
1082         SetLastResultReturn(r);
1083 }
1084
1085 result
1086 _ListViewImpl::RefreshList(int index, ListRefreshType type)
1087 {
1088         result r = E_SUCCESS;
1089
1090         if (__needReloadItems)
1091         {
1092                 return r;
1093         }
1094
1095         int itemCount = GetCore().GetItemCountAt(0);
1096
1097         if ((index < 0) || (index > itemCount) || ((type != LIST_REFRESH_TYPE_ITEM_ADD) && (index == itemCount)))
1098         {
1099                 SysLogException(NID_UI_CTRL, E_OUT_OF_RANGE, "[E_OUT_OF_RANGE] The index is out of range.");
1100                 return E_OUT_OF_RANGE;
1101         }
1102
1103         if (type == LIST_REFRESH_TYPE_ITEM_MODIFY)
1104         {
1105                 if (IsContextItemOpened(index))
1106                 {
1107                         CloseContextItem(index);
1108                 }
1109
1110                 int topGroupIndex = -1;
1111                 int topItemIndex = -1;
1112                 int bottomGroupIndex = -1;
1113                 int bottomItemIndex = -1;
1114
1115                 GetCore().GetFirstLoadedItemIndex(topGroupIndex, topItemIndex);
1116                 GetCore().GetLastLoadedItemIndex(bottomGroupIndex, bottomItemIndex);
1117
1118                 if ((topItemIndex <= index) && (bottomItemIndex >= index))
1119                 {
1120                         _ListViewItem* pListViewItem = static_cast<_ListViewItem*>(GetCore().FindItem(0, index));
1121                         _ListViewItemStatus itemStatus;
1122                         memset(&itemStatus, 0, sizeof(_ListViewItemStatus));
1123                         bool needChangeEventTarget = false;
1124
1125                         if (pListViewItem != null && pListViewItem->IsItemSelected())
1126                         {
1127                                 needChangeEventTarget = true;
1128                         }
1129
1130                         if (needChangeEventTarget && (pListViewItem != null))
1131                         {
1132                                 pListViewItem->GetCurrentStatus(itemStatus);
1133                                 pListViewItem = null;
1134                         }
1135
1136                         // item unload
1137                         GetCore().UnloadItem(0, index);
1138                         // item load
1139                         pListViewItem = static_cast<_ListViewItem*>(GetCore().LoadItem(0, index));
1140
1141                         if (needChangeEventTarget && (pListViewItem != null))
1142                         {
1143                                 pListViewItem->SetCurrentStatus(itemStatus);
1144
1145                                 _Control* pTarget = static_cast<_Control*>(pListViewItem);
1146
1147                                 for (int i = 0; i < pListViewItem->GetChildCount(); i++)
1148                                 {
1149                                         if (pListViewItem->GetChild(i)->GetBoundsF().Contains(itemStatus.currentTouchPosition))
1150                                         {
1151                                                 pTarget = pListViewItem->GetChild(i);
1152                                         }
1153                                 }
1154
1155                                 // change touch event target
1156                                 pTarget->SetChangingEventTarget(true);
1157                                 _TouchManager::GetInstance()->SetChangedTouchableTarget(pTarget);
1158                         }
1159                 }
1160                 else
1161                 {
1162                         // not yet loaded item
1163                         SetLastResultReturn(r);
1164                 }
1165         }
1166         else
1167         {
1168                 r = GetCore().RefreshTableView(0, index, static_cast<TableViewRefreshType>(type));
1169         }
1170
1171         CheckEmptyListShowState();
1172
1173         Draw();
1174         Show();
1175
1176         SetLastResultReturn(r);
1177 }
1178
1179 result
1180 _ListViewImpl::RefreshList(int index, int elementId)
1181 {
1182         if ((index < 0) || (index >= GetCore().GetItemCountAt(0)))
1183         {
1184                 return E_OUT_OF_RANGE;
1185         }
1186
1187         result r = E_SUCCESS;
1188         _ListViewItem* pListViewItem = static_cast<_ListViewItem*>(GetCore().FindItem(0, index));
1189
1190         if (pListViewItem != null)
1191         {
1192                 r = (pListViewItem->RefreshElement(elementId)) ? E_SUCCESS : E_OUT_OF_RANGE;
1193         }
1194
1195         SetLastResultReturn(r);
1196 }
1197
1198 result
1199 _ListViewImpl::UpdateList(void)
1200 {
1201         __needReloadItems = true;
1202
1203         result r = GetCore().UpdateTableView();
1204
1205         CheckEmptyListShowState();
1206
1207         Invalidate(true);
1208
1209         // API versioning for initial Show() operation
1210         if (Tizen::App::_AppInfo::GetApiVersion() == _API_VERSION_2_0 && Tizen::App::_AppInfo::IsOspCompat())
1211         {
1212                 Show();
1213         }
1214
1215         __needReloadItems = false;
1216
1217         SetLastResultReturn(r);
1218 }
1219
1220 void
1221 _ListViewImpl::SetItemNeedsLazyDeletion(_ListViewItem* pItem)
1222 {
1223         _ListViewItemProviderAdaptor* pProviderAdaptor = static_cast <_ListViewItemProviderAdaptor*>(GetCore().GetItemProviderAdaptor());
1224
1225         if (pProviderAdaptor != null)
1226         {
1227                 pProviderAdaptor->SetItemNeedsLazyDeletion(pItem);
1228         }
1229 }
1230
1231 int
1232 _ListViewImpl::GetItemIndexFromPosition(const FloatPoint& position) const
1233 {
1234         int groupIndex = -1;
1235         int itemIndex = -1;
1236
1237         GetCore().GetItemIndexFromPosition(position, groupIndex, itemIndex);
1238
1239         return itemIndex;
1240 }
1241
1242 result
1243 _ListViewImpl::GetItemIndexFromPosition(const FloatPoint& position, int& itemIndex, int& elementId) const
1244 {
1245         int groupIndex = -1;
1246         elementId = -1;
1247
1248         result r =  GetCore().GetItemIndexFromPosition(position, groupIndex, itemIndex);
1249         SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), E_SYSTEM, E_SYSTEM, "[E_SYSTEM] There is no item at the specified position.");
1250
1251         _ListViewItem* pListViewItem = static_cast<_ListViewItem*>(GetCore().FindItem(0, itemIndex));
1252
1253         if (pListViewItem != null)
1254         {
1255                 FloatPoint originPosition = pListViewItem->GetPositionF();
1256                 originPosition.y -= GetCore().GetScrollPosition();
1257
1258                 elementId = pListViewItem->GetElementIdFromPosition(FloatPoint(position.x - originPosition.x, position.y - originPosition.y));
1259         }
1260
1261         SetLastResultReturn(r);
1262 }
1263
1264 result
1265 _ListViewImpl::SetItemDividerColor(const Color& color)
1266 {
1267         return GetCore().SetItemDividerColor(color);
1268 }
1269
1270 Color
1271 _ListViewImpl::GetItemDividerColor(void) const
1272 {
1273         return GetCore().GetItemDividerColor();
1274 }
1275
1276 void
1277 _ListViewImpl::AdjustLayoutOfEmptyList(void)
1278 {
1279         FloatDimension listDimension = GetCore().GetSizeF();
1280         FloatDimension emptyBitmap;
1281         FloatDimension emptyText;
1282         FloatPoint bitmapPos;
1283         FloatPoint textPos;
1284         float totalHeight = 0.0f;
1285         float horizontalSpacing = 0.0f;
1286
1287         if (__pEmptyBitmap != null)
1288         {
1289                 emptyBitmap = __pEmptyBitmap->GetSizeF();
1290         }
1291
1292         if (__pEmptyText != null)
1293         {
1294                 emptyText = __pEmptyText->GetSizeF();
1295
1296                 if (__pEmptyBitmap != null)
1297                 {
1298                         GET_SHAPE_CONFIG(LISTVIEW::EMPTY_LIST_HORIZONTAL_SPACING, _CONTROL_ORIENTATION_PORTRAIT, horizontalSpacing);
1299                 }
1300         }
1301
1302         totalHeight = emptyBitmap.height + horizontalSpacing + emptyText.height;
1303
1304         if ((__pEmptyBitmap != null) && (__pEmptyText != null) && (totalHeight < listDimension.height))
1305         {
1306                 bitmapPos.x = ((_FloatCompare(listDimension.width, emptyBitmap.width)) ? 0.0f : (listDimension.width - emptyBitmap.width) / 2.0f);
1307                 bitmapPos.y = (listDimension.height - totalHeight) / 2.0f;
1308
1309                 textPos.x = ((_FloatCompare(listDimension.width, emptyText.width)) ? 0.0f : (listDimension.width - emptyText.width) / 2.0f);
1310                 textPos.y = bitmapPos.y + emptyBitmap.height + horizontalSpacing;
1311         }
1312         else
1313         {
1314                 if (__pEmptyBitmap != null)
1315                 {
1316                         bitmapPos.x = ((_FloatCompare(listDimension.width, emptyBitmap.width)) ? 0.0f : (listDimension.width - emptyBitmap.width) / 2.0f);
1317                         bitmapPos.y = ((listDimension.height <= totalHeight) ? 0.0f : (listDimension.height - totalHeight) / 2.0f);
1318                 }
1319
1320                 if (__pEmptyText != null)
1321                 {
1322                         textPos.x = ((_FloatCompare(listDimension.width, emptyText.width)) ? 0.0f : (listDimension.width - emptyText.width) / 2.0f);
1323                         textPos.y = ((listDimension.height <= totalHeight ) ? (bitmapPos.y + emptyBitmap.height + horizontalSpacing) : (listDimension.height - totalHeight) / 2.0f);
1324                 }
1325         }
1326
1327         if (__pEmptyBitmap != null)
1328         {
1329                 __pEmptyBitmap->SetPosition(bitmapPos);
1330         }
1331         if (__pEmptyText != null)
1332         {
1333                 __pEmptyText->SetPosition(textPos);
1334         }
1335
1336         CheckEmptyListShowState();
1337         Invalidate(true);
1338 }
1339
1340 void
1341 _ListViewImpl::CheckEmptyListShowState(void)
1342 {
1343         bool isEmpty = (GetItemCount() <= 0);
1344
1345         if (__pEmptyBitmap != null)
1346         {
1347                 __pEmptyBitmap->SetVisibleState(isEmpty);
1348         }
1349         if (__pEmptyText != null)
1350         {
1351                 __pEmptyText->SetVisibleState(isEmpty);
1352         }
1353
1354         _AccessibilityContainer* pContainer = GetCore().GetAccessibilityContainer();
1355
1356         if (_AccessibilityManager::IsActivated() && (pContainer != null))
1357         {
1358                 if (isEmpty)
1359                 {
1360                         if (__pAccessibilityElement == null)
1361                         {
1362                                 __pAccessibilityElement = new (std::nothrow) _AccessibilityElement(true);
1363
1364                                 SysTryReturnVoidResult(NID_UI_CTRL, (__pAccessibilityElement != null), E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
1365
1366                                 __pAccessibilityElement->SetName(L"ListView");
1367
1368                                 pContainer->RemoveAllElement();
1369                                 pContainer->AddElement(*__pAccessibilityElement);
1370                         }
1371
1372                         Rectangle bounds = GetBounds();
1373                         __pAccessibilityElement->SetBounds(Rectangle(0, 0, bounds.width, bounds.height));
1374
1375                         String accessibilityLable;
1376
1377                         if (__pEmptyBitmap != null)
1378                         {
1379                                 __pEmptyBitmap->GetAccessibilityContainer()->Activate(false);
1380
1381                                 accessibilityLable += L"Image, ";
1382                         }
1383                         if (__pEmptyText != null)
1384                         {
1385                                 __pEmptyText->GetAccessibilityContainer()->Activate(false);
1386
1387                                 accessibilityLable += __pEmptyText->GetText();
1388                                 accessibilityLable += L", ";
1389                         }
1390
1391                         accessibilityLable += L"No items";
1392
1393                         __pAccessibilityElement->SetLabel(accessibilityLable);
1394                 }
1395                 else
1396                 {
1397                         if (__pAccessibilityElement != null)
1398                         {
1399                                 if (pContainer->RemoveElement(*__pAccessibilityElement) != E_SUCCESS)
1400                                 {
1401                                         delete __pAccessibilityElement;
1402                                 }
1403                                 __pAccessibilityElement = null;
1404                         }
1405                 }
1406         }
1407 }
1408
1409 result
1410 _ListViewImpl::SetBitmapOfEmptyList(const Bitmap* pBitmap)
1411 {
1412         if (pBitmap == null)
1413         {
1414                 if (__pEmptyBitmap != null)
1415                 {
1416                         GetCore().DetachChild(*__pEmptyBitmap);
1417
1418                         delete __pEmptyBitmap;
1419                         __pEmptyBitmap = null;
1420                 }
1421         }
1422         else
1423         {
1424                 if (__pEmptyBitmap == null)
1425                 {
1426                         __pEmptyBitmap = _Label::CreateLabelN();
1427                         SysTryReturn(NID_UI_CTRL, (__pEmptyBitmap != null), E_SYSTEM, E_SYSTEM, "[%s] Propagating.", GetErrorMessage(GetLastResult()));
1428
1429                         __pEmptyBitmap->SetVisibleState(false);
1430                         __pEmptyBitmap->SetMargin(0.0f, 0.0f);
1431
1432                         GetCore().AttachChild(*__pEmptyBitmap);
1433                 }
1434
1435                 __pEmptyBitmap->SetSize(FloatDimension(pBitmap->GetWidthF(), pBitmap->GetHeightF()));
1436                 __pEmptyBitmap->SetBackgroundColor(Color(0, 0, 0, 0));
1437                 __pEmptyBitmap->SetBackgroundBitmap(*pBitmap);
1438         }
1439
1440         AdjustLayoutOfEmptyList();
1441
1442         SetLastResultReturn(E_SUCCESS);
1443 }
1444
1445 result
1446 _ListViewImpl::SetTextOfEmptyList(const String& text)
1447 {
1448         if (text.IsEmpty())
1449         {
1450                 if (__pEmptyText != null)
1451                 {
1452                         GetCore().DetachChild(*__pEmptyText);
1453
1454                         delete __pEmptyText;
1455                         __pEmptyText = null;
1456                 }
1457         }
1458         else
1459         {
1460                 if (__pEmptyText == null)
1461                 {
1462                         __pEmptyText = _Label::CreateLabelN();
1463                         SysTryReturn(NID_UI_CTRL, (__pEmptyText != null), E_SYSTEM, E_SYSTEM, "[%s] Propagating.", GetErrorMessage(GetLastResult()));
1464
1465                         __pEmptyText->SetVisibleState(false);
1466                         __pEmptyText->SetMargin(0.0f, 0.0f);
1467
1468                         GetCore().AttachChild(*__pEmptyText);
1469                 }
1470
1471                 TextObject* pText = new (std::nothrow) TextObject;
1472                 SysTryReturn(NID_UI_CTRL, (pText != null), E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Propagating.", GetErrorMessage(GetLastResult()));
1473
1474                 pText->Construct();
1475
1476                 TextSimple* pSimpleText = new (std::nothrow) TextSimple(const_cast <wchar_t*>(text.GetPointer()), text.GetLength());
1477                 SysTryReturn(NID_UI_CTRL, (pSimpleText != null), E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Propagating.", GetErrorMessage(GetLastResult()));
1478
1479                 pText->AppendElement(*pSimpleText);
1480
1481                 float textSize = 0.0f;
1482                 GET_SHAPE_CONFIG(LISTVIEW::EMPTY_LIST_TEXT_HEIGHT, _CONTROL_ORIENTATION_PORTRAIT, textSize);
1483
1484                 Font font;
1485                 font.Construct(GetFont(), FONT_STYLE_PLAIN, textSize);
1486                 pText->SetFont(&font, 0, pText->GetTextLength());
1487
1488                 FloatDimension listDimension = GetCore().GetSizeF();
1489
1490                 pText->SetBounds(FloatRectangle(0.0f, 0.0f, listDimension.width, 1.0f));
1491                 pText->Compose();
1492
1493                 FloatDimension labelDimension = pText->GetTextExtentF(0, pText->GetTextLength());
1494                 labelDimension.height = pText->GetTotalHeightF();
1495
1496                 if (labelDimension.width > listDimension.width)
1497                 {
1498                         pText->SetBounds(FloatRectangle(0.0f, 0.0f, listDimension.width, 1.0f));
1499                         pText->Compose();
1500
1501                         float labelHeight = pText->GetTotalHeightF();
1502
1503                         labelDimension.width = listDimension.width;
1504                         labelDimension.height = ((listDimension.height < labelHeight) ? listDimension.height : labelHeight);
1505                 }
1506
1507                 delete pText;
1508
1509                 __pEmptyText->SetSize(labelDimension);
1510                 __pEmptyText->SetBackgroundColor(Color(0, 0, 0, 0));
1511                 __pEmptyText->SetMargin(0.0f, 0.0f, 0.0f, 0.0f);
1512                 __pEmptyText->SetTextColor(__emptyTextColor);
1513                 __pEmptyText->SetTextConfig(textSize, LABEL_TEXT_STYLE_NORMAL);
1514                 __pEmptyText->SetText(text);
1515         }
1516
1517         AdjustLayoutOfEmptyList();
1518
1519         SetLastResultReturn(E_SUCCESS);
1520 }
1521
1522 String
1523 _ListViewImpl::GetTextOfEmptyList(void) const
1524 {
1525         return ((__pEmptyText != null) ? __pEmptyText->GetText() : String());
1526 }
1527
1528 result
1529 _ListViewImpl::SetTextColorOfEmptyList(const Color& color)
1530 {
1531         __emptyTextColor = color;
1532
1533         if (__pEmptyText != null)
1534         {
1535                 __pEmptyText->SetTextColor(color);
1536         }
1537
1538         SetLastResultReturn(E_SUCCESS);
1539 }
1540
1541 Color
1542 _ListViewImpl::GetTextColorOfEmptyList(void) const
1543 {
1544         return __emptyTextColor;
1545 }
1546
1547 result
1548 _ListViewImpl::SetListBackgroundColor(const Color& color)
1549 {
1550         SetBackgroundColor(color);
1551
1552         SetLastResultReturn(E_SUCCESS);
1553 }
1554
1555 result
1556 _ListViewImpl::SetBackgroundBitmap(const Bitmap* pBitmap)
1557 {
1558         GetCore().SetBackgroundBitmap(const_cast<Bitmap*>(pBitmap));
1559         GetCore().SetBackgroundBitmapStretch(true);
1560
1561         SetLastResultReturn(E_SUCCESS);
1562 }
1563
1564 result
1565 _ListViewImpl::BeginReorderingMode(void)
1566 {
1567         result r = GetCore().SetReorderModeEnabled(true);
1568
1569         SetLastResultReturn(r);
1570 }
1571
1572 result
1573 _ListViewImpl::EndReorderingMode(void)
1574 {
1575         result r = GetCore().SetReorderModeEnabled(false);
1576
1577         SetLastResultReturn(r);
1578 }
1579
1580 bool
1581 _ListViewImpl::IsInReorderingMode(void) const
1582 {
1583         return GetCore().IsReorderModeEnabled();
1584 }
1585
1586 void
1587 _ListViewImpl::SetScrollInputMode(ScrollInputMode mode)
1588 {
1589         GetCore().SetScrollInputMode(mode);
1590 }
1591
1592 ScrollInputMode
1593 _ListViewImpl::GetScrollInputMode(void) const
1594 {
1595         return GetCore().GetScrollInputMode();
1596 }
1597
1598 result
1599 _ListViewImpl::OpenContextItem(int itemIndex)
1600 {
1601         return GetCore().OpenContextItem(0, itemIndex);
1602 }
1603
1604 result
1605 _ListViewImpl::CloseContextItem(int itemIndex)
1606 {
1607         return GetCore().CloseContextItem(0, itemIndex);
1608 }
1609
1610 bool
1611 _ListViewImpl::IsContextItemOpened(int itemIndex) const
1612 {
1613         return GetCore().IsContextItemOpened(0, itemIndex);
1614 }
1615
1616 void
1617 _ListViewImpl::OnListViewContextItemStateChanged(_Control& source, int groupIndex, int itemIndex, int elementId,
1618                 ListContextItemStatus status)
1619 {
1620         if (__pListItemEvent != null)
1621         {
1622                 CloseContextItem(itemIndex);
1623
1624                 _ListViewItem* pListViewItem = static_cast<_ListViewItem*>(GetCore().FindItem(0, itemIndex));
1625
1626                 SetItemNeedsLazyDeletion(pListViewItem);
1627
1628                 _ListItemEventArg* pArg = new (std::nothrow) _ListItemEventArg(itemIndex, elementId, 0, 0, NOTIFY_TYPE_SELCTED_CONTEXT_ITEM);
1629                 __pListItemEvent->Fire(*pArg);
1630
1631                 SetItemNeedsLazyDeletion(null);
1632         }
1633 }
1634
1635 void
1636 _ListViewImpl::OnTableViewItemStateChanged(_TableView& tableView, int itemIndex, _TableViewItem* pItem, TableViewItemStatus status)
1637 {
1638         if (__pListItemEvent != null)
1639         {
1640                 _ListViewItem* pListViewItem = static_cast<_ListViewItem*>(pItem);
1641
1642                 if (pListViewItem != null)
1643                 {
1644                         SetItemNeedsLazyDeletion(pListViewItem);
1645
1646                         _ListViewItemStateChangedInfo itemInfo;
1647                         pListViewItem->GetLastStateChangedInfo(itemInfo);
1648
1649                         if ((__pLinkEvent != null) && (itemInfo.pUiLinkInfo != null))
1650                         {
1651                                 IEventArg* pLinkEventArg = _PublicLinkEvent::CreateLinkEventArgN(itemInfo.pUiLinkInfo->textInfo,
1652                                                 itemInfo.pUiLinkInfo->linkType, itemInfo.pUiLinkInfo->linkInfo);
1653
1654                                 SysTryReturnVoidResult(NID_UI_CTRL, (pLinkEventArg != null), E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Unable to create _LinkEventArg.");
1655                                 __pLinkEvent->Fire(*pLinkEventArg);
1656
1657                         }
1658                         else
1659                         {
1660                                 _ListItemEventArg* pArg = new (std::nothrow) _ListItemEventArg(itemIndex, itemInfo.elementId, 0, 0, static_cast<NotifyType>(status));
1661                                 __pListItemEvent->Fire(*pArg);
1662                         }
1663
1664                         pListViewItem->ClearLastStateChangedInfo();
1665
1666                         SetItemNeedsLazyDeletion(null);
1667                 }
1668         }
1669 }
1670
1671 void
1672 _ListViewImpl::OnTableViewContextItemActivationStateChanged(_TableView& tableView, int itemIndex, _TableViewItem* pContextItem, bool activated)
1673 {
1674         _ListViewItem* pListViewItem = static_cast<_ListViewItem*>(GetCore().FindItem(0, itemIndex));
1675
1676         if (pListViewItem != null)
1677         {
1678                 pListViewItem->SetContextItemActivationState(activated);
1679         }
1680 }
1681
1682 void
1683 _ListViewImpl::OnTableViewItemReordered(_TableView& tableView, int itemIndexFrom, int itemIndexTo)
1684 {
1685         if (__pListItemEvent != null)
1686         {
1687                 _ListItemEventArg* pArg = new (std::nothrow) _ListItemEventArg(itemIndexFrom, itemIndexTo, 0, 0, NOTIFY_TYPE_REORDERED_ITEM);
1688                 __pListItemEvent->Fire(*pArg);
1689         }
1690 }
1691
1692 void
1693 _ListViewImpl::OnTableViewItemSwept(_TableView& tableView, int groupIndex, int itemIndex, TableViewSweepDirection direction)
1694 {
1695         if (__pListItemEvent != null)
1696         {
1697                 _ListViewItem* pListViewItem = static_cast<_ListViewItem*>(GetCore().FindItem(0, itemIndex));
1698
1699                 SetItemNeedsLazyDeletion(pListViewItem);
1700
1701                 _ListItemEventArg* pArg = new (std::nothrow) _ListItemEventArg(itemIndex, direction, 0, 0, NOTIFY_TYPE_SWEPT_ITEM);
1702                 __pListItemEvent->Fire(*pArg);
1703
1704                 SetItemNeedsLazyDeletion(null);
1705         }
1706 }
1707
1708 void
1709 _ListViewImpl::OnScrollEndReached(_Control& source, ScrollEndEvent type)
1710 {
1711         if (__pScrollEvent != null)
1712         {
1713                 _ScrollEventArg* pEventArg = _ScrollEventArg::GetScrollEventArgN(GetPublic(), type);
1714                 result r = GetLastResult();
1715                 SysTryReturnVoidResult(NID_UI_CTRL, (r == E_SUCCESS), r, "[%s] Propagating.", GetErrorMessage(r));
1716
1717                 __pScrollEvent->Fire(*pEventArg);
1718         }
1719 }
1720
1721 void
1722 _ListViewImpl::OnScrollPositionChanged(_Control& source, float scrollPosition)
1723 {
1724         if (__pScrollEvent != null)
1725         {
1726                 _ScrollEventArg* pEventArg = _ScrollEventArg::GetScrollEventArgN(GetPublic(), scrollPosition);
1727                 result r = GetLastResult();
1728                 SysTryReturnVoidResult(NID_UI_CTRL, (pEventArg != null), r, "[%s] Propagating.", GetErrorMessage(r));
1729
1730                 __pScrollEvent->Fire(*pEventArg);
1731         }
1732 }
1733
1734 void
1735 _ListViewImpl::OnScrollStopped(_Control& source)
1736 {
1737         if (__pScrollEvent != null)
1738         {
1739                 _ScrollEventArg* pEventArg = _ScrollEventArg::GetScrollEventArgN(GetPublic());
1740                 result r = GetLastResult();
1741                 SysTryReturnVoidResult(NID_UI_CTRL, (r == E_SUCCESS), r, "[%s] Propagating.", GetErrorMessage(r));
1742
1743                 __pScrollEvent->Fire(*pEventArg);
1744         }
1745 }
1746
1747 void
1748 _ListViewImpl::OnUiFastScrollIndexSelected(_Control& source, _FastScrollIndex& index)
1749 {
1750         if (__pFastScrollEvent != null)
1751         {
1752                 String* pIndexText = index.GetIndexText();
1753                 if (pIndexText != null)
1754                 {
1755                         _FastScrollEventArg* pEventArg = new (std::nothrow) _FastScrollEventArg(GetPublic(), *pIndexText);
1756                         __pFastScrollEvent->Fire(*pEventArg);
1757                 }
1758         }
1759 }
1760
1761 void
1762 _ListViewImpl::OnDraw(void)
1763 {
1764         _ControlImpl::OnDraw();
1765
1766         if (__redrawListView)
1767         {
1768                 CheckEmptyListShowState();
1769                 __redrawListView = false;
1770         }
1771 }
1772
1773 void
1774 _ListViewImpl::OnChangeLayout(_ControlOrientation orientation)
1775 {
1776         __isOrientationChanged = true;
1777
1778         _ControlImpl::OnChangeLayout(orientation);
1779 }
1780
1781 void
1782 _ListViewImpl::OnBoundsChanged(void)
1783 {
1784         _ControlImpl::OnBoundsChanged();
1785
1786         if (__pEmptyBitmap != null)
1787         {
1788                 SetBitmapOfEmptyList(__pEmptyBitmap->GetBackgroundBitmap());
1789         }
1790         if (__pEmptyText != null)
1791         {
1792                 SetTextOfEmptyList(__pEmptyText->GetText());
1793         }
1794
1795         if (__isOrientationChanged)
1796         {
1797                 __isOrientationChanged = false;
1798                 UpdateList();
1799         }
1800 }
1801
1802 void
1803 _ListViewImpl::OnFontChanged(Font* pFont)
1804 {
1805         String fontName = GetFont();
1806         _ListViewItemProviderAdaptor* pProviderAdaptor = static_cast <_ListViewItemProviderAdaptor*>(GetCore().GetItemProviderAdaptor());
1807
1808         if (__pEmptyText != null)
1809         {
1810                 __pEmptyText->SetFont(fontName);
1811                 SetTextOfEmptyList(__pEmptyText->GetText());
1812         }
1813
1814         if (pProviderAdaptor != null)
1815         {
1816                 pProviderAdaptor->SetItemFont(fontName);
1817         }
1818
1819         int firstGroup = -1;
1820         int firstItem = -1;
1821         int lastGroup = -1;
1822         int lastItem = -1;
1823
1824         GetCore().GetFirstLoadedItemIndex(firstGroup, firstItem);
1825         GetCore().GetLastLoadedItemIndex(lastGroup, lastItem);
1826
1827         firstItem = ((firstItem == -1) ?  0 : firstItem);
1828
1829         for (int i = firstItem; i <= lastItem; i++)
1830         {
1831                 _ListViewItem* pListViewItem = static_cast<_ListViewItem*>(GetCore().FindItem(0, i));
1832
1833                 if (pListViewItem != null)
1834                 {
1835                         pListViewItem->SetFont(fontName);
1836                 }
1837         }
1838 }
1839
1840 void
1841 _ListViewImpl::OnFontInfoRequested(unsigned long& style, int& size)
1842 {
1843         float textSize = 0.0f;
1844         OnFontInfoRequested(style, textSize);
1845
1846         size = _CoordinateSystemUtils::ConvertToInteger(textSize);
1847 }
1848
1849 void
1850 _ListViewImpl::OnFontInfoRequested(unsigned long& style, float& size)
1851 {
1852         GET_SHAPE_CONFIG(LISTVIEW::EMPTY_LIST_TEXT_HEIGHT, _CONTROL_ORIENTATION_PORTRAIT, size);
1853         style = FONT_STYLE_PLAIN;
1854 }
1855
1856 FloatPoint
1857 _ListViewImpl::GetCurrentTouchPosition(void)
1858 {
1859         FloatPoint currentTouchPos = _TouchManager::GetInstance()->GetScreenPoint(0);
1860         FloatRectangle bounds = GetCore().GetAbsoluteBoundsF();
1861
1862         currentTouchPos.x -= bounds.x;
1863         currentTouchPos.y -= bounds.y;
1864
1865         return currentTouchPos;
1866 }
1867
1868 result
1869 _ListViewImpl::OnTouchEventListenerAdded(void)
1870 {
1871         return E_SUCCESS;
1872 }
1873
1874 result
1875 _ListViewImpl::OnTouchEventListenerRemoved(void)
1876 {
1877         return E_SUCCESS;
1878 }
1879
1880 void
1881 _ListViewImpl::FireListViewItemLongPressedEvent(void)
1882 {
1883         if (__pListItemEvent != null)
1884         {
1885                 int itemIndex = -1;
1886                 int elementId = -1;
1887
1888                 if (GetItemIndexFromPosition(GetCurrentTouchPosition(), itemIndex, elementId) == E_SUCCESS)
1889                 {
1890                         _ListViewItem* pListViewItem = static_cast<_ListViewItem*>(GetCore().FindItem(0, itemIndex));
1891
1892                         if ((pListViewItem != null) && (!pListViewItem->IsContextItem()))
1893                         {
1894                                 SetItemNeedsLazyDeletion(pListViewItem);
1895
1896                                 _ListItemEventArg* pArg = new (std::nothrow) _ListItemEventArg(itemIndex, elementId, 0, 0, NOTIFY_TYPE_LONG_PRESSED_ITEM);
1897                                 __pListItemEvent->Fire(*pArg);
1898
1899                                 SetItemNeedsLazyDeletion(null);
1900                         }
1901                 }
1902         }
1903 }
1904
1905 class _ListViewMaker
1906         : public _UiBuilderControlMaker
1907 {
1908 public:
1909         _ListViewMaker(_UiBuilder* uibuilder)
1910                 : _UiBuilderControlMaker(uibuilder){};
1911
1912         virtual ~_ListViewMaker(){};
1913
1914         static _UiBuilderControlMaker*
1915         GetInstance(_UiBuilder* uibuilder)
1916         {
1917                 _ListViewMaker* pListViewMaker = new (std::nothrow) _ListViewMaker(uibuilder);
1918                 return pListViewMaker;
1919         };
1920
1921 protected:
1922         virtual Control*
1923         Make(_UiBuilderControl* pControl)
1924         {
1925                 result r = E_SYSTEM;
1926                 _UiBuilderControlLayout* pControlProperty = null;
1927                 ListView* pListView = null;
1928                 FloatRectangle rect;
1929                 String elementString;
1930
1931                 ListScrollStyle scrollStyle = SCROLL_STYLE_FADE_OUT;
1932                 ScrollInputMode scrollInputMode = SCROLL_INPUT_MODE_ALLOW_ANY_DIRECTION;
1933
1934                 bool hasItemDivider = true;
1935                 int opacity = 100;
1936                 bool isSweepEnabled = false;
1937                 Color color;
1938
1939                 GetProperty(pControl, &pControlProperty);
1940                 if (pControlProperty == null)
1941                 {
1942                         return null;
1943                 }
1944
1945                 pListView = new (std::nothrow) ListView();
1946                 if (pListView == null)
1947                 {
1948                         return null;
1949                 }
1950
1951                 rect = pControlProperty->GetRectF();
1952
1953                 //Construct
1954                 if (pControl->GetElement(L"itemDivider", elementString))
1955                 {
1956                         if (elementString.Equals(L"true", false))
1957                         {
1958                                 hasItemDivider = true;
1959                         }
1960                         else
1961                         {
1962                                 hasItemDivider = false;
1963                         }
1964                 }
1965
1966                 if (pControl->GetElement(L"listScrollStyle", elementString))
1967                 {
1968                         if (elementString.Equals(L"SCROLL_STYLE_FIXED", false))
1969                         {
1970                                 scrollStyle = SCROLL_STYLE_FIXED;
1971                         }
1972                         else if (elementString.Equals(L"SCROLL_STYLE_FAST_SCROLL", false))
1973                         {
1974                                 scrollStyle = SCROLL_STYLE_FAST_SCROLL;
1975                         }
1976                         else if (elementString.Equals(L"SCROLL_STYLE_JUMP_TO_TOP", false))
1977                         {
1978                                 scrollStyle = SCROLL_STYLE_JUMP_TO_TOP;
1979                         }
1980                         else if (elementString.Equals(L"SCROLL_STYLE_THUMB", false))
1981                         {
1982                                 scrollStyle = SCROLL_STYLE_THUMB;
1983                         }
1984                 }
1985                 else if (pControl->GetElement(L"fastScroll", elementString))
1986                 {
1987                         if (elementString.Equals(L"true", false))
1988                         {
1989                                 scrollStyle = SCROLL_STYLE_FAST_SCROLL;
1990                         }
1991                 }
1992
1993                 r = pListView->Construct(rect, hasItemDivider, scrollStyle);
1994                 SysTryCatch(NID_UI, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r));
1995
1996                 // Set BackgroundsBitmap
1997                 if (pControl->GetElement("backgroundBitmapPath", elementString))
1998                 {
1999                         Bitmap* pBackgroundBitmap = null;
2000                         pBackgroundBitmap = LoadBitmapN(elementString);
2001                         if (pBackgroundBitmap != null)
2002                         {
2003                                 r = pListView->SetBackgroundBitmap(pBackgroundBitmap);
2004                                 delete pBackgroundBitmap;
2005                                 pBackgroundBitmap = null;
2006
2007                                 SysTryCatch(NID_UI, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r));
2008                         }
2009                 }
2010
2011                 // Set Empty List
2012                 if (pControl->GetElement(L"textOfEmptyList", elementString))
2013                 {
2014                         r = pListView->SetTextOfEmptyList(elementString);
2015                         SysTryCatch(NID_UI, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r));
2016                 }
2017
2018                 if (pControl->GetElement(L"colorOfEmptyListText", elementString))
2019                 {
2020                         ConvertStringToColor(elementString, color);
2021                         r = pListView->SetTextColorOfEmptyList(color);
2022                         SysTryCatch(NID_UI, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r));
2023                 }
2024
2025                 if (pControl->GetElement(L"bitmapPathOfEmptyList", elementString))
2026                 {
2027                         Bitmap* pBackgroundBitmap = null;
2028                         pBackgroundBitmap = LoadBitmapN(elementString); //__image->DecodeN(path,BITMAP_PIXEL_FORMAT_RGB565);
2029                         if (pBackgroundBitmap != null)
2030                         {
2031                                 r = pListView->SetBitmapOfEmptyList(pBackgroundBitmap);
2032                                 delete pBackgroundBitmap;
2033                                 pBackgroundBitmap = null;
2034
2035                                 SysTryCatch(NID_UI, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r));
2036                         }
2037                 }
2038
2039                 if (pControl->GetElement(L"backgroundColorOpacity", elementString) || pControl->GetElement(L"BGColorOpacity", elementString))
2040                 {
2041                         Base::Integer::Parse(elementString, opacity);
2042                 }
2043
2044                 if (pControl->GetElement(L"backgroundColor", elementString) || pControl->GetElement(L"BGColor", elementString))
2045                 {
2046                         ConvertStringToColor32(elementString, opacity, color);
2047                         r = pListView->SetBackgroundColor(color);
2048                         SysTryCatch(NID_UI, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r));
2049                 }
2050
2051                 if (pControl->GetElement(L"itemDividerColor", elementString))
2052                 {
2053                         ConvertStringToColor(elementString, color);
2054                         r = pListView->SetItemDividerColor(color);
2055                         SysTryCatch(NID_UI, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r));
2056                 }
2057
2058                 if (pControl->GetElement(L"sweepEnabled", elementString))
2059                 {
2060                         if (elementString.Equals(L"true", false))
2061                         {
2062                                 isSweepEnabled = true;
2063                         }
2064                         else
2065                         {
2066                                 isSweepEnabled = false;
2067                         }
2068
2069                         r = pListView->SetSweepEnabled(isSweepEnabled);
2070                         SysTryCatch(NID_UI, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r));
2071                 }
2072
2073                 // scroll Input Mode
2074                 if (pControl->GetElement(L"scrollInputMode", elementString))
2075                 {
2076                         if (elementString.Equals(L"SCROLL_INPUT_MODE_RESTRICT_TO_INITIAL_DIRECTION", false))
2077                         {
2078                                 scrollInputMode = SCROLL_INPUT_MODE_RESTRICT_TO_INITIAL_DIRECTION;
2079                         }
2080
2081                         pListView->SetScrollInputMode(scrollInputMode);
2082                 }
2083
2084                 return pListView;
2085
2086         CATCH:
2087                 delete pListView;
2088                 return null;
2089         }
2090
2091 private:
2092 }; // _ListViewMaker
2093
2094 _ListViewRegister::_ListViewRegister()
2095 {
2096           _UiBuilderControlTableManager* pUiBuilderControlTableManager = _UiBuilderControlTableManager::GetInstance();
2097           pUiBuilderControlTableManager->RegisterControl(L"ListView", _ListViewMaker::GetInstance);
2098 }
2099
2100 _ListViewRegister::~_ListViewRegister()
2101 {
2102           _UiBuilderControlTableManager* pUiBuilderControlTableManager = _UiBuilderControlTableManager::GetInstance();
2103           pUiBuilderControlTableManager->UnregisterControl(L"ListView");
2104 }
2105
2106 static _ListViewRegister ListViewRegisterToUIbuilder;
2107 }}} // Tizen::Ui::Controls