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_PublicActionEvent.cpp
19 * @brief This is the implementation for the _PublicActionEvent class.
23 #include <FUiIActionEventListener.h>
24 #include <FBaseErrors.h>
25 #include <FBaseSysLog.h>
26 #include "FUiCtrl_PublicActionEvent.h"
28 using namespace Tizen::Base;
29 using namespace Tizen::Base::Runtime;
31 namespace Tizen { namespace Ui { namespace Controls
35 * @class _PublicActionEventArg
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_ _PublicActionEventArg
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 _PublicActionEventArg(int actionId);
58 * This is the class destructor.
61 virtual ~_PublicActionEventArg(void);
65 * This method returns the actionId which the event initially occurred.
67 * @return See the comment above.
69 int GetActionId(void) const;
76 }; // _PublicActionEventArg
78 _PublicActionEventArg::_PublicActionEventArg(int actionId)
79 : __actionId(actionId)
84 _PublicActionEventArg::~_PublicActionEventArg(void)
90 _PublicActionEventArg::GetActionId(void) const
95 _PublicActionEvent::_PublicActionEvent(const Control& source)
98 result r = _Event::Initialize();
104 SetLastResult(E_SUCCESS);
108 _PublicActionEvent::~_PublicActionEvent(void)
114 _PublicActionEvent::CreateInstanceN(const Control& source)
116 _PublicActionEvent* pPublicActionEvent = new (std::nothrow) _PublicActionEvent(source);
117 SysTryReturn(NID_UI_CTRL, pPublicActionEvent, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory shortage.");
119 if (IsFailed(GetLastResult()))
124 return pPublicActionEvent;
127 delete pPublicActionEvent;
132 _PublicActionEvent::GetSource(void) const
138 _PublicActionEvent::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 _PublicActionEventArg
146 const _PublicActionEventArg* pArg = dynamic_cast <const _PublicActionEventArg*>(&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 _PublicActionEvent::CreateActionEventArgN(int actionId)
160 _PublicActionEventArg* pEventArg = new (std::nothrow) _PublicActionEventArg(actionId);
161 SysTryReturn(NID_UI_CTRL, pEventArg, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory shortage.");
166 }}} // Tizen::Ui::Controls