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_TextEvent.cpp
19 * @brief This is the implementation for the TextEvent class.
24 #include <FBaseErrors.h>
25 #include <FBaseSysLog.h>
27 #include "FUiCtrl_ITextEventListener.h"
28 #include "FUiCtrl_TextEvent.h"
32 using namespace Tizen::Base;
33 using namespace Tizen::Base::Runtime;
35 namespace Tizen { namespace Ui { namespace Controls
39 * @class _TextEventArg
40 * @brief This class is used as the argument to action event listener.
42 * This class is used as the argument to action event listener. When an action event is generated
43 * (such as when a button is pressed) the TextEvent calls TextEventListener's OnActionPerformed
44 * with an instance of this class as an argument.
46 * From this class, one can find out, the (event) source object and the action ID.
48 class _OSP_EXPORT_ _TextEventArg
55 * This is the default class constructor.
57 * @param[in] source A pointer to the Object instance which contains this instance.
58 * @param[in] actionId Action Id.
60 _TextEventArg(CoreTextEventStatus status);
63 * This is the class destructor.
66 virtual ~_TextEventArg(void);
72 * This method returns the TextEventStatus which the event initially occurred.
74 * @return See the comment above.
76 CoreTextEventStatus GetStatus(void) const;
84 CoreTextEventStatus __status;
87 _TextEventArg::_TextEventArg(CoreTextEventStatus status)
93 _TextEventArg::~_TextEventArg(void)
98 ////////////////////////////////////////////////////////////////////////////////
99 /// _TextEventArg class Access
102 _TextEventArg::GetStatus(void) const
108 ////////////////////////////////////////////////////////////////////////////////
109 /// _TextEvent class Lifecycle
111 _TextEvent::_TextEvent(const _Control& source)
114 result r = _Event::Initialize();
123 _TextEvent::~_TextEvent(void)
129 _TextEvent::CreateInstanceN(const _Control& source)
131 _TextEvent* pCoreTextEvent = new (std::nothrow) _TextEvent(source);
132 SysTryReturn(NID_UI_CTRL, pCoreTextEvent, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory shortage.");
134 if (IsFailed(GetLastResult()))
139 return pCoreTextEvent;
142 delete pCoreTextEvent;
146 ////////////////////////////////////////////////////////////////////////////////
147 /// _WindowEvent class Accessor
150 _TextEvent::GetSource(void) const
155 ////////////////////////////////////////////////////////////////////////////////
156 /// _TextEvent class Operation
159 _TextEvent::FireImpl(IEventListener& listener, const IEventArg& arg)
161 // cast to _ITextEventListener
162 _ITextEventListener* pTextListener = dynamic_cast <_ITextEventListener*>(&listener);
163 SysTryReturnVoidResult(NID_UI_CTRL, pTextListener != null, E_INVALID_ARG,
164 "[E_INVALID_ARG] The invalid listener was given.\n");
166 // cast to _TextEventArg
167 const _TextEventArg* pArg = dynamic_cast <const _TextEventArg*>(&arg);
168 SysTryReturnVoidResult(NID_UI_CTRL, pArg != null, E_INVALID_ARG, "[E_INVALID_ARG] The invalid Event Argument was given.\n");
170 CoreTextEventStatus stauts = pArg->GetStatus();
171 if (stauts == CORE_TEXT_EVENT_CHANGED)
173 pTextListener->OnTextValueChanged(*__pSource);
175 else if (stauts == CORE_TEXT_EVENT_CANCELED)
177 pTextListener->OnTextValueChangeCanceled(*__pSource);
180 SetLastResult(E_SUCCESS);
186 _TextEvent::CreateTextEventArgN(CoreTextEventStatus status)
188 _TextEventArg* pEventArg = new (std::nothrow) _TextEventArg(status);
189 SysTryReturn(NID_UI_CTRL, pEventArg, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory shortage.");
194 }}} // Tizen::Ui::Controls