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_TextEvent.cpp
20 * @brief This is the implementation for the TextEvent class.
25 #include <FBaseErrors.h>
26 #include <FBaseSysLog.h>
28 #include "FUiCtrl_ITextEventListener.h"
29 #include "FUiCtrl_TextEvent.h"
33 using namespace Tizen::Base;
34 using namespace Tizen::Base::Runtime;
36 namespace Tizen { namespace Ui { namespace Controls
40 * @class _TextEventArg
41 * @brief This class is used as the argument to action event listener.
43 * This class is used as the argument to action event listener. When an action event is generated
44 * (such as when a button is pressed) the TextEvent calls TextEventListener's OnActionPerformed
45 * with an instance of this class as an argument.
47 * From this class, one can find out, the (event) source object and the action ID.
49 class _OSP_EXPORT_ _TextEventArg
56 * This is the default class constructor.
58 * @param[in] source A pointer to the Object instance which contains this instance.
59 * @param[in] actionId Action Id.
61 _TextEventArg(CoreTextEventStatus status);
64 * This is the class destructor.
67 virtual ~_TextEventArg(void);
73 * This method returns the TextEventStatus which the event initially occurred.
75 * @return See the comment above.
77 CoreTextEventStatus GetStatus(void) const;
85 CoreTextEventStatus __status;
88 _TextEventArg::_TextEventArg(CoreTextEventStatus status)
94 _TextEventArg::~_TextEventArg(void)
99 ////////////////////////////////////////////////////////////////////////////////
100 /// _TextEventArg class Access
103 _TextEventArg::GetStatus(void) const
109 ////////////////////////////////////////////////////////////////////////////////
110 /// _TextEvent class Lifecycle
112 _TextEvent::_TextEvent(const _Control& source)
115 result r = _Event::Initialize();
124 _TextEvent::~_TextEvent(void)
130 _TextEvent::CreateInstanceN(const _Control& source)
132 _TextEvent* pCoreTextEvent = new (std::nothrow) _TextEvent(source);
133 SysTryReturn(NID_UI_CTRL, pCoreTextEvent, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory shortage.");
135 if (IsFailed(GetLastResult()))
140 return pCoreTextEvent;
143 delete pCoreTextEvent;
147 ////////////////////////////////////////////////////////////////////////////////
148 /// _WindowEvent class Accessor
151 _TextEvent::GetSource(void) const
156 ////////////////////////////////////////////////////////////////////////////////
157 /// _TextEvent class Operation
160 _TextEvent::FireImpl(IEventListener& listener, const IEventArg& arg)
162 // cast to _ITextEventListener
163 _ITextEventListener* pTextListener = dynamic_cast <_ITextEventListener*>(&listener);
164 SysTryReturnVoidResult(NID_UI_CTRL, pTextListener != null, E_INVALID_ARG,
165 "[E_INVALID_ARG] The invalid listener was given.\n");
167 // cast to _TextEventArg
168 const _TextEventArg* pArg = dynamic_cast <const _TextEventArg*>(&arg);
169 SysTryReturnVoidResult(NID_UI_CTRL, pArg != null, E_INVALID_ARG, "[E_INVALID_ARG] The invalid Event Argument was given.\n");
171 CoreTextEventStatus stauts = pArg->GetStatus();
172 if (stauts == CORE_TEXT_EVENT_CHANGED)
174 pTextListener->OnTextValueChanged(*__pSource);
176 else if (stauts == CORE_TEXT_EVENT_CANCELED)
178 pTextListener->OnTextValueChangeCanceled(*__pSource);
181 SetLastResult(E_SUCCESS);
187 _TextEvent::CreateTextEventArgN(CoreTextEventStatus status)
189 _TextEventArg* pEventArg = new (std::nothrow) _TextEventArg(status);
190 SysTryReturn(NID_UI_CTRL, pEventArg, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory shortage.");
195 }}} // Tizen::Ui::Controls