3bcc07a757921f586474d0baff84da1096e20057
[platform/framework/native/uifw.git] / src / ui / FUi_ControlManager.cpp
1 //
2 // Open Service Platform
3 // Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
4 //
5 // Licensed under the Flora License, Version 1.0 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
8 //
9 //     http://floralicense.org/license/
10 //
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an AS IS BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
16 //
17
18 /**
19  * @file                FUi_ControlManager.cpp
20  * @brief               This is the implementation file for the _ControlManager class.
21  */
22
23 #include <new>
24 #include <app.h>
25 #include <runtime_info.h>
26 #include <Ecore_X.h>
27 #include <Elementary.h>
28 #include <FBaseInt8.h>
29 #include <FBaseSysLog.h>
30 #include <FGrpRectangle.h>
31 #include <FApp_AppInfo.h>
32 #include <FAppPkg_PackageInfoImpl.h>
33 #include <FGrp_Screen.h>
34 #include <FGrp_FontImpl.h>
35 #include <FSys_SettingInfoImpl.h>
36 #include <FSys_SystemInfoImpl.h>
37 #include "FUi_ControlManager.h"
38 #include "FUi_Control.h"
39 #include "FUi_Window.h"
40 #include "FUi_WindowImpl.h"
41 #include "FUi_EcoreEvas.h"
42 #include "FUi_EcoreEvasMgr.h"
43 #include "FUi_EflWindow.h"
44 #include "FUi_ResourceManager.h"
45 #include "FUi_Clipboard.h"
46 #include "FUi_UiFocusEvent.h"
47 #include "FUi_UiEventManager.h"
48 #include "FUi_TouchManager.h"
49 #include "FUi_TouchLongPressGestureDetector.h"
50 #include "FUi_TouchTapGestureDetector.h"
51 #include "FUi_KeyEventManager.h"
52 #include "FUi_CoordinateSystemUtils.h"
53 #include "FUiAnim_RootVisualElement.h"
54 #include "FUiAnim_AnimationManager.h"
55 #include "FUiAnim_DisplayManager.h"
56 #include "FUi_AccessibilityManager.h"
57 #include "FUiAnim_VisualElement.h"
58 #include "FUiAnim_EflLayer.h"
59 #include "FUiCtrl_FrameImpl.h"
60 #include "FUiCtrl_FormImpl.h"
61 #include "FUiCtrl_Frame.h"
62 #include "FUiCtrl_IndicatorManager.h"
63
64 using namespace Tizen::App;
65 using namespace Tizen::App::Package;
66 using namespace Tizen::Base;
67 using namespace Tizen::Base::Collection;
68 using namespace Tizen::Graphics;
69 using namespace Tizen::Ui;
70 using namespace Tizen::Ui::Animations;
71 using namespace Tizen::Ui::Controls;
72 using namespace Tizen::System;
73
74 namespace {
75
76 _ControlRotation Convert(int rotationDegree)
77 {
78         switch (rotationDegree)
79         {
80                 case 0:
81                         return _CONTROL_ROTATION_0;
82                 case 90:
83                         return _CONTROL_ROTATION_90;
84                 case 180:
85                         return _CONTROL_ROTATION_180;
86                 case 270:
87                         return _CONTROL_ROTATION_270;
88                 default:
89                         return _CONTROL_ROTATION_0;
90         }
91 }
92
93 int Convert(_ControlRotation rotation)
94 {
95         switch (rotation)
96         {
97                 case _CONTROL_ROTATION_0:
98                         return 0;
99                 case _CONTROL_ROTATION_90:
100                         return 90;
101                 case _CONTROL_ROTATION_180:
102                         return 180;
103                 case _CONTROL_ROTATION_270:
104                         return 270;
105         }
106 }
107
108 } // Anonymous
109
110 extern "C"
111 {
112 _OSP_EXPORT_ void
113 _UiPrintControl(const _Control& control, bool printChildren, int level)
114 {
115         const_cast<_Control&>(control).PrintDescription(printChildren, level);
116 }
117
118 _OSP_EXPORT_ void
119 _UiPrintTree(int level)
120 {
121         _ControlManager* pControlManager = _ControlManager::GetInstance();
122         SysTryReturnVoidResult(NID_UI, pControlManager, E_SYSTEM, "[E_SYSTEM] System error occurred.");
123
124         if (pControlManager->GetWindowCount() == 0)
125         {
126                 return;
127         }
128
129         int count = pControlManager->GetWindowCount();
130         for (int i = 0; i < count; i++)
131         {
132                 _Window* pWindow = pControlManager->GetWindow((count-1) - i);
133                 _UiPrintControl(*pWindow, true, level);
134         }
135 }
136 }
137
138 namespace Tizen { namespace Ui
139 {
140 _ControlManager* _ControlManager::__pInstance = null;
141
142 void
143 _ControlManager::Initialize(void)
144 {
145         static pthread_once_t once_block = PTHREAD_ONCE_INIT;
146
147         if (!__pInstance)
148         {
149                 pthread_once(&once_block, InitInstance);
150         }
151
152         result r = _SettingInfoImpl::AddSettingEventListenerForInternal(*__pInstance);
153         SysTryReturnVoidResult(NID_UI, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
154
155         // [ToDo] Is it OK to directly get the device orientation?
156         int degree = app_get_device_orientation();
157         SysLog(NID_UI, "The initial value of device orientation is %d.", degree);
158
159         __pInstance->__screenRotation = ::Convert(degree);
160
161         elm_init(0, null);
162 }
163
164 void
165 _ControlManager::Release(void)
166 {
167         result  r = _SettingInfoImpl::RemoveSettingEventListenerForInternal(*__pInstance);
168         SysTryReturnVoidResult(NID_UI, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
169
170         delete __pInstance;
171         __pInstance = null;
172
173         elm_shutdown();
174 }
175
176 _ControlManager*
177 _ControlManager::GetInstance(void)
178 {
179         return __pInstance;
180 }
181
182 void
183 _ControlManager::InitInstance(void)
184 {
185         if (__pInstance)
186         {
187                 return;
188         }
189
190         __pInstance = new (std::nothrow) _ControlManager;
191         SysAssert(__pInstance);
192 }
193
194 _ControlHandle
195 _ControlManager::Register(_Control* pObject)
196 {
197         if (pObject)
198         {
199                 SysLog(NID_UI, "A _Control Registered()");
200         }
201
202         if (pObject == null)
203         {
204                 return _ControlHandle();
205         }
206
207         return __objectManager.Register(*pObject);
208 }
209
210 _Control*
211 _ControlManager::Release(const _ControlHandle& handle)
212 {
213         _Control* pObject = GetObject(handle);
214         if (pObject)
215         {
216                 SysLog(NID_UI, "A _Control Released()");
217         }
218
219         return __objectManager.Unregister(handle);
220 }
221
222 _Control*
223 _ControlManager::GetObject(const _ControlHandle& handle)
224 {
225         return __objectManager.GetObject(handle);
226 }
227
228 const _Control*
229 _ControlManager::GetObject(const _ControlHandle& handle) const
230 {
231         return __objectManager.GetObject(handle);
232 }
233
234 int
235 _ControlManager::GetUsedHandleCount(void) const
236 {
237         return __objectManager.GetObjectCount();
238 }
239
240 result
241 _ControlManager::GetAppCoordinateSystem(bool& isCoordinateSystemLogical, int& logicalCoordinateSystemInt, _BaseScreenSize& logicalBaseScreenSize)
242 {
243         _PackageInfoImpl infoImpl;
244         {
245                 String subAppId(_AppInfo::GetPackageId());
246
247                 result r = infoImpl.Construct(subAppId);
248                 SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
249         }
250
251         String baseScreenSize(null);
252         String coordinateSystem(null);
253         String logicalCoordinate(null);
254
255         result r = infoImpl.GetUiScalabilityInfo(baseScreenSize, coordinateSystem, logicalCoordinate);
256         SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
257
258         if (coordinateSystem.Equals(L"Physical", false))
259         {
260                 isCoordinateSystemLogical = false;
261                 logicalCoordinateSystemInt = 0;
262                 logicalBaseScreenSize = BASE_SCREEN_SIZE_DEFAULT;
263
264                 return E_SUCCESS;
265         }
266
267         //Logical Resolution
268         r = Integer::Parse(logicalCoordinate, logicalCoordinateSystemInt);
269         SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
270
271         // BaseScreenSize
272         if (baseScreenSize.Equals(L"Large", false))
273         {
274                 logicalBaseScreenSize = BASE_SCREEN_SIZE_LARGE;
275         }
276         else // temp
277         {
278                 logicalBaseScreenSize = BASE_SCREEN_SIZE_NORMAL;
279         }
280
281         return r;
282 }
283
284 bool
285 _ControlManager::IsCoordinateSystemLogical(void) const
286 {
287         return __isCoordinateSystemLogical;
288 }
289
290 int
291 _ControlManager::GetCoordinateSystem(void) const
292 {
293         return __logicalCoordinateSystem;
294 }
295
296 _BaseScreenSize
297 _ControlManager::GetLogicalBaseScreenSize(void) const
298 {
299         return __logicalBaseScreenSize;
300 }
301
302 _ControlManager::_ControlManager(void) // [ToDo] exception check.
303         : __pWindowList(null)
304         , __isCoordinateSystemLogical(true)
305         , __logicalCoordinateSystem(0)
306         , __logicalBaseScreenSize(BASE_SCREEN_SIZE_NONE)
307         , __pSystemWindowList(null)
308         , __pFocusedControl(null)
309         , __screenRotation(_CONTROL_ROTATION_0)
310         , __orientationStatus(_CONTROL_ROTATION_0)
311         , __orientation(_CONTROL_ORIENTATION_PORTRAIT)
312         , __pCurrentFrame(null)
313         , __pGestureList(null)
314         , __gestureMaxDuration(0)
315         , __touchedWindow(0)
316         , __isDefaultFontChanged(false)
317         , __defaultFontName(L"")
318         , __screenDpi(0)
319 {
320         result r = GetAppCoordinateSystem(__isCoordinateSystemLogical, __logicalCoordinateSystem, __logicalBaseScreenSize);
321         SysTryReturnVoidResult(NID_UI, r == E_SUCCESS, E_SYSTEM, "[E_SYSTEM] System error occurred.");
322
323         Dimension deviceResolution = CoordinateSystem::GetPhysicalResolution();
324         _BaseScreenSize deviceBaseScreenSize = _CoordinateSystem::GetInstance()->GetPhysicalBaseScreenSize();
325
326         r = _CoordinateSystem::Initialize(__logicalCoordinateSystem, __logicalBaseScreenSize, deviceResolution, deviceBaseScreenSize);
327         SysAssert(r == E_SUCCESS);
328
329         r = _AnimationManager::CreateInstance();
330         SysAssertf(r == E_SUCCESS, "Failed to create animation manager!");
331
332         r = _DisplayManager::CreateInstance();
333         SysAssertf(r == E_SUCCESS, "Failed to create display manager!");
334
335         _EcoreEvas::CreateInstanceN();
336
337         __pWindowList = new (std::nothrow)LinkedListT<_Window*>;
338         SysTryCatch(NID_UI, __pWindowList, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
339
340         __pGestureList = new (std::nothrow)LinkedListT<_TouchGestureDetector*>;
341         SysTryCatch(NID_UI, __pGestureList, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
342
343         _UiEventManager::Initialize();
344         _TouchManager::Initialize();
345         _KeyEventManager::Initialize();
346         _IndicatorManager::InitializeInstance();
347         _AccessibilityManager::CreateInstance();
348         InitializeScreenDpi();
349
350         SetLastResult(E_SUCCESS);
351
352         return;
353
354 CATCH:
355         _AnimationManager::ReleaseInstance();
356
357         if (__pWindowList)
358         {
359                 delete __pWindowList;
360                 __pWindowList = null;
361         }
362
363         if (__pGestureList)
364         {
365                 delete __pGestureList;
366                 __pGestureList = null;
367         }
368 }
369
370 _ControlManager::~_ControlManager(void)
371 {
372         _Clipboard::ReleaseInstance();
373
374         if (__pWindowList)
375         {
376                 delete __pWindowList;
377                 __pWindowList = null;
378         }
379
380         if (__pGestureList)
381         {
382                 delete __pGestureList;
383                 __pGestureList = null;
384         }
385
386         DestroyEcoreEvasMgr();
387
388         if (GetUsedHandleCount() != 0)
389         {
390                 SysLog(NID_UI, "[Control Manager] The number of unreleased controls: %d", GetUsedHandleCount());
391         }
392
393
394         _IndicatorManager::ReleaseInstance();
395
396         _DisplayManager::ReleaseInstance();
397
398         _AnimationManager::ReleaseInstance();
399
400         _AccessibilityManager::ReleaseInstance();
401
402         _KeyEventManager::ReleaseInstance();
403         _TouchManager::ReleaseInstance();
404         _UiEventManager::Release();
405 }
406
407 _Window*
408 _ControlManager::GetTopWindow(void) const
409 {
410         ClearLastResult();
411
412         if (GetWindowCount() == 0)
413         {
414                 return null;
415         }
416
417         return GetWindow(GetWindowCount() - 1);
418 }
419
420 _Window*
421 _ControlManager::GetTopVisibleWindow(void) const
422 {
423         ClearLastResult();
424
425         if (GetWindowCount() == 0)
426         {
427                 return null;
428         }
429
430         int count = GetWindowCount();
431         for (int i = 0; i < count; i++)
432         {
433                 _Window* pWindow = GetWindow((count-1) - i);
434
435                 if (pWindow->GetVisibleState() == true)
436                 {
437                         return pWindow;
438                 }
439         }
440
441         return null;
442 }
443
444 _Window*
445 _ControlManager::GetTopVisibleWindowAt(const Point& point) const
446 {
447         ClearLastResult();
448
449         if (GetWindowCount() == 0)
450         {
451                 return null;
452         }
453
454         int count = GetWindowCount();
455         for (int i = 0; i < count; i++)
456         {
457                 _Window* pWindow = GetWindow((count-1) - i);
458
459                 if (pWindow->GetVisibleState() == false)
460                 {
461                         continue;
462                 }
463
464                 Rectangle winBounds = pWindow->GetBounds();
465                 if (winBounds.Contains(point))
466                 {
467                         return pWindow;
468                 }
469         }
470
471         return null;
472 }
473
474 bool
475 _ControlManager::IsWindowOnTop(const _Window& window) const
476 {
477         return GetTopWindow() == &window;
478 }
479
480 bool
481 _ControlManager::IsWindowAttached(const _Window& window) const
482 {
483         return __pWindowList->Contains(const_cast<_Window*>(&window));
484 }
485
486 // Open a window and bring it to top.
487 result
488 _ControlManager::OpenWindow(_Window& window, bool invalidate)
489 {
490         if (dynamic_cast <_Frame*>(&window) != null)
491         {
492                 __pCurrentFrame = &window;
493         }
494
495         result r = ActivateWindow(window);
496         SysTryReturn(NID_UI, r != E_INVALID_OPERATION, r, r, "[%s] Propagating.", GetErrorMessage(r));
497         SysTryReturn(NID_UI, r == E_SUCCESS, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] System Error.");
498
499         if (invalidate)
500         {
501                 window.Invalidate(true);
502         }
503
504         return E_SUCCESS;
505 }
506
507 result
508 _ControlManager::ActivateWindow(_Window& window)
509 {
510         ClearLastResult();
511         result r = E_SUCCESS;
512
513         if (IsWindowOnTop(window))
514         {
515                 return E_SUCCESS;
516         }
517
518         if (window.IsActivationEnabled())
519         {
520                 _Window* pTopWindow = GetTopWindow();
521                 if (pTopWindow)
522                 {
523                         pTopWindow->Deactivate();
524                 }
525         }
526
527         if (IsWindowAttached(window))
528         {
529                 r = MoveWindowToTop(window); // [ToDo] excpetion
530                 SysAssert(r == E_SUCCESS);
531
532                 return E_SUCCESS;
533         }
534
535         r = window.GetControlDelegate().OnAttaching(null);
536         SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
537
538         r = CallOnAttachingToMainTree(window);
539         SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
540
541         r = AttachWindow(window);
542         SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
543
544         if (window.IsActivationEnabled())
545         {
546                 window.Activate();
547         }
548
549         if (window.IsOrientationRoot() == false)
550         {
551 #if !defined(WINDOW_BASE_ROTATE)
552                 window.ChangeLayout(GetOrientation());
553
554                 _EcoreEvas* pEcoreEvas = ::GetEcoreEvasMgr()->GetEcoreEvas();
555                 if (pEcoreEvas)
556                 {
557                         pEcoreEvas->RotateWindow(window, ::Convert(__orientationStatus));
558                 }
559 #else
560                 _EcoreEvas* pEcoreEvas = ::GetEcoreEvasMgr()->GetEcoreEvas();
561                 if (pEcoreEvas)
562                 {
563                         pEcoreEvas->SetWindowPreferredRotation(window, ::Convert(__orientationStatus));
564                 }
565 #endif
566         }
567
568         r = window.GetControlDelegate().OnAttached();
569         SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
570
571         r = CallOnAttachedToMainTree(window);
572         SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
573
574         return E_SUCCESS;
575 }
576
577 result
578 _ControlManager::CallOnAttachingToMainTree(_Control& control)
579 {
580         result r = E_SUCCESS;
581
582         r = control.GetControlDelegate().OnAttachingToMainTree(null);
583         SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
584
585         _Control::ControlList& children = control.GetChildList();
586         _Control* pChild = null;
587
588         for (int index = 0; index < children.GetCount(); index++)
589         {
590                 r = children.GetAt(index, pChild);
591                 if (IsFailed(r))
592                 {
593                         SysAssert(r == E_OUT_OF_RANGE);
594                         SysTryReturn(NID_UI,
595                                 (r != E_OUT_OF_RANGE), E_OUT_OF_RANGE,
596                                 E_OUT_OF_RANGE, "[E_OUT_OF_RANGE] The specified index is out of range.");
597                 }
598                 r = CallOnAttachingToMainTree(*pChild);
599                 SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
600         }
601
602         return r;
603 }
604
605 result
606 _ControlManager::CallOnAttachedToMainTree(_Control& control)
607 {
608         result r = E_SUCCESS;
609
610         _Control* pChild = null;
611         _Control::ControlList* pControlList = new (std::nothrow) _Control::ControlList;
612         pControlList->Construct(control.GetChildList());
613
614         r = control.GetControlDelegate().OnAttachedToMainTree();
615         SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
616
617         for (int index = 0; index < pControlList->GetCount(); index++)
618         {
619                 r = pControlList->GetAt(index, pChild);
620                 if (IsFailed(r))
621                 {
622                         SysAssert(r == E_OUT_OF_RANGE);
623                         SysTryReturn(NID_UI,
624                                 (r != E_OUT_OF_RANGE), E_OUT_OF_RANGE,
625                                 E_OUT_OF_RANGE, "[E_OUT_OF_RANGE] The specified index is out of range.");
626                 }
627                 r = control.CallOnAttachedToMainTree(*pChild);
628                 SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
629         }
630
631         delete pControlList;
632
633         return r;
634 }
635
636 result
637 _ControlManager::CallOnDetachingFromMainTree(_Control& control)
638 {
639         result r = E_SUCCESS;
640
641         _Control* pChild = null;
642         _Control::ControlList& children = control.GetChildList();
643
644         r = control.GetControlDelegate().OnDetachingFromMainTree();
645         SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
646
647         for (int index = 0; index < children.GetCount(); index++)
648         {
649                 r = children.GetAt(index, pChild);
650                 if (IsFailed(r))
651                 {
652                         SysAssert(r == E_OUT_OF_RANGE);
653                         SysTryReturn(NID_UI,
654                                 (r != E_OUT_OF_RANGE), E_OUT_OF_RANGE,
655                                 E_OUT_OF_RANGE, "[E_OUT_OF_RANGE] The specified index is out of range.");
656                 }
657                 r = CallOnDetachingFromMainTree(*pChild);
658                 SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
659         }
660
661         return r;
662 }
663
664 result
665 _ControlManager::CloseWindow(_Window& window) // [ToDo] exception check.
666 {
667         ClearLastResult();
668         result r = E_SUCCESS;
669
670         if (IsWindowAttached(window) == false)
671         {
672                 return E_SUCCESS;
673         }
674
675         bool wasWindowOnTop = IsWindowOnTop(window);
676
677         r = CallOnDetachingFromMainTree(window);
678         SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
679
680         window.GetControlDelegate().OnDetaching();
681
682         window.Deactivate();
683
684         r = DetachWindow(window);
685         SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
686
687         if (wasWindowOnTop)
688         {
689                 _Window* pNewTopWindow = GetTopWindow();
690                 if (pNewTopWindow && pNewTopWindow->IsActivationEnabled())
691                 {
692                         pNewTopWindow->Activate();
693                 }
694
695                 if (dynamic_cast <_Frame*>(pNewTopWindow) != null)
696                 {
697                         __pCurrentFrame = pNewTopWindow;
698                 }
699         }
700
701         return E_SUCCESS;
702 }
703
704 _Window*
705 _ControlManager::GetWindow(int index) const
706 {
707         _Window* pWindow;
708         __pWindowList->GetAt(index, pWindow);
709
710         return pWindow;
711 }
712
713 int
714 _ControlManager::GetWindowCount(void) const
715 {
716         return __pWindowList->GetCount();
717 }
718
719 result
720 _ControlManager::AttachWindow(_Window& window)
721 {
722         _IndicatorManager::GetInstance()->AddWindow(&window);
723
724         return __pWindowList->Add(&window);
725 }
726
727 result
728 _ControlManager::InsertWindowToBottom(_Window& window)
729 {
730         return __pWindowList->InsertAt(&window, 0);
731 }
732
733 result
734 _ControlManager::InsertWindowAfter(const _Window& targetWindow, _Window& window)
735 {
736         int index = 0;
737
738         result r = __pWindowList->IndexOf(const_cast<_Window*>(&targetWindow), index);
739         SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
740
741         return __pWindowList->InsertAt(&window, index+1);
742 }
743
744 result
745 _ControlManager::InsertWindowBefore(const _Window& targetWindow, _Window& window)
746 {
747         int index = 0;
748
749         result r = __pWindowList->IndexOf(const_cast<_Window*>(&targetWindow), index);
750         SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
751
752         return __pWindowList->InsertAt(&window, index);
753 }
754
755 result
756 _ControlManager::DetachWindow(_Window& window)
757 {
758         _IndicatorManager::GetInstance()->DeleteWindow(&window);
759
760         return __pWindowList->Remove(&window);
761 }
762
763 void
764 _ControlManager::DetachAllWindows(void)
765 {
766         __pWindowList->RemoveAll();
767 }
768
769 result
770 _ControlManager::MoveWindowToTop(const _Window& window)
771 {
772         result r = __pWindowList->Remove(const_cast<_Window*>(&window));
773         SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
774
775         return __pWindowList->Add(const_cast<_Window*>(&window));
776 }
777
778 result
779 _ControlManager::MoveWindowToBottom(const _Window& window)
780 {
781         result r = __pWindowList->Remove(const_cast<_Window*>(&window));
782         SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
783
784         return __pWindowList->InsertAt(const_cast<_Window*>(&window), 0);
785 }
786
787 result
788 _ControlManager::MoveWindowAfter(const _Window& targetWindow, const _Window& window)
789 {
790         result r = __pWindowList->Remove(const_cast<_Window*>(&window));
791         SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
792
793         int index = 0;
794
795         r = __pWindowList->IndexOf(const_cast<_Window*>(&targetWindow), index);
796         SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
797
798         return __pWindowList->InsertAt(const_cast<_Window*>(&window), index+1);
799 }
800
801 result
802 _ControlManager::MoveWindowBefore(const _Window& targetWindow, const _Window& window)
803 {
804         result r = __pWindowList->Remove(const_cast<_Window*>(&window));
805         SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
806
807         int index = 0;
808
809         r = __pWindowList->IndexOf(const_cast<_Window*>(&targetWindow), index);
810         SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
811
812         return __pWindowList->InsertAt(const_cast<_Window*>(&window), index);
813 }
814
815 _ControlOrientation
816 _ControlManager::GetOrientation(void) const
817 {
818         return __orientation;
819 }
820
821 void
822 _ControlManager::SetOrientation(_ControlOrientation orientation)
823 {
824         __orientation = orientation;
825 }
826
827 _ControlRotation
828 _ControlManager::GetScreenRotation(void) const
829 {
830         bool autoRotate = true;
831         int ret = runtime_info_get_value_bool(RUNTIME_INFO_KEY_AUTO_ROTATION_ENABLED, &autoRotate);
832
833         if (ret == RUNTIME_INFO_ERROR_NONE)
834         {
835                 SysLog(NID_UI, "The flag of auto-rotate is %d.", autoRotate);
836         }
837         else
838         {
839                 SysLog(NID_UI, "It's failed to get the flag of auto-rotate.");
840         }
841
842         if (autoRotate == false)
843         {
844                 return _CONTROL_ROTATION_0;
845         }
846         else
847         {
848 #if defined(WINDOW_BASE_ROTATE)
849                 int degree = app_get_device_orientation();
850
851                 return ::Convert(degree);
852 #else
853                 return __screenRotation;
854 #endif
855         }
856 }
857
858 void
859 _ControlManager::OnScreenRotated(int rotation)
860 {
861         SysLog(NID_UI, "The angle of Emul or Target is %d.", rotation);
862         __screenRotation = ::Convert(rotation);
863
864         int count = GetWindowCount();
865         for (int i = 0; i < count; i++)
866         {
867                 _Window* pWindow = GetWindow((count-1) - i);
868
869                 _Frame* pFrame = dynamic_cast<_Frame*>(pWindow);
870
871                 if (pFrame)
872                 {
873                         Controls::_FrameImpl* pFrameImpl = static_cast<Controls::_FrameImpl*>(pFrame->GetUserData());
874                         if (pFrameImpl == null)
875                         {
876                                 continue;
877                         }
878
879                         Controls::_FormImpl* pCurrentFormImpl = pFrameImpl->GetCurrentForm();
880                         if (pCurrentFormImpl)
881                         {
882                                 pCurrentFormImpl->UpdateOrientationStatus(true);
883                         }
884                         else
885                         {
886                                 pFrameImpl->UpdateOrientationStatus();
887                         }
888                 }
889         }
890 }
891
892 void
893 _ControlManager::SetTouchedWindow(unsigned int window)
894 {
895         __touchedWindow = window;
896 }
897
898 _Window*
899 _ControlManager::GetTouchedWindow(void) const
900 {
901         ClearLastResult();
902
903         if (GetWindowCount() == 0)
904         {
905                 return null;
906         }
907
908         int count = GetWindowCount();
909         for (int i = 0; i < count; i++)
910         {
911                 _Window* pWindow = GetWindow((count-1) - i);
912
913                 _RootVisualElement* pRootVE = pWindow->GetRootVisualElement();
914                 _EflLayer* pLayer = static_cast<_EflLayer*>(pRootVE->GetNativeLayer());
915
916                 Ecore_Evas* pEcoreEvas = pLayer->GetEcoreEvas();
917                 Ecore_X_Window win = (Ecore_X_Window) ecore_evas_window_get(pEcoreEvas);
918
919                 if (win == __touchedWindow)
920                 {
921                         return pWindow;
922                 }
923         }
924
925         return null;
926 }
927
928 void
929 _ControlManager::SetOrientationStatus(_ControlRotation orientationStatus)
930 {
931         __orientationStatus = orientationStatus;
932 }
933
934 _ControlRotation
935 _ControlManager::GetOrientationStatus(void) const
936 {
937         return __orientationStatus;
938 }
939
940 void
941 _ControlManager::RotateScreen(const _Control& control, _ControlRotation screenRotation)
942 {
943         // Non-auto mode
944         // Rotate window
945         // Set window preferred rotation
946
947         _EcoreEvas* pEcoreEvas = ::GetEcoreEvasMgr()->GetEcoreEvas();
948         SysAssert(pEcoreEvas);
949         if (pEcoreEvas == null)
950         {
951                 return;
952         }
953
954         // Rotate root window.
955         _Window* pRootWindow = control.GetRootWindow();
956         if (pRootWindow)
957         {
958                 pEcoreEvas->RotateWindow(*pRootWindow, ::Convert(screenRotation));
959                 //pRootWindow->SetRotation(::Convert(screenRotation));
960         }
961
962 #if !defined(WINDOW_BASE_ROTATE)
963         // Rotate Ownees.
964         int owneeCount = control.GetOwneeCount();
965         for (int i = 0; i < owneeCount; i++)
966         {
967                 _Window* pOwnee = control.GetOwnee(i);
968                 if (pOwnee)
969                 {
970                         pEcoreEvas->RotateWindow(*pOwnee, ::Convert(screenRotation));
971                 }
972         }
973 #endif
974
975         if (__orientationStatus != screenRotation)
976         {
977                 _TouchManager* pTouchManager = _TouchManager::GetInstance();
978                 if (pTouchManager)
979                 {
980                         pTouchManager->SetTouchCanceled(true);
981                 }
982         }
983 }
984
985 void
986 _ControlManager::OnWindowRotated(int rotation)
987 {
988         // For non-ownees
989         IEnumeratorT<_Window*>* pEnumerator = __pWindowList->GetEnumeratorN();
990         SysTryReturnVoidResult(NID_UI, pEnumerator, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory is insufficient.");
991
992         while (pEnumerator->MoveNext() == E_SUCCESS)
993         {
994                 _Window* pWindow = null;
995                 pEnumerator->GetCurrent(pWindow);
996
997                 if (pWindow->GetOwner() == null)
998                 {
999                         void* pUserData = pWindow->GetUserData();
1000                         if (pUserData)
1001                         {
1002                                 _WindowImpl* pWindowImpl = static_cast<_WindowImpl*>(pUserData);
1003                                 pWindowImpl->OnRotated(Convert(rotation));
1004                         }
1005                 }
1006         }
1007
1008         delete pEnumerator;
1009 }
1010
1011 void
1012 _ControlManager::SetFocusedControl(const _Control& control, bool on)
1013 {
1014         if (on)
1015         {
1016                 if (__pFocusedControl == &control)
1017                 {
1018                         return;
1019                 }
1020
1021                 _EcoreEvas* pEcoreEvas = GetEcoreEvasMgr()->GetEcoreEvas();
1022                 SysTryReturnVoidResult(NID_UI, pEcoreEvas, E_SYSTEM, "[E_SYSTEM] System error occurred.");
1023
1024                 _Control *pPreviousFocusedControl = __pFocusedControl;
1025                 if (pPreviousFocusedControl)
1026                 {
1027                         // [review] make SetFocus() return result and use the returned result here.
1028                         pEcoreEvas->SetFocus(*pPreviousFocusedControl, false);
1029                         if (GetLastResult() == E_SUCCESS)
1030                         {
1031                                 if (pPreviousFocusedControl)
1032                                 {
1033                                         pPreviousFocusedControl->SetFocusState(false);
1034                                 }
1035                                 _UiFocusEvent event(pPreviousFocusedControl->GetHandle(), FOCUS_LOST);
1036                                 _UiEventManager::GetInstance()->SendEvent(event);
1037                         }
1038                 }
1039
1040                 // [review] make SetFocus() return result and use the returned result here.
1041
1042                 if (control.IsNativeObjectFocusable())
1043                 {
1044                         pEcoreEvas->SetFocus(control, true);
1045                 }
1046
1047                 if (GetLastResult() == E_SUCCESS)
1048                 {
1049                         __pFocusedControl = const_cast<_Control*>(&control);
1050                         _UiFocusEvent event(control.GetHandle(), FOCUS_GAINED);
1051                         _UiEventManager::GetInstance()->SendEvent(event);
1052                 }
1053         }
1054         else
1055         {
1056                 if (__pFocusedControl != &control)
1057                 {
1058                         return;
1059                 }
1060
1061                 _EcoreEvas* pEcoreEvas = GetEcoreEvasMgr()->GetEcoreEvas();
1062                 SysTryReturnVoidResult(NID_UI, pEcoreEvas, E_SYSTEM, "[E_SYSTEM] System error occurred.");
1063
1064                 if (__pFocusedControl)
1065                 {
1066                         // [review] make SetFocus() return result and use the returned result here.
1067                         pEcoreEvas->SetFocus(*__pFocusedControl, false);
1068                         if (GetLastResult() == E_SUCCESS)
1069                         {
1070                                 _UiFocusEvent event(__pFocusedControl->GetHandle(), FOCUS_LOST);
1071                                 _UiEventManager::GetInstance()->SendEvent(event);
1072                         }
1073                 }
1074
1075                 _Window* pTopWindow = GetTopWindow();
1076                 if (pTopWindow)
1077                 {
1078                         // [review] make SetFocus() return result and use the returned result here.
1079                         pEcoreEvas->SetFocus(*pTopWindow, true);
1080                         if (GetLastResult() == E_SUCCESS)
1081                         {
1082                                 pTopWindow->SetFocusState(true);
1083                                 _UiFocusEvent event(pTopWindow->GetHandle(), FOCUS_GAINED);
1084                                 _UiEventManager::GetInstance()->SendEvent(event);
1085                         }
1086
1087                         __pFocusedControl = static_cast<_Control*>(pTopWindow);
1088                 }
1089         }
1090 }
1091
1092 // [review] called in ~_Control and virtual OnFocusLost is called.
1093 // _Control::Release() instead of ~_Control.
1094 bool
1095 _ControlManager::TakeFocusFromControl(const _Control& control)
1096 {
1097         if (__pFocusedControl == &control)
1098         {
1099                 _Control *pPreviousFocusedControl = __pFocusedControl;
1100                 __pFocusedControl = null;
1101                 _UiFocusEvent event(pPreviousFocusedControl->GetHandle(), FOCUS_LOST);
1102                 _UiEventManager::GetInstance()->SendEvent(event);
1103
1104                 return true;
1105         }
1106
1107         return false;
1108 }
1109
1110 _Control*
1111 _ControlManager::GetFocusedControl(void) const
1112 {
1113         return __pFocusedControl;
1114 }
1115
1116 _Control*
1117 _ControlManager::GetTopmostTouchedControl(const Point& point)
1118 {
1119         _Control* pControl = null;
1120         _Window* pTopWindow = null;
1121
1122         int count = GetWindowCount();
1123         if (count != 0)
1124         {
1125                 for (int i = 0; i < count; i++)
1126                 {
1127                         _Window* pWindow = GetWindow((count-1) - i);
1128
1129                         if (pWindow->GetVisibleState() == false)
1130                         {
1131                                 continue;
1132                         }
1133
1134                         _RootVisualElement* pRootVE = pWindow->GetRootVisualElement();
1135                         _EflLayer* pLayer = static_cast<_EflLayer*>(pRootVE->GetNativeLayer());
1136
1137                         Ecore_Evas* pEcoreEvas = pLayer->GetEcoreEvas();
1138                         Ecore_X_Window win = (Ecore_X_Window)ecore_evas_window_get(pEcoreEvas);
1139
1140                         Rectangle winDeviceBounds(0, 0, 0, 0);
1141                         ecore_x_window_geometry_get(win, &winDeviceBounds.x, &winDeviceBounds.y, &winDeviceBounds.width, &winDeviceBounds.height);
1142
1143                         Point winDevicePoint = _CoordinateSystemUtils::Transform(pWindow->GetPosition());
1144
1145                         Point devicePoint = _CoordinateSystemUtils::Transform(point);
1146                         int x = devicePoint.x;
1147                         int y = devicePoint.y;
1148
1149                         int rootW = 0;
1150                         int rootH = 0;
1151                         ecore_x_window_size_get(ecore_x_window_root_get(win), &rootW, &rootH);
1152
1153                         int rotation = ecore_evas_rotation_get(pEcoreEvas);
1154                         switch (rotation)
1155                         {
1156                         case 270:
1157                                 devicePoint.x = rootW - y;
1158                                 devicePoint.y = x;
1159                                 winDeviceBounds.x = rootW - winDevicePoint.y - winDeviceBounds.width;
1160                                 winDeviceBounds.y = winDevicePoint.x;
1161                                 break;
1162                         case 180:
1163                                 devicePoint.x = rootW - x;
1164                                 devicePoint.y = rootH - y;
1165                                 winDeviceBounds.x = rootW - winDevicePoint.x - winDeviceBounds.width;
1166                                 winDeviceBounds.y = rootH - winDevicePoint.y - winDeviceBounds.height;
1167                                 break;
1168                         case 90:
1169                                 devicePoint.x = y;
1170                                 devicePoint.y = rootH - x;
1171                                 winDeviceBounds.x = winDevicePoint.y;
1172                                 winDeviceBounds.y = rootH - winDevicePoint.x - winDeviceBounds.height;
1173                                 break;
1174                         default:
1175                                 devicePoint.x = x;
1176                                 devicePoint.y = y;
1177                                 winDeviceBounds.x = winDevicePoint.x;
1178                                 winDeviceBounds.y = winDevicePoint.y;
1179                                 break;
1180                         }
1181
1182                         if (winDeviceBounds.Contains(devicePoint))
1183                         {
1184                                 pTopWindow = pWindow;
1185                                 break;
1186                         }
1187                 }
1188         }
1189
1190         if (pTopWindow != null)
1191         {
1192                 Point winPos(0, 0);
1193                 winPos = pTopWindow->GetPosition();
1194
1195                 Point relPos(point.x - winPos.x, point.y - winPos.y);
1196                 pControl = pTopWindow->GetTopmostChildAt(relPos);
1197                 if (pControl != null)
1198                 {
1199                         if (pControl->GetRootWindow() == pTopWindow)
1200                         {
1201                                 return pControl;
1202                         }
1203                 }
1204         }
1205
1206         return null;
1207 }
1208
1209 // [review] rename __InvXformer
1210 Dimension
1211 _ControlManager::GetScreenSize(void) const
1212 {
1213         return _CoordinateSystemUtils::InverseTransform(Dimension(_Screen::GetWidth(), _Screen::GetHeight()));
1214 }
1215
1216 FloatDimension
1217 _ControlManager::GetScreenSizeF(void) const
1218 {
1219         return _CoordinateSystemUtils::InverseTransform(FloatDimension(_Screen::GetWidth(), _Screen::GetHeight()));
1220 }
1221
1222 void
1223 _ControlManager::InitializeScreenDpi()
1224 {
1225         Tizen::System::_SystemInfoImpl::GetSysInfo(L"http://tizen.org/feature/screen.dpi", __screenDpi);
1226 }
1227
1228 int
1229 _ControlManager::GetScreenDpi() const
1230 {
1231         return __screenDpi;
1232 }
1233
1234 _Window*
1235 _ControlManager::GetCurrentFrame(void) const
1236 {
1237         return __pCurrentFrame;
1238 }
1239
1240 result
1241 _ControlManager::SetDefaultFont(const String& appFontName)
1242 {
1243
1244         if(appFontName.Equals(__defaultFontName))
1245         {
1246                 return E_SUCCESS;
1247         }
1248
1249         __isDefaultFontChanged = true;
1250         __defaultFontName = appFontName;
1251         __defaultFontFileName.Clear();
1252
1253         struct _Visitor
1254                 : public _Control::Visitor
1255         {
1256                  virtual _Control::VisitType Visit(_Control& control)
1257                 {
1258                         if (control.__fontName.IsEmpty() && control.__fontFileName.IsEmpty())
1259                         {
1260                                 control.GetFallbackFont();
1261                                 _IControlDelegate& delegate = control.GetControlDelegate();
1262                                 delegate.OnFontChanged(control.__pFont);
1263                         }
1264                         return _Control::VISIT_DOWNWARD;
1265                 }
1266         };
1267
1268         _Visitor visitor;
1269
1270         int count = GetWindowCount();
1271         for (int j = 0; j < count; j++)
1272         {
1273                 _Window* pWindow = GetWindow((count-1) - j);
1274                 pWindow->Accept(visitor);
1275         }
1276
1277         SetDefaultFontChangeState(false);
1278
1279         return E_SUCCESS;
1280 }
1281
1282 Tizen::Base::String
1283 _ControlManager::GetDefaultFont(void)
1284 {
1285         return __defaultFontName;
1286 }
1287
1288 result
1289 _ControlManager::SetDefaultFontFromFile(const Tizen::Base::String& fileName)
1290 {
1291         if(fileName.Equals(__defaultFontFileName))
1292         {
1293                 return E_SUCCESS;
1294         }
1295
1296         __isDefaultFontChanged = true;
1297         __defaultFontFileName = fileName;
1298         __defaultFontName.Clear();
1299         struct _Visitor
1300                 : public _Control::Visitor
1301         {
1302                  virtual _Control::VisitType Visit(_Control& control)
1303                 {
1304                         if (control.__fontName.IsEmpty() && control.__fontFileName.IsEmpty())
1305                         {
1306                                 control.GetFallbackFont();
1307                                 _IControlDelegate& delegate = control.GetControlDelegate();
1308                                 delegate.OnFontChanged(control.__pFont);
1309                         }
1310                         return _Control::VISIT_DOWNWARD;
1311                 }
1312         };
1313
1314         _Visitor visitor;
1315
1316         int count = GetWindowCount();
1317         for (int j = 0; j < count; j++)
1318         {
1319                 _Window* pWindow = GetWindow((count-1) - j);
1320                 pWindow->Accept(visitor);
1321         }
1322
1323         SetDefaultFontChangeState(false);
1324
1325         return E_SUCCESS;
1326 }
1327 String
1328 _ControlManager::GetDefaultFontFile(void) const
1329 {
1330         return __defaultFontFileName;
1331 }
1332 bool
1333 _ControlManager::IsDefaultFontChanged(void)
1334 {
1335         return __isDefaultFontChanged;
1336 }
1337
1338 void
1339 _ControlManager::SetDefaultFontChangeState(bool isDefaultFontChanged)
1340 {
1341         __isDefaultFontChanged = isDefaultFontChanged;
1342 }
1343
1344 bool
1345 _ControlManager::IsFrameActivated(void) const
1346 {
1347         _Frame* pFrame = dynamic_cast<_Frame*>(__pCurrentFrame);
1348         SysTryReturn(NID_UI, pFrame, false, E_SYSTEM, "[E_SYSTEM] System error occurred. ");
1349
1350         return pFrame->IsActivated();
1351 }
1352
1353 // [review] refactoring
1354 result
1355 _ControlManager::AddGestureDetector(const _TouchGestureDetector& gesture)
1356 {
1357         ClearLastResult();
1358
1359         SysTryReturn(NID_UI, __pGestureList != null, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] System error occurred. ");
1360
1361         bool exist = __pGestureList->Contains(const_cast<_TouchGestureDetector*>(&gesture));
1362         SysTryReturnResult(NID_UI, exist == false, E_OBJ_ALREADY_EXIST, "[E_OBJ_ALREADY_EXIST]__pGestureList has gesture already");
1363
1364         result r = __pGestureList->Add(const_cast<_TouchGestureDetector*>(&gesture));
1365         SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1366
1367         switch (gesture.GetDetectorType())
1368         {
1369                 case _TOUCH_GESTURE_DETECTOR_TYPE_TAP:
1370                 {
1371                         _TouchTapGestureDetector* pGestureTap = dynamic_cast<_TouchTapGestureDetector*>(const_cast<_TouchGestureDetector*>(&gesture));
1372                         SysTryReturnResult(NID_UI, pGestureTap, E_SYSTEM, "[E_SYSTEM]system error occurred.");
1373
1374                         if (pGestureTap->GetTapInterval() > __gestureMaxDuration)
1375                         {
1376                                 __gestureMaxDuration = pGestureTap->GetTapInterval();
1377                         }
1378                 }
1379                 break;
1380                 case _TOUCH_GESTURE_DETECTOR_TYPE_LONG_PRESS:
1381                 {
1382                         _TouchLongPressGestureDetector* pGestureLongPress= dynamic_cast<_TouchLongPressGestureDetector*>(const_cast<_TouchGestureDetector*>(&gesture));
1383                         SysTryReturnResult(NID_UI, pGestureLongPress, E_SYSTEM, "[E_SYSTEM]system error occurred.");
1384
1385                         if (pGestureLongPress->GetDuration() > __gestureMaxDuration)
1386                         {
1387                                 __gestureMaxDuration = pGestureLongPress->GetDuration();
1388                         }
1389                 }
1390                 break;
1391                 default:
1392                         break;
1393         }
1394
1395         return E_SUCCESS;
1396 }
1397
1398 result
1399 _ControlManager::RemoveGestureDetector(const _TouchGestureDetector& gesture)
1400 {
1401         ClearLastResult();
1402
1403         result r = __pGestureList->Remove(&(const_cast<_TouchGestureDetector&>(gesture)));
1404         SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1405
1406         return E_SUCCESS;
1407 }
1408
1409 IListT <_TouchGestureDetector*>*
1410 _ControlManager::GetGestureDetectorList(void) const
1411 {
1412         return __pGestureList;
1413 }
1414
1415 int
1416 _ControlManager::GetGestureMaxTimeDuration(void) const
1417 {
1418         return __gestureMaxDuration;
1419 }
1420
1421 void
1422 _ControlManager::OnSettingChanged(Tizen::Base::String& key)
1423 {
1424         const wchar_t* FONT_TYPE = L"http://tizen.org/setting/font.type";
1425         const wchar_t* LOCALE_COUNTRY = L"http://tizen.org/setting/locale.country";
1426         const wchar_t* LOCALE_LANGUAGE = L"http://tizen.org/setting/locale.language";
1427
1428          if (key == FONT_TYPE || key == LOCALE_COUNTRY || key == LOCALE_LANGUAGE)
1429         {
1430                 _FontImpl::UpdateDefaultFont(key);
1431
1432                 int count = GetWindowCount();
1433
1434                 for(int index = 0; index < count ; index++)
1435                 {
1436                         _Window* pWindow = GetWindow(index);
1437                         pWindow->Invalidate(true);
1438                 }
1439         }
1440
1441         //fixme : check longpress duration key
1442         //if (key == )
1443         {
1444                 if (!__pGestureList || (__pGestureList && (__pGestureList->GetCount() <= 0)))
1445                 {
1446                         return;
1447                 }
1448
1449                 IEnumeratorT<_TouchGestureDetector*>* pEnumerator = __pGestureList->GetEnumeratorN();
1450                 SysTryReturnVoidResult(NID_UI, pEnumerator, E_SYSTEM, "[E_SYSTEM] System error occurred.")
1451
1452                 int duration = static_cast<int>(elm_config_longpress_timeout_get());
1453                 if (duration == 0)
1454                 {
1455                         duration = 500;
1456                 }
1457
1458                 while (pEnumerator->MoveNext() == E_SUCCESS)
1459                 {
1460                         _TouchGestureDetector* pGestureDetector = null;
1461                         pEnumerator->GetCurrent(pGestureDetector);
1462
1463                         if (!pGestureDetector)
1464                         {
1465                                 continue;
1466                         }
1467
1468                         if(pGestureDetector->GetDetectorType() == _TOUCH_GESTURE_DETECTOR_TYPE_LONG_PRESS)
1469                         {
1470                                 _TouchLongPressGestureDetector* pGestureLongPress= dynamic_cast<_TouchLongPressGestureDetector*>(const_cast<_TouchGestureDetector*>(pGestureDetector));
1471                                 SysTryReturnVoidResult(NID_UI, pGestureLongPress, E_SYSTEM, "[E_SYSTEM] System error occurred.")
1472                                 pGestureLongPress->SetDuration(duration);
1473                         }
1474                 }
1475
1476                 delete pEnumerator;
1477         }
1478 }
1479
1480 }} // Tizen::Ui