2 // Open Service Platform
3 // Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
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
9 // http://www.apache.org/licenses/LICENSE-2.0/
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.
19 * @file FUi_ImeOrientationAgent.cpp
20 * @brief This is the implementation file for the _ImeOrientationAgent class.
23 #include <unique_ptr.h>
25 #include <Elementary.h>
26 #include <FBaseSysLog.h>
27 #include <FBaseColArrayList.h>
28 #include "FUi_ImeOrientationAgent.h"
29 #include "FUi_ControlManager.h"
30 #include "FUi_ControlImplManager.h"
31 #include "FUi_PublicOrientationEvent.h"
32 #include "FUi_ControlImpl.h"
33 #include "FUi_Window.h"
34 #include "FUiCtrl_FormImpl.h"
35 #include "FUiCtrl_FrameImpl.h"
36 #include "FUiCtrl_Frame.h"
37 #include "FUiCtrl_Form.h"
38 #include "FUi_EcoreEvasMgr.h"
39 #include "FUi_EcoreEvas.h"
40 #include "FUi_ControlManager.h"
41 #include "FUi_UiNotificationEvent.h"
42 #include "FUi_UiEventManager.h"
43 #include "FUiAnim_RootVisualElement.h"
44 #include "FUiAnim_EflLayer.h"
47 using namespace Tizen::Base;
48 using namespace Tizen::Base::Collection;
49 using namespace Tizen::Base::Runtime;
50 using namespace Tizen::Ui::Controls;
51 using namespace Tizen::Ui::Animations;
52 using namespace Tizen::Graphics;
54 namespace Tizen { namespace Ui {
57 _ImeOrientationAgent::CreateInstanceN(Control& publicControl)
59 SysLog(NID_UI, "[Ime Rotation]");
61 _ImeOrientationAgent* pAgent = new (std::nothrow) _ImeOrientationAgent(publicControl);
62 SysTryReturn(NID_UI, pAgent, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory is insufficient.");
64 result r = GetLastResult();
65 SysTryCatch(NID_UI, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
67 SetLastResult(E_SUCCESS);
76 _ImeOrientationAgent::_ImeOrientationAgent(Control& publicControl)
77 : __publicControl(publicControl)
78 , __pPublicEvent(null)
79 , __status(ORIENTATION_STATUS_PORTRAIT)
81 _PublicOrientationEvent* pPublicEvent = _PublicOrientationEvent::CreateInstanceN(publicControl);
83 result r = GetLastResult();
84 SysTryReturnVoidResult(NID_UI, pPublicEvent, r, "[%s] Propagating.", GetErrorMessage(r));
86 __pPublicEvent = pPublicEvent;
88 SetLastResult(E_SUCCESS);
91 _ImeOrientationAgent::~_ImeOrientationAgent(void)
95 delete __pPublicEvent;
96 __pPublicEvent = null;
101 _ImeOrientationAgent::AddListener(IOrientationEventListener& listener)
103 result r = __pPublicEvent->AddListener(listener);
104 SysTryReturnVoidResult(NID_UI, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
106 SetLastResult(E_SUCCESS);
110 _ImeOrientationAgent::RemoveListener(IOrientationEventListener& listener)
112 result r = __pPublicEvent->RemoveListener(listener);
113 SysTryReturnVoidResult(NID_UI, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
115 SetLastResult(E_SUCCESS);
119 _ImeOrientationAgent::GetStatus(void) const
125 _ImeOrientationAgent::UpdateOrientation(int angle)
127 SysLog(NID_UI, "[Ime Rotation]");
129 _ControlImpl* pImpl = _ControlImpl::GetInstance(__publicControl);
135 _Window* pRootWindow = pImpl->GetCore().GetRootWindow();
141 int rotation = angle;
143 _RootVisualElement* pRootVisualElement = pRootWindow->GetRootVisualElement();
144 if (!pRootVisualElement)
146 SysLog(NID_UI, "[Ime Rotation] The root visual element is null.");
150 _EflLayer* pLayer = static_cast<_EflLayer*>(pRootVisualElement->GetNativeLayer());
153 SysLog(NID_UI, "[Ime Rotation] The efl layer is null.");
157 Evas_Object* pWinObj = pLayer->GetElmWin();
161 elm_win_rotation_with_resize_set(pWinObj, rotation);
164 OrientationStatus status = ORIENTATION_STATUS_NONE;
168 status = ORIENTATION_STATUS_PORTRAIT;
171 status = ORIENTATION_STATUS_LANDSCAPE;
174 status = ORIENTATION_STATUS_PORTRAIT_REVERSE;
177 status = ORIENTATION_STATUS_LANDSCAPE_REVERSE;
186 pImpl->Invalidate(true);
190 _ImeOrientationAgent::FireEvent(OrientationStatus status)
194 _ControlManager* pCoreManager = _ControlManager::GetInstance();
195 SysAssert(pCoreManager);
197 _ControlImpl* pImpl = _ControlImpl::GetInstance(__publicControl);
203 _ControlOrientation coreOrientation =
204 (status == ORIENTATION_STATUS_PORTRAIT || status == ORIENTATION_STATUS_PORTRAIT_REVERSE) ?
205 _CONTROL_ORIENTATION_PORTRAIT : _CONTROL_ORIENTATION_LANDSCAPE;
207 _ControlImplManager* pImplManager = _ControlImplManager::GetInstance();
208 SysAssert(pImplManager);
211 pCoreManager->SetOrientation(coreOrientation);
212 pImplManager->SetOrientationStatus(status);
213 pImpl->GetCore().ChangeLayout(coreOrientation);
216 IEventArg* pArg = _PublicOrientationEvent::CreateOrientationEventArgN(*__pPublicEvent->GetSource(), status);
217 __pPublicEvent->Fire(*pArg);