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_LinkEvent.cpp
19 * @brief This is the implementation for the _LinkEvent class.
24 #include <FBaseErrors.h>
25 #include <FBaseSysLog.h>
27 #include "FUiCtrl_LinkEvent.h"
31 using namespace Tizen::Base;
32 using namespace Tizen::Base::Runtime;
33 using namespace Tizen::Base::Utility;
35 namespace Tizen { namespace Ui { namespace Controls
39 * @class _LinkEventArg
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 TextSelectionEvent calls TextSelectionEventListener'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_ _LinkEventArg
55 * This is the default class constructor.
58 _LinkEventArg(const String& text, LinkType linkType, const String& link);
61 * This is the class destructor.
64 virtual ~_LinkEventArg(void);
66 String GetText(void) const;
68 LinkType GetLinkType(void) const;
70 String GetLinkText(void) const;
81 ////////////////////////////////////////////////////////////////////////////////
82 /// _LinkEventArg class Lifecycle
84 _LinkEventArg::_LinkEventArg(const String& text, LinkType linkType, const String& link)
86 , __linkType(linkType)
92 _LinkEventArg::~_LinkEventArg(void)
98 _LinkEventArg::GetText(void) const
104 _LinkEventArg::GetLinkType(void) const
110 _LinkEventArg::GetLinkText(void) const
115 ////////////////////////////////////////////////////////////////////////////////
116 /// _LinkEvent class Lifecycle
117 _LinkEvent::_LinkEvent(const _Control& source)
120 result r = _Event::Initialize();
129 _LinkEvent::~_LinkEvent(void)
135 _LinkEvent::CreateInstanceN(const _Control& source)
137 _LinkEvent* pCoreLinkEvent = new (std::nothrow) _LinkEvent(source);
138 SysTryReturn(NID_UI_CTRL, pCoreLinkEvent, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory shortage.");
140 if (IsFailed(GetLastResult()))
143 return pCoreLinkEvent;
146 delete pCoreLinkEvent;
151 _LinkEvent::GetSource(void) const
157 _LinkEvent::FireImpl(IEventListener& listener, const IEventArg& arg)
159 _IUiLinkEventListener* pLinkEventListener = dynamic_cast <_IUiLinkEventListener*>(&listener);
160 SysTryReturnVoidResult(NID_UI_CTRL, pLinkEventListener != null, E_INVALID_ARG, "The Invalid listener is given.\n");
162 _LinkEventArg* pLinkEventArg = dynamic_cast <_LinkEventArg*>(const_cast <IEventArg*>(&arg));
163 SysTryReturnVoidResult(NID_UI_CTRL, pLinkEventArg != null, E_INVALID_ARG, "The Invalid Event Argument is given.\n");
165 const String text = pLinkEventArg->GetText();
166 LinkType linkType = pLinkEventArg->GetLinkType();
167 const String linkText = pLinkEventArg->GetLinkText();
169 pLinkEventListener->OnLinkClicked(const_cast <_Control&>(*__pSource), text, linkType, linkText);
171 SetLastResult(E_SUCCESS);
177 _LinkEvent::CreateLinkEventArgN(String text, LinkType linkType, String link)
179 _LinkEventArg* pEventArg = new (std::nothrow) _LinkEventArg(text, linkType, link);
180 SysTryReturn(NID_UI_CTRL, pEventArg, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory shortage.");
185 }}} // Tizen::Ui::Controls