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_KeypadEvent.cpp
19 * @brief This file contains implementation of _KeypadEvent class
21 * This file contains implementation of _KeypadEvent class.
25 #include <FBaseErrors.h>
26 #include <FBaseSysLog.h>
28 #include "FUiCtrl_KeypadEvent.h"
31 using namespace Tizen::Base;
32 using namespace Tizen::Base::Runtime;
34 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_ _KeypadEventArg
53 * This is the default class constructor.
55 * @param[in] source A pointer to the Object instance which contains this instance.
57 _KeypadEventArg(CoreKeypadAction actionId, CoreKeypadEventStatus status);
60 * This is the class destructor.
63 virtual ~_KeypadEventArg(void);
68 CoreKeypadAction GetKeypadActionId() const;
70 CoreKeypadEventStatus GetStatus() const;
77 CoreKeypadAction __actionId;
82 CoreKeypadEventStatus __status;
85 ////////////////////////////////////////////////////////////////////////////////
86 /// __TextSelectionEventArg class Lifecycle
88 _KeypadEventArg::_KeypadEventArg(CoreKeypadAction actionId, CoreKeypadEventStatus status)
90 __actionId = actionId;
94 _KeypadEventArg::~_KeypadEventArg(void)
100 _KeypadEventArg::GetKeypadActionId(void) const
105 CoreKeypadEventStatus
106 _KeypadEventArg::GetStatus() const
111 ////////////////////////////////////////////////////////////////////////////////
112 /// __TextSelectionEvent class Lifecycle
113 _KeypadEvent::_KeypadEvent(const _Control& source)
116 result r = _Event::Initialize();
125 _KeypadEvent::~_KeypadEvent(void)
131 _KeypadEvent::CreateInstanceN(const _Control& source)
133 _KeypadEvent* pCoreKeypadEvent = new (std::nothrow) _KeypadEvent(source);
134 SysTryReturn(NID_UI_CTRL, pCoreKeypadEvent, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory shortage.");
136 if (IsFailed(GetLastResult()))
141 return pCoreKeypadEvent;
143 delete pCoreKeypadEvent;
148 _KeypadEvent::GetSource(void) const
156 _KeypadEvent::FireImpl(IEventListener& listener, const IEventArg& arg)
159 _IKeypadEventListener* pKeypadEventListener = dynamic_cast <_IKeypadEventListener*>(&listener);
160 SysTryReturnVoidResult(NID_UI_CTRL, pKeypadEventListener != null, E_INVALID_ARG,
161 "[E_INVALID_ARG] The invalid listener was given.\n");
163 const _KeypadEventArg* pKeypadEventArg = dynamic_cast <const _KeypadEventArg*>(&arg);
164 SysTryReturnVoidResult(NID_UI_CTRL, pKeypadEventArg != null, E_INVALID_ARG,
165 "[E_INVALID_ARG] The invalid Event Argument was given.\n");
167 CoreKeypadAction keypadAction = pKeypadEventArg->GetKeypadActionId();
169 CoreKeypadEventStatus status = pKeypadEventArg->GetStatus();
172 case CORE_KEYPAD_EVENT_STATUS_CREATED:
173 pKeypadEventListener->OnKeypadWillOpen();
176 case CORE_KEYPAD_EVENT_STATUS_OPEN:
177 pKeypadEventListener->OnKeypadOpened();
180 case CORE_KEYPAD_EVENT_STATUS_CLOSE:
181 pKeypadEventListener->OnKeypadClosed();
184 case CORE_KEYPAD_EVENT_STATUS_BOUNDS_CHANGED:
185 pKeypadEventListener->OnKeypadBoundsChanged();
188 case CORE_KEYPAD_EVENT_STATUS_ENTERACTION:
189 pKeypadEventListener->OnKeypadActionPerformed(keypadAction);
196 SetLastResult(E_SUCCESS);
202 _KeypadEvent::CreateKeypadEventArgN(CoreKeypadAction actionId, CoreKeypadEventStatus status)
204 _KeypadEventArg* pEventArg = new (std::nothrow) _KeypadEventArg(actionId, status);
205 SysTryReturn(NID_UI_CTRL, pEventArg, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory shortage.");
210 }}} // Tizen::Ui::Controls