Merge "Merge from master branch" into tizen_2.1
[platform/framework/native/uifw.git] / src / ui / controls / FUiCtrl_Frame.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  * @file                FUiCtrl_Frame.cpp
19  * @brief               This is the implementation file for the _Frame class.
20  */
21
22 #include <new>
23 #include <FBaseErrorDefine.h>
24 #include <FBaseInteger.h>
25 #include <FBaseSysLog.h>
26 #include <FApp_AppInfo.h>
27 #include "FUi_UiNotificationEvent.h"
28 #include "FUi_UiEventManager.h"
29 #include "FUi_ControlManager.h"
30 #include "FUi_EcoreEvasMgr.h"
31 #include "FUi_EcoreEvas.h"
32 #include "FUi_TouchManager.h"
33 #include "FUi_CoordinateSystemUtils.h"
34 #include "FUiCtrl_Frame.h"
35 #include "FUiCtrl_FramePresenter.h"
36 #include "FUiCtrl_FrameEvent.h"
37 #include "FUiCtrl_IFrameEventListener.h"
38 #include "FUiCtrl_IFormActivationChangeEventListener.h"
39 #include "FUiCtrl_Form.h"
40 #include "FUiCtrl_FormImpl.h"
41 #include "FUiCtrl_FrameImpl.h"
42 #include "FUiAnim_VisualElement.h"
43 #include "FUiAnim_RootVisualElement.h"
44 #include "FUiAnim_EflLayer.h"
45 #include "FUi_AccessibilityManager.h"
46
47 using namespace Tizen::App;
48 using namespace Tizen::Ui::Animations;
49 using namespace Tizen::Ui;
50 using namespace Tizen::Base;
51 using namespace Tizen::Base::Collection;
52 using namespace Tizen::Base::Runtime;
53 using namespace Tizen::Graphics;
54
55 namespace Tizen { namespace Ui { namespace Controls {
56
57 const String _ACTIVATE_FRAME = L"ActivateFrame";
58
59 _Frame::_Frame(void)
60         : __pFramePresenter(null)
61         , __pFrameEvent(null)
62         , __floatingBounds(0.0f, 0.0f, 0.0f, 0.0f)
63         , __showMode(FRAME_SHOW_MODE_FULL_SCREEN)
64         , __restore(false)
65         , __minimized(false)
66         , __activated(false)
67         , __constructed(false)
68         , __rotation(false)
69         , __pFormActivationChangeEventListener(null)
70 {
71         _FramePresenter* pPresenter = new (std::nothrow) _FramePresenter(*this);
72         SysTryReturnVoidResult(NID_UI_CTRL, pPresenter, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory is insufficient.");
73
74         FloatDimension screen = _ControlManager::GetInstance()->GetScreenSizeF();
75         __floatingBounds.width = screen.width;
76         __floatingBounds.height = screen.height;
77
78         __pFrameEvent = _FrameEvent::CreateInstanceN(*this);
79         SysTryCatch(NID_UI_CTRL, __pFrameEvent, , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
80
81         SetPresenter(*pPresenter);
82         SetClipChildrenEnabled(false);
83
84         ClearLastResult();
85
86         return;
87
88 CATCH:
89         delete pPresenter;
90         pPresenter = null;
91 }
92
93 _Frame::~_Frame(void)
94 {
95         if (__pFrameEvent)
96         {
97                 delete __pFrameEvent;
98                 __pFrameEvent = null;
99         }
100
101         delete __pFramePresenter;
102         __pFramePresenter = null;
103
104         ClearLastResult();
105 }
106
107 _Frame*
108 _Frame::CreateFrameN(void)
109 {
110         result r = E_SUCCESS;
111         _RootVisualElement* pRootVE = null;
112         _EflLayer* pLayer = null;
113         int appType = _AppInfo::GetAppType();
114
115         _Frame* pFrame = new (std::nothrow) _Frame;
116         SysTryCatch(NID_UI_CTRL, pFrame, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory shortage.");
117         SysTryCatch(NID_UI_CTRL, GetLastResult() == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] A system error occurred.");
118
119         if (appType & _APP_TYPE_IME_APP)
120         {
121                 SysLog(NID_UI_CTRL, "[Ime Rotation]");
122                 r = pFrame->CreateRootVisualElement(_WINDOW_TYPE_SUB);
123                 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
124         }
125         else
126         {
127                 r = pFrame->CreateRootVisualElement();
128                 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
129         }
130
131         pRootVE = pFrame->GetRootVisualElement();
132         SysAssert(pRootVE);
133
134         pLayer = static_cast<_EflLayer*>(pRootVE->GetNativeLayer());
135         SysAssert(pLayer);
136
137         if (!(appType & _APP_TYPE_IME_APP))
138         {
139                 pLayer->SetOpacity(1);
140         }
141
142         pFrame->AcquireHandle();
143
144         SetLastResult(E_SUCCESS);
145
146         return pFrame;
147
148 CATCH:
149         delete pFrame;
150
151         return null;
152 }
153
154 result
155 _Frame::SetPresenter(const _FramePresenter& framePresenter)
156 {
157         __pFramePresenter = const_cast <_FramePresenter*>(&framePresenter);
158
159         return E_SUCCESS;
160 }
161
162 void
163 _Frame::OnDraw(void)
164 {
165         if (__pFramePresenter)
166         {
167                 __pFramePresenter->Draw();
168         }
169 }
170
171 void
172 _Frame::OnActivated(void)
173 {
174         SysLog(NID_UI, "activated(%d)", __activated);
175
176         if (!__activated)
177         {
178                 return;
179         }
180
181         _Window::OnActivated();
182
183         _Form* pCurrentForm = GetCurrentForm();
184         if (pCurrentForm == null)
185         {
186                 return;
187         }
188
189         pCurrentForm->AddIndicatorObject();
190
191         _Control* pFocusedControl = pCurrentForm->GetFocused();
192         if (pFocusedControl)
193         {
194                 pFocusedControl->SetFocused();
195         }
196         else
197         {
198                 pCurrentForm->SetFocused();
199         }
200         _AccessibilityManager::GetInstance()->RequestAutoReading(_ACCESSIBILITY_AUTO_READING_MODE_FIRST_ITEM);
201 }
202
203 bool
204 _Frame::OnNotifiedN(const _Control& source, IList* pArgs)
205 {
206         SysTryReturn(NID_UI_CTRL, pArgs, false, E_SYSTEM, "[E_SYSTEM] pArgs is null.")
207
208         String* pType = dynamic_cast <String*>(pArgs->GetAt(0));
209         SysTryReturn(NID_UI_CTRL, pType, false, E_SYSTEM, "[E_SYSTEM] pType is null.")
210
211         if (*pType == L"VisibilityEvent")
212         {
213                 int obscured = 0;
214
215                 Integer* pObscured = dynamic_cast<Integer*>(pArgs->GetAt(1));
216                 if (pObscured == null)
217                 {
218                         pArgs->RemoveAll(true);
219                         delete pArgs;
220
221                         return true;
222                 }
223
224                 obscured = pObscured->ToInt();
225                 if (obscured == 0)
226                 {
227                         __activated = true;
228                         OnFrameActivated();
229                 }
230                 else
231                 {
232                         __activated = false;
233                         OnFrameDeactivated();
234                 }
235
236                 pArgs->RemoveAll(true);
237                 delete pArgs;
238
239                 return true;
240         }
241         else if (*pType == _ACTIVATE_FRAME)
242         {
243                 _EcoreEvas* pEcoreEvas = GetEcoreEvasMgr()->GetEcoreEvas();
244                 if (pEcoreEvas)
245                 {
246                         pEcoreEvas->ActivateWindow(*this);
247                 }
248
249                 pArgs->RemoveAll(true);
250                 delete pArgs;
251
252                 return true;
253         }
254
255         return false;
256 }
257
258 void
259 _Frame::OnFrameActivated(void)
260 {
261         int childcount = GetChildCount();
262
263         for (int i = 0 ; i < childcount ; i++)
264         {
265                 _Control* pChild = GetChild(i);
266                 _Form* pForm = dynamic_cast<_Form*>(pChild);
267                 if (pForm)
268                 {
269                         pForm->MoveOverlayRegion(true);
270                 }
271         }
272
273         // Fire Event.
274         IEventArg* pArg = _FrameEvent::CreateFrameEventArgN(*this, _FRAME_STATUS_ACTIVATED);
275         __pFrameEvent->Fire(*pArg);
276
277         if (GetChildCount() < 1)
278         {
279                 _EcoreEvas* pEcoreEvas = GetEcoreEvasMgr()->GetEcoreEvas();
280                 SysTryReturnVoidResult(NID_UI_CTRL, pEcoreEvas, E_SYSTEM, "[E_SYSTEM] Unable to get evas");
281
282                 if (GetShowMode() == FRAME_SHOW_MODE_FULL_SCREEN)
283                 {
284                         pEcoreEvas->SetIndicatorShowState(*GetRootWindow(), false);
285                 }
286         }
287 }
288
289 void
290 _Frame::OnFrameDeactivated(void)
291 {
292         int childcount = GetChildCount();
293
294         for (int i = 0 ; i < childcount ; i++)
295         {
296                 _Control* pChild = GetChild(i);
297                 _Form* pForm = dynamic_cast<_Form*>(pChild);
298                 if (pForm)
299                 {
300                         pForm->MoveOverlayRegion(false);
301                 }
302         }
303
304         // Fire Event.
305         IEventArg* pArg = _FrameEvent::CreateFrameEventArgN(*this, _FRAME_STATUS_DEACTIVATED);
306         __pFrameEvent->Fire(*pArg);
307
308         _TouchManager* pTouchManager = _TouchManager::GetInstance();
309         if (pTouchManager)
310         {
311                 pTouchManager->SetTouchCanceled(null);
312         }
313 }
314
315 void
316 _Frame::OnFrameMinimized(void)
317 {
318         IEventArg* pArg = _FrameEvent::CreateFrameEventArgN(*this, _FRAME_STATUS_MINIMIZED);
319         __pFrameEvent->Fire(*pArg);
320 }
321
322 void
323 _Frame::OnFrameRestored(void)
324 {
325         __minimized = false;
326
327         IEventArg* pArg = _FrameEvent::CreateFrameEventArgN(*this, _FRAME_STATUS_RESTORED);
328         __pFrameEvent->Fire(*pArg);
329 }
330
331 bool
332 _Frame::IsFocusableDescendant(const _Control* pFocus) const
333 {
334         const _Control* pTopChild = GetChild(GetChildCount() - 1); // Find the current Form.
335         const _Control* pTop = pFocus;
336
337         if (pTop == this)
338         {
339                 return true;
340         }
341
342         // 1. Find the Form of the pFocus.
343         // 2. If the Form is the current Form, then return true.
344         while (pTop)
345         {
346                 if (pTop == pTopChild)
347                 {
348                         return true;
349                 }
350                 pTop = pTop->GetParent();
351         }
352
353         return false;
354 }
355
356 void
357 _Frame::SetCurrentForm(const _Form* pForm)
358 {
359         result r = E_SUCCESS;
360
361         SysTryReturnVoidResult(NID_UI_CTRL, pForm != null, E_INVALID_ARG, "[E_INVALID_ARG] Form to become a new current form is null");
362         _Form* pNewForm = const_cast<_Form*>(pForm);
363
364         _Form* pCurrentForm = GetCurrentForm();
365         pNewForm->AddIndicatorObject();
366
367         if (pCurrentForm != null)
368         {
369                 if (pCurrentForm != pForm)
370                 {
371                         // Change order
372                         r = MoveChildToTop(*pForm);
373                         SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
374                         pNewForm->MoveOverlayRegion(true);
375
376                         pCurrentForm->SetVisibleState(false);
377                         pCurrentForm->MoveOverlayRegion(false);
378
379                         if (__pFormActivationChangeEventListener)
380                                 __pFormActivationChangeEventListener->OnFormDeactivated(*pCurrentForm);
381                 }
382         }
383
384         _Control* pFocus = pNewForm->GetFocused();
385         if (pFocus)
386         {
387                 pFocus->SetFocused();
388         }
389         else
390         {
391                 pNewForm->SetFocused();
392         }
393
394         pNewForm->SetVisibleState(true);
395         pNewForm->SetUpdateLayoutState(true);
396
397         if (__pFormActivationChangeEventListener)
398                 __pFormActivationChangeEventListener->OnFormActivated(*pNewForm);
399
400         SetLastResult(E_SUCCESS);
401
402         return;
403 }
404
405 _Form*
406 _Frame::GetCurrentForm(void) const
407 {
408         _Form* pCurrentForm = null;
409         int controlCount = GetChildCount();
410
411         if (controlCount > 0)
412         {
413                 for (int i = controlCount; i > 0; i--)
414                 {
415                         pCurrentForm = dynamic_cast<_Form*>(GetChild(i - 1));
416                         SysTryReturn(NID_UI_CTRL, pCurrentForm != null, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
417                         if (pCurrentForm->IsVisible())
418                         {
419                                 break;
420                         }
421                 }
422         }
423
424         return pCurrentForm;
425 }
426
427 bool
428 _Frame::IsOrientationRoot(void) const
429 {
430         return true;
431 }
432
433 void
434 _Frame::SetRotation(bool rotation)
435 {
436         __rotation = rotation;
437 }
438
439 void
440 _Frame::AddFrameEventListener(const _IFrameEventListener& listener)
441 {
442         __constructed = true;
443
444         result r = __pFrameEvent->AddListener(listener);
445         SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
446 }
447
448 void
449 _Frame::RemoveFrameEventListener(const _IFrameEventListener& listener)
450 {
451         result r = __pFrameEvent->RemoveListener(listener);
452         SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
453 }
454
455 void
456 _Frame::SetFormActivationChangeEventListener(const _IFormActivationChangeEventListener* plistener)
457 {
458         __pFormActivationChangeEventListener = const_cast<_IFormActivationChangeEventListener*>(plistener);
459 }
460
461
462 void
463 _Frame::SetFloatingBounds(const FloatRectangle& rect)
464 {
465         __floatingBounds = rect;
466 }
467
468 void
469 _Frame::SetFloatingBounds(const Rectangle& rect)
470 {
471         __floatingBounds = _CoordinateSystemUtils::ConvertToFloat(rect);
472 }
473
474 result
475 _Frame::SetShowMode(FrameShowMode showMode)
476 {
477         _EcoreEvas* pEcoreEvas = GetEcoreEvasMgr()->GetEcoreEvas();
478         SysTryReturnResult(NID_UI_CTRL, pEcoreEvas, E_SYSTEM, "The method cannot proceed due to a severe system error.");
479
480         if (showMode == FRAME_SHOW_MODE_MINIMIZED)
481         {
482                 if (__minimized == true)
483                 {
484                         return E_SUCCESS;
485                 }
486
487                 pEcoreEvas->MinimizeWindow(*GetRootWindow());
488                 __minimized = true;
489
490                 return E_SUCCESS;
491         }
492         else
493         {
494                 if (__minimized == true)
495                 {
496                         return E_SYSTEM;
497                 }
498         }
499
500         bool changeMode = true;
501
502         if ((showMode == FRAME_SHOW_MODE_PARTIAL_SCREEN) || (showMode == FRAME_SHOW_MODE_PARTIAL_SCREEN_FLOATING))
503         {
504                 _Form* pCurrentForm = GetCurrentForm();
505
506                 if (pCurrentForm)
507                 {
508                         if (pCurrentForm->GetFormStyle() & _FORM_STYLE_INDICATOR)
509                         {
510                                 changeMode = false;
511                         }
512                 }
513         }
514
515         SysTryReturnResult(NID_UI_CTRL, changeMode == true, E_SYSTEM, "The method cannot proceed due to a severe system error.");
516
517         int oldShowMode = __showMode;
518         __showMode = showMode;
519
520         result r = E_SUCCESS;
521
522         switch (__showMode)
523         {
524         case FRAME_SHOW_MODE_FULL_SCREEN:
525                 if (oldShowMode == FRAME_SHOW_MODE_PARTIAL_SCREEN_FLOATING)
526                 {
527                         r = pEcoreEvas->SetFloatingMode(*GetRootWindow(), false);
528                         SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
529                 }
530
531                 if (oldShowMode != FRAME_SHOW_MODE_FULL_SCREEN)
532                 {
533                         FloatDimension screen = _ControlManager::GetInstance()->GetScreenSizeF();
534
535                         __restore = true;
536
537                         if (GetOrientation() == _CONTROL_ORIENTATION_PORTRAIT)
538                         {
539                                 SetBounds(FloatRectangle(0.0f, 0.0f, screen.width, screen.height));
540                         }
541                         else
542                         {
543                                 SetBounds(FloatRectangle(0.0f, 0.0f, screen.height, screen.width));
544                         }
545
546                         __restore = false;
547                 }
548
549                 break;
550         case FRAME_SHOW_MODE_PARTIAL_SCREEN:
551                 if (oldShowMode == FRAME_SHOW_MODE_PARTIAL_SCREEN_FLOATING)
552                 {
553                         r = pEcoreEvas->SetFloatingMode(*GetRootWindow(), false);
554                         SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
555                 }
556
557                 if (oldShowMode == FRAME_SHOW_MODE_FULL_SCREEN)
558                 {
559                         SetBounds(__floatingBounds);
560                 }
561                 else if (oldShowMode == FRAME_SHOW_MODE_PARTIAL_SCREEN_FLOATING)
562                 {
563                         pEcoreEvas->SetWindowBounds(*GetRootWindow(), _CoordinateSystemUtils::ConvertToInteger(__floatingBounds));
564                 }
565
566                 break;
567         case FRAME_SHOW_MODE_PARTIAL_SCREEN_FLOATING:
568                 if (oldShowMode != FRAME_SHOW_MODE_PARTIAL_SCREEN_FLOATING)
569                 {
570                         r = pEcoreEvas->SetFloatingMode(*GetRootWindow(), true);
571                         SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
572                 }
573
574                 if (oldShowMode == FRAME_SHOW_MODE_FULL_SCREEN)
575                 {
576                         SetBounds(__floatingBounds);
577                 }
578
579                 break;
580         default:
581                 break;
582         }
583
584         return E_SUCCESS;
585 }
586
587 FrameShowMode
588 _Frame::GetShowMode(bool minimize) const
589 {
590         if (minimize)
591         {
592                 if (__minimized == true)
593                 {
594                         return FRAME_SHOW_MODE_MINIMIZED;
595                 }
596                 else
597                 {
598                         return __showMode;
599                 }
600         }
601         else
602         {
603                 return __showMode;
604         }
605 }
606
607 bool
608 _Frame::IsActivated(void) const
609 {
610         return __activated;
611 }
612
613 void
614 _Frame::OnChildAttached(const _Control& child)
615 {
616         _Form* pCurrentForm = GetCurrentForm();
617
618         if (pCurrentForm == &child)
619         {
620                 int controlCount = GetChildCount();
621
622                 if (controlCount > 1)
623                 {
624                         _Control* pOldCurrentForm = GetChild(controlCount - 2);
625                         SysTryReturnVoidResult(NID_UI_CTRL, pOldCurrentForm != null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
626                         pOldCurrentForm->SetVisibleState(false);
627                 }
628         }
629 }
630
631 void
632 _Frame::OnChildDetached(const _Control& child)
633 {
634         int controlCount = GetChildCount();
635
636         if (controlCount > 0)
637         {
638                 _Control* pCurrentForm = GetChild(controlCount - 1);
639                 SysTryReturnVoidResult(NID_UI_CTRL, pCurrentForm, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
640                 pCurrentForm->SetVisibleState(true);
641         }
642         else
643         {
644                 _EcoreEvas* pEcoreEvas = GetEcoreEvasMgr()->GetEcoreEvas();
645                 SysTryReturnVoidResult(NID_UI_CTRL, pEcoreEvas, E_SYSTEM, "[E_SYSTEM] Unable to get evas");
646                 pEcoreEvas->SetIndicatorShowState(*GetRootWindow(), false);
647         }
648 }
649
650 result
651 _Frame::OnBoundsChanging(const FloatRectangle& bounds)
652 {
653         int appType = _AppInfo::GetAppType();
654         if (appType & _APP_TYPE_IME_APP)
655         {
656                 SysLog(NID_UI_CTRL, "[Ime Rotation]");
657                 return E_SUCCESS;
658         }
659
660         if (__restore == false)
661         {
662                 __floatingBounds = bounds;
663         }
664
665         if ((__showMode == FRAME_SHOW_MODE_FULL_SCREEN) && (__restore == false))
666         {
667                 if (__constructed == false)
668                 {
669                         return E_SUCCESS;
670                 }
671                 else
672                 {
673                         if (__rotation == true)
674                         {
675                                 return E_SUCCESS;
676                         }
677                         else
678                         {
679                                 return E_UNSUPPORTED_OPERATION;
680                         }
681                 }
682         }
683
684         _EcoreEvas* pEcoreEvas = GetEcoreEvasMgr()->GetEcoreEvas();
685         SysTryReturn(NID_UI, pEcoreEvas, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error occurred.");
686
687         pEcoreEvas->SetWindowBounds(*GetRootWindow(), _CoordinateSystemUtils::ConvertToInteger(bounds));
688         result r = GetLastResult();
689         SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
690
691         return r;
692 }
693
694
695 result
696 _Frame::OnAttached(void)
697 {
698         _EcoreEvas* pEcoreEvas = GetEcoreEvasMgr()->GetEcoreEvas();
699         SysAssert(pEcoreEvas);
700
701         pEcoreEvas->SetWindowVisibleState(*GetRootWindow(), true);
702
703         return E_SUCCESS;
704 }
705
706 void
707 _Frame::OnBackgroundColorChanged(Color& backgroundColor)
708 {
709         _RootVisualElement* pRootVE = GetRootVisualElement();
710         SysAssert(pRootVE);
711
712         _EflLayer* pLayer = static_cast<_EflLayer*>(pRootVE->GetNativeLayer());
713         SysAssert(pLayer);
714
715         byte alpha = backgroundColor.GetAlpha();
716         float opacity = static_cast<float>(alpha) / 255.0f;
717
718         pLayer->SetOpacity(opacity);
719
720         // Restore
721         FrameShowMode showMode = GetShowMode(false);
722         SetShowMode(FRAME_SHOW_MODE_FULL_SCREEN);
723
724         SetShowMode(showMode);
725
726         _EcoreEvas* pEcoreEvas = GetEcoreEvasMgr()->GetEcoreEvas();
727         if (!pEcoreEvas)
728         {
729                 return;
730         }
731
732         Orientation mode = ORIENTATION_PORTRAIT;
733         
734         _Form* pCurrentForm = GetCurrentForm();
735         if (pCurrentForm)
736         {
737                 _FormImpl* pFormImpl = static_cast<_FormImpl*>(pCurrentForm->GetUserData());
738                 if (pFormImpl)
739                 {
740                         mode = pFormImpl->GetOrientation();
741                 }
742         }
743         else
744         {
745                 _FrameImpl* pFrameImpl = static_cast<_FrameImpl*>(GetUserData());
746                 if (pFrameImpl)
747                 {
748                         mode = pFrameImpl->GetOrientation();
749                 }
750         }
751
752         switch (mode)
753         {
754         case ORIENTATION_PORTRAIT:
755                 pEcoreEvas->SetWindowPreferredRotation(*this, 0, true);
756                 break;
757         case ORIENTATION_LANDSCAPE:
758                 pEcoreEvas->SetWindowPreferredRotation(*this, 270, true);
759                 break;
760         case ORIENTATION_PORTRAIT_REVERSE:
761                 pEcoreEvas->SetWindowPreferredRotation(*this, 180, true);
762                 break;
763         case ORIENTATION_LANDSCAPE_REVERSE:
764                 pEcoreEvas->SetWindowPreferredRotation(*this, 90, true);
765                 break;
766         case ORIENTATION_AUTOMATIC:
767                 {
768                         pEcoreEvas->SetWindowPreferredRotation(*this, -1);
769                         int autoRotation[3] = {0, 90, 270};
770                         pEcoreEvas->SetWindowAvailabledRotation(*this, autoRotation, 3, true);
771                 }
772                 break;
773         case ORIENTATION_AUTOMATIC_FOUR_DIRECTION:
774                 {
775                         pEcoreEvas->SetWindowPreferredRotation(*this, -1);
776                         int autoFourRotation[4] = {0, 90, 180, 270};
777                         pEcoreEvas->SetWindowAvailabledRotation(*this, autoFourRotation, 4, true);
778                 }
779                 break;
780         default:
781                 break;
782         }
783 }
784
785 void
786 _Frame::ResetFocusList(void)
787 {
788         Tizen::Ui::Controls::_Form* pCurrentForm = GetCurrentForm();
789         if (pCurrentForm)
790         {
791                 pCurrentForm->ResetFocusList();
792         }
793 }
794 }}} // Tizen::Ui::Controls