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_PublicKeypadEvent.cpp
19 * @brief This is the implementation for the _PublicKeypadEvent class.
21 * This file contains implementation of _PublicKeypadEvent class.
25 #include <FBaseErrors.h>
26 #include <FBaseSysLog.h>
28 #include "FUiCtrl_PublicKeypadEvent.h"
30 using namespace Tizen::Base;
31 using namespace Tizen::Base::Runtime;
33 namespace Tizen {namespace Ui {namespace Controls
38 * @brief This class is used as the argument to change event listener.
40 * This class is used as the argument to change event listener. When an change event is generated
41 * (such as when a button is pressed) the TextSelectionEvent calls TextSelectionEventListener's OnTextd
42 * with an instance of this class as an argument.
44 * From this class, one can find out, the (event) source object and the change ID.
46 class _OSP_EXPORT_ _PublicKeypadEventArg
53 * This is the default class constructor.
55 * @param[in] source A pointer to the Object instance which contains this instance.
57 _PublicKeypadEventArg(const Control& source, KeypadAction actionId, KeypadEventStatus status);
60 * This is the class destructor.
63 virtual ~_PublicKeypadEventArg(void);
69 * This method returns the object which the event initially occurred.
71 * @return The object which the event initially occurred.
73 const Control* GetSource(void) const;
75 KeypadAction GetKeypadActionId() const;
77 KeypadEventStatus GetStatus() const;
84 const Control* __pSource;
89 KeypadAction __actionId;
94 KeypadEventStatus __status;
95 }; // _PublicKeypadEventArg
97 ////////////////////////////////////////////////////////////////////////////////
98 /// __TextSelectionEventArg class Lifecycle
100 _PublicKeypadEventArg::_PublicKeypadEventArg(const Control& source, KeypadAction actionId, Controls::KeypadEventStatus status)
103 __actionId = actionId;
107 _PublicKeypadEventArg::~_PublicKeypadEventArg(void)
113 _PublicKeypadEventArg::GetSource(void) const
119 _PublicKeypadEventArg::GetKeypadActionId(void) const
125 _PublicKeypadEventArg::GetStatus() const
130 ////////////////////////////////////////////////////////////////////////////////
131 /// __TextSelectionEvent class Lifecycle
132 _PublicKeypadEvent::_PublicKeypadEvent(const Control& source)
135 result r = _Event::Initialize();
142 _PublicKeypadEvent::~_PublicKeypadEvent(void)
148 _PublicKeypadEvent::CreateInstanceN(const Control& source)
150 _PublicKeypadEvent* pPublicKeypadEvent = new (std::nothrow) _PublicKeypadEvent(source);
151 SysTryReturn(NID_UI_CTRL, pPublicKeypadEvent, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory shortage.");
153 return pPublicKeypadEvent;
157 _PublicKeypadEvent::GetSource(void) const
165 _PublicKeypadEvent::FireImpl(IEventListener& listener, const IEventArg& arg)
167 IKeypadEventListener* pKeypadEventListener = dynamic_cast <IKeypadEventListener*>(&listener);
168 SysTryReturnVoidResult(NID_UI_CTRL, pKeypadEventListener != null, E_INVALID_ARG,
169 "[E_INVALID_ARG] The invalid listener was given.\n");
171 const _PublicKeypadEventArg* pKeypadEventArg = dynamic_cast <const _PublicKeypadEventArg*>(&arg);
172 SysTryReturnVoidResult(NID_UI_CTRL, pKeypadEventArg != null, E_INVALID_ARG,
173 "[E_INVALID_ARG] The invalid Event Argument was given.\n");
175 Control* tempSource = null;
176 tempSource = const_cast <Control*>(pKeypadEventArg->GetSource());
177 KeypadAction keypadAction = pKeypadEventArg->GetKeypadActionId();
179 Controls::KeypadEventStatus status = pKeypadEventArg->GetStatus();
182 case KEYPAD_EVENT_STATUS_CREATED:
183 pKeypadEventListener->OnKeypadWillOpen(*tempSource);
186 case KEYPAD_EVENT_STATUS_OPEN:
187 pKeypadEventListener->OnKeypadOpened(*tempSource);
190 case KEYPAD_EVENT_STATUS_CLOSE:
191 pKeypadEventListener->OnKeypadClosed(*tempSource);
194 case KEYPAD_EVENT_STATUS_BOUNDS_CHANGED:
195 pKeypadEventListener->OnKeypadBoundsChanged(*tempSource);
198 case KEYPAD_EVENT_STATUS_ENTERACTION:
199 pKeypadEventListener->OnKeypadActionPerformed(*tempSource, keypadAction);
206 SetLastResult(E_SUCCESS);
211 Tizen::Base::Runtime::IEventArg*
212 _PublicKeypadEvent::CreateKeypadEventArgN(const Tizen::Ui::Control& source, Tizen::Ui::KeypadAction actionId,
213 KeypadEventStatus status)
215 _PublicKeypadEventArg* pEventArg = new (std::nothrow) _PublicKeypadEventArg(source, actionId, status);
216 SysTryReturn(NID_UI_CTRL, pEventArg, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory shortage.");
221 }}} // Tizen::Ui::Controls