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