add translateKeyEventInfo
authorminkyu kim <imetjade.kim@samsung.com>
Thu, 16 May 2013 10:49:28 +0000 (19:49 +0900)
committerminkyu kim <imetjade.kim@samsung.com>
Thu, 16 May 2013 10:49:28 +0000 (19:49 +0900)
Change-Id: Iba97650b0d2ce1185dcbf00c3e557fa818de025a

src/ui/FUi_ControlImpl.cpp
src/ui/FUi_UiEventManager.cpp
src/ui/FUi_UiKeyEvent.cpp
src/ui/inc/FUi_Control.h
src/ui/inc/FUi_ControlImpl.h
src/ui/inc/FUi_UiEventManager.h
src/ui/inc/FUi_UiKeyEvent.h

index cc7f28c..c5c8c62 100644 (file)
@@ -1682,6 +1682,44 @@ public:
                }
        }
 
+       virtual bool TranslateKeyEventInfo(const _Control& source, _KeyInfo& keyInfo)
+       {
+               SysTryReturn(NID_UI, __impl.__pCoreKeyEvent, false, E_SYSTEM, "[E_SYSTEM] System error occurred.");
+
+               bool isFiltered = false;
+
+               if (__impl.__pPublicPropagatedKeyEventListener != null)
+               {
+                       _ControlImpl* pControlImpl = static_cast<_ControlImpl*>(source.GetUserData());
+                       SysTryReturn(NID_UI, pControlImpl, false, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] pControlImpl == null.");
+
+                       Control& control = static_cast<Control&>(pControlImpl->GetPublic());
+
+                       KeyEventInfo* pKeyEventInfo = new (std::nothrow) KeyEventInfo(static_cast<KeyCode>(keyInfo.GetKeyCode()),
+                               static_cast<KeyModifier>(keyInfo.GetKeyModifier()));
+
+                       isFiltered = __impl.__pPublicPropagatedKeyEventListener->TranslateKeyEventInfo(control, *pKeyEventInfo);
+                       if (isFiltered)
+                       {
+                               keyInfo.SetKeyCode(static_cast<_KeyCode>(pKeyEventInfo->GetKeyCode()));
+                               keyInfo.SetKeyModifier(static_cast<_KeyModifier>(pKeyEventInfo->GetKeyModifier()));
+                               return true;
+                       }
+               }
+
+               // 3. Impl
+               isFiltered = __impl.TranslateKeyEventInfo(__impl, keyInfo);
+               if (isFiltered)
+               {
+                       return true;
+               }
+
+               // 4. Core
+               isFiltered = __core.TranslateKeyEventInfo(source, keyInfo);
+
+               return isFiltered;
+       }
+
        virtual bool OnKeyPressed(const _Control& source, const _KeyInfo& keyInfo)
        {
                SysTryReturn(NID_UI, __impl.__pCoreKeyEvent, false, E_SYSTEM, "[E_SYSTEM] System error occurred.");
@@ -2712,6 +2750,12 @@ _ControlImpl::OnTouchCancelHandled(const _Control& control)
 }
 
 bool
