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 FUiCtrl_FrameEvent.cpp
19 * @brief This is the implementation for the _FrameEvent class.
24 #include <FUiCtrlFrame.h>
25 #include <FBaseErrors.h>
26 #include <FBaseSysLog.h>
27 #include "FUiCtrl_IFrameEventListener.h"
28 #include "FUiCtrl_FrameEvent.h"
30 using namespace Tizen::Base;
31 using namespace Tizen::Base::Runtime;
33 namespace Tizen { namespace Ui { namespace Controls
36 * @class _FrameEventArg
37 * @brief This class is used as an argument of event listener's method.
39 * This class is used as an argument of event listener's method. When frame event is generated,
40 * the @c _FrameEvent instance calls WindowEventListener's method with instance of this class as an argument.
43 : public Tizen::Base::Object
44 , public Tizen::Base::Runtime::IEventArg
49 * This is the default class constructor.
51 * @param[in] source A pointer to the _Frame instance which contains this instance.
52 * @param[in] frameState The frame event type.
54 _FrameEventArg(const _Frame& source, int frameState);
57 * This is the class destructor.
60 virtual ~_FrameEventArg(void);
64 * This method returns the Window object which the event initially occurred.
66 * @return See the comment above.
69 const _Frame* GetSource(void) const;
72 * This method returns the event type of frame event.
74 * @return See the comment above.
76 int GetType(void) const;
84 _FrameEventArg::_FrameEventArg(const _Frame& source, int frameState)
85 : __pSource(const_cast <_Frame*>(&source))
86 , __frameState(frameState)
90 _FrameEventArg::~_FrameEventArg(void)
95 _FrameEventArg::GetSource(void) const
101 _FrameEventArg::GetType(void) const
107 _FrameEvent::CreateInstanceN(const _Frame& source)
109 _FrameEvent* pFrameEvent = new (std::nothrow) _FrameEvent(source);
110 SysTryReturn(NID_UI_CTRL, pFrameEvent, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory shortage.");
112 if (IsFailed(GetLastResult()))
117 SetLastResult(E_SUCCESS);
127 _FrameEvent::CreateFrameEventArgN(const _Frame& source, int frameState)
129 _FrameEventArg* pEventArg = new (std::nothrow) _FrameEventArg(source, frameState);
130 SysTryReturn(NID_UI_CTRL, pEventArg, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory shortage.");
132 SetLastResult(E_SUCCESS);
137 _FrameEvent::~_FrameEvent(void)
142 _FrameEvent::GetSource(void) const
148 _FrameEvent::FireImpl(IEventListener& listener, const IEventArg& arg)
150 _IFrameEventListener* pFrameListener = dynamic_cast <_IFrameEventListener*>(&listener);
151 SysTryReturnVoidResult(NID_UI_CTRL, pFrameListener, E_INVALID_ARG, "[E_INVALID_ARG] The invalid listener was given.");
153 const _FrameEventArg* pArg = static_cast <const _FrameEventArg*>(&arg);
154 SysTryReturnVoidResult(NID_UI_CTRL, pArg, E_INVALID_ARG, "[E_INVALID_ARG] The invalid event argument was given.");
156 if (pArg->GetType() == _FRAME_STATUS_ACTIVATED)
158 pFrameListener->OnFrameActivated(*pArg->GetSource());
160 else if (pArg->GetType() == _FRAME_STATUS_DEACTIVATED)
162 pFrameListener->OnFrameDeactivated(*pArg->GetSource());
168 _FrameEvent::_FrameEvent(const _Frame& source)
171 result r = _Event::Initialize();
172 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
179 }}} // Tizen::Ui::Controls