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 * @file FUiCtrl_PublicSearchBarEvent.cpp
20 * @brief This is the implementation for the PublicSearcBarEvent class.
25 #include <FBaseErrors.h>
26 #include <FUiCtrlSearchBar.h>
27 #include <FBaseSysLog.h>
28 #include "FUiCtrl_PublicSearchBarEvent.h"
31 using namespace Tizen::Base;
32 using namespace Tizen::Base::Runtime;
34 namespace Tizen { namespace Ui { namespace Controls
38 * @class _PublicSearchBarEventArg
39 * @brief This class is used as the argument to searchbar event listener.
41 * This class is used as the argument to searchbar event listener. When an searchbar event is generated
42 * (such as when a searchbar is pressed) the SearchBarEvent calls SearchBarEventListener's OnSearchBarModeChanged
43 * with an instance of this class as an argument.
45 * From this class, one can find out, the (event) source object and the action ID.
47 class _OSP_EXPORT_ _PublicSearchBarEventArg
48 : public Tizen::Base::Runtime::IEventArg
49 , public Tizen::Base::Object
54 * This is the default class constructor.
58 _PublicSearchBarEventArg(SearchBarEventStatus status);
61 * This is the class destructor.
64 virtual ~_PublicSearchBarEventArg(void);
70 * This method returns the actionId which the event initially occurred.
72 * @return See the comment above.
74 SearchBarEventStatus GetStatus(void) const;
82 SearchBarEventStatus __status;
85 _PublicSearchBarEventArg::_PublicSearchBarEventArg(SearchBarEventStatus status)
91 _PublicSearchBarEventArg::~_PublicSearchBarEventArg(void)
96 ////////////////////////////////////////////////////////////////////////////////
97 /// _SearchBarEventArg class Access
99 _PublicSearchBarEventArg::GetStatus(void) const
104 ////////////////////////////////////////////////////////////////////////////////
105 /// _PublicSearchBarEvent class Lifecycle
106 _PublicSearchBarEvent::_PublicSearchBarEvent(const SearchBar& source)
109 result r = _Event::Initialize();
118 _PublicSearchBarEvent::~_PublicSearchBarEvent(void)
123 _PublicSearchBarEvent*
124 _PublicSearchBarEvent::CreateInstanceN(const SearchBar& source)
126 _PublicSearchBarEvent* pPublicSearchBarEvent = new (std::nothrow) _PublicSearchBarEvent(source);
127 SysTryReturn(NID_UI_CTRL, pPublicSearchBarEvent, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory shortage.");
129 if (IsFailed(GetLastResult()))
134 return pPublicSearchBarEvent;
137 delete pPublicSearchBarEvent;
141 ////////////////////////////////////////////////////////////////////////////////
142 /// _WindowEvent class Accessor
145 _PublicSearchBarEvent::GetSource(void) const
150 ////////////////////////////////////////////////////////////////////////////////
151 /// _PublicActionEvent class Operation
154 _PublicSearchBarEvent::FireImpl(Tizen::Base::Runtime::IEventListener& listener, const Tizen::Base::Runtime::IEventArg& arg)
157 // cast to IActionEventListener
158 ISearchBarEventListener* pSearchBarListener = dynamic_cast <ISearchBarEventListener*>(&listener);
159 SysTryReturnVoidResult(NID_UI_CTRL, pSearchBarListener != null, E_INVALID_ARG, "[E_INVALID_ARG] The invalid listener was given.");
161 // cast to _PublicSearchBarEventArg
162 const _PublicSearchBarEventArg* pArg = dynamic_cast <const _PublicSearchBarEventArg*>(&arg);
163 SysTryReturnVoidResult(NID_UI_CTRL, pArg != null, E_INVALID_ARG, "[E_INVALID_ARG] The invalid Event Argument was given.");
165 SearchBar* pSource = null;
166 pSource = const_cast <SearchBar*>(__pSource);
167 SysTryReturnVoidResult(NID_UI_CTRL, pSource != null, E_INVALID_ARG, "[E_INVALID_ARG] The invalid Event Argument was given.");
169 // call cursor change event listener method
170 SearchBarEventStatus status = pArg->GetStatus();
171 if (status == SEARCH_BAR_EVENT_MODE_CHANGE)
173 pSearchBarListener->OnSearchBarModeChanged(*pSource, pSource->GetMode());
176 SetLastResult(E_SUCCESS);
182 _PublicSearchBarEvent::CreateSearchBarEventArgN(SearchBarEventStatus status)
184 _PublicSearchBarEventArg* pEventArg = new (std::nothrow) _PublicSearchBarEventArg(status);
185 SysTryReturn(NID_UI_CTRL, pEventArg, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory shortage.");
190 }}} // Tizen::Ui::Controls