+_ControlImpl::TranslateKeyEventInfo(const _ControlImpl& source, _KeyInfo& keyInfo)
+{
+       return false;
+}
+
+bool
 _ControlImpl::OnKeyPressed(const _ControlImpl& source, const _KeyInfo& keyInfo)
 {
        return false;
index 0becc63..3eea95c 100644 (file)
@@ -429,6 +429,11 @@ _UiEventManager::ProcessEvent(const _UiEvent& event, bool& isFiltered)
 
                        if (r == E_SUCCESS)
                        {
+                               if (event.GetEventType() == _UI_EVENT_KEY)
+                               {
+                                       CallTranslateKeyEventInfo(event,isFiltered);
+                               }
+
                                ProcessTunnelingEvent(tunnelingPath, event, isFiltered);
 
                                if (event.GetEventType() == _UI_EVENT_TOUCH)
@@ -464,6 +469,28 @@ _UiEventManager::ProcessEvent(const _UiEvent& event, bool& isFiltered)
 }
 
 result
+_UiEventManager::CallTranslateKeyEventInfo(const _UiEvent& event, bool& isFiltered)
+{
+       _ControlManager* pControlManager = _ControlManager::GetInstance();
+       SysTryReturn(NID_UI, pControlManager, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] System error occurred.");
+
+       _Control* pTarget = pControlManager->GetObject(event.GetDestination());
+       SysTryReturn(NID_UI, pTarget, E_OBJ_NOT_FOUND, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] pTarget is null.");
+
+       _UiKeyEvent& keyEvent = static_cast<_UiKeyEvent&>(const_cast<_UiEvent&>(event));
+
+       _KeyInfo* pKeyInfo = keyEvent.GetKeyInfo();
+       SysTryReturn(NID_UI, pKeyInfo, E_OBJ_NOT_FOUND, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] pTarget is null.");
+
+       _IPropagatedKeyEventListener* pKeyEventListener = pTarget->GetPropagatedKeyEventListener();
+       SysTryReturn(NID_UI, pKeyEventListener, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] System error occurred.");
+
+       pKeyEventListener->TranslateKeyEventInfo(*pTarget, *pKeyInfo);
+
+       return E_SUCCESS;
+}
+
+result
 _UiEventManager::ProcessGlobalGesture(const _UiEvent& event, bool& isFiltered)
 {
        if (event.GetEventType() != _UI_EVENT_TOUCH)
index f63b247..ec1a0e5 100644 (file)
@@ -142,10 +142,10 @@ _UiKeyEvent::operator =(const _UiKeyEvent& rhs)
        return *this;
 }
 
-const _KeyInfo*
+_KeyInfo*
 _UiKeyEvent::GetKeyInfo(void) const
 {
-       return &__keyInfo;
+       return const_cast<_KeyInfo*>(&__keyInfo);
 }
 
 _UiKeyEvent*
index 90d72ec..e58a8db 100644 (file)
@@ -144,6 +144,7 @@ public:
        virtual ~_IPropagatedKeyEventListener(void){}
        virtual bool OnPreviewKeyPressed(const _Control& source, const _KeyInfo& keyInfo) = 0;
        virtual bool OnPreviewKeyReleased(const _Control& source, const _KeyInfo& keyInfo) = 0;
+       virtual bool TranslateKeyEventInfo(const _Control& source, _KeyInfo& keyInfo) = 0;
 };
 
 class _OSP_EXPORT_ _Control // Temp: export only for test
index adee9ce..f09787a 100644 (file)
@@ -174,6 +174,7 @@ public:
        virtual void OnFocusableStateChanged(bool focusalbeState);
 
 // Event Callbacks
+       virtual bool TranslateKeyEventInfo(const _ControlImpl& source, _KeyInfo& keyInfo);
        virtual bool OnKeyPressed(const _ControlImpl& source, const _KeyInfo& keyInfo);
        virtual bool OnKeyReleased(const _ControlImpl& source, const _KeyInfo& keyInfo);
 
index ca19229..2de8f25 100644 (file)
@@ -107,6 +107,7 @@ private:
        _UiObjectHandle GetTarget(void) const;
        _UiObjectHandle GetTarget(int x, int y) const;
        void RemoveAllEventListenerList(Tizen::Base::Collection::HashMapT<_UiEventType, Tizen::Base::Collection::LinkedListT<_IUiEventListener*>*>* pMap);
+       result CallTranslateKeyEventInfo(const _UiEvent& event, bool& isFiltered);
        _UiEventManager(void);
        ~_UiEventManager(void);
        _UiEventManager(const _UiEventManager& rhs);
index 7b743fc..ee41341 100644 (file)
@@ -922,7 +922,7 @@ public:
        _UiKeyEvent& operator =(const _UiKeyEvent& rhs);
 
 public:
-       const _KeyInfo* GetKeyInfo(void) const;
+       _KeyInfo* GetKeyInfo(void) const;
 
 private:
        void SetKeyState(KeyState keyState);