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_PublicOrientationEvent.cpp
20 * @brief This is the implementation for the _PublicOrientationEvent class.
25 #include <FBaseErrors.h>
26 #include <FBaseSysLog.h>
27 #include "FUi_PublicOrientationEvent.h"
29 using namespace Tizen::Base;
30 using namespace Tizen::Base::Runtime;
32 namespace Tizen { namespace Ui
35 * @class _PublicOrientationEventArg
36 * @brief This class is used as the argument to orientation event listener.
38 * This class is used as the argument to orientation event listener. When an orientation event is generated
39 * (such as when a button is pressed) the OrientationEvent calls OrientationEventListener's OnOrientationPerformed
40 * with an instance of this class as an argument.
42 * From this class, one can find out, the (event) source object and the orientation ID.
44 class _PublicOrientationEventArg
45 : public Tizen::Base::Runtime::IEventArg
46 , public Tizen::Base::Object
49 _PublicOrientationEventArg(const Control& source, OrientationStatus orientationStatus);
51 virtual ~_PublicOrientationEventArg(void);
53 const Control* GetSource(void) const;
54 int GetOrientationStatus(void) const;
57 _PublicOrientationEventArg(const _PublicOrientationEventArg& rhs);
58 _PublicOrientationEventArg& operator =(const _PublicOrientationEventArg& rhs);
62 OrientationStatus __orientationStatus;
63 }; // _PublicOrientationEventArg
65 _PublicOrientationEventArg::_PublicOrientationEventArg(const Control& source, OrientationStatus orientationStatus)
66 : __pSource(const_cast <Control*>(&source))
67 , __orientationStatus(orientationStatus)
71 _PublicOrientationEventArg::~_PublicOrientationEventArg(void)
76 _PublicOrientationEventArg::GetSource(void) const
82 _PublicOrientationEventArg::GetOrientationStatus(void) const
84 return __orientationStatus;
87 _PublicOrientationEvent*
88 _PublicOrientationEvent::CreateInstanceN(const Control& source)
90 _PublicOrientationEvent* pPublicOrientationEvent = new (std::nothrow) _PublicOrientationEvent(source);
91 SysTryReturn(NID_UI, pPublicOrientationEvent, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory is insufficient.");
93 result r = GetLastResult();
94 SysTryCatch(NID_UI, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
96 SetLastResult(E_SUCCESS);
98 return pPublicOrientationEvent;
101 delete pPublicOrientationEvent;
106 _PublicOrientationEvent::CreateOrientationEventArgN(const Control& source, OrientationStatus orientationStatus)
108 _PublicOrientationEventArg* pEventArg = new (std::nothrow) _PublicOrientationEventArg(source, orientationStatus);
109 SysTryReturn(NID_UI, pEventArg, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory is insufficient.");
111 SetLastResult(E_SUCCESS);
116 _PublicOrientationEvent::~_PublicOrientationEvent(void)
121 _PublicOrientationEvent::GetSource(void) const
127 _PublicOrientationEvent::FireImpl(IEventListener& listener, const IEventArg& arg)
129 IOrientationEventListener* pEventListener = dynamic_cast <IOrientationEventListener*>(&listener);
130 SysTryReturnVoidResult(NID_UI, pEventListener, E_INVALID_ARG, "[E_INVALID_ARG] A specified input parameter is invalid.");
132 const _PublicOrientationEventArg* pArg = dynamic_cast <const _PublicOrientationEventArg*>(&arg);
133 SysTryReturnVoidResult(NID_UI, pArg, E_INVALID_ARG, "[E_INVALID_ARG] A specified input parameter is invalid.");
135 SysLog(NID_UI, "[WM ROTATION] Fire the public orientation event with %d -> 0x%x", pArg->GetOrientationStatus(), __pSource);
137 pEventListener->OnOrientationChanged(*__pSource, (OrientationStatus)(pArg->GetOrientationStatus()));
139 SetLastResult(E_SUCCESS);
142 _PublicOrientationEvent::_PublicOrientationEvent(const Control& source)
145 result r = _Event::Initialize();
146 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
150 SetLastResult(E_SUCCESS);