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_TextBlockEvent.cpp
20 * @brief This is the implementation for the _TextBlockEvent class.
25 #include <FBaseErrors.h>
26 #include <FBaseSysLog.h>
28 #include "FUiCtrl_TextBlockEvent.h"
29 #include "FUiCtrl_ITextBlockEventListener.h"
32 using namespace Tizen::Base;
33 using namespace Tizen::Base::Runtime;
35 namespace Tizen { namespace Ui { namespace Controls
39 * @class _TextBlockEventArg
40 * @brief This class is used as the argument to change event listener.
42 * This class is used as the argument to change event listener. When an change event is generated
43 * (such as when a button is pressed) the TextBlockEvent calls TextBlockEventListener's OnTextd
44 * with an instance of this class as an argument.
46 * From this class, one can find out, the (event) source object and the change ID.
48 class _OSP_EXPORT_ _TextBlockEventArg
55 * This is the default class constructor.
58 _TextBlockEventArg(int start, int end);
61 * This is the class destructor.
64 virtual ~_TextBlockEventArg(void);
69 const int GetStartPosition(void) const;
71 const int GetEndPosition(void) const;
84 }; // _TextBlockEventArg
86 ////////////////////////////////////////////////////////////////////////////////
87 /// _TextBlockEventArg class Lifecycle
89 _TextBlockEventArg::_TextBlockEventArg(int start, int end)
96 _TextBlockEventArg::~_TextBlockEventArg(void)
102 _TextBlockEventArg::GetStartPosition(void) const
108 _TextBlockEventArg::GetEndPosition(void) const
113 ////////////////////////////////////////////////////////////////////////////////
114 /// _TextBlockEvent class Lifecycle
115 _TextBlockEvent::_TextBlockEvent(const _Control& source)
118 result r = _Event::Initialize();
127 _TextBlockEvent::~_TextBlockEvent(void)
133 _TextBlockEvent::CreateInstanceN(const _Control& source)
135 _TextBlockEvent* pCoreTextBlockEvent = new (std::nothrow) _TextBlockEvent(source);
136 SysTryReturn(NID_UI_CTRL, pCoreTextBlockEvent, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory shortage.");
138 if (IsFailed(GetLastResult()))
143 return pCoreTextBlockEvent;
146 delete pCoreTextBlockEvent;
153 _TextBlockEvent::GetSource(void) const
161 _TextBlockEvent::FireImpl(IEventListener& listener, const IEventArg& arg)
163 _ITextBlockEventListener* pTextBlockEventListener = dynamic_cast <_ITextBlockEventListener*>(&listener);
164 SysTryReturnVoidResult(NID_UI_CTRL, pTextBlockEventListener != null, E_INVALID_ARG, "The Invalid listener is given.\n");
166 const _TextBlockEventArg* pTextBlockEventArg = dynamic_cast <const _TextBlockEventArg*>(&arg);
167 SysTryReturnVoidResult(NID_UI_CTRL, pTextBlockEventArg != null, E_INVALID_ARG, "The Invalid Event Argument is given.\n");
169 pTextBlockEventListener->OnTextBlockSelected(const_cast <_Control&>(*__pSource),
170 pTextBlockEventArg->GetStartPosition(), pTextBlockEventArg->GetEndPosition());
172 SetLastResult(E_SUCCESS);
178 _TextBlockEvent::CreateTextBlockEventArgN(int start, int end)
180 _TextBlockEventArg* pEventArg = new (std::nothrow) _TextBlockEventArg(start, end);
181 SysTryReturn(NID_UI_CTRL, pEventArg, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory shortage.");
186 }}} // Tizen::Ui::Controls