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.
18 * @file FUi_UiFocusEvent.cpp
19 * @brief This is the implementation file for _UiFocusEvent class.
22 #include <FBaseSysLog.h>
23 #include <FBaseResult.h>
24 #include "FUi_UiFocusEvent.h"
25 #include "FUi_IFocusEventListener.h"
26 #include "FUi_Control.h"
28 namespace Tizen { namespace Ui
31 _UiFocusEvent::_UiFocusEvent(const _UiObjectHandle& destination, FocusStatus focusState, _UiEventRouteType routeType, const _UiObjectHandle& source)
32 : _UiEvent(destination, source, routeType)
33 , __focusState(focusState)
37 _UiFocusEvent::~_UiFocusEvent(void)
41 _UiFocusEvent::_UiFocusEvent(const _UiFocusEvent& rhs)
43 , __focusState(rhs.__focusState)
48 _UiFocusEvent::operator =(const _UiFocusEvent& rhs)
50 _UiEvent::operator =(rhs);
54 __focusState = rhs.__focusState;
61 _UiFocusEvent::GetFocusState(void) const
67 _UiFocusEvent::CloneN(void) const
69 return new (std::nothrow) _UiFocusEvent(*this);
73 _UiFocusEvent::GetEventType(void) const
75 return _UI_EVENT_FOCUS;
79 _UiFocusEvent::OnPreviewEventProcessing(const _Control& control, bool& isFiltered)
85 _UiFocusEvent::OnEventProcessing(const _Control& control, bool& isFiltered)
87 _IFocusEventListener* pFocusListener = control.GetEventListener<_UI_EVENT_FOCUS, _IFocusEventListener*>();
88 SysTryReturn(NID_UI, pFocusListener, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] System error occurred.");
90 return FireListener(pFocusListener, isFiltered);
94 _UiFocusEvent::OnListenerProcessing(const _IUiEventListener& listener, bool& isFiltered)
101 _IFocusEventListener* pFocusListener = dynamic_cast <_IFocusEventListener*>(const_cast <_IUiEventListener*>(&listener));
102 SysTryReturn(NID_UI, pFocusListener, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] System error occurred.");
104 return FireListener(pFocusListener, isFiltered);
108 _UiFocusEvent::FireListener(const _IFocusEventListener* pListener, bool& isFiltered)
110 SysTryReturn(NID_UI, pListener, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid.");
112 result r = E_SUCCESS;
114 _IFocusEventListener* pFocusListener = const_cast <_IFocusEventListener*>(pListener);
115 SysTryReturn(NID_UI, pFocusListener, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] System error occurred.");
117 const _Control* pTarget = GetControl(GetDestination());
118 SysTryReturn(NID_UI, pTarget, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] System error occurred.");
120 // call a listener method by the key state
121 switch (GetFocusState())
124 isFiltered = pFocusListener->OnFocusGained(*pTarget);
128 isFiltered = pFocusListener->OnFocusLost(*pTarget);
132 //SysLogI(NID_UI, "unable to determine the key event type.");