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_PublicTextBlockEvent.cpp
20 * @brief This is the implementation for the _PublicTextBlockEvent class.
22 * This file contains implementation of _PublicTextBlockEvent class.
26 #include <FBaseErrors.h>
27 #include <FBaseSysLog.h>
29 #include <FUiITextBlockEventListener.h>
30 #include "FUiCtrl_PublicTextBlockEvent.h"
34 using namespace Tizen::Base;
35 using namespace Tizen::Base::Runtime;
37 namespace Tizen { namespace Ui { namespace Controls
41 * @class _PublicTextBlockEventArg
42 * @brief This class is used as the argument to change event listener.
44 * This class is used as the argument to change event listener. When an change event is generated
45 * (such as when a button is pressed) the TextBlockEvent calls TextBlockEventListener's OnTextd
46 * with an instance of this class as an argument.
48 * From this class, one can find out, the (event) source object and the change ID.
50 class _OSP_EXPORT_ _PublicTextBlockEventArg
57 * This is the default class constructor.
60 _PublicTextBlockEventArg(int start, int end);
63 * This is the class destructor.
66 virtual ~_PublicTextBlockEventArg(void);
72 * Gets the start position of text block.
74 * @return the start position of text block.
76 const int GetStartPosition(void) const;
79 * Gets the end position of text block.
81 * @return the end position of text block.
83 const int GetEndPosition(void) const;
96 }; // _PublicTextBlockEventArg
98 ////////////////////////////////////////////////////////////////////////////////
99 /// _PublicTextBlockEventArg class Lifecycle
101 _PublicTextBlockEventArg::_PublicTextBlockEventArg(int start, int end)
108 _PublicTextBlockEventArg::~_PublicTextBlockEventArg(void)
114 _PublicTextBlockEventArg::GetStartPosition(void) const
120 _PublicTextBlockEventArg::GetEndPosition(void) const
125 ////////////////////////////////////////////////////////////////////////////////
126 /// _PublicTextBlockEvent class Lifecycle
127 _PublicTextBlockEvent::_PublicTextBlockEvent(const Control& source)
130 result r = _Event::Initialize();
139 _PublicTextBlockEvent::~_PublicTextBlockEvent(void)
144 _PublicTextBlockEvent*
145 _PublicTextBlockEvent::CreateInstanceN(const Control& source)
147 _PublicTextBlockEvent* pPublicTextBlockEvent = new (std::nothrow) _PublicTextBlockEvent(source);
148 SysTryReturn(NID_UI_CTRL, pPublicTextBlockEvent, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory shortage.");
150 return pPublicTextBlockEvent;
156 _PublicTextBlockEvent::GetSource(void) const
164 _PublicTextBlockEvent::FireImpl(IEventListener& listener, const IEventArg& arg)
166 ITextBlockEventListener* pTextBlockEventListener = dynamic_cast <ITextBlockEventListener*>(&listener);
167 SysTryReturnVoidResult(NID_UI_CTRL, pTextBlockEventListener != null, E_INVALID_ARG, "The Invalid listener is given.\n");
169 const _PublicTextBlockEventArg* pTextBlockEventArg = dynamic_cast <const _PublicTextBlockEventArg*>(&arg);
170 SysTryReturnVoidResult(NID_UI_CTRL, pTextBlockEventArg != null, E_INVALID_ARG, "The Invalid Event Argument is given.\n");
172 pTextBlockEventListener->OnTextBlockSelected(const_cast <Control&>(*__pSource),
173 pTextBlockEventArg->GetStartPosition(), pTextBlockEventArg->GetEndPosition());
175 SetLastResult(E_SUCCESS);
181 _PublicTextBlockEvent::CreateTextBlockEventArgN(int start, int end)
183 _PublicTextBlockEventArg* pEventArg = new (std::nothrow) _PublicTextBlockEventArg(start, end);
184 SysTryReturn(NID_UI_CTRL, pEventArg, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory shortage.");
189 }}} // Tizen::Ui::Controls