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_PublicExpandableEditAreaEvent.cpp
19 * @brief This is the implementation for the _PublicExpandableEditAreaEvent class.
21 * This file contains implementation of _PublicExpandableEditAreaEvent class.
26 #include <FBaseSysLog.h>
27 #include <FBaseErrors.h>
28 #include <FUiCtrlIExpandableEditAreaEventListener.h>
29 #include "FUiCtrl_PublicExpandableEditAreaEvent.h"
32 using namespace Tizen::Base;
33 using namespace Tizen::Base::Runtime;
35 namespace Tizen {namespace Ui {namespace Controls
38 * @class _PublicExpandableEditAreaEventArg
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 ExpandableEditAreaEvent calls ExpandableEditAreaEventListener'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_ _PublicExpandableEditAreaEventArg
48 : public Tizen::Base::Runtime::IEventArg
49 , public Tizen::Base::Object
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 _PublicExpandableEditAreaEventArg(ExpandableEditAreaEventStatus status, int selectedTokenIndex = -1);
62 * This is the class destructor.
65 virtual ~_PublicExpandableEditAreaEventArg(void);
71 * This method returns the ExpandableEditAreaEventStatus which the event initially occurred.
73 * @return See the comment above.
75 ExpandableEditAreaEventStatus GetStatus(void) const;
77 int GetNewLineCount(void) const;
83 * ExpandableEditAreaEventStatus.
85 ExpandableEditAreaEventStatus __status;
88 }; // _PublicExpandableEditAreaEventArg
90 _PublicExpandableEditAreaEventArg::_PublicExpandableEditAreaEventArg(ExpandableEditAreaEventStatus status, int newLineCount)
92 , __newLineCount(newLineCount)
97 _PublicExpandableEditAreaEventArg::~_PublicExpandableEditAreaEventArg(void)
102 ////////////////////////////////////////////////////////////////////////////////
103 /// _ExpandableEditAreaEventArg class Access
104 ExpandableEditAreaEventStatus
105 _PublicExpandableEditAreaEventArg::GetStatus(void) const
111 _PublicExpandableEditAreaEventArg::GetNewLineCount(void) const
113 return __newLineCount;
117 ////////////////////////////////////////////////////////////////////////////////
118 /// _PublicExpandableEditAreaEvent class Lifecycle
119 _PublicExpandableEditAreaEvent::_PublicExpandableEditAreaEvent(const Tizen::Ui::Control& source)
122 result r = _Event::Initialize();
131 _PublicExpandableEditAreaEvent::~_PublicExpandableEditAreaEvent(void)
136 _PublicExpandableEditAreaEvent*
137 _PublicExpandableEditAreaEvent::CreateInstanceN(const Tizen::Ui::Control& source)
139 _PublicExpandableEditAreaEvent* pPublicExpandableEditAreaEvent = new (std::nothrow) _PublicExpandableEditAreaEvent(source);
140 SysTryReturn(NID_UI_CTRL, pPublicExpandableEditAreaEvent, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory shortage.");
142 if (IsFailed(GetLastResult()))
147 return pPublicExpandableEditAreaEvent;
150 delete pPublicExpandableEditAreaEvent;
154 ////////////////////////////////////////////////////////////////////////////////
155 /// _WindowEvent class Accessor
157 const Tizen::Ui::Control*
158 _PublicExpandableEditAreaEvent::GetSource(void) const
163 ////////////////////////////////////////////////////////////////////////////////
164 /// _PublicExpandableEditAreaEvent class Operation
167 _PublicExpandableEditAreaEvent::FireImpl(Tizen::Base::Runtime::IEventListener& listener, const Tizen::Base::Runtime::IEventArg& arg)
169 // cast to IExpandableEditAreaEventListener
170 IExpandableEditAreaEventListener* pExpandableEditAreaEventListener =
171 dynamic_cast <IExpandableEditAreaEventListener*>(&listener);
172 SysTryReturnVoidResult(NID_UI_CTRL, pExpandableEditAreaEventListener != null, E_INVALID_ARG,
173 "[E_INVALID_ARG] The invalid listener was given.\n");
175 // cast to _PublicExpandableEditAreaEventArg
176 const _PublicExpandableEditAreaEventArg* pArg = dynamic_cast <const _PublicExpandableEditAreaEventArg*>(&arg);
177 SysTryReturnVoidResult(NID_UI_CTRL, pArg != null, E_INVALID_ARG, "[E_INVALID_ARG] The invalid Event Argument was given.\n");
179 // call cursor change event listener method
180 ExpandableEditAreaEventStatus status = pArg->GetStatus();
181 if (status == EXPANDABLE_EDITAREA_EVENT_ADDED)
183 pExpandableEditAreaEventListener->OnExpandableEditAreaLineAdded(*dynamic_cast <ExpandableEditArea*>(const_cast <Control*>(__pSource)),
184 pArg->GetNewLineCount());
186 else if (status == EXPANDABLE_EDITAREA_EVENT_REMOVED)
188 pExpandableEditAreaEventListener->OnExpandableEditAreaLineRemoved(*dynamic_cast <ExpandableEditArea*>(const_cast <Control*>(__pSource)),
189 pArg->GetNewLineCount());
191 SetLastResult(E_SUCCESS);
197 _PublicExpandableEditAreaEvent::CreateExpandableEditAreaEventArgN(ExpandableEditAreaEventStatus status, int newLineCount)
199 _PublicExpandableEditAreaEventArg* pEventArg = new (std::nothrow) _PublicExpandableEditAreaEventArg(status, newLineCount);
200 SysTryReturn(NID_UI_CTRL, pEventArg, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory shortage.");
205 }}} // Tizen::Ui::Controls