#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;
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);
Bitmap* __pMagnifierBitmap;
_VisualElement* __pRoot;
int __handlerCursorPos;
+ FloatRectangle __windowBounds;
+ int __rowIndex;
+ int __columnIndex;
};
_EditCopyPasteMagnifier::_EditCopyPasteMagnifier(_EditCopyPasteManager* pCopyPasteManager, int handlerCursorPos)
, __pMagnifierBitmap(null)
, __pRoot(null)
, __handlerCursorPos(handlerCursorPos)
+ , __windowBounds(0.0f, 0.0f, 0.0f, 0.0f)
+ , __rowIndex(-1)
+ , __columnIndex(-1)
{
AcquireHandle();
__pRoot = GetVisualElement();
_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)
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);
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
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.
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);
bool CreateCopyPasteMagnifier(void);
void DestroyCopyPasteMagnifier(void);
void MoveCopyPasteMagnifier(void);
+ void UpdateCopyPasteMagnifier(void);
// virtual function
virtual void OnDraw(void);
bool __singleHandler;
_EditCopyPasteMagnifier* __pCopyPasteMagnifier;
bool __isTouchMoving;
+ int __rowIndex;
+ int __columnIndex;
}; // _EditCopyPasteHandler
Bitmap*
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");
}
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)
, __singleHandler(false)
, __pCopyPasteMagnifier(null)
, __isTouchMoving(false)
+ , __rowIndex(-1)
+ , __columnIndex(-1)
{
AcquireHandle();
, __singleHandler(false)
, __pCopyPasteMagnifier(null)
, __isTouchMoving(false)
+ , __rowIndex(-1)
+ , __columnIndex(-1)
{
AcquireHandle();
}
void
+_EditCopyPasteHandler::GetHandlerRowColumnIndex(int& rowIndex, int& columnIndex) const
+{
+ rowIndex = __rowIndex;
+ columnIndex = __columnIndex;
+}
+
+void
_EditCopyPasteHandler::SetHandlerCursorPosition(int handlerCursorPos)
{
__handlerCursorPos = handlerCursorPos;
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;
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)
{
{
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;
}
else
{
- if (__pCopyPasteManager->CheckHandlePosition(__leftHandler, cursorPos))
+ if (__singleHandler || __pCopyPasteManager->CheckHandlePosition(__leftHandler, cursorPos))
{
__pCopyPasteManager->SetCursorPosition(cursorPos);
pEditPresenter->ScrollPanelToCursorPosition(true);
}
else
{
- if (__pCopyPasteManager->CheckHandlePosition(__leftHandler, cursorPos))
+ if (__singleHandler || __pCopyPasteManager->CheckHandlePosition(__leftHandler, cursorPos))
{
__pCopyPasteManager->SetCursorPosition(cursorPos);
pEditPresenter->ScrollPanelToCursorPosition(true);
return true;
}
+ if (cursorPosFromTouch && (__rowIndex != -1 && __columnIndex != -1))
+ {
+ __rowIndex = rowIndex;
+ __columnIndex = columnIndex;
+ }
+ else
+ {
+ __rowIndex = -1;
+ __columnIndex = -1;
+ }
+
pTextObject->SetFirstDisplayLineIndexFromTextIndex(cursorPos);
__handlerCursorPos = cursorPos;
}
else
{
- __pCopyPasteManager->SetCursorPosition(cursorPos);
+ if (__rowIndex == -1 && __columnIndex == -1)
+ {
+ __pCopyPasteManager->SetCursorPosition(cursorPos);
+ }
+ else
+ {
+ pEditPresenter->SetCursorPosition(cursorPos, __rowIndex, __columnIndex);
+ }
pEditPresenter->DrawText();
AdjustBounds();
}
__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;
// __pHandle[HANDLER_TYPE_CENTER]->CreateCopyPasteMagnifier();
#endif
}
-*/
}
void
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();
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;
}
}
}
+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
{
#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"
, __clipboardConnected(false)
, __updateInitialBounds(true)
, __blockTextColor(Color(0, 0, 0))
+ , __rowCursorIndex(-1)
+ , __columnCursorIndex(-1)
{
}
__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)
{
__pTextObject->SetBounds(__textObjectBounds);
__pTextObject->Draw(*_CanvasImpl::GetInstance(canvas));
+ DrawTextBlockLine(canvas);
+
return r;
}
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)
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;
}
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)
}
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.");
__isCopyPasteManagerExist = true;
}
}
-*/
//if ((cutLinkIndex < 0) && ((__pEdit->GetEditStyle() & EDIT_STYLE_VIEWER) == false) && (IsKeypadEnabled()))
if ((cutLinkIndex < 0) && ((__pEdit->GetEditStyle() & EDIT_STYLE_VIEWER) == false))
{
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)
{
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;
}
{
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;
}
return false;
}
}
+ else
+ {
+ if (__pCopyPasteManager->IsCopyPasteSingleHandleExist())
+ {
+ InitializeCopyPasteManager();
+ SetBlockRangeWithShiftArrowkey(keyCode);
+ return true;
+ }
+ }
switch (keyCode)
{
}
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)
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)
{
}
return true;
}
- else if (_KEY_UP == keyCode || _KEY_NUM_UP == keyCode)
+ else if (_KEY_UP == keyCode || _KEY_NUMPAD_8 == keyCode)
{
if (__isCopyPasteManagerExist)
{
}
return true;
}
- else if (_KEY_DOWN == keyCode || _KEY_NUM_DOWN == keyCode)
+ else if (_KEY_DOWN == keyCode || _KEY_NUMPAD_2 == keyCode)
{
if (__isCopyPasteManagerExist)
{
}
return true;
}
- else if (_KEY_RIGHT == keyCode || _KEY_NUM_RIGHT == keyCode)
+ else if (_KEY_RIGHT == keyCode || _KEY_NUMPAD_6 == keyCode)
{
if (__isCopyPasteManagerExist)
{
{
_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;
}
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)
}
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)
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;
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;
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)
{
__isCursorOpaque = __isCursorOpaque ? false : true;
StartCursorTimer();
+ if (__pCopyPasteManager)
+ {
+ __pCopyPasteManager->UpdateCopyPasteMagnifier();
+ }
+
return;
}
endPos = textLength;
}
+ if (startPos > endPos)
+ {
+ int temp = startPos;
+ startPos = endPos;
+ endPos = temp;
+ }
return;
}
}
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;