applied Magnifier
authorChulheon <ch.jeong47@samsung.com>
Tue, 4 Jun 2013 12:25:08 +0000 (21:25 +0900)
committerChulheon <ch.jeong47@samsung.com>
Tue, 4 Jun 2013 12:25:08 +0000 (21:25 +0900)
Change-Id: I9b6d7ddf3b0603134c9f7bdbe923080eb2911147

src/ui/controls/FUiCtrl_EditCopyPasteManager.cpp
src/ui/controls/FUiCtrl_EditPresenter.cpp
src/ui/inc/FUiCtrl_EditCopyPasteManager.h
src/ui/inc/FUiCtrl_EditPresenter.h

index 0ccfd14..85e1d05 100644 (file)
@@ -37,7 +37,7 @@
 #include "FUi_Math.h"
 #include "FUi_Window.h"
 
-#define EDIT_COPY_PASTE_MAGNIFIER 0
+#define EDIT_COPY_PASTE_MAGNIFIER 1
 
 using namespace Tizen::Ui;
 using namespace Tizen::App;
@@ -70,6 +70,9 @@ public:
        void MoveMagnifier(const FloatPoint& point, int handlerCursorPos);
        Bitmap* GetMagnifierBitmap(void) const;
        virtual result OnAttachedToMainTree(void);
+       result OnBoundsChanging(const FloatRectangle& bounds);
+       result OnBoundsChanging(const Rectangle& bounds);
+       void SetRowColumnIndex(int rowIndex, int columnIndex);
 
 private:
        _EditCopyPasteMagnifier(const _EditCopyPasteMagnifier& value);
@@ -80,6 +83,9 @@ private:
        Bitmap* __pMagnifierBitmap;
        _VisualElement* __pRoot;
        int __handlerCursorPos;
+       FloatRectangle __windowBounds;
+       int __rowIndex;
+       int __columnIndex;
 };
 
 _EditCopyPasteMagnifier::_EditCopyPasteMagnifier(_EditCopyPasteManager* pCopyPasteManager, int handlerCursorPos)
