modify license, permission and remove ^M char
[platform/framework/native/uifw.git] / src / ui / FUi_ControlManager.cpp
old mode 100755 (executable)
new mode 100644 (file)
index b0a94af..1a67121
@@ -2,14 +2,14 @@
 // Open Service Platform
 // Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
 //
-// Licensed under the Flora License, Version 1.0 (the License);
+// Licensed under the Apache License, Version 2.0 (the License);
 // you may not use this file except in compliance with the License.
 // You may obtain a copy of the License at
 //
-//     http://floralicense.org/license/
+//     http://www.apache.org/licenses/LICENSE-2.0/
 //
 // Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an AS IS BASIS,
+// distributed under the License is distributed on an ”AS IS” BASIS,
 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 // See the License for the specific language governing permissions and
 // limitations under the License.
@@ -160,8 +160,6 @@ _ControlManager::Initialize(void)
        SysLog(NID_UI, "The initial value of device orientation is %d.", degree);
 
        __pInstance->__screenRotation = ::Convert(degree);
-
-       elm_init(0, null);
 }
 
 void
@@ -172,8 +170,6 @@ _ControlManager::Release(void)
 
        delete __pInstance;
        __pInstance = null;
-
-       elm_shutdown();
 }
 
 _ControlManager*
@@ -317,8 +313,10 @@ _ControlManager::_ControlManager(void) // [ToDo] exception check.
        , __gestureMaxDuration(0)
        , __touchedWindow(0)
        , __isDefaultFontChanged(false)
+       , __isSystemFontChanged(false)
        , __defaultFontName(L"")
        , __screenDpi(0)
+       , __pClipboardOwner(null)
 {
        result r = GetAppCoordinateSystem(__isCoordinateSystemLogical, __logicalCoordinateSystem, __logicalBaseScreenSize);
        SysTryReturnVoidResult(NID_UI, r == E_SUCCESS, E_SYSTEM, "[E_SYSTEM] System error occurred.");
@@ -560,10 +558,21 @@ _ControlManager::ActivateWindow(_Window& window)
                        pEcoreEvas->RotateWindow(window, ::Convert(__orientationStatus));
                }
 #else
+               // Rotate partial window without Window State Changed Callback.
+
                _EcoreEvas* pEcoreEvas = ::GetEcoreEvasMgr()->GetEcoreEvas();
                if (pEcoreEvas)
                {
+#if !defined(WINDOW_OWNEE_PREFERRED)
+                       window.ChangeLayout(GetOrientation());
+                       pEcoreEvas->RotateWindow(window, ::Convert(__orientationStatus));
+//                     window.SetRotation(::Convert(__orientationStatus));
+//                     window.Invalidate(true);
+
                        pEcoreEvas->SetWindowPreferredRotation(window, ::Convert(__orientationStatus));
+#else
+                       pEcoreEvas->SetWindowPreferredRotation(window, ::Convert(__orientationStatus));
+#endif
                }
 #endif
        }
@@ -574,6 +583,12 @@ _ControlManager::ActivateWindow(_Window& window)
        r = CallOnAttachedToMainTree(window);
        SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
 
+       if (window.IsDimmingEnabled())
+       {
+               r = _DimmingManager::GetInstance()->ShowDimmingLayer(&window);
+               SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
+       }
+
        return E_SUCCESS;
 }
 
@@ -1023,7 +1038,7 @@ _ControlManager::RotateScreen(const _Control& control, _ControlRotation screenRo
                _TouchManager* pTouchManager = _TouchManager::GetInstance();
                if (pTouchManager)
                {
-                       pTouchManager->SetTouchCanceled(true);
+                       pTouchManager->SetTouchCanceled(null);
                }
        }
 }
@@ -1159,12 +1174,86 @@ _ControlManager::GetFocusedControl(void) const
        return __pFocusedControl;
 }
 
+void
+_ControlManager::SetClipboardOwner(_Window* pOwner)
+{
+       __pClipboardOwner = pOwner;
+}
+
+_Window*
+_ControlManager::GetClipboardOwner(void) const
+{
+       if (__pClipboardOwner)
+       {
+               return __pClipboardOwner;
+       }
+
+       return GetCurrentFrame();
+}
+
 _Control*
 _ControlManager::GetTopmostTouchedControl(const Point& point)
 {
        _Control* pControl = null;
        _Window* pTopWindow = null;
 
+       _TouchManager* pTouchManager = _TouchManager::GetInstance();
+       SysTryReturn(NID_UI, pTouchManager, null, E_SYSTEM, "[E_SYSTEM] A system error occurred.");
+
+       _Control* pCapturedControl = pTouchManager->GetCapturedControl();
+
+       if (pCapturedControl)
+       {
+               if (pTouchManager->IsCaptureAllowedOwnerBounds())
+               {
+                       if (pTouchManager->IsCaptureAllowedOutOfBounds())
+                       {
+                               pControl = pCapturedControl;
+                       }
+
+                       _Window * pWindow = dynamic_cast<_Window*>(pCapturedControl);
+                       if (pWindow)
+                       {
+                               _Control* pOwner = pWindow->GetOwner();
+                               if (pOwner)
+                               {
+                                       Tizen::Graphics::Rectangle ownerRc(pOwner->GetAbsoluteBounds());
+                                       if ((point.x >= ownerRc.x) && (point.x <= (ownerRc.x + ownerRc.width)) && (point.y >= ownerRc.y) && (point.y <= (ownerRc.y + ownerRc.height)))
+                                       {
+                                               pControl = pOwner;
+                                       }
+                               }
+                       }
+
+                       Tizen::Graphics::Rectangle rc(pCapturedControl->GetAbsoluteBounds());
+                       if ((point.x >= rc.x) && (point.x <= (rc.x + rc.width)) && (point.y >= rc.y) && (point.y <= (rc.y + rc.height)))
+                       {
+                               pControl = pCapturedControl;
+                       }
+               }
+               else
+               {
+                       if (pTouchManager->IsCaptureAllowedOutOfBounds())
+                       {
+                               pControl = pCapturedControl;
+                       }
+                       else
+                       {
+                               Tizen::Graphics::Rectangle rc(pCapturedControl->GetAbsoluteBounds());
+
+                               if ((point.x < rc.x) || (point.x > (rc.x + rc.width)) || (point.y < rc.y) || (point.y > (rc.y + rc.height)))
+                               {
+                                       pControl = pCapturedControl;
+                               }
+                       }
+               }
+
+               if (pControl != null)
+               {
+                       return pControl;
+               }
+       }
+
        int count = GetWindowCount();
        if (count != 0)
        {
@@ -1376,11 +1465,17 @@ _ControlManager::GetDefaultFontFile(void) const
        return __defaultFontFileName;
 }
 bool
-_ControlManager::IsDefaultFontChanged(void)
+_ControlManager::IsDefaultFontChanged(void) const
 {
        return __isDefaultFontChanged;
 }
 
+bool
+_ControlManager::IsSystemFontChanged(void) const
+{
+       return __isSystemFontChanged;
+}
+
 void
 _ControlManager::SetDefaultFontChangeState(bool isDefaultFontChanged)
 {
@@ -1474,9 +1569,29 @@ _ControlManager::OnSettingChanged(Tizen::Base::String& key)
          if (key == FONT_TYPE || key == LOCALE_COUNTRY || key == LOCALE_LANGUAGE)
        {
                _FontImpl::UpdateDefaultFont(key);
+               __isSystemFontChanged = true;
+               struct _Visitor
+               : public _Control::Visitor
+               {
+                        virtual _Control::VisitType Visit(_Control& control)
+                       {
+                               control.GetFallbackFont();
+                               _IControlDelegate& delegate = control.GetControlDelegate();
+                               delegate.OnFontChanged(control.__pFont);
+                               return _Control::VISIT_DOWNWARD;
+                       }
+               };
+
+               _Visitor visitor;
 
                int count = GetWindowCount();
+               for (int j = 0; j < count; j++)
+               {
+                       _Window* pWindow = GetWindow((count-1) - j);
+                       pWindow->Accept(visitor);
+               }
 
+               __isSystemFontChanged = false;
                for(int index = 0; index < count ; index++)
                {
                        _Window* pWindow = GetWindow(index);