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.
18 * @file FUiCtrl_ActionEvent.cpp
19 * @brief This is the implementation for the ActionEvent class.
23 #include <FBaseErrors.h>
24 #include <FBaseSysLog.h>
25 #include "FUiCtrl_IActionEventListener.h"
26 #include "FUiCtrl_ActionEvent.h"
28 using namespace Tizen::Base;
29 using namespace Tizen::Base::Runtime;
31 namespace Tizen { namespace Ui { namespace Controls
35 * @class _ActionEventArg
36 * @brief This class is used as the argument to action event listener.
38 * This class is used as the argument to action event listener. When an action event is generated
39 * (such as when a button is pressed) the ActionEvent calls ActionEventListener's OnActionPerformed
40 * with an instance of this class as an argument.
42 * From this class, one can find out, the (event) source object and the action ID.
44 class _OSP_EXPORT_ _ActionEventArg
50 * This is the default class constructor.
52 * @param[in] source A pointer to the Object instance which contains this instance.
53 * @param[in] actionId Action Id.
55 _ActionEventArg(int actionId);
58 * This is the class destructor.
61 virtual ~_ActionEventArg(void);
65 * This method returns the actionId which the event initially occurred.
67 * @return See the comment above.
69 int GetActionId(void) const;
78 _ActionEventArg::_ActionEventArg(int actionId)
79 : __actionId(actionId)
84 _ActionEventArg::~_ActionEventArg(void)
90 _ActionEventArg::GetActionId(void) const
95 _ActionEvent::_ActionEvent(const _Control& source)
98 result r = _Event::Initialize();
104 SetLastResult(E_SUCCESS);
108 _ActionEvent::~_ActionEvent(void)
114 _ActionEvent::CreateInstanceN(const _Control& source)
116 _ActionEvent* pActionEvent = new (std::nothrow) _ActionEvent(source);
117 SysTryReturn(NID_UI_CTRL, pActionEvent, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory shortage.");
119 if (IsFailed(GetLastResult()))
132 _ActionEvent::GetSource(void) const
138 _ActionEvent::FireImpl(IEventListener& listener, const IEventArg& arg)
140 // cast to _IActionEventListener
141 _IActionEventListener* pActionListener = dynamic_cast <_IActionEventListener*>(&listener);
142 SysTryReturnVoidResult(NID_UI_CTRL, pActionListener != null, E_INVALID_ARG,
143 "[E_INVALID_ARG] The invalid listener was given.\n");
145 // cast to _ActionEventArg
146 const _ActionEventArg* pArg = dynamic_cast <const _ActionEventArg*>(&arg);
147 SysTryReturnVoidResult(NID_UI_CTRL, pArg != null, E_INVALID_ARG, "[E_INVALID_ARG] The invalid Event Argument was given.\n");
149 // call cursor change event listener method
150 pActionListener->OnActionPerformed(*__pSource, pArg->GetActionId());
152 SetLastResult(E_SUCCESS);
158 _ActionEvent::CreateActionEventArgN(int actionId)
160 _ActionEventArg* pEventArg = new (std::nothrow) _ActionEventArg(actionId);
161 SysTryReturn(NID_UI_CTRL, pEventArg, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory shortage.");
166 }}} // Tizen::Ui::Controls