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