@@ -87,6 +93,9 @@ _EditCopyPasteMagnifier::_EditCopyPasteMagnifier(_EditCopyPasteManager* pCopyPas
        , __pMagnifierBitmap(null)
        , __pRoot(null)
        , __handlerCursorPos(handlerCursorPos)
+       , __windowBounds(0.0f, 0.0f, 0.0f, 0.0f)
+       , __rowIndex(-1)
+       , __columnIndex(-1)
 {
        AcquireHandle();
        __pRoot = GetVisualElement();
@@ -193,7 +202,7 @@ _EditCopyPasteMagnifier::OnDraw(void)
        _EcoreEvas* pEcoreEvas = GetEcoreEvasMgr()->GetEcoreEvas();
        SysTryReturnVoidResult(NID_UI_CTRL, pEcoreEvas, E_INVALID_STATE, "pEcoreEvas is null.");
 
-       pEcoreEvas->SetWindowBounds(*GetRootWindow(), GetBoundsF());
+       pEcoreEvas->SetWindowBounds(*GetRootWindow(), __windowBounds);
 
        Canvas* pCanvas = GetCanvasN();
        if (pCanvas == null)
@@ -220,24 +229,22 @@ _EditCopyPasteMagnifier::OnDraw(void)
 void
 _EditCopyPasteMagnifier::CaptureTextArea(Canvas& canvas)
 {
+       result r = E_SUCCESS;
+       float captureWidth = 0.0f;
+       float captureHeight = 0.0f;
+       float capturePosX = 0.0f;
+       float capturePosY = 0.0f;
+       float adjustPoxX = 0.0f;
+       float adjustPoxY = 0.0f;
+       FloatRectangle cursorBounds(0.0f, 0.0f, 0.0f, 0.0f);
+       FloatRectangle captureBounds(0.0f, 0.0f, 0.0f, 0.0f);
+
        _Edit* pEdit = __pCopyPasteManager->GetEdit();
        SysTryReturnVoidResult(NID_UI_CTRL, pEdit, E_INVALID_STATE, "pEdit is null.");
 
        _EditPresenter* pEditPresenter = pEdit->GetPresenter();
        SysTryReturnVoidResult(NID_UI_CTRL, pEditPresenter, E_INVALID_STATE, "pEditPresenter is null.");
 
-       _VisualElement* pTextVisualElement = pEditPresenter->GetTextVisualElement();
-       SysTryReturnVoidResult(NID_UI_CTRL, pTextVisualElement, E_INVALID_STATE, "pTextVisualElement is null.");
-
-       Canvas* pTextCanvas = pTextVisualElement->GetCanvasN();
-       SysTryReturnVoidResult(NID_UI_CTRL, pTextCanvas, E_INVALID_STATE, "pTextCanvas is null.");
-
-       float captureWidth = 0.0f;
-       float captureHeight = 0.0f;
-       float capturePosX = 0.0f;
-       float capturePosY = 0.0f;
-       FloatRectangle cursorBounds(0.0f, 0.0f, 0.0f, 0.0f);
-       FloatRectangle magnifierBounds = GetBoundsF();
        pEditPresenter->CalculateCursorBounds(pEditPresenter->GetTextBoundsF(), cursorBounds, __handlerCursorPos);
 
        GET_SHAPE_CONFIG(EDIT::COPYPASTE_MAGNIFIER_CAPTURE_WIDTH, pEdit->GetOrientation(), captureWidth);
@@ -245,58 +252,131 @@ _EditCopyPasteMagnifier::CaptureTextArea(Canvas& canvas)
        GET_SHAPE_CONFIG(EDIT::COPYPASTE_MAGNIFIER_CAPTURE_POSITION_X, pEdit->GetOrientation(), capturePosX);
        GET_SHAPE_CONFIG(EDIT::COPYPASTE_MAGNIFIER_CAPTURE_POSITION_Y, pEdit->GetOrientation(), capturePosY);
 
-       FloatRectangle textVisualElementBounds = pTextVisualElement->GetBounds();
-       FloatRectangle captureBounds(0.0f, 0.0f, 0.0f, 0.0f);
-       if (cursorBounds.x >= captureWidth/2.0f)
+       FloatRectangle textObjectBounds = pEditPresenter->GetTextBoundsF();
+       captureBounds.x = cursorBounds.x - captureWidth/2.0f;
+       captureBounds.y = cursorBounds.y + cursorBounds.height/2 - captureHeight/2;
+       captureBounds.width = captureWidth;
+       captureBounds.height = captureHeight;
+       captureBounds = textObjectBounds.GetIntersection(captureBounds);
+
+       if (captureBounds.width < captureWidth && captureBounds.x < textObjectBounds.x + textObjectBounds.width - captureBounds.width)
        {
-               captureBounds.x = cursorBounds.x - captureWidth/2.0f;
+               adjustPoxX = captureWidth - captureBounds.width;
        }
-       else
+       if (captureBounds.height < captureHeight && captureBounds.y < captureHeight)
        {
-               captureBounds.x = 0.0f;
+               adjustPoxY = captureHeight - captureBounds.height;
        }
 
-       if (cursorBounds.x <=  textVisualElementBounds.width - captureWidth/2.0f)
+       Bitmap* pOriginalBitmp = pEdit->GetCapturedBitmapN(true);
+       SysTryReturnVoidResult(NID_UI_CTRL, pOriginalBitmp, E_INVALID_STATE, "pOriginalBitmp is null.");
+
+       Bitmap bitmap;
+       r = bitmap.Construct(captureBounds);
+       SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+
+       r = bitmap.Merge(FloatPoint(0.0f, 0.0f), *pOriginalBitmp, captureBounds);
+       SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+
+       r = bitmap.SetScalingQuality(BITMAP_SCALING_QUALITY_HIGH);
+       SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+
+       r = bitmap.Scale(FloatDimension(bitmap.GetWidth()*1.5f, bitmap.GetHeight()*1.5f));
+       SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+
+       canvas.DrawBitmap(FloatPoint(capturePosX + adjustPoxX*1.5f, capturePosY + adjustPoxY*1.5f), bitmap);
+
+       delete pOriginalBitmp;
+
+       return;
+
+CATCH:
+       delete pOriginalBitmp;
+
+       return;
+/*
+       result r = E_SUCCESS;
+       float captureWidth = 0.0f;
+       float captureHeight = 0.0f;
+       float capturePosX = 0.0f;
+       float capturePosY = 0.0f;
+       float adjustPoxX = 0.0f;
+       float adjustPoxY = 0.0f;
+       FloatRectangle cursorBounds(0.0f, 0.0f, 0.0f, 0.0f);
+       FloatRectangle captureBounds(0.0f, 0.0f, 0.0f, 0.0f);
+
+       _Edit* pEdit = __pCopyPasteManager->GetEdit();
+       SysTryReturnVoidResult(NID_UI_CTRL, pEdit, E_INVALID_STATE, "pEdit is null.");
+
+       _VisualElement* pEditVisualElement = pEdit->GetVisualElement();
+       SysTryReturnVoidResult(NID_UI_CTRL, pEditVisualElement, E_INVALID_STATE, "pEditVisualElement is null.");
+
+       _EditPresenter* pEditPresenter = pEdit->GetPresenter();
+       SysTryReturnVoidResult(NID_UI_CTRL, pEditPresenter, E_INVALID_STATE, "pEditPresenter is null.");
+
+       if (__rowIndex == -1 && __columnIndex == -1)
        {
-               if (captureBounds.x != 0.0f)
-               {
-                       captureBounds.width = captureWidth;
-               }
-               else
-               {
-                       captureBounds.width = captureWidth/2.0f + cursorBounds.x;
-               }
+               pEditPresenter->CalculateCursorBounds(pEditPresenter->GetTextBoundsF(), cursorBounds,__handlerCursorPos);
        }
        else
        {
-               captureBounds.width = textVisualElementBounds.width - captureBounds.x;
+               pEditPresenter->CalculateCursorBounds(pEditPresenter->GetTextBoundsF(), cursorBounds, __rowIndex, __columnIndex);
        }
 
+       GET_SHAPE_CONFIG(EDIT::COPYPASTE_MAGNIFIER_CAPTURE_WIDTH, pEdit->GetOrientation(), captureWidth);
+       GET_SHAPE_CONFIG(EDIT::COPYPASTE_MAGNIFIER_CAPTURE_HEIGHT, pEdit->GetOrientation(), captureHeight);
+       GET_SHAPE_CONFIG(EDIT::COPYPASTE_MAGNIFIER_CAPTURE_POSITION_X, pEdit->GetOrientation(), capturePosX);
+       GET_SHAPE_CONFIG(EDIT::COPYPASTE_MAGNIFIER_CAPTURE_POSITION_Y, pEdit->GetOrientation(), capturePosY);
+
+       FloatRectangle textObjectBounds = pEditPresenter->GetTextBoundsF();
+       captureBounds.x = cursorBounds.x - captureWidth/2.0f;
        captureBounds.y = cursorBounds.y + cursorBounds.height/2 - captureHeight/2;
-       if (cursorBounds.y <=  textVisualElementBounds.height - captureHeight)
+       captureBounds.width = captureWidth;
+       captureBounds.height = captureHeight;
+       captureBounds = textObjectBounds.GetIntersection(captureBounds);
+
+       if (captureBounds.width < captureWidth && captureBounds.x < textObjectBounds.x + textObjectBounds.width - captureBounds.width)
        {
-               captureBounds.height = captureHeight;
+               adjustPoxX = captureWidth - captureBounds.width;
        }
-       else
+       if (captureBounds.height < captureHeight && captureBounds.y < captureHeight)
        {
-               captureBounds.height = textVisualElementBounds.height - captureBounds.y;
+               adjustPoxY = captureHeight - captureBounds.height;
        }
 
-       Bitmap bitmap;
-       bitmap.Construct(*pTextCanvas, captureBounds);
-       bitmap.Scale(FloatDimension(bitmap.GetWidth()*1.5f, bitmap.GetHeight()*1.5f));
+       Bitmap* pOriginalBitmp = null;
+       Canvas* pCanvas = new (std::nothrow) Canvas;
+       SysTryReturnVoidResult(NID_UI_CTRL, pCanvas, E_OUT_OF_MEMORY, "pCanvas is null.");
 
-       if (captureBounds.x != 0.0f)
-       {
-               canvas.DrawBitmap(FloatPoint(capturePosX, capturePosY), bitmap);
-       }
-       else
-       {
+       r = pCanvas->Construct(FloatRectangle(0, 0, captureBounds.width, captureBounds.height));
+       SysTryCatch(NID_UI, r == E_SUCCESS, , r, "[%s] Propagated.", GetErrorMessage(r));
 
-               canvas.DrawBitmap(FloatPoint(capturePosX + (captureWidth/2.0f -cursorBounds.x)*1.5f, capturePosY), bitmap);
-       }
+       pEditVisualElement->Capture(*pCanvas, FloatRectangle(0, 0, captureBounds.width, captureBounds.height), captureBounds, true);
+
+       pOriginalBitmp = new (std::nothrow) Bitmap;
+       SysTryCatch(NID_UI, pOriginalBitmp != null, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory shortage.");
+       
+       r = pOriginalBitmp->Construct(*pCanvas, FloatRectangle(0, 0, captureBounds.width, captureBounds.height));
+
+       r = pOriginalBitmp->SetScalingQuality(BITMAP_SCALING_QUALITY_HIGH);
+       SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
 
-       delete pTextCanvas;
+       r = pOriginalBitmp->Scale(FloatDimension(captureBounds.width*1.5f, captureBounds.height*1.5f));
+       SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+
+       canvas.DrawBitmap(FloatPoint(capturePosX + adjustPoxX*1.5f, capturePosY + adjustPoxY*1.5f), *pOriginalBitmp);
+
+       delete pCanvas;
+       delete pOriginalBitmp;
+
+       return;
+       
+CATCH:
+       delete pCanvas;
+       delete pOriginalBitmp;
+
+       return;
+*/
 }
 
 void
@@ -308,6 +388,31 @@ _EditCopyPasteMagnifier::MoveMagnifier(const FloatPoint& point, int handlerCurso
        Invalidate();
 }
 
+result
+_EditCopyPasteMagnifier::OnBoundsChanging(const FloatRectangle& bounds)
+{
+       result r = E_SUCCESS;
+
+       __windowBounds = bounds;
+
+       return r;
+}
+
+result
+_EditCopyPasteMagnifier::OnBoundsChanging(const Rectangle& bounds)
+{
+       result r = E_SUCCESS;
+
+       return r;
+}
+
+void
+_EditCopyPasteMagnifier::SetRowColumnIndex(int rowIndex, int columnIndex)
+{
+       __rowIndex = rowIndex;
+       __columnIndex = columnIndex;
+}
+
 /**
 * @class       _EditCopyPasteHandler
 * @brief       This class defines the common behavior for the %_EditCopyPasteHandler.
@@ -348,6 +453,7 @@ public:
        static _EditCopyPasteHandler* CreateInstanceN(const Point& point, int handlerCursorPos, _EditCopyPasteManager* pCopyPasteManager, bool singleHandler, bool leftHandler = true);
        static _EditCopyPasteHandler* CreateInstanceN(const FloatPoint& point, int handlerCursorPos, _EditCopyPasteManager* pCopyPasteManager, bool singleHandler, bool leftHandler = true);
        int GetHandlerCursorPosition(void) const;
+       void GetHandlerRowColumnIndex(int& rowIndex, int& columnIndex) const;
        void SetHandlerCursorPosition(int handlerCursorPos);
        void AdjustBounds(void);
        void CheckReverseStatus(void);
@@ -356,6 +462,7 @@ public:
        bool CreateCopyPasteMagnifier(void);
        void DestroyCopyPasteMagnifier(void);
        void MoveCopyPasteMagnifier(void);
+       void UpdateCopyPasteMagnifier(void);
 
 // virtual function
        virtual void OnDraw(void);
@@ -391,6 +498,8 @@ private:
        bool __singleHandler;
        _EditCopyPasteMagnifier* __pCopyPasteMagnifier;
        bool __isTouchMoving;
+       int __rowIndex;
+       int __columnIndex;
 }; // _EditCopyPasteHandler
 
 Bitmap*
@@ -411,8 +520,14 @@ _EditCopyPasteHandler::CreateCopyPasteMagnifier(void)
                SysTryReturn(NID_UI_CTRL, pEditPresenter, false, E_INVALID_STATE, "[E_INVALID_STATE] pEditPresenter is null.\n");
 
                FloatRectangle cursorBounds(0.0f, 0.0f, 0.0f, 0.0f);
-               pEdit->CalculateAbsoluteCursorBounds(__handlerCursorPos, cursorBounds);
-
+               if (__rowIndex == -1 && __columnIndex == -1)
+               {
+                       pEditPresenter->CalculateAbsoluteCursorBounds(__handlerCursorPos, cursorBounds);
+               }
+               else
+               {
+                       pEditPresenter->CalculateAbsoluteCursorBounds(__rowIndex, __columnIndex, cursorBounds);                 
+               }
                __pCopyPasteMagnifier = _EditCopyPasteMagnifier::CreateInstanceN(FloatPoint(cursorBounds.x, cursorBounds.y), __handlerCursorPos, __pCopyPasteManager);
                SysTryReturn(NID_UI_CTRL, pEdit, false, E_INVALID_STATE, "[E_INVALID_STATE] pEdit is null.\n");
        }
@@ -442,13 +557,29 @@ _EditCopyPasteHandler::MoveCopyPasteMagnifier(void)
                SysTryReturnVoidResult(NID_UI_CTRL, pEditPresenter, E_INVALID_STATE, "pEditPresenter is null.");
 
                FloatRectangle cursorBounds(0.0f, 0.0f, 0.0f, 0.0f);
-               pEdit->CalculateAbsoluteCursorBounds(__handlerCursorPos, cursorBounds);
-
+               if (__rowIndex == -1 && __columnIndex == -1)
+               {
+                       pEditPresenter->CalculateAbsoluteCursorBounds(__handlerCursorPos, cursorBounds);
+               }
+               else
+               {
+                       pEditPresenter->CalculateAbsoluteCursorBounds(__rowIndex, __columnIndex, cursorBounds);
+                       __pCopyPasteMagnifier->SetRowColumnIndex(__rowIndex, __columnIndex);                    
+               }
                __pCopyPasteMagnifier->MoveMagnifier(FloatPoint(cursorBounds.x, cursorBounds.y), __handlerCursorPos);
        }
 }
 
 void
+_EditCopyPasteHandler::UpdateCopyPasteMagnifier(void)
+{
+       if (__pCopyPasteMagnifier)
+       {
+               __pCopyPasteMagnifier->Invalidate();
+       }
+}
+
+void
 _EditCopyPasteHandler::ChangeHandlerBitmap(void)
 {
        if (__pHandlerBitmap)
@@ -513,6 +644,8 @@ _EditCopyPasteHandler::_EditCopyPasteHandler(const Point& point, int handlerCurs
        , __singleHandler(false)
        , __pCopyPasteMagnifier(null)
        , __isTouchMoving(false)
+       , __rowIndex(-1)
+       , __columnIndex(-1)
 {
        AcquireHandle();
 
@@ -558,6 +691,8 @@ _EditCopyPasteHandler::_EditCopyPasteHandler(const FloatPoint& point, int handle
        , __singleHandler(false)
        , __pCopyPasteMagnifier(null)
        , __isTouchMoving(false)
+       , __rowIndex(-1)
+       , __columnIndex(-1)
 {
        AcquireHandle();
 
@@ -697,6 +832,13 @@ _EditCopyPasteHandler::GetHandlerCursorPosition(void) const
 }
 
 void
+_EditCopyPasteHandler::GetHandlerRowColumnIndex(int& rowIndex, int& columnIndex) const
+{
+       rowIndex = __rowIndex;
+       columnIndex = __columnIndex;
+}
+
+void
 _EditCopyPasteHandler::SetHandlerCursorPosition(int handlerCursorPos)
 {
        __handlerCursorPos = handlerCursorPos;
@@ -714,14 +856,28 @@ _EditCopyPasteHandler::AdjustBounds(void)
 
        if (__singleHandler)
        {
-               cursorRect = __pCopyPasteManager->GetCursorBoundsF(true);
+               if (__rowIndex == -1 && __columnIndex == -1)
+               {
+                       pEditPresenter->CalculateAbsoluteCursorBounds(__handlerCursorPos, cursorRect);
+               }
+               else
+               {
+                       pEditPresenter->CalculateAbsoluteCursorBounds(__rowIndex, __columnIndex, cursorRect);                   
+               }
                rect.x = cursorRect.x - __pHandlerBitmap->GetWidthF()/2.0f;
                rect.y = cursorRect.y + cursorRect.height;
                checkPoint = FloatPoint(cursorRect.x , cursorRect.y + cursorRect.height);
        }
        else
        {
-               pEditPresenter->CalculateAbsoluteCursorBounds(__handlerCursorPos, cursorRect);
+               if (__rowIndex == -1 && __columnIndex == -1)
+               {
+                       pEditPresenter->CalculateAbsoluteCursorBounds(__handlerCursorPos, cursorRect);
+               }
+               else
+               {
+                       pEditPresenter->CalculateAbsoluteCursorBounds(__rowIndex, __columnIndex, cursorRect);                   
+               }
 
                rect.x = cursorRect.x;
                rect.y = cursorRect.y + cursorRect.height;
@@ -1110,12 +1266,20 @@ _EditCopyPasteHandler::OnTouchMoved(const _Control& source, const _TouchInfo& to
        if (!__singleHandler)
        {
                previousCursorPos = __pCopyPasteManager->GetCursorPosition();
-               __pCopyPasteManager->SetCursorPosition(__handlerCursorPos);
        }
 
        FloatPoint absoluteTouchMovedPoint = FloatPoint(GetBoundsF().x + point.x, GetBoundsF().y + point.y);
-       cursorRect = __pCopyPasteManager->GetCursorBoundsF(false);
-       absCursorRect = __pCopyPasteManager->GetCursorBoundsF(true);
+       if (__rowIndex == -1 && __columnIndex == -1)
+       {
+               pEditPresenter->CalculateCursorBounds(pEditPresenter->GetTextBoundsF(), cursorRect,__handlerCursorPos);
+               pEditPresenter->CalculateAbsoluteCursorBounds(__handlerCursorPos, absCursorRect);
+       }
+       else
+       {
+               pEditPresenter->CalculateCursorBounds(pEditPresenter->GetTextBoundsF(), cursorRect, __rowIndex, __columnIndex);
+               pEditPresenter->CalculateAbsoluteCursorBounds(__rowIndex, __columnIndex, absCursorRect);                        
+       }
+
        touchPoint.x = cursorRect.x + (point.x - __touchPressedPoint.x);
        if (totalLine == 1)
        {
@@ -1125,12 +1289,23 @@ _EditCopyPasteHandler::OnTouchMoved(const _Control& source, const _TouchInfo& to
        {
                touchPoint.y = cursorRect.y + cursorRect.height + (point.y - __touchPressedPoint.y);
        }
-       cursorPos = __pCopyPasteManager->GetCursorPositionAt(touchPoint);
+       int rowIndex = -1;
+       int columnIndex = -1;
+       bool cursorPosFromTouch = false;
+       cursorPos = pEditPresenter->GetCursorPositionAt(touchPoint, rowIndex, columnIndex, true);
 
        if (cursorPos != -1)
        {
+               cursorPosFromTouch = true;
                FloatRectangle cursorBounds(0.0f, 0.0f, 0.0f, 0.0f);
-               pEdit->CalculateAbsoluteCursorBounds(cursorPos, cursorBounds);
+               if (__rowIndex == -1 && __columnIndex == -1)
+               {
+                       pEdit->CalculateAbsoluteCursorBounds(cursorPos, cursorBounds);
+               }
+               else
+               {
+                       pEditPresenter->CalculateAbsoluteCursorBounds(__rowIndex, __columnIndex, cursorBounds);
+               }
                cursorChange = true;
                checkPoint.x = cursorBounds.x;
 
@@ -1165,7 +1340,7 @@ _EditCopyPasteHandler::OnTouchMoved(const _Control& source, const _TouchInfo& to
                                                }
                                                else
                                                {
-                                                       if (__pCopyPasteManager->CheckHandlePosition(__leftHandler, cursorPos))
+                                                       if (__singleHandler || __pCopyPasteManager->CheckHandlePosition(__leftHandler, cursorPos))
                                                        {
                                                                __pCopyPasteManager->SetCursorPosition(cursorPos);
                                                                pEditPresenter->ScrollPanelToCursorPosition(true);
@@ -1266,7 +1441,7 @@ _EditCopyPasteHandler::OnTouchMoved(const _Control& source, const _TouchInfo& to
                                                }
                                                else
                                                {
-                                                       if (__pCopyPasteManager->CheckHandlePosition(__leftHandler, cursorPos))
+                                                       if (__singleHandler || __pCopyPasteManager->CheckHandlePosition(__leftHandler, cursorPos))
                                                        {
                                                                __pCopyPasteManager->SetCursorPosition(cursorPos);
                                                                pEditPresenter->ScrollPanelToCursorPosition(true);
@@ -1328,6 +1503,17 @@ _EditCopyPasteHandler::OnTouchMoved(const _Control& source, const _TouchInfo& to
                return true;
        }
 
+       if (cursorPosFromTouch && (__rowIndex != -1 && __columnIndex != -1))
+       {
+               __rowIndex = rowIndex;
+               __columnIndex =  columnIndex;
+       }
+       else
+       {
+               __rowIndex = -1;
+               __columnIndex  = -1;
+       }
+
        pTextObject->SetFirstDisplayLineIndexFromTextIndex(cursorPos);
 
        __handlerCursorPos = cursorPos;
@@ -1337,7 +1523,14 @@ _EditCopyPasteHandler::OnTouchMoved(const _Control& source, const _TouchInfo& to
        }
        else
        {
-               __pCopyPasteManager->SetCursorPosition(cursorPos);
+               if (__rowIndex == -1 && __columnIndex == -1)
+               {
+                       __pCopyPasteManager->SetCursorPosition(cursorPos);
+               }
+               else
+               {
+                       pEditPresenter->SetCursorPosition(cursorPos, __rowIndex, __columnIndex);
+               }
                pEditPresenter->DrawText();
                AdjustBounds();
        }
@@ -1983,7 +2176,6 @@ _EditCopyPasteManager::CreateHandle(void)
                __pHandle[HANDLER_TYPE_LEFT] = _EditCopyPasteHandler::CreateInstanceN(leftHandler, start, this, false, true);
                __pHandle[HANDLER_TYPE_RIGHT] = _EditCopyPasteHandler::CreateInstanceN(rightHandler, end, this, false, false);
        }
-/*
        else
        {
                FloatRectangle centerRect;
@@ -1995,7 +2187,6 @@ _EditCopyPasteManager::CreateHandle(void)
 //             __pHandle[HANDLER_TYPE_CENTER]->CreateCopyPasteMagnifier();
 #endif
        }
-*/
 }
 
 void
@@ -2133,10 +2324,18 @@ _EditCopyPasteManager::CheckHandlePosition(bool leftHandle, int cursorPosition)
 void
 _EditCopyPasteManager::RefreshBlock(bool isLeftHandle)
 {
+       int leftRowIndex = -1;
+       int leftColumnIndex = -1;
+       int rightRowIndex = -1;
+       int rightColumnIndex = -1;
+
        int leftHandlerPos = __pHandle[HANDLER_TYPE_LEFT]->GetHandlerCursorPosition();
        int rightHandlerPos = __pHandle[HANDLER_TYPE_RIGHT]->GetHandlerCursorPosition();
+       __pHandle[HANDLER_TYPE_RIGHT]->GetHandlerRowColumnIndex(leftRowIndex, leftColumnIndex);
+       __pHandle[HANDLER_TYPE_RIGHT]->GetHandlerRowColumnIndex(rightRowIndex, rightColumnIndex);
+
+       __pEditPresenter->SetBlockRange(leftHandlerPos, rightHandlerPos, leftColumnIndex, leftColumnIndex, rightRowIndex, rightColumnIndex);
 
-       __pEdit->SetBlockRange(leftHandlerPos, rightHandlerPos);
        __pEditPresenter->SetCursorChangedFlag(!isLeftHandle);
        __pEditPresenter->DrawText();
        AdjustBounds();
@@ -2322,7 +2521,7 @@ _EditCopyPasteManager::SetTextBlockReleaseFlag(bool enabled)
 bool
 _EditCopyPasteManager::IsCopyPasteHandleExist(void) const
 {
-       if (__pHandle[HANDLER_TYPE_LEFT] && __pHandle[HANDLER_TYPE_RIGHT])
+       if (__pHandle[HANDLER_TYPE_CENTER] || (__pHandle[HANDLER_TYPE_LEFT] && __pHandle[HANDLER_TYPE_RIGHT]))
        {
                return true;
        }
@@ -2332,6 +2531,31 @@ _EditCopyPasteManager::IsCopyPasteHandleExist(void) const
        }
 }
 
+bool
+_EditCopyPasteManager::IsCopyPasteSingleHandleExist(void) const
+{
+       if (__pHandle[HANDLER_TYPE_CENTER])
+       {
+               return true;
+       }
+       else
+       {
+               return false;
+       }
+}
+
+void
+_EditCopyPasteManager::UpdateCopyPasteMagnifier(void)
+{
+       for (int i = 0; i < HANDLER_TYPE_MAX; i++)
+       {
+               if (__pHandle[i])
+               {
+                       __pHandle[i]->UpdateCopyPasteMagnifier();
+               }
+       }
+}
+
 _Edit*
 _EditCopyPasteManager::GetEdit(void) const
 {
index 47a38ce..a78610d 100755 (executable)
@@ -58,6 +58,7 @@
 #include "FUiCtrl_Edit.h"
 #include "FUiCtrl_EditCopyPasteManager.h"
 #include "FUiCtrl_EditPresenter.h"
+#include "FUiCtrl_TokenEditPresenter.h"
 #include "FUiCtrl_FlickAnimation.h"
 #include "FUiCtrl_Frame.h"
 #include "FUiCtrl_Form.h"
@@ -230,6 +231,8 @@ _EditPresenter::_EditPresenter(void)
        , __clipboardConnected(false)
        , __updateInitialBounds(true)
        , __blockTextColor(Color(0, 0, 0))
+       , __rowCursorIndex(-1)
+       , __columnCursorIndex(-1)
 {
 }
 
@@ -1923,11 +1926,58 @@ _EditPresenter::DrawText(Canvas& canvas)
                __pTextObject->SetBackgroundColor(Color::GetColor(COLOR_ID_BLACK),  0, __pTextObject->GetTextLength());
        }
 
+       DrawTextBlockLine(canvas);
+
        __pEdit->UpdateAccessibilityElement(EDIT_ACCESSIBILITY_ELEMENT_TYPE_TEXT);
 
        return r;
 }
 
