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.
18 * @file FUiCtrl_ExpandableEditAreaEvent.cpp
19 * @brief This is the implementation for the _ExpandableEditAreaEvent class.
24 #include <FBaseSysLog.h>
25 #include <FBaseErrors.h>
27 #include "FUiCtrl_ExpandableEditAreaEvent.h"
28 #include "FUiCtrl_IExpandableEditAreaEventListener.h"
31 using namespace Tizen::Base;
32 using namespace Tizen::Base::Runtime;
34 namespace Tizen {namespace Ui {namespace Controls
38 * @class _CoreExpandableEditAreaEventArg
39 * @brief This class is used as the argument to action event listener.
41 * This class is used as the argument to action event listener. When an action event is generated
42 * (such as when a button is pressed) the TextEvent calls TextEventListener's OnActionPerformed
43 * with an instance of this class as an argument.
45 * From this class, one can find out, the (event) source object and the action ID.
47 class _OSP_EXPORT_ _CoreExpandableEditAreaEventArg
54 * This is the default class constructor.
56 * @param[in] source A pointer to the Object instance which contains this instance.
57 * @param[in] actionId Action Id.
59 _CoreExpandableEditAreaEventArg(_ExpandableEditAreaEventStatus status, int tokenIndex = -1);
62 * This is the class destructor.
65 virtual ~_CoreExpandableEditAreaEventArg(void);
71 * This method returns the TextEventStatus which the event initially occurred.
73 * @return See the comment above.
75 _ExpandableEditAreaEventStatus GetStatus(void) const;
77 int GetNewLineCount(void) const;
85 _ExpandableEditAreaEventStatus __status;
88 }; // _CoreExpandableEditAreaEventArg
90 _CoreExpandableEditAreaEventArg::_CoreExpandableEditAreaEventArg(_ExpandableEditAreaEventStatus status, int newLineCount)
92 , __newLineCount(newLineCount)
97 _CoreExpandableEditAreaEventArg::~_CoreExpandableEditAreaEventArg(void)
102 ////////////////////////////////////////////////////////////////////////////////
103 /// _CoreExpandableEditAreaEventArg class Access
105 _ExpandableEditAreaEventStatus
106 _CoreExpandableEditAreaEventArg::GetStatus(void) const
112 _CoreExpandableEditAreaEventArg::GetNewLineCount(void) const
114 return __newLineCount;
117 ////////////////////////////////////////////////////////////////////////////////
118 /// _CoreExpandableEditAreaEvent class Lifecycle
120 _ExpandableEditAreaEvent::_ExpandableEditAreaEvent(const _Control& source)
123 result r = _Event::Initialize();
132 _ExpandableEditAreaEvent::~_ExpandableEditAreaEvent(void)
137 _ExpandableEditAreaEvent*
138 _ExpandableEditAreaEvent::CreateInstanceN(const _Control& source)
140 _ExpandableEditAreaEvent* pCoreTextEvent = new (std::nothrow) _ExpandableEditAreaEvent(source);
141 SysTryReturn(NID_UI_CTRL, pCoreTextEvent, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory shortage.");
143 if (IsFailed(GetLastResult()))
148 return pCoreTextEvent;
151 delete pCoreTextEvent;
155 ////////////////////////////////////////////////////////////////////////////////
156 /// _WindowEvent class Accessor
159 _ExpandableEditAreaEvent::GetSource(void) const
164 ////////////////////////////////////////////////////////////////////////////////
165 /// _CoreExpandableEditAreaEvent class Operation
168 _ExpandableEditAreaEvent::FireImpl(IEventListener& listener, const IEventArg& arg)
170 // cast to _ITextEventListener
171 _IExpandableEditAreaEventListener* pExpandableEditAreaEventListener =
172 dynamic_cast <_IExpandableEditAreaEventListener*>(&listener);
173 SysTryReturnVoidResult(NID_UI_CTRL, pExpandableEditAreaEventListener != null, E_INVALID_ARG,
174 "[E_INVALID_ARG] The invalid listener was given.\n");
176 // cast to _CoreExpandableEditAreaEventArg
177 const _CoreExpandableEditAreaEventArg* pArg = dynamic_cast <const _CoreExpandableEditAreaEventArg*>(&arg);
178 SysTryReturnVoidResult(NID_UI_CTRL, pArg != null, E_INVALID_ARG, "[E_INVALID_ARG] The invalid Event Argument was given.\n");
180 _ExpandableEditAreaEventStatus status = pArg->GetStatus();
181 if (status == _EXPANDABLE_EDITAREA_EVENT_ADDED)
183 pExpandableEditAreaEventListener->OnExpandableEditAreaLineAdded(*__pSource, pArg->GetNewLineCount());
185 else if (status == _EXPANDABLE_EDITAREA_EVENT_REMOVED)
187 pExpandableEditAreaEventListener->OnExpandableEditAreaLineRemoved(*__pSource, pArg->GetNewLineCount());
190 SetLastResult(E_SUCCESS);
196 _ExpandableEditAreaEvent::CreateExpandableEditAreaEventArgN(_ExpandableEditAreaEventStatus status, int newLineCount)
198 _CoreExpandableEditAreaEventArg* pEventArg = new (std::nothrow) _CoreExpandableEditAreaEventArg(status, newLineCount);
199 SysTryReturn(NID_UI_CTRL, pEventArg, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory shortage.");
204 }}} // Tizen::Ui::Controls