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_PublicTextEvent.cpp
20 * @brief This is the implementation for the _PublicTextEvent class.
22 * This file contains implementation of _PublicTextEvent class.
26 #include <FBaseErrors.h>
27 #include <FBaseSysLog.h>
28 #include <FUiITextEventListener.h>
30 #include "FUiCtrl_PublicTextEvent.h"
34 using namespace Tizen::Base;
35 using namespace Tizen::Base::Runtime;
37 namespace Tizen { namespace Ui { namespace Controls
41 * @class _PublicTextEventArg
42 * @brief This class is used as the argument to action event listener.
44 * This class is used as the argument to action event listener. When an action event is generated
45 * (such as when a button is pressed) the TextEvent calls TextEventListener's OnActionPerformed
46 * with an instance of this class as an argument.
48 * From this class, one can find out, the (event) source object and the action ID.
50 class _OSP_EXPORT_ _PublicTextEventArg
57 * This is the default class constructor.
59 * @param[in] source A pointer to the Object instance which contains this instance.
60 * @param[in] actionId Action Id.
62 _PublicTextEventArg(TextEventStatus status);
65 * This is the class destructor.
68 virtual ~_PublicTextEventArg(void);
74 * This method returns the TextEventStatus which the event initially occurred.
76 * @return See the comment above.
78 TextEventStatus GetStatus(void) const;
86 TextEventStatus __status;
87 }; // _PublicTextEventArg
89 _PublicTextEventArg::_PublicTextEventArg(TextEventStatus status)
95 _PublicTextEventArg::~_PublicTextEventArg(void)
100 ////////////////////////////////////////////////////////////////////////////////
101 /// _TextEventArg class Access
103 _PublicTextEventArg::GetStatus(void) const
108 ////////////////////////////////////////////////////////////////////////////////
109 /// _PublicTextEvent class Lifecycle
110 _PublicTextEvent::_PublicTextEvent(const Control& source)
113 result r = _Event::Initialize();
122 _PublicTextEvent::~_PublicTextEvent(void)
128 _PublicTextEvent::CreateInstanceN(const Control& source)
130 _PublicTextEvent* pPublicTextEvent = new (std::nothrow) _PublicTextEvent(source);
131 SysTryReturn(NID_UI_CTRL, pPublicTextEvent, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory shortage.");
133 return pPublicTextEvent;
136 ////////////////////////////////////////////////////////////////////////////////
137 /// _WindowEvent class Accessor
140 _PublicTextEvent::GetSource(void) const
145 ////////////////////////////////////////////////////////////////////////////////
146 /// _PublicTextEvent class Operation
149 _PublicTextEvent::FireImpl(IEventListener& listener, const IEventArg& arg)
151 // cast to ITextEventListener
152 ITextEventListener* pTextListener = dynamic_cast <ITextEventListener*>(&listener);
153 SysTryReturnVoidResult(NID_UI_CTRL, pTextListener != null, E_INVALID_ARG,
154 "[E_INVALID_ARG] The invalid listener was given.\n");
156 // cast to _PublicTextEventArg
157 const _PublicTextEventArg* pArg = dynamic_cast <const _PublicTextEventArg*>(&arg);
158 SysTryReturnVoidResult(NID_UI_CTRL, pArg != null, E_INVALID_ARG, "[E_INVALID_ARG] The invalid Event Argument was given.\n");
160 // call cursor change event listener method
161 TextEventStatus stauts = pArg->GetStatus();
162 if (stauts == TEXT_EVENT_CHANGED)
164 pTextListener->OnTextValueChanged(*__pSource);
166 else if (stauts == TEXT_EVENT_CANCELED)
168 pTextListener->OnTextValueChangeCanceled(*__pSource);
171 SetLastResult(E_SUCCESS);
177 _PublicTextEvent::CreateTextEventArgN(TextEventStatus status)
179 _PublicTextEventArg* pEventArg = new (std::nothrow) _PublicTextEventArg(status);
180 SysTryReturn(NID_UI_CTRL, pEventArg, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory shortage.");
185 }}} // Tizen::Ui::Controls