+void
+_EditPresenter::DrawTextBlockLine(Canvas& canvas)
+{
+       if (!__isTextBlocked)
+       {
+               return;
+       }
+       int startRange = 0;
+       int lengthRange = 0;
+
+       GetBlockRange(startRange, lengthRange);
+
+       FloatRectangle cursorBounds;
+       FloatRectangle textObjectBounds = __textObjectBounds;
+       textObjectBounds.x -= 1;
+       textObjectBounds.width = textObjectBounds.width + 2;
+       CalculateCursorBounds(__textObjectBounds, cursorBounds, startRange);
+       Color textBlockLineColor(0x3B, 0x73, 0xB6);
+
+       if (cursorBounds.x != -1)
+       {
+               cursorBounds.x -= 1;
+               cursorBounds.width = 2*cursorBounds.width;
+               cursorBounds = cursorBounds.GetIntersection(textObjectBounds);
+               canvas.FillRectangle(textBlockLineColor, cursorBounds);
+       }
+
+       if (__rowCursorIndex != -1 && __columnCursorIndex != -1)
+       {
+               CalculateCursorBounds(__textObjectBounds, cursorBounds, __rowCursorIndex, __columnCursorIndex); 
+       }
+       else
+       {
+               CalculateCursorBounds(__textObjectBounds, cursorBounds, lengthRange);
+       }
+
+       if (cursorBounds.x != -1 && cursorBounds.x < __textObjectBounds.x + __textObjectBounds.width)
+       {
+               cursorBounds.x -= 1;
+               cursorBounds.width = 2*cursorBounds.width;
+               cursorBounds = cursorBounds.GetIntersection(textObjectBounds);
+               canvas.FillRectangle(textBlockLineColor, cursorBounds);
+       }
+}
+
 result
 _EditPresenter::DrawTextForEntireFontSetting(Canvas& canvas)
 {
@@ -2033,6 +2083,8 @@ _EditPresenter::DrawTextForEntireFontSetting(Canvas& canvas)
        __pTextObject->SetBounds(__textObjectBounds);
        __pTextObject->Draw(*_CanvasImpl::GetInstance(canvas));
 
+       DrawTextBlockLine(canvas);
+
        return r;
 }
 
