Tizen 2.1 base
[framework/osp/uifw.git] / src / ui / controls / FUiCtrl_FastScrollPresenter.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_FastScrollPresenter.cpp
20  * @brief               This is the implementation file for the _FastScrollPresenter class.
21  */
22 #include <wchar.h>
23 #include <FBaseErrors.h>
24 #include <FBaseString.h>
25
26 #include <FGrpColor.h>
27 #include <FGrpRectangle.h>
28 #include <FGrpCanvas.h>
29 #include <FGrpBitmap.h>
30 #include <FUiAnimVisualElementAnimation.h>
31 #include <FUiAnimVisualElementAnimationProvider.h>
32 #include <FUiAnimIVisualElementAnimationStatusEventListener.h>
33 #include <FUiAnimVisualElementContentProvider.h>
34 #include <FUiAnimIVisualElementContentProvider.h>
35 #include <FUiAnimVisualElement.h>
36
37 #include <FBaseSysLog.h>
38 #include "FGrp_BitmapImpl.h"
39 #include "FGrp_TextTextObject.h"
40 #include <FGrp_TextTextSimple.h>
41 #include "FUiAnim_VisualElement.h"
42 #include "FUi_Control.h"
43 #include "FUi_UiTouchEvent.h"
44 #include "FUi_ResourceManager.h"
45 #include "FUiCtrl_IFastScrollListener.h"
46 #include "FUiCtrl_UiFastScrollEvent.h"
47 #include "FUiCtrl_UiFastScrollEventArg.h"
48 #include "FUiCtrl_FastScroll.h"
49 #include "FUiCtrl_FastScrollPresenter.h"
50 #include "FUiCtrl_FastScrollModel.h"
51 #include "FUiCtrl_FastScrollIndex.h"
52
53 #include "FUiAnim_MatrixUtil.h"
54
55 using namespace Tizen::Base;
56 using namespace Tizen::Graphics;
57 using namespace Tizen::Ui;
58 using namespace Tizen::Ui::Animations;
59 using namespace Tizen::Graphics::_Text;
60
61 namespace
62 {
63 const float FASTSCROLL_OPACITY_ON = 1.0f;
64 const float FASTSCROLL_OPACITY_SELECTEDBG_DIM = 0.5f;
65 const float FASTSCROLL_OPACITY_LIGHT_DIM = 0.3f;
66 const float FASTSCROLL_OPACITY_OFF = 0.0f;
67 const int FASTSCROLL_POPUPINDEX_COUNT = 3;
68 }
69
70 namespace Tizen { namespace Ui { namespace Controls
71 {
72
73 #ifndef MAX
74 #define MAX(a, b) ((a) > (b) ? (a) : (b))
75 #define MIN(a, b) ((a) < (b) ? (a) : (b))
76 #endif
77
78
79 _FastScrollViewConfig::_FastScrollViewConfig(void)
80         : __indexBgColor(Color::GetColor(COLOR_ID_BLACK))
81         , __indexHighlightColor(Color::GetColor(COLOR_ID_BLACK))
82         , __indexLeftLineColor(Color::GetColor(COLOR_ID_BLACK))
83         , __indexTextColor(Color::GetColor(COLOR_ID_BLACK))
84         , __indexSeparatorColor(Color::GetColor(COLOR_ID_BLACK))
85         , __selectedIndexBgColor(Color::GetColor(COLOR_ID_BLACK))
86         , __selectedIndexTextColor(Color::GetColor(COLOR_ID_BLACK))
87         , __selectedIndexOutlineColor(Color::GetColor(COLOR_ID_BLACK))
88         , __popupBgColor(Color::GetColor(COLOR_ID_BLACK))
89         , __popupTextColor(Color::GetColor(COLOR_ID_BLACK))
90         , __indexSizeMin(0, 0)
91         , __popupSize(0, 0)
92         , __indexMarginRight(0)
93         , __indexMarginTop(0)
94         , __indexGap(0)
95         , __indexLeftLineThickness(0)
96         , __indexTextSize(0)
97         , __indexSeparatorThickness(0)
98         , __selectedIndexMarginRight(0)
99         , __selectedIndexHeight(0)
100         , __popupWidthIncrement(0)
101         , __popupTextSize(0)
102         , __popupShadowRight(0)
103         , __popupShadowBottom(0)
104         , __pIndexBgBitmap(null)
105         , __pSelectedIndexBgBitmap(null)
106         , __pSelectedIndexOutlineBitmap(null)
107         , __pPopupBgBitmap(null)
108         , __pPopupBgEffectBitmap(null)
109         , __pFont(null)
110 {
111 }
112
113 _FastScrollViewConfig::~_FastScrollViewConfig(void)
114 {
115         ReleaseResources();
116 }
117
118 _FastScrollViewConfig*
119 _FastScrollViewConfig::CreateFastScrollViewConfigN(_ControlOrientation orientation)
120 {
121         _FastScrollViewConfig* pConfig = new (std::nothrow) _FastScrollViewConfig();
122         SysTryReturn(NID_UI_CTRL, pConfig, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
123
124         result r = pConfig->Construct(orientation);
125         SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
126
127         SetLastResult(E_SUCCESS);
128         return pConfig;
129
130 CATCH:
131         delete pConfig;
132
133         return null;
134 }
135
136 result
137 _FastScrollViewConfig::ReloadConfig(_ControlOrientation orientation)
138 {
139         result r = E_SUCCESS;
140
141         // release allocated resources.
142         ReleaseResources();
143
144         // load bitmap resources
145         r = GET_BITMAP_CONFIG_N(FASTSCROLL::INDEX_BG, BITMAP_PIXEL_FORMAT_ARGB8888, __pIndexBgBitmap);
146         SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] Failed to load image.");
147
148         r = GET_BITMAP_CONFIG_N(FASTSCROLL::SELECTED_INDEX_BG, BITMAP_PIXEL_FORMAT_ARGB8888, __pSelectedIndexBgBitmap);
149         SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] Failed to load image.");
150
151         r = GET_BITMAP_CONFIG_N(FASTSCROLL::SELECTED_INDEX_OUTLINE, BITMAP_PIXEL_FORMAT_ARGB8888, __pSelectedIndexOutlineBitmap);
152         SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] Failed to load image.");
153
154         r = GET_BITMAP_CONFIG_N(FASTSCROLL::POPUP_BG, BITMAP_PIXEL_FORMAT_ARGB8888, __pPopupBgEffectBitmap);
155         SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] Failed to load image.");
156
157         r = GET_BITMAP_CONFIG_N(FASTSCROLL::POPUP_BG_EFFECT, BITMAP_PIXEL_FORMAT_ARGB8888, __pPopupBgBitmap);
158         SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] Failed to load image.");
159
160
161         // load shape configuration
162         r = GET_SHAPE_CONFIG(FASTSCROLL::INDEX_WIDTH, _CONTROL_ORIENTATION_PORTRAIT, __indexSizeMin.width);
163         SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] Failed to get resource.");
164
165         r = GET_SHAPE_CONFIG(FASTSCROLL::INDEX_HEIGHT, _CONTROL_ORIENTATION_PORTRAIT, __indexSizeMin.height);
166         SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] Failed to get resource.");
167
168         r = GET_SHAPE_CONFIG(FASTSCROLL::INDEX_TOP_MARGIN, _CONTROL_ORIENTATION_PORTRAIT, __indexMarginTop);
169         SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] Failed to get resource.");
170
171         r = GET_SHAPE_CONFIG(FASTSCROLL::INDEX_LEFT_LINE_THICKNESS, _CONTROL_ORIENTATION_PORTRAIT, __indexLeftLineThickness);
172         SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] Failed to get resource.");
173
174         r = GET_SHAPE_CONFIG(FASTSCROLL::INDEX_TEXT_SIZE, _CONTROL_ORIENTATION_PORTRAIT, __indexTextSize);
175         SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] Failed to get resource.");
176
177         r = GET_FIXED_VALUE_CONFIG(FASTSCROLL::INDEX_SEPARATOR_THICKNESS, _CONTROL_ORIENTATION_PORTRAIT, __indexSeparatorThickness);
178         SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] Failed to get resource.");
179
180         r = GET_SHAPE_CONFIG(FASTSCROLL::SELECTED_INDEX_RIGHT_MARGIN, _CONTROL_ORIENTATION_PORTRAIT, __selectedIndexMarginRight);
181         SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] Failed to get resource.");
182
183         r = GET_SHAPE_CONFIG(FASTSCROLL::SELECTED_INDEX_HEIGHT, _CONTROL_ORIENTATION_PORTRAIT, __selectedIndexHeight);
184         SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] Failed to get resource.");
185
186         r = GET_SHAPE_CONFIG(FASTSCROLL::POPUP_WIDTH, _CONTROL_ORIENTATION_PORTRAIT, __popupSize.width);
187         SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] Failed to get resource.");
188
189         r = GET_SHAPE_CONFIG(FASTSCROLL::POPUP_HEIGHT, _CONTROL_ORIENTATION_PORTRAIT, __popupSize.height);
190         SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] Failed to get resource.");
191
192         r = GET_SHAPE_CONFIG(FASTSCROLL::POPUP_WIDTH_INCREMENT, _CONTROL_ORIENTATION_PORTRAIT, __popupWidthIncrement);
193         SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] Failed to get resource.");
194
195         r = GET_SHAPE_CONFIG(FASTSCROLL::POPUP_TEXT_SIZE, _CONTROL_ORIENTATION_PORTRAIT, __popupTextSize);
196         SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] Failed to get resource.");
197
198         r = GET_SHAPE_CONFIG(FASTSCROLL::POPUP_RIGHT_SHADOW, _CONTROL_ORIENTATION_PORTRAIT, __popupShadowRight);
199         SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] Failed to get resource.");
200
201         r = GET_SHAPE_CONFIG(FASTSCROLL::POPUP_BOTTOM_SHADOW, _CONTROL_ORIENTATION_PORTRAIT, __popupShadowBottom);
202         SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] Failed to get resource.");
203
204
205         // load color configuration
206         r = GET_COLOR_CONFIG(FASTSCROLL::INDEX_BAR, __indexBgColor);
207         SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] Failed to get resource.");
208
209         r = GET_COLOR_CONFIG(FASTSCROLL::INDEX_LEFT_LINE, __indexLeftLineColor);
210         SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] Failed to get resource.");
211
212         r = GET_COLOR_CONFIG(FASTSCROLL::INDEX_BAR_TEXT, __indexTextColor);
213         SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] Failed to get resource.");
214
215         r = GET_COLOR_CONFIG(FASTSCROLL::INDEX_SEPARATOR, __indexSeparatorColor);
216         SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] Failed to get resource.");
217
218         r = GET_COLOR_CONFIG(FASTSCROLL::SELECTED_INDEX_BG, __selectedIndexBgColor);
219         SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] Failed to get resource.");
220
221         r = GET_COLOR_CONFIG(FASTSCROLL::SELECTED_INDEX_TEXT, __selectedIndexTextColor);
222         SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] Failed to get resource.");
223
224         r = GET_COLOR_CONFIG(FASTSCROLL::SELECTED_INDEX_OUTLINE, __selectedIndexOutlineColor);
225         SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] Failed to get resource.");
226
227         r = GET_COLOR_CONFIG(FASTSCROLL::POPUP_BG, __popupBgColor);
228         SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] Failed to get resource.");
229
230         r = GET_COLOR_CONFIG(FASTSCROLL::POPUP_TEXT, __popupTextColor);
231         SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] Failed to get resource.");
232
233         return E_SUCCESS;
234
235 CATCH:
236         __indexBgColor = Color::GetColor(COLOR_ID_BLACK);
237         __indexHighlightColor = Color::GetColor(COLOR_ID_BLACK);
238         __indexLeftLineColor = Color::GetColor(COLOR_ID_BLACK);
239         __indexTextColor = Color::GetColor(COLOR_ID_BLACK);
240         __indexSeparatorColor = Color::GetColor(COLOR_ID_BLACK);
241         __selectedIndexBgColor = Color::GetColor(COLOR_ID_BLACK);
242         __selectedIndexTextColor = Color::GetColor(COLOR_ID_BLACK);
243         __selectedIndexOutlineColor = Color::GetColor(COLOR_ID_BLACK);
244         __popupBgColor = Color::GetColor(COLOR_ID_BLACK);
245         __popupTextColor = Color::GetColor(COLOR_ID_BLACK);
246
247         __indexSizeMin.SetSize(0, 0);
248         __popupSize.SetSize(0, 0);
249
250         __indexMarginRight = 0;
251         __indexMarginTop = 0;
252         __indexGap = 0;
253         __indexLeftLineThickness = 0;
254         __indexTextSize = 0;
255         __indexSeparatorThickness = 0;
256         __selectedIndexMarginRight = 0;
257         __selectedIndexHeight = 0;
258         __popupWidthIncrement = 0;
259         __popupTextSize = 0;
260
261         ReleaseResources();
262
263         return E_SYSTEM;
264 }
265
266 void
267 _FastScrollViewConfig::ReleaseResources(void)
268 {
269         delete __pIndexBgBitmap;
270         delete __pSelectedIndexBgBitmap;
271         delete __pSelectedIndexOutlineBitmap;
272         delete __pPopupBgBitmap;
273         delete __pPopupBgEffectBitmap;
274
275         __pIndexBgBitmap = null;
276         __pSelectedIndexBgBitmap = null;
277         __pSelectedIndexOutlineBitmap = null;
278         __pPopupBgBitmap = null;
279         __pPopupBgEffectBitmap = null;
280 }
281
282 result
283 _FastScrollViewConfig::Construct(_ControlOrientation orientation)
284 {
285         return ReloadConfig(orientation);
286 }
287
288
289 _FastScrollIndexView::_FastScrollIndexView(_VisualElement& parentVe, _FastScrollViewConfig& viewConfig)
290         : __parentVe(parentVe)
291         , __viewConfig(viewConfig)
292         , __pBaseIndex(null)
293         , __pSelectedIndex(null)
294         , __pSelectedIndexInOmittedIndex(null)
295         , __pFormerIndex(null)
296         , __pBaseIndexVe(null)
297         , __pSelectedBgVe(null)
298         , __pSelectedIndexVe(null)
299         , __needUpdateBaseIndex(false)
300         , __needUpdateSelectedIndex(false)
301         , __needDestroySelf(false)
302 {
303 }
304
305 _FastScrollIndexView::~_FastScrollIndexView(void)
306 {
307         if (__pSelectedIndexVe)
308         {
309                 __pSelectedIndexVe->RemoveAllAnimations();
310                 __pSelectedIndexVe->SetAnimationProvider(null);
311
312                 __pSelectedIndexVe->Destroy();
313                 __pSelectedIndexVe = null;
314         }
315
316         if (__pSelectedBgVe)
317         {
318                 __pSelectedBgVe->RemoveAllAnimations();
319                 __pSelectedBgVe->SetAnimationProvider(null);
320
321                 __pSelectedBgVe->Destroy();
322                 __pSelectedBgVe = null;
323         }
324
325         if (__pBaseIndexVe)
326         {
327                 __pBaseIndexVe->RemoveAllAnimations();
328                 __pBaseIndexVe->SetAnimationProvider(null);
329
330                 __pBaseIndexVe->Destroy();
331                 __pBaseIndexVe = null;
332         }
333 }
334
335 _FastScrollIndexView*
336 _FastScrollIndexView::CreateFastScrollIndexViewN(_VisualElement& parentVe, _FastScrollViewConfig& viewConfig)
337 {
338         _FastScrollIndexView* pIndexView = new (std::nothrow) _FastScrollIndexView(parentVe, viewConfig);
339         SysTryReturn(NID_UI_CTRL, pIndexView, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
340
341         result r = pIndexView->Construct();
342         SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
343
344         SetLastResult(E_SUCCESS);
345         return pIndexView;
346
347 CATCH:
348         delete pIndexView;
349
350         return null;
351 }
352
353 result
354 _FastScrollIndexView::FadeOutAndDestroy(void)
355 {
356         __needDestroySelf = true;
357         if (__pSelectedIndexVe)
358         {
359                 __pSelectedIndexVe->RemoveAllAnimations();
360         }
361
362         if (__pSelectedBgVe)
363         {
364                 __pSelectedBgVe->RemoveAllAnimations();
365         }
366
367         return SetIndexVisibility(false);
368 }
369
370 result
371 _FastScrollIndexView::SetBaseIndex(_FastScrollIndex* pIndex)
372 {
373         __pBaseIndex = pIndex;
374
375         result r = UpdateIndex(false);
376         SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Failed to update the index view.");
377
378         return E_SUCCESS;
379 }
380
381 _FastScrollIndex*
382 _FastScrollIndexView::GetBaseIndex(void) const
383 {
384         return __pBaseIndex;
385 }
386
387 result
388 _FastScrollIndexView::SetIndexBounds(const Rectangle& indexBounds)
389 {
390         SysTryReturnResult(NID_UI_CTRL, __pSelectedIndexVe, E_INVALID_STATE, "__pSelectedIndexVe must not be null.");
391
392         FloatRectangle veBounds(indexBounds.x, indexBounds.y, indexBounds.width, indexBounds.height);
393
394         __pBaseIndexVe->SetBounds(veBounds);
395
396         __needUpdateBaseIndex = true;
397
398         veBounds.x = 0;
399         veBounds.y = 0;
400         __pSelectedIndexVe->SetBounds(veBounds);
401
402         __needUpdateSelectedIndex = true;
403
404         return E_SUCCESS;
405 }
406
407 Rectangle
408 _FastScrollIndexView::GetIndexBounds(void) const
409 {
410         FloatRectangle veBounds = __pBaseIndexVe->GetBounds();
411         return Rectangle(veBounds.x, veBounds.y, veBounds.width, veBounds.height);
412 }
413
414 result
415 _FastScrollIndexView::SetSelectedBgBounds(const Rectangle& indexBounds)
416 {
417         SysTryReturnResult(NID_UI_CTRL, __pSelectedBgVe, E_INVALID_STATE, "__pSelectedBgVe must not be null.");
418
419         FloatRectangle veBounds(indexBounds.x, indexBounds.y, indexBounds.width, indexBounds.height);
420         __pSelectedBgVe->SetBounds(veBounds);
421
422         return E_SUCCESS;
423 }
424
425 Rectangle
426 _FastScrollIndexView::GetSelectedBgBounds(void) const
427 {
428         SysTryReturn(NID_UI_CTRL, __pSelectedBgVe, Rectangle(0, 0, 0, 0), E_INVALID_STATE, "[E_INVALID_STATE] __pSelectedBgVe must not be null.");
429
430         FloatRectangle veBounds = __pSelectedBgVe->GetBounds();
431         return Rectangle(veBounds.x, veBounds.y, veBounds.width, veBounds.height);
432 }
433
434 result
435 _FastScrollIndexView::SetSelectedIndexBounds(const Rectangle& indexBounds)
436 {
437         SysTryReturnResult(NID_UI_CTRL, __pSelectedIndexVe, E_INVALID_STATE, "__pSelectedIndexVe must not be null.");
438
439         FloatRectangle veBounds(indexBounds.x, indexBounds.y, indexBounds.width, indexBounds.height);
440         __pSelectedIndexVe->SetBounds(veBounds);
441
442         return E_SUCCESS;
443 }
444
445 Rectangle
446 _FastScrollIndexView::GetSelectedIndexBounds(void) const
447 {
448         SysTryReturn(NID_UI_CTRL, __pSelectedIndexVe, Rectangle(0, 0, 0, 0), E_INVALID_STATE, "[E_INVALID_STATE] __pSelectedIndexVe must not be null.");
449
450         FloatRectangle veBounds = __pSelectedIndexVe->GetBounds();
451         return Rectangle(veBounds.x, veBounds.y, veBounds.width, veBounds.height);
452 }
453
454 _FastScrollIndex*
455 _FastScrollIndexView::GetIndexAtPoint(const Point& point) const
456 {
457         SysTryReturn(NID_UI_CTRL, __pBaseIndex, null, E_INVALID_STATE, "[E_INVALID_STATE] __pBaseIndex must not be null.");
458
459         int childCount = __pBaseIndex->GetChildCount(__pBaseIndex->GetIndexType());
460         SysTryReturn(NID_UI_CTRL, childCount > 0, null, E_INVALID_STATE, "[E_INVALID_STATE] The index have no children.");
461
462         _FastScrollIndex* pChildIndex = null;
463
464         Rectangle bounds = GetIndexBounds();
465         if (bounds.Contains(point) == true)
466         {
467                 int touchY = point.y - bounds.y - __viewConfig.__indexMarginTop;
468                 int indexHeight = GetIndexHeight();
469                 int indexOrder = 0;
470
471                 if ((touchY != 0) && (indexHeight != 0))
472                 {
473                         indexOrder = touchY / indexHeight;
474                 }
475
476                 pChildIndex = __pBaseIndex->GetChildIndex(indexOrder, true);
477                 SysTryReturn(NID_UI_CTRL, pChildIndex, null, GetLastResult(), "[%s] Failed to get the child index.",
478                                 GetErrorMessage(GetLastResult()));
479         }
480
481         SetLastResult(E_SUCCESS);
482         return pChildIndex;
483 }
484
485 _FastScrollIndex*
486 _FastScrollIndexView::GetOmissionIndexAtPoint(_FastScrollIndex* pIndex, const Point& point) const
487 {
488         Rectangle bounds = GetIndexBounds();
489         int touchY = point.y - bounds.y - __viewConfig.__indexMarginTop - (pIndex->GetIndexOrder(true) * GetIndexHeight());
490         int indexHeight = GetIndexHeight() / pIndex->GetChildCount();
491         int omissionIndexOrder = 0;
492
493         if ((touchY != 0) && (indexHeight != 0))
494         {
495                 omissionIndexOrder = touchY / indexHeight;
496         }
497
498         _FastScrollIndex* pChildIndex = pIndex->GetChildIndex(omissionIndexOrder);
499         SysTryReturn(NID_UI_CTRL, pChildIndex, null, GetLastResult(), "[%s] Failed to get the child index.",
500                                 GetErrorMessage(GetLastResult()));
501
502         SetLastResult(E_SUCCESS);
503         return pChildIndex;
504 }
505
506 int
507 _FastScrollIndexView::GetIndexHeight(void) const
508 {
509         Rectangle bounds = GetIndexBounds();
510         int indexHeight = __viewConfig.__indexSizeMin.height;
511
512         if (__pBaseIndex->GetParentIndex() == null)
513         {
514                 indexHeight = MAX(indexHeight,
515                                 ((bounds.height - __viewConfig.__indexMarginTop * 2) / __pBaseIndex->GetChildCount(__pBaseIndex->GetIndexType())));
516         }
517
518         return indexHeight;
519 }
520
521 result
522 _FastScrollIndexView::SelectIndex(int indexOrder)
523 {
524         result r = E_SUCCESS;
525
526         SysTryReturnResult(NID_UI_CTRL, __pBaseIndex, E_INVALID_STATE, "__pBaseIndex must not be null.");
527
528         _FastScrollIndex* pIndex = __pBaseIndex->GetChildIndex(indexOrder, true);
529         SysTryReturnResult(NID_UI_CTRL, pIndex, GetLastResult(), "Failed to get the child index.");
530
531         r = SelectIndex(pIndex, false);
532         SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Failed to select the index.");
533
534         return E_SUCCESS;
535 }
536
537 result
538 _FastScrollIndexView::SelectIndex(_FastScrollIndex* pIndex, bool animation)
539 {
540         result r = E_SUCCESS;
541
542         if (__pSelectedIndex == pIndex)
543         {
544                 return E_SUCCESS;
545         }
546
547         __pSelectedIndex = pIndex;
548
549         if (__pSelectedIndex)
550         {
551                 r = SetSelectedBgBounds(CalculateSelectedBg());
552                 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Failed to get the canvas of the Selected Bg ve.");
553
554                 if (GetSelectedIndexVisibility() == false)
555                 {
556                         r = SetSelectedIndexVisibility(true, animation);
557                         SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Failed to set visibility of the Selected Bg ve.");
558                 }
559         }
560         else
561         {
562                 if (GetSelectedIndexVisibility() == true)
563                 {
564                         r = SetSelectedIndexVisibility(false, animation);
565                         SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Failed to set visibility of the Selected Bg ve.");
566                 }
567                 SetSelectedIndexInOmittedIndex(null);
568                 __pFormerIndex = null;
569         }
570
571         r = UpdateIndex(false);
572         SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Failed to update the index view.");
573
574         return E_SUCCESS;
575 }
576
577 int
578 _FastScrollIndexView::GetSelectedIndexOrder(void) const
579 {
580         SysTryReturn(NID_UI_CTRL, __pBaseIndex, -1, E_INVALID_STATE, "[E_INVALID_STATE] __pBaseIndex must not be null.");
581         SysTryReturn(NID_UI_CTRL, __pSelectedIndex, -1, E_INVALID_STATE, "[E_INVALID_STATE] __pSelectedIndex must not be null.");
582
583         return __pBaseIndex->GetChildOrder(__pSelectedIndex, true);
584 }
585
586 _FastScrollIndex*
587 _FastScrollIndexView::GetSelectedIndex(void) const
588 {
589         return __pSelectedIndex;
590 }
591
592 void
593 _FastScrollIndexView::SetSelectedIndexInOmittedIndex(_FastScrollIndex* pIndex)
594 {
595         __pFormerIndex = __pSelectedIndexInOmittedIndex;
596         __pSelectedIndexInOmittedIndex = pIndex;
597 }
598
599 _FastScrollIndex*
600 _FastScrollIndexView::GetSelectedIndexInOmittedIndex(void) const
601 {
602         return __pSelectedIndexInOmittedIndex;
603 }
604
605 _FastScrollIndex*
606 _FastScrollIndexView::GetFormerIndex(void) const
607 {
608         return __pFormerIndex;
609 }
610
611 bool
612 _FastScrollIndexView::IsOnAnimation(void) const
613 {
614         return false;
615 }
616
617 void
618 _FastScrollIndexView::RemoveAllAnimations(void)
619 {
620         __pBaseIndexVe->RemoveAllAnimations();
621 }
622
623 result
624 _FastScrollIndexView::SetIndexVisibility(bool visibility)
625 {
626         result r = E_SUCCESS;
627
628         __pBaseIndexVe->SetImplicitAnimationEnabled(true);
629
630                 if (visibility)
631                 {
632                         __pBaseIndexVe->SetOpacity(FASTSCROLL_OPACITY_ON);
633                 }
634                 else
635                 {
636                         __pBaseIndexVe->SetOpacity(FASTSCROLL_OPACITY_OFF);
637                 }
638                 // else keep up current visibility.
639
640         __pBaseIndexVe->SetImplicitAnimationEnabled(false);
641
642         return r;
643 }
644
645 bool
646 _FastScrollIndexView::GetIndexVisibility(void) const
647 {
648         float opacity = __pBaseIndexVe->GetOpacity();
649         if (opacity > FASTSCROLL_OPACITY_OFF)
650         {
651                 return true;
652         }
653         else
654         {
655                 return false;
656         }
657 }
658
659 result
660 _FastScrollIndexView::SetSelectedIndexVisibility(bool visibility, bool animation)
661 {
662         SysTryReturnResult(NID_UI_CTRL, __pSelectedIndexVe, E_INVALID_STATE, "__pSelectedIndexVe must not be null.");
663         SysTryReturnResult(NID_UI_CTRL, __pSelectedBgVe, E_INVALID_STATE, "__pSelectedBgVe must not be null.");
664
665         if (animation)
666         {
667                 __pSelectedIndexVe->SetImplicitAnimationEnabled(true);
668                 __pSelectedBgVe->SetImplicitAnimationEnabled(true);
669         }
670
671         if (visibility)
672         {
673                 __pSelectedIndexVe->SetOpacity(FASTSCROLL_OPACITY_ON);
674                 __pSelectedBgVe->SetOpacity(FASTSCROLL_OPACITY_SELECTEDBG_DIM);
675         }
676         else
677         {
678                 __pSelectedIndexVe->SetOpacity(FASTSCROLL_OPACITY_OFF);
679                 __pSelectedBgVe->SetOpacity(FASTSCROLL_OPACITY_OFF);
680         }
681         // else keep up current visibility.
682
683         __pSelectedIndexVe->SetImplicitAnimationEnabled(false);
684         __pSelectedBgVe->SetImplicitAnimationEnabled(false);
685
686         return E_SUCCESS;
687 }
688
689 bool
690 _FastScrollIndexView::GetSelectedIndexVisibility(void) const
691 {
692         SysTryReturn(NID_UI_CTRL, __pSelectedIndexVe, false, E_INVALID_STATE, "[E_INVALID_STATE] __pSelectedIndexVe must not be null.");
693
694         float opacity = __pSelectedIndexVe->GetOpacity();
695         if (opacity > FASTSCROLL_OPACITY_OFF)
696         {
697                 return true;
698         }
699
700         return false;
701 }
702
703
704 result
705 _FastScrollIndexView::AddAccessibilityElement(const _AccessibilityContainer& control)
706 {
707         SysTryReturnResult(NID_UI_CTRL, __pBaseIndex, E_INVALID_STATE, "[E_INVALID_STATE] __pBaseIndex must not be null.");
708
709         int omittedChildCount = __pBaseIndex->GetChildCount(__pBaseIndex->GetIndexType());
710         SysTryReturnResult(NID_UI_CTRL, omittedChildCount > 0, E_INVALID_STATE, "The index have no children.");
711
712         Rectangle bounds = GetIndexBounds();
713         int indexHeight = GetIndexHeight();
714         Rectangle indexRect(bounds.x, __viewConfig.__indexMarginTop, bounds.width, indexHeight);
715         int nonOmittedIndex = 0;
716
717         _AccessibilityElement* pAccessibilityElement = null;
718         result r = E_SUCCESS;
719         for (int i = 0; i < omittedChildCount; )
720         {
721                 _FastScrollIndex* pChildIndex = __pBaseIndex->GetChildIndex(i, true);
722                 SysTryReturnResult(NID_UI_CTRL, pChildIndex, GetLastResult(), "Failed to get the child index.");
723
724                 int omittedCount = 0;
725                 if (pChildIndex->GetOmitted())
726                 {
727                         omittedCount = pChildIndex->GetChildCount();
728                         pChildIndex = __pBaseIndex->GetChildIndex(nonOmittedIndex, false);
729                         SysTryReturnResult(NID_UI_CTRL, pChildIndex, GetLastResult(), "Failed to get the child index.");
730                 }
731
732                 Bitmap* pChildIndexImage = pChildIndex->GetIndexImage();
733                 if (pChildIndexImage == null)
734                 {
735                         String* pChildIndexText = pChildIndex->GetIndexText();
736                         SysTryReturnResult(NID_UI_CTRL, pChildIndexText, E_INVALID_STATE, "pChildIndexText must not be null.");
737
738                         _AccessibilityContainer* pAccessibilityContainer = const_cast <_AccessibilityContainer*>(&control);
739                         pAccessibilityElement = new (std::nothrow) _AccessibilityElement(true);
740                         SysTryReturnResult(NID_UI_CTRL, pAccessibilityElement, E_OUT_OF_MEMORY, "Memory allocation failed.");
741                         pAccessibilityElement->SetBounds(indexRect);
742                         pAccessibilityElement->SetLabel(*pChildIndexText);
743                         pAccessibilityElement->SetName(L"FastScrollIndex");
744                         pAccessibilityElement->SetHint(L"double tap to move ," + *pChildIndexText + L", list");
745                         r = pAccessibilityContainer->AddElement(*pAccessibilityElement);
746                         SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to add accessibility element.", GetErrorMessage(r));
747                 }
748
749                 if (omittedCount > 1)
750                 {
751                         omittedCount--;
752                 }
753                 else
754                 {
755                         indexRect.y += indexHeight;
756                         i++;
757                 }
758
759                 nonOmittedIndex++;
760         }
761
762         return E_SUCCESS;
763
764 CATCH:
765         delete pAccessibilityElement;
766         return r;
767 }
768
769 result
770 _FastScrollIndexView::UpdateIndex(bool bNeedUpdateBaseIndex)
771 {
772         result r = E_SUCCESS;
773
774         r = __parentVe.InvalidateRectangle(null);
775         SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Failed to invalidate the index Ve.");
776
777         if (__pSelectedIndex)
778         {
779                 __needUpdateSelectedIndex = true;
780         }
781
782         if (bNeedUpdateBaseIndex)
783         {
784                 __needUpdateBaseIndex = true;
785         }
786
787         return E_SUCCESS;
788 }
789
790 Rectangle
791 _FastScrollIndexView::CalculateSelectedBg(void)
792 {
793         SysTryReturn(NID_UI_CTRL, __pBaseIndex, Rectangle(0, 0, 0, 0), E_INVALID_STATE,
794                         "[E_INVALID_STATE] __pBaseIndex must not be     null.");
795         SysTryReturn(NID_UI_CTRL, __pSelectedIndexVe, Rectangle(0, 0, 0, 0), E_INVALID_STATE,
796                         "[E_INVALID_STATE] __pSelectedIndexVe must not be null.");
797         SysTryReturn(NID_UI_CTRL, __pSelectedIndex, Rectangle(0, 0, 0, 0), E_INVALID_STATE,
798                         "[E_INVALID_STATE] __pSelectedIndex must not be null.");
799
800         int childCount = __pBaseIndex->GetChildCount(__pBaseIndex->GetIndexType());
801         SysTryReturn(NID_UI_CTRL, childCount > 0, Rectangle(0, 0, 0, 0), E_INVALID_STATE, "[E_INVALID_STATE] The index have no children.");
802
803         Rectangle bounds = GetIndexBounds();
804         int indexHeight = GetIndexHeight();
805         int selectedIndexOrder = GetSelectedIndexOrder();
806         Rectangle selectedRect(0, 0, (bounds.width - __viewConfig.__selectedIndexMarginRight), __viewConfig.__selectedIndexHeight);
807
808         if (indexHeight > __viewConfig.__selectedIndexHeight)
809         {
810                 selectedRect.y = (selectedIndexOrder * indexHeight) + __viewConfig.__indexMarginTop * 2;
811                 selectedRect.height = indexHeight - (__viewConfig.__indexMarginTop * 2) ;
812         }
813         else if (bounds.height <= __viewConfig.__selectedIndexHeight)
814         {
815                 selectedRect.height = bounds.height;
816         }
817         else
818         {
819                 if (selectedIndexOrder == (childCount - 1))
820                 {
821                         selectedRect.y = bounds.height - __viewConfig.__selectedIndexHeight - __viewConfig.__indexMarginTop;
822                 }
823                 else
824                 {
825                         selectedRect.y = ((selectedIndexOrder * indexHeight) + __viewConfig.__indexMarginTop) - (__viewConfig.__selectedIndexHeight - indexHeight) / 2;
826                         selectedRect.y = MAX (selectedRect.y, __viewConfig.__indexMarginTop);
827                 }
828         }
829
830         return selectedRect;
831 }
832
833 void
834 _FastScrollIndexView::OnDraw(void)
835 {
836         DrawBaseIndex();
837         if (__pSelectedIndex)
838         {
839                 DrawSelectedBg();
840                 DrawSelectedIndex();
841         }
842 }
843
844 void
845 _FastScrollIndexView::DrawBaseIndex()
846 {
847         if (!__needUpdateBaseIndex)
848         {
849                 return;
850         }
851
852         SysTryReturnVoidResult(NID_UI_CTRL, __pBaseIndex, E_INVALID_STATE, "[E_INVALID_STATE] __pBaseIndex must not be null.");
853
854         result r = E_SUCCESS;
855
856         int childCount = __pBaseIndex->GetChildCount(__pBaseIndex->GetIndexType());
857         SysTryReturnVoidResult(NID_UI_CTRL, childCount > 0, E_INVALID_STATE, "[E_INVALID_STATE] The index have no children.");
858
859         Canvas* pCanvas = __pBaseIndexVe->GetCanvasN();
860         SysTryReturnVoidResult(NID_UI_CTRL, pCanvas, GetLastResult(), "[%s] Failed to get the canvas of the index ve.",
861                         GetErrorMessage(GetLastResult()));
862
863         pCanvas->SetBackgroundColor(Color(0, 0, 0, 0));
864         pCanvas->Clear();
865
866         //Draw Seperator
867         pCanvas->SetLineWidth(__viewConfig.__indexSeparatorThickness);
868
869         Rectangle bounds = GetIndexBounds();
870         int indexHeight = GetIndexHeight();
871
872         //Draw background ef, bitmap
873         Rectangle bgBounds(0, 0, bounds.width, bounds.height);
874         if (__viewConfig.__pIndexBgBitmap)
875         {
876                 Bitmap* pReplacementColorBackgroundBitmap =
877                                 _BitmapImpl::GetColorReplacedBitmapN(*__viewConfig.__pIndexBgBitmap,
878                                                                 Color::GetColor(COLOR_ID_MAGENTA), __viewConfig.__indexBgColor);
879                 DrawBitmap(*pCanvas, bgBounds, *pReplacementColorBackgroundBitmap);
880
881                 delete pReplacementColorBackgroundBitmap;
882         }
883
884         Rectangle indexRect(0, __viewConfig.__indexMarginTop, bounds.width, indexHeight);
885         Bitmap* pReplacementColorBitmap = null;
886
887         TextObject* pTextObject = new (std::nothrow) TextObject();
888         SysTryCatch(NID_UI_CTRL, pTextObject, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
889
890         pTextObject->Construct();
891
892         for (int i = 0; i < childCount; i++)
893         {
894                 TextSimple* pSimpleText = null;
895
896                 _FastScrollIndex* pChildIndex = __pBaseIndex->GetChildIndex(i, true);
897                 SysTryCatch(NID_UI_CTRL, pChildIndex, , GetLastResult(), "[%s] Failed to get the child index.",
898                                 GetErrorMessage(GetLastResult()));
899
900                 Bitmap* pChildIndexImage = pChildIndex->GetIndexImage();
901                 if (pChildIndexImage)
902                 {
903                         Rectangle imageRect = indexRect;
904
905                         float scaleFactor = MIN(((float)indexRect.width / pChildIndexImage->GetWidth()), ((float)indexRect.height / pChildIndexImage->GetHeight()));
906
907                         imageRect.width = pChildIndexImage->GetWidth() * scaleFactor + FASTSCROLL_OPACITY_SELECTEDBG_DIM;
908                         imageRect.height = pChildIndexImage->GetHeight() * scaleFactor + FASTSCROLL_OPACITY_SELECTEDBG_DIM;
909
910                         if (indexRect.width - imageRect.width > 0)
911                         {
912                                 imageRect.x = indexRect.x + (indexRect.width - imageRect.width)/2;
913                         }
914
915                         if (indexRect.height - imageRect.height > 0)
916                         {
917                                 imageRect.y = indexRect.y + (indexRect.height - imageRect.height)/2;
918                         }
919
920                         pReplacementColorBitmap =
921                                 _BitmapImpl::GetColorReplacedBitmapN(*pChildIndexImage,
922                                                                 Color::GetColor(COLOR_ID_MAGENTA), __viewConfig.__indexTextColor);
923                         r = DrawBitmap(*pCanvas, imageRect, *pReplacementColorBitmap,
924                                         Rectangle(0, 0, pChildIndexImage->GetWidth(), pChildIndexImage->GetHeight()));
925                         SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to draw a bitmap.", GetErrorMessage(r));
926
927                         delete pReplacementColorBitmap;
928                         pReplacementColorBitmap = null;
929                 }
930                 else
931                 {
932                         String* pChildIndexText = pChildIndex->GetIndexText();
933                         SysTryCatch(NID_UI_CTRL, pChildIndexText, , E_INVALID_STATE, "pChildIndexText must not be null.");
934
935                         pTextObject->RemoveAll();
936
937                         pSimpleText = new (std::nothrow)TextSimple(const_cast<wchar_t*>(pChildIndexText->GetPointer()), pChildIndexText->GetLength(), TEXT_ELEMENT_SOURCE_TYPE_EXTERNAL);
938                         SysTryCatch(NID_UI_CTRL, pSimpleText, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed");
939
940                         r = pTextObject->AppendElement(*pSimpleText);
941                         SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to append simple text.", GetErrorMessage(r));
942
943                         r = pTextObject->SetWrap(TEXT_OBJECT_WRAP_TYPE_WORD);
944                         SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to set wrap.", GetErrorMessage(r));
945
946                         r = pTextObject->SetFont(__viewConfig.__pFont, 0, pTextObject->GetTextLength());
947                         SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to set font.", GetErrorMessage(r));
948
949                         r = pTextObject->SetAlignment(TEXT_OBJECT_ALIGNMENT_CENTER | TEXT_OBJECT_ALIGNMENT_MIDDLE);
950                         SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to set alignment.", GetErrorMessage(r));
951
952                         r = pTextObject->SetBounds(indexRect);
953                         SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to set bounds of pTextObject.", GetErrorMessage(r));
954
955                         r = pTextObject->SetForegroundColor(__viewConfig.__indexTextColor, 0, pTextObject->GetTextLength());
956                         SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to set foreground color.", GetErrorMessage(r));
957
958                         r = pTextObject->Draw(*_CanvasImpl::GetInstance(*pCanvas));
959                         SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to draw text.", GetErrorMessage(r));
960
961                 }
962
963                 indexRect.y += indexHeight;
964                 if (i != (childCount - 1))
965                 {
966                         pCanvas->SetForegroundColor(__viewConfig.__indexSeparatorColor);
967                         pCanvas->DrawLine(Point(indexRect.x, indexRect.y + __viewConfig.__indexSeparatorThickness),
968                                                         Point(indexRect.x + indexRect.width, indexRect.y + __viewConfig.__indexSeparatorThickness));
969                 }
970         }
971
972         __needUpdateBaseIndex = false;
973         //fall through
974 CATCH:
975         delete pTextObject;
976         delete pCanvas;
977         delete pReplacementColorBitmap;
978 }
979
980 void
981 _FastScrollIndexView::DrawSelectedBg()
982 {
983         if (!__needUpdateSelectedIndex)
984         {
985                 return;
986         }
987
988         SysTryReturnVoidResult(NID_UI_CTRL, __pSelectedIndex, E_INVALID_STATE,
989                         "[E_INVALID_STATE] __pSelectedIndex must not be null.");
990
991         Canvas* pCanvas = __pSelectedBgVe->GetCanvasN();
992         SysTryReturnVoidResult(NID_UI_CTRL, pCanvas, GetLastResult(), "[%s] Failed to get the canvas of the Selected Bg ve.",
993                         GetErrorMessage(GetLastResult()));
994
995         pCanvas->SetBackgroundColor(Color(0, 0, 0, 0));
996         pCanvas->Clear();
997
998         Rectangle bounds = GetSelectedBgBounds();
999         bounds.y = 0;
1000
1001         if (__viewConfig.__pSelectedIndexBgBitmap)
1002         {
1003                 Bitmap* pReplacementColorBackgroundBitmap = null;
1004                 pReplacementColorBackgroundBitmap =
1005                                 _BitmapImpl::GetColorReplacedBitmapN(*__viewConfig.__pSelectedIndexBgBitmap,
1006                                                                 Color::GetColor(COLOR_ID_MAGENTA), __viewConfig.__selectedIndexBgColor);
1007                 DrawBitmap(*pCanvas, bounds, *pReplacementColorBackgroundBitmap);
1008
1009                 delete pReplacementColorBackgroundBitmap;
1010         }
1011
1012         delete pCanvas;
1013 }
1014
1015 void
1016 _FastScrollIndexView::DrawSelectedIndex()
1017 {
1018         if (!__needUpdateSelectedIndex)
1019         {
1020                 return;
1021         }
1022
1023         SysTryReturnVoidResult(NID_UI_CTRL, __pSelectedIndex, E_INVALID_STATE, "[E_INVALID_STATE] __pSelectedIndex must not be null.");
1024
1025         Canvas* pCanvas = __pSelectedIndexVe->GetCanvasN();
1026         SysTryReturnVoidResult(NID_UI_CTRL, pCanvas, GetLastResult(), "[%s] Failed to get the canvas of the selected index ve.",
1027                         GetErrorMessage(GetLastResult()));
1028
1029         result r = E_SUCCESS;
1030
1031         pCanvas->SetBackgroundColor(Color(0, 0, 0, 0));
1032         pCanvas->Clear();
1033         Rectangle bounds = GetSelectedIndexBounds();
1034
1035         //draw selected outline
1036         Rectangle outlineBounds = GetSelectedBgBounds();
1037         if (__viewConfig.__pSelectedIndexOutlineBitmap)
1038         {
1039                 Bitmap* pReplacementColorBackgroundBitmap = null;
1040                 pReplacementColorBackgroundBitmap =
1041                                 _BitmapImpl::GetColorReplacedBitmapN(*__viewConfig.__pSelectedIndexOutlineBitmap,
1042                                                                 Color::GetColor(COLOR_ID_MAGENTA), __viewConfig.__selectedIndexOutlineColor);
1043                 DrawBitmap(*pCanvas, outlineBounds, *pReplacementColorBackgroundBitmap);
1044
1045                 delete pReplacementColorBackgroundBitmap;
1046         }
1047
1048         //Draw left line
1049         pCanvas->SetLineWidth(__viewConfig.__indexLeftLineThickness);
1050         pCanvas->SetForegroundColor(__viewConfig.__indexLeftLineColor);
1051
1052         pCanvas->DrawLine(Point(0, 0), Point(0, outlineBounds.y));
1053         pCanvas->DrawLine(Point(0, (outlineBounds.y + 1 + outlineBounds.height)), Point(0, bounds.height));
1054
1055         //draw text
1056         TextObject* pTextObject = null;
1057         TextSimple* pSimpleText = null;
1058
1059         int indexHeight = GetIndexHeight();
1060         Rectangle indexRect(0, ((GetSelectedIndexOrder() * indexHeight) + __viewConfig.__indexMarginTop),
1061                         bounds.width, indexHeight);
1062
1063         Bitmap* pChildIndexImage = __pSelectedIndex->GetIndexImage();
1064         Bitmap* pReplacementColorBitmap = null;
1065         if (pChildIndexImage)
1066         {
1067                 Rectangle imageRect = indexRect;
1068
1069                 float scaleFactor = MIN(((float)indexRect.width / pChildIndexImage->GetWidth()), ((float)indexRect.height / pChildIndexImage->GetHeight()));
1070
1071                 imageRect.width = pChildIndexImage->GetWidth() * scaleFactor + FASTSCROLL_OPACITY_SELECTEDBG_DIM;
1072                 imageRect.height = pChildIndexImage->GetHeight() * scaleFactor + FASTSCROLL_OPACITY_SELECTEDBG_DIM;
1073
1074                 if (indexRect.width - imageRect.width > 0)
1075                 {
1076                         imageRect.x = indexRect.x + (indexRect.width - imageRect.width)/2;
1077                 }
1078
1079                 if (indexRect.height - imageRect.height > 0)
1080                 {
1081                         imageRect.y = indexRect.y + (indexRect.height - imageRect.height)/2;
1082                 }
1083
1084                 pReplacementColorBitmap =
1085                         _BitmapImpl::GetColorReplacedBitmapN(*pChildIndexImage,
1086                                                         Color::GetColor(COLOR_ID_MAGENTA), __viewConfig.__selectedIndexTextColor);
1087                 r = DrawBitmap(*pCanvas, imageRect, *pReplacementColorBitmap,
1088                                 Rectangle(0, 0, pChildIndexImage->GetWidth(), pChildIndexImage->GetHeight()));
1089                 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to draw a bitmap.", GetErrorMessage(r));
1090
1091                 delete pReplacementColorBitmap;
1092                 pReplacementColorBitmap = null;
1093         }
1094         else
1095         {
1096                 String* pChildIndexText = __pSelectedIndex->GetIndexText();
1097                 SysTryCatch(NID_UI_CTRL, pChildIndexText, , E_INVALID_STATE, "[E_INVALID_STATE] pChildIndexText must not be null.");
1098
1099                 pTextObject = new (std::nothrow) TextObject();
1100                 SysTryCatch(NID_UI_CTRL, pTextObject, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
1101
1102                 pTextObject->Construct();
1103
1104                 pSimpleText = new (std::nothrow)TextSimple(const_cast<wchar_t*>(pChildIndexText->GetPointer()), pChildIndexText->GetLength(), TEXT_ELEMENT_SOURCE_TYPE_EXTERNAL);
1105                 SysTryCatch(NID_UI_CTRL, pSimpleText, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
1106
1107                 r = pTextObject->AppendElement(*pSimpleText);
1108                 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to append simpletext.", GetErrorMessage(r));
1109
1110                 r = pTextObject->SetWrap(TEXT_OBJECT_WRAP_TYPE_WORD);
1111                 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to set wrap.", GetErrorMessage(r));
1112
1113                 r = pTextObject->SetFont(__viewConfig.__pFont, 0, pTextObject->GetTextLength());
1114                 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to set font.", GetErrorMessage(r));
1115
1116                 r = pTextObject->SetAlignment(TEXT_OBJECT_ALIGNMENT_CENTER | TEXT_OBJECT_ALIGNMENT_MIDDLE);
1117                 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to set alignment.", GetErrorMessage(r));
1118
1119                 r = pTextObject->SetBounds(indexRect);
1120                 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to set bounds of pTextObject.", GetErrorMessage(r));
1121
1122                 r = pTextObject->SetForegroundColor(__viewConfig.__selectedIndexTextColor, 0, pTextObject->GetTextLength());
1123                 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to set foreground color.", GetErrorMessage(r));
1124
1125                 r = pTextObject->Draw(*_CanvasImpl::GetInstance(*pCanvas));
1126                 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to draw text.", GetErrorMessage(r));
1127
1128         }
1129
1130         __needUpdateSelectedIndex = false;
1131
1132         //fall through
1133 CATCH:
1134         delete pTextObject;
1135         delete pCanvas;
1136         delete pReplacementColorBitmap;
1137 }
1138
1139 result
1140 _FastScrollIndexView::DrawBitmap(Canvas& canvas, const Rectangle& bounds, const Bitmap& bitmap)
1141 {
1142         result r = E_SUCCESS;
1143         if (bitmap.IsNinePatchedBitmap())
1144         {
1145                 r = canvas.DrawNinePatchedBitmap(bounds, bitmap);
1146                 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Failed to draw ninepathced bitmap");
1147         }
1148         else
1149         {
1150                 r = canvas.DrawBitmap(bounds, bitmap);
1151                 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Failed to draw bitmap");
1152         }
1153
1154         return E_SUCCESS;
1155 }
1156
1157 result
1158 _FastScrollIndexView::DrawBitmap(Canvas& canvas, const Rectangle& srcRect, const Bitmap& bitmap, const Rectangle& dstRect)
1159 {
1160         result r = E_SUCCESS;
1161         if (bitmap.IsNinePatchedBitmap())
1162         {
1163                 r = canvas.DrawNinePatchedBitmap(srcRect, bitmap);
1164                 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Failed to draw ninepathced bitmap");
1165         }
1166         else
1167         {
1168                 r = canvas.DrawBitmap(srcRect, bitmap, dstRect);
1169                 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Failed to draw bitmap");
1170         }
1171
1172         return E_SUCCESS;
1173 }
1174
1175 VisualElementAnimation*
1176 _FastScrollIndexView::CreateAnimationForProperty(VisualElement& target, const String& property)
1177 {
1178         VisualElementAnimation* pAnimation = VisualElementAnimationProvider::CreateAnimationForProperty(target, property);
1179
1180         if (pAnimation)
1181         {
1182                 const IVisualElementAnimationTimingFunction* pTimingFunction = VisualElementAnimation::GetTimingFunctionByName("EaseInOut");
1183                 if (pTimingFunction)
1184                 {
1185                         pAnimation->SetTimingFunction(pTimingFunction);
1186                 }
1187                 pAnimation->SetVisualElementAnimationStatusEventListener(this);
1188         }
1189         return pAnimation;
1190 }
1191
1192 void
1193 _FastScrollIndexView::OnVisualElementAnimationStarted(const VisualElementAnimation& animation, const String& keyName, VisualElement& target)
1194 {
1195 }
1196
1197 void
1198 _FastScrollIndexView::OnVisualElementAnimationRepeated(const VisualElementAnimation& animation, const String& keyName, VisualElement& target, long currentRepeatCount)
1199 {
1200 }
1201
1202 void
1203 _FastScrollIndexView::OnVisualElementAnimationFinished(const VisualElementAnimation& animation, const String& keyName, VisualElement& target, bool completedNormally)
1204 {
1205         if (__pBaseIndexVe == (static_cast <_VisualElement*>(&target)))
1206         {
1207                 if (__needDestroySelf && completedNormally)
1208                 {
1209                         if (__pSelectedIndexVe)
1210                         {
1211                                 __pSelectedIndexVe->RemoveAllAnimations();
1212                                 __pSelectedIndexVe->SetAnimationProvider(null);
1213                         }
1214
1215                         if (__pSelectedBgVe)
1216                         {
1217                                 __pSelectedBgVe->RemoveAllAnimations();
1218                                 __pSelectedBgVe->SetAnimationProvider(null);
1219                         }
1220
1221                         __pBaseIndexVe->RemoveAllAnimations();
1222                         __pBaseIndexVe->SetAnimationProvider(null);
1223
1224                         delete this;
1225                 }
1226         }
1227 }
1228
1229 result
1230 _FastScrollIndexView::Construct(void)
1231 {
1232         result r = E_SUCCESS;
1233
1234         // FormattedText for Title text
1235         __pBaseIndexVe = new (std::nothrow) _VisualElement();
1236         SysTryCatch(NID_UI_CTRL, __pBaseIndexVe, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
1237
1238         r = __pBaseIndexVe->Construct();
1239         SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to construct the index Ve.", GetErrorMessage(r));
1240
1241         __pBaseIndexVe->SetAnimationProvider(this);
1242
1243         r = __pBaseIndexVe->SetSurfaceOpaque(false);
1244         SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to set the opaque of the base index ve.", GetErrorMessage(r));
1245
1246         __pBaseIndexVe->SetImplicitAnimationEnabled(false);
1247
1248         r = __parentVe.AttachChild(*__pBaseIndexVe);
1249         SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to attach the base index ve to the parent.", GetErrorMessage(r));
1250
1251         __pBaseIndexVe->SetShowState(true);
1252
1253         //__pSelectedBgVe
1254         __pSelectedBgVe = new (std::nothrow) _VisualElement();
1255         SysTryCatch(NID_UI_CTRL, __pSelectedBgVe, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
1256
1257         r = __pSelectedBgVe->Construct();
1258         SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to construct the selected Bg ve.", GetErrorMessage(r));
1259
1260         __pSelectedBgVe->SetAnimationProvider(this);
1261
1262         r = __pSelectedBgVe->SetSurfaceOpaque(false);
1263         SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to set the opaque of the selected Bg ve.", GetErrorMessage(r));
1264
1265         __pSelectedBgVe->SetImplicitAnimationEnabled(false);
1266
1267         r = __pBaseIndexVe->AttachChild(*__pSelectedBgVe);
1268         SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to attach the selected Bg ve to the parent.", GetErrorMessage(r));
1269
1270         __pSelectedBgVe->SetOpacity(FASTSCROLL_OPACITY_SELECTEDBG_DIM);
1271
1272         __pSelectedBgVe->SetShowState(true);
1273
1274         //__pSelectedIndexVe
1275         __pSelectedIndexVe = new (std::nothrow) _VisualElement();
1276         SysTryCatch(NID_UI_CTRL, __pSelectedIndexVe, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
1277
1278         r = __pSelectedIndexVe->Construct();
1279         SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to construct the selected index ve.", GetErrorMessage(r));
1280
1281         __pSelectedIndexVe->SetAnimationProvider(this);
1282
1283         r = __pSelectedIndexVe->SetSurfaceOpaque(false);
1284         SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to set the opaque of the selected index ve.", GetErrorMessage(r));
1285
1286         __pSelectedIndexVe->SetImplicitAnimationEnabled(false);
1287
1288         r = __pBaseIndexVe->AttachChild(*__pSelectedIndexVe);
1289         SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to attach the selected index ve to the parent.", GetErrorMessage(r));
1290
1291         __pSelectedIndexVe->SetShowState(true);
1292
1293         return E_SUCCESS;
1294
1295 CATCH:
1296         if (__pSelectedIndexVe)
1297         {
1298                 __pSelectedIndexVe->Destroy();
1299                 __pSelectedIndexVe = null;
1300         }
1301
1302         if (__pSelectedBgVe)
1303         {
1304                 __pSelectedBgVe->Destroy();
1305                 __pSelectedBgVe = null;
1306         }
1307
1308         if (__pBaseIndexVe)
1309         {
1310                 __pBaseIndexVe->Destroy();
1311                 __pBaseIndexVe = null;
1312         }
1313
1314         return r;
1315 }
1316
1317 _FastScrollPopupView::_FastScrollPopupView(_VisualElement& parentVe, _FastScrollViewConfig& viewConfig)
1318         : __parentVe(parentVe)
1319         , __viewConfig(viewConfig)
1320         , __pPopupVe(null)
1321         , __needUpdatePopupVe(false)
1322         , __needUpdatePopupIndexVe(false)
1323         , __needDestroySelf(false)
1324 {
1325 }
1326
1327 _FastScrollPopupView::~_FastScrollPopupView(void)
1328 {
1329         for (int i = 0; i < GetIndexVeCount(); i++)
1330         {
1331                 _VisualElement* pIndexVe = GetIndexVe(i);
1332
1333                 if (pIndexVe)
1334                 {
1335                         pIndexVe->RemoveAllAnimations();
1336                         pIndexVe->SetAnimationProvider(null);
1337                         pIndexVe->Destroy();
1338                 }
1339         }
1340         __indexViews.RemoveAll(false);
1341
1342         if (__pPopupVe)
1343         {
1344                 __pPopupVe->RemoveAllAnimations();
1345                 __pPopupVe->SetAnimationProvider(null);
1346
1347                 __pPopupVe->Destroy();
1348                 __pPopupVe = null;
1349         }
1350 }
1351
1352 _FastScrollPopupView*
1353 _FastScrollPopupView::CreateFastScrollPopupViewN(_VisualElement& parentVe, _FastScrollViewConfig& viewConfig)
1354 {
1355         _FastScrollPopupView* pPopupView = new (std::nothrow) _FastScrollPopupView(parentVe, viewConfig);
1356         SysTryReturn(NID_UI_CTRL, pPopupView, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
1357
1358         result r = pPopupView->Construct();
1359         SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
1360
1361         SetLastResult(E_SUCCESS);
1362         return pPopupView;
1363
1364 CATCH:
1365         delete pPopupView;
1366
1367         return null;
1368 }
1369
1370 result
1371 _FastScrollPopupView::FadeOutAndDestroy(void)
1372 {
1373         __needDestroySelf = true;
1374
1375         for (int i = 0; i < GetIndexVeCount(); i++)
1376         {
1377                 _VisualElement* pIndexVe = GetIndexVe(i);
1378                 SysTryReturnResult(NID_UI_CTRL, pIndexVe, GetLastResult(), "Failed to get the popup index view.");
1379
1380                 pIndexVe->RemoveAllAnimations();
1381         }
1382
1383         return SetPopupVisibility(false);
1384 }
1385
1386 result
1387 _FastScrollPopupView::SelectIndex(int indexLevel, _FastScrollIndex* pIndex, _FastScrollIndex* pFormerIndex)
1388 {
1389         _VisualElement* pIndexVe = GetIndexVe(indexLevel);
1390         SysTryReturnResult(NID_UI_CTRL, pIndexVe, GetLastResult(), "Failed to get the popup index view.");
1391
1392         if (pIndex)
1393         {
1394                 pIndexVe->SetOpacity(FASTSCROLL_OPACITY_ON);
1395                 FloatRectangle popupVeBounds = __pPopupVe->GetBounds();
1396                 FloatMatrix4 popupVeMatrix;
1397                 popupVeMatrix.SetAsIdentity();
1398
1399                 if (pFormerIndex && (pFormerIndex != pIndex))
1400                 {
1401                         FloatRectangle popupIndexVeBounds = pIndexVe->GetBounds();
1402
1403                         int selectedOrder = pIndex->GetIndexOrder(false);
1404                         int oldOrder = pFormerIndex->GetIndexOrder(false);
1405
1406                         if (selectedOrder > oldOrder)
1407                         {
1408                                 _MatrixUtilTranslate(popupVeMatrix, 0, 0, 0);
1409                         }
1410                         else
1411                         {
1412                                 _MatrixUtilTranslate(popupVeMatrix, 0, -(popupVeBounds.height * (FASTSCROLL_POPUPINDEX_COUNT - 1)), 0);
1413                         }
1414                         pIndexVe->SetTransformMatrix(popupVeMatrix);
1415                         pIndexVe->SetImplicitAnimationEnabled(true);
1416
1417                         popupVeMatrix.SetAsIdentity();
1418                         _MatrixUtilTranslate(popupVeMatrix, 0, -popupVeBounds.height, 0);
1419                         pIndexVe->SetTransformMatrix(popupVeMatrix);
1420
1421                         pIndexVe->SetImplicitAnimationEnabled(false);
1422                 }
1423                 else
1424                 {
1425                         _MatrixUtilTranslate(popupVeMatrix, 0, -popupVeBounds.height, 0);
1426                         pIndexVe->SetTransformMatrix(popupVeMatrix);
1427                 }
1428         }
1429         else
1430         {
1431                 pIndexVe->SetOpacity(FASTSCROLL_OPACITY_LIGHT_DIM);
1432         }
1433
1434         return E_SUCCESS;
1435 }
1436
1437 result
1438 _FastScrollPopupView::AddPopupIndexVe(int indexLevel)
1439 {
1440         result r = E_SUCCESS;
1441         _VisualElement* pPopupIndexVe = new (std::nothrow) _VisualElement();
1442         SysTryCatch(NID_UI_CTRL, pPopupIndexVe, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
1443
1444         r = pPopupIndexVe->Construct();
1445         SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to construct the popup index ve.", GetErrorMessage(r));
1446
1447         pPopupIndexVe->SetAnimationProvider(this);
1448
1449         r = pPopupIndexVe->SetSurfaceOpaque(false);
1450         SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to set the opaque of the popup index ve.", GetErrorMessage(r));
1451
1452         pPopupIndexVe->SetImplicitAnimationEnabled(false);
1453
1454         r = __pPopupVe->AttachChild(*pPopupIndexVe);
1455         SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to attach the popup index ve to the popup ve.", GetErrorMessage(r));
1456
1457         pPopupIndexVe->SetShowState(true);
1458
1459         r = __indexViews.InsertAt(*pPopupIndexVe, indexLevel);
1460         SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to change the last index view.", GetErrorMessage(r));
1461
1462         return E_SUCCESS;
1463
1464 CATCH:
1465         if (pPopupIndexVe)
1466         {
1467                 pPopupIndexVe->RemoveAllAnimations();
1468                 pPopupIndexVe->SetAnimationProvider(null);
1469
1470                 pPopupIndexVe->Destroy();
1471         }
1472
1473         return r;
1474 }
1475
1476 result
1477 _FastScrollPopupView::RemovePopupIndexVe(int indexLevel)
1478 {
1479         result r = E_SUCCESS;
1480
1481         if (indexLevel < GetIndexVeCount())
1482         {
1483                 _VisualElement* pIndexVe = GetIndexVe(indexLevel);
1484                 SysTryReturnResult(NID_UI_CTRL, pIndexVe, GetLastResult(), "Failed to get the popup index ve.");
1485
1486                 r = __indexViews.Remove(*pIndexVe, false);
1487                 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Failed to remove the popup index ve.");
1488
1489                 pIndexVe->RemoveAllAnimations();
1490                 pIndexVe->SetAnimationProvider(null);
1491                 pIndexVe->Destroy();
1492         }
1493
1494         return E_SUCCESS;
1495 }
1496
1497 result
1498 _FastScrollPopupView::SetPopupBounds(const Rectangle& indexBounds)
1499 {
1500         SysTryReturnResult(NID_UI_CTRL, __pPopupVe, E_INVALID_STATE, "__pPopupVe must not be null.");
1501
1502         FloatRectangle veBounds(indexBounds.x, indexBounds.y, indexBounds.width, indexBounds.height);
1503         __pPopupVe->SetBounds(veBounds);
1504
1505         return E_SUCCESS;
1506 }
1507
1508 Rectangle
1509 _FastScrollPopupView::GetPopupBounds(void) const
1510 {
1511         SysTryReturn(NID_UI_CTRL, __pPopupVe, Rectangle(0, 0, 0, 0), E_INVALID_STATE,
1512                         "[E_INVALID_STATE] __pPopupVe must not be null.");
1513
1514         FloatRectangle veBounds = __pPopupVe->GetBounds();
1515         return Rectangle(veBounds.x, veBounds.y, veBounds.width, veBounds.height);
1516 }
1517
1518 result
1519 _FastScrollPopupView::SetPopupIndexBounds(int indexLevel, const _FastScrollIndex* pBaseIndex)
1520 {
1521         FloatRectangle veBounds = __pPopupVe->GetBounds();
1522         _VisualElement* pIndexVe = GetIndexVe(indexLevel);
1523         SysTryReturnResult(NID_UI_CTRL, pIndexVe, GetLastResult(), "Failed to get the popup index view.");
1524
1525         if (pBaseIndex)
1526         {
1527                 veBounds.x = 0;
1528                 veBounds.y = 0;
1529                 veBounds.height = veBounds.height * FASTSCROLL_POPUPINDEX_COUNT;
1530         }
1531
1532         int indexVeCount = GetIndexVeCount();
1533         int indexWidth = veBounds.width;
1534         if (indexVeCount > 0)
1535         {
1536                 indexWidth /= indexVeCount;
1537         }
1538
1539         veBounds.width = indexWidth;
1540         veBounds.x = veBounds.width * indexLevel;
1541
1542         pIndexVe->SetBounds(veBounds);
1543
1544         return E_SUCCESS;
1545 }
1546
1547 Rectangle
1548 _FastScrollPopupView::GetPopupIndexBounds(int indexLevel) const
1549 {
1550         _VisualElement* pIndexVe = GetIndexVe(indexLevel);
1551         SysTryReturn(NID_UI_CTRL, pIndexVe, Rectangle(0, 0, 0, 0), GetLastResult(), "[%s] Failed to get the popup index view.",
1552                                 GetErrorMessage(GetLastResult()));
1553
1554         FloatRectangle veBounds = pIndexVe->GetBounds();
1555         return Rectangle(veBounds.x, veBounds.y, veBounds.width, veBounds.height);
1556 }
1557
1558 _VisualElement*
1559 _FastScrollPopupView::GetIndexVe(int indexLevel) const
1560 {
1561         Object* pObj = const_cast<Object*>(__indexViews.GetAt(indexLevel));
1562         SysTryReturn(NID_UI_CTRL, pObj, null, GetLastResult(), "[%s] Failed to get the popup index ve.",
1563                         GetErrorMessage(GetLastResult()));
1564
1565         return dynamic_cast<_VisualElement*>(pObj);
1566 }
1567
1568 int
1569 _FastScrollPopupView::GetIndexVeCount(void) const
1570 {
1571         return __indexViews.GetCount();
1572 }
1573
1574 bool
1575 _FastScrollPopupView::IsOnAnimation(void) const
1576 {
1577         return false;
1578 }
1579
1580 void
1581 _FastScrollPopupView::RemoveAllAnimations(void)
1582 {
1583         SysTryReturnVoidResult(NID_UI_CTRL, __pPopupVe, E_INVALID_STATE, "[E_INVALID_STATE] __pPopupVe must not be null.");
1584         __pPopupVe->RemoveAllAnimations();
1585 }
1586
1587 result
1588 _FastScrollPopupView::SetPopupVisibility(bool visibility)
1589 {
1590         SysTryReturnResult(NID_UI_CTRL, __pPopupVe, E_INVALID_STATE, "__pPopupVe must not be null.");
1591
1592         if (visibility)
1593         {
1594                 __pPopupVe->SetTransformMatrix(__matrixFadeInStart);
1595                 __pPopupVe->SetImplicitAnimationEnabled(true);
1596                 __pPopupVe->SetOpacity(FASTSCROLL_OPACITY_ON);
1597                 __pPopupVe->SetTransformMatrix(__matrixOrigin);
1598                 __pPopupVe->SetImplicitAnimationEnabled(false);
1599         }
1600         else
1601         {
1602                 __pPopupVe->SetImplicitAnimationEnabled(true);
1603                 __pPopupVe->SetOpacity(FASTSCROLL_OPACITY_OFF);
1604                 __pPopupVe->SetTransformMatrix(__matrixFadeOutEnd);
1605                 __pPopupVe->SetImplicitAnimationEnabled(false);
1606         }
1607         // else keep up current visibility.
1608
1609         return E_SUCCESS;
1610 }
1611
1612 bool
1613 _FastScrollPopupView::GetPopupVisibility(void) const
1614 {
1615         SysTryReturn(NID_UI_CTRL, __pPopupVe, false, E_INVALID_STATE, "[E_INVALID_STATE] __pPopupVe must not be null.");
1616
1617         float opacity = __pPopupVe->GetOpacity();
1618         if (opacity > FASTSCROLL_OPACITY_OFF)
1619         {
1620                 return true;
1621         }
1622
1623         return false;
1624 }
1625
1626 void
1627 _FastScrollPopupView::SetPopupVeUpdateNeeded(bool needUpdate)
1628 {
1629         __needUpdatePopupIndexVe = needUpdate;
1630 }
1631
1632 result
1633 _FastScrollPopupView::UpdateIndex(void)
1634 {
1635         SysTryReturnResult(NID_UI_CTRL, __pPopupVe, E_INVALID_STATE, "__pPopupVe must not be null.");
1636
1637         result r = E_SUCCESS;
1638
1639         r = __parentVe.InvalidateRectangle(null);
1640         SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Failed to invaildate the popup Ve.");
1641
1642         __needUpdatePopupIndexVe = true;
1643
1644         return E_SUCCESS;
1645 }
1646
1647 void
1648 _FastScrollPopupView::DrawPopupVe(void)
1649 {
1650         if (!__needUpdatePopupVe)
1651         {
1652                 return;
1653         }
1654
1655         SysTryReturnVoidResult(NID_UI_CTRL, __pPopupVe, E_INVALID_STATE, "[E_INVALID_STATE] __pPopupVe must not be null.");
1656
1657         Canvas* pCanvas = __pPopupVe->GetCanvasN();
1658         SysTryReturnVoidResult(NID_UI_CTRL, pCanvas, GetLastResult(), "[%s] Failed to get the canvas of the popup ve.",
1659                         GetErrorMessage(GetLastResult()));
1660
1661         Rectangle bounds = GetPopupBounds();
1662         bounds.SetPosition(0, 0);
1663
1664         pCanvas->SetBackgroundColor(Color(0, 0, 0, 0));
1665         pCanvas->Clear();
1666
1667         if (__viewConfig.__pPopupBgEffectBitmap)
1668         {
1669                 DrawBitmap(*pCanvas, bounds, *__viewConfig.__pPopupBgEffectBitmap);
1670         }
1671
1672         if (__viewConfig.__pPopupBgBitmap)
1673         {
1674                 Bitmap* pReplacementColorBackgroundBitmap = null;
1675                 pReplacementColorBackgroundBitmap =
1676                                 _BitmapImpl::GetColorReplacedBitmapN(*__viewConfig.__pPopupBgBitmap, Color::GetColor(COLOR_ID_MAGENTA), __viewConfig.__popupBgColor);
1677                 DrawBitmap(*pCanvas, bounds, *pReplacementColorBackgroundBitmap);
1678
1679                 delete pReplacementColorBackgroundBitmap;
1680         }
1681
1682         delete pCanvas;
1683
1684         __needUpdatePopupVe = false;
1685 }
1686
1687
1688 void
1689 _FastScrollPopupView::DrawPopupIndexVe(int indexLevel, const _FastScrollIndex* pBaseIndex, const _FastScrollIndex* pSelectedIndex)
1690 {
1691         if (__needUpdatePopupIndexVe != true)
1692         {
1693                 return;
1694         }
1695
1696         SysTryReturnVoidResult(NID_UI_CTRL, pBaseIndex, E_INVALID_STATE, "[E_INVALID_STATE] pBaseIndex must not be null.");
1697         SysTryReturnVoidResult(NID_UI_CTRL, pSelectedIndex, E_INVALID_STATE, "[E_INVALID_STATE] pBaseIndex must not be null.");
1698
1699         result r = E_SUCCESS;
1700
1701         int childCount = pBaseIndex->GetChildCount();
1702         SysTryReturnVoidResult(NID_UI_CTRL, childCount > 0, E_INVALID_STATE, "[E_INVALID_STATE] The index have no children.");
1703
1704         _VisualElement* pIndexVe = GetIndexVe(indexLevel);
1705         SysTryReturnVoidResult(NID_UI_CTRL, pIndexVe, GetLastResult(), "[%s] Failed to get the popup index ve.",
1706                                 GetErrorMessage(GetLastResult()));
1707
1708         Canvas* pCanvas = pIndexVe->GetCanvasN();
1709         SysTryReturnVoidResult(NID_UI_CTRL, pCanvas, GetLastResult(), "[%s] Failed to get the canvas of the popup index ve.",
1710                         GetErrorMessage(GetLastResult()));
1711
1712         pCanvas->SetBackgroundColor(Color(0, 0, 0, 0));
1713         pCanvas->Clear();
1714
1715         FloatRectangle veBounds = pIndexVe->GetBounds();
1716         Rectangle bounds(veBounds.x, veBounds.y, veBounds.width, veBounds.height);
1717
1718         int indexHeight = bounds.height / FASTSCROLL_POPUPINDEX_COUNT;
1719         indexHeight = MAX(__viewConfig.__popupTextSize, indexHeight);
1720
1721         Rectangle indexRect(0, 0, bounds.width, indexHeight);
1722         int selectedOrder = pSelectedIndex->GetIndexOrder(false);
1723         Bitmap* pReplacementColorBitmap = null;
1724
1725         TextObject* pTextObject = new (std::nothrow) TextObject();
1726         SysTryCatch(NID_UI_CTRL, pTextObject, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
1727
1728         pTextObject->Construct();
1729
1730         for (int i = -1; i < 2; i++)
1731         {
1732                 TextSimple* pSimpleText = null;
1733
1734                 _FastScrollIndex* pChildIndex = pBaseIndex->GetChildIndex(selectedOrder + i);
1735                 if (pChildIndex)
1736                 {
1737                         Bitmap* pChildIndexImage = pChildIndex->GetIndexImage();
1738                         if (pChildIndexImage)
1739                         {
1740                                 Rectangle imageRect = indexRect;
1741                                 float widthScale = (float)indexRect.width / pChildIndexImage->GetWidth();
1742                                 int rectHeight = MIN(indexRect.height, __viewConfig.__popupTextSize);
1743                                 float heightScale = (float)rectHeight / pChildIndexImage->GetHeight();
1744                                 float scaleFactor = MIN(widthScale, heightScale);
1745
1746                                 imageRect.width = pChildIndexImage->GetWidth() * scaleFactor;
1747                                 imageRect.height = pChildIndexImage->GetHeight() * scaleFactor;
1748
1749                                 if (indexRect.width - imageRect.width > 0)
1750                                 {
1751                                         imageRect.x = indexRect.x + (indexRect.width - imageRect.width)/2;
1752                                 }
1753
1754                                 if (indexRect.height - imageRect.height > 0)
1755                                 {
1756                                         imageRect.y = indexRect.y + (indexRect.height - imageRect.height)/2;
1757                                 }
1758
1759                                 pReplacementColorBitmap =
1760                                         _BitmapImpl::GetColorReplacedBitmapN(*pChildIndexImage,
1761                                                         Color::GetColor(COLOR_ID_MAGENTA), __viewConfig.__popupTextColor);
1762                                 r = DrawBitmap(*pCanvas, imageRect, *pReplacementColorBitmap,
1763                                                 Rectangle(0, 0, pChildIndexImage->GetWidth(), pChildIndexImage->GetHeight()));
1764                                 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to draw a bitmap.", GetErrorMessage(r));
1765
1766                                 delete pReplacementColorBitmap;
1767                                 pReplacementColorBitmap = null;
1768                         }
1769                         else
1770                         {
1771                                 String* pChildIndexText = pChildIndex->GetIndexText();
1772                                 SysTryCatch(NID_UI_CTRL, pChildIndexText, , E_INVALID_STATE, "[E_INVALID_STATE] pChildIndexText must not be null.");
1773
1774                                 pTextObject->RemoveAll();
1775
1776                                 pSimpleText = new (std::nothrow)TextSimple(const_cast<wchar_t*>(pChildIndexText->GetPointer()), pChildIndexText->GetLength(), TEXT_ELEMENT_SOURCE_TYPE_EXTERNAL);
1777                                 SysTryCatch(NID_UI_CTRL, pSimpleText, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
1778
1779                                 r = pTextObject->AppendElement(*pSimpleText);
1780                                 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to append simple text.", GetErrorMessage(r));
1781
1782                                 r = pTextObject->SetWrap(TEXT_OBJECT_WRAP_TYPE_WORD);
1783                                 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to set wrap.", GetErrorMessage(r));
1784
1785                                 r = pTextObject->SetFont(__viewConfig.__pFont, 0, pTextObject->GetTextLength());
1786                                 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to set font.", GetErrorMessage(r));
1787
1788                                 r = pTextObject->SetForegroundColor(__viewConfig.__popupTextColor, 0, pTextObject->GetTextLength());
1789                                 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to set foreground color.", GetErrorMessage(r));
1790
1791                                 r = pTextObject->SetAlignment(TEXT_OBJECT_ALIGNMENT_CENTER | TEXT_OBJECT_ALIGNMENT_MIDDLE);
1792                                 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to set alignment.", GetErrorMessage(r));
1793
1794                                 r = pTextObject->SetBounds(indexRect);
1795                                 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to set bounds of pTextObject.", GetErrorMessage(r));
1796
1797                                 r = pTextObject->Draw(*_CanvasImpl::GetInstance(*pCanvas));
1798                                 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to draw text.", GetErrorMessage(r));
1799                         }
1800                 }
1801
1802                 indexRect.y += indexHeight;
1803         }
1804
1805         //fall through
1806 CATCH:
1807         delete pTextObject;
1808         delete pCanvas;
1809         delete pReplacementColorBitmap;
1810 }
1811
1812 void
1813 _FastScrollPopupView::OnDraw(int indexLevel, const _FastScrollIndex* pBaseIndex, const _FastScrollIndex* pSelectedIndex)
1814 {
1815         DrawPopupVe();
1816         DrawPopupIndexVe(indexLevel, pBaseIndex, pSelectedIndex);
1817 }
1818
1819 result
1820 _FastScrollPopupView::DrawBitmap(Canvas& canvas, const Rectangle& bounds, const Bitmap& bitmap)
1821 {
1822         result r = E_SUCCESS;
1823         if (bitmap.IsNinePatchedBitmap())
1824         {
1825                 r = canvas.DrawNinePatchedBitmap(bounds, bitmap);
1826                 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Failed to draw ninepathced bitmap");
1827         }
1828         else
1829         {
1830                 r = canvas.DrawBitmap(bounds, bitmap);
1831                 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Failed to draw bitmap");
1832         }
1833
1834         return E_SUCCESS;
1835 }
1836
1837 result
1838 _FastScrollPopupView::DrawBitmap(Canvas& canvas, const Rectangle& srcRect, const Bitmap& bitmap, const Rectangle& dstRect)
1839 {
1840         result r = E_SUCCESS;
1841         if (bitmap.IsNinePatchedBitmap())
1842         {
1843                 r = canvas.DrawNinePatchedBitmap(srcRect, bitmap);
1844                 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Failed to draw ninepathced bitmap");
1845         }
1846         else
1847         {
1848                 r = canvas.DrawBitmap(srcRect, bitmap, dstRect);
1849                 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Failed to draw bitmap");
1850         }
1851
1852         return E_SUCCESS;
1853 }
1854
1855 VisualElementAnimation*
1856 _FastScrollPopupView::CreateAnimationForProperty(VisualElement& target, const String& property)
1857 {
1858         VisualElementAnimation* pAnimation = VisualElementAnimationProvider::CreateAnimationForProperty(target, property);
1859
1860         if (pAnimation)
1861         {
1862                 const IVisualElementAnimationTimingFunction* pTimingFunction = VisualElementAnimation::GetTimingFunctionByName("EaseInOut");
1863                 if (pTimingFunction)
1864                 {
1865                         pAnimation->SetTimingFunction(pTimingFunction);
1866                 }
1867                 pAnimation->SetVisualElementAnimationStatusEventListener(this);
1868         }
1869         return pAnimation;
1870 }
1871
1872 void
1873 _FastScrollPopupView::OnVisualElementAnimationStarted(const VisualElementAnimation& animation, const String& keyName, VisualElement& target)
1874 {
1875 }
1876
1877 void
1878 _FastScrollPopupView::OnVisualElementAnimationRepeated(const VisualElementAnimation& animation, const String& keyName, VisualElement& target, long currentRepeatCount)
1879 {
1880 }
1881
1882 void
1883 _FastScrollPopupView::OnVisualElementAnimationFinished(const VisualElementAnimation& animation, const String& keyName, VisualElement& target, bool completedNormally)
1884 {
1885         SysTryReturnVoidResult(NID_UI_CTRL, __pPopupVe, E_INVALID_STATE, "[E_INVALID_STATE] The popup Ve must not be null.");
1886         if (__pPopupVe == (static_cast <_VisualElement*>(&target)))
1887         {
1888                 if (__needDestroySelf && completedNormally)
1889                 {
1890                         for (int i = 0; i < GetIndexVeCount(); i++)
1891                         {
1892                                 _VisualElement* pIndexVe = GetIndexVe(i);
1893                                 if (pIndexVe)
1894                                 {
1895                                         pIndexVe->RemoveAllAnimations();
1896                                         pIndexVe->SetAnimationProvider(null);
1897                                 }
1898                         }
1899
1900                         __pPopupVe->RemoveAllAnimations();
1901                         __pPopupVe->SetAnimationProvider(null);
1902
1903                         delete this;
1904                 }
1905         }
1906 }
1907
1908 result
1909 _FastScrollPopupView::Construct(void)
1910 {
1911         result r = E_SUCCESS;
1912
1913         __pPopupVe = new (std::nothrow) _VisualElement();
1914         SysTryCatch(NID_UI_CTRL, __pPopupVe, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
1915
1916         r = __pPopupVe->Construct();
1917         SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to construct the popup ve.", GetErrorMessage(r));
1918
1919         __pPopupVe->SetAnimationProvider(this);
1920
1921         r = __pPopupVe->SetSurfaceOpaque(false);
1922         SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to set the opaque of the popup ve.", GetErrorMessage(r));
1923
1924         __pPopupVe->SetImplicitAnimationEnabled(false);
1925
1926         r = __parentVe.AttachChild(*__pPopupVe);
1927         SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to attach the popup ve to the parent.", GetErrorMessage(r));
1928
1929         __pPopupVe->SetShowState(true);
1930         __pPopupVe->SetClipChildrenEnabled(true);
1931         __pPopupVe->SetOpacity(FASTSCROLL_OPACITY_OFF);
1932
1933         __needUpdatePopupVe = true;
1934
1935         __matrixOrigin.SetAsIdentity();
1936         __matrixFadeInStart.SetAsIdentity();
1937         __matrixFadeOutEnd.SetAsIdentity();
1938
1939         _MatrixUtilScale(__matrixFadeInStart, 0.8, 0.8, 1);
1940         _MatrixUtilScale(__matrixFadeOutEnd, 0.1, 0.1, 1);
1941
1942         return E_SUCCESS;
1943
1944 CATCH:
1945         if (__pPopupVe)
1946         {
1947                 __pPopupVe->Destroy();
1948                 __pPopupVe = null;
1949         }
1950
1951         return r;
1952 }
1953
1954 _FastScrollPresenter::_FastScrollPresenter(_Control& parentCtrl, _FastScroll& fastScroll, bool visibility)
1955         : __parentCtrl(parentCtrl)
1956         , __fastScroll(fastScroll)
1957         , __pCtrlVe(null)
1958         , __pViewConfig(null)
1959         , __pFastScrollEvent(null)
1960         , __pFastScrollModel(null)
1961         , __fontStyle(0)
1962         , __fontSize(0)
1963         , __pPopupView(null)
1964         , __focusedIndexLevel(0)
1965         , __pSelectedIndex(null)
1966         , __enableFadeEffect(true)
1967         , __indexCountMax(0)
1968         , __fadeIn(false)
1969         , __fadeOut(false)
1970         , __scrollVisibility(visibility)
1971         , __fadeEffectDuration_ms(500)
1972 {
1973 }
1974
1975 _FastScrollPresenter::~_FastScrollPresenter(void)
1976 {
1977         delete __pFastScrollEvent;
1978         __pFastScrollEvent = null;
1979
1980         delete __pFastScrollModel;
1981         __pFastScrollModel = null;
1982
1983         delete __pPopupView;
1984         __pPopupView = null;
1985
1986         RemoveAllIndexViews(false);
1987
1988         delete __pViewConfig;
1989         __pViewConfig = null;
1990
1991         if (__pCtrlVe)
1992         {
1993                 __pCtrlVe->RemoveAllAnimations();
1994                 __pCtrlVe->SetAnimationProvider(null);
1995         }
1996 }
1997
1998 _FastScrollPresenter*
1999 _FastScrollPresenter::CreateFastScrollPresenterN(_Control& parentCtrl, _FastScroll& fastScroll, bool visibility)
2000 {
2001         _FastScrollPresenter* pPresenter = new (std::nothrow) _FastScrollPresenter(parentCtrl, fastScroll, visibility);
2002         SysTryReturn(NID_UI_CTRL, pPresenter, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
2003
2004         result r = pPresenter->Construct();
2005         SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
2006
2007         return pPresenter;
2008
2009 CATCH:
2010         delete pPresenter;
2011
2012         return null;
2013 }
2014
2015 result
2016 _FastScrollPresenter::SetRootIndex(_FastScrollIndex* pIndex)
2017 {
2018         result r = E_SUCCESS;
2019
2020         // initialize index views
2021         RemoveAllIndexViews(false);
2022
2023         // initialize the popup view
2024         if (__pPopupView)
2025         {
2026                 r = __pPopupView->SetPopupVisibility(false);
2027                 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Failed to clear visibility of the popup view.");
2028         }
2029
2030         r = SetFontInfo(FONT_STYLE_PLAIN, __pViewConfig->__indexTextSize);
2031         SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Failed to set font.");
2032
2033         // set the root index into _FastScrollModel
2034         r = __pFastScrollModel->SetRootIndex(pIndex);
2035         SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Failed to set the root index into _FastScrollModel");
2036
2037         // add new root index view.
2038         if (pIndex)
2039         {
2040                 r = AddIndexView(0, *pIndex);
2041                 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Failed to add the root index view.");
2042         }
2043
2044         return E_SUCCESS;
2045 }
2046
2047 _FastScrollIndex*
2048 _FastScrollPresenter::GetRootIndex(void) const
2049 {
2050         return __pFastScrollModel->GetRootIndex();
2051 }
2052
2053 result
2054 _FastScrollPresenter::UpdateIndex(void)
2055 {
2056         result r = E_SUCCESS;
2057
2058         // update the base index of index views
2059         int indexViewCount = GetIndexViewCount();
2060         for (int i = 0; i < indexViewCount; i++)
2061         {
2062                 _FastScrollIndexView* pIndexView = GetIndexView(i);
2063                 SysTryReturnResult(NID_UI_CTRL, pIndexView, GetLastResult(), "Failed to get the index view.");
2064
2065                 _FastScrollIndex* pIndex = pIndexView->GetBaseIndex();
2066
2067                 if ((pIndex->GetChildCount() > __indexCountMax) && (pIndex->GetIndexType() != FAST_SCROLL_INDEX_TYPE_OMISSION))
2068                 {
2069                         r = pIndex->SetOmissionIndex(__indexCountMax);
2070                         SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Failed to set omiited index.");
2071                 }
2072
2073                 r = pIndexView->UpdateIndex(true);
2074                 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Failed to update the index view.");
2075         }
2076
2077         // update the base index of the popup view
2078         if (__pPopupView)
2079         {
2080                 r = __pPopupView->UpdateIndex();
2081                 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Failed to update the popup view.");
2082         }
2083
2084         return E_SUCCESS;
2085 }
2086
2087 void
2088 _FastScrollPresenter::EnableFadeEffect(bool enable)
2089 {
2090         __enableFadeEffect = enable;
2091 }
2092
2093 bool
2094 _FastScrollPresenter::IsEnabledFadeEffect(void) const
2095 {
2096         return __enableFadeEffect;
2097 }
2098
2099 bool
2100 _FastScrollPresenter::IsOnFadeEffect(void) const
2101 {
2102         return (__fadeIn || __fadeOut);
2103 }
2104
2105 bool
2106 _FastScrollPresenter::IsScrollVisible(void) const
2107 {
2108         return (__fadeIn || __fadeOut || __scrollVisibility);
2109 }
2110
2111 result
2112 _FastScrollPresenter::SetScrollVisibility(bool visibility)
2113 {
2114         result r = E_SUCCESS;
2115
2116         if (GetScrollVisibility() == visibility)
2117         {
2118                 // keep up current visibility.
2119                 return E_SUCCESS;
2120         }
2121
2122         __pCtrlVe->RemoveAllAnimations();
2123         if (visibility)
2124         {
2125                 if (__enableFadeEffect)
2126                 {
2127                         __fadeIn = true;
2128                         __fadeOut = false;
2129
2130                         __pCtrlVe->SetImplicitAnimationEnabled(true);
2131                 }
2132
2133                 __pCtrlVe->SetOpacity(FASTSCROLL_OPACITY_ON);
2134
2135                 if (__enableFadeEffect)
2136                 {
2137                         __pCtrlVe->SetImplicitAnimationEnabled(false);
2138                 }
2139                 else
2140                 {
2141                         __fadeIn = false;
2142                         __fadeOut = false;
2143                 }
2144         }
2145         else
2146         {
2147                 if (__enableFadeEffect)
2148                 {
2149                         __fadeIn = false;
2150                         __fadeOut = true;
2151
2152                         __pCtrlVe->SetImplicitAnimationEnabled(true);
2153                 }
2154
2155                 __pCtrlVe->SetOpacity(FASTSCROLL_OPACITY_OFF);
2156
2157                 if (__enableFadeEffect)
2158                 {
2159                         __pCtrlVe->SetImplicitAnimationEnabled(false);
2160                 }
2161                 else
2162                 {
2163                         __fadeIn = false;
2164                         __fadeOut = false;
2165                 }
2166         }
2167
2168         __scrollVisibility = visibility;
2169
2170         return  r;
2171 }
2172
2173 bool
2174 _FastScrollPresenter::GetScrollVisibility(void) const
2175 {
2176         float opacity = __pCtrlVe->GetOpacity();
2177
2178         if (__enableFadeEffect)
2179         {
2180                 if (__scrollVisibility)
2181                 {
2182                         return true;
2183                 }
2184         }
2185         else if (opacity > FASTSCROLL_OPACITY_OFF)
2186         {
2187                 return true;
2188         }
2189
2190         return false;
2191 }
2192
2193 void
2194 _FastScrollPresenter::CancelFadeEffect(void)
2195 {
2196         if (__fadeIn)
2197         {
2198                 __fadeIn = false;
2199                 __scrollVisibility = false;
2200                 __pCtrlVe->SetOpacity(FASTSCROLL_OPACITY_OFF);
2201         }
2202         else if (__fadeOut)
2203         {
2204                 __fadeOut = false;
2205                 __scrollVisibility = true;
2206                 __pCtrlVe->SetOpacity(FASTSCROLL_OPACITY_ON);
2207         }
2208 }
2209
2210 void
2211 _FastScrollPresenter::AddFastScrollEventListener(const Controls::_IUiFastScrollListener& listener)
2212 {
2213         result r = E_SUCCESS;
2214
2215         if (__pFastScrollEvent == null)
2216         {
2217                 __pFastScrollEvent = new (std::nothrow) _UiFastScrollEvent();
2218                 SysTryReturnVoidResult(NID_UI_CTRL, __pFastScrollEvent, E_OUT_OF_MEMORY,
2219                                 "[E_OUT_OF_MEMORY] Memory allocation failed.");
2220
2221                 r = __pFastScrollEvent->Construct(__fastScroll);
2222                 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
2223         }
2224
2225         r = __pFastScrollEvent->AddListener(listener);
2226         SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
2227 }
2228
2229 void
2230 _FastScrollPresenter::RemoveFastScrollEventListener(const Controls::_IUiFastScrollListener& listener)
2231 {
2232         result r = E_SUCCESS;
2233
2234         SysTryReturnVoidResult(NID_UI_CTRL, __pFastScrollEvent, E_INVALID_STATE, "[E_INVALID_STATE] __pFastScrollEvent must not be null.");
2235
2236         r = __pFastScrollEvent->RemoveListener(listener);
2237         SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
2238 }
2239
2240 result
2241 _FastScrollPresenter::AddAccessibilityElement(const _AccessibilityContainer& control, bool onAccessibility)
2242 {
2243         _FastScrollIndexView* pIndexView = GetIndexView(0);
2244         SysTryReturnResult(NID_UI_CTRL, pIndexView, GetLastResult(), "Failed to get fastscroll indexview.",
2245                         GetErrorMessage(GetLastResult()));
2246
2247         _AccessibilityContainer* pAccessibilityContainer = const_cast <_AccessibilityContainer*>(&control);
2248         result r = pAccessibilityContainer->RemoveAllElement();
2249         SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Failed to remove accessibility elements.");
2250         _AccessibilityElement* pAccessibilityElement = null;
2251
2252         if (onAccessibility)
2253         {
2254                 r = pIndexView->AddAccessibilityElement(control);
2255                 SysTryReturnResult(NID_UI_CTRL, r = E_SUCCESS, r, "Failed to Add accessibility element.");
2256         }
2257         else
2258         {
2259                 pAccessibilityElement = new (std::nothrow) _AccessibilityElement(true);
2260                 SysTryReturnResult(NID_UI_CTRL, pAccessibilityElement, E_OUT_OF_MEMORY, "Memory allocation failed.");
2261
2262                 pAccessibilityElement->SetBounds(pIndexView->GetIndexBounds());
2263                 pAccessibilityElement->SetTrait(L"Fast scroll bar");
2264                 pAccessibilityElement->SetName(L"FastScroll");
2265                 pAccessibilityElement->SetHint(L"double tap to enter fast scroll mode");
2266                 r = pAccessibilityContainer->AddElement(*pAccessibilityElement);
2267                 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to Add accessibility element.", GetErrorMessage(r));
2268         }
2269         return E_SUCCESS;
2270
2271 CATCH:
2272         delete pAccessibilityElement;
2273         return r;
2274 }
2275
2276 void
2277 _FastScrollPresenter::OnParentBoundsChanged(void)
2278 {
2279         RelayoutFastScrollChildren();
2280 }
2281
2282 void
2283 _FastScrollPresenter::OnDraw(void)
2284 {
2285         // draw index views
2286         int indexViewCount = GetIndexViewCount();
2287         for (int i = 0; i < indexViewCount; i++)
2288         {
2289                 _FastScrollIndexView* pIndexView = GetIndexView(i);
2290                 SysTryReturnVoidResult(NID_UI_CTRL, pIndexView, GetLastResult(), "[%s] Failed to get the index view.",
2291                                 GetErrorMessage(GetLastResult()));
2292
2293                 result r = SetFontInfo(FONT_STYLE_PLAIN, __pViewConfig->__indexTextSize);
2294                 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Failed to set font.", GetErrorMessage(r));
2295                 pIndexView->OnDraw();
2296
2297                 // draw the popup view
2298                 if (__pPopupView && i <= __focusedIndexLevel)
2299                 {
2300                         r = SetFontInfo(FONT_STYLE_PLAIN, __pViewConfig->__popupTextSize);
2301                         SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Failed to set font.", GetErrorMessage(r));
2302                         __pPopupView->OnDraw(i, pIndexView->GetBaseIndex(), pIndexView->GetSelectedIndexInOmittedIndex());
2303                 }
2304         }
2305
2306         if (__pPopupView)
2307         {
2308                 __pPopupView->SetPopupVeUpdateNeeded(false);
2309         }
2310 }
2311
2312 bool
2313 _FastScrollPresenter::OnTouchPressed(const _Control& source, const _TouchInfo& touchinfo)
2314 {
2315         return OnTouchPressedAndMoved(touchinfo.GetCurrentPosition(), true);
2316 }
2317
2318 bool
2319 _FastScrollPresenter::OnTouchReleased(const _Control& source, const _TouchInfo& touchinfo)
2320 {
2321         return OnTouchReleasedAndCanceled();
2322 }
2323
2324 bool
2325 _FastScrollPresenter::OnTouchMoved(const _Control& source, const _TouchInfo& touchinfo)
2326 {
2327         return OnTouchPressedAndMoved(touchinfo.GetCurrentPosition(), false);
2328 }
2329
2330 bool
2331 _FastScrollPresenter::OnTouchCanceled(const _Control& source, const _TouchInfo& touchinfo)
2332 {
2333         return OnTouchReleasedAndCanceled();
2334 }
2335
2336 void
2337 _FastScrollPresenter::OnFontChanged(Font* pFont)
2338 {
2339         __pViewConfig->__pFont = pFont;
2340 }
2341
2342 void
2343 _FastScrollPresenter::OnFontInfoRequested(unsigned long& style, int& size)
2344 {
2345         style = __fontStyle;
2346         size = __fontSize;
2347 }
2348
2349 result
2350 _FastScrollPresenter::SetFontInfo(unsigned long style, int size)
2351 {
2352         __fontStyle = style;
2353         __fontSize = size;
2354
2355         __pViewConfig->__pFont = __fastScroll.GetFallbackFont();
2356         SysTryReturnResult(NID_UI_CTRL, __pViewConfig->__pFont, GetLastResult(), "Failed to get a font.");
2357
2358         return E_SUCCESS;
2359 }
2360
2361 VisualElementAnimation*
2362 _FastScrollPresenter::CreateAnimationForProperty(VisualElement& target, const String& property)
2363 {
2364         VisualElementAnimation* pAnimation = VisualElementAnimationProvider::CreateAnimationForProperty(target, property);
2365
2366         if (pAnimation)
2367         {
2368                 const IVisualElementAnimationTimingFunction* pTimingFunction = VisualElementAnimation::GetTimingFunctionByName("EaseInOut");
2369                 if (pTimingFunction)
2370                 {
2371                         pAnimation->SetTimingFunction(pTimingFunction);
2372                 }
2373                 pAnimation->SetVisualElementAnimationStatusEventListener(this);
2374         }
2375         return pAnimation;
2376 }
2377
2378 void
2379 _FastScrollPresenter::OnVisualElementAnimationStarted(const VisualElementAnimation& animation, const String& keyName, VisualElement& target)
2380 {
2381 }
2382
2383 void
2384 _FastScrollPresenter::OnVisualElementAnimationRepeated(const VisualElementAnimation& animation, const String& keyName, VisualElement& target, long currentRepeatCount)
2385 {
2386 }
2387
2388 void
2389 _FastScrollPresenter::OnVisualElementAnimationFinished(const VisualElementAnimation& animation, const String& keyName, VisualElement& target, bool completedNormally)
2390 {
2391         if (__pCtrlVe == (static_cast <_VisualElement*>(&target)))
2392         {
2393                 __fadeIn = false;
2394                 __fadeOut = false;
2395         }
2396 }
2397
2398 HitTestResult
2399 _FastScrollPresenter::HitTest(const Tizen::Graphics::FloatPoint& point)
2400 {
2401         if (IsScrollVisible() == false)
2402         {
2403                 return HIT_TEST_NOWHERE;
2404         }
2405
2406         int indexViewCount = GetIndexViewCount();
2407         for (int i = 0; i < indexViewCount; i++)
2408         {
2409                 _FastScrollIndexView* pIndexView = GetIndexView(i);
2410                 SysTryReturn(NID_UI_CTRL, pIndexView, HIT_TEST_NOWHERE, GetLastResult(), "[%s] Failed to get the index view.",
2411                                 GetErrorMessage(GetLastResult()));
2412
2413                 Rectangle indexBounds = pIndexView->GetIndexBounds();
2414                 if (indexBounds.Contains(Point(point.x, point.y)) == true)
2415                 {
2416                         return HIT_TEST_MATCH;
2417                 }
2418         }
2419
2420         return HIT_TEST_NOWHERE;
2421 }
2422
2423 void
2424 _FastScrollPresenter::OnIndexDataUpdated(_FastScrollIndex& updatedIndex)
2425 {
2426         result r = E_SUCCESS;
2427
2428         int indexViewCount = GetIndexViewCount();
2429         for (int i = 0; i < indexViewCount; i++)
2430         {
2431                 _FastScrollIndexView* pIndexView = GetIndexView(i);
2432                 SysTryReturnVoidResult(NID_UI_CTRL, pIndexView, GetLastResult(), "[%s] Failed to get the index view.",
2433                                 GetErrorMessage(GetLastResult()));
2434
2435                 if (pIndexView->GetBaseIndex() == &updatedIndex)
2436                 {
2437                         r = pIndexView->UpdateIndex(false);
2438                         SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Failed to update index view.", GetErrorMessage(r));
2439
2440                         if (__pPopupView)
2441                         {
2442                                 r = __pPopupView->UpdateIndex();
2443                                 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Failed to update the popup view.", GetErrorMessage(r));
2444                         }
2445                         break;
2446                 }
2447         }
2448 }
2449
2450 void
2451 _FastScrollPresenter::OnIndexDeleted(_FastScrollIndex& deletedIndex)
2452 {
2453         result r = E_SUCCESS;
2454
2455         int indexViewCount = GetIndexViewCount();
2456         for (int i = 0; i < indexViewCount; i++)
2457         {
2458                 _FastScrollIndexView* pIndexView = GetIndexView(i);
2459                 SysTryReturnVoidResult(NID_UI_CTRL, pIndexView, GetLastResult(), "[%s] Failed to get the index view.",
2460                                 GetErrorMessage(GetLastResult()));
2461
2462                 if (pIndexView->GetBaseIndex() == &deletedIndex)
2463                 {
2464                         // first of all, update the base index view
2465                         if (i != 0)
2466                         {
2467                                 _FastScrollIndexView* pBaseIndexView = GetIndexView(i - 1);
2468                                 SysTryReturnVoidResult(NID_UI_CTRL, pBaseIndexView, GetLastResult(), "[%s] Failed to get the index view.",
2469                                                 GetErrorMessage(GetLastResult()));
2470
2471                                 r = pBaseIndexView->UpdateIndex(false);
2472                                 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Failed to update index view.", GetErrorMessage(r));
2473                         }
2474
2475                         // then remove the index view for detached index.
2476                         RemoveIndexView(i, true);
2477
2478                         delete __pPopupView;
2479                         __pPopupView = null;
2480
2481                         break;
2482                 }
2483                 else if (pIndexView->GetBaseIndex() == deletedIndex.GetParentIndex())
2484                 {
2485                         r = pIndexView->UpdateIndex(false);
2486                         SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Failed to update index view.", GetErrorMessage(r));
2487
2488                         r = __pPopupView->UpdateIndex();
2489                         SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Failed to update popup view.", GetErrorMessage(r));
2490                 }
2491         }
2492 }
2493
2494 void
2495 _FastScrollPresenter::OnChildIndexAttached(_FastScrollIndex& parentIndex, int attachedOrder, _FastScrollIndex& attachedIndex)
2496 {
2497         result r = E_SUCCESS;
2498
2499         int indexViewCount = GetIndexViewCount();
2500         for (int i = 0; i < indexViewCount; i++)
2501         {
2502                 _FastScrollIndexView* pIndexView = GetIndexView(i);
2503                 SysTryReturnVoidResult(NID_UI_CTRL, pIndexView, GetLastResult(), "[%s] Failed to get the index view.",
2504                                 GetErrorMessage(GetLastResult()));
2505
2506                 if (pIndexView->GetBaseIndex() == &parentIndex)
2507                 {
2508                         r = pIndexView->UpdateIndex(false);
2509                         SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Failed to update index view.", GetErrorMessage(r));
2510
2511                         r = __pPopupView->UpdateIndex();
2512                         SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Failed to update popup view.", GetErrorMessage(r));
2513                         break;
2514                 }
2515         }
2516 }
2517
2518 void
2519 _FastScrollPresenter::OnChildIndexDetached(_FastScrollIndex& parentIndex, int detachedOrder, _FastScrollIndex& detachedIndex)
2520 {
2521         result r = E_SUCCESS;
2522
2523         int indexViewCount = GetIndexViewCount();
2524         for (int i = 0; i < indexViewCount; i++)
2525         {
2526                 _FastScrollIndexView* pIndexView = GetIndexView(i);
2527                 SysTryReturnVoidResult(NID_UI_CTRL, pIndexView, GetLastResult(), "[%s] Failed to get the index view.",
2528                                 GetErrorMessage(GetLastResult()));
2529
2530                 if (pIndexView->GetBaseIndex() == &detachedIndex)
2531                 {
2532                         // first of all, update the base index view
2533                         if (i != 0)
2534                         {
2535                                 _FastScrollIndexView* pBaseIndexView = GetIndexView(i - 1);
2536                                 SysTryReturnVoidResult(NID_UI_CTRL, pBaseIndexView, GetLastResult(), "[%s] Failed to get the index view.",
2537                                                 GetErrorMessage(GetLastResult()));
2538
2539                                 r = pBaseIndexView->UpdateIndex(false);
2540                                 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Failed to update index view.", GetErrorMessage(r));
2541                         }
2542
2543                         // then remove the index view for detached index.
2544                         RemoveIndexView(i, true);
2545
2546                         delete __pPopupView;
2547                         __pPopupView = null;
2548                         break;
2549                 }
2550                 else if (pIndexView->GetBaseIndex() == &parentIndex)
2551                 {
2552                         r = pIndexView->UpdateIndex(false);
2553                         SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Failed to update index view.", GetErrorMessage(r));
2554
2555                         r = __pPopupView->UpdateIndex();
2556                         SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Failed to update popup view.", GetErrorMessage(r));
2557                 }
2558         }
2559 }
2560
2561
2562 result
2563 _FastScrollPresenter::Construct(void)
2564 {
2565         result r = E_SUCCESS;
2566
2567         // load color/shape configuration and bitmap resources
2568         __pViewConfig = _FastScrollViewConfig::CreateFastScrollViewConfigN(_CONTROL_ORIENTATION_PORTRAIT);
2569         SysTryReturnResult(NID_UI_CTRL, __pViewConfig, GetLastResult(), "Failed to create _FastScrollViewConfig.");
2570
2571         // create _FastScrollModel
2572         __pFastScrollModel = _FastScrollModel::CreateFastScrollModelN();
2573         SysTryCatch(NID_UI_CTRL, __pFastScrollModel, , GetLastResult(), "[%s] Failed to create _FastScrollModel.",
2574                         GetErrorMessage(GetLastResult()));
2575
2576         // initialize visual elements
2577         __pCtrlVe = __fastScroll.GetVisualElement();
2578         SysTryCatch(NID_UI_CTRL, __pCtrlVe, , GetLastResult(), "[%s] Failed to get VisualElement of the _FastScroll",
2579                         GetErrorMessage(GetLastResult()));
2580
2581         __pCtrlVe->SetAnimationProvider(this);
2582         __pCtrlVe->SetClipChildrenEnabled(false);
2583
2584         if (__scrollVisibility)
2585         {
2586                 __pCtrlVe->SetOpacity(FASTSCROLL_OPACITY_ON);
2587         }
2588         else
2589         {
2590                 __pCtrlVe->SetOpacity(FASTSCROLL_OPACITY_OFF);
2591         }
2592
2593         // initialize the fastscroll control
2594         r = __fastScroll.SetBounds(CalculateFastScrollBounds(0));
2595         SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to set the bounds of _FastScroll", GetErrorMessage(r));
2596
2597         __fastScroll.SetBackgroundColor(Tizen::Graphics::Color(0, 0, 0, 0));
2598
2599         __indexCountMax = (__fastScroll.GetBounds().height - (__pViewConfig->__indexMarginTop * 2)) / __pViewConfig->__indexSizeMin.height;
2600
2601         return E_SUCCESS;
2602
2603 CATCH:
2604         delete __pFastScrollModel;
2605         __pFastScrollModel = null;
2606
2607         delete __pViewConfig;
2608         __pViewConfig = null;
2609
2610         return GetLastResult();
2611 }
2612
2613 Rectangle
2614 _FastScrollPresenter::CalculateFastScrollBounds(int indexCount)
2615 {
2616         Rectangle fastScrollBounds(0, 0, 0, 0);
2617         Rectangle parentBounds = __parentCtrl.GetBounds();
2618         fastScrollBounds.width = parentBounds.width;
2619         fastScrollBounds.height = parentBounds.height;
2620         return fastScrollBounds;
2621 }
2622
2623 Rectangle
2624 _FastScrollPresenter::CalculateIndexBounds(int indexLevel, _FastScrollIndex& pIndex)
2625 {
2626         Rectangle indexBounds(0, 0, 0, 0);
2627         Rectangle fastScrollBounds = __fastScroll.GetBounds();
2628
2629         indexBounds.x = fastScrollBounds.width;
2630         for (int i = 0; i <= indexLevel; i++)
2631         {
2632                 if ( i != 0)
2633                 {
2634                         indexBounds.x -= __pViewConfig->__indexGap;
2635                 }
2636
2637                 indexBounds.x -= __pViewConfig->__indexSizeMin.width;
2638         }
2639         indexBounds.x = MAX(indexBounds.x, 0);
2640         indexBounds.y = 0;
2641
2642         indexBounds.width = __pViewConfig->__indexSizeMin.width;
2643         indexBounds.height = fastScrollBounds.height;
2644
2645         if (indexLevel != 0)
2646         {
2647                 int childCount = pIndex.GetChildCount();
2648                 indexBounds.height = (childCount * __pViewConfig->__indexSizeMin.height) + (__pViewConfig->__indexMarginTop * 2);
2649
2650                 if (indexBounds.height < fastScrollBounds.height)
2651                 {
2652                         _FastScrollIndexView* pParentIndexView = GetIndexView(indexLevel - 1);
2653                         if (pParentIndexView)
2654                         {
2655                                 int parentIndexHeight = pParentIndexView->GetIndexHeight();
2656                                 Rectangle parentBounds = pParentIndexView->GetIndexBounds();
2657
2658                                 indexBounds.y = parentBounds.y + (pIndex.GetIndexOrder() * parentIndexHeight) - __pViewConfig->__indexMarginTop;
2659                                 indexBounds.y = MAX(indexBounds.y, fastScrollBounds.y);
2660
2661                                 if (indexBounds.y + indexBounds.height >= fastScrollBounds.height)
2662                                 {
2663                                         indexBounds.y = fastScrollBounds.height - indexBounds.height;
2664                                 }
2665                         }
2666                 }
2667                 else
2668                 {
2669                         indexBounds.height = fastScrollBounds.height;
2670                 }
2671         }
2672
2673         return indexBounds;
2674 }
2675
2676 Rectangle
2677 _FastScrollPresenter::CalculatePopupBounds(void)
2678 {
2679         Rectangle popupBounds(0, 0, 0, 0);
2680         Rectangle parentBounds = __parentCtrl.GetBounds();
2681         Rectangle fastScrollBounds = __fastScroll.GetBounds();
2682         int popupWidth = __pViewConfig->__popupSize.width + (__pViewConfig->__popupWidthIncrement * __focusedIndexLevel);
2683
2684         popupBounds.width = MIN(popupWidth, parentBounds.width);
2685         popupBounds.height = MIN(__pViewConfig->__popupSize.height, parentBounds.height);
2686
2687         popupBounds.x = (parentBounds.width - popupBounds.width) ? ((parentBounds.width - popupBounds.width)/2) : 0;
2688         popupBounds.y = (parentBounds.height - popupBounds.height) ? ((parentBounds.height - popupBounds.height)/2) : 0;
2689
2690         popupBounds.x -= fastScrollBounds.x;
2691         popupBounds.y -= fastScrollBounds.y;
2692
2693         return popupBounds;
2694 }
2695
2696 void
2697 _FastScrollPresenter::RelayoutFastScrollChildren(void)
2698 {
2699         result r = E_SUCCESS;
2700
2701         int indexViewCount = GetIndexViewCount();
2702
2703         // initialize the fastscroll control
2704         r = __fastScroll.SetBounds(CalculateFastScrollBounds(indexViewCount));
2705         SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Failed to set the bounds of _FastScroll", GetErrorMessage(r));
2706
2707         __indexCountMax = (__fastScroll.GetBounds().height - (__pViewConfig->__indexMarginTop * 2)) / __pViewConfig->__indexSizeMin.height;
2708
2709         for (int i = 0; i < indexViewCount; i++)
2710         {
2711                 _FastScrollIndexView* pIndexView = GetIndexView(i);
2712                 SysTryReturnVoidResult(NID_UI_CTRL, pIndexView, GetLastResult(), "[%s] Failed to get the index view.",
2713                                 GetErrorMessage(GetLastResult()));
2714
2715                 r = pIndexView->SetIndexBounds(CalculateIndexBounds(i, *(pIndexView->GetBaseIndex())));
2716                 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Failed to set bounds of the index.", GetErrorMessage(r));
2717
2718                 _FastScrollIndex* pIndex = pIndexView->GetBaseIndex();
2719                 if (pIndex->GetIndexType() == FAST_SCROLL_INDEX_TYPE_OMISSION)
2720                 {
2721                         r = pIndex->RemoveOmissionChildren(false);
2722                         SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Failed to remove omission index view", GetErrorMessage(r));
2723                 }
2724
2725                 if (pIndex->GetChildCount() > __indexCountMax)
2726                 {
2727                         r = pIndex->SetOmissionIndex(__indexCountMax);
2728                         SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Failed to set omission index.", GetErrorMessage(r));
2729                 }
2730
2731                 r = pIndexView->UpdateIndex(false);
2732                 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Failed to update index view.", GetErrorMessage(r));
2733         }
2734
2735         if (__pPopupView)
2736         {
2737                 r = __pPopupView->SetPopupBounds(CalculatePopupBounds());
2738                 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Failed to set bounds of the popup view.", GetErrorMessage(r));
2739         }
2740 }
2741
2742 _FastScrollIndex*
2743 _FastScrollPresenter::SelectOnIndexViews(const Point& point, bool animation)
2744 {
2745         result r = E_SUCCESS;
2746
2747         _FastScrollIndex* pSelectedIndex = null;
2748         int selectedIndexLevel = 0;
2749         int indexViewCount = GetIndexViewCount();
2750         SysTryReturn(NID_UI_CTRL, indexViewCount > 0, null, E_INVALID_STATE, "[E_INVALID_STATE] The root index view is invalid state.");
2751
2752         // search the hit index on index views, then fade out other index views
2753         for (int i = 0; i < indexViewCount; i++)
2754         {
2755                 _FastScrollIndexView* pIndexView = GetIndexView(i);
2756                 SysTryReturn(NID_UI_CTRL, pIndexView, null, GetLastResult(), "[%s] Failed to get the index view.",
2757                                 GetErrorMessage(GetLastResult()));
2758
2759                 _FastScrollIndex* pIndex = pIndexView->GetIndexAtPoint(point);
2760                 if (pIndex)
2761                 {
2762                         // select the index of the index view.
2763                         r = pIndexView->SelectIndex(pIndex, animation);
2764                         SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, null, r, "[%s] Failed to select the index.", GetErrorMessage(r));
2765                         pSelectedIndex = pIndex;
2766                         if (pIndex->GetOmitted() == true)
2767                         {
2768                                 pSelectedIndex = pIndexView->GetOmissionIndexAtPoint(pIndex, point);
2769                         }
2770                         pIndexView->SetSelectedIndexInOmittedIndex(pSelectedIndex);
2771
2772                         selectedIndexLevel = i;
2773                         break;
2774                 }
2775         }
2776
2777         // if can no find the index on views, select index of the last index view
2778         if ((pSelectedIndex == null) && (__focusedIndexLevel != -1))
2779         {
2780                 _FastScrollIndexView* pFocusedIndexView = GetIndexView(__focusedIndexLevel);
2781                 SysTryReturn(NID_UI_CTRL, pFocusedIndexView, null, GetLastResult(), "[%s] Failed to get the index view.",
2782                                 GetErrorMessage(GetLastResult()));
2783
2784                 _FastScrollIndex* pIndex = pFocusedIndexView->GetIndexAtPoint(Point(pFocusedIndexView->GetIndexBounds().x, point.y));
2785                 if (pIndex)
2786                 {
2787                         // select the index of the focused index view.
2788                         r = pFocusedIndexView->SelectIndex(pIndex, animation);
2789                         SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, null, r, "[%s] Failed to select the index.", GetErrorMessage(r));
2790                         pSelectedIndex = pIndex;
2791
2792                         if (pIndex->GetOmitted() == true)
2793                         {
2794                                 pSelectedIndex = pFocusedIndexView->GetOmissionIndexAtPoint(pIndex,
2795                                                                                 Point(pFocusedIndexView->GetIndexBounds().x, point.y));
2796                         }
2797                         pFocusedIndexView->SetSelectedIndexInOmittedIndex(pSelectedIndex);
2798
2799                         selectedIndexLevel = __focusedIndexLevel;
2800                 }
2801                 else
2802                 {
2803                         pSelectedIndex = pFocusedIndexView->GetSelectedIndex();
2804                         selectedIndexLevel = __focusedIndexLevel;
2805                 }
2806         }
2807
2808         if (pSelectedIndex)
2809         {
2810                 int childCount = pSelectedIndex->GetChildCount();
2811                 if (childCount > 0)
2812                 {
2813                         _FastScrollIndexView* pSelectedIndexView = GetIndexView(selectedIndexLevel + 1);
2814                         if (pSelectedIndexView)
2815                         {
2816                                 r = pSelectedIndexView->SelectIndex((_FastScrollIndex*)null, false);
2817                                 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, null, r, "[%s] Failed to select the index.", GetErrorMessage(r));
2818
2819                                 r = pSelectedIndexView->SetBaseIndex(pSelectedIndex);
2820                                 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, null, r, "[%s] Failed to set the base index of the index view.", GetErrorMessage(r));
2821
2822                                 r = pSelectedIndexView->SetIndexBounds(CalculateIndexBounds(selectedIndexLevel + 1, *pSelectedIndex));
2823                                 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, null, r, "[%s] Failed to set bounds of the index.", GetErrorMessage(r));
2824
2825                                 r = pSelectedIndexView->SetIndexVisibility(true);
2826                                 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, null, r, "[%s] Failed to set the visibility of the index view.", GetErrorMessage(r));
2827
2828                                 indexViewCount = GetIndexViewCount();
2829                                 while (indexViewCount > selectedIndexLevel + 2)
2830                                 {
2831                                         r = RemoveIndexView(indexViewCount - 1, true);
2832                                         SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, null, r, "[%s] Failed to remove the index view.", GetErrorMessage(r));
2833                                         indexViewCount = GetIndexViewCount();
2834                                 }
2835                         }
2836                         else
2837                         {
2838                                 r = AddIndexView(*pSelectedIndex);
2839                                 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, null, r, "[%s] Failed to add new child index.", GetErrorMessage(r));
2840                         }
2841
2842                         if ((childCount > __indexCountMax) && (pSelectedIndex->GetIndexType() != FAST_SCROLL_INDEX_TYPE_OMISSION))
2843                         {
2844                                 r = pSelectedIndex->SetOmissionIndex(__indexCountMax);
2845                                 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, null, r, "[%s] Failed to set omission index.", GetErrorMessage(r));
2846                         }
2847                 }
2848                 else
2849                 {
2850                         indexViewCount = GetIndexViewCount();
2851                         while (indexViewCount > selectedIndexLevel + 1)
2852                         {
2853                                 r = RemoveIndexView(indexViewCount - 1, true);
2854                                 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, null, r, "[%s] Failed to remove the index view.", GetErrorMessage(r));
2855                                 indexViewCount = GetIndexViewCount();
2856                         }
2857                 }
2858         }
2859         else
2860         {
2861                 indexViewCount = GetIndexViewCount();
2862                 while (indexViewCount > 1)
2863                 {
2864                         r = RemoveIndexView(indexViewCount - 1, true);
2865                         SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, null, r, "[%s] Failed to remove the index view.", GetErrorMessage(r));
2866                         indexViewCount = GetIndexViewCount();
2867                 }
2868         }
2869
2870         __focusedIndexLevel = selectedIndexLevel;
2871         return pSelectedIndex;
2872 }
2873
2874 result
2875 _FastScrollPresenter::DeselectIndexViews(void)
2876 {
2877         result r = E_SUCCESS;
2878
2879         while (GetIndexViewCount() > 1)
2880         {
2881                 RemoveIndexView(GetIndexViewCount() - 1, true);
2882         }
2883
2884         _FastScrollIndexView* pIndexView = GetIndexView(0);
2885         SysTryReturnResult(NID_UI_CTRL, pIndexView, GetLastResult(), "Failed to get the index view.");
2886
2887         r = pIndexView->SelectIndex((_FastScrollIndex*)null, true);
2888         SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Failed to clear the index selection.");
2889         pIndexView->SetSelectedIndexInOmittedIndex(null);
2890
2891         __fastScroll.Invalidate();
2892
2893         return E_SUCCESS;
2894 }
2895
2896 result
2897 _FastScrollPresenter::SetPopupIndex(_FastScrollIndex& popupIndex, const Point& point)
2898 {
2899         result r = E_SUCCESS;
2900
2901         // set the selected node into the popup views.
2902         if (__pPopupView == null)
2903         {
2904                 __pPopupView = _FastScrollPopupView::CreateFastScrollPopupViewN(*__pCtrlVe, *__pViewConfig);
2905                 SysTryReturnResult(NID_UI_CTRL, __pPopupView, GetLastResult(), "Propagating.");
2906
2907                 r = __pPopupView->SetPopupBounds(CalculatePopupBounds());
2908                 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Failed to set bounds of the popup view.");
2909
2910                 r = __pPopupView->SetPopupVisibility(true);
2911                 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Failed to set visibility of the popup view.");
2912         }
2913
2914         int indexViewCount = __focusedIndexLevel + 1;
2915         int popupIndexViewCount = __pPopupView->GetIndexVeCount();
2916
2917         if (indexViewCount != popupIndexViewCount)
2918         {
2919                 r = __pPopupView->SetPopupBounds(CalculatePopupBounds());
2920                 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Failed to set bounds of the popup view.");
2921
2922                 if (indexViewCount > popupIndexViewCount)
2923                 {
2924                         for (int i = popupIndexViewCount; i < indexViewCount; i++)
2925                         {
2926                                 r = __pPopupView->AddPopupIndexVe(i);
2927                                 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Failed to add popup index ve.");
2928                         }
2929                 }
2930                 else if (indexViewCount < popupIndexViewCount)
2931                 {
2932                         for (int i = indexViewCount; i < popupIndexViewCount; i++)
2933                         {
2934                                 r = __pPopupView->RemovePopupIndexVe(i);
2935                                 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Failed to remove popup index ve.");
2936                         }
2937                 }
2938         }
2939
2940         r = __pPopupView->UpdateIndex();
2941         SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Failed to update the popup view.");
2942
2943         for (int i = 0; i < indexViewCount; i++)
2944         {
2945                 _FastScrollIndexView* pIndexView = GetIndexView(i);
2946                 SysTryReturnResult(NID_UI_CTRL, pIndexView, r, "Failed to index view.");
2947
2948                 r = __pPopupView->SetPopupIndexBounds(i, pIndexView->GetBaseIndex());
2949                 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Failed to set bounds of the popup index ve.");
2950
2951                 _FastScrollIndex* pFormerIndex = null;
2952                 if ( i == __focusedIndexLevel )
2953                 {
2954                         pFormerIndex = pIndexView->GetFormerIndex();
2955                         r = __pPopupView->SelectIndex(i, &popupIndex, pFormerIndex);
2956                         SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Failed to select the popup index.");
2957                 }
2958                 else
2959                 {
2960                         r = __pPopupView->SelectIndex(i, null, null);
2961                         SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Failed to select the popup index.");
2962                 }
2963         }
2964
2965         return E_SUCCESS;
2966 }
2967
2968 result
2969 _FastScrollPresenter::ClearPopupIndex(void)
2970 {
2971         result r = E_SUCCESS;
2972
2973         // clear the node data of the popup view
2974         if (__pPopupView)
2975         {
2976                 r = __pPopupView->FadeOutAndDestroy();
2977                 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Failed to clear visibility of the popup view.");
2978
2979                 __pPopupView = null;
2980         }
2981
2982         return E_SUCCESS;
2983 }
2984
2985 result
2986 _FastScrollPresenter::FireFastScrollEvent(_FastScrollIndex& selectedIndex)
2987 {
2988         // fire the fast scroll event
2989         if (__pFastScrollEvent)
2990         {
2991                 String* pIndexNodeText = selectedIndex.GetIndexText();
2992                 if (pIndexNodeText)
2993                 {
2994                         _UiFastScrollEventArg* pEventArg = new (std::nothrow) _UiFastScrollEventArg(*__pFastScrollEvent->GetSource(), selectedIndex);
2995                         SysTryReturnResult(NID_UI_CTRL, pEventArg, E_OUT_OF_MEMORY,     "Memory allocation failed.");
2996
2997                         __pFastScrollEvent->Fire(*pEventArg);
2998                 }
2999         }
3000
3001         return E_SUCCESS;
3002 }
3003
3004 bool
3005 _FastScrollPresenter::OnTouchPressedAndMoved(const Point& point, bool animation)
3006 {
3007         result r = E_SUCCESS;
3008         if (__scrollVisibility == false)
3009         {
3010                 r = SetScrollVisibility(true);
3011                 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, true, r, "[%s] Failed to fade out fastscroll.", GetErrorMessage(r));
3012         }
3013
3014         _FastScrollIndex* pSelectedIndex = SelectOnIndexViews(point, animation);
3015         if (pSelectedIndex && (__pSelectedIndex != pSelectedIndex))
3016         {
3017                 r = SetPopupIndex(*pSelectedIndex, point);
3018                 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, true, r, "[%s] Failed to set the poup index.", GetErrorMessage(r));
3019
3020                 r = FireFastScrollEvent(*pSelectedIndex);
3021                 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, true, r, "[%s] Failed to send the fast scroll event.", GetErrorMessage(r));
3022         }
3023
3024         __pSelectedIndex = pSelectedIndex;
3025
3026         return true;
3027 }
3028
3029 bool
3030 _FastScrollPresenter::OnTouchReleasedAndCanceled(void)
3031 {
3032         result r = E_SUCCESS;
3033
3034         r = DeselectIndexViews();
3035         SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, true, r, "[%s] Failed to deselect index views.", GetErrorMessage(r));
3036
3037         r = ClearPopupIndex();
3038         SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, true, r, "[%s] Failed to clear the popup index.", GetErrorMessage(r));
3039
3040         if (__scrollVisibility == false)
3041         {
3042                 r = SetScrollVisibility(false);
3043                 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, true, r, "[%s] Failed to fade out fastscroll.", GetErrorMessage(r));
3044         }
3045
3046         __pSelectedIndex = null;
3047
3048         return true;
3049 }
3050
3051 result
3052 _FastScrollPresenter::AddIndexView(_FastScrollIndex& baseIndex)
3053 {
3054         return AddIndexView(GetIndexViewCount(), baseIndex);
3055 }
3056
3057 result
3058 _FastScrollPresenter::AddIndexView(int indexLevel, _FastScrollIndex& baseIndex)
3059 {
3060         result r = E_SUCCESS;
3061
3062         _FastScrollIndexView* pNewIndexView = _FastScrollIndexView::CreateFastScrollIndexViewN( *__pCtrlVe, *__pViewConfig);
3063         SysTryReturnResult(NID_UI_CTRL, pNewIndexView, GetLastResult(), "Propagating.");
3064
3065         r = __fastScroll.SetBounds(CalculateFastScrollBounds(GetIndexViewCount() + 1));
3066         SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Failed to set the bounds of _FastScroll.");
3067
3068         r = pNewIndexView->SetIndexBounds(CalculateIndexBounds(indexLevel, baseIndex));
3069         SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Failed to set bounds of the index view.");
3070
3071         r = pNewIndexView->SetBaseIndex(&baseIndex);
3072         SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Failed to set the index data for the index view.");
3073
3074         r = pNewIndexView->SetIndexVisibility(true);
3075         SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Failed to set visibility of the index view.");
3076
3077         r = __indexViews.InsertAt(*pNewIndexView, indexLevel);
3078         SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Failed to change the last index view.");
3079
3080         return E_SUCCESS;
3081 }
3082
3083 result
3084 _FastScrollPresenter::RemoveIndexView(int indexLevel, bool fadeout)
3085 {
3086         result r = E_SUCCESS;
3087
3088         int indexViewCount = GetIndexViewCount();
3089         if (indexLevel < indexViewCount)
3090         {
3091                 _FastScrollIndexView* pIndexView = GetIndexView(indexLevel);
3092                 SysTryReturnResult(NID_UI_CTRL, pIndexView, GetLastResult(), "Failed to get the index view.");
3093
3094                 if (fadeout)
3095                 {
3096                         r = pIndexView->FadeOutAndDestroy();
3097                         SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Failed to request to fade out of the index view.");
3098                 }
3099
3100                 r = __indexViews.Remove(*pIndexView, false);
3101                 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Failed to remove the index views.");
3102
3103                 // initialize the fastscroll control
3104                 r = __fastScroll.SetBounds(CalculateFastScrollBounds(GetIndexViewCount()));
3105                 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Failed to set the bounds of _FastScroll");
3106         }
3107
3108         return E_SUCCESS;
3109 }
3110
3111 result
3112 _FastScrollPresenter::RemoveAllIndexViews(bool fadeout)
3113 {
3114         result r = E_SUCCESS;
3115
3116         if (fadeout)
3117         {
3118                 int indexViewCount = GetIndexViewCount();
3119                 for (int i = 0; i < indexViewCount; i++)
3120                 {
3121                         _FastScrollIndexView* pIndexView = GetIndexView(i);
3122                         SysTryReturnResult(NID_UI_CTRL, pIndexView, GetLastResult(), "Failed to get the index view.");
3123
3124                         r = pIndexView->FadeOutAndDestroy();
3125                         SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Failed to request to fade out of the index view.");
3126                 }
3127         }
3128
3129         __indexViews.RemoveAll(true);
3130
3131         // initialize the fastscroll control
3132         r = __fastScroll.SetBounds(CalculateFastScrollBounds(0));
3133         SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Failed to set the bounds of _FastScroll.");
3134
3135         return E_SUCCESS;
3136 }
3137
3138 _FastScrollIndexView*
3139 _FastScrollPresenter::GetIndexView(int indexLevel) const
3140 {
3141         Object* pIndexView = const_cast<Object*>(__indexViews.GetAt(indexLevel));
3142         SysTryReturn(NID_UI_CTRL, pIndexView, null, GetLastResult(), "[%s] Failed to get the index view.",
3143                         GetErrorMessage(GetLastResult()));
3144
3145         return dynamic_cast<_FastScrollIndexView*>(pIndexView);
3146 }
3147
3148 int
3149 _FastScrollPresenter::GetIndexViewCount(void) const
3150 {
3151         return __indexViews.GetCount();
3152 }
3153
3154 } } } // Tizen::Ui::Controls