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_PublicTextEvent.cpp
19 * @brief This is the implementation for the _PublicTextEvent class.
21 * This file contains implementation of _PublicTextEvent class.
25 #include <FBaseErrors.h>
26 #include <FBaseSysLog.h>
27 #include <FUiITextEventListener.h>
29 #include "FUiCtrl_PublicTextEvent.h"
33 using namespace Tizen::Base;
34 using namespace Tizen::Base::Runtime;
36 namespace Tizen { namespace Ui { namespace Controls
40 * @class _PublicTextEventArg
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_ _PublicTextEventArg
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 _PublicTextEventArg(TextEventStatus status);
64 * This is the class destructor.
67 virtual ~_PublicTextEventArg(void);
73 * This method returns the TextEventStatus which the event initially occurred.
75 * @return See the comment above.
77 TextEventStatus GetStatus(void) const;
85 TextEventStatus __status;
86 }; // _PublicTextEventArg
88 _PublicTextEventArg::_PublicTextEventArg(TextEventStatus status)
94 _PublicTextEventArg::~_PublicTextEventArg(void)
99 ////////////////////////////////////////////////////////////////////////////////
100 /// _TextEventArg class Access
102 _PublicTextEventArg::GetStatus(void) const
107 ////////////////////////////////////////////////////////////////////////////////
108 /// _PublicTextEvent class Lifecycle
109 _PublicTextEvent::_PublicTextEvent(const Control& source)
112 result r = _Event::Initialize();
121 _PublicTextEvent::~_PublicTextEvent(void)
127 _PublicTextEvent::CreateInstanceN(const Control& source)
129 _PublicTextEvent* pPublicTextEvent = new (std::nothrow) _PublicTextEvent(source);
130 SysTryReturn(NID_UI_CTRL, pPublicTextEvent, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory shortage.");
132 return pPublicTextEvent;
135 ////////////////////////////////////////////////////////////////////////////////
136 /// _WindowEvent class Accessor
139 _PublicTextEvent::GetSource(void) const
144 ////////////////////////////////////////////////////////////////////////////////
145 /// _PublicTextEvent class Operation
148 _PublicTextEvent::FireImpl(IEventListener& listener, const IEventArg& arg)
150 // cast to ITextEventListener
151 ITextEventListener* pTextListener = dynamic_cast <ITextEventListener*>(&listener);
152 SysTryReturnVoidResult(NID_UI_CTRL, pTextListener != null, E_INVALID_ARG,
153 "[E_INVALID_ARG] The invalid listener was given.\n");
155 // cast to _PublicTextEventArg
156 const _PublicTextEventArg* pArg = dynamic_cast <const _PublicTextEventArg*>(&arg);
157 SysTryReturnVoidResult(NID_UI_CTRL, pArg != null, E_INVALID_ARG, "[E_INVALID_ARG] The invalid Event Argument was given.\n");
159 // call cursor change event listener method
160 TextEventStatus stauts = pArg->GetStatus();
161 if (stauts == TEXT_EVENT_CHANGED)
163 pTextListener->OnTextValueChanged(*__pSource);
165 else if (stauts == TEXT_EVENT_CANCELED)
167 pTextListener->OnTextValueChangeCanceled(*__pSource);
170 SetLastResult(E_SUCCESS);
176 _PublicTextEvent::CreateTextEventArgN(TextEventStatus status)
178 _PublicTextEventArg* pEventArg = new (std::nothrow) _PublicTextEventArg(status);
179 SysTryReturn(NID_UI_CTRL, pEventArg, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory shortage.");
184 }}} // Tizen::Ui::Controls