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