2 // Open Service Platform
3 // Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
5 // Licensed under the Flora License, Version 1.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
9 // http://floralicense.org/license/
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.
18 * @file FUi_ControlImplManager.cpp
19 * @brief This is the implementation file for the _ControlImplManager class.
30 #include <FBaseSysLog.h>
31 #include <FUiCtrlForm.h>
32 #include <FApp_AppInfo.h>
33 #include <FGrp_CoordinateSystem.h>
34 #include <FSys_SystemInfoImpl.h>
35 #include "FUi_ControlImplManager.h"
36 #include "FUi_ControlManager.h"
37 #include "FUi_WindowImpl.h"
38 #include "FUi_KeyEventManagerImpl.h"
39 #include "FUi_FocusManagerImpl.h"
41 #include "FUiCtrl_FrameImpl.h"
42 #include "FUiCtrl_FormImpl.h"
44 using namespace Tizen::App;
45 using namespace Tizen::Base;
46 using namespace Tizen::Graphics;
47 using namespace Tizen::Io;
48 using namespace Tizen::Ui;
49 using namespace Tizen::Ui::Controls;
50 using namespace Tizen::Ui::Animations;
56 Convert(_ControlRotation rotate, bool allowReverse)
58 OrientationStatus status = ORIENTATION_STATUS_NONE;
60 if (allowReverse == true)
64 case _CONTROL_ROTATION_0:
65 status = ORIENTATION_STATUS_PORTRAIT;
67 case _CONTROL_ROTATION_270:
68 status = ORIENTATION_STATUS_LANDSCAPE;
70 case _CONTROL_ROTATION_180:
71 status = ORIENTATION_STATUS_PORTRAIT_REVERSE;
73 case _CONTROL_ROTATION_90:
74 status = ORIENTATION_STATUS_LANDSCAPE_REVERSE;
82 case _CONTROL_ROTATION_0:
84 case _CONTROL_ROTATION_180:
85 status = ORIENTATION_STATUS_PORTRAIT;
87 case _CONTROL_ROTATION_90:
88 status = ORIENTATION_STATUS_LANDSCAPE_REVERSE;
90 case _CONTROL_ROTATION_270:
91 status = ORIENTATION_STATUS_LANDSCAPE;
100 Convert(OrientationStatus orientationStatus)
102 switch (orientationStatus)
104 case ORIENTATION_STATUS_PORTRAIT:
105 return _CONTROL_ROTATION_0;
106 case ORIENTATION_STATUS_LANDSCAPE:
107 return _CONTROL_ROTATION_270;
108 case ORIENTATION_STATUS_PORTRAIT_REVERSE:
109 return _CONTROL_ROTATION_180;
110 case ORIENTATION_STATUS_LANDSCAPE_REVERSE:
111 return _CONTROL_ROTATION_90;
113 return _CONTROL_ROTATION_0;
117 } // unnamed namespace
120 InitializeTestbuddyManager(void)
122 result r = E_FAILURE;
123 void* pHandle = null;
125 SysLog(NID_UI,"TestbuddyManager is starting.");
127 result (*pfnInitialize_TestBuddyManager)(void) = null;
129 pHandle = dlopen ("libtestbuddy.so", RTLD_LAZY);
132 SysLog(NID_UI, "[%s] Failed to dlopen libtestbuddy.so", dlerror());
133 return E_LIBRARY_NOT_FOUND;
136 pfnInitialize_TestBuddyManager = reinterpret_cast<result (*)(void)>(dlsym(pHandle, "_Initialize_TestBuddyManager"));
137 if (pfnInitialize_TestBuddyManager == null)
139 SysLog(NID_UI, "[%s] Failed to dlsym _Initialize_TestBuddyManager", dlerror());
141 return E_SYMBOL_NOT_FOUND;
144 r = pfnInitialize_TestBuddyManager();
145 SysTryReturn(NID_UI, r == E_SUCCESS, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] pfnInitialize_TestBuddyManager() is invaild.");
151 InitializeUiFramework(void)
153 _ControlImplManager::Initialize();
155 // TODO : After completing InitializeTestbuddyManager( )
156 //return GetLastResult();
161 FinalizeUiFramework(void)
163 _ControlImplManager::Release();
167 namespace Tizen { namespace Ui {
169 _ControlImplManager* _ControlImplManager::__pInstance(null);
171 // Explicitly initialize just before the Form is created.
173 _ControlImplManager::Initialize(void)
175 static pthread_once_t once_block = PTHREAD_ONCE_INIT;
179 pthread_once(&once_block, InitInstance);
182 _ControlManager::Initialize();
184 result r = InitializeTestbuddyManager();
189 _ControlImplManager::Release(void)
191 _ControlManager::Release();
198 _ControlImplManager::GetInstance(void)
204 _ControlImplManager::InitInstance(void)
206 if (__pInstance != null)
211 __pInstance = new (std::nothrow) _ControlImplManager;
212 SysAssert(__pInstance);
215 _ControlImplManager::_ControlImplManager(void)
218 _KeyEventManagerImpl::Initialize();
219 _FocusManagerImpl::Initialize();
222 _ControlImplManager::~_ControlImplManager(void)
224 _FocusManagerImpl::ReleaseInstance();
225 _KeyEventManagerImpl::ReleaseInstance();
229 _ControlImplManager::GetCurrentFrame(void) const
231 _Window* pFrame = _ControlManager::GetInstance()->GetCurrentFrame();
237 _WindowImpl* pImpl = static_cast <_WindowImpl*>(pFrame->GetUserData());
242 _ControlImplManager::OnScreenRotated(int rotation)
244 _ControlManager* pCore = _ControlManager::GetInstance();
247 pCore->OnScreenRotated(rotation);
249 #if !defined(MULTI_WINDOW)
250 Controls::_FrameImpl* pFrameImpl = dynamic_cast<Controls::_FrameImpl*>(GetCurrentFrame());
251 if (pFrameImpl == null)
256 Controls::_FormImpl* pCurrentFormImpl = pFrameImpl->GetCurrentForm();
258 if (pCurrentFormImpl != null)
260 pCurrentFormImpl->UpdateOrientationStatus(true);
264 pFrameImpl->UpdateOrientationStatus();
270 _ControlImplManager::SetOrientationStatus(OrientationStatus orientationStatus)
272 _ControlManager* pCore = _ControlManager::GetInstance();
275 pCore->SetOrientationStatus(::Convert(orientationStatus));
278 #if !defined(MULTI_WINDOW)
280 _ControlImplManager::RotateScreen(OrientationStatus orientationStatus)
282 _ControlManager* pCore = _ControlManager::GetInstance();
285 pCore->RotateScreen(::Convert(orientationStatus));
289 _ControlImplManager::RotateScreen(_ControlImpl* pControlImpl, OrientationStatus orientationStatus)
291 _ControlManager* pCore = _ControlManager::GetInstance();
294 pCore->RotateScreen(pControlImpl->GetCore(), ::Convert(orientationStatus));
299 _ControlImplManager::GetOrientationStatus(Orientation mode) const
301 _ControlManager* pCore = _ControlManager::GetInstance();
304 const _ControlRotation screenRotation = pCore->GetScreenRotation();
306 if (mode == ORIENTATION_AUTOMATIC_FOUR_DIRECTION)
308 return ::Convert(screenRotation, true);
311 if (mode == ORIENTATION_AUTOMATIC)
313 return ::Convert(screenRotation, false);
316 OrientationStatus status = ORIENTATION_STATUS_NONE;
319 case ORIENTATION_PORTRAIT:
320 status = ORIENTATION_STATUS_PORTRAIT;
322 case ORIENTATION_LANDSCAPE:
323 status = ORIENTATION_STATUS_LANDSCAPE;
325 case ORIENTATION_PORTRAIT_REVERSE:
326 status = ORIENTATION_STATUS_PORTRAIT_REVERSE;
328 case ORIENTATION_LANDSCAPE_REVERSE:
329 status = ORIENTATION_STATUS_LANDSCAPE_REVERSE;
339 _ControlImplManager::GetFormOrientationStatus(_ControlImpl *pControlImpl)
341 _FormImpl* pParentImpl = null;
342 OrientationStatus orientation = ORIENTATION_STATUS_NONE;
345 pParentImpl = dynamic_cast<_FormImpl*>(pControlImpl->GetParent());
347 if (pParentImpl != null)
353 pControlImpl = pControlImpl->GetParent();
359 orientation = pParentImpl->GetOrientationStatus();