2 // Open Service Platform
3 // Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
5 // Licensed under the Apache License, Version 2.0 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
9 // http://www.apache.org/licenses/LICENSE-2.0/
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
19 * @file FUiCtrl_EditCopyPasteManager.cpp
20 * @brief This is the implementation file for the _EditCopyPasteManager class.
23 #include <appsvc/appsvc.h>
24 #include <FApp_AppControlManager.h>
25 #include <FApp_AppMessageImpl.h>
26 #include <FBaseUtilMath.h>
27 #include <FGrp_BitmapImpl.h>
28 #include "FUi_Clipboard.h"
29 #include "FUi_ClipboardItem.h"
30 #include "FUi_CoordinateSystemUtils.h"
31 #include "FUi_EcoreEvasMgr.h"
32 #include "FUiCtrl_EditCopyPasteManager.h"
33 #include "FUiCtrl_EditCopyPasteEvent.h"
34 #include "FUiCtrl_EditPresenter.h"
35 #include "FUiCtrl_Form.h"
36 #include "FUiCtrl_Frame.h"
37 #include "FUi_EcoreEvas.h"
39 #include "FUi_Window.h"
41 #define EDIT_COPY_PASTE_MAGNIFIER 1
43 using namespace Tizen::Ui;
44 using namespace Tizen::App;
45 using namespace Tizen::Base;
46 using namespace Tizen::Base::Runtime;
47 using namespace Tizen::Base::Utility;
48 using namespace Tizen::Graphics;
49 using namespace Tizen::Graphics::_Text;
50 using namespace Tizen::Ui::Animations;
52 namespace Tizen { namespace Ui { namespace Controls
55 const int COPY_PASTE_SELECT_ID = 231;
56 const int COPY_PASTE_SELECT_ALL_ID = 232;
57 const int COPY_PASTE_COPY_ID = 233;
58 const int COPY_PASTE_CUT_ID = 234;
59 const int COPY_PASTE_PASTE_ID = 235;
60 const int COPY_PASTE_CLIPBOARD_ID = 236;
61 const int COPY_PASTE_SEARCH_ID = 237;
63 class _EditCopyPasteMagnifier
67 _EditCopyPasteMagnifier(_EditCopyPasteManager* pCopyPasteManager, int handlerCursorPos);
68 virtual ~_EditCopyPasteMagnifier(void);
69 static _EditCopyPasteMagnifier* CreateInstanceN(const FloatPoint& point, int handlerCursorPos, _EditCopyPasteManager* pCopyPasteManager);
70 virtual void OnDraw(void);
71 void CaptureTextArea(Canvas& canvas);
72 void MoveMagnifier(const FloatPoint& point, int handlerCursorPos);
73 Bitmap* GetMagnifierBitmap(void) const;
74 virtual result OnAttachedToMainTree(void);
75 result OnBoundsChanging(const FloatRectangle& bounds);
76 result OnBoundsChanging(const Rectangle& bounds);
77 void SetRowColumnIndex(int rowIndex, int columnIndex);
80 _EditCopyPasteMagnifier(const _EditCopyPasteMagnifier& value);
81 _EditCopyPasteMagnifier& operator =(const _EditCopyPasteMagnifier& value);
84 _EditCopyPasteManager* __pCopyPasteManager;
85 Bitmap* __pMagnifierBitmap;
86 Bitmap* __pMagnifierMaskBitmap;
87 _VisualElement* __pRoot;
88 int __handlerCursorPos;
89 FloatRectangle __windowBounds;
94 _EditCopyPasteMagnifier::_EditCopyPasteMagnifier(_EditCopyPasteManager* pCopyPasteManager, int handlerCursorPos)
95 : __pCopyPasteManager(pCopyPasteManager)
96 , __pMagnifierBitmap(null)
97 , __pMagnifierMaskBitmap(null)
99 , __handlerCursorPos(handlerCursorPos)
100 , __windowBounds(0.0f, 0.0f, 0.0f, 0.0f)
105 __pRoot = GetVisualElement();
106 __pRoot->SetSurfaceOpaque(false);
108 GET_BITMAP_CONFIG_N(EDIT::COPY_PASTE_MAGNIFIER, BITMAP_PIXEL_FORMAT_ARGB8888, __pMagnifierBitmap);
109 GET_BITMAP_CONFIG_N(EDIT::COPY_PASTE_MAGNIFIER_MASK, BITMAP_PIXEL_FORMAT_ARGB8888, __pMagnifierMaskBitmap);
112 _EditCopyPasteMagnifier::~_EditCopyPasteMagnifier(void)
114 if (__pMagnifierBitmap)
116 delete __pMagnifierBitmap;
117 __pMagnifierBitmap = null;
119 if (__pMagnifierMaskBitmap)
121 delete __pMagnifierMaskBitmap;
122 __pMagnifierMaskBitmap = null;
127 _EditCopyPasteMagnifier::GetMagnifierBitmap(void) const
129 return __pMagnifierBitmap;
132 _EditCopyPasteMagnifier*
133 _EditCopyPasteMagnifier::CreateInstanceN(const FloatPoint& point, int handlerCursorPos, _EditCopyPasteManager* pCopyPasteManager)
135 _EditCopyPasteMagnifier* pCopyPasteMagnifier = new (std::nothrow) _EditCopyPasteMagnifier(pCopyPasteManager, handlerCursorPos);
136 SysTryReturn(NID_UI_CTRL, pCopyPasteMagnifier != null, null, E_OUT_OF_MEMORY, "pCopyPasteMagnifier is null");
138 FloatPoint cursorPoint(point);
139 FloatRectangle bounds(0.0f, 0.0f, 0.0f, 0.0f);
142 _Edit* pEdit = pCopyPasteManager->GetEdit();
143 _ControlOrientation orientation = pEdit->GetOrientation();
145 Bitmap* pMagnifierBitmap = pCopyPasteMagnifier->GetMagnifierBitmap();
146 SysTryReturn(NID_UI_CTRL, pMagnifierBitmap != null, null, E_OUT_OF_MEMORY, "pMagnifierBitmap is null");
148 result r = pCopyPasteMagnifier->CreateRootVisualElement();
149 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
151 pCopyPasteMagnifier->SetActivationEnabled(false);
153 GET_SHAPE_CONFIG(EDIT::COPYPASTE_MAGNIFIER_WIDTH, orientation, width);
154 GET_SHAPE_CONFIG(EDIT::COPYPASTE_MAGNIFIER_HEIGHT, orientation, height);
156 bounds = FloatRectangle(cursorPoint.x - width/2.0f, cursorPoint.y - height, width, height);
161 pCopyPasteMagnifier->SetBounds(bounds);
162 pCopyPasteMagnifier->Open();
164 return pCopyPasteMagnifier;
167 pCopyPasteMagnifier->Close();
168 delete pCopyPasteMagnifier;
174 _EditCopyPasteMagnifier::OnAttachedToMainTree(void)
176 result r = E_SUCCESS;
178 if (GetOwner() == null)
180 _Edit* pEdit = __pCopyPasteManager->GetEdit();
181 SysTryReturnResult(NID_UI_CTRL, pEdit, GetLastResult(), "Unable to get pEdit.");
183 _EditPresenter* pEditPresenter = pEdit->GetPresenter();
184 SysTryReturnResult(NID_UI_CTRL, pEdit, GetLastResult(), "Unable to get pEditPresenter.");
186 _Form* pParentForm = pEditPresenter->GetParentForm();
189 SetOwner(pParentForm);
194 _Frame* pCurrentFrame = dynamic_cast <_Frame*>(_ControlManager::GetInstance()->GetCurrentFrame());
197 pForm = pCurrentFrame->GetCurrentForm();
204 SetOwner(pCurrentFrame);
214 _EditCopyPasteMagnifier::OnDraw(void)
216 _EcoreEvas* pEcoreEvas = GetEcoreEvasMgr()->GetEcoreEvas();
217 SysTryReturnVoidResult(NID_UI_CTRL, pEcoreEvas, E_INVALID_STATE, "pEcoreEvas is null.");
219 pEcoreEvas->SetWindowBounds(*GetRootWindow(), __windowBounds);
221 Canvas* pCanvas = GetCanvasN();
226 pCanvas->SetBackgroundColor(Color(0, 0, 0, 0));
228 if (_BitmapImpl::CheckNinePatchedBitmapStrictly(*__pMagnifierBitmap))
230 pCanvas->DrawNinePatchedBitmap(pCanvas->GetBoundsF(), *__pMagnifierBitmap);
234 pCanvas->DrawBitmap(pCanvas->GetBoundsF(), *__pMagnifierBitmap);
237 if (_BitmapImpl::CheckNinePatchedBitmapStrictly(*__pMagnifierMaskBitmap))
239 Color editColor = __pCopyPasteManager->GetEdit()->GetColor(EDIT_STATUS_HIGHLIGHTED);
240 if (editColor.GetAlpha() == 0x00)
242 editColor = Color::GetColor(COLOR_ID_WHITE);
245 Bitmap* pReplacedMaskBitmap = _BitmapImpl::GetColorReplacedBitmapN(*__pMagnifierMaskBitmap, Color::GetColor(COLOR_ID_MAGENTA), editColor);
246 SysTryCatch(NID_UI_CTRL, pReplacedMaskBitmap, , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
248 pCanvas->DrawNinePatchedBitmap(pCanvas->GetBoundsF(), *pReplacedMaskBitmap);
250 delete pReplacedMaskBitmap;
254 pCanvas->DrawBitmap(pCanvas->GetBoundsF(), *__pMagnifierMaskBitmap);
257 CaptureTextArea(*pCanvas);
270 _EditCopyPasteMagnifier::CaptureTextArea(Canvas& canvas)
272 result r = E_SUCCESS;
273 float captureWidth = 0.0f;
274 float captureHeight = 0.0f;
275 float capturePosX = 0.0f;
276 float capturePosY = 0.0f;
277 float adjustPosX = 0.0f;
278 float adjustPosY = 0.0f;
279 FloatRectangle cursorBounds(0.0f, 0.0f, 0.0f, 0.0f);
280 FloatRectangle captureBounds(0.0f, 0.0f, 0.0f, 0.0f);
282 _Edit* pEdit = __pCopyPasteManager->GetEdit();
283 SysTryReturnVoidResult(NID_UI_CTRL, pEdit, E_INVALID_STATE, "pEdit is null.");
285 _EditPresenter* pEditPresenter = pEdit->GetPresenter();
286 SysTryReturnVoidResult(NID_UI_CTRL, pEditPresenter, E_INVALID_STATE, "pEditPresenter is null.");
288 pEditPresenter->CalculateCursorBounds(pEditPresenter->GetTextBoundsF(), cursorBounds, __handlerCursorPos);
290 GET_SHAPE_CONFIG(EDIT::COPYPASTE_MAGNIFIER_CAPTURE_WIDTH, pEdit->GetOrientation(), captureWidth);
291 GET_SHAPE_CONFIG(EDIT::COPYPASTE_MAGNIFIER_CAPTURE_HEIGHT, pEdit->GetOrientation(), captureHeight);
292 GET_SHAPE_CONFIG(EDIT::COPYPASTE_MAGNIFIER_CAPTURE_POSITION_X, pEdit->GetOrientation(), capturePosX);
293 GET_SHAPE_CONFIG(EDIT::COPYPASTE_MAGNIFIER_CAPTURE_POSITION_Y, pEdit->GetOrientation(), capturePosY);
295 FloatRectangle textObjectBounds = pEditPresenter->GetTextBoundsF();
297 // textobject minimum width/height
298 if (pEdit->GetBoundsF().width < textObjectBounds.width)
300 textObjectBounds.width = pEdit->GetBoundsF().width - pEdit->GetHorizontalMarginF(EDIT_TEXT_LEFT_MARGIN) - pEdit->GetHorizontalMarginF(EDIT_TEXT_RIGHT_MARGIN);
303 captureBounds.x = cursorBounds.x + cursorBounds.width/2.0f - captureWidth/2.0f;
304 captureBounds.y = cursorBounds.y + cursorBounds.height/2.0f - captureHeight/2.0f;
305 captureBounds.width = captureWidth;
306 captureBounds.height = captureHeight;
307 captureBounds = textObjectBounds.GetIntersection(captureBounds);
309 if ((cursorBounds.x + cursorBounds.width/2.0f) - captureBounds.x < captureWidth/2.0f)
311 adjustPosX = captureWidth/2.0f - (cursorBounds.x + cursorBounds.width/2.0f - captureBounds.x);
314 if (captureBounds.height < captureHeight && captureBounds.y < captureHeight)
316 adjustPosY = captureHeight - captureBounds.height;
319 Bitmap* pOriginalBitmp = pEdit->GetCapturedBitmapN(true);
320 SysTryReturnVoidResult(NID_UI_CTRL, pOriginalBitmp, E_INVALID_STATE, "pOriginalBitmp is null.");
323 r = bitmap.Construct(FloatRectangle(0, 0, captureBounds.width, captureBounds.height));
324 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
326 r = bitmap.Merge(FloatPoint(0.0f, 0.0f), *pOriginalBitmp, CoordinateSystem::AlignToDevice(FloatRectangle(captureBounds.x, captureBounds.y, captureBounds.width, captureBounds.height)));
327 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
329 r = bitmap.SetScalingQuality(BITMAP_SCALING_QUALITY_HIGH);
330 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
332 r = bitmap.Scale(CoordinateSystem::AlignToDevice(FloatDimension(bitmap.GetActualWidth()*1.5f, bitmap.GetActualHeight()*1.5f)));
333 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
335 canvas.DrawBitmap(CoordinateSystem::AlignToDevice(FloatPoint(capturePosX + adjustPosX*1.5f, capturePosY + adjustPosY*1.5f)), bitmap);
337 delete pOriginalBitmp;
342 delete pOriginalBitmp;
348 _EditCopyPasteMagnifier::MoveMagnifier(const FloatPoint& point, int handlerCursorPos)
350 FloatRectangle bounds = FloatRectangle(point.x - GetBoundsF().width/2.0f, point.y - GetBoundsF().height, GetBoundsF().width, GetBoundsF().height);
351 __handlerCursorPos = handlerCursorPos;
361 _EditCopyPasteMagnifier::OnBoundsChanging(const FloatRectangle& bounds)
363 result r = E_SUCCESS;
365 __windowBounds = bounds;
371 _EditCopyPasteMagnifier::OnBoundsChanging(const Rectangle& bounds)
373 result r = E_SUCCESS;
379 _EditCopyPasteMagnifier::SetRowColumnIndex(int rowIndex, int columnIndex)
381 __rowIndex = rowIndex;
382 __columnIndex = columnIndex;
386 * @class _EditCopyPasteHandler
387 * @brief This class defines the common behavior for the %_EditCopyPasteHandler.
390 class _EditCopyPasteHandler
392 , virtual public IEventListener
393 , virtual public _IUiEventListener
394 , virtual public _IUiEventPreviewer
400 * This is the default class constructor.
403 _EditCopyPasteHandler(const Point& point, int handlerCursorPos, _EditCopyPasteManager* pCopyPasteManager, bool singleHandler, bool leftHandler);
404 _EditCopyPasteHandler(const FloatPoint& point, int handlerCursorPos, _EditCopyPasteManager* pCopyPasteManager, bool singleHandler, bool leftHandler);
407 * This is the default class destructor.
410 virtual ~_EditCopyPasteHandler(void);
414 enum HandlerDirection
416 HANDLER_DIRECTION_NONE = 0,
417 HANDLER_DIRECTION_REVERSE_1,//horizontal reverse
418 HANDLER_DIRECTION_REVERSE_2,//vertical reverse
419 HANDLER_DIRECTION_REVERSE_3,//horizontal vertical reverse
422 static _EditCopyPasteHandler* CreateInstanceN(const Point& point, int handlerCursorPos, _EditCopyPasteManager* pCopyPasteManager, bool singleHandler, bool leftHandler = true);
423 static _EditCopyPasteHandler* CreateInstanceN(const FloatPoint& point, int handlerCursorPos, _EditCopyPasteManager* pCopyPasteManager, bool singleHandler, bool leftHandler = true);
424 int GetHandlerCursorPosition(void) const;
425 void GetHandlerRowColumnIndex(int& rowIndex, int& columnIndex) const;
426 void SetHandlerCursorPosition(int handlerCursorPos);
427 void AdjustBounds(void);
428 void CheckReverseStatus(void);
429 void ChangeHandlerBitmap(void);
430 Bitmap* GetHandlerBitmap(void) const;
431 bool CreateCopyPasteMagnifier(void);
432 void DestroyCopyPasteMagnifier(void);
433 void MoveCopyPasteMagnifier(void);
434 void UpdateCopyPasteMagnifier(void);
437 virtual void OnDraw(void);
438 virtual bool OnTouchPressed(const _Control& source, const _TouchInfo& touchinfo);
439 virtual bool OnTouchMoved(const _Control& source, const _TouchInfo& touchinfo);
440 virtual bool OnTouchReleased(const _Control& source, const _TouchInfo& touchinfo);
441 virtual bool IsActivatedOnOpen(void) const;
442 virtual void OnChangeLayout(_ControlOrientation orientation);
443 virtual result OnAttachedToMainTree(void);
445 result OnBoundsChanging(const Rectangle& bounds);
446 result OnBoundsChanging(const FloatRectangle& bounds);
447 result SetWindowBounds(const Rectangle& bounds);
448 result SetWindowBounds(const FloatRectangle& bounds);
451 _EditCopyPasteHandler(const _EditCopyPasteHandler& value);
452 _EditCopyPasteHandler& operator =(const _EditCopyPasteHandler& value);
456 _VisualElement* __pRoot;
457 Bitmap* __pHandlerBitmap;
458 FloatPoint __touchPressedPoint;
459 FloatPoint __absoluteTouchPressedPoint;
460 _EditCopyPasteManager* __pCopyPasteManager;
463 int __handlerCursorPos;
464 bool __isTouchPressed;
465 FloatRectangle __windowBounds;
466 HandlerDirection __handlerDirection;
467 bool __singleHandler;
468 _EditCopyPasteMagnifier* __pCopyPasteMagnifier;
469 bool __isTouchMoving;
472 }; // _EditCopyPasteHandler
475 _EditCopyPasteHandler::GetHandlerBitmap(void) const
477 return __pHandlerBitmap;
481 _EditCopyPasteHandler::CreateCopyPasteMagnifier(void)
483 if (!__pCopyPasteMagnifier)
485 _Edit* pEdit = __pCopyPasteManager->GetEdit();
486 SysTryReturn(NID_UI_CTRL, pEdit, false, E_INVALID_STATE, "[E_INVALID_STATE] pEdit is null.\n");
488 _EditPresenter* pEditPresenter = pEdit->GetPresenter();
489 SysTryReturn(NID_UI_CTRL, pEditPresenter, false, E_INVALID_STATE, "[E_INVALID_STATE] pEditPresenter is null.\n");
491 FloatRectangle cursorBounds(0.0f, 0.0f, 0.0f, 0.0f);
492 if (__rowIndex == -1 && __columnIndex == -1)
494 pEditPresenter->CalculateAbsoluteCursorBounds(__handlerCursorPos, cursorBounds);
498 pEditPresenter->CalculateAbsoluteCursorBounds(__rowIndex, __columnIndex, cursorBounds);
500 __pCopyPasteMagnifier = _EditCopyPasteMagnifier::CreateInstanceN(FloatPoint(cursorBounds.x, cursorBounds.y), __handlerCursorPos, __pCopyPasteManager);
501 SysTryReturn(NID_UI_CTRL, __pCopyPasteMagnifier, false, E_INVALID_STATE, "[E_INVALID_STATE] __pCopyPasteMagnifier is null.\n");
503 __pCopyPasteMagnifier->SetRowColumnIndex(__rowIndex, __columnIndex);
509 _EditCopyPasteHandler::DestroyCopyPasteMagnifier(void)
511 if (__pCopyPasteMagnifier)
513 __pCopyPasteMagnifier->Close();
514 delete __pCopyPasteMagnifier;
515 __pCopyPasteMagnifier = null;
520 _EditCopyPasteHandler::MoveCopyPasteMagnifier(void)
522 if (__pCopyPasteMagnifier)
524 _Edit* pEdit = __pCopyPasteManager->GetEdit();
525 SysTryReturnVoidResult(NID_UI_CTRL, pEdit, E_INVALID_STATE, "pEdit is null.");
527 _EditPresenter* pEditPresenter = pEdit->GetPresenter();
528 SysTryReturnVoidResult(NID_UI_CTRL, pEditPresenter, E_INVALID_STATE, "pEditPresenter is null.");
530 FloatRectangle cursorBounds(0.0f, 0.0f, 0.0f, 0.0f);
531 if (__rowIndex == -1 && __columnIndex == -1)
533 pEditPresenter->CalculateAbsoluteCursorBounds(__handlerCursorPos, cursorBounds);
537 pEditPresenter->CalculateAbsoluteCursorBounds(__rowIndex, __columnIndex, cursorBounds);
538 __pCopyPasteMagnifier->SetRowColumnIndex(__rowIndex, __columnIndex);
540 __pCopyPasteMagnifier->MoveMagnifier(FloatPoint(cursorBounds.x, cursorBounds.y), __handlerCursorPos);
545 _EditCopyPasteHandler::UpdateCopyPasteMagnifier(void)
547 if (__pCopyPasteMagnifier)
549 __pCopyPasteMagnifier->Invalidate();
554 _EditCopyPasteHandler::ChangeHandlerBitmap(void)
556 if (__pHandlerBitmap)
558 delete __pHandlerBitmap;
559 __pHandlerBitmap = null;
563 if (__handlerDirection == HANDLER_DIRECTION_NONE)
565 GET_BITMAP_CONFIG_N(EDIT::COPY_PASTE_ICON_CENTER_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, __pHandlerBitmap);
569 GET_BITMAP_CONFIG_N(EDIT::COPY_PASTE_ICON_REVERSE_CENTER_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, __pHandlerBitmap);
575 switch(__handlerDirection)
577 case HANDLER_DIRECTION_REVERSE_1:
578 GET_BITMAP_CONFIG_N(EDIT::COPY_PASTE_ICON_RIGHT_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, __pHandlerBitmap);
580 case HANDLER_DIRECTION_REVERSE_2:
581 GET_BITMAP_CONFIG_N(EDIT::COPY_PASTE_ICON_REVERSE_LEFT_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, __pHandlerBitmap);
583 case HANDLER_DIRECTION_REVERSE_3:
584 GET_BITMAP_CONFIG_N(EDIT::COPY_PASTE_ICON_REVERSE_RIGHT_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, __pHandlerBitmap);
586 case HANDLER_DIRECTION_NONE:
589 GET_BITMAP_CONFIG_N(EDIT::COPY_PASTE_ICON_LEFT_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, __pHandlerBitmap);
595 switch(__handlerDirection)
597 case HANDLER_DIRECTION_REVERSE_1:
598 GET_BITMAP_CONFIG_N(EDIT::COPY_PASTE_ICON_LEFT_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, __pHandlerBitmap);
600 case HANDLER_DIRECTION_REVERSE_2:
601 GET_BITMAP_CONFIG_N(EDIT::COPY_PASTE_ICON_REVERSE_RIGHT_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, __pHandlerBitmap);
603 case HANDLER_DIRECTION_REVERSE_3:
604 GET_BITMAP_CONFIG_N(EDIT::COPY_PASTE_ICON_REVERSE_LEFT_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, __pHandlerBitmap);
606 case HANDLER_DIRECTION_NONE:
609 GET_BITMAP_CONFIG_N(EDIT::COPY_PASTE_ICON_RIGHT_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, __pHandlerBitmap);
615 _EditCopyPasteHandler::_EditCopyPasteHandler(const Point& point, int handlerCursorPos, _EditCopyPasteManager* pCopyPasteManager, bool singleHandler, bool leftHandler)
617 , __pHandlerBitmap(null)
618 , __touchPressedPoint(0.0f, 0.0f)
619 , __absoluteTouchPressedPoint(0.0f, 0.0f)
620 , __pCopyPasteManager(pCopyPasteManager)
621 , __leftHandler(leftHandler)
622 , __reverseCheck(false)
623 , __handlerCursorPos(handlerCursorPos)
624 , __isTouchPressed(false)
625 , __windowBounds(0.0f, 0.0f, 0.0f, 0.0f)
626 , __handlerDirection(HANDLER_DIRECTION_NONE)
627 , __singleHandler(false)
628 , __pCopyPasteMagnifier(null)
629 , __isTouchMoving(false)
635 __pRoot = GetVisualElement();
636 __pRoot->SetSurfaceOpaque(false);
638 Point handlerPoint(point);
642 GET_BITMAP_CONFIG_N(EDIT::COPY_PASTE_ICON_CENTER_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, __pHandlerBitmap);
643 handlerPoint.x = handlerPoint.x - (__pHandlerBitmap->GetWidth() / 2);
644 __singleHandler = true;
650 GET_BITMAP_CONFIG_N(EDIT::COPY_PASTE_ICON_LEFT_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, __pHandlerBitmap);
651 handlerPoint.x = handlerPoint.x - __pHandlerBitmap->GetWidth();
655 GET_BITMAP_CONFIG_N(EDIT::COPY_PASTE_ICON_RIGHT_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, __pHandlerBitmap);
659 FloatRectangle bounds(handlerPoint.x, handlerPoint.y, __pHandlerBitmap->GetWidth(), __pHandlerBitmap->GetHeight());
662 _EditCopyPasteHandler::_EditCopyPasteHandler(const FloatPoint& point, int handlerCursorPos, _EditCopyPasteManager* pCopyPasteManager, bool singleHandler, bool leftHandler)
664 , __pHandlerBitmap(null)
665 , __touchPressedPoint(0.0f, 0.0f)
666 , __absoluteTouchPressedPoint(0.0f, 0.0f)
667 , __pCopyPasteManager(pCopyPasteManager)
668 , __leftHandler(leftHandler)
669 , __reverseCheck(false)
670 , __handlerCursorPos(handlerCursorPos)
671 , __isTouchPressed(false)
672 , __windowBounds(0.0f, 0.0f, 0.0f, 0.0f)
673 , __handlerDirection(HANDLER_DIRECTION_NONE)
674 , __singleHandler(false)
675 , __pCopyPasteMagnifier(null)
676 , __isTouchMoving(false)
682 __pRoot = GetVisualElement();
683 __pRoot->SetSurfaceOpaque(false);
686 //Point handlerPoint(_CoordinateSystemUtils::ConvertToInteger(point));
687 FloatPoint handlerPoint(point);
690 GET_BITMAP_CONFIG_N(EDIT::COPY_PASTE_ICON_CENTER_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, __pHandlerBitmap);
691 handlerPoint.x = handlerPoint.x - (__pHandlerBitmap->GetWidthF() / 2.0f);
692 __singleHandler = true;
698 GET_BITMAP_CONFIG_N(EDIT::COPY_PASTE_ICON_LEFT_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, __pHandlerBitmap);
699 handlerPoint.x = handlerPoint.x - __pHandlerBitmap->GetWidthF();
703 GET_BITMAP_CONFIG_N(EDIT::COPY_PASTE_ICON_RIGHT_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, __pHandlerBitmap);
707 FloatRectangle bounds(handlerPoint.x, handlerPoint.y, _CoordinateSystemUtils::ConvertToFloat(__pHandlerBitmap->GetWidth()), _CoordinateSystemUtils::ConvertToFloat(__pHandlerBitmap->GetHeight()));
710 _EditCopyPasteHandler::~_EditCopyPasteHandler(void)
712 DestroyCopyPasteMagnifier();
714 if (__pHandlerBitmap)
716 delete __pHandlerBitmap;
717 __pHandlerBitmap = null;
721 _EditCopyPasteHandler*
722 _EditCopyPasteHandler::CreateInstanceN(const Point& point, int handlerCursorPos, _EditCopyPasteManager* pCopyPasteManager, bool singleHandler, bool leftHandler)
724 _EditCopyPasteHandler* pCopyPasteHandler = new (std::nothrow) _EditCopyPasteHandler(point, handlerCursorPos, pCopyPasteManager, singleHandler, leftHandler);
725 SysTryReturn(NID_UI_CTRL, pCopyPasteHandler != null, null, E_OUT_OF_MEMORY, "pContextMenu is null");
727 Point handlerPoint(point);
728 Rectangle bounds(0, 0, 0, 0);
729 Bitmap* pHandlerBitmap = pCopyPasteHandler->GetHandlerBitmap();
731 result r = pCopyPasteHandler->CreateRootVisualElement();
732 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
734 pCopyPasteHandler->SetActivationEnabled(false);
738 handlerPoint.x = handlerPoint.x - (pHandlerBitmap->GetWidth() / 2);
744 handlerPoint.x = handlerPoint.x - pHandlerBitmap->GetWidth();
748 bounds.x = handlerPoint.x;
749 bounds.y = handlerPoint.y;
750 bounds.width = pHandlerBitmap->GetWidth();
751 bounds.height = pHandlerBitmap->GetHeight();
753 pCopyPasteHandler->SetBounds(bounds);
754 pCopyPasteHandler->CheckReverseStatus();
755 pCopyPasteHandler->Open(false);
757 return pCopyPasteHandler;
760 pCopyPasteHandler->Close();
761 delete pCopyPasteHandler;
766 _EditCopyPasteHandler*
767 _EditCopyPasteHandler::CreateInstanceN(const FloatPoint& point, int handlerCursorPos, _EditCopyPasteManager* pCopyPasteManager, bool singleHandler, bool leftHandler)
769 _EditCopyPasteHandler* pCopyPasteHandler = new (std::nothrow) _EditCopyPasteHandler(point, handlerCursorPos, pCopyPasteManager, singleHandler, leftHandler);
770 SysTryReturn(NID_UI_CTRL, pCopyPasteHandler != null, null, E_OUT_OF_MEMORY, "pContextMenu is null");
772 FloatPoint handlerPoint(point);
773 FloatRectangle bounds(0.0f, 0.0f, 0.0f, 0.0f);
774 Bitmap* pHandlerBitmap = pCopyPasteHandler->GetHandlerBitmap();
776 result r = pCopyPasteHandler->CreateRootVisualElement();
777 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
779 pCopyPasteHandler->SetActivationEnabled(false);
783 handlerPoint.x = handlerPoint.x - (pHandlerBitmap->GetWidthF() / 2.0f);
789 handlerPoint.x = handlerPoint.x - pHandlerBitmap->GetWidthF();
793 bounds.x = handlerPoint.x;
794 bounds.y = handlerPoint.y;
795 bounds.width = pHandlerBitmap->GetWidthF();
796 bounds.height = pHandlerBitmap->GetHeightF();
798 pCopyPasteHandler->SetBounds(bounds);
799 pCopyPasteHandler->CheckReverseStatus();
800 pCopyPasteHandler->Open(false);
802 return pCopyPasteHandler;
805 pCopyPasteHandler->Close();
806 delete pCopyPasteHandler;
812 _EditCopyPasteHandler::GetHandlerCursorPosition(void) const
814 return __handlerCursorPos;
818 _EditCopyPasteHandler::GetHandlerRowColumnIndex(int& rowIndex, int& columnIndex) const
820 rowIndex = __rowIndex;
821 columnIndex = __columnIndex;
825 _EditCopyPasteHandler::SetHandlerCursorPosition(int handlerCursorPos)
827 __handlerCursorPos = handlerCursorPos;
831 _EditCopyPasteHandler::AdjustBounds(void)
833 FloatRectangle cursorRect;
834 FloatRectangle rect = GetBoundsF();
835 FloatPoint checkPoint(0.0f, 0.0f);
836 _Edit* pEdit = __pCopyPasteManager->GetEdit();
837 _EditPresenter* pEditPresenter = pEdit->GetPresenter();
841 if (__rowIndex == -1 && __columnIndex == -1)
843 pEditPresenter->CalculateAbsoluteCursorBounds(__handlerCursorPos, cursorRect);
847 pEditPresenter->CalculateAbsoluteCursorBounds(__rowIndex, __columnIndex, cursorRect);
849 rect.x = cursorRect.x - __pHandlerBitmap->GetWidthF()/2.0f;
850 rect.y = cursorRect.y + cursorRect.height;
851 checkPoint = FloatPoint(cursorRect.x , cursorRect.y + cursorRect.height);
852 if (__handlerDirection == HANDLER_DIRECTION_REVERSE_2)
854 rect.y -= (cursorRect.height + __pHandlerBitmap->GetHeightF());
859 if (__rowIndex == -1 && __columnIndex == -1)
861 pEditPresenter->CalculateAbsoluteCursorBounds(__handlerCursorPos, cursorRect);
865 pEditPresenter->CalculateAbsoluteCursorBounds(__rowIndex, __columnIndex, cursorRect);
868 rect.x = cursorRect.x;
869 rect.y = cursorRect.y + cursorRect.height;
871 checkPoint = FloatPoint(cursorRect.x, cursorRect.y + cursorRect.height);
875 if (__handlerDirection == HANDLER_DIRECTION_NONE)
877 rect.x = rect.x - __pHandlerBitmap->GetWidthF();
879 else if (__handlerDirection == HANDLER_DIRECTION_REVERSE_2)
881 rect.x = rect.x - __pHandlerBitmap->GetWidthF();
882 rect.y -= (rect.height + cursorRect.height);
884 else if (__handlerDirection == HANDLER_DIRECTION_REVERSE_3)
886 rect.y -= (rect.height + cursorRect.height);
891 if (__handlerDirection == HANDLER_DIRECTION_REVERSE_1)
893 rect.x = rect.x - __pHandlerBitmap->GetWidthF();
895 else if (__handlerDirection == HANDLER_DIRECTION_REVERSE_2)
897 rect.y -= (rect.height + cursorRect.height);
899 else if (__handlerDirection == HANDLER_DIRECTION_REVERSE_3)
901 rect.x = rect.x - __pHandlerBitmap->GetWidthF();
902 rect.y -= (rect.height + cursorRect.height);
907 if (!__isTouchMoving)
909 bool visibleState = __pCopyPasteManager->CheckHandleBounds(checkPoint);
910 if (visibleState && !GetVisibleState())
912 SetVisibleState(true);
915 else if (!visibleState && GetVisibleState())
917 SetVisibleState(false);
927 _EditCopyPasteHandler::OnDraw(void)
929 Canvas* pCanvas = GetCanvasN();
934 pCanvas->SetBackgroundColor(Color(0, 0, 0, 0));
936 if (_BitmapImpl::CheckNinePatchedBitmapStrictly(*__pHandlerBitmap))
938 pCanvas->DrawNinePatchedBitmap(pCanvas->GetBoundsF(), *__pHandlerBitmap);
942 pCanvas->DrawBitmap(pCanvas->GetBoundsF(), *__pHandlerBitmap);
949 SetWindowBounds(__windowBounds);
950 __reverseCheck = false;
954 SetWindowBounds(__windowBounds);
959 _EditCopyPasteHandler::OnTouchPressed(const _Control& source, const _TouchInfo& touchinfo)
961 __pCopyPasteManager->ReleaseCopyPastePopup();
962 #if EDIT_COPY_PASTE_MAGNIFIER
963 CreateCopyPasteMagnifier();
965 __touchPressedPoint = touchinfo.GetCurrentPosition();
966 __absoluteTouchPressedPoint = FloatPoint(GetBoundsF().x + __touchPressedPoint.x, GetBoundsF().y + __touchPressedPoint.y);
967 __isTouchPressed = true;
973 _EditCopyPasteHandler::CheckReverseStatus(void)
975 FloatDimension screenSize;
976 _ControlManager* pControlManager = _ControlManager::GetInstance();
977 _Edit* pEdit = __pCopyPasteManager->GetEdit();
978 _ControlOrientation orientation = pEdit->GetOrientation();
979 FloatRectangle rect = GetBoundsF();
980 FloatRectangle cursorAbsBounds = __pCopyPasteManager->GetCursorBoundsF(true);
981 float clipboardHeight = 0.0f;
982 FloatRectangle keypadBounds(0.0f, 0.0f, 0.0f, 0.0f);
983 float adjustHeight = 0.0f;
985 _EditPresenter* pEditPresenter = pEdit->GetPresenter();
986 SysTryReturnVoidResult(NID_UI_CTRL, pEditPresenter, E_INVALID_STATE, "pEditPresenter is null.\n");
988 clipboardHeight = pEditPresenter->GetClipboardHeight();
989 pEditPresenter->GetKeypadBoundsEx(keypadBounds);
990 if (clipboardHeight > keypadBounds.height)
992 adjustHeight = clipboardHeight;
996 adjustHeight = keypadBounds.height;
999 if (orientation == _CONTROL_ORIENTATION_PORTRAIT)
1001 screenSize = pControlManager->GetScreenSizeF();
1005 screenSize.width = pControlManager->GetScreenSizeF().height;
1006 screenSize.height = pControlManager->GetScreenSizeF().width;
1008 if (adjustHeight > 0.0f)
1010 screenSize.height -= adjustHeight;
1013 if (__singleHandler)
1015 if ((__handlerDirection == HANDLER_DIRECTION_NONE) && ((cursorAbsBounds.y + cursorAbsBounds.height + rect.height) > screenSize.height))
1017 __handlerDirection = HANDLER_DIRECTION_REVERSE_2;
1018 rect.y -= (cursorAbsBounds.height + rect.height);
1019 __reverseCheck = true;
1021 else if ((__handlerDirection == HANDLER_DIRECTION_REVERSE_2) && ((cursorAbsBounds.y + cursorAbsBounds.height + rect.height) <= screenSize.height))
1023 __handlerDirection = HANDLER_DIRECTION_NONE;
1024 rect.y += (cursorAbsBounds.height + rect.height);
1025 __reverseCheck = true;
1027 ChangeHandlerBitmap();
1034 if (((__handlerDirection == HANDLER_DIRECTION_NONE) || (__handlerDirection == HANDLER_DIRECTION_REVERSE_2)) && rect.x < 0.0f)
1036 if ((__handlerDirection == HANDLER_DIRECTION_NONE) && ((rect.y + rect.height) > screenSize.height))
1038 __handlerDirection = HANDLER_DIRECTION_REVERSE_3;
1039 rect.y -= (rect.height + cursorAbsBounds.height);
1041 else if ((__handlerDirection == HANDLER_DIRECTION_NONE) && ((rect.y + rect.height) <= screenSize.height))
1043 __handlerDirection = HANDLER_DIRECTION_REVERSE_1;
1045 else if ((__handlerDirection == HANDLER_DIRECTION_REVERSE_2) && ((rect.y + 2*rect.height) > screenSize.height))
1047 __handlerDirection = HANDLER_DIRECTION_REVERSE_3;
1049 else if ((__handlerDirection == HANDLER_DIRECTION_REVERSE_2) && ((rect.y + 2*rect.height) <= screenSize.height))
1051 __handlerDirection = HANDLER_DIRECTION_REVERSE_1;
1052 rect.y += (rect.height + cursorAbsBounds.height);
1054 ChangeHandlerBitmap();
1055 rect.x += rect.width;
1056 __reverseCheck = true;
1058 else if (((__handlerDirection == HANDLER_DIRECTION_REVERSE_1) || (__handlerDirection == HANDLER_DIRECTION_REVERSE_3)) && rect.x >= rect.width)
1060 if ((__handlerDirection == HANDLER_DIRECTION_REVERSE_1) && ((rect.y + rect.height) > screenSize.height))
1062 __handlerDirection = HANDLER_DIRECTION_REVERSE_2;
1063 rect.y -= (rect.height + cursorAbsBounds.height);
1065 else if ((__handlerDirection == HANDLER_DIRECTION_REVERSE_1) && ((rect.y + rect.height) <= screenSize.height))
1067 __handlerDirection = HANDLER_DIRECTION_NONE;
1069 else if ((__handlerDirection == HANDLER_DIRECTION_REVERSE_3) && ((rect.y + 2*rect.height) > screenSize.height))
1071 __handlerDirection = HANDLER_DIRECTION_REVERSE_2;
1073 else if ((__handlerDirection == HANDLER_DIRECTION_REVERSE_3) && ((rect.y + 2*rect.height) <= screenSize.height))
1075 __handlerDirection = HANDLER_DIRECTION_NONE;
1076 rect.y += (rect.height + cursorAbsBounds.height);
1078 ChangeHandlerBitmap();
1079 rect.x -= rect.width;
1080 __reverseCheck = true;
1082 else if (((__handlerDirection == HANDLER_DIRECTION_NONE) || (__handlerDirection == HANDLER_DIRECTION_REVERSE_1)) && ((rect.y + rect.height) > screenSize.height))
1084 if ((__handlerDirection == HANDLER_DIRECTION_NONE) && rect.x < rect.width)
1086 __handlerDirection = HANDLER_DIRECTION_REVERSE_3;
1087 rect.x += rect.width;
1089 else if ((__handlerDirection == HANDLER_DIRECTION_NONE) && rect.x >= rect.width)
1091 __handlerDirection = HANDLER_DIRECTION_REVERSE_2;
1093 else if ((__handlerDirection == HANDLER_DIRECTION_REVERSE_1) && ((rect.x - rect.width) >= 0.0f))
1095 __handlerDirection = HANDLER_DIRECTION_REVERSE_2;
1096 rect.x -= rect.width;
1098 else if ((__handlerDirection == HANDLER_DIRECTION_REVERSE_1) && ((rect.x - rect.width) < 0.0f))
1100 __handlerDirection = HANDLER_DIRECTION_REVERSE_3;
1102 rect.y -= (rect.height + cursorAbsBounds.height);
1103 ChangeHandlerBitmap();
1104 __reverseCheck = true;
1106 else if (((__handlerDirection == HANDLER_DIRECTION_REVERSE_2) || (__handlerDirection == HANDLER_DIRECTION_REVERSE_3)) && ((rect.y + 2*rect.height + cursorAbsBounds.height) <= screenSize.height))
1108 if ((__handlerDirection == HANDLER_DIRECTION_REVERSE_2) && rect.x < 0.0f)
1110 __handlerDirection = HANDLER_DIRECTION_REVERSE_1;
1111 rect.x += rect.width;
1113 else if ((__handlerDirection == HANDLER_DIRECTION_REVERSE_2) && rect.x >= rect.width)
1115 __handlerDirection = HANDLER_DIRECTION_NONE;
1117 else if ((__handlerDirection == HANDLER_DIRECTION_REVERSE_3) && ((rect.x - rect.width) >= 0.0f))
1119 __handlerDirection = HANDLER_DIRECTION_NONE;
1120 rect.x -= rect.width;
1122 else if ((__handlerDirection == HANDLER_DIRECTION_REVERSE_3) && ((rect.x - rect.width) < 0.0f))
1124 __handlerDirection = HANDLER_DIRECTION_REVERSE_1;
1126 rect.y += (rect.height + cursorAbsBounds.height);
1127 ChangeHandlerBitmap();
1128 __reverseCheck = true;
1133 if (((__handlerDirection == HANDLER_DIRECTION_NONE) || (__handlerDirection == HANDLER_DIRECTION_REVERSE_2)) && (rect.x + rect.width) > screenSize.width)
1135 if ((__handlerDirection == HANDLER_DIRECTION_NONE) && ((rect.y + rect.height) > screenSize.height))
1137 __handlerDirection = HANDLER_DIRECTION_REVERSE_3;
1138 rect.y -= (rect.height + cursorAbsBounds.height);
1140 else if ((__handlerDirection == HANDLER_DIRECTION_NONE) && ((rect.y + rect.height) <= screenSize.height))
1142 __handlerDirection = HANDLER_DIRECTION_REVERSE_1;
1144 else if ((__handlerDirection == HANDLER_DIRECTION_REVERSE_2) && ((rect.y + 2*rect.height) > screenSize.height))
1146 __handlerDirection = HANDLER_DIRECTION_REVERSE_3;
1148 else if ((__handlerDirection == HANDLER_DIRECTION_REVERSE_2) && ((rect.y + 2*rect.height) <= screenSize.height))
1150 __handlerDirection = HANDLER_DIRECTION_REVERSE_1;
1151 rect.y += (rect.height + cursorAbsBounds.height);
1153 ChangeHandlerBitmap();
1154 rect.x -= rect.width;
1155 __reverseCheck = true;
1157 else if (((__handlerDirection == HANDLER_DIRECTION_REVERSE_1) || (__handlerDirection == HANDLER_DIRECTION_REVERSE_3)) && (rect.x + 2*rect.width) <= screenSize.width)
1159 if ((__handlerDirection == HANDLER_DIRECTION_REVERSE_1) && ((rect.y + rect.height) > screenSize.height))
1161 __handlerDirection = HANDLER_DIRECTION_REVERSE_2;
1162 rect.y -= (rect.height + cursorAbsBounds.height);
1164 else if ((__handlerDirection == HANDLER_DIRECTION_REVERSE_1) && ((rect.y + rect.height) <= screenSize.height))
1166 __handlerDirection = HANDLER_DIRECTION_NONE;
1168 else if ((__handlerDirection == HANDLER_DIRECTION_REVERSE_3) && ((rect.y + 2*rect.height) > screenSize.height))
1170 __handlerDirection = HANDLER_DIRECTION_REVERSE_2;
1172 else if ((__handlerDirection == HANDLER_DIRECTION_REVERSE_3) && ((rect.y + 2*rect.height) <= screenSize.height))
1174 __handlerDirection = HANDLER_DIRECTION_NONE;
1175 rect.y += (rect.height + cursorAbsBounds.height);
1177 ChangeHandlerBitmap();
1178 rect.x += rect.width;
1179 __reverseCheck = true;
1181 else if (((__handlerDirection == HANDLER_DIRECTION_NONE) || (__handlerDirection == HANDLER_DIRECTION_REVERSE_1)) && ((rect.y + rect.height) > screenSize.height))
1183 if ((__handlerDirection == HANDLER_DIRECTION_NONE) && (rect.x + rect.width) > screenSize.width)
1185 __handlerDirection = HANDLER_DIRECTION_REVERSE_3;
1186 rect.x -= rect.width;
1188 else if ((__handlerDirection == HANDLER_DIRECTION_NONE) && (rect.x + rect.width) <= screenSize.width)
1190 __handlerDirection = HANDLER_DIRECTION_REVERSE_2;
1192 else if ((__handlerDirection == HANDLER_DIRECTION_REVERSE_1) && (rect.x + 2*rect.width) <= screenSize.width)
1194 __handlerDirection = HANDLER_DIRECTION_REVERSE_2;
1195 rect.x += rect.width;
1197 else if ((__handlerDirection == HANDLER_DIRECTION_REVERSE_1) && (rect.x + 2*rect.width) > screenSize.width)
1199 __handlerDirection = HANDLER_DIRECTION_REVERSE_3;
1201 rect.y -= (rect.height + cursorAbsBounds.height);
1202 ChangeHandlerBitmap();
1203 __reverseCheck = true;
1205 else if (((__handlerDirection == HANDLER_DIRECTION_REVERSE_2) || (__handlerDirection == HANDLER_DIRECTION_REVERSE_3)) && ((rect.y + 2*rect.height + cursorAbsBounds.height) <= screenSize.height))
1207 if ((__handlerDirection == HANDLER_DIRECTION_REVERSE_2) && ((rect.x + rect.width) <= screenSize.width))
1209 __handlerDirection = HANDLER_DIRECTION_NONE;
1211 else if ((__handlerDirection == HANDLER_DIRECTION_REVERSE_2) && ((rect.x + rect.width) > screenSize.width))
1213 __handlerDirection = HANDLER_DIRECTION_REVERSE_1;
1214 rect.x -= rect.width;
1216 else if ((__handlerDirection == HANDLER_DIRECTION_REVERSE_3) && ((rect.x + 2*rect.width) <= screenSize.width))
1218 __handlerDirection = HANDLER_DIRECTION_NONE;
1219 rect.x += rect.width;
1221 else if ((__handlerDirection == HANDLER_DIRECTION_REVERSE_3) && ((rect.x + 2*rect.width) > screenSize.width))
1223 __handlerDirection = HANDLER_DIRECTION_REVERSE_1;
1225 rect.y += (rect.height + cursorAbsBounds.height);
1226 ChangeHandlerBitmap();
1227 __reverseCheck = true;
1235 _EditCopyPasteHandler::OnTouchReleased(const _Control& source, const _TouchInfo& touchinfo)
1237 CheckReverseStatus();
1238 __isTouchPressed = false;
1239 __absoluteTouchPressedPoint = FloatPoint(0.0f, 0.0f);
1240 DestroyCopyPasteMagnifier();
1241 __pCopyPasteManager->CreateCopyPastePopup();
1242 __pCopyPasteManager->Show();
1243 __pCopyPasteManager->SendTextBlockEvent();
1245 __isTouchMoving = false;
1250 _EditCopyPasteHandler::OnTouchMoved(const _Control& source, const _TouchInfo& touchinfo)
1253 FloatRectangle cursorRect(0.0f, 0.0f, 0.0f, 0.0f);
1254 FloatRectangle absCursorRect(0.0f, 0.0f, 0.0f, 0.0f);
1255 FloatRectangle rect = GetBoundsF();
1256 FloatPoint point = touchinfo.GetCurrentPosition();
1257 FloatPoint touchPoint(0.0f, 0.0f);
1258 FloatPoint checkPoint(0.0f, 0.0f);
1259 __isTouchMoving = true;
1261 _Edit* pEdit = __pCopyPasteManager->GetEdit();
1262 SysTryReturn(NID_UI_CTRL, pEdit, false, E_INVALID_STATE, "[E_INVALID_STATE] pEdit is null.\n");
1264 _EditPresenter* pEditPresenter = pEdit->GetPresenter();
1265 SysTryReturn(NID_UI_CTRL, pEditPresenter, false, E_INVALID_STATE, "[E_INVALID_STATE] pEditPresenter is null.\n");
1267 TextObject* pTextObject = pEditPresenter->GetTextObject();
1268 SysTryReturn(NID_UI_CTRL, pTextObject, false, E_INVALID_STATE, "[E_INVALID_STATE] pEditPresenter is null.\n");
1270 int curCursorLine = pTextObject->GetLineIndexAtTextIndex(__handlerCursorPos);
1271 int totalLine = pTextObject->GetTotalLineCount();
1273 float totalHeight = pTextObject->GetTotalHeightF();
1274 float firstDisplayY = pTextObject->GetFirstDisplayPositionYF();
1275 FloatRectangle absTextObjectBounds(0.0f, 0.0f, 0.0f, 0.0f);
1276 FloatRectangle textObjectBounds = pEditPresenter->GetTextBoundsF();
1277 FloatRectangle absEditBounds = pEdit->GetAbsoluteBoundsF();
1278 absTextObjectBounds.x = absEditBounds.x + textObjectBounds.x;
1279 absTextObjectBounds.y = absEditBounds.y + textObjectBounds.y;
1280 absTextObjectBounds.width = textObjectBounds.width;
1281 absTextObjectBounds.height = textObjectBounds.height;
1282 if (__touchPressedPoint.x == point.x && __touchPressedPoint.y == point.y)
1287 if (__rowIndex == -1 && __columnIndex == -1)
1289 pEditPresenter->CalculateCursorBounds(pEditPresenter->GetTextBoundsF(), cursorRect,__handlerCursorPos);
1290 pEditPresenter->CalculateAbsoluteCursorBounds(__handlerCursorPos, absCursorRect);
1294 pEditPresenter->CalculateCursorBounds(pEditPresenter->GetTextBoundsF(), cursorRect, __rowIndex, __columnIndex);
1295 pEditPresenter->CalculateAbsoluteCursorBounds(__rowIndex, __columnIndex, absCursorRect);
1298 FloatPoint absoluteTouchMovedPoint = FloatPoint(GetBoundsF().x + point.x, GetBoundsF().y + point.y);
1299 //Calculate handler's position
1300 if (__singleHandler)
1302 touchPoint.x = absoluteTouchMovedPoint.x;
1303 if (__handlerDirection == HANDLER_DIRECTION_NONE)
1305 touchPoint.y = absoluteTouchMovedPoint.y - GetBoundsF().height/2.0f;
1307 else // HANDLER_DIRECTION_REVERSE_2
1309 touchPoint.y = absoluteTouchMovedPoint.y + GetBoundsF().height/2.0f;
1316 if (__handlerDirection == HANDLER_DIRECTION_NONE)
1318 touchPoint.x = absoluteTouchMovedPoint.x + GetBoundsF().width/2.0f;
1319 touchPoint.y = absoluteTouchMovedPoint.y - GetBoundsF().height/2.0f;
1321 else if (__handlerDirection == HANDLER_DIRECTION_REVERSE_1)
1323 touchPoint.x = absoluteTouchMovedPoint.x - GetBoundsF().width/2.0f;
1324 touchPoint.y = absoluteTouchMovedPoint.y - GetBoundsF().height/2.0f;
1326 else if (__handlerDirection == HANDLER_DIRECTION_REVERSE_2)
1328 touchPoint.x = absoluteTouchMovedPoint.x + GetBoundsF().width/2.0f;
1329 touchPoint.y = absoluteTouchMovedPoint.y + GetBoundsF().height/2.0f;
1331 else if (__handlerDirection == HANDLER_DIRECTION_REVERSE_3)
1333 touchPoint.x = absoluteTouchMovedPoint.x - GetBoundsF().width/2.0f;
1334 touchPoint.y = absoluteTouchMovedPoint.y + GetBoundsF().height/2.0f;
1339 if (__handlerDirection == HANDLER_DIRECTION_NONE)
1341 touchPoint.x = absoluteTouchMovedPoint.x - GetBoundsF().width/2.0f;
1342 touchPoint.y = absoluteTouchMovedPoint.y - GetBoundsF().height/2.0f;
1344 else if (__handlerDirection == HANDLER_DIRECTION_REVERSE_1)
1346 touchPoint.x = absoluteTouchMovedPoint.x + GetBoundsF().width/2.0f;
1347 touchPoint.y = absoluteTouchMovedPoint.y - GetBoundsF().height/2.0f;
1349 else if (__handlerDirection == HANDLER_DIRECTION_REVERSE_2)
1351 touchPoint.x = absoluteTouchMovedPoint.x - GetBoundsF().width/2.0f;
1352 touchPoint.y = absoluteTouchMovedPoint.y + GetBoundsF().height/2.0f;
1354 else if (__handlerDirection == HANDLER_DIRECTION_REVERSE_3)
1356 touchPoint.x = absoluteTouchMovedPoint.x + GetBoundsF().width/2.0f;
1357 touchPoint.y = absoluteTouchMovedPoint.y + GetBoundsF().height/2.0f;
1361 if (totalHeight - firstDisplayY < absTextObjectBounds.height)
1363 absTextObjectBounds.height = totalHeight - firstDisplayY - 1.0f; // check TextObject
1366 if (totalLine != 1) //single line edit doesn't need to adjust horizontal value.
1368 if (absTextObjectBounds.x > touchPoint.x)
1370 touchPoint.x = absTextObjectBounds.x;
1372 if (absTextObjectBounds.x + absTextObjectBounds.width <= touchPoint.x) // check FloatRectangle Contains?
1374 touchPoint.x = absTextObjectBounds.x + absTextObjectBounds.width - 1.0f;
1377 if (absTextObjectBounds.y > touchPoint.y)
1379 if (totalLine == 1 || firstDisplayY == 0.0f) // whether need to scroll the text or not
1381 touchPoint.y = absTextObjectBounds.y; //not need to scroll the text.
1384 if (absTextObjectBounds.y + absTextObjectBounds.height < touchPoint.y)
1386 if (totalLine == 1 || (totalHeight - firstDisplayY < textObjectBounds.height) || curCursorLine == (totalLine - 1)) // || pTextObject->IsDisplayedLastLine()) // whether need to scroll the text or not
1388 touchPoint.y = absTextObjectBounds.y + absTextObjectBounds.height - 1.0f; // check TextObject
1392 if (!__singleHandler)
1394 int nextHandlerLine = -1;
1397 nextHandlerLine = pTextObject->GetLineIndexAtTextIndex(__pCopyPasteManager->GetHandlerCursorPosition(Tizen::Ui::Controls::_EditCopyPasteManager::HANDLER_TYPE_RIGHT));
1401 nextHandlerLine = pTextObject->GetLineIndexAtTextIndex(__pCopyPasteManager->GetHandlerCursorPosition(Tizen::Ui::Controls::_EditCopyPasteManager::HANDLER_TYPE_LEFT));
1404 if (curCursorLine == nextHandlerLine)
1406 if (__leftHandler && absoluteTouchMovedPoint.y >= absCursorRect.y + absCursorRect.height)
1408 touchPoint.y = absCursorRect.y + absCursorRect.height/2.0f;
1410 else if (!__leftHandler && absoluteTouchMovedPoint.y <= absCursorRect.y + absCursorRect.height)
1412 touchPoint.y = absCursorRect.y + absCursorRect.height/2.0f;
1417 touchPoint.x = touchPoint.x - absEditBounds.x - textObjectBounds.x;
1418 touchPoint.y = touchPoint.y - absEditBounds.y - textObjectBounds.y;
1420 if (Math::Abs(touchPoint.y) < 1)
1422 touchPoint.y = 0.0f;
1426 int columnIndex = -1;
1427 cursorPos = pTextObject->GetTextIndexFromPosition(touchPoint.x, touchPoint.y, rowIndex, columnIndex, true);
1429 if (__handlerCursorPos == cursorPos)
1434 if (cursorPos == -1)
1439 if (absoluteTouchMovedPoint.y > (absCursorRect.y + absCursorRect.height))
1441 if (curCursorLine < totalLine - 1)
1443 int offset = __handlerCursorPos - pTextObject->GetFirstTextIndexAt(curCursorLine);
1444 int firstTextIndex = pTextObject->GetFirstTextIndexAt(curCursorLine+1);
1445 cursorPos = offset + firstTextIndex;
1446 int textLength = pTextObject->GetTextLengthAt(curCursorLine+1);
1447 if (offset > textLength)
1449 cursorPos = firstTextIndex+textLength;
1455 if (curCursorLine !=0)
1457 if (__rowIndex == 0)
1461 int offset = __handlerCursorPos - pTextObject->GetFirstTextIndexAt(curCursorLine);
1462 int firstTextIndex = pTextObject->GetFirstTextIndexAt(curCursorLine-1);
1463 cursorPos = offset + firstTextIndex;
1464 int textLength = pTextObject->GetTextLengthAt(curCursorLine-1);
1465 if (offset > textLength)
1467 cursorPos = firstTextIndex+textLength;
1472 if (cursorPos == -1)
1478 if (__handlerCursorPos == cursorPos)
1482 if (!__singleHandler)
1484 if (!__pCopyPasteManager->CheckHandlePosition(__leftHandler, cursorPos))
1488 _EditCopyPasteManager::HandlerType nextHandlerType = _EditCopyPasteManager::HANDLER_TYPE_MAX;
1491 nextHandlerType = _EditCopyPasteManager::HANDLER_TYPE_RIGHT;
1495 nextHandlerType = _EditCopyPasteManager::HANDLER_TYPE_LEFT;
1497 int nextHandler = __pCopyPasteManager->GetHandlerCursorPosition(nextHandlerType);
1498 if (Math::Abs(nextHandler - __handlerCursorPos) <= 1)
1500 pTextObject->SetFirstDisplayLineIndexFromTextIndex(nextHandler);
1507 if (rowIndex > -1 && columnIndex > -1)
1509 __rowIndex = rowIndex;
1510 __columnIndex = columnIndex;
1518 pTextObject->SetFirstDisplayLineIndexFromTextIndex(cursorPos);
1520 __handlerCursorPos = cursorPos;
1521 __pCopyPasteManager->SetCursorPosition(__handlerCursorPos);
1522 pEditPresenter->ScrollPanelToCursorPosition(true);
1524 if (!__singleHandler)
1526 __pCopyPasteManager->RefreshBlock(__leftHandler);
1530 if (__rowIndex == -1 && __columnIndex == -1)
1532 __pCopyPasteManager->SetCursorPosition(cursorPos);
1536 pEditPresenter->SetCursorPosition(cursorPos, __rowIndex, __columnIndex);
1538 pEditPresenter->DrawText();
1541 MoveCopyPasteMagnifier();
1547 _EditCopyPasteHandler::IsActivatedOnOpen(void) const
1553 _EditCopyPasteHandler::OnChangeLayout(_ControlOrientation orientation)
1560 _EditCopyPasteHandler::OnAttachedToMainTree(void)
1562 result r = E_SUCCESS;
1564 if (GetOwner() == null)
1566 _Edit* pEdit = __pCopyPasteManager->GetEdit();
1567 SysTryReturnResult(NID_UI_CTRL, pEdit, GetLastResult(), "Unable to get pEdit.");
1569 _EditPresenter* pEditPresenter = pEdit->GetPresenter();
1570 SysTryReturnResult(NID_UI_CTRL, pEdit, GetLastResult(), "Unable to get pEditPresenter.");
1572 _Form* pParentForm = pEditPresenter->GetParentForm();
1575 SetOwner(pParentForm);
1579 _Form* pForm = null;
1580 _Frame* pCurrentFrame = dynamic_cast <_Frame*>(_ControlManager::GetInstance()->GetCurrentFrame());
1583 pForm = pCurrentFrame->GetCurrentForm();
1590 SetOwner(pCurrentFrame);
1600 _EditCopyPasteHandler::OnBoundsChanging(const FloatRectangle& bounds)
1602 result r = E_SUCCESS;
1604 __windowBounds = bounds;
1606 if (!GetVisibleState())
1611 if (!__reverseCheck)
1613 _EcoreEvas* pEcoreEvas = GetEcoreEvasMgr()->GetEcoreEvas();
1614 SysTryReturn(NID_UI, pEcoreEvas, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error occurred.");
1616 pEcoreEvas->SetWindowBounds(*GetRootWindow(), bounds);
1617 result r = GetLastResult();
1618 SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1625 _EditCopyPasteHandler::OnBoundsChanging(const Rectangle& bounds)
1627 result r = E_SUCCESS;
1632 _EditCopyPasteHandler::SetWindowBounds(const Rectangle& bounds)
1634 _EcoreEvas* pEcoreEvas = GetEcoreEvasMgr()->GetEcoreEvas();
1635 SysTryReturn(NID_UI, pEcoreEvas, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error occurred.");
1637 pEcoreEvas->SetWindowBounds(*GetRootWindow(), bounds);
1638 result r = GetLastResult();
1639 SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1645 _EditCopyPasteHandler::SetWindowBounds(const FloatRectangle& bounds)
1647 _EcoreEvas* pEcoreEvas = GetEcoreEvasMgr()->GetEcoreEvas();
1648 SysTryReturn(NID_UI, pEcoreEvas, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error occurred.");
1650 pEcoreEvas->SetWindowBounds(*GetRootWindow(), bounds);
1651 result r = GetLastResult();
1652 SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1657 _EditCopyPasteManager::_EditCopyPasteManager(_Edit& parenEdit)
1658 : __pCopyPastePopup(null)
1659 , __contextMenuAlign(CONTEXT_MENU_CORE_ALIGN_UP)
1660 , __pCoreCopyPasteEvent(null)
1661 , __pEdit(&parenEdit)
1662 , __pEditPresenter(null)
1663 , __contextMenuHeight(0.0f)
1664 , __needToReleaseBlock(true)
1665 , __isHandlerMoving(false)
1666 , __editVisibleArea(0.0f, 0.0f, 0.0f, 0.0f)
1668 __pEditPresenter = __pEdit->GetPresenter();
1669 __pHandle[HANDLER_TYPE_CENTER] = null;
1670 __pHandle[HANDLER_TYPE_LEFT] = null;
1671 __pHandle[HANDLER_TYPE_RIGHT] = null;
1676 _EditCopyPasteManager::~_EditCopyPasteManager(void)
1680 if (__pCoreCopyPasteEvent)
1682 delete __pCoreCopyPasteEvent;
1683 __pCoreCopyPasteEvent = null;
1688 _EditCopyPasteManager::Release(void)
1690 if (__pCopyPastePopup)
1692 __pCopyPastePopup->Close();
1693 delete __pCopyPastePopup;
1694 __pCopyPastePopup = null;
1697 if (__pHandle[HANDLER_TYPE_CENTER])
1699 __pHandle[HANDLER_TYPE_CENTER]->Close();
1700 delete __pHandle[HANDLER_TYPE_CENTER];
1701 __pHandle[HANDLER_TYPE_CENTER] = null;
1704 if (__pHandle[HANDLER_TYPE_LEFT])
1706 __pHandle[HANDLER_TYPE_LEFT]->Close();
1707 delete __pHandle[HANDLER_TYPE_LEFT];
1708 __pHandle[HANDLER_TYPE_LEFT] = null;
1711 if (__pHandle[HANDLER_TYPE_RIGHT])
1713 __pHandle[HANDLER_TYPE_RIGHT]->Close();
1714 delete __pHandle[HANDLER_TYPE_RIGHT];
1715 __pHandle[HANDLER_TYPE_RIGHT] = null;
1720 _EditCopyPasteManager::ReleaseCopyPastePopup(void)
1722 if (__pCopyPastePopup)
1724 __pCopyPastePopup->Close();
1725 delete __pCopyPastePopup;
1726 __pCopyPastePopup = null;
1731 _EditCopyPasteManager::IsCopyPastePopup(const _Control& control) const
1733 if (__pCopyPastePopup == &control)
1742 _EditCopyPasteManager::IsCopyPasteHandle(const _Control& control) const
1744 if (__pHandle[HANDLER_TYPE_CENTER] == &control)
1749 if (__pHandle[HANDLER_TYPE_LEFT] == &control)
1754 if (__pHandle[HANDLER_TYPE_RIGHT] == &control)
1763 _EditCopyPasteManager::AddCopyPasteEventListener(const _IEditCopyPasteEventListener& listener)
1767 if (__pCoreCopyPasteEvent == null)
1769 __pCoreCopyPasteEvent = _EditCopyPasteEvent::CreateInstanceN(*this);
1770 SysTryReturn(NID_UI_CTRL, __pCoreCopyPasteEvent, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] System error occurred.\n");
1773 return __pCoreCopyPasteEvent->AddListener(listener);
1777 _EditCopyPasteManager::SendCopyPasteEvent(CoreCopyPasteStatus status, CoreCopyPasteAction action)
1779 if (__pCoreCopyPasteEvent)
1781 IEventArg* pCopyPasteEventArg = _EditCopyPasteEvent::CreateCopyPasteEventArgN(status, action);
1782 SysTryReturn(NID_UI_CTRL, pCopyPasteEventArg, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Unable to create _LinkEventArg.");
1784 __pCoreCopyPasteEvent->Fire(*pCopyPasteEventArg);
1791 _EditCopyPasteManager::CreateCopyPastePopup(void)
1793 if (__pHandle[HANDLER_TYPE_CENTER])
1795 __pHandle[HANDLER_TYPE_CENTER]->DestroyCopyPasteMagnifier();
1797 if (__pCopyPastePopup)
1799 __pCopyPastePopup->Close();
1800 delete __pCopyPastePopup;
1801 __pCopyPastePopup = null;
1804 FloatRectangle startRect;
1805 FloatRectangle endRect;
1806 FloatRectangle editAbsRect;
1807 FloatRectangle editShowAreaAbsRect;
1808 FloatRectangle commandButtonBounds;
1809 FloatRectangle keypadBounds(0.0f, 0.0f, 0.0f, 0.0f);
1810 FloatRectangle formClientBounds(0.0f, 0.0f, 0.0f, 0.0f);
1811 FloatRectangle panelAbsoulteBounds(0.0f, 0.0f, 0.0f, 0.0f);
1812 bool commandButtonExist = false;
1813 FloatRectangle cursorRect = GetCursorBoundsF(true);
1815 float contextMenuHeight = 0.0f;
1816 float contextMenuTopMargin = 0.0f;
1817 float contextMenuBottomMargin = 0.0f;
1818 float contextMenuArrowHeight = 0.0f;
1819 float handlerHeight = 0.0f;
1820 bool isPasswordStyle = false;
1821 bool isClipped = false;
1822 if (__pEdit->GetEditStyle() & EDIT_STYLE_PASSWORD)
1824 isPasswordStyle = true;
1827 _ControlOrientation orientation = __pEdit->GetOrientation();
1829 FloatDimension screenSize;
1830 _ControlManager* pControlManager = _ControlManager::GetInstance();
1831 if (orientation == _CONTROL_ORIENTATION_PORTRAIT)
1833 screenSize = pControlManager->GetScreenSizeF();
1837 screenSize.width = pControlManager->GetScreenSizeF().height;
1838 screenSize.height = pControlManager->GetScreenSizeF().width;
1841 GET_SHAPE_CONFIG(EDIT::COPYPASTE_HANDLER_HEIGHT, orientation, handlerHeight);
1843 GET_SHAPE_CONFIG(CONTEXTMENU::GRID_ITEM_HEIGHT, orientation, contextMenuHeight);
1844 GET_SHAPE_CONFIG(CONTEXTMENU::GRID_TOP_MARGIN, orientation, contextMenuTopMargin);
1845 GET_SHAPE_CONFIG(CONTEXTMENU::GRID_BOTTOM_MARGIN, orientation, contextMenuBottomMargin);
1846 GET_SHAPE_CONFIG(CONTEXTMENU::ANCHOR_HEIGHT, orientation, contextMenuArrowHeight);
1848 isClipped = __pEdit->IsClipped();
1849 if ((__pEdit->GetTextLength() == 0 || __pEdit->GetEditStyle() & EDIT_STYLE_PASSWORD) && !isClipped)
1854 if (__pEdit->GetTextLength() == 0 && (__pEditPresenter->IsViewModeEnabled()))
1859 __contextMenuHeight = contextMenuHeight + contextMenuTopMargin + contextMenuBottomMargin + contextMenuArrowHeight;
1860 if (isClipped && __pEditPresenter->IsViewModeEnabled() == false && __pEdit->GetTextLength() > 0 && orientation == _CONTROL_ORIENTATION_PORTRAIT)
1862 __contextMenuHeight = __contextMenuHeight + contextMenuHeight;
1865 editAbsRect = __pEdit->GetAbsoluteBoundsF();
1867 _Toolbar* pCommandButton = __pEditPresenter->GetKeypadCommandButton();
1870 commandButtonBounds = pCommandButton->GetAbsoluteBoundsF();
1871 commandButtonExist = true;
1873 _Form* pForm = __pEditPresenter->GetParentForm();
1876 formClientBounds = pForm->GetClientBoundsF();
1878 _ScrollPanel* pPanel = __pEditPresenter->GetParentPanel();
1881 panelAbsoulteBounds = pPanel->GetAbsoluteBoundsF();
1883 __pEdit->GetKeypadBounds(keypadBounds);
1887 editShowAreaAbsRect = editAbsRect;
1888 FloatRectangle textObjectBounds = __pEditPresenter->GetTextBoundsF();
1890 if (!(__pEdit->GetEditStyle() & EDIT_STYLE_TOKEN))
1892 editShowAreaAbsRect.x += textObjectBounds.x;
1893 editShowAreaAbsRect.y += textObjectBounds.y;
1894 editShowAreaAbsRect.width = textObjectBounds.width;
1896 if (!(__pEdit->GetEditStyle() & EDIT_STYLE_SINGLE_LINE))
1898 editShowAreaAbsRect.height = textObjectBounds.height;
1902 if (commandButtonExist)
1904 if (editShowAreaAbsRect.y + editShowAreaAbsRect.height > commandButtonBounds.y)
1906 editShowAreaAbsRect.height -= (editShowAreaAbsRect.y + editShowAreaAbsRect.height - commandButtonBounds.y);
1911 if (editShowAreaAbsRect.y + editShowAreaAbsRect.height > keypadBounds.y)
1913 editShowAreaAbsRect.height -= (editShowAreaAbsRect.y + editShowAreaAbsRect.height - keypadBounds.y);
1916 if (editShowAreaAbsRect.y < formClientBounds.y)
1918 editShowAreaAbsRect.y = formClientBounds.y;
1919 editShowAreaAbsRect.height -= formClientBounds.y;
1921 if (editShowAreaAbsRect.y < panelAbsoulteBounds.y)
1923 editShowAreaAbsRect.y = panelAbsoulteBounds.y;
1924 editShowAreaAbsRect.height -= (panelAbsoulteBounds.y - editShowAreaAbsRect.y);
1926 __editVisibleArea = editShowAreaAbsRect;
1928 FloatPoint copyPastePoint(0.0f, 0.0f);
1929 __contextMenuAlign = CONTEXT_MENU_CORE_ALIGN_UP;
1931 if (__pEdit->IsBlocked())
1935 __pEdit->GetBlockRange(start, end);
1936 if (start == -1 || end == -1)
1938 SysLog(NID_UI_CTRL, "[EditCopyPasteManager] There is no blocked Range");
1942 __pEdit->CalculateAbsoluteCursorBounds(start, startRect);
1943 __pEdit->CalculateAbsoluteCursorBounds(end, endRect);
1944 if (startRect.x > endRect.x)
1946 copyPastePoint.x = endRect.x + (startRect.x - endRect.x)/2;
1948 else if (startRect.x < endRect.x)
1950 copyPastePoint.x = startRect.x + (endRect.x - startRect.x)/2;
1954 copyPastePoint.x = startRect.x;
1957 if (copyPastePoint.x < editShowAreaAbsRect.x)
1959 copyPastePoint.x = editShowAreaAbsRect.x;
1961 else if (copyPastePoint.x > (editShowAreaAbsRect.x + editShowAreaAbsRect.width))
1963 copyPastePoint.x = editShowAreaAbsRect.x + editShowAreaAbsRect.width;
1966 //Both of handlers are located on the top of the Editor.
1967 if ( ((startRect.y + startRect.height) < editShowAreaAbsRect.y) && ((endRect.y + endRect.height) < editShowAreaAbsRect.y))
1969 SysLog(NID_UI_CTRL, "Both of handlers are located on the top of the Editor.\n");
1972 //Both of handlers are located on the bottom of the Editor.
1973 else if( ((startRect.y + startRect.height) > editShowAreaAbsRect.y + editShowAreaAbsRect.height ) && ((endRect.y + endRect.height) > editShowAreaAbsRect.y + editShowAreaAbsRect.height))
1975 SysLog(NID_UI_CTRL, "Both of handlers are located on the bottom of the Editor.\n");
1978 // Left handler is located on the top of the Editor and Right handler is located on the bottom of the Editor.
1979 else if ( ((startRect.y + startRect.height) < editShowAreaAbsRect.y) && ((endRect.y + endRect.height) > (editShowAreaAbsRect.y + editShowAreaAbsRect.height)))
1981 copyPastePoint.y = editShowAreaAbsRect.y + editShowAreaAbsRect.height/2;
1983 if (copyPastePoint.y < __contextMenuHeight)
1985 __contextMenuAlign = CONTEXT_MENU_CORE_ALIGN_DOWN;
1989 // Left handler is located on the top of the Editor and Right handler is located on the Editor
1990 else if ( ((startRect.y + startRect.height) < editShowAreaAbsRect.y) && ((endRect.y + endRect.height) <= (editShowAreaAbsRect.y + editShowAreaAbsRect.height)) )
1992 if ( (endRect.y + endRect.height + handlerHeight + __contextMenuHeight) < keypadBounds.y)
1994 __contextMenuAlign = CONTEXT_MENU_CORE_ALIGN_DOWN;
1995 copyPastePoint.y = endRect.y + endRect.height + handlerHeight;
1997 else if (endRect.y - editShowAreaAbsRect.y > __contextMenuHeight)
1999 copyPastePoint.y = editShowAreaAbsRect.y + __contextMenuHeight;
2001 else if (endRect.y > __contextMenuHeight)
2003 copyPastePoint.y = endRect.y;
2007 SysLog(NID_UI_CTRL, "There is no space to draw the copy&paste popup\n");
2011 // Left handler is located on the Editor and Right handler is located on the bottom of the Editor
2012 else if ( ((startRect.y + startRect.height) >= editShowAreaAbsRect.y) && ((endRect.y + endRect.height) > (editShowAreaAbsRect.y + editShowAreaAbsRect.height)) )
2014 if (__contextMenuHeight < startRect.y)
2016 copyPastePoint.y = startRect.y;
2020 copyPastePoint.y = startRect.y + (editShowAreaAbsRect.y + editShowAreaAbsRect.height - startRect.y)/2;
2023 // There is a space on the top of the Editor.
2024 else if (__contextMenuHeight < startRect.y)
2026 copyPastePoint.y = startRect.y;
2028 // There is a space on the bottom of the Editor.
2029 else if ( screenSize.height > (endRect.y + endRect.height + handlerHeight + __contextMenuHeight))
2031 __contextMenuAlign = CONTEXT_MENU_CORE_ALIGN_DOWN;
2033 copyPastePoint.y = endRect.y + endRect.height + handlerHeight;
2035 // There is no space on the top and bottom of the Editor. The Popup should be drawn on the center of the Editor.
2038 if (endRect.y - startRect.y < __contextMenuHeight)
2040 SysLog(NID_UI_CTRL, "There is no space to draw the copy&paste popup\n");
2043 copyPastePoint.y = startRect.y + __contextMenuHeight;
2049 if (editShowAreaAbsRect.height <= 0)
2053 FloatRectangle cursorRect;
2054 int cursorPosition = GetCursorPosition();
2055 __pEdit->CalculateAbsoluteCursorBounds(cursorPosition, cursorRect);
2056 copyPastePoint.x = cursorRect.x;
2057 copyPastePoint.y = cursorRect.y;
2059 if (__editVisibleArea.y > copyPastePoint.y || __editVisibleArea.y + __editVisibleArea.height < copyPastePoint.y)
2064 if (copyPastePoint.y < __contextMenuHeight)
2066 FloatRectangle cursorRect = GetCursorBoundsF(true);
2068 copyPastePoint.y += cursorRect.height;
2069 __contextMenuAlign = CONTEXT_MENU_CORE_ALIGN_DOWN;
2070 if (__pHandle[HANDLER_TYPE_CENTER])
2072 copyPastePoint.y += __pHandle[HANDLER_TYPE_CENTER]->GetBounds().height;
2077 //Todo: Create API ex)CreateContrexMenuFN
2078 __pCopyPastePopup = _ContextMenu::CreateContextMenuN(copyPastePoint, CONTEXT_MENU_CORE_STYLE_GRID, __contextMenuAlign);
2079 SysTryReturnVoidResult(NID_UI_CTRL, __pCopyPastePopup, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2081 if ( __pEdit->GetTextLength() != 0 && !isPasswordStyle)
2083 if (__pEdit->IsBlocked())
2088 GET_STRING_CONFIG(IDS_TPLATFORM_OPT_COPY, copyText);
2089 GET_STRING_CONFIG(IDS_TPLATFORM_OPT_CUT, cutText);
2091 __pCopyPastePopup->AddItem(copyText, COPY_PASTE_COPY_ID, null, null, null);
2092 if (!__pEditPresenter->IsViewModeEnabled())
2094 __pCopyPastePopup->AddItem(cutText, COPY_PASTE_CUT_ID, null, null, null);
2100 String selectAllText;
2102 GET_STRING_CONFIG(IDS_TPLATFORM_OPT_SELECT, selectText);
2103 GET_STRING_CONFIG(IDS_TPLATFORM_OPT_SELECT_ALL, selectAllText);
2105 __pCopyPastePopup->AddItem(selectText, COPY_PASTE_SELECT_ID, null, null, null);
2106 __pCopyPastePopup->AddItem(selectAllText, COPY_PASTE_SELECT_ALL_ID, null, null, null);
2112 if (!__pEditPresenter->IsViewModeEnabled())
2115 String clipboardText;
2117 GET_STRING_CONFIG(IDS_TPLATFORM_OPT_PASTE, pasteText);
2118 GET_STRING_CONFIG(IDS_TPLATFORM_OPT_CLIPBOARD, clipboardText);
2120 __pCopyPastePopup->AddItem(pasteText, COPY_PASTE_PASTE_ID, null, null, null);
2121 if (!isPasswordStyle && __pEdit->IsKeypadEnabled())
2123 __pCopyPastePopup->AddItem(clipboardText, COPY_PASTE_CLIPBOARD_ID, null, null, null);
2128 __pCopyPastePopup->AddActionEventListener(*this);
2131 Bitmap* pSearchBitmap = null;
2132 Bitmap* pReplacedSearchBitmap = null;
2133 Bitmap* pReplacedSearchPressedBitmap = null;
2135 Color searchPressedColor;
2136 result r = E_SUCCESS;
2138 if (__pEdit->IsBlocked() && !isPasswordStyle)
2140 r = GET_BITMAP_CONFIG_N(EDIT::COPY_PASTE_SEARCH_ICON, BITMAP_PIXEL_FORMAT_ARGB8888, pSearchBitmap);
2141 SysTryReturnVoidResult(NID_UI_CTRL, (r == E_SUCCESS), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2143 GET_COLOR_CONFIG(CONTEXTMENU::ITEM_TEXT_NORMAL, searchColor);
2144 GET_COLOR_CONFIG(CONTEXTMENU::ITEM_TEXT_PRESSED, searchPressedColor);
2146 pReplacedSearchBitmap = _BitmapImpl::GetColorReplacedBitmapN(*pSearchBitmap, Color::GetColor(COLOR_ID_MAGENTA), searchColor);
2147 SysTryCatch(NID_UI_CTRL, pReplacedSearchBitmap, r = GetLastResult(), GetLastResult(),"[%s] Propagating.", GetErrorMessage(GetLastResult()));
2149 pReplacedSearchPressedBitmap = _BitmapImpl::GetColorReplacedBitmapN(*pSearchBitmap, Color::GetColor(COLOR_ID_MAGENTA), searchPressedColor);
2150 SysTryCatch(NID_UI_CTRL, pReplacedSearchPressedBitmap, r = GetLastResult(), GetLastResult(),"[%s] Propagating.", GetErrorMessage(GetLastResult()));
2152 __pCopyPastePopup->AddItem(null, COPY_PASTE_SEARCH_ID, pReplacedSearchBitmap, pReplacedSearchPressedBitmap, null);
2157 delete pSearchBitmap;
2158 pSearchBitmap = null;
2160 if (pReplacedSearchBitmap)
2162 delete pReplacedSearchBitmap;
2163 pReplacedSearchBitmap = null;
2166 if (pReplacedSearchPressedBitmap)
2168 delete pReplacedSearchPressedBitmap;
2169 pReplacedSearchPressedBitmap = null;
2171 __pCopyPastePopup->AddActionEventListener(*this);
2176 delete pSearchBitmap;
2177 pSearchBitmap = null;
2179 delete pReplacedSearchBitmap;
2180 pReplacedSearchBitmap = null;
2187 _EditCopyPasteManager::CreateHandle(void)
2191 if (__pEdit->IsBlocked())
2195 FloatRectangle startRect;
2196 FloatRectangle endRect;
2198 __pEdit->GetBlockRange(start, end);
2200 __pEdit->CalculateAbsoluteCursorBounds(start, startRect);
2201 __pEdit->CalculateAbsoluteCursorBounds(end, endRect);
2203 FloatPoint leftHandler(startRect.x, startRect.y + startRect.height);
2204 FloatPoint rightHandler(endRect.x, endRect.y + endRect.height);
2206 __pHandle[HANDLER_TYPE_LEFT] = _EditCopyPasteHandler::CreateInstanceN(leftHandler, start, this, false, true);
2207 __pHandle[HANDLER_TYPE_RIGHT] = _EditCopyPasteHandler::CreateInstanceN(rightHandler, end, this, false, false);
2211 FloatRectangle centerRect;
2212 __pEdit->CalculateAbsoluteCursorBounds(__pEdit->GetCursorPosition(), centerRect);
2213 FloatPoint centerHandler(centerRect.x, centerRect.y + centerRect.height);
2215 __pHandle[HANDLER_TYPE_CENTER] = _EditCopyPasteHandler::CreateInstanceN(centerHandler, __pEdit->GetCursorPosition(), this, true, true);
2216 #if EDIT_COPY_PASTE_MAGNIFIER
2217 // __pHandle[HANDLER_TYPE_CENTER]->CreateCopyPasteMagnifier();
2223 _EditCopyPasteManager::Show(void)
2225 if (__pHandle[HANDLER_TYPE_CENTER])
2227 if (__pEdit->GetCursorPosition() != __pHandle[HANDLER_TYPE_CENTER]->GetHandlerCursorPosition())
2229 __pHandle[HANDLER_TYPE_CENTER]->SetHandlerCursorPosition(__pEdit->GetCursorPosition());
2231 __pHandle[HANDLER_TYPE_CENTER]->AdjustBounds();
2232 __pHandle[HANDLER_TYPE_CENTER]->CheckReverseStatus();
2233 __pHandle[HANDLER_TYPE_CENTER]->Invalidate();
2234 __pEditPresenter->DrawText();
2237 if (__pHandle[HANDLER_TYPE_LEFT] && __pHandle[HANDLER_TYPE_RIGHT])
2240 __pHandle[HANDLER_TYPE_LEFT]->CheckReverseStatus();
2241 __pHandle[HANDLER_TYPE_RIGHT]->CheckReverseStatus();
2242 __pHandle[HANDLER_TYPE_LEFT]->Invalidate();
2243 __pHandle[HANDLER_TYPE_RIGHT]->Invalidate();
2244 __pEditPresenter->DrawText();
2247 if (__pCopyPastePopup)
2249 __pCopyPastePopup->Open();
2250 __pCopyPastePopup->ReleaseTouchCapture();
2252 _Control* pControl = __pCopyPastePopup->GetOwner();
2255 pControl->UnlockInputEvent();
2261 _EditCopyPasteManager::CheckHandleBounds(const FloatPoint& point)
2263 bool hasCommandButton = false;
2264 bool hasParentForm = false;
2265 bool hasParentPanel = false;
2266 bool showCheck = true;
2267 FloatRectangle commandButtonBounds(0.0f, 0.0f, 0.0f, 0.0f);
2268 FloatRectangle formClientBounds(0.0f, 0.0f, 0.0f, 0.0f);
2269 FloatRectangle panelAbsoulteBounds(0.0f, 0.0f, 0.0f, 0.0f);
2270 FloatRectangle editAbsBounds = __pEdit->GetAbsoluteBoundsF();
2271 FloatRectangle textObjectBounds = __pEditPresenter->GetTextBoundsF();
2273 if (!(__pEdit->GetEditStyle() & EDIT_STYLE_TOKEN))
2275 editAbsBounds.x += textObjectBounds.x;
2276 editAbsBounds.y += textObjectBounds.y;
2277 editAbsBounds.width = textObjectBounds.width;
2279 if (!(__pEdit->GetEditStyle() & EDIT_STYLE_SINGLE_LINE))
2281 editAbsBounds.height = textObjectBounds.height;
2285 _Toolbar* pCommandButton = __pEditPresenter->GetKeypadCommandButton();
2288 commandButtonBounds = pCommandButton->GetAbsoluteBoundsF();
2289 hasCommandButton = true;
2291 _Form* pForm = __pEditPresenter->GetParentForm();
2294 formClientBounds = pForm->GetClientBoundsF();
2295 hasParentForm = true;
2298 _ScrollPanel* pPanel = __pEditPresenter->GetParentPanel();
2301 panelAbsoulteBounds = pPanel->GetAbsoluteBoundsF();
2302 hasParentPanel = true;
2305 if ((!_FloatCompare(editAbsBounds.x, point.x) && (editAbsBounds.x > point.x)) || (!_FloatCompare(point.x, editAbsBounds.x + editAbsBounds.width) && point.x > (editAbsBounds.x + editAbsBounds.width)))
2310 if ((!_FloatCompare(editAbsBounds.y, point.y) && (editAbsBounds.y > point.y)) || (!_FloatCompare(point.y, editAbsBounds.y + editAbsBounds.height) && point.y > (editAbsBounds.y + editAbsBounds.height)))
2314 if (hasParentForm && ((!_FloatCompare(formClientBounds.y, point.y) && formClientBounds.y > point.y) || (!_FloatCompare(point.y, formClientBounds.y + formClientBounds.height) && point.y > (formClientBounds.y + formClientBounds.height))))
2318 if (hasParentPanel && ((!_FloatCompare(panelAbsoulteBounds.y, point.y) && panelAbsoulteBounds.y > point.y) || (!_FloatCompare(point.y, panelAbsoulteBounds.y + panelAbsoulteBounds.height) && point.y > (panelAbsoulteBounds.y + panelAbsoulteBounds.height))))
2322 if (hasCommandButton && commandButtonBounds.Contains(point))
2330 _EditCopyPasteManager::CheckHandlePosition(bool leftHandle, int cursorPosition)
2332 int leftHandlerPosition = __pHandle[HANDLER_TYPE_LEFT]->GetHandlerCursorPosition();
2333 int rightHandlerPosition = __pHandle[HANDLER_TYPE_RIGHT]->GetHandlerCursorPosition();
2337 if (cursorPosition + 1 <= rightHandlerPosition)
2348 if (cursorPosition >= leftHandlerPosition + 1)
2360 _EditCopyPasteManager::RefreshBlock(bool isLeftHandle)
2362 int leftRowIndex = -1;
2363 int leftColumnIndex = -1;
2364 int rightRowIndex = -1;
2365 int rightColumnIndex = -1;
2367 int leftHandlerPos = __pHandle[HANDLER_TYPE_LEFT]->GetHandlerCursorPosition();
2368 int rightHandlerPos = __pHandle[HANDLER_TYPE_RIGHT]->GetHandlerCursorPosition();
2369 __pHandle[HANDLER_TYPE_RIGHT]->GetHandlerRowColumnIndex(leftRowIndex, leftColumnIndex);
2370 __pHandle[HANDLER_TYPE_RIGHT]->GetHandlerRowColumnIndex(rightRowIndex, rightColumnIndex);
2372 __pEditPresenter->SetBlockRange(leftHandlerPos, rightHandlerPos, leftColumnIndex, leftColumnIndex, rightRowIndex, rightColumnIndex);
2374 __pEditPresenter->SetCursorChangedFlag(!isLeftHandle);
2375 __pEditPresenter->DrawText();
2380 _EditCopyPasteManager::GetCursorBoundsF(bool isAbsRect) const
2382 FloatRectangle cursorBounds;
2384 __pEdit->GetCursorBounds(isAbsRect, cursorBounds);
2386 return cursorBounds;
2390 _EditCopyPasteManager::GetCursorPositionAt(const FloatPoint& touchPoint) const
2392 return __pEdit->GetCursorPositionAt(touchPoint);
2396 _EditCopyPasteManager::SetCursorPosition(int position)
2398 return __pEdit->SetCursorPosition(position);
2402 _EditCopyPasteManager::GetCursorPosition(void) const
2404 return __pEdit->GetCursorPosition();
2408 _EditCopyPasteManager::GetHandlerCursorPosition(HandlerType handlerType) const
2410 return __pHandle[handlerType]->GetHandlerCursorPosition();
2414 _EditCopyPasteManager::SendTextBlockEvent(void)
2418 result r = E_SUCCESS;
2420 __pEdit->GetBlockRange(start, end);
2421 if (start != -1 && end != -1)
2423 r = __pEdit->SendTextBlockEvent(start, end);
2424 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
2429 _EditCopyPasteManager::OnActionPerformed(const _Control& source, int actionId)
2431 _Clipboard* pClipBoard = _Clipboard::GetInstance();
2432 SysTryReturnVoidResult(NID_UI_CTRL, pClipBoard, E_SYSTEM, "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2434 ReleaseCopyPastePopup();
2438 case COPY_PASTE_SELECT_ID:
2440 int cursorPos = GetCursorPosition();
2443 __pEdit->GetWordPosition(cursorPos, start, end);
2444 __pEdit->SetBlockRange(start, end);
2445 SendTextBlockEvent();
2449 CreateCopyPastePopup();
2456 case COPY_PASTE_SELECT_ALL_ID:
2458 int textLength = __pEdit->GetTextLength();
2459 __pEdit->SetBlockRange(0, textLength);
2460 SendTextBlockEvent();
2461 __pEditPresenter->UpdateComponentInformation();
2465 CreateCopyPastePopup();
2472 case COPY_PASTE_COPY_ID:
2473 ReleaseCopyPastePopup();
2474 SendCopyPasteEvent(CORE_COPY_PASTE_STATUS_HIDE, CORE_COPY_PASTE_ACTION_COPY);
2477 case COPY_PASTE_CUT_ID:
2478 SendCopyPasteEvent(CORE_COPY_PASTE_STATUS_HIDE, CORE_COPY_PASTE_ACTION_CUT);
2481 case COPY_PASTE_PASTE_ID:
2482 SendCopyPasteEvent(CORE_COPY_PASTE_STATUS_HIDE, CORE_COPY_PASTE_ACTION_PASTE);
2485 case COPY_PASTE_CLIPBOARD_ID:
2486 pClipBoard->ShowPopup(CLIPBOARD_DATA_TYPE_TEXT, *__pEdit);
2487 ReleaseCopyPastePopup();
2488 SendCopyPasteEvent(CORE_COPY_PASTE_STATUS_HIDE, CORE_COPY_PASTE_ACTION_CLIPBOARD);
2490 case COPY_PASTE_SEARCH_ID:
2492 SendCopyPasteEvent(CORE_COPY_PASTE_STATUS_HIDE, CORE_COPY_PASTE_ACTION_SEARCH);
2502 _EditCopyPasteManager::AdjustBounds(void)
2504 if (__pHandle[HANDLER_TYPE_CENTER])
2506 __pHandle[HANDLER_TYPE_CENTER]->AdjustBounds();
2508 if (__pHandle[HANDLER_TYPE_LEFT])
2510 __pHandle[HANDLER_TYPE_LEFT]->AdjustBounds();
2512 if (__pHandle[HANDLER_TYPE_RIGHT])
2514 __pHandle[HANDLER_TYPE_RIGHT]->AdjustBounds();
2519 _EditCopyPasteManager::LaunchSearch(void)
2521 result r = E_SUCCESS;
2524 __pEdit->GetBlockRange(start, end);
2525 String blockText = __pEditPresenter->GetText(start, end-1);
2527 _AppMessageImpl msg;
2529 msg.AddData(APPSVC_DATA_KEYWORD, blockText);
2530 r = _AppControlManager::GetInstance()->LaunchPkg(msg, null, APPSVC_OPERATION_SEARCH, null, null, 0, 0);
2534 _EditCopyPasteManager::GetTextBlockReleaseFlag(void) const
2536 return __needToReleaseBlock;
2540 _EditCopyPasteManager::SetTextBlockReleaseFlag(bool enabled)
2542 __needToReleaseBlock = enabled;
2546 _EditCopyPasteManager::IsCopyPasteHandleExist(void) const
2548 if (__pHandle[HANDLER_TYPE_CENTER] || (__pHandle[HANDLER_TYPE_LEFT] && __pHandle[HANDLER_TYPE_RIGHT]))
2559 _EditCopyPasteManager::IsCopyPasteSingleHandleExist(void) const
2561 if (__pHandle[HANDLER_TYPE_CENTER])
2572 _EditCopyPasteManager::UpdateCopyPasteMagnifier(void)
2574 for (int i = 0; i < HANDLER_TYPE_MAX; i++)
2578 __pHandle[i]->UpdateCopyPasteMagnifier();
2584 _EditCopyPasteManager::GetEdit(void) const
2590 _EditCopyPasteManager::MoveHandler(HandlerMoveType moveType)
2592 if (!__pHandle[HANDLER_TYPE_RIGHT] || ! __pHandle[HANDLER_TYPE_LEFT])
2597 int leftHandlerPosition = __pHandle[HANDLER_TYPE_LEFT]->GetHandlerCursorPosition();
2598 int rightHandlerPosition = __pHandle[HANDLER_TYPE_RIGHT]->GetHandlerCursorPosition();
2599 int textLength = __pEdit->GetTextLength();
2600 FloatRectangle cursorBounds;
2601 int newCursorPosition;
2602 __pEdit->GetCursorBounds(false, cursorBounds);
2603 FloatPoint cursorPoint(cursorBounds.x, cursorBounds.y);
2605 TextObject* pTextObject = __pEditPresenter->GetTextObject();
2609 case HANDLER_MOVE_TYPE_LEFT:
2610 if (leftHandlerPosition < rightHandlerPosition-1)
2612 __pHandle[HANDLER_TYPE_RIGHT]->SetHandlerCursorPosition(--rightHandlerPosition);
2614 __pHandle[HANDLER_TYPE_RIGHT]->CheckReverseStatus();
2615 __pHandle[HANDLER_TYPE_RIGHT]->Invalidate();
2622 case HANDLER_MOVE_TYPE_UP:
2623 cursorPoint.y -= cursorBounds.height/2.0f;
2624 newCursorPosition = GetCursorPositionAt(cursorPoint);
2626 if (newCursorPosition <= 0)
2628 int curCursorLine = pTextObject->GetLineIndexAtTextIndex(pTextObject->GetCursorIndex());
2630 if (curCursorLine !=0 )
2632 int offset = rightHandlerPosition - pTextObject->GetFirstTextIndexAt(curCursorLine);
2633 int firstTextIndex = pTextObject->GetFirstTextIndexAt(curCursorLine-1);
2634 newCursorPosition = offset + firstTextIndex;
2635 int textLength = pTextObject->GetTextLengthAt(curCursorLine-1);
2636 if (offset > textLength)
2638 newCursorPosition = firstTextIndex+textLength;
2641 if (leftHandlerPosition >= newCursorPosition)
2643 newCursorPosition = leftHandlerPosition + 1;
2648 if (newCursorPosition >= 0 && leftHandlerPosition < newCursorPosition)
2650 __pHandle[HANDLER_TYPE_RIGHT]->SetHandlerCursorPosition(newCursorPosition);
2652 __pHandle[HANDLER_TYPE_RIGHT]->CheckReverseStatus();
2653 __pHandle[HANDLER_TYPE_RIGHT]->Invalidate();
2660 case HANDLER_MOVE_TYPE_DOWN:
2661 cursorPoint.y += cursorBounds.height + cursorBounds.height/2.0f;
2662 newCursorPosition = GetCursorPositionAt(cursorPoint);
2664 if (newCursorPosition < 0)
2666 int curCursorLine = pTextObject->GetLineIndexAtTextIndex(pTextObject->GetCursorIndex());
2667 int totalLine = pTextObject->GetTotalLineCount();
2668 if (curCursorLine < totalLine - 1)
2670 int offset = rightHandlerPosition - pTextObject->GetFirstTextIndexAt(curCursorLine);
2671 int firstTextIndex = pTextObject->GetFirstTextIndexAt(curCursorLine+1);
2672 newCursorPosition = offset + firstTextIndex;
2673 int textLength = pTextObject->GetTextLengthAt(curCursorLine+1);
2674 if (offset > textLength)
2676 newCursorPosition = firstTextIndex+textLength;
2680 else if (curCursorLine == totalLine - 1)
2682 int firstTextIndex = pTextObject->GetFirstTextIndexAt(curCursorLine);
2683 int textLength = pTextObject->GetTextLengthAt(curCursorLine);
2684 newCursorPosition = firstTextIndex + textLength;
2688 if (newCursorPosition >= 0)
2690 __pHandle[HANDLER_TYPE_RIGHT]->SetHandlerCursorPosition(newCursorPosition);
2692 __pHandle[HANDLER_TYPE_RIGHT]->CheckReverseStatus();
2693 __pHandle[HANDLER_TYPE_RIGHT]->Invalidate();
2700 case HANDLER_MOVE_TYPE_RIGHT:
2701 if (textLength >= rightHandlerPosition+1)
2703 __pHandle[HANDLER_TYPE_RIGHT]->SetHandlerCursorPosition(++rightHandlerPosition);
2705 __pHandle[HANDLER_TYPE_RIGHT]->CheckReverseStatus();
2706 __pHandle[HANDLER_TYPE_RIGHT]->Invalidate();
2717 ReleaseCopyPastePopup();
2718 __isHandlerMoving = true;
2723 _EditCopyPasteManager::IsHandlerMovingEnabled(void) const
2725 return __isHandlerMoving;
2729 _EditCopyPasteManager::SetHandlerMovingEnabled(bool enabled)
2731 __isHandlerMoving = enabled;
2735 _EditCopyPasteManager::GetEditVisibleArea(void) const
2737 return _CoordinateSystemUtils::ConvertToInteger(GetEditVisibleAreaF());
2741 _EditCopyPasteManager::GetEditVisibleAreaF(void) const
2743 return __editVisibleArea;
2747 _EditCopyPasteManager::GetCopyPastePopup(void) const
2749 return __pCopyPastePopup;
2753 _EditCopyPasteManager::GetHandlerRowColumnIndex(bool singleHandler, bool leftHandler, int& rowIndex, int& columnIndex) const
2755 HandlerType handlerType = HANDLER_TYPE_MAX;
2758 handlerType = HANDLER_TYPE_CENTER;
2760 else if (leftHandler)
2762 handlerType = HANDLER_TYPE_LEFT;
2766 handlerType = HANDLER_TYPE_RIGHT;
2769 if (__pHandle[handlerType])
2771 __pHandle[handlerType]->GetHandlerRowColumnIndex(rowIndex, columnIndex);
2782 }}} // Tizen::Ui::Controls