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 FUiCtrl_KeypadEvent.cpp
20 * @brief This file contains implementation of _KeypadEvent class
22 * This file contains implementation of _KeypadEvent class.
26 #include <FBaseErrors.h>
27 #include <FBaseSysLog.h>
29 #include "FUiCtrl_KeypadEvent.h"
32 using namespace Tizen::Base;
33 using namespace Tizen::Base::Runtime;
35 namespace Tizen {namespace Ui {namespace Controls
39 * @brief This class is used as the argument to change event listener.
41 * This class is used as the argument to change event listener. When an change event is generated
42 * (such as when a button is pressed) the TextSelectionEvent calls TextSelectionEventListener's OnTextd
43 * with an instance of this class as an argument.
45 * From this class, one can find out, the (event) source object and the change ID.
47 class _OSP_EXPORT_ _KeypadEventArg
54 * This is the default class constructor.
56 * @param[in] source A pointer to the Object instance which contains this instance.
58 _KeypadEventArg(CoreKeypadAction actionId, CoreKeypadEventStatus status);
61 * This is the class destructor.
64 virtual ~_KeypadEventArg(void);
69 CoreKeypadAction GetKeypadActionId() const;
71 CoreKeypadEventStatus GetStatus() const;
78 CoreKeypadAction __actionId;
83 CoreKeypadEventStatus __status;
86 ////////////////////////////////////////////////////////////////////////////////
87 /// __TextSelectionEventArg class Lifecycle
89 _KeypadEventArg::_KeypadEventArg(CoreKeypadAction actionId, CoreKeypadEventStatus status)
91 __actionId = actionId;
95 _KeypadEventArg::~_KeypadEventArg(void)
101 _KeypadEventArg::GetKeypadActionId(void) const
106 CoreKeypadEventStatus
107 _KeypadEventArg::GetStatus() const
112 ////////////////////////////////////////////////////////////////////////////////
113 /// __TextSelectionEvent class Lifecycle
114 _KeypadEvent::_KeypadEvent(const _Control& source)
117 result r = _Event::Initialize();
126 _KeypadEvent::~_KeypadEvent(void)
132 _KeypadEvent::CreateInstanceN(const _Control& source)
134 _KeypadEvent* pCoreKeypadEvent = new (std::nothrow) _KeypadEvent(source);
135 SysTryReturn(NID_UI_CTRL, pCoreKeypadEvent, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory shortage.");
137 if (IsFailed(GetLastResult()))
142 return pCoreKeypadEvent;
144 delete pCoreKeypadEvent;
149 _KeypadEvent::GetSource(void) const
157 _KeypadEvent::FireImpl(IEventListener& listener, const IEventArg& arg)
160 _IKeypadEventListener* pKeypadEventListener = dynamic_cast <_IKeypadEventListener*>(&listener);
161 SysTryReturnVoidResult(NID_UI_CTRL, pKeypadEventListener != null, E_INVALID_ARG,
162 "[E_INVALID_ARG] The invalid listener was given.\n");
164 const _KeypadEventArg* pKeypadEventArg = dynamic_cast <const _KeypadEventArg*>(&arg);
165 SysTryReturnVoidResult(NID_UI_CTRL, pKeypadEventArg != null, E_INVALID_ARG,
166 "[E_INVALID_ARG] The invalid Event Argument was given.\n");
168 CoreKeypadAction keypadAction = pKeypadEventArg->GetKeypadActionId();
170 CoreKeypadEventStatus status = pKeypadEventArg->GetStatus();
173 case CORE_KEYPAD_EVENT_STATUS_CREATED:
174 pKeypadEventListener->OnKeypadWillOpen();
177 case CORE_KEYPAD_EVENT_STATUS_OPEN:
178 pKeypadEventListener->OnKeypadOpened();
181 case CORE_KEYPAD_EVENT_STATUS_CLOSE:
182 pKeypadEventListener->OnKeypadClosed();
185 case CORE_KEYPAD_EVENT_STATUS_BOUNDS_CHANGED:
186 pKeypadEventListener->OnKeypadBoundsChanged();
189 case CORE_KEYPAD_EVENT_STATUS_ENTERACTION:
190 pKeypadEventListener->OnKeypadActionPerformed(keypadAction);
197 SetLastResult(E_SUCCESS);
203 _KeypadEvent::CreateKeypadEventArgN(CoreKeypadAction actionId, CoreKeypadEventStatus status)
205 _KeypadEventArg* pEventArg = new (std::nothrow) _KeypadEventArg(actionId, status);
206 SysTryReturn(NID_UI_CTRL, pEventArg, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory shortage.");
211 }}} // Tizen::Ui::Controls