@@ -2614,6 +2666,66 @@ _EditPresenter::GetCursorPositionAt(const FloatPoint& touchPoint) const
 
        return cursorPos;
 }
+int
+_EditPresenter::GetCursorPositionAt(const FloatPoint& touchPoint, int& rowIndex, int& columnIndex, bool isMoving)
+{
+       FloatPoint cursorPoint;
+       int cursorPos = -1;
+
+       FloatRectangle textObjectBounds = __textObjectBounds;
+
+       if (!(__pEdit->GetEditStyle() & EDIT_STYLE_TOKEN) == false)
+       {
+               if (IsTextBlockedInTokenEdit())
+               {
+                       textObjectBounds = GetTextBoundsF();
+               }
+       }
+
+       if (textObjectBounds.Contains(touchPoint))
+       {
+               cursorPoint.x = touchPoint.x - textObjectBounds.x;
+               cursorPoint.y = touchPoint.y - textObjectBounds.y;
+       }
+       else if (__textBoxBounds.Contains(touchPoint) && !isMoving)
+       {
+               if (touchPoint.y <= textObjectBounds.y)
+               {
+                       cursorPoint.y = textObjectBounds.y + 1.0f;
+               }
+               else if (touchPoint.y >= (textObjectBounds.y + textObjectBounds.height))
+               {
+                       cursorPoint.y = textObjectBounds.y + textObjectBounds.height - 1.0f;
+               }
+               else
+               {
+                       cursorPoint.y = touchPoint.y;
+               }
+
+               if (touchPoint.x <= textObjectBounds.x)
+               {
+                       cursorPoint.x = textObjectBounds.x + 1.0f;
+               }
+               else if (touchPoint.x >= (textObjectBounds.x + textObjectBounds.width))
+               {
+                       cursorPoint.x = textObjectBounds.x + textObjectBounds.width - 1.0f;
+               }
+               else
+               {
+                       cursorPoint.x = touchPoint.x;
+               }
+               cursorPoint.y -= textObjectBounds.y;
+               cursorPoint.x -= textObjectBounds.x;
+       }
+       else
+       {
+               return cursorPos;
+       }
+
+       cursorPos = __pTextObject->GetTextIndexFromPosition(cursorPoint.x, cursorPoint.y, rowIndex, columnIndex, true);
+
+       return cursorPos;
+}
 
 bool
 _EditPresenter::IsHorizontalDirection(const _TouchInfo& touchInfo)
@@ -2669,7 +2781,91 @@ _EditPresenter::CalculateCursorBounds(const FloatRectangle& textBounds, FloatRec
                cursorPos = __pTextObject->GetCursorIndex();
        }
 
