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_TextBlockEvent.cpp
19 * @brief This is the implementation for the _TextBlockEvent class.
24 #include <FBaseErrors.h>
25 #include <FBaseSysLog.h>
27 #include "FUiCtrl_TextBlockEvent.h"
28 #include "FUiCtrl_ITextBlockEventListener.h"
31 using namespace Tizen::Base;
32 using namespace Tizen::Base::Runtime;
34 namespace Tizen { namespace Ui { namespace Controls
38 * @class _TextBlockEventArg
39 * @brief This class is used as the argument to change event listener.
41 * This class is used as the argument to change event listener. When an change event is generated
42 * (such as when a button is pressed) the TextBlockEvent calls TextBlockEventListener's OnTextd
43 * with an instance of this class as an argument.
45 * From this class, one can find out, the (event) source object and the change ID.
47 class _OSP_EXPORT_ _TextBlockEventArg
54 * This is the default class constructor.
57 _TextBlockEventArg(int start, int end);
60 * This is the class destructor.
63 virtual ~_TextBlockEventArg(void);
68 const int GetStartPosition(void) const;
70 const int GetEndPosition(void) const;
83 }; // _TextBlockEventArg
85 ////////////////////////////////////////////////////////////////////////////////
86 /// _TextBlockEventArg class Lifecycle
88 _TextBlockEventArg::_TextBlockEventArg(int start, int end)
95 _TextBlockEventArg::~_TextBlockEventArg(void)
101 _TextBlockEventArg::GetStartPosition(void) const
107 _TextBlockEventArg::GetEndPosition(void) const
112 ////////////////////////////////////////////////////////////////////////////////
113 /// _TextBlockEvent class Lifecycle
114 _TextBlockEvent::_TextBlockEvent(const _Control& source)
117 result r = _Event::Initialize();
126 _TextBlockEvent::~_TextBlockEvent(void)
132 _TextBlockEvent::CreateInstanceN(const _Control& source)
134 _TextBlockEvent* pCoreTextBlockEvent = new (std::nothrow) _TextBlockEvent(source);
135 SysTryReturn(NID_UI_CTRL, pCoreTextBlockEvent, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory shortage.");
137 if (IsFailed(GetLastResult()))
142 return pCoreTextBlockEvent;
145 delete pCoreTextBlockEvent;
152 _TextBlockEvent::GetSource(void) const
160 _TextBlockEvent::FireImpl(IEventListener& listener, const IEventArg& arg)
162 _ITextBlockEventListener* pTextBlockEventListener = dynamic_cast <_ITextBlockEventListener*>(&listener);
163 SysTryReturnVoidResult(NID_UI_CTRL, pTextBlockEventListener != null, E_INVALID_ARG, "The Invalid listener is given.\n");
165 const _TextBlockEventArg* pTextBlockEventArg = dynamic_cast <const _TextBlockEventArg*>(&arg);
166 SysTryReturnVoidResult(NID_UI_CTRL, pTextBlockEventArg != null, E_INVALID_ARG, "The Invalid Event Argument is given.\n");
168 pTextBlockEventListener->OnTextBlockSelected(const_cast <_Control&>(*__pSource),
169 pTextBlockEventArg->GetStartPosition(), pTextBlockEventArg->GetEndPosition());
171 SetLastResult(E_SUCCESS);
177 _TextBlockEvent::CreateTextBlockEventArgN(int start, int end)
179 _TextBlockEventArg* pEventArg = new (std::nothrow) _TextBlockEventArg(start, end);
180 SysTryReturn(NID_UI_CTRL, pEventArg, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory shortage.");
185 }}} // Tizen::Ui::Controls