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_PublicTextBlockEvent.cpp
19 * @brief This is the implementation for the _PublicTextBlockEvent class.
21 * This file contains implementation of _PublicTextBlockEvent class.
25 #include <FBaseErrors.h>
26 #include <FBaseSysLog.h>
28 #include <FUiITextBlockEventListener.h>
29 #include "FUiCtrl_PublicTextBlockEvent.h"
33 using namespace Tizen::Base;
34 using namespace Tizen::Base::Runtime;
36 namespace Tizen { namespace Ui { namespace Controls
40 * @class _PublicTextBlockEventArg
41 * @brief This class is used as the argument to change event listener.
43 * This class is used as the argument to change event listener. When an change event is generated
44 * (such as when a button is pressed) the TextBlockEvent calls TextBlockEventListener's OnTextd
45 * with an instance of this class as an argument.
47 * From this class, one can find out, the (event) source object and the change ID.
49 class _OSP_EXPORT_ _PublicTextBlockEventArg
56 * This is the default class constructor.
59 _PublicTextBlockEventArg(int start, int end);
62 * This is the class destructor.
65 virtual ~_PublicTextBlockEventArg(void);
71 * Gets the start position of text block.
73 * @return the start position of text block.
75 const int GetStartPosition(void) const;
78 * Gets the end position of text block.
80 * @return the end position of text block.
82 const int GetEndPosition(void) const;
95 }; // _PublicTextBlockEventArg
97 ////////////////////////////////////////////////////////////////////////////////
98 /// _PublicTextBlockEventArg class Lifecycle
100 _PublicTextBlockEventArg::_PublicTextBlockEventArg(int start, int end)
107 _PublicTextBlockEventArg::~_PublicTextBlockEventArg(void)
113 _PublicTextBlockEventArg::GetStartPosition(void) const
119 _PublicTextBlockEventArg::GetEndPosition(void) const
124 ////////////////////////////////////////////////////////////////////////////////
125 /// _PublicTextBlockEvent class Lifecycle
126 _PublicTextBlockEvent::_PublicTextBlockEvent(const Control& source)
129 result r = _Event::Initialize();
138 _PublicTextBlockEvent::~_PublicTextBlockEvent(void)
143 _PublicTextBlockEvent*
144 _PublicTextBlockEvent::CreateInstanceN(const Control& source)
146 _PublicTextBlockEvent* pPublicTextBlockEvent = new (std::nothrow) _PublicTextBlockEvent(source);
147 SysTryReturn(NID_UI_CTRL, pPublicTextBlockEvent, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory shortage.");
149 return pPublicTextBlockEvent;
155 _PublicTextBlockEvent::GetSource(void) const
163 _PublicTextBlockEvent::FireImpl(IEventListener& listener, const IEventArg& arg)
165 ITextBlockEventListener* pTextBlockEventListener = dynamic_cast <ITextBlockEventListener*>(&listener);
166 SysTryReturnVoidResult(NID_UI_CTRL, pTextBlockEventListener != null, E_INVALID_ARG, "The Invalid listener is given.\n");
168 const _PublicTextBlockEventArg* pTextBlockEventArg = dynamic_cast <const _PublicTextBlockEventArg*>(&arg);
169 SysTryReturnVoidResult(NID_UI_CTRL, pTextBlockEventArg != null, E_INVALID_ARG, "The Invalid Event Argument is given.\n");
171 pTextBlockEventListener->OnTextBlockSelected(const_cast <Control&>(*__pSource),
172 pTextBlockEventArg->GetStartPosition(), pTextBlockEventArg->GetEndPosition());
174 SetLastResult(E_SUCCESS);
180 _PublicTextBlockEvent::CreateTextBlockEventArgN(int start, int end)
182 _PublicTextBlockEventArg* pEventArg = new (std::nothrow) _PublicTextBlockEventArg(start, end);
183 SysTryReturn(NID_UI_CTRL, pEventArg, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory shortage.");
188 }}} // Tizen::Ui::Controls