-       if (__pTextObject->GetTextPositionInfoAt(cursorPos, cursorWidth, cursorHeight, cursorAbsX, cursorAbsY, cursorRelativeX, cursorRelativeY) != E_SUCCESS)
+       if (cursorPos != __cursorPos)
+       {
+               if (__pTextObject->GetTextPositionInfoAt(cursorPos, cursorWidth, cursorHeight, cursorAbsX, cursorAbsY, cursorRelativeX, cursorRelativeY) != E_SUCCESS)
+               {
+                       return E_SYSTEM;
+               }
+       }
+       else
+       {
+               if (__pTextObject->GetTextPositionInfoAt(__rowCursorIndex, __columnCursorIndex, cursorWidth, cursorHeight, cursorAbsX, cursorAbsY, cursorRelativeX, cursorRelativeY) != E_SUCCESS)
+               {
+                       return E_SYSTEM;
+               }
+       }
+
+       cursorBounds.x = cursorRelativeX;
+       cursorBounds.y = cursorRelativeY;
+       float cursorWidthValue = 0.0f;
+       GET_SHAPE_CONFIG(EDIT::CURSOR_WIDTH, __pEdit->GetOrientation(), cursorWidthValue);
+       cursorBounds.width = cursorWidthValue;
+       cursorBounds.height = cursorHeight;
+
+       if (cursorBounds.y == 0.0f)
+       {
+               cursorBounds.y = __textObjectBounds.y;
+       }
+
+       if (cursorBounds.height == 0.0f)
+       {
+               cursorBounds.height = __textObjectBounds.height;
+       }
+
+       if (cursorBounds.height == 0.0f)
+       {
+               return E_SYSTEM;
+       }
+
+       if (cursorBounds.y < textBounds.y)
+       {
+               float cursorHeightDiff = textBounds.y - cursorBounds.y;
+               cursorBounds.y = textBounds.y;
+               cursorBounds.height -= cursorHeightDiff;
+       }
+
+       if (cursorBounds.y + cursorBounds.height > textBounds.y + textBounds.height)
+       {
+               float cursorHeightDiff = cursorBounds.y + cursorBounds.height - textBounds.y - textBounds.height - 1.0f;
+               cursorBounds.height -= cursorHeightDiff;
+       }
+
+       if (cursorBounds.x == textBounds.x + textBounds.width)
+       {
+               cursorBounds.x -= 1.0f;
+       }
+       else if (cursorBounds.x > textBounds.x + textBounds.width)
+       {
+               cursorBounds.x = textBounds.x + textBounds.width;
+               return E_SYSTEM;
+       }
+
+       if (__pTextObject->GetBlock() == false)
+       {
+               cursorBounds.x -= 1.0f;
+               if (cursorBounds.x < textBounds.x)
+               {
+                       cursorBounds.x = textBounds.x;
+               }
+       }
+
+       return E_SUCCESS;
+}
+
+result
+_EditPresenter::CalculateCursorBounds(const FloatRectangle& textBounds, FloatRectangle& cursorBounds, int rowIndex, int columnIndex)
+{
+       float cursorWidth = 0.0f;
+       float cursorHeight = 0.0f;
+       float cursorAbsX = 0.0f;
+       float cursorAbsY = 0.0f;
+       float cursorRelativeX = 0.0f;
+       float cursorRelativeY = 0.0f;
+
+       __pTextObject->SetBounds(textBounds);
+
+       if (__pTextObject->GetTextPositionInfoAt(rowIndex, columnIndex, cursorWidth, cursorHeight, cursorAbsX, cursorAbsY, cursorRelativeX, cursorRelativeY) != E_SUCCESS)
        {
                return E_SYSTEM;
        }
@@ -3111,7 +3307,9 @@ _EditPresenter::OnTouchReleased(const _Control& source, const _TouchInfo& touchI
        touchPoint = touchInfo.GetCurrentPosition();
        if (clientBounds.Contains(touchPoint))
        {
-               int cursorPos = GetCursorPositionAt(touchPoint);
+               int rowIndex;
+               int columnIndex;
+               int cursorPos = GetCursorPositionAt(touchPoint, rowIndex,columnIndex);
                if (cursorPos != -1)
                {
                        if (__isInputConnectionBound == true && __isTextComposing == true)
@@ -3126,15 +3324,27 @@ _EditPresenter::OnTouchReleased(const _Control& source, const _TouchInfo& touchI
                                }
                                else
                                {
-                                       SetCursorPosition(cursorPos);
+                                       SetCursorPosition(cursorPos, rowIndex, columnIndex);
                                }
                        }
                }
                FadeOutScrollBar();
-/*
-               if (!__isCopyPasteManagerExist)
+               if (!__isCopyPasteManagerExist && !__pFlickAnimationTimer)
                {
-                       if (IsInternalFocused())
+                       bool tokenEditting = false;
+                       if (__pEdit->GetEditStyle() & EDIT_STYLE_TOKEN)
+                       {
+                               _TokenEditPresenter* pTokenEditPresenter = dynamic_cast < _TokenEditPresenter* >(this);
+                               if (pTokenEditPresenter)
+                               {
+                                       if (pTokenEditPresenter->GetSelectedTokenIndex() != -1)
+                                       {
+                                               tokenEditting = true;
+                                       }
+                               }
+                       }
+
+                       if (IsInternalFocused() && !tokenEditting)
                        {
                                __pCopyPasteManager = new (std::nothrow) _EditCopyPasteManager(*__pEdit);
                                SysTryReturn(NID_UI_CTRL, __pCopyPasteManager != null, false, E_SYSTEM, "[EDIT] Unable to create _EditCopyPasteManager instance.");
@@ -3143,7 +3353,6 @@ _EditPresenter::OnTouchReleased(const _Control& source, const _TouchInfo& touchI
                                __isCopyPasteManagerExist = true;
                        }
                }
-*/
                //if ((cutLinkIndex < 0) && ((__pEdit->GetEditStyle() & EDIT_STYLE_VIEWER) == false) && (IsKeypadEnabled()))
                if ((cutLinkIndex < 0) && ((__pEdit->GetEditStyle() & EDIT_STYLE_VIEWER) == false))
                {
@@ -3433,13 +3642,46 @@ _EditPresenter::OnKeyPressed(const _Control& source, const _KeyInfo& keyInfo)
        result r = E_SUCCESS;
        _KeyCode keyCode = keyInfo.GetKeyCode();
        int textLength = 0;
+       int start = 0;
+       int end = 0;
 
        if (IsViewModeEnabled() == true)
        {
                return false;
        }
 
-       if (__isUSBKeyboardConnected && (keyInfo.GetKeyModifier() & _KEY_MODIFIER_CTRL))
+       if (__isUSBKeyboardConnected && (keyInfo.GetKeyModifier() & _KEY_MODIFIER_CTRL) && (keyInfo.GetKeyModifier() & _KEY_MODIFIER_SHIFT))
+       {
+               if ((keyCode == _KEY_LEFT) || (keyCode == _KEY_RIGHT))
+               {
+                       if (!__isCopyPasteManagerExist)
+                       {
+                               if (__pEdit->GetEditStyle() & EDIT_STYLE_TOKEN)
+                               {
+                                       _TokenEditPresenter* pTokenEditPresenter = dynamic_cast < _TokenEditPresenter* >(this);
+                                       if (pTokenEditPresenter)
+                                       {
+                                               if (pTokenEditPresenter->GetSelectedTokenIndex() != -1)
+                                               {
+                                                       return true;
+                                               }
+                                       }
+                               }
+                               SetBlockRangeWithCtrlShiftArrowkey(keyCode);
+                               return true;
+                       }
+                       else
+                       {
+                               if (__pCopyPasteManager->IsCopyPasteSingleHandleExist())
+                               {
+                                       InitializeCopyPasteManager();
+                                       SetBlockRangeWithShiftArrowkey(keyCode);
+                               }
+                               return true;
+                       }
+               }
+       }
+       else    if (__isUSBKeyboardConnected && (keyInfo.GetKeyModifier() & _KEY_MODIFIER_CTRL))
        {
                switch (keyCode)
                {
@@ -3503,6 +3745,74 @@ _EditPresenter::OnKeyPressed(const _Control& source, const _KeyInfo& keyInfo)
                                        InitializeCopyPasteManager();
                                }
                                break;
+                       case _KEY_HOME_BUTTON:
+                               if (__isCopyPasteManagerExist)
+                               {
+                                       InitializeCopyPasteManager();
+                               }
+                               if (__cursorPos != 0)
+                               {
+                                       SetCursorPosition(0);
+                               }
+                               else
+                               {
+                                       return true;
+                               }
+                               break;
+                       case _KEY_END_BUTTON:
+                               if (__isCopyPasteManagerExist)
+                               {
+                                       InitializeCopyPasteManager();
+                               }
+                               if (__cursorPos != GetTextLength())
+                               {
+                                       SetCursorPosition(GetTextLength());
+                               }
+                               else
+                               {
+                                       return true;
+                               }
+                               break;
+                       case _KEY_LEFT:
+                               if (__isCopyPasteManagerExist)
+                               {
+                                       InitializeCopyPasteManager();
+                               }
+                               if (__cursorPos == 0)
+                               {
+                                       return true;
+                               }
+                               GetWordPosition(__cursorPos, start, end);
+                               if (__cursorPos != start)
+                               {
+                                       SetCursorPosition(start);
+                               }
+                               else
+                               {
+                                       GetWordPosition(start-1, start, end);
+                                       SetCursorPosition(start);
+                               }
+                               break;
+                       case _KEY_RIGHT:
+                               if (__isCopyPasteManagerExist)
+                               {
+                                       InitializeCopyPasteManager();
+                               }
+                               if (__cursorPos == GetTextLength())
+                               {
+                                       return true;
+                               }
+                               GetWordPosition(__cursorPos, start, end);
+                               if (__cursorPos != end)
+                               {
+                                       SetCursorPosition(end);
+                               }
+                               else
+                               {
+                                       GetWordPosition(end+1, start, end);
+                                       SetCursorPosition(end);
+                               }
+                               break;
                        default:
                                return true;
                }
@@ -3523,6 +3833,17 @@ _EditPresenter::OnKeyPressed(const _Control& source, const _KeyInfo& keyInfo)
                {
                        if ( (keyCode == _KEY_LEFT) || (keyCode == _KEY_UP) || (keyCode == _KEY_DOWN) || (keyCode == _KEY_RIGHT) )
                        {
+                               if (__pEdit->GetEditStyle() & EDIT_STYLE_TOKEN)
+                               {
+                                       _TokenEditPresenter* pTokenEditPresenter = dynamic_cast < _TokenEditPresenter* >(this);
+                                       if (pTokenEditPresenter)
+                                       {
+                                               if (pTokenEditPresenter->GetSelectedTokenIndex() != -1)
+                                               {
+                                                       return true;
+                                               }
+                                       }
+                               }
                                SetBlockRangeWithShiftArrowkey(keyCode);
                                return true;
                        }
@@ -3531,6 +3852,15 @@ _EditPresenter::OnKeyPressed(const _Control& source, const _KeyInfo& keyInfo)
                                return false;
                        }
                }
+               else
+               {
+                       if (__pCopyPasteManager->IsCopyPasteSingleHandleExist())
+                       {
+                               InitializeCopyPasteManager();
+                               SetBlockRangeWithShiftArrowkey(keyCode);
+                               return true;
+                       }
+               }
 
                switch (keyCode)
                {
@@ -3551,6 +3881,77 @@ _EditPresenter::OnKeyPressed(const _Control& source, const _KeyInfo& keyInfo)
                }
                return true;
        }
+       else if (_KEY_END_BUTTON == keyCode || _KEY_HOME_BUTTON == keyCode)
+       {
+               if (__isCopyPasteManagerExist)
+               {
+                       InitializeCopyPasteManager();
+               }
+
+               if (__isInputConnectionBound != false && __isTextComposing != false)
+               {
+                       __pInputConnection->FinishTextComposition();
+                       __isTextComposing = false;
+                       __composingTextLength = 0;
+               }
+
+               int curCursorLine = __pTextObject->GetLineIndexAtTextIndex(__pTextObject->GetCursorIndex());
+               int firstTextIndex = __pTextObject->GetFirstTextIndexAt(curCursorLine);
+
+               if (_KEY_HOME_BUTTON == keyCode)
+               {
+                       if(__pEdit->GetEditStyle() & EDIT_STYLE_SINGLE_LINE)
+                       {
+                               if (__cursorPos != 0)
+                               {
+                                       SetCursorPosition(0);
+                               }
+                               else
+                               {
+                                       return true;
+                               }
+                       }
+                       else
+                       {
+                               SetCursorPosition(firstTextIndex);
+                       }
+               }
+               else if (_KEY_END_BUTTON == keyCode)
+               {
+                       if(__pEdit->GetEditStyle() & EDIT_STYLE_SINGLE_LINE)
+                       {
+                               if (__cursorPos != GetTextLength())
+                               {
+                                       SetCursorPosition(GetTextLength());
+                               }
+                               else
+                               {
+                                       return true;
+                               }
+                       }
+                       else
+                       {
+                               int totalLine = __pTextObject->GetTotalLineCount();
+                               if (curCursorLine < totalLine - 1)
+                               {
+                                       int nextLinefirstTextIndex = __pTextObject->GetFirstTextIndexAt(curCursorLine+1);
+                                       SetCursorPosition(nextLinefirstTextIndex-1);
+                               }
+                               else
+                               {
+                                       if (__cursorPos != GetTextLength())
+                                       {
+                                               SetCursorPosition(GetTextLength());
+                                       }
+                                       else
+                                       {
+                                               return true;
+                                       }
+                               }
+                       }
+               }
+               DrawText();
+       }
        else if (_KEY_ENTER == keyCode)
        {
                if (__isInputConnectionBound != false && __isTextComposing != false)
@@ -3582,11 +3983,11 @@ _EditPresenter::OnKeyPressed(const _Control& source, const _KeyInfo& keyInfo)
                        return true;
                }
        }
-       else if ((keyInfo.GetKeyModifier() & _KEY_LOCK_NUM) && (_KEY_NUM_LEFT == keyCode || _KEY_NUM_RIGHT == keyCode || _KEY_NUM_UP == keyCode || _KEY_NUM_DOWN == keyCode))
+       else if ((keyInfo.GetKeyModifier() & _KEY_LOCK_NUM) && (_KEY_NUMPAD_4 == keyCode || _KEY_NUMPAD_6 == keyCode || _KEY_NUMPAD_8 == keyCode || _KEY_NUMPAD_2 == keyCode))
        {
                return false;
        }
-       else if (_KEY_LEFT == keyCode || _KEY_NUM_LEFT == keyCode)
+       else if (_KEY_LEFT == keyCode || _KEY_NUMPAD_4 == keyCode)
        {
                if (__isCopyPasteManagerExist)
                {
@@ -3625,7 +4026,7 @@ _EditPresenter::OnKeyPressed(const _Control& source, const _KeyInfo& keyInfo)
                }
                return true;
        }
-       else if (_KEY_UP == keyCode || _KEY_NUM_UP == keyCode)
+       else if (_KEY_UP == keyCode || _KEY_NUMPAD_8 == keyCode)
        {
                if (__isCopyPasteManagerExist)
                {
@@ -3690,7 +4091,7 @@ _EditPresenter::OnKeyPressed(const _Control& source, const _KeyInfo& keyInfo)
                }
                return true;
        }
-       else if (_KEY_DOWN == keyCode || _KEY_NUM_DOWN == keyCode)
+       else if (_KEY_DOWN == keyCode || _KEY_NUMPAD_2 == keyCode)
        {
                if (__isCopyPasteManagerExist)
                {
@@ -3758,7 +4159,7 @@ _EditPresenter::OnKeyPressed(const _Control& source, const _KeyInfo& keyInfo)
                }
                return true;
        }
-       else if (_KEY_RIGHT == keyCode || _KEY_NUM_RIGHT == keyCode)
+       else if (_KEY_RIGHT == keyCode || _KEY_NUMPAD_6 == keyCode)
        {
                if (__isCopyPasteManagerExist)
                {
@@ -3880,28 +4281,98 @@ _EditPresenter::OnKeyReleased(const _Control& source, const _KeyInfo& keyInfo)
 {
         _KeyCode keyCode = keyInfo.GetKeyCode();
 
-       if (__isUSBKeyboardConnected && (keyCode == _KEY_SHIFT_L || keyCode == _KEY_SHIFT_R))
-       {
-               if (__pCopyPasteManager && __pCopyPasteManager->IsHandlerMovingEnabled())
+       if (__isUSBKeyboardConnected && (keyCode == _KEY_SHIFT_L || keyCode == _KEY_SHIFT_R))
+       {
+               if (__pCopyPasteManager && __pCopyPasteManager->IsHandlerMovingEnabled())
+               {
+                       __pCopyPasteManager->SetHandlerMovingEnabled(false);
+                       __pCopyPasteManager->CreateCopyPastePopup();
+                       __pCopyPasteManager->Show();
+               }
+               else if (__textBlockMoving)
+               {
+                       __pCopyPasteManager = new (std::nothrow) _EditCopyPasteManager(*__pEdit);
+                       SysTryReturn(NID_UI_CTRL, __pCopyPasteManager != null, true, E_OUT_OF_MEMORY, "[EDIT] Unable to create _EditCopyPasteManager instance.");
+                       __pCopyPasteManager->AddCopyPasteEventListener(*this);
+                       __pCopyPasteManager->CreateCopyPastePopup();
+                       __pCopyPasteManager->Show();
+                       __isCopyPasteManagerExist = true;
+
+                       __textBlockMoving = false;
+               }
+               return true;
+       }
+
+       return false;
+}
+
+bool
+_EditPresenter::TranslateKeyEventInfo(const _Control& source, _KeyInfo& keyInfo)
+{
+       _KeyCode keyCode = keyInfo.GetKeyCode();
+       if (keyInfo.GetKeyModifier() & _KEY_MODIFIER_SHIFT || keyInfo.GetKeyModifier() & _KEY_MODIFIER_CTRL)
+       {
+               return false;
+       }
+       if ((keyInfo.GetKeyModifier() & _KEY_LOCK_NUM) && ((_KEY_NUMPAD_8 == keyCode || _KEY_NUMPAD_2 == keyCode || _KEY_NUMPAD_6 == keyCode || _KEY_NUMPAD_4 == keyCode)))
+       {
+               return false;
+       }
+       if (__isUSBKeyboardConnected && (_KEY_UP == keyCode || _KEY_NUMPAD_8 == keyCode || _KEY_DOWN == keyCode || _KEY_NUMPAD_2 == keyCode
+               || _KEY_RIGHT == keyCode || _KEY_NUMPAD_6 == keyCode || _KEY_LEFT == keyCode || _KEY_NUMPAD_4 == keyCode || _KEY_ENTER == keyCode))
+       {
+               if (__isCopyPasteManagerExist)
+               {
+                       InitializeCopyPasteManager();
+               }
+
+               if (__isInputConnectionBound != false && __isTextComposing != false)
+               {
+                       __pInputConnection->FinishTextComposition();
+                       __isTextComposing = false;
+                       __composingTextLength = 0;
+               }
+
+               int curCursorLine = __pTextObject->GetLineIndexAtTextIndex(__pTextObject->GetCursorIndex());
+               int totalLine = __pTextObject->GetTotalLineCount();
+               if(_KEY_UP == keyCode || _KEY_NUMPAD_8 == keyCode)
                {
-                       __pCopyPasteManager->SetHandlerMovingEnabled(false);
-                       __pCopyPasteManager->CreateCopyPastePopup();
-                       __pCopyPasteManager->Show();
+                       if (curCursorLine == 0)
+                       {
+                               keyInfo.SetKeyCode(_KEY_TAB);
+                               keyInfo.SetKeyModifier(KEY_MODIFIER_SHIFT);
+                       }
                }
-               else if (__textBlockMoving)
+               else if ( _KEY_DOWN == keyCode || _KEY_NUMPAD_2 == keyCode)
                {
-                       __pCopyPasteManager = new (std::nothrow) _EditCopyPasteManager(*__pEdit);
-                       SysTryReturn(NID_UI_CTRL, __pCopyPasteManager != null, true, E_OUT_OF_MEMORY, "[EDIT] Unable to create _EditCopyPasteManager instance.");
-                       __pCopyPasteManager->AddCopyPasteEventListener(*this);
-                       __pCopyPasteManager->CreateCopyPastePopup();
-                       __pCopyPasteManager->Show();
-                       __isCopyPasteManagerExist = true;
-
-                       __textBlockMoving = false;
+                       if (curCursorLine == (totalLine - 1))
+                       {
+                               keyInfo.SetKeyCode(_KEY_TAB);
+                       }
+               }
+               else if (_KEY_RIGHT == keyCode || _KEY_NUMPAD_6 == keyCode)
+               {
+                       if (__cursorPos == GetTextLength())
+                       {
+                               keyInfo.SetKeyCode(_KEY_TAB);
+                       }
+               }
+               else if (_KEY_LEFT == keyCode || _KEY_NUMPAD_4 == keyCode)
+               {
+                       if (__cursorPos == 0)
+                       {
+                               keyInfo.SetKeyCode(_KEY_TAB);
+                               keyInfo.SetKeyModifier(KEY_MODIFIER_SHIFT);
+                       }
+               }
+               else if (_KEY_ENTER == keyCode)
+               {
+                       if(__pEdit->GetEditStyle() & EDIT_STYLE_SINGLE_LINE)
+                       {
+                               keyInfo.SetKeyCode(_KEY_TAB);
+                       }
                }
-               return true;
        }
-
        return false;
 }
 
@@ -4100,7 +4571,16 @@ _EditPresenter::OnTapGestureDetected(void)
 
                if (cursorPos == -1)
                {
-                       cursorPos = 0;
+                       cursorPos = GetTextLength();
+               }
+               else
+               {
+                       int curCursorLine = __pTextObject->GetLineIndexAtTextIndex(cursorPos);
+                       int firstTextIndex = __pTextObject->GetFirstTextIndexAt(curCursorLine);
+                       if (cursorPos != 0 && cursorPos == firstTextIndex && __rowCursorIndex != curCursorLine)
+                       {
+                               cursorPos--;
+                       }
                }
 
                if (__isInputConnectionBound && __isTextComposing)
@@ -4193,6 +4673,37 @@ _EditPresenter::SetBlockRange(int start, int end)
 }
 
 result
+_EditPresenter::SetBlockRange(int start, int end, int leftRowIndex, int leftColumnIndex, int rightRowIndex, int rightColumnIndex)
+{
+       result r = E_SUCCESS;
+
+       if (leftRowIndex == -1 && leftColumnIndex == -1)
+       {
+               r = SetCursorPosition(start);
+       }
+       else
+       {
+               r = SetCursorPosition(start, leftRowIndex, leftColumnIndex);
+       }
+       SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       r = BeginTextBlock();
+       SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       if (rightRowIndex == -1 && rightColumnIndex == -1)
+       {
+               r = SetCursorPosition(end);
+       }
+       else
+       {
+               r = SetCursorPosition(end, rightRowIndex, rightColumnIndex);
+       }
+       SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+       return r;
+}
+
+result
 _EditPresenter::BeginTextBlock(void)
 {
        if (__pEdit->GetEditStyle() & EDIT_STYLE_PASSWORD)
@@ -4695,6 +5206,34 @@ _EditPresenter::SetCursorPosition(int position)
        r = __pTextObject->SetCursorIndex(position);
        SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, "[Edit] Failed to set cursor position");
 
+       if (__cursorPos != position)
+       {
+               __pTextObject->ConvertToRowColumn(position, __rowCursorIndex, __columnCursorIndex);
+               __cursorPos = position;
+       }
+
+       return r;
+}
+
+result
+_EditPresenter::SetCursorPosition(int position,int rowIndex, int columnIndex)
+{
+       result r = E_SUCCESS;
+       int length = GetTextLength();
+
+       SysTryReturnResult(NID_UI_CTRL, -1 < position && position <= length, E_INVALID_ARG, "[Edit] Invalid argument is given.");
+
+       if (__isTouchMoving == false)
+       {
+               __isCursorChanged = true;
+       }
+
+       r = __pTextObject->SetCursorIndex(position);
+       SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, "[Edit] Failed to set cursor position");
+
+       __rowCursorIndex = rowIndex;
+       __columnCursorIndex = columnIndex;
+
        __cursorPos = position;
 
        return r;
@@ -5982,10 +6521,66 @@ _EditPresenter::CalculateAbsoluteCursorBounds(int index, FloatRectangle& absCurs
        FloatRectangle absBounds = __pEdit->GetAbsoluteBoundsF();
 
        __pTextObject->SetBounds(GetTextBoundsF());
+       if (index != __cursorPos)
+       {
        if (__pTextObject->GetTextPositionInfoAt(index, cursorWidth, cursorHeight, cursorAbsX, cursorAbsY, cursorRelativeX, cursorRelativeY) != E_SUCCESS)
        {
                return E_SYSTEM;
        }
+       }
+       else
+       {
+               if (__pTextObject->GetTextPositionInfoAt(__rowCursorIndex, __columnCursorIndex, cursorWidth, cursorHeight, cursorAbsX, cursorAbsY, cursorRelativeX, cursorRelativeY) != E_SUCCESS)
+               {
+                       return E_SYSTEM;
+               }
+       }
+
+       absCursorBounds.x = absBounds.x + cursorRelativeX;
+
+       if (__pEdit->GetEditStyle() & EDIT_STYLE_SINGLE_LINE)
+       {
+               FloatRectangle tempBounds;
+               GetCursorBounds(true, tempBounds);
+               absCursorBounds.y = tempBounds.y;
+       }
+       else
+       {
+               absCursorBounds.y = absBounds.y + cursorRelativeY;
+       }
+
+       absCursorBounds.width = cursorWidth;
+
+       if (cursorHeight > 0.0f)
+       {
+               absCursorBounds.height = cursorHeight;
+       }
+       else
+       {
+               absCursorBounds.height = __pTextObject->GetLineHeightAtF(0);
+       }
+
+       return E_SUCCESS;
+}
+
+result
+_EditPresenter::CalculateAbsoluteCursorBounds(int rowIndex, int columnIndex, FloatRectangle& absCursorBounds)
+{
+       float cursorAbsX = 0.0f;
+       float cursorAbsY = 0.0f;
+       float cursorWidth = 0.0f;
+       float cursorHeight = 0.0f;
+       float cursorRelativeX = 0.0f;
+       float cursorRelativeY = 0.0f;
+
+       FloatRectangle absBounds = __pEdit->GetAbsoluteBoundsF();
+
+       __pTextObject->SetBounds(GetTextBoundsF());
+
+       if (__pTextObject->GetTextPositionInfoAt(rowIndex, columnIndex, cursorWidth, cursorHeight, cursorAbsX, cursorAbsY, cursorRelativeX, cursorRelativeY) != E_SUCCESS)
+       {
+               return E_SYSTEM;
+       }
 
        absCursorBounds.x = absBounds.x + cursorRelativeX;
 
@@ -7221,8 +7816,9 @@ _EditPresenter::DrawCursor(Canvas& canvas, FloatRectangle& cursorBounds, bool is
 
        if (__isCursorDisabled == false)
        {
-               Color cursorColor;
-               GET_COLOR_CONFIG(EDIT::CURSOR_NORMAL, cursorColor);
+//             Color cursorColor;
+//             GET_COLOR_CONFIG(EDIT::CURSOR_NORMAL, cursorColor);
+               Color cursorColor(0x3B, 0x73, 0xB6);
 
                if (__isCursorInitialized)
                {
@@ -7336,6 +7932,11 @@ _EditPresenter::OnCursorTimerExpired(void)
        __isCursorOpaque = __isCursorOpaque ? false : true;
        StartCursorTimer();
 
+       if (__pCopyPasteManager)
+       {
+               __pCopyPasteManager->UpdateCopyPasteMagnifier();
+       }
+
        return;
 }
 
@@ -9676,6 +10277,12 @@ _EditPresenter::GetWordPosition(int cursorPos, int& startPos, int& endPos) const
                endPos = textLength;
        }
 
+       if (startPos > endPos)
+       {
+               int temp = startPos;
+               startPos = endPos;
+               endPos = temp;
+       }
        return;
 }
 
@@ -10229,6 +10836,154 @@ _EditPresenter::SetBlockRangeWithShiftArrowkey(_KeyCode keyCode)
 }
 
 void
+_EditPresenter::SetBlockRangeWithCtrlShiftArrowkey(_KeyCode keyCode)
+{
+       int start = 0;
+       int end = 0;
+       int originalStart = 0;
+       int originalEnd = 0;
+       if (IsBlocked() == true)
+       {
+               GetBlockRange(start, end);
+               switch(keyCode)
+               {
+                       case _KEY_LEFT:
+                               if (__textBlockMoveLeft)
+                               {
+                                       if (start > 0)
+                                       {
+                                               originalStart = start;
+                                               originalEnd = end;
+                                               GetWordPosition(start-1, start, end);
+                                               SetBlockRange(start, originalEnd);
+                                       }
+                               }
+                               else
+                               {
+                                       originalStart = start;
+                                       originalEnd = end;
+                                       GetWordPosition(end, start, end);
+                                       if (originalEnd == start)
+                                       {
+                                               GetWordPosition(start-1, start, end);
+                                       }
+
+                                       if (originalStart < start)
+                                       {
+                                               SetBlockRange(originalStart, start);
+                                       }
+                                       else if (originalStart > start)
+                                       {
+                                               SetBlockRange(start, originalStart);
+                                               __textBlockMoveLeft = true;
+                                       }
+                                       else if (originalStart == start)
+                                       {
+                                               ReleaseTextBlock();
+                                               SetCursorPosition(start);
+                                               __textBlockMoveLeft = true;
+                                       }
+                               }
+                               break;
+                       case _KEY_RIGHT:
+                               if (__textBlockMoveLeft)
+                               {
+                                       originalStart = start;
+                                       originalEnd = end;
+                                       GetWordPosition(start, start, end);
+                                       if (originalStart == end)
+                                       {
+                                               GetWordPosition(end+1, start, end);
+                                       }
+                                       if (originalEnd > end)
+                                       {
+                                               SetBlockRange(end, originalEnd);
+                                       }
+                                       else if (originalEnd < end)
+                                       {
+                                               SetBlockRange(originalEnd, end);
+                                               __textBlockMoveLeft = false;
+                                       }
+                                       else if (originalEnd == end)
+                                       {
+                                               ReleaseTextBlock();
+                                               SetCursorPosition(end);
+                                               __textBlockMoveLeft = false;
+                                       }
+                               }
+                               else
+                               {
+                                       if (end < GetTextLength())
+                                       {
+                                               originalStart = start;
+                                               originalEnd = end;
+                                               GetWordPosition(end+1, start, end);
+                                               SetBlockRange(originalStart, end);
+                                       }
+                               }
+                               break;
+                       default:
+                               break;
+               }
+
+               if (IsBlocked())
+               {
+                       if (__textBlockMoveLeft)
+                       {
+                               __pTextObject->SetFirstDisplayLineIndexFromTextIndex(start);
+                       }
+                       SetCursorChangedFlag(!__textBlockMoveLeft);
+               }
+               DrawText();
+       }
+       else
+       {
+               switch(keyCode)
+               {
+                       case _KEY_LEFT:
+                               if (__cursorPos > 0)
+                               {
+                                       GetWordPosition(__cursorPos, start, end);
+                                       if (__cursorPos != start)
+                                       {
+                                               SetBlockRange(start, __cursorPos);
+                                       }
+                                       else
+                                       {
+                                               GetWordPosition(start-1, start, end);
+                                               SetBlockRange(start, __cursorPos);
+                                       }
+                                       __textBlockMoveLeft = true;
+                               }
+                               break;
+                       case _KEY_RIGHT:
+                               if (GetTextLength() >= __cursorPos + 1)
+                               {
+                                       GetWordPosition(__cursorPos, start, end);
+                                       if (__cursorPos != end)
+                                       {
+                                               SetBlockRange(__cursorPos, end);
+                                       }
+                                       else
+                                       {
+                                               GetWordPosition(end+1, start, end);
+                                               SetBlockRange(__cursorPos, end);
+                                       }
+                                       __textBlockMoveLeft = false;
+                               }
+                               break;
+                       default:
+                               break;
+               }
+               DrawText();
+       }
+       if (IsBlocked())
+       {
+               __textBlockMoving = true;
+       }
+}
+
+void
 _EditPresenter::SetEditTextFilter(_IEditTextFilter* pFilter)
 {
        __pTextFilter = pFilter;
index fd0d77c..7668a6b 100644 (file)
@@ -109,6 +109,8 @@ public:
        bool GetTextBlockReleaseFlag(void) const;
        void SetTextBlockReleaseFlag(bool enabled);
        bool IsCopyPasteHandleExist(void) const;
+       bool IsCopyPasteSingleHandleExist(void) const;
+       void UpdateCopyPasteMagnifier(void);
 
 // virtual function
        virtual void OnActionPerformed(const Tizen::Ui::_Control& source, int actionId);
index e11b96d..d19d7d8 100644 (file)
@@ -134,6 +134,7 @@ public:
        virtual bool OnTouchReleased(const _Control& source, const _TouchInfo& touchinfo);
        virtual bool OnKeyPressed(const _Control& source, const _KeyInfo& keyInfo);
        virtual bool OnKeyReleased(const _Control& source, const _KeyInfo& keyInfo);
+       virtual bool TranslateKeyEventInfo(const _Control& source, _KeyInfo& keyInfo);
 
        virtual void OnClipboardPopupClosed(const ClipboardItem* pClipboardItem);
        virtual result SetInitialBounds(void);
@@ -163,9 +164,11 @@ public:
        result SetAutoLinkMask(unsigned long autoLinks);
        result SetAutoResizingEnabled(bool enable);
        result SetBlockRange(int start, int end);
+       result SetBlockRange(int start, int end, int leftRowIndex, int leftColumnIndex, int rightRowIndex, int rightColumnIndex);
        result SetCurrentInputModeCategory(EditInputModeCategory inputModeCategory);
        result SetCurrentLanguage(Tizen::Locales::LanguageCode languageCode);
        result SetCursorPosition(int position);
+       result SetCursorPosition(int position,int rowIndex, int columnIndex);
        void SetClientBounds(void);
        result SetEllipsisPosition(EllipsisPosition position);
        virtual result SetFlexBounds(const Tizen::Graphics::Rectangle& bounds);
@@ -206,6 +209,7 @@ public:
        void GetCurrentTextRange(int& start, int& end) const;
        int GetCursorPositionAt(const Tizen::Graphics::Point& touchPoint) const;
        int GetCursorPositionAt(const Tizen::Graphics::FloatPoint& touchPoint) const;
+       int GetCursorPositionAt(const Tizen::Graphics::FloatPoint& touchPoint, int& rowIndex, int& columnIndex, bool isMoving = false);
        virtual bool IsTextBlockedInTokenEdit(void) const;
        int GetCursorPosition(void) const;
        result GetCursorBounds(bool isAbsRect, Tizen::Graphics::Rectangle& cursorBounds);
@@ -268,6 +272,7 @@ public:
        result BeginTextBlock(void);
        result CalculateAbsoluteCursorBounds(int index, Tizen::Graphics::Rectangle& absCursorBounds);
        result CalculateAbsoluteCursorBounds(int index, Tizen::Graphics::FloatRectangle& absCursorBounds);
+       result CalculateAbsoluteCursorBounds(int rowIndex, int columnIndex, FloatRectangle& absCursorBounds);
        virtual result ChangeLayout(_ControlOrientation orientation);
        result ClearText(void);
        result CopyText(void);
@@ -304,6 +309,7 @@ public:
        EditStatus GetCurrentStatus(void) const;
        result ScrollContents(float moveY);
        virtual void DrawText(void);
+       void DrawTextBlockLine(Canvas& canvas);
        virtual bool IsGuideTextActivated(void) const;
        result UpdateComponentInformation(void);
        void SetCursorChangedFlag(bool enabled);
@@ -320,6 +326,7 @@ public:
        bool IsCopyPasteHandleExist(void) const;
        void DeleteFullscreenKeypad(void);
        void SetBlockRangeWithShiftArrowkey(_KeyCode keyCode);
+       void SetBlockRangeWithCtrlShiftArrowkey(_KeyCode keyCode);
        void SetEditTextFilter(_IEditTextFilter* pFilter);
        virtual bool ValidatePastedText(const Tizen::Base::String& pastedText, Tizen::Base::String& replacedText);
        void SendOpaqueCommand (const Tizen::Base::String& command);
@@ -333,6 +340,7 @@ public:
        result InitializeCursor(void);
        result CalculateCursorBounds(const Tizen::Graphics::Rectangle& textBounds, Tizen::Graphics::Rectangle& cursorBounds, int curPos = -1);
        result CalculateCursorBounds(const Tizen::Graphics::FloatRectangle& textBounds, Tizen::Graphics::FloatRectangle& cursorBounds, int curPos = -1);
+       result CalculateCursorBounds(const Tizen::Graphics::FloatRectangle& textBounds, Tizen::Graphics::FloatRectangle& cursorBounds, int rowIndex, int columnIndex);
        virtual void ResetTextBounds(void){}
        void UpdateKeypadCommandString(void);
 
@@ -581,6 +589,8 @@ private:
        bool __clipboardConnected;
        bool __updateInitialBounds;
        Tizen::Graphics::Color __blockTextColor;
+       int __rowCursorIndex;
+       int __columnCursorIndex;
 }; // _EditPresenter
 
 }}} // Tizen::Ui::Controls