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.
19 #include <FBaseErrors.h>
20 #include <FBaseSysLog.h>
21 #include "FUiCtrl_ISearchBarEventListener.h"
22 #include "FUiCtrl_SearchBarEvent.h"
23 #include "FUiCtrl_SearchBar.h"
26 using namespace Tizen::Base;
27 using namespace Tizen::Base::Runtime;
29 namespace Tizen { namespace Ui { namespace Controls
33 * @class _SearchBarEventArg
34 * @brief This class is used as the argument to action event listener.
36 * This class is used as the argument to searchbar event listener. When an searchbar event is generated
37 * (such as when a searchbar is pressed) the SearchBarEvent calls SearchBarEventListener's OnActionPerformed
38 * with an instance of this class as an argument.
40 * From this class, one can find out, the (event) source object and the action ID.
42 class _OSP_EXPORT_ _SearchBarEventArg
49 * This is the default class constructor.
53 _SearchBarEventArg(_SearchBarEventStatus status);
56 * This is the class destructor.
59 virtual ~_SearchBarEventArg(void);
65 * This method returns the status which the event initially occurred.
67 * @return See the comment above.
69 _SearchBarEventStatus GetStatus(void) const;
77 _SearchBarEventStatus __status;
80 _SearchBarEventArg::_SearchBarEventArg(_SearchBarEventStatus status)
86 _SearchBarEventArg::~_SearchBarEventArg(void)
91 ////////////////////////////////////////////////////////////////////////////////
92 /// _SearchBarEventArg class Access
95 _SearchBarEventArg::GetStatus(void) const
101 ////////////////////////////////////////////////////////////////////////////////
102 /// _SearchBarEvent class Lifecycle
104 _SearchBarEvent::_SearchBarEvent(const _SearchBar& source)
107 result r = _Event::Initialize();
116 _SearchBarEvent::~_SearchBarEvent(void)
122 _SearchBarEvent::CreateInstanceN(const _SearchBar& source)
124 _SearchBarEvent* pSearchBarEvent = new (std::nothrow) _SearchBarEvent(source);
125 SysTryReturn(NID_UI_CTRL, pSearchBarEvent, null, E_OUT_OF_MEMORY,
126 "[E_OUT_OF_MEMORY] Memory allocation failed.");
128 if (IsFailed(GetLastResult()))
133 return pSearchBarEvent;
136 delete pSearchBarEvent;
140 ////////////////////////////////////////////////////////////////////////////////
141 /// _WindowEvent class Accessor
144 _SearchBarEvent::GetSource(void) const
149 ////////////////////////////////////////////////////////////////////////////////
150 /// _SearchBarEvent class Operation
153 _SearchBarEvent::FireImpl(Tizen::Base::Runtime::IEventListener& listener, const Tizen::Base::Runtime::IEventArg& arg)
155 // cast to _IActionEventListener
156 _ISearchBarEventListener* pSearchBarListener = dynamic_cast <_ISearchBarEventListener*>(&listener);
157 SysTryReturnVoidResult(NID_UI_CTRL, pSearchBarListener != null, E_INVALID_ARG,
158 "[E_INVALID_ARG] Invalid argument(s) is used. The searchbar listener instance is null.");
160 // cast to _SearchBarEventArg
161 const _SearchBarEventArg* pArg = dynamic_cast <const _SearchBarEventArg*>(&arg);
162 SysTryReturnVoidResult(NID_UI_CTRL, pArg != null, E_INVALID_ARG,
163 "[E_INVALID_ARG] Invalid argument(s) is used. The argument to searchbar event listener is null.");
165 _SearchBar* pSource = null;
166 pSource = const_cast <_SearchBar*>(__pSource);
167 SysTryReturnVoidResult(NID_UI_CTRL, pSource != null, E_INVALID_ARG,
168 "[E_INVALID_ARG] Invalid argument(s) is used.The searchbar instance is null.");
170 // call cursor change event listener method
171 _SearchBarEventStatus status = pArg->GetStatus();
172 if (status == _SEARCH_BAR_EVENT_MODE_CHANGE)
174 pSearchBarListener->OnSearchBarModeChanged(*pSource, pSource->GetMode());
177 SetLastResult(E_SUCCESS);
183 _SearchBarEvent::CreateSearchBarEventArgN(_SearchBarEventStatus status)
185 _SearchBarEventArg* pEventArg = new (std::nothrow) _SearchBarEventArg(status);
186 SysTryReturn(NID_UI_CTRL, pEventArg, null, E_OUT_OF_MEMORY,
187 "[E_OUT_OF_MEMORY] Memory allocation failed.");
192 }}} // Tizen::Ui::Controls