Merge "Modified return value of move event for scroll." 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* pFocusControl = pCurrentForm->GetFocusControl();
192         if (pFocusControl)
193         {
194                 pFocusControl->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                         _Control* pFocusTraversalControl = pCurrentForm->GetFocusTraversalControl();
372                         if (pFocusTraversalControl)
373                         {
374                                 pFocusTraversalControl->SetFocusModeStateEnabled(false) ;
375                         }
376                         // Change order
377                         r = MoveChildToTop(*pForm);
378                         SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
379                         pNewForm->MoveOverlayRegion(true);
380
381                         pCurrentForm->SetVisibleState(false);
382                         pCurrentForm->MoveOverlayRegion(false);
383
384                         if (__pFormActivationChangeEventListener)
385                                 __pFormActivationChangeEventListener->OnFormDeactivated(*pCurrentForm);
386                 }
387         }
388
389         _Control* pFocus = pNewForm->GetFocusControl();
390         if (pFocus)
391         {
392                 pFocus->SetFocused();
393         }
394         else
395         {
396                 pNewForm->SetFocused();
397         }
398
399         pNewForm->SetVisibleState(true);
400         pNewForm->SetUpdateLayoutState(true);
401
402         if (__pFormActivationChangeEventListener)
403                 __pFormActivationChangeEventListener->OnFormActivated(*pNewForm);
404
405         SetLastResult(E_SUCCESS);
406
407         return;
408 }
409
410 _Form*
411 _Frame::GetCurrentForm(void) const
412 {
413         _Form* pCurrentForm = null;
414         int controlCount = GetChildCount();
415
416         if (controlCount > 0)
417         {
418                 for (int i = controlCount; i > 0; i--)
419                 {
420                         pCurrentForm = dynamic_cast<_Form*>(GetChild(i - 1));
421                         SysTryReturn(NID_UI_CTRL, pCurrentForm != null, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
422                         if (pCurrentForm->IsVisible())
423                         {
424                                 break;
425                         }
426                 }
427         }
428
429         return pCurrentForm;
430 }
431
432 bool
433 _Frame::IsOrientationRoot(void) const
434 {
435         return true;
436 }
437
438 void
439 _Frame::SetRotation(bool rotation)
440 {
441         __rotation = rotation;
442 }
443
444 void
445 _Frame::AddFrameEventListener(const _IFrameEventListener& listener)
446 {
447         __constructed = true;
448
449         result r = __pFrameEvent->AddListener(listener);
450         SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
451 }
452
453 void
454 _Frame::RemoveFrameEventListener(const _IFrameEventListener& listener)
455 {
456         result r = __pFrameEvent->RemoveListener(listener);
457         SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
458 }
459
460 void
461 _Frame::SetFormActivationChangeEventListener(const _IFormActivationChangeEventListener* plistener)
462 {
463         __pFormActivationChangeEventListener = const_cast<_IFormActivationChangeEventListener*>(plistener);
464 }
465
466
467 void
468 _Frame::SetFloatingBounds(const FloatRectangle& rect)
469 {
470         __floatingBounds = rect;
471 }
472
473 void
474 _Frame::SetFloatingBounds(const Rectangle& rect)
475 {
476         __floatingBounds = _CoordinateSystemUtils::ConvertToFloat(rect);
477 }
478
479 result
480 _Frame::SetShowMode(FrameShowMode showMode)
481 {
482         _EcoreEvas* pEcoreEvas = GetEcoreEvasMgr()->GetEcoreEvas();
483         SysTryReturnResult(NID_UI_CTRL, pEcoreEvas, E_SYSTEM, "The method cannot proceed due to a severe system error.");
484
485         if (showMode == FRAME_SHOW_MODE_MINIMIZED)
486         {
487                 if (__minimized == true)
488                 {
489                         return E_SUCCESS;
490                 }
491
492                 pEcoreEvas->MinimizeWindow(*GetRootWindow());
493                 __minimized = true;
494
495                 return E_SUCCESS;
496         }
497         else
498         {
499                 if (__minimized == true)
500                 {
501                         return E_SYSTEM;
502                 }
503         }
504
505         bool changeMode = true;
506
507         if ((showMode == FRAME_SHOW_MODE_PARTIAL_SCREEN) || (showMode == FRAME_SHOW_MODE_PARTIAL_SCREEN_FLOATING))
508         {
509                 _Form* pCurrentForm = GetCurrentForm();
510
511                 if (pCurrentForm)
512                 {
513                         if (pCurrentForm->GetFormStyle() & _FORM_STYLE_INDICATOR)
514                         {
515                                 changeMode = false;
516                         }
517                 }
518         }
519
520         SysTryReturnResult(NID_UI_CTRL, changeMode == true, E_SYSTEM, "The method cannot proceed due to a severe system error.");
521
522         int oldShowMode = __showMode;
523         __showMode = showMode;
524
525         result r = E_SUCCESS;
526
527         switch (__showMode)
528         {
529         case FRAME_SHOW_MODE_FULL_SCREEN:
530                 if (oldShowMode == FRAME_SHOW_MODE_PARTIAL_SCREEN_FLOATING)
531                 {
532                         r = pEcoreEvas->SetFloatingMode(*GetRootWindow(), false);
533                         SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
534                 }
535
536                 if (oldShowMode != FRAME_SHOW_MODE_FULL_SCREEN)
537                 {
538                         FloatDimension screen = _ControlManager::GetInstance()->GetScreenSizeF();
539
540                         __restore = true;
541
542                         if (GetOrientation() == _CONTROL_ORIENTATION_PORTRAIT)
543                         {
544                                 SetBounds(FloatRectangle(0.0f, 0.0f, screen.width, screen.height));
545                         }
546                         else
547                         {
548                                 SetBounds(FloatRectangle(0.0f, 0.0f, screen.height, screen.width));
549                         }
550
551                         __restore = false;
552                 }
553
554                 break;
555         case FRAME_SHOW_MODE_PARTIAL_SCREEN:
556                 if (oldShowMode == FRAME_SHOW_MODE_PARTIAL_SCREEN_FLOATING)
557                 {
558                         r = pEcoreEvas->SetFloatingMode(*GetRootWindow(), false);
559                         SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
560                 }
561
562                 if (oldShowMode == FRAME_SHOW_MODE_FULL_SCREEN)
563                 {
564                         SetBounds(__floatingBounds);
565                 }
566                 else if (oldShowMode == FRAME_SHOW_MODE_PARTIAL_SCREEN_FLOATING)
567                 {
568                         pEcoreEvas->SetWindowBounds(*GetRootWindow(), _CoordinateSystemUtils::ConvertToInteger(__floatingBounds));
569                 }
570
571                 break;
572         case FRAME_SHOW_MODE_PARTIAL_SCREEN_FLOATING:
573                 if (oldShowMode != FRAME_SHOW_MODE_PARTIAL_SCREEN_FLOATING)
574                 {
575                         r = pEcoreEvas->SetFloatingMode(*GetRootWindow(), true);
576                         SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
577                 }
578
579                 if (oldShowMode == FRAME_SHOW_MODE_FULL_SCREEN)
580                 {
581                         SetBounds(__floatingBounds);
582                 }
583
584                 break;
585         default:
586                 break;
587         }
588
589         return E_SUCCESS;
590 }
591
592 FrameShowMode
593 _Frame::GetShowMode(bool minimize) const
594 {
595         if (minimize)
596         {
597                 if (__minimized == true)
598                 {
599                         return FRAME_SHOW_MODE_MINIMIZED;
600                 }
601                 else
602                 {
603                         return __showMode;
604                 }
605         }
606         else
607         {
608                 return __showMode;
609         }
610 }
611
612 bool
613 _Frame::IsActivated(void) const
614 {
615         return __activated;
616 }
617
618 void
619 _Frame::OnChildAttached(const _Control& child)
620 {
621         _Form* pCurrentForm = GetCurrentForm();
622
623         if (pCurrentForm == &child)
624         {
625                 int controlCount = GetChildCount();
626
627                 if (controlCount > 1)
628                 {
629                         _Control* pOldCurrentForm = GetChild(controlCount - 2);
630                         SysTryReturnVoidResult(NID_UI_CTRL, pOldCurrentForm != null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
631                         pOldCurrentForm->SetVisibleState(false);
632                         _Form* pOldForm = static_cast<_Form*>(pOldCurrentForm);
633                         if (pOldForm)
634                         {
635                                 _Control* pFocusTraversalControl = pOldForm->GetFocusTraversalControl();
636                                 if (pFocusTraversalControl)
637                                 {
638                                         pFocusTraversalControl->SetFocusModeStateEnabled(false) ;
639                                 }
640                         }
641                 }
642         }
643 }
644
645 void
646 _Frame::OnChildDetached(const _Control& child)
647 {
648         int controlCount = GetChildCount();
649
650         if (controlCount > 0)
651         {
652                 _Control* pCurrentForm = GetChild(controlCount - 1);
653                 SysTryReturnVoidResult(NID_UI_CTRL, pCurrentForm, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
654                 pCurrentForm->SetVisibleState(true);
655         }
656         else
657         {
658                 _EcoreEvas* pEcoreEvas = GetEcoreEvasMgr()->GetEcoreEvas();
659                 SysTryReturnVoidResult(NID_UI_CTRL, pEcoreEvas, E_SYSTEM, "[E_SYSTEM] Unable to get evas");
660                 pEcoreEvas->SetIndicatorShowState(*GetRootWindow(), false);
661         }
662 }
663
664 result
665 _Frame::OnBoundsChanging(const FloatRectangle& bounds)
666 {
667         int appType = _AppInfo::GetAppType();
668         if (appType & _APP_TYPE_IME_APP)
669         {
670                 SysLog(NID_UI_CTRL, "[Ime Rotation]");
671                 return E_SUCCESS;
672         }
673
674         if (__restore == false)
675         {
676                 __floatingBounds = bounds;
677         }
678
679         if ((__showMode == FRAME_SHOW_MODE_FULL_SCREEN) && (__restore == false))
680         {
681                 if (__constructed == false)
682                 {
683                         return E_SUCCESS;
684                 }
685                 else
686                 {
687                         if (__rotation == true)
688                         {
689                                 return E_SUCCESS;
690                         }
691                         else
692                         {
693                                 return E_UNSUPPORTED_OPERATION;
694                         }
695                 }
696         }
697
698         _EcoreEvas* pEcoreEvas = GetEcoreEvasMgr()->GetEcoreEvas();
699         SysTryReturn(NID_UI, pEcoreEvas, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error occurred.");
700
701         pEcoreEvas->SetWindowBounds(*GetRootWindow(), _CoordinateSystemUtils::ConvertToInteger(bounds));
702         result r = GetLastResult();
703         SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
704
705         return r;
706 }
707
708
709 result
710 _Frame::OnAttached(void)
711 {
712         _EcoreEvas* pEcoreEvas = GetEcoreEvasMgr()->GetEcoreEvas();
713         SysAssert(pEcoreEvas);
714
715         pEcoreEvas->SetWindowVisibleState(*GetRootWindow(), true);
716
717         return E_SUCCESS;
718 }
719
720 void
721 _Frame::OnBackgroundColorChanged(Color& backgroundColor)
722 {
723         _RootVisualElement* pRootVE = GetRootVisualElement();
724         SysAssert(pRootVE);
725
726         _EflLayer* pLayer = static_cast<_EflLayer*>(pRootVE->GetNativeLayer());
727         SysAssert(pLayer);
728
729         byte alpha = backgroundColor.GetAlpha();
730         float opacity = static_cast<float>(alpha) / 255.0f;
731
732         pLayer->SetOpacity(opacity);
733
734         // Restore
735         FrameShowMode showMode = GetShowMode(false);
736         SetShowMode(FRAME_SHOW_MODE_FULL_SCREEN);
737
738         SetShowMode(showMode);
739
740         _EcoreEvas* pEcoreEvas = GetEcoreEvasMgr()->GetEcoreEvas();
741         if (!pEcoreEvas)
742         {
743                 return;
744         }
745
746         Orientation mode = ORIENTATION_PORTRAIT;
747         
748         _Form* pCurrentForm = GetCurrentForm();
749         if (pCurrentForm)
750         {
751                 _FormImpl* pFormImpl = static_cast<_FormImpl*>(pCurrentForm->GetUserData());
752                 if (pFormImpl)
753                 {
754                         mode = pFormImpl->GetOrientation();
755                 }
756         }
757         else
758         {
759                 _FrameImpl* pFrameImpl = static_cast<_FrameImpl*>(GetUserData());
760                 if (pFrameImpl)
761                 {
762                         mode = pFrameImpl->GetOrientation();
763                 }
764         }
765
766         switch (mode)
767         {
768         case ORIENTATION_PORTRAIT:
769                 pEcoreEvas->SetWindowPreferredRotation(*this, 0, true);
770                 break;
771         case ORIENTATION_LANDSCAPE:
772                 pEcoreEvas->SetWindowPreferredRotation(*this, 270, true);
773                 break;
774         case ORIENTATION_PORTRAIT_REVERSE:
775                 pEcoreEvas->SetWindowPreferredRotation(*this, 180, true);
776                 break;
777         case ORIENTATION_LANDSCAPE_REVERSE:
778                 pEcoreEvas->SetWindowPreferredRotation(*this, 90, true);
779                 break;
780         case ORIENTATION_AUTOMATIC:
781                 {
782                         pEcoreEvas->SetWindowPreferredRotation(*this, -1);
783                         int autoRotation[3] = {0, 90, 270};
784                         pEcoreEvas->SetWindowAvailabledRotation(*this, autoRotation, 3, true);
785                 }
786                 break;
787         case ORIENTATION_AUTOMATIC_FOUR_DIRECTION:
788                 {
789                         pEcoreEvas->SetWindowPreferredRotation(*this, -1);
790                         int autoFourRotation[4] = {0, 90, 180, 270};
791                         pEcoreEvas->SetWindowAvailabledRotation(*this, autoFourRotation, 4, true);
792                 }
793                 break;
794         default:
795                 break;
796         }
797 }
798
799 void
800 _Frame::ResetFocusList(void)
801 {
802         Tizen::Ui::Controls::_Form* pCurrentForm = GetCurrentForm();
803         if (pCurrentForm)
804         {
805                 pCurrentForm->ResetFocusList();
806         }
807 }
808
809 _Control* 
810 _Frame::GetFocusControl(void) const
811 {
812         _Form* pForm = GetCurrentForm();
813         if (pForm)
814         {
815                 return pForm->GetFocusControl();
816         }
817         return null;
818 }
819
820 void 
821 _Frame::SetFocusControl(const _Control* pControl)
822 {
823         _Form* pForm = GetCurrentForm();
824         if (pForm)
825         {
826                 pForm->SetFocusControl(pControl);
827         }
828 }
829
830
831 Tizen::Base::Collection::IListT<_Control*>* 
832 _Frame::GetFocusList(void) const
833 {
834         _Form* pForm = GetCurrentForm();
835         if (pForm)
836         {
837                 return pForm->GetFocusList();
838         }
839         return null;    
840 }
841
842 _Control* 
843 _Frame::GetFocusTraversalControl(void) const
844 {
845         _Form* pForm = GetCurrentForm();
846         if (pForm)
847         {
848                 return pForm->GetFocusTraversalControl();               
849         }
850         return null;
851 }
852
853 void 
854 _Frame::SetFocusTraversalControl(_Control* pControl)
855 {
856         _Form* pForm = GetCurrentForm();
857         if (pForm)
858         {
859                 pForm->SetFocusTraversalControl(pControl);              
860         }
861 }
862 }}} // Tizen::Ui::Controls