Merge "Applied focus UI on TableView" 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         _Control* pFocusedControl = pCurrentForm->GetFocused();
190         if (pFocusedControl)
191         {
192                 pFocusedControl->SetFocused();
193         }
194         else
195         {
196                 pCurrentForm->SetFocused();
197         }
198         _AccessibilityManager::GetInstance()->RequestAutoReading(_ACCESSIBILITY_AUTO_READING_MODE_FIRST_ITEM);
199 }
200
201 bool
202 _Frame::OnNotifiedN(const _Control& source, IList* pArgs)
203 {
204         SysTryReturn(NID_UI_CTRL, pArgs, false, E_SYSTEM, "[E_SYSTEM] pArgs is null.")
205
206         String* pType = dynamic_cast <String*>(pArgs->GetAt(0));
207         SysTryReturn(NID_UI_CTRL, pType, false, E_SYSTEM, "[E_SYSTEM] pType is null.")
208
209         if (*pType == L"VisibilityEvent")
210         {
211                 int obscured = 0;
212
213                 Integer* pObscured = dynamic_cast<Integer*>(pArgs->GetAt(1));
214                 if (pObscured == null)
215                 {
216                         pArgs->RemoveAll(true);
217                         delete pArgs;
218
219                         return true;
220                 }
221
222                 obscured = pObscured->ToInt();
223                 if (obscured == 0)
224                 {
225                         __activated = true;
226                         OnFrameActivated();
227                 }
228                 else
229                 {
230                         __activated = false;
231                         OnFrameDeactivated();
232                 }
233
234                 pArgs->RemoveAll(true);
235                 delete pArgs;
236
237                 return true;
238         }
239         else if (*pType == _ACTIVATE_FRAME)
240         {
241                 _EcoreEvas* pEcoreEvas = GetEcoreEvasMgr()->GetEcoreEvas();
242                 if (pEcoreEvas)
243                 {
244                         pEcoreEvas->ActivateWindow(*this);
245                 }
246
247                 pArgs->RemoveAll(true);
248                 delete pArgs;
249
250                 return true;
251         }
252
253         return false;
254 }
255
256 void
257 _Frame::OnFrameActivated(void)
258 {
259         int childcount = GetChildCount();
260
261         for (int i = 0 ; i < childcount ; i++)
262         {
263                 _Control* pChild = GetChild(i);
264                 _Form* pForm = dynamic_cast<_Form*>(pChild);
265                 if (pForm)
266                 {
267                         pForm->MoveOverlayRegion(true);
268                 }
269         }
270
271         // Fire Event.
272         IEventArg* pArg = _FrameEvent::CreateFrameEventArgN(*this, _FRAME_STATUS_ACTIVATED);
273         __pFrameEvent->Fire(*pArg);
274
275         if (GetChildCount() < 1)
276         {
277                 _EcoreEvas* pEcoreEvas = GetEcoreEvasMgr()->GetEcoreEvas();
278                 SysTryReturnVoidResult(NID_UI_CTRL, pEcoreEvas, E_SYSTEM, "[E_SYSTEM] Unable to get evas");
279
280                 if (GetShowMode() == FRAME_SHOW_MODE_FULL_SCREEN)
281                 {
282                         pEcoreEvas->SetIndicatorShowState(*GetRootWindow(), false);
283                 }
284         }
285 }
286
287 void
288 _Frame::OnFrameDeactivated(void)
289 {
290         int childcount = GetChildCount();
291
292         for (int i = 0 ; i < childcount ; i++)
293         {
294                 _Control* pChild = GetChild(i);
295                 _Form* pForm = dynamic_cast<_Form*>(pChild);
296                 if (pForm)
297                 {
298                         pForm->MoveOverlayRegion(false);
299                 }
300         }
301
302         // Fire Event.
303         IEventArg* pArg = _FrameEvent::CreateFrameEventArgN(*this, _FRAME_STATUS_DEACTIVATED);
304         __pFrameEvent->Fire(*pArg);
305
306         _TouchManager* pTouchManager = _TouchManager::GetInstance();
307         if (pTouchManager)
308         {
309                 pTouchManager->SetTouchCanceled(null);
310         }
311 }
312
313 void
314 _Frame::OnFrameMinimized(void)
315 {
316         IEventArg* pArg = _FrameEvent::CreateFrameEventArgN(*this, _FRAME_STATUS_MINIMIZED);
317         __pFrameEvent->Fire(*pArg);
318 }
319
320 void
321 _Frame::OnFrameRestored(void)
322 {
323         __minimized = false;
324
325         IEventArg* pArg = _FrameEvent::CreateFrameEventArgN(*this, _FRAME_STATUS_RESTORED);
326         __pFrameEvent->Fire(*pArg);
327 }
328
329 bool
330 _Frame::IsFocusableDescendant(const _Control* pFocus) const
331 {
332         const _Control* pTopChild = GetChild(GetChildCount() - 1); // Find the current Form.
333         const _Control* pTop = pFocus;
334
335         if (pTop == this)
336         {
337                 return true;
338         }
339
340         // 1. Find the Form of the pFocus.
341         // 2. If the Form is the current Form, then return true.
342         while (pTop)
343         {
344                 if (pTop == pTopChild)
345                 {
346                         return true;
347                 }
348                 pTop = pTop->GetParent();
349         }
350
351         return false;
352 }
353
354 void
355 _Frame::SetCurrentForm(const _Form* pForm)
356 {
357         result r = E_SUCCESS;
358
359         SysTryReturnVoidResult(NID_UI_CTRL, pForm != null, E_INVALID_ARG, "[E_INVALID_ARG] Form to become a new current form is null");
360         _Form* pNewForm = const_cast<_Form*>(pForm);
361
362         _Form* pCurrentForm = GetCurrentForm();
363         pNewForm->AddIndicatorObject();
364
365         if (pCurrentForm != null)
366         {
367                 if (pCurrentForm != pForm)
368                 {
369                         // Change order
370                         r = MoveChildToTop(*pForm);
371                         SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
372                         pNewForm->MoveOverlayRegion(true);
373
374                         pCurrentForm->SetVisibleState(false);
375                         pCurrentForm->MoveOverlayRegion(false);
376
377                         if (__pFormActivationChangeEventListener)
378                                 __pFormActivationChangeEventListener->OnFormDeactivated(*pCurrentForm);
379                 }
380         }
381
382         _Control* pFocus = pNewForm->GetFocused();
383         if (pFocus)
384         {
385                 pFocus->SetFocused();
386         }
387         else
388         {
389                 pNewForm->SetFocused();
390         }
391
392         pNewForm->SetVisibleState(true);
393         pNewForm->SetUpdateLayoutState(true);
394
395         if (__pFormActivationChangeEventListener)
396                 __pFormActivationChangeEventListener->OnFormActivated(*pNewForm);
397
398         SetLastResult(E_SUCCESS);
399
400         return;
401 }
402
403 _Form*
404 _Frame::GetCurrentForm(void) const
405 {
406         _Form* pCurrentForm = null;
407         int controlCount = GetChildCount();
408
409         if (controlCount > 0)
410         {
411                 for (int i = controlCount; i > 0; i--)
412                 {
413                         pCurrentForm = dynamic_cast<_Form*>(GetChild(i - 1));
414                         SysTryReturn(NID_UI_CTRL, pCurrentForm != null, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
415                         if (pCurrentForm->IsVisible())
416                         {
417                                 break;
418                         }
419                 }
420         }
421
422         return pCurrentForm;
423 }
424
425 bool
426 _Frame::IsOrientationRoot(void) const
427 {
428         return true;
429 }
430
431 void
432 _Frame::SetRotation(bool rotation)
433 {
434         __rotation = rotation;
435 }
436
437 void
438 _Frame::AddFrameEventListener(const _IFrameEventListener& listener)
439 {
440         __constructed = true;
441
442         result r = __pFrameEvent->AddListener(listener);
443         SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
444 }
445
446 void
447 _Frame::RemoveFrameEventListener(const _IFrameEventListener& listener)
448 {
449         result r = __pFrameEvent->RemoveListener(listener);
450         SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
451 }
452
453 void
454 _Frame::SetFormActivationChangeEventListener(const _IFormActivationChangeEventListener* plistener)
455 {
456         __pFormActivationChangeEventListener = const_cast<_IFormActivationChangeEventListener*>(plistener);
457 }
458
459
460 void
461 _Frame::SetFloatingBounds(const FloatRectangle& rect)
462 {
463         __floatingBounds = rect;
464 }
465
466 void
467 _Frame::SetFloatingBounds(const Rectangle& rect)
468 {
469         __floatingBounds = _CoordinateSystemUtils::ConvertToFloat(rect);
470 }
471
472 result
473 _Frame::SetShowMode(FrameShowMode showMode)
474 {
475         _EcoreEvas* pEcoreEvas = GetEcoreEvasMgr()->GetEcoreEvas();
476         SysTryReturnResult(NID_UI_CTRL, pEcoreEvas, E_SYSTEM, "The method cannot proceed due to a severe system error.");
477
478         if (showMode == FRAME_SHOW_MODE_MINIMIZED)
479         {
480                 if (__minimized == true)
481                 {
482                         return E_SUCCESS;
483                 }
484
485                 pEcoreEvas->MinimizeWindow(*GetRootWindow());
486                 __minimized = true;
487
488                 return E_SUCCESS;
489         }
490         else
491         {
492                 if (__minimized == true)
493                 {
494                         return E_SYSTEM;
495                 }
496         }
497
498         bool changeMode = true;
499
500         if ((showMode == FRAME_SHOW_MODE_PARTIAL_SCREEN) || (showMode == FRAME_SHOW_MODE_PARTIAL_SCREEN_FLOATING))
501         {
502                 _Form* pCurrentForm = GetCurrentForm();
503
504                 if (pCurrentForm)
505                 {
506                         if (pCurrentForm->GetFormStyle() & _FORM_STYLE_INDICATOR)
507                         {
508                                 changeMode = false;
509                         }
510                 }
511         }
512
513         SysTryReturnResult(NID_UI_CTRL, changeMode == true, E_SYSTEM, "The method cannot proceed due to a severe system error.");
514
515         int oldShowMode = __showMode;
516         __showMode = showMode;
517
518         result r = E_SUCCESS;
519
520         switch (__showMode)
521         {
522         case FRAME_SHOW_MODE_FULL_SCREEN:
523                 if (oldShowMode == FRAME_SHOW_MODE_PARTIAL_SCREEN_FLOATING)
524                 {
525                         r = pEcoreEvas->SetFloatingMode(*GetRootWindow(), false);
526                         SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
527                 }
528
529                 if (oldShowMode != FRAME_SHOW_MODE_FULL_SCREEN)
530                 {
531                         FloatDimension screen = _ControlManager::GetInstance()->GetScreenSizeF();
532
533                         __restore = true;
534
535                         if (GetOrientation() == _CONTROL_ORIENTATION_PORTRAIT)
536                         {
537                                 SetBounds(FloatRectangle(0.0f, 0.0f, screen.width, screen.height));
538                         }
539                         else
540                         {
541                                 SetBounds(FloatRectangle(0.0f, 0.0f, screen.height, screen.width));
542                         }
543
544                         __restore = false;
545                 }
546
547                 break;
548         case FRAME_SHOW_MODE_PARTIAL_SCREEN:
549                 if (oldShowMode == FRAME_SHOW_MODE_PARTIAL_SCREEN_FLOATING)
550                 {
551                         r = pEcoreEvas->SetFloatingMode(*GetRootWindow(), false);
552                         SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
553                 }
554
555                 if (oldShowMode == FRAME_SHOW_MODE_FULL_SCREEN)
556                 {
557                         SetBounds(__floatingBounds);
558                 }
559                 else if (oldShowMode == FRAME_SHOW_MODE_PARTIAL_SCREEN_FLOATING)
560                 {
561                         pEcoreEvas->SetWindowBounds(*GetRootWindow(), _CoordinateSystemUtils::ConvertToInteger(__floatingBounds));
562                 }
563
564                 break;
565         case FRAME_SHOW_MODE_PARTIAL_SCREEN_FLOATING:
566                 if (oldShowMode != FRAME_SHOW_MODE_PARTIAL_SCREEN_FLOATING)
567                 {
568                         r = pEcoreEvas->SetFloatingMode(*GetRootWindow(), true);
569                         SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
570                 }
571
572                 if (oldShowMode == FRAME_SHOW_MODE_FULL_SCREEN)
573                 {
574                         SetBounds(__floatingBounds);
575                 }
576
577                 break;
578         default:
579                 break;
580         }
581
582         return E_SUCCESS;
583 }
584
585 FrameShowMode
586 _Frame::GetShowMode(bool minimize) const
587 {
588         if (minimize)
589         {
590                 if (__minimized == true)
591                 {
592                         return FRAME_SHOW_MODE_MINIMIZED;
593                 }
594                 else
595                 {
596                         return __showMode;
597                 }
598         }
599         else
600         {
601                 return __showMode;
602         }
603 }
604
605 bool
606 _Frame::IsActivated(void) const
607 {
608         return __activated;
609 }
610
611 void
612 _Frame::OnChildAttached(const _Control& child)
613 {
614         _Form* pCurrentForm = GetCurrentForm();
615
616         if (pCurrentForm == &child)
617         {
618                 int controlCount = GetChildCount();
619
620                 if (controlCount > 1)
621                 {
622                         _Control* pOldCurrentForm = GetChild(controlCount - 2);
623                         SysTryReturnVoidResult(NID_UI_CTRL, pOldCurrentForm != null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
624                         pOldCurrentForm->SetVisibleState(false);
625                 }
626         }
627 }
628
629 void
630 _Frame::OnChildDetached(const _Control& child)
631 {
632         int controlCount = GetChildCount();
633
634         if (controlCount > 0)
635         {
636                 _Control* pCurrentForm = GetChild(controlCount - 1);
637                 SysTryReturnVoidResult(NID_UI_CTRL, pCurrentForm, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
638                 pCurrentForm->SetVisibleState(true);
639         }
640         else
641         {
642                 _EcoreEvas* pEcoreEvas = GetEcoreEvasMgr()->GetEcoreEvas();
643                 SysTryReturnVoidResult(NID_UI_CTRL, pEcoreEvas, E_SYSTEM, "[E_SYSTEM] Unable to get evas");
644                 pEcoreEvas->SetIndicatorShowState(*GetRootWindow(), false);
645         }
646 }
647
648 result
649 _Frame::OnBoundsChanging(const FloatRectangle& bounds)
650 {
651         int appType = _AppInfo::GetAppType();
652         if (appType & _APP_TYPE_IME_APP)
653         {
654                 SysLog(NID_UI_CTRL, "[Ime Rotation]");
655                 return E_SUCCESS;
656         }
657
658         if (__restore == false)
659         {
660                 __floatingBounds = bounds;
661         }
662
663         if ((__showMode == FRAME_SHOW_MODE_FULL_SCREEN) && (__restore == false))
664         {
665                 if (__constructed == false)
666                 {
667                         return E_SUCCESS;
668                 }
669                 else
670                 {
671                         if (__rotation == true)
672                         {
673                                 return E_SUCCESS;
674                         }
675                         else
676                         {
677                                 return E_UNSUPPORTED_OPERATION;
678                         }
679                 }
680         }
681
682         _EcoreEvas* pEcoreEvas = GetEcoreEvasMgr()->GetEcoreEvas();
683         SysTryReturn(NID_UI, pEcoreEvas, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error occurred.");
684
685         pEcoreEvas->SetWindowBounds(*GetRootWindow(), _CoordinateSystemUtils::ConvertToInteger(bounds));
686         result r = GetLastResult();
687         SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
688
689         return r;
690 }
691
692
693 result
694 _Frame::OnAttached(void)
695 {
696         _EcoreEvas* pEcoreEvas = GetEcoreEvasMgr()->GetEcoreEvas();
697         SysAssert(pEcoreEvas);
698
699         pEcoreEvas->SetWindowVisibleState(*GetRootWindow(), true);
700
701         return E_SUCCESS;
702 }
703
704 void
705 _Frame::OnBackgroundColorChanged(Color& backgroundColor)
706 {
707         _RootVisualElement* pRootVE = GetRootVisualElement();
708         SysAssert(pRootVE);
709
710         _EflLayer* pLayer = static_cast<_EflLayer*>(pRootVE->GetNativeLayer());
711         SysAssert(pLayer);
712
713         byte alpha = backgroundColor.GetAlpha();
714         float opacity = static_cast<float>(alpha) / 255.0f;
715
716         pLayer->SetOpacity(opacity);
717
718         // Restore
719         FrameShowMode showMode = GetShowMode(false);
720         SetShowMode(FRAME_SHOW_MODE_FULL_SCREEN);
721
722         SetShowMode(showMode);
723
724         _EcoreEvas* pEcoreEvas = GetEcoreEvasMgr()->GetEcoreEvas();
725         if (!pEcoreEvas)
726         {
727                 return;
728         }
729
730         Orientation mode = ORIENTATION_PORTRAIT;
731         
732         _Form* pCurrentForm = GetCurrentForm();
733         if (pCurrentForm)
734         {
735                 _FormImpl* pFormImpl = static_cast<_FormImpl*>(pCurrentForm->GetUserData());
736                 if (pFormImpl)
737                 {
738                         mode = pFormImpl->GetOrientation();
739                 }
740         }
741         else
742         {
743                 _FrameImpl* pFrameImpl = static_cast<_FrameImpl*>(GetUserData());
744                 if (pFrameImpl)
745                 {
746                         mode = pFrameImpl->GetOrientation();
747                 }
748         }
749
750         switch (mode)
751         {
752         case ORIENTATION_PORTRAIT:
753                 pEcoreEvas->SetWindowPreferredRotation(*this, 0, true);
754                 break;
755         case ORIENTATION_LANDSCAPE:
756                 pEcoreEvas->SetWindowPreferredRotation(*this, 270, true);
757                 break;
758         case ORIENTATION_PORTRAIT_REVERSE:
759                 pEcoreEvas->SetWindowPreferredRotation(*this, 180, true);
760                 break;
761         case ORIENTATION_LANDSCAPE_REVERSE:
762                 pEcoreEvas->SetWindowPreferredRotation(*this, 90, true);
763                 break;
764         case ORIENTATION_AUTOMATIC:
765                 {
766                         pEcoreEvas->SetWindowPreferredRotation(*this, -1);
767                         int autoRotation[3] = {0, 90, 270};
768                         pEcoreEvas->SetWindowAvailabledRotation(*this, autoRotation, 3, true);
769                 }
770                 break;
771         case ORIENTATION_AUTOMATIC_FOUR_DIRECTION:
772                 {
773                         pEcoreEvas->SetWindowPreferredRotation(*this, -1);
774                         int autoFourRotation[4] = {0, 90, 180, 270};
775                         pEcoreEvas->SetWindowAvailabledRotation(*this, autoFourRotation, 4, true);
776                 }
777                 break;
778         default:
779                 break;
780         }
781 }
782
783 void
784 _Frame::ResetFocusList(void)
785 {
786         Tizen::Ui::Controls::_Form* pCurrentForm = GetCurrentForm();
787         if (pCurrentForm)
788         {
789                 pCurrentForm->ResetFocusList();
790         }
791 }
792 }}} // Tizen::Ui::Controls