Merge "modify Klockwork bug" into tizen_2.2
[platform/framework/native/uifw.git] / src / ui / controls / FUiCtrl_EditDatePresenter.cpp
index f149156..fc4e805 100644 (file)
@@ -290,6 +290,9 @@ _EditDatePresenter::InitializeTextObject(void)
        pSimpleText = new (std::nothrow)TextSimple(null, 0, TEXT_ELEMENT_SOURCE_TYPE_EXTERNAL);
        SysTryReturn(NID_UI_CTRL, (pSimpleText != null), E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
 
+       pSimpleText->SetTextShadowEnabled(true);
+       pSimpleText->SetTextShadowOffset(FloatPoint(0.0f, -1.0f));
+
        __textObject.AppendElement(*pSimpleText);
 
        __textObject.SetFont(__pFont, 0, __textObject.GetTextLength());
@@ -569,8 +572,9 @@ _EditDatePresenter::DrawFocus(void)
 {
        FloatRectangle bounds(0.0f, 0.0f, 0.0f, 0.0f);
 
+       Canvas* pContentCanvas = null;
        Canvas* pCanvas = __pEditDate->GetCanvasN();
-       SysTryReturnResult(NID_UI_CTRL, (pCanvas != null), E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Unable to create canvas.");
+       SysTryReturnResult(NID_UI_CTRL, (pCanvas != null), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
 
        if (__focusId == DATETIME_ID_DAY)
        {
@@ -594,9 +598,16 @@ _EditDatePresenter::DrawFocus(void)
        }
        else
        {
-               r = pCanvas->DrawBitmap(bounds, *__pContentBgHighlightedColorReplacementBitmap);
+               pContentCanvas = __pEditDate->GetCanvasN(bounds);
+               SysTryCatch(NID_UI_CTRL, (pContentCanvas != null), , GetLastResult(), "[%s]Propagating.", GetErrorMessage(GetLastResult()));
+
+               bounds.x = (bounds.width - __pContentBgHighlightedColorReplacementBitmap->GetWidthF()) / 2;
+               bounds.y = (bounds.height - __pContentBgHighlightedColorReplacementBitmap->GetHeightF()) / 2;
+
+               r = pContentCanvas->DrawBitmap(FloatPoint(bounds.x, bounds.y), *__pContentBgHighlightedColorReplacementBitmap);
                SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r));
 
+               delete pContentCanvas;
        }
 
        delete pCanvas;
@@ -604,6 +615,7 @@ _EditDatePresenter::DrawFocus(void)
 
 CATCH:
        delete pCanvas;
+       delete pContentCanvas;
        return r;
 }
 
@@ -731,6 +743,9 @@ _EditDatePresenter::DrawText(Canvas& canvas, const FloatRectangle& bounds, const
        pSimpleText = new (std::nothrow)TextSimple((const_cast <wchar_t*>(text.GetPointer())), text.GetLength(), TEXT_ELEMENT_SOURCE_TYPE_EXTERNAL);
        SysTryReturn(NID_UI_CTRL, (pSimpleText != null), E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
 
+       pSimpleText->SetTextShadowEnabled(true);
+       pSimpleText->SetTextShadowOffset(FloatPoint(0.0f, -1.0f));
+
        __textObject.RemoveAll();
        if (__isFocused && __focusId == boxId)
        {
@@ -777,7 +792,7 @@ _EditDatePresenter::DrawContentBitmap(Canvas& canvas, const FloatRectangle& boun
                pEffectBitmap = __pContentBgEffectPressedBitmap;
        }
 
-       r = DrawResourceBitmap(canvas, bounds, pReplacementBitmap);
+       r = DrawResourceBitmap(canvas, bounds, pReplacementBitmap, isCustomBitmap);
        SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r));
 
        if (!isCustomBitmap)
@@ -790,7 +805,7 @@ _EditDatePresenter::DrawContentBitmap(Canvas& canvas, const FloatRectangle& boun
 }
 
 result
-_EditDatePresenter::DrawResourceBitmap(Canvas& canvas, const FloatRectangle& bounds, Bitmap* pBitmap)
+_EditDatePresenter::DrawResourceBitmap(Canvas& canvas, const FloatRectangle& bounds, Bitmap* pBitmap, bool isCustomBitmap)
 {
        result r = E_SUCCESS;
 
@@ -806,7 +821,23 @@ _EditDatePresenter::DrawResourceBitmap(Canvas& canvas, const FloatRectangle& bou
        }
        else
        {
-               r = canvas.DrawBitmap(bounds, *pBitmap);
+               if (isCustomBitmap)
+               {
+                       Canvas *pContentCanvas = __pEditDate->GetCanvasN(bounds);
+                       SysTryReturnResult(NID_UI_CTRL, (pContentCanvas != null), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+                       FloatPoint position;
+
+                       position.x = (bounds.width - pBitmap->GetWidthF()) / 2;
+                       position.y = (bounds.height - pBitmap->GetHeightF()) / 2;
+                       r = pContentCanvas->DrawBitmap(position, *pBitmap);
+                       delete pContentCanvas;
+               }
+               else
+               {
+                       r = canvas.DrawBitmap(FloatPoint(bounds.x, bounds.y), *pBitmap);
+               }
+
                SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r));
        }
 
@@ -914,7 +945,11 @@ _EditDatePresenter::SetFocusedElement(void)
        if (__isEnterKeyPressed)
        {
                __isEnterKeyPressed = false;
-               __isFocused = true;
+
+               if (__pEditDate->IsFocusModeStateEnabled())
+               {
+                       __isFocused = true;
+               }
        }
        int localeDateFormat =  dateTimeUtils.GetLocaleDateFormat();
        if (__focusId == DATETIME_ID_NONE)
@@ -955,6 +990,7 @@ void
 _EditDatePresenter::OnFocusModeStateChanged(void)
 {
        __isFocused = false;
+       __isEnterKeyPressed = false;
        __focusId = DATETIME_ID_NONE;
        __pEditDate->Invalidate();
        return;
@@ -1083,7 +1119,7 @@ _EditDatePresenter::OnKeyPressed(const _Control& source, const _KeyInfo& keyInfo
 }
 
 bool
-_EditDatePresenter::OnKeyReleased(const _Control& source, const _KeyInfo& keyInfo)
+_EditDatePresenter::OnKeyReleased(const _Control& source, const _KeyCode& keyCode)
 {
        if (!__isFocused)
        {
@@ -1103,7 +1139,6 @@ _EditDatePresenter::OnKeyReleased(const _Control& source, const _KeyInfo& keyInf
        int displayValue = -1;
 
        _DateTimeId boxId = DATETIME_ID_NONE;
-       _KeyCode keyCode = keyInfo.GetKeyCode();
 
        switch (keyCode)
        {
@@ -1482,8 +1517,8 @@ _EditDatePresenter::Animate(void)
        pCanvas->Clear();
        rect.x = 0.0f;
        rect.y = 0.0f;
-       r = DrawResourceBitmap(*pCanvas, rect, __pContentBgPressedColorReplacementBitmap);
        isCustomBitmap = IS_CUSTOM_BITMAP(EDITTIME::CONTENT_BG_PRESSED);
+       r = DrawResourceBitmap(*pCanvas, rect, __pContentBgPressedColorReplacementBitmap, isCustomBitmap);
 
        if (!isCustomBitmap)
        {
@@ -1530,6 +1565,9 @@ _EditDatePresenter::Animate(void)
        pOldSimpleText = new (std::nothrow)TextSimple((const_cast <wchar_t*>(__lastSelectedValue.GetPointer())), __lastSelectedValue.GetLength(), TEXT_ELEMENT_SOURCE_TYPE_EXTERNAL);
        SysTryCatch(NID_UI_CTRL, (pOldSimpleText != null), , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
 
+       pOldSimpleText->SetTextShadowEnabled(true);
+       pOldSimpleText->SetTextShadowOffset(FloatPoint(0.0f, -1.0f));
+
        pCanvas = pOldVisualElement->GetCanvasN();
        r = GetLastResult();
        SysTryCatch(NID_UI_CTRL, (pCanvas != null), , r, "[%s] Propagating.", GetErrorMessage(r));
@@ -1554,6 +1592,9 @@ _EditDatePresenter::Animate(void)
        pNewSimpleText = new (std::nothrow)TextSimple((const_cast <wchar_t*>(newValue.GetPointer())), newValue.GetLength(), TEXT_ELEMENT_SOURCE_TYPE_EXTERNAL);
        SysTryCatch(NID_UI_CTRL, (pNewSimpleText != null), , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
 
+       pNewSimpleText->SetTextShadowEnabled(true);
+       pNewSimpleText->SetTextShadowOffset(FloatPoint(0.0f, -1.0f));
+
        pCanvas = pNewVisualElement->GetCanvasN();
        r = GetLastResult();
        SysTryCatch(NID_UI_CTRL, (pCanvas != null), , r, "[%s] Propagating.", GetErrorMessage(r));