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 _VisualElement* __pRoot;
87 int __handlerCursorPos;
88 FloatRectangle __windowBounds;
93 _EditCopyPasteMagnifier::_EditCopyPasteMagnifier(_EditCopyPasteManager* pCopyPasteManager, int handlerCursorPos)
94 : __pCopyPasteManager(pCopyPasteManager)
95 , __pMagnifierBitmap(null)
97 , __handlerCursorPos(handlerCursorPos)
98 , __windowBounds(0.0f, 0.0f, 0.0f, 0.0f)
103 __pRoot = GetVisualElement();
104 __pRoot->SetSurfaceOpaque(false);
106 GET_BITMAP_CONFIG_N(EDIT::COPY_PASTE_MAGNIFIER, BITMAP_PIXEL_FORMAT_ARGB8888, __pMagnifierBitmap);
109 _EditCopyPasteMagnifier::~_EditCopyPasteMagnifier(void)
111 if (__pMagnifierBitmap)
113 delete __pMagnifierBitmap;
114 __pMagnifierBitmap = null;
119 _EditCopyPasteMagnifier::GetMagnifierBitmap(void) const
121 return __pMagnifierBitmap;
124 _EditCopyPasteMagnifier*
125 _EditCopyPasteMagnifier::CreateInstanceN(const FloatPoint& point, int handlerCursorPos, _EditCopyPasteManager* pCopyPasteManager)
127 _EditCopyPasteMagnifier* pCopyPasteMagnifier = new (std::nothrow) _EditCopyPasteMagnifier(pCopyPasteManager, handlerCursorPos);
128 SysTryReturn(NID_UI_CTRL, pCopyPasteMagnifier != null, null, E_OUT_OF_MEMORY, "pCopyPasteMagnifier is null");
130 FloatPoint cursorPoint(point);
131 FloatRectangle bounds(0.0f, 0.0f, 0.0f, 0.0f);
134 _Edit* pEdit = pCopyPasteManager->GetEdit();
135 _ControlOrientation orientation = pEdit->GetOrientation();
137 Bitmap* pMagnifierBitmap = pCopyPasteMagnifier->GetMagnifierBitmap();
138 SysTryReturn(NID_UI_CTRL, pMagnifierBitmap != null, null, E_OUT_OF_MEMORY, "pMagnifierBitmap is null");
140 result r = pCopyPasteMagnifier->CreateRootVisualElement();
141 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
143 pCopyPasteMagnifier->SetActivationEnabled(false);
145 GET_SHAPE_CONFIG(EDIT::COPYPASTE_MAGNIFIER_WIDTH, orientation, width);
146 GET_SHAPE_CONFIG(EDIT::COPYPASTE_MAGNIFIER_HEIGHT, orientation, height);
148 bounds = FloatRectangle(cursorPoint.x - width/2, cursorPoint.y - height, width, height);
153 pCopyPasteMagnifier->SetBounds(bounds);
154 pCopyPasteMagnifier->Open();
156 return pCopyPasteMagnifier;
159 pCopyPasteMagnifier->Close();
160 delete pCopyPasteMagnifier;
166 _EditCopyPasteMagnifier::OnAttachedToMainTree(void)
168 result r = E_SUCCESS;
170 if (GetOwner() == null)
172 _Edit* pEdit = __pCopyPasteManager->GetEdit();
173 SysTryReturnResult(NID_UI_CTRL, pEdit, GetLastResult(), "Unable to get pEdit.");
175 _EditPresenter* pEditPresenter = pEdit->GetPresenter();
176 SysTryReturnResult(NID_UI_CTRL, pEdit, GetLastResult(), "Unable to get pEditPresenter.");
178 _Form* pParentForm = pEditPresenter->GetParentForm();
181 SetOwner(pParentForm);
186 _Frame* pCurrentFrame = dynamic_cast <_Frame*>(_ControlManager::GetInstance()->GetCurrentFrame());
189 pForm = pCurrentFrame->GetCurrentForm();
196 SetOwner(pCurrentFrame);
206 _EditCopyPasteMagnifier::OnDraw(void)
208 _EcoreEvas* pEcoreEvas = GetEcoreEvasMgr()->GetEcoreEvas();
209 SysTryReturnVoidResult(NID_UI_CTRL, pEcoreEvas, E_INVALID_STATE, "pEcoreEvas is null.");
211 pEcoreEvas->SetWindowBounds(*GetRootWindow(), __windowBounds);
213 Canvas* pCanvas = GetCanvasN();
218 pCanvas->SetBackgroundColor(Color(0, 0, 0, 0));
220 if (_BitmapImpl::CheckNinePatchedBitmapStrictly(*__pMagnifierBitmap))
222 pCanvas->DrawNinePatchedBitmap(pCanvas->GetBoundsF(), *__pMagnifierBitmap);
226 pCanvas->DrawBitmap(pCanvas->GetBoundsF(), *__pMagnifierBitmap);
229 CaptureTextArea(*pCanvas);
236 _EditCopyPasteMagnifier::CaptureTextArea(Canvas& canvas)
238 result r = E_SUCCESS;
239 float captureWidth = 0.0f;
240 float captureHeight = 0.0f;
241 float capturePosX = 0.0f;
242 float capturePosY = 0.0f;
243 float adjustPoxX = 0.0f;
244 float adjustPoxY = 0.0f;
245 FloatRectangle cursorBounds(0.0f, 0.0f, 0.0f, 0.0f);
246 FloatRectangle captureBounds(0.0f, 0.0f, 0.0f, 0.0f);
248 _Edit* pEdit = __pCopyPasteManager->GetEdit();
249 SysTryReturnVoidResult(NID_UI_CTRL, pEdit, E_INVALID_STATE, "pEdit is null.");
251 _EditPresenter* pEditPresenter = pEdit->GetPresenter();
252 SysTryReturnVoidResult(NID_UI_CTRL, pEditPresenter, E_INVALID_STATE, "pEditPresenter is null.");
254 pEditPresenter->CalculateCursorBounds(pEditPresenter->GetTextBoundsF(), cursorBounds, __handlerCursorPos);
256 GET_SHAPE_CONFIG(EDIT::COPYPASTE_MAGNIFIER_CAPTURE_WIDTH, pEdit->GetOrientation(), captureWidth);
257 GET_SHAPE_CONFIG(EDIT::COPYPASTE_MAGNIFIER_CAPTURE_HEIGHT, pEdit->GetOrientation(), captureHeight);
258 GET_SHAPE_CONFIG(EDIT::COPYPASTE_MAGNIFIER_CAPTURE_POSITION_X, pEdit->GetOrientation(), capturePosX);
259 GET_SHAPE_CONFIG(EDIT::COPYPASTE_MAGNIFIER_CAPTURE_POSITION_Y, pEdit->GetOrientation(), capturePosY);
261 FloatRectangle textObjectBounds = pEditPresenter->GetTextBoundsF();
262 captureBounds.x = cursorBounds.x - captureWidth/2.0f;
263 captureBounds.y = cursorBounds.y + cursorBounds.height/2 - captureHeight/2;
264 captureBounds.width = captureWidth;
265 captureBounds.height = captureHeight;
266 captureBounds = textObjectBounds.GetIntersection(captureBounds);
268 if (captureBounds.width < captureWidth && captureBounds.x < textObjectBounds.x + textObjectBounds.width - captureBounds.width)
270 adjustPoxX = captureWidth - captureBounds.width;
272 if (captureBounds.height < captureHeight && captureBounds.y < captureHeight)
274 adjustPoxY = captureHeight - captureBounds.height;
277 Bitmap* pOriginalBitmp = pEdit->GetCapturedBitmapN(true);
278 SysTryReturnVoidResult(NID_UI_CTRL, pOriginalBitmp, E_INVALID_STATE, "pOriginalBitmp is null.");
281 r = bitmap.Construct(captureBounds);
282 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
284 r = bitmap.Merge(FloatPoint(0.0f, 0.0f), *pOriginalBitmp, captureBounds);
285 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
287 r = bitmap.SetScalingQuality(BITMAP_SCALING_QUALITY_HIGH);
288 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
290 r = bitmap.Scale(FloatDimension(bitmap.GetWidth()*1.5f, bitmap.GetHeight()*1.5f));
291 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
293 canvas.DrawBitmap(FloatPoint(capturePosX + adjustPoxX*1.5f, capturePosY + adjustPoxY*1.5f), bitmap);
295 delete pOriginalBitmp;
300 delete pOriginalBitmp;
306 _EditCopyPasteMagnifier::MoveMagnifier(const FloatPoint& point, int handlerCursorPos)
308 FloatRectangle bounds = FloatRectangle(point.x - GetBoundsF().width/2, point.y - GetBoundsF().height, GetBoundsF().width, GetBoundsF().height);
309 __handlerCursorPos = handlerCursorPos;
319 _EditCopyPasteMagnifier::OnBoundsChanging(const FloatRectangle& bounds)
321 result r = E_SUCCESS;
323 __windowBounds = bounds;
329 _EditCopyPasteMagnifier::OnBoundsChanging(const Rectangle& bounds)
331 result r = E_SUCCESS;
337 _EditCopyPasteMagnifier::SetRowColumnIndex(int rowIndex, int columnIndex)
339 __rowIndex = rowIndex;
340 __columnIndex = columnIndex;
344 * @class _EditCopyPasteHandler
345 * @brief This class defines the common behavior for the %_EditCopyPasteHandler.
348 class _EditCopyPasteHandler
350 , virtual public IEventListener
351 , virtual public _IUiEventListener
352 , virtual public _IUiEventPreviewer
358 * This is the default class constructor.
361 _EditCopyPasteHandler(const Point& point, int handlerCursorPos, _EditCopyPasteManager* pCopyPasteManager, bool singleHandler, bool leftHandler);
362 _EditCopyPasteHandler(const FloatPoint& point, int handlerCursorPos, _EditCopyPasteManager* pCopyPasteManager, bool singleHandler, bool leftHandler);
365 * This is the default class destructor.
368 virtual ~_EditCopyPasteHandler(void);
372 enum HandlerDirection
374 HANDLER_DIRECTION_NONE = 0,
375 HANDLER_DIRECTION_REVERSE_1,//horizontal reverse
376 HANDLER_DIRECTION_REVERSE_2,//vertical reverse
377 HANDLER_DIRECTION_REVERSE_3,//horizontal vertical reverse
380 static _EditCopyPasteHandler* CreateInstanceN(const Point& point, int handlerCursorPos, _EditCopyPasteManager* pCopyPasteManager, bool singleHandler, bool leftHandler = true);
381 static _EditCopyPasteHandler* CreateInstanceN(const FloatPoint& point, int handlerCursorPos, _EditCopyPasteManager* pCopyPasteManager, bool singleHandler, bool leftHandler = true);
382 int GetHandlerCursorPosition(void) const;
383 void GetHandlerRowColumnIndex(int& rowIndex, int& columnIndex) const;
384 void SetHandlerCursorPosition(int handlerCursorPos);
385 void AdjustBounds(void);
386 void CheckReverseStatus(void);
387 void ChangeHandlerBitmap(void);
388 Bitmap* GetHandlerBitmap(void) const;
389 bool CreateCopyPasteMagnifier(void);
390 void DestroyCopyPasteMagnifier(void);
391 void MoveCopyPasteMagnifier(void);
392 void UpdateCopyPasteMagnifier(void);
395 virtual void OnDraw(void);
396 virtual bool OnTouchPressed(const _Control& source, const _TouchInfo& touchinfo);
397 virtual bool OnTouchMoved(const _Control& source, const _TouchInfo& touchinfo);
398 virtual bool OnTouchReleased(const _Control& source, const _TouchInfo& touchinfo);
399 virtual bool IsActivatedOnOpen(void) const;
400 virtual void OnChangeLayout(_ControlOrientation orientation);
401 virtual result OnAttachedToMainTree(void);
403 result OnBoundsChanging(const Rectangle& bounds);
404 result OnBoundsChanging(const FloatRectangle& bounds);
405 result SetWindowBounds(const Rectangle& bounds);
406 result SetWindowBounds(const FloatRectangle& bounds);
409 _EditCopyPasteHandler(const _EditCopyPasteHandler& value);
410 _EditCopyPasteHandler& operator =(const _EditCopyPasteHandler& value);
414 _VisualElement* __pRoot;
415 Bitmap* __pHandlerBitmap;
416 FloatPoint __touchPressedPoint;
417 FloatPoint __absoluteTouchPressedPoint;
418 _EditCopyPasteManager* __pCopyPasteManager;
421 int __handlerCursorPos;
422 bool __isTouchPressed;
423 FloatRectangle __windowBounds;
424 HandlerDirection __handlerDirection;
425 bool __singleHandler;
426 _EditCopyPasteMagnifier* __pCopyPasteMagnifier;
427 bool __isTouchMoving;
430 }; // _EditCopyPasteHandler
433 _EditCopyPasteHandler::GetHandlerBitmap(void) const
435 return __pHandlerBitmap;
439 _EditCopyPasteHandler::CreateCopyPasteMagnifier(void)
441 if (!__pCopyPasteMagnifier)
443 _Edit* pEdit = __pCopyPasteManager->GetEdit();
444 SysTryReturn(NID_UI_CTRL, pEdit, false, E_INVALID_STATE, "[E_INVALID_STATE] pEdit is null.\n");
446 _EditPresenter* pEditPresenter = pEdit->GetPresenter();
447 SysTryReturn(NID_UI_CTRL, pEditPresenter, false, E_INVALID_STATE, "[E_INVALID_STATE] pEditPresenter is null.\n");
449 FloatRectangle cursorBounds(0.0f, 0.0f, 0.0f, 0.0f);
450 if (__rowIndex == -1 && __columnIndex == -1)
452 pEditPresenter->CalculateAbsoluteCursorBounds(__handlerCursorPos, cursorBounds);
456 pEditPresenter->CalculateAbsoluteCursorBounds(__rowIndex, __columnIndex, cursorBounds);
458 __pCopyPasteMagnifier = _EditCopyPasteMagnifier::CreateInstanceN(FloatPoint(cursorBounds.x, cursorBounds.y), __handlerCursorPos, __pCopyPasteManager);
459 SysTryReturn(NID_UI_CTRL, __pCopyPasteMagnifier, false, E_INVALID_STATE, "[E_INVALID_STATE] __pCopyPasteMagnifier is null.\n");
461 __pCopyPasteMagnifier->SetRowColumnIndex(__rowIndex, __columnIndex);
467 _EditCopyPasteHandler::DestroyCopyPasteMagnifier(void)
469 if (__pCopyPasteMagnifier)
471 __pCopyPasteMagnifier->Close();
472 delete __pCopyPasteMagnifier;
473 __pCopyPasteMagnifier = null;
478 _EditCopyPasteHandler::MoveCopyPasteMagnifier(void)
480 if (__pCopyPasteMagnifier)
482 _Edit* pEdit = __pCopyPasteManager->GetEdit();
483 SysTryReturnVoidResult(NID_UI_CTRL, pEdit, E_INVALID_STATE, "pEdit is null.");
485 _EditPresenter* pEditPresenter = pEdit->GetPresenter();
486 SysTryReturnVoidResult(NID_UI_CTRL, pEditPresenter, E_INVALID_STATE, "pEditPresenter is null.");
488 FloatRectangle cursorBounds(0.0f, 0.0f, 0.0f, 0.0f);
489 if (__rowIndex == -1 && __columnIndex == -1)
491 pEditPresenter->CalculateAbsoluteCursorBounds(__handlerCursorPos, cursorBounds);
495 pEditPresenter->CalculateAbsoluteCursorBounds(__rowIndex, __columnIndex, cursorBounds);
496 __pCopyPasteMagnifier->SetRowColumnIndex(__rowIndex, __columnIndex);
498 __pCopyPasteMagnifier->MoveMagnifier(FloatPoint(cursorBounds.x, cursorBounds.y), __handlerCursorPos);
503 _EditCopyPasteHandler::UpdateCopyPasteMagnifier(void)
505 if (__pCopyPasteMagnifier)
507 __pCopyPasteMagnifier->Invalidate();
512 _EditCopyPasteHandler::ChangeHandlerBitmap(void)
514 if (__pHandlerBitmap)
516 delete __pHandlerBitmap;
517 __pHandlerBitmap = null;
521 if (__handlerDirection == HANDLER_DIRECTION_NONE)
523 GET_BITMAP_CONFIG_N(EDIT::COPY_PASTE_ICON_CENTER_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, __pHandlerBitmap);
527 GET_BITMAP_CONFIG_N(EDIT::COPY_PASTE_ICON_REVERSE_CENTER_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, __pHandlerBitmap);
533 switch(__handlerDirection)
535 case HANDLER_DIRECTION_REVERSE_1:
536 GET_BITMAP_CONFIG_N(EDIT::COPY_PASTE_ICON_RIGHT_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, __pHandlerBitmap);
538 case HANDLER_DIRECTION_REVERSE_2:
539 GET_BITMAP_CONFIG_N(EDIT::COPY_PASTE_ICON_REVERSE_LEFT_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, __pHandlerBitmap);
541 case HANDLER_DIRECTION_REVERSE_3:
542 GET_BITMAP_CONFIG_N(EDIT::COPY_PASTE_ICON_REVERSE_RIGHT_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, __pHandlerBitmap);
544 case HANDLER_DIRECTION_NONE:
547 GET_BITMAP_CONFIG_N(EDIT::COPY_PASTE_ICON_LEFT_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, __pHandlerBitmap);
553 switch(__handlerDirection)
555 case HANDLER_DIRECTION_REVERSE_1:
556 GET_BITMAP_CONFIG_N(EDIT::COPY_PASTE_ICON_LEFT_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, __pHandlerBitmap);
558 case HANDLER_DIRECTION_REVERSE_2:
559 GET_BITMAP_CONFIG_N(EDIT::COPY_PASTE_ICON_REVERSE_RIGHT_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, __pHandlerBitmap);
561 case HANDLER_DIRECTION_REVERSE_3:
562 GET_BITMAP_CONFIG_N(EDIT::COPY_PASTE_ICON_REVERSE_LEFT_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, __pHandlerBitmap);
564 case HANDLER_DIRECTION_NONE:
567 GET_BITMAP_CONFIG_N(EDIT::COPY_PASTE_ICON_RIGHT_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, __pHandlerBitmap);
573 _EditCopyPasteHandler::_EditCopyPasteHandler(const Point& point, int handlerCursorPos, _EditCopyPasteManager* pCopyPasteManager, bool singleHandler, bool leftHandler)
575 , __pHandlerBitmap(null)
576 , __touchPressedPoint(0.0f, 0.0f)
577 , __absoluteTouchPressedPoint(0.0f, 0.0f)
578 , __pCopyPasteManager(pCopyPasteManager)
579 , __leftHandler(leftHandler)
580 , __reverseCheck(false)
581 , __handlerCursorPos(handlerCursorPos)
582 , __isTouchPressed(false)
583 , __windowBounds(0.0f, 0.0f, 0.0f, 0.0f)
584 , __handlerDirection(HANDLER_DIRECTION_NONE)
585 , __singleHandler(false)
586 , __pCopyPasteMagnifier(null)
587 , __isTouchMoving(false)
593 __pRoot = GetVisualElement();
594 __pRoot->SetSurfaceOpaque(false);
596 Point handlerPoint(point);
600 GET_BITMAP_CONFIG_N(EDIT::COPY_PASTE_ICON_CENTER_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, __pHandlerBitmap);
601 handlerPoint.x = handlerPoint.x - (__pHandlerBitmap->GetWidth() / 2);
602 __singleHandler = true;
608 GET_BITMAP_CONFIG_N(EDIT::COPY_PASTE_ICON_LEFT_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, __pHandlerBitmap);
609 handlerPoint.x = handlerPoint.x - __pHandlerBitmap->GetWidth();
613 GET_BITMAP_CONFIG_N(EDIT::COPY_PASTE_ICON_RIGHT_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, __pHandlerBitmap);
617 FloatRectangle bounds(handlerPoint.x, handlerPoint.y, __pHandlerBitmap->GetWidth(), __pHandlerBitmap->GetHeight());
620 _EditCopyPasteHandler::_EditCopyPasteHandler(const FloatPoint& point, int handlerCursorPos, _EditCopyPasteManager* pCopyPasteManager, bool singleHandler, bool leftHandler)
622 , __pHandlerBitmap(null)
623 , __touchPressedPoint(0.0f, 0.0f)
624 , __absoluteTouchPressedPoint(0.0f, 0.0f)
625 , __pCopyPasteManager(pCopyPasteManager)
626 , __leftHandler(leftHandler)
627 , __reverseCheck(false)
628 , __handlerCursorPos(handlerCursorPos)
629 , __isTouchPressed(false)
630 , __windowBounds(0.0f, 0.0f, 0.0f, 0.0f)
631 , __handlerDirection(HANDLER_DIRECTION_NONE)
632 , __singleHandler(false)
633 , __pCopyPasteMagnifier(null)
634 , __isTouchMoving(false)
640 __pRoot = GetVisualElement();
641 __pRoot->SetSurfaceOpaque(false);
644 //Point handlerPoint(_CoordinateSystemUtils::ConvertToInteger(point));
645 FloatPoint handlerPoint(point);
648 GET_BITMAP_CONFIG_N(EDIT::COPY_PASTE_ICON_CENTER_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, __pHandlerBitmap);
649 handlerPoint.x = handlerPoint.x - (__pHandlerBitmap->GetWidthF() / 2.0f);
650 __singleHandler = true;
656 GET_BITMAP_CONFIG_N(EDIT::COPY_PASTE_ICON_LEFT_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, __pHandlerBitmap);
657 handlerPoint.x = handlerPoint.x - __pHandlerBitmap->GetWidthF();
661 GET_BITMAP_CONFIG_N(EDIT::COPY_PASTE_ICON_RIGHT_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, __pHandlerBitmap);
665 FloatRectangle bounds(handlerPoint.x, handlerPoint.y, _CoordinateSystemUtils::ConvertToFloat(__pHandlerBitmap->GetWidth()), _CoordinateSystemUtils::ConvertToFloat(__pHandlerBitmap->GetHeight()));
668 _EditCopyPasteHandler::~_EditCopyPasteHandler(void)
670 DestroyCopyPasteMagnifier();
672 if (__pHandlerBitmap)
674 delete __pHandlerBitmap;
675 __pHandlerBitmap = null;
679 _EditCopyPasteHandler*
680 _EditCopyPasteHandler::CreateInstanceN(const Point& point, int handlerCursorPos, _EditCopyPasteManager* pCopyPasteManager, bool singleHandler, bool leftHandler)
682 _EditCopyPasteHandler* pCopyPasteHandler = new (std::nothrow) _EditCopyPasteHandler(point, handlerCursorPos, pCopyPasteManager, singleHandler, leftHandler);
683 SysTryReturn(NID_UI_CTRL, pCopyPasteHandler != null, null, E_OUT_OF_MEMORY, "pContextMenu is null");
685 Point handlerPoint(point);
686 Rectangle bounds(0, 0, 0, 0);
687 Bitmap* pHandlerBitmap = pCopyPasteHandler->GetHandlerBitmap();
689 result r = pCopyPasteHandler->CreateRootVisualElement();
690 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
692 pCopyPasteHandler->SetActivationEnabled(false);
696 handlerPoint.x = handlerPoint.x - (pHandlerBitmap->GetWidth() / 2);
702 handlerPoint.x = handlerPoint.x - pHandlerBitmap->GetWidth();
706 bounds.x = handlerPoint.x;
707 bounds.y = handlerPoint.y;
708 bounds.width = pHandlerBitmap->GetWidth();
709 bounds.height = pHandlerBitmap->GetHeight();
711 pCopyPasteHandler->SetBounds(bounds);
712 pCopyPasteHandler->CheckReverseStatus();
713 pCopyPasteHandler->Open(false);
715 return pCopyPasteHandler;
718 pCopyPasteHandler->Close();
719 delete pCopyPasteHandler;
724 _EditCopyPasteHandler*
725 _EditCopyPasteHandler::CreateInstanceN(const FloatPoint& point, int handlerCursorPos, _EditCopyPasteManager* pCopyPasteManager, bool singleHandler, bool leftHandler)
727 _EditCopyPasteHandler* pCopyPasteHandler = new (std::nothrow) _EditCopyPasteHandler(point, handlerCursorPos, pCopyPasteManager, singleHandler, leftHandler);
728 SysTryReturn(NID_UI_CTRL, pCopyPasteHandler != null, null, E_OUT_OF_MEMORY, "pContextMenu is null");
730 FloatPoint handlerPoint(point);
731 FloatRectangle bounds(0.0f, 0.0f, 0.0f, 0.0f);
732 Bitmap* pHandlerBitmap = pCopyPasteHandler->GetHandlerBitmap();
734 result r = pCopyPasteHandler->CreateRootVisualElement();
735 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
737 pCopyPasteHandler->SetActivationEnabled(false);
741 handlerPoint.x = handlerPoint.x - (pHandlerBitmap->GetWidthF() / 2.0f);
747 handlerPoint.x = handlerPoint.x - pHandlerBitmap->GetWidthF();
751 bounds.x = handlerPoint.x;
752 bounds.y = handlerPoint.y;
753 bounds.width = pHandlerBitmap->GetWidthF();
754 bounds.height = pHandlerBitmap->GetHeightF();
756 pCopyPasteHandler->SetBounds(bounds);
757 pCopyPasteHandler->CheckReverseStatus();
758 pCopyPasteHandler->Open(false);
760 return pCopyPasteHandler;
763 pCopyPasteHandler->Close();
764 delete pCopyPasteHandler;
770 _EditCopyPasteHandler::GetHandlerCursorPosition(void) const
772 return __handlerCursorPos;
776 _EditCopyPasteHandler::GetHandlerRowColumnIndex(int& rowIndex, int& columnIndex) const
778 rowIndex = __rowIndex;
779 columnIndex = __columnIndex;
783 _EditCopyPasteHandler::SetHandlerCursorPosition(int handlerCursorPos)
785 __handlerCursorPos = handlerCursorPos;
789 _EditCopyPasteHandler::AdjustBounds(void)
791 FloatRectangle cursorRect;
792 FloatRectangle rect = GetBoundsF();
793 FloatPoint checkPoint(0.0f, 0.0f);
794 _Edit* pEdit = __pCopyPasteManager->GetEdit();
795 _EditPresenter* pEditPresenter = pEdit->GetPresenter();
799 if (__rowIndex == -1 && __columnIndex == -1)
801 pEditPresenter->CalculateAbsoluteCursorBounds(__handlerCursorPos, cursorRect);
805 pEditPresenter->CalculateAbsoluteCursorBounds(__rowIndex, __columnIndex, cursorRect);
807 rect.x = cursorRect.x - __pHandlerBitmap->GetWidthF()/2.0f;
808 rect.y = cursorRect.y + cursorRect.height;
809 checkPoint = FloatPoint(cursorRect.x , cursorRect.y + cursorRect.height);
810 if (__handlerDirection == HANDLER_DIRECTION_REVERSE_2)
812 rect.y -= (cursorRect.height + __pHandlerBitmap->GetHeightF());
817 if (__rowIndex == -1 && __columnIndex == -1)
819 pEditPresenter->CalculateAbsoluteCursorBounds(__handlerCursorPos, cursorRect);
823 pEditPresenter->CalculateAbsoluteCursorBounds(__rowIndex, __columnIndex, cursorRect);
826 rect.x = cursorRect.x;
827 rect.y = cursorRect.y + cursorRect.height;
829 checkPoint = FloatPoint(cursorRect.x, cursorRect.y + cursorRect.height);
833 if (__handlerDirection == HANDLER_DIRECTION_NONE)
835 rect.x = rect.x - __pHandlerBitmap->GetWidthF();
837 else if (__handlerDirection == HANDLER_DIRECTION_REVERSE_2)
839 rect.x = rect.x - __pHandlerBitmap->GetWidthF();
840 rect.y -= (rect.height + cursorRect.height);
842 else if (__handlerDirection == HANDLER_DIRECTION_REVERSE_3)
844 rect.y -= (rect.height + cursorRect.height);
849 if (__handlerDirection == HANDLER_DIRECTION_REVERSE_1)
851 rect.x = rect.x - __pHandlerBitmap->GetWidthF();
853 else if (__handlerDirection == HANDLER_DIRECTION_REVERSE_2)
855 rect.y -= (rect.height + cursorRect.height);
857 else if (__handlerDirection == HANDLER_DIRECTION_REVERSE_3)
859 rect.x = rect.x - __pHandlerBitmap->GetWidthF();
860 rect.y -= (rect.height + cursorRect.height);
865 if (!__isTouchMoving)
867 bool visibleState = __pCopyPasteManager->CheckHandleBounds(checkPoint);
868 if (visibleState && !GetVisibleState())
870 SetVisibleState(true);
873 else if (!visibleState && GetVisibleState())
875 SetVisibleState(false);
885 _EditCopyPasteHandler::OnDraw(void)
887 Canvas* pCanvas = GetCanvasN();
892 pCanvas->SetBackgroundColor(Color(0, 0, 0, 0));
894 if (_BitmapImpl::CheckNinePatchedBitmapStrictly(*__pHandlerBitmap))
896 pCanvas->DrawNinePatchedBitmap(pCanvas->GetBoundsF(), *__pHandlerBitmap);
900 pCanvas->DrawBitmap(pCanvas->GetBoundsF(), *__pHandlerBitmap);
907 SetWindowBounds(__windowBounds);
908 __reverseCheck = false;
912 SetWindowBounds(__windowBounds);
917 _EditCopyPasteHandler::OnTouchPressed(const _Control& source, const _TouchInfo& touchinfo)
919 __pCopyPasteManager->ReleaseCopyPastePopup();
920 #if EDIT_COPY_PASTE_MAGNIFIER
921 CreateCopyPasteMagnifier();
923 __touchPressedPoint = touchinfo.GetCurrentPosition();
924 __absoluteTouchPressedPoint = FloatPoint(GetBoundsF().x + __touchPressedPoint.x, GetBoundsF().y + __touchPressedPoint.y);
925 __isTouchPressed = true;
931 _EditCopyPasteHandler::CheckReverseStatus(void)
933 FloatDimension screenSize;
934 _ControlManager* pControlManager = _ControlManager::GetInstance();
935 _Edit* pEdit = __pCopyPasteManager->GetEdit();
936 _ControlOrientation orientation = pEdit->GetOrientation();
937 FloatRectangle rect = GetBoundsF();
938 FloatRectangle cursorAbsBounds = __pCopyPasteManager->GetCursorBoundsF(true);
940 if (orientation == _CONTROL_ORIENTATION_PORTRAIT)
942 screenSize = pControlManager->GetScreenSizeF();
946 screenSize.width = pControlManager->GetScreenSizeF().height;
947 screenSize.height = pControlManager->GetScreenSizeF().width;
952 if ((__handlerDirection == HANDLER_DIRECTION_NONE) && ((cursorAbsBounds.y + cursorAbsBounds.height + rect.height) > screenSize.height))
954 __handlerDirection = HANDLER_DIRECTION_REVERSE_2;
955 rect.y -= (cursorAbsBounds.height + rect.height);
956 __reverseCheck = true;
958 else if ((__handlerDirection == HANDLER_DIRECTION_REVERSE_2) && ((cursorAbsBounds.y + cursorAbsBounds.height + rect.height) <= screenSize.height))
960 __handlerDirection = HANDLER_DIRECTION_NONE;
961 rect.y += (cursorAbsBounds.height + rect.height);
962 __reverseCheck = true;
964 ChangeHandlerBitmap();
971 if (((__handlerDirection == HANDLER_DIRECTION_NONE) || (__handlerDirection == HANDLER_DIRECTION_REVERSE_2)) && rect.x < 0.0f)
973 if ((__handlerDirection == HANDLER_DIRECTION_NONE) && ((rect.y + rect.height) > screenSize.height))
975 __handlerDirection = HANDLER_DIRECTION_REVERSE_3;
976 rect.y -= (rect.height + cursorAbsBounds.height);
978 else if ((__handlerDirection == HANDLER_DIRECTION_NONE) && ((rect.y + rect.height) <= screenSize.height))
980 __handlerDirection = HANDLER_DIRECTION_REVERSE_1;
982 else if ((__handlerDirection == HANDLER_DIRECTION_REVERSE_2) && ((rect.y + 2*rect.height) > screenSize.height))
984 __handlerDirection = HANDLER_DIRECTION_REVERSE_3;
986 else if ((__handlerDirection == HANDLER_DIRECTION_REVERSE_2) && ((rect.y + 2*rect.height) <= screenSize.height))
988 __handlerDirection = HANDLER_DIRECTION_REVERSE_1;
989 rect.y += (rect.height + cursorAbsBounds.height);
991 ChangeHandlerBitmap();
992 rect.x += rect.width;
993 __reverseCheck = true;
995 else if (((__handlerDirection == HANDLER_DIRECTION_REVERSE_1) || (__handlerDirection == HANDLER_DIRECTION_REVERSE_3)) && rect.x >= rect.width)
997 if ((__handlerDirection == HANDLER_DIRECTION_REVERSE_1) && ((rect.y + rect.height) > screenSize.height))
999 __handlerDirection = HANDLER_DIRECTION_REVERSE_2;
1000 rect.y -= (rect.height + cursorAbsBounds.height);
1002 else if ((__handlerDirection == HANDLER_DIRECTION_REVERSE_1) && ((rect.y + rect.height) <= screenSize.height))
1004 __handlerDirection = HANDLER_DIRECTION_NONE;
1006 else if ((__handlerDirection == HANDLER_DIRECTION_REVERSE_3) && ((rect.y + 2*rect.height) > screenSize.height))
1008 __handlerDirection = HANDLER_DIRECTION_REVERSE_2;
1010 else if ((__handlerDirection == HANDLER_DIRECTION_REVERSE_3) && ((rect.y + 2*rect.height) <= screenSize.height))
1012 __handlerDirection = HANDLER_DIRECTION_NONE;
1013 rect.y += (rect.height + cursorAbsBounds.height);
1015 ChangeHandlerBitmap();
1016 rect.x -= rect.width;
1017 __reverseCheck = true;
1019 else if (((__handlerDirection == HANDLER_DIRECTION_NONE) || (__handlerDirection == HANDLER_DIRECTION_REVERSE_1)) && ((rect.y + rect.height) > screenSize.height))
1021 if ((__handlerDirection == HANDLER_DIRECTION_NONE) && rect.x < rect.width)
1023 __handlerDirection = HANDLER_DIRECTION_REVERSE_3;
1024 rect.x += rect.width;
1026 else if ((__handlerDirection == HANDLER_DIRECTION_NONE) && rect.x >= rect.width)
1028 __handlerDirection = HANDLER_DIRECTION_REVERSE_2;
1030 else if ((__handlerDirection == HANDLER_DIRECTION_REVERSE_1) && ((rect.x - rect.width) >= 0.0f))
1032 __handlerDirection = HANDLER_DIRECTION_REVERSE_2;
1033 rect.x -= rect.width;
1035 else if ((__handlerDirection == HANDLER_DIRECTION_REVERSE_1) && ((rect.x - rect.width) < 0.0f))
1037 __handlerDirection = HANDLER_DIRECTION_REVERSE_3;
1039 rect.y -= (rect.height + cursorAbsBounds.height);
1040 ChangeHandlerBitmap();
1041 __reverseCheck = true;
1043 else if (((__handlerDirection == HANDLER_DIRECTION_REVERSE_2) || (__handlerDirection == HANDLER_DIRECTION_REVERSE_3)) && ((rect.y + 2*rect.height + cursorAbsBounds.height) <= screenSize.height))
1045 if ((__handlerDirection == HANDLER_DIRECTION_REVERSE_2) && rect.x < 0.0f)
1047 __handlerDirection = HANDLER_DIRECTION_REVERSE_1;
1048 rect.x += rect.width;
1050 else if ((__handlerDirection == HANDLER_DIRECTION_REVERSE_2) && rect.x >= rect.width)
1052 __handlerDirection = HANDLER_DIRECTION_NONE;
1054 else if ((__handlerDirection == HANDLER_DIRECTION_REVERSE_3) && ((rect.x - rect.width) >= 0.0f))
1056 __handlerDirection = HANDLER_DIRECTION_NONE;
1057 rect.x -= rect.width;
1059 else if ((__handlerDirection == HANDLER_DIRECTION_REVERSE_3) && ((rect.x - rect.width) < 0.0f))
1061 __handlerDirection = HANDLER_DIRECTION_REVERSE_1;
1063 rect.y += (rect.height + cursorAbsBounds.height);
1064 ChangeHandlerBitmap();
1065 __reverseCheck = true;
1070 if (((__handlerDirection == HANDLER_DIRECTION_NONE) || (__handlerDirection == HANDLER_DIRECTION_REVERSE_2)) && (rect.x + rect.width) > screenSize.width)
1072 if ((__handlerDirection == HANDLER_DIRECTION_NONE) && ((rect.y + rect.height) > screenSize.height))
1074 __handlerDirection = HANDLER_DIRECTION_REVERSE_3;
1075 rect.y -= (rect.height + cursorAbsBounds.height);
1077 else if ((__handlerDirection == HANDLER_DIRECTION_NONE) && ((rect.y + rect.height) <= screenSize.height))
1079 __handlerDirection = HANDLER_DIRECTION_REVERSE_1;
1081 else if ((__handlerDirection == HANDLER_DIRECTION_REVERSE_2) && ((rect.y + 2*rect.height) > screenSize.height))
1083 __handlerDirection = HANDLER_DIRECTION_REVERSE_3;
1085 else if ((__handlerDirection == HANDLER_DIRECTION_REVERSE_2) && ((rect.y + 2*rect.height) <= screenSize.height))
1087 __handlerDirection = HANDLER_DIRECTION_REVERSE_1;
1088 rect.y += (rect.height + cursorAbsBounds.height);
1090 ChangeHandlerBitmap();
1091 rect.x -= rect.width;
1092 __reverseCheck = true;
1094 else if (((__handlerDirection == HANDLER_DIRECTION_REVERSE_1) || (__handlerDirection == HANDLER_DIRECTION_REVERSE_3)) && (rect.x + 2*rect.width) <= screenSize.width)
1096 if ((__handlerDirection == HANDLER_DIRECTION_REVERSE_1) && ((rect.y + rect.height) > screenSize.height))
1098 __handlerDirection = HANDLER_DIRECTION_REVERSE_2;
1099 rect.y -= (rect.height + cursorAbsBounds.height);
1101 else if ((__handlerDirection == HANDLER_DIRECTION_REVERSE_1) && ((rect.y + rect.height) <= screenSize.height))
1103 __handlerDirection = HANDLER_DIRECTION_NONE;
1105 else if ((__handlerDirection == HANDLER_DIRECTION_REVERSE_3) && ((rect.y + 2*rect.height) > screenSize.height))
1107 __handlerDirection = HANDLER_DIRECTION_REVERSE_2;
1109 else if ((__handlerDirection == HANDLER_DIRECTION_REVERSE_3) && ((rect.y + 2*rect.height) <= screenSize.height))
1111 __handlerDirection = HANDLER_DIRECTION_NONE;
1112 rect.y += (rect.height + cursorAbsBounds.height);
1114 ChangeHandlerBitmap();
1115 rect.x += rect.width;
1116 __reverseCheck = true;
1118 else if (((__handlerDirection == HANDLER_DIRECTION_NONE) || (__handlerDirection == HANDLER_DIRECTION_REVERSE_1)) && ((rect.y + rect.height) > screenSize.height))
1120 if ((__handlerDirection == HANDLER_DIRECTION_NONE) && (rect.x + rect.width) > screenSize.width)
1122 __handlerDirection = HANDLER_DIRECTION_REVERSE_3;
1123 rect.x -= rect.width;
1125 else if ((__handlerDirection == HANDLER_DIRECTION_NONE) && (rect.x + rect.width) <= screenSize.width)
1127 __handlerDirection = HANDLER_DIRECTION_REVERSE_2;
1129 else if ((__handlerDirection == HANDLER_DIRECTION_REVERSE_1) && (rect.x + 2*rect.width) <= screenSize.width)
1131 __handlerDirection = HANDLER_DIRECTION_REVERSE_2;
1132 rect.x += rect.width;
1134 else if ((__handlerDirection == HANDLER_DIRECTION_REVERSE_1) && (rect.x + 2*rect.width) > screenSize.width)
1136 __handlerDirection = HANDLER_DIRECTION_REVERSE_3;
1138 rect.y -= (rect.height + cursorAbsBounds.height);
1139 ChangeHandlerBitmap();
1140 __reverseCheck = true;
1142 else if (((__handlerDirection == HANDLER_DIRECTION_REVERSE_2) || (__handlerDirection == HANDLER_DIRECTION_REVERSE_3)) && ((rect.y + 2*rect.height + cursorAbsBounds.height) <= screenSize.height))
1144 if ((__handlerDirection == HANDLER_DIRECTION_REVERSE_2) && ((rect.x + rect.width) <= screenSize.width))
1146 __handlerDirection = HANDLER_DIRECTION_NONE;
1148 else if ((__handlerDirection == HANDLER_DIRECTION_REVERSE_2) && ((rect.x + rect.width) > screenSize.width))
1150 __handlerDirection = HANDLER_DIRECTION_REVERSE_1;
1151 rect.x -= rect.width;
1153 else if ((__handlerDirection == HANDLER_DIRECTION_REVERSE_3) && ((rect.x + 2*rect.width) <= screenSize.width))
1155 __handlerDirection = HANDLER_DIRECTION_NONE;
1156 rect.x += rect.width;
1158 else if ((__handlerDirection == HANDLER_DIRECTION_REVERSE_3) && ((rect.x + 2*rect.width) > screenSize.width))
1160 __handlerDirection = HANDLER_DIRECTION_REVERSE_1;
1162 rect.y += (rect.height + cursorAbsBounds.height);
1163 ChangeHandlerBitmap();
1164 __reverseCheck = true;
1172 _EditCopyPasteHandler::OnTouchReleased(const _Control& source, const _TouchInfo& touchinfo)
1174 CheckReverseStatus();
1175 __isTouchPressed = false;
1176 __absoluteTouchPressedPoint = FloatPoint(0.0f, 0.0f);
1177 DestroyCopyPasteMagnifier();
1178 __pCopyPasteManager->CreateCopyPastePopup();
1179 __pCopyPasteManager->Show();
1180 __pCopyPasteManager->SendTextBlockEvent();
1182 __isTouchMoving = false;
1187 _EditCopyPasteHandler::OnTouchMoved(const _Control& source, const _TouchInfo& touchinfo)
1190 int previousCursorPos = -1;
1191 FloatRectangle cursorRect(0.0f, 0.0f, 0.0f, 0.0f);
1192 FloatRectangle absCursorRect(0.0f, 0.0f, 0.0f, 0.0f);
1193 FloatRectangle rect = GetBoundsF();
1194 FloatPoint point = touchinfo.GetCurrentPosition();
1195 FloatPoint touchPoint(0.0f, 0.0f);
1196 FloatPoint checkPoint(0.0f, 0.0f);
1197 __isTouchMoving = true;
1198 bool cursorChange = false;
1200 _Edit* pEdit = __pCopyPasteManager->GetEdit();
1201 SysTryReturn(NID_UI_CTRL, pEdit, false, E_INVALID_STATE, "[E_INVALID_STATE] pEdit is null.\n");
1203 _EditPresenter* pEditPresenter = pEdit->GetPresenter();
1204 SysTryReturn(NID_UI_CTRL, pEditPresenter, false, E_INVALID_STATE, "[E_INVALID_STATE] pEditPresenter is null.\n");
1206 TextObject* pTextObject = pEditPresenter->GetTextObject();
1207 SysTryReturn(NID_UI_CTRL, pTextObject, false, E_INVALID_STATE, "[E_INVALID_STATE] pEditPresenter is null.\n");
1209 int curCursorLine = pTextObject->GetLineIndexAtTextIndex(__handlerCursorPos);
1210 int totalLine = pTextObject->GetTotalLineCount();
1212 float totalHeight = pTextObject->GetTotalHeightF();
1213 float firstDisplayY = pTextObject->GetFirstDisplayPositionYF();
1214 FloatRectangle absTextObjectBounds(0.0f, 0.0f, 0.0f, 0.0f);
1215 FloatRectangle textObjectBounds = pEditPresenter->GetTextBoundsF();
1216 FloatRectangle absEditBounds = pEdit->GetAbsoluteBoundsF();
1217 absTextObjectBounds.x = absEditBounds.x + textObjectBounds.x;
1218 absTextObjectBounds.y = absEditBounds.y + textObjectBounds.y;
1219 absTextObjectBounds.width = textObjectBounds.width;
1220 absTextObjectBounds.height = textObjectBounds.height;
1221 bool needToFixYPosition= false;
1223 if (__touchPressedPoint.x == point.x && __touchPressedPoint.y == point.y)
1228 if (!__singleHandler)
1230 previousCursorPos = __pCopyPasteManager->GetCursorPosition();
1233 FloatPoint absoluteTouchMovedPoint = FloatPoint(GetBoundsF().x + point.x, GetBoundsF().y + point.y);
1234 if (__handlerDirection == HANDLER_DIRECTION_REVERSE_2 || __handlerDirection == HANDLER_DIRECTION_REVERSE_3)
1236 absoluteTouchMovedPoint.y += (GetBoundsF().height + absCursorRect.height);
1238 if (__rowIndex == -1 && __columnIndex == -1)
1240 pEditPresenter->CalculateCursorBounds(pEditPresenter->GetTextBoundsF(), cursorRect,__handlerCursorPos);
1241 pEditPresenter->CalculateAbsoluteCursorBounds(__handlerCursorPos, absCursorRect);
1245 pEditPresenter->CalculateCursorBounds(pEditPresenter->GetTextBoundsF(), cursorRect, __rowIndex, __columnIndex);
1246 pEditPresenter->CalculateAbsoluteCursorBounds(__rowIndex, __columnIndex, absCursorRect);
1249 if (absTextObjectBounds.height >= (totalHeight - firstDisplayY))
1251 absTextObjectBounds.height = totalHeight - firstDisplayY;
1252 absTextObjectBounds.y += absCursorRect.height/2.0f;
1253 if (absTextObjectBounds.y > absoluteTouchMovedPoint.y || (absTextObjectBounds.y + absTextObjectBounds.height) < absoluteTouchMovedPoint.y)
1255 needToFixYPosition = true;
1260 absTextObjectBounds.y += absCursorRect.height/2.0f;
1261 if (firstDisplayY == 0.0f && absTextObjectBounds.y > absoluteTouchMovedPoint.y)
1263 needToFixYPosition = true;
1265 else if ((totalHeight - firstDisplayY) == absTextObjectBounds.height && (absTextObjectBounds.y + absTextObjectBounds.height) < absoluteTouchMovedPoint.y)
1267 needToFixYPosition = true;
1271 if (!__singleHandler)
1273 int nextHandlerLine = -1;
1276 nextHandlerLine = pTextObject->GetLineIndexAtTextIndex(__pCopyPasteManager->GetHandlerCursorPosition(Tizen::Ui::Controls::_EditCopyPasteManager::HANDLER_TYPE_RIGHT));
1280 nextHandlerLine = pTextObject->GetLineIndexAtTextIndex(__pCopyPasteManager->GetHandlerCursorPosition(Tizen::Ui::Controls::_EditCopyPasteManager::HANDLER_TYPE_LEFT));
1283 if (curCursorLine == nextHandlerLine)
1285 if (__leftHandler && absoluteTouchMovedPoint.y > absCursorRect.y)
1287 needToFixYPosition = true;
1289 else if (!__leftHandler && absoluteTouchMovedPoint.y < absCursorRect.y)
1291 needToFixYPosition = true;
1296 touchPoint.x = cursorRect.x + (point.x - __touchPressedPoint.x);
1297 if (totalLine == 1 || needToFixYPosition)
1299 touchPoint.y = cursorRect.y + cursorRect.height/2;
1303 touchPoint.y = cursorRect.y + cursorRect.height + (point.y - __touchPressedPoint.y);
1306 int columnIndex = -1;
1307 bool cursorPosFromTouch = false;
1308 cursorPos = pEditPresenter->GetCursorPositionAt(touchPoint, rowIndex, columnIndex, true);
1310 if (cursorPos != -1 && __handlerCursorPos != cursorPos)
1312 cursorPosFromTouch = true;
1313 FloatRectangle cursorBounds(0.0f, 0.0f, 0.0f, 0.0f);
1314 if (__rowIndex == -1 && __columnIndex == -1)
1316 pEdit->CalculateAbsoluteCursorBounds(cursorPos, cursorBounds);
1320 pEditPresenter->CalculateAbsoluteCursorBounds(__rowIndex, __columnIndex, cursorBounds);
1322 cursorChange = true;
1323 checkPoint.x = cursorBounds.x;
1325 if (absoluteTouchMovedPoint.y -__absoluteTouchPressedPoint.y >= 0.0f || totalLine == 1)
1327 checkPoint.y = cursorBounds.y + cursorBounds.height;
1331 checkPoint.y = cursorBounds.y;
1335 if (cursorPos == -1 || (cursorChange && !__pCopyPasteManager->CheckHandleBounds(FloatPoint(checkPoint.x, checkPoint.y))))
1337 if (cursorPos != -1)
1341 pTextObject->SetFirstDisplayLineIndexFromTextIndex(cursorPos);
1345 if (absoluteTouchMovedPoint.y -__absoluteTouchPressedPoint.y >= 0.0f)
1347 if (curCursorLine < totalLine - 1)
1349 if (!pTextObject->IsDisplayedLastLine())
1351 int line = pTextObject->GetFirstDisplayLineIndex();
1352 pTextObject->SetFirstDisplayLineIndex(line+1);
1356 if (__singleHandler || __pCopyPasteManager->CheckHandlePosition(__leftHandler, cursorPos))
1358 __pCopyPasteManager->SetCursorPosition(cursorPos);
1359 pEditPresenter->ScrollPanelToCursorPosition(true);
1370 if (curCursorLine !=0)
1372 if (!pTextObject->IsDisplayedFirstLine())
1374 int line = pTextObject->GetFirstDisplayLineIndex();
1375 pTextObject->SetFirstDisplayLineIndex(line-1);
1379 __pCopyPasteManager->SetCursorPosition(cursorPos);
1380 pEditPresenter->ScrollPanelToCursorPosition(true);
1390 if (point.x - __touchPressedPoint.x == 0.0f)
1395 else if (point.x - __touchPressedPoint.x > 0.0f)
1397 if (__handlerCursorPos == pEditPresenter->GetTextLength())
1399 cursorPos = __handlerCursorPos;
1403 cursorPos = __handlerCursorPos + 1;
1405 if (!__singleHandler && __leftHandler && (cursorPos == pEditPresenter->GetTextLength()))
1407 cursorPos = __handlerCursorPos;
1413 if (__handlerCursorPos != 0)
1415 cursorPos = __handlerCursorPos - 1;
1417 if (!__singleHandler && __leftHandler)
1419 pTextObject->SetFirstDisplayLineIndexFromTextIndex(cursorPos);
1423 if (point.y < 0.0f || (point.y > GetBoundsF().height))
1430 if (absoluteTouchMovedPoint.y -__absoluteTouchPressedPoint.y >= 0.0f)
1432 if (curCursorLine < totalLine - 1)
1434 int offset = __handlerCursorPos - pTextObject->GetFirstTextIndexAt(curCursorLine);
1435 int firstTextIndex = pTextObject->GetFirstTextIndexAt(curCursorLine+1);
1436 cursorPos = offset + firstTextIndex;
1437 int textLength = pTextObject->GetTextLengthAt(curCursorLine+1);
1438 if (offset > textLength)
1440 cursorPos = firstTextIndex+textLength;
1442 if (!pTextObject->IsDisplayedLastLine())
1444 int line = pTextObject->GetFirstDisplayLineIndex();
1445 pTextObject->SetFirstDisplayLineIndex(line+1);
1446 __pCopyPasteManager->SetCursorPosition(cursorPos);
1447 pEditPresenter->ScrollPanelToCursorPosition(true);
1451 if (__singleHandler || __pCopyPasteManager->CheckHandlePosition(__leftHandler, cursorPos))
1453 __pCopyPasteManager->SetCursorPosition(cursorPos);
1454 pEditPresenter->ScrollPanelToCursorPosition(true);
1465 if (curCursorLine !=0)
1467 if (__rowIndex == 0)
1471 int offset = __handlerCursorPos - pTextObject->GetFirstTextIndexAt(curCursorLine);
1472 int firstTextIndex = pTextObject->GetFirstTextIndexAt(curCursorLine-1);
1473 cursorPos = offset + firstTextIndex;
1474 int textLength = pTextObject->GetTextLengthAt(curCursorLine-1);
1475 if (offset > textLength)
1477 cursorPos = firstTextIndex+textLength;
1479 if (!pTextObject->IsDisplayedFirstLine())
1481 int line = pTextObject->GetFirstDisplayLineIndex();
1482 pTextObject->SetFirstDisplayLineIndex(line-1);
1483 __pCopyPasteManager->SetCursorPosition(cursorPos);
1484 pEditPresenter->ScrollPanelToCursorPosition(true);
1488 __pCopyPasteManager->SetCursorPosition(cursorPos);
1489 pEditPresenter->ScrollPanelToCursorPosition(true);
1497 if (!__singleHandler && !__pCopyPasteManager->CheckHandlePosition(__leftHandler, cursorPos))
1499 __pCopyPasteManager->SetCursorPosition(previousCursorPos);
1500 pEditPresenter->SetCursorChangedFlag(!__leftHandler);
1502 if ((__pCopyPasteManager->GetEdit()->GetEditStyle() & EDIT_STYLE_SINGLE_LINE))
1504 _EditCopyPasteManager::HandlerType nextHandlerType = _EditCopyPasteManager::HANDLER_TYPE_MAX;
1507 nextHandlerType = _EditCopyPasteManager::HANDLER_TYPE_RIGHT;
1511 nextHandlerType = _EditCopyPasteManager::HANDLER_TYPE_LEFT;
1513 int nextHandler = __pCopyPasteManager->GetHandlerCursorPosition(nextHandlerType);
1514 if (Math::Abs(nextHandler - __handlerCursorPos) <= 1)
1516 pTextObject->SetFirstDisplayLineIndexFromTextIndex(nextHandler);
1522 if (cursorPos == -1 || __handlerCursorPos == cursorPos)
1524 if (!__singleHandler)
1526 __pCopyPasteManager->SetCursorPosition(previousCursorPos);
1527 pEditPresenter->SetCursorChangedFlag(!__leftHandler);
1529 if (!__singleHandler && (__pCopyPasteManager->GetEdit()->GetEditStyle() & EDIT_STYLE_SINGLE_LINE))
1531 _EditCopyPasteManager::HandlerType nextHandlerType = _EditCopyPasteManager::HANDLER_TYPE_MAX;
1534 nextHandlerType = _EditCopyPasteManager::HANDLER_TYPE_RIGHT;
1538 nextHandlerType = _EditCopyPasteManager::HANDLER_TYPE_LEFT;
1540 int nextHandler = __pCopyPasteManager->GetHandlerCursorPosition(nextHandlerType);
1541 if (Math::Abs(nextHandler - __handlerCursorPos) <= 1)
1543 pTextObject->SetFirstDisplayLineIndexFromTextIndex(nextHandler);
1549 if (cursorPosFromTouch && (rowIndex != -1 && columnIndex != -1))
1551 __rowIndex = rowIndex;
1552 __columnIndex = columnIndex;
1560 pTextObject->SetFirstDisplayLineIndexFromTextIndex(cursorPos);
1562 __handlerCursorPos = cursorPos;
1563 __pCopyPasteManager->SetCursorPosition(__handlerCursorPos);
1564 pEditPresenter->ScrollPanelToCursorPosition(true);
1566 if (!__singleHandler)
1568 __pCopyPasteManager->RefreshBlock(__leftHandler);
1572 if (__rowIndex == -1 && __columnIndex == -1)
1574 __pCopyPasteManager->SetCursorPosition(cursorPos);
1578 pEditPresenter->SetCursorPosition(cursorPos, __rowIndex, __columnIndex);
1580 pEditPresenter->DrawText();
1583 MoveCopyPasteMagnifier();
1589 _EditCopyPasteHandler::IsActivatedOnOpen(void) const
1595 _EditCopyPasteHandler::OnChangeLayout(_ControlOrientation orientation)
1602 _EditCopyPasteHandler::OnAttachedToMainTree(void)
1604 result r = E_SUCCESS;
1606 if (GetOwner() == null)
1608 _Edit* pEdit = __pCopyPasteManager->GetEdit();
1609 SysTryReturnResult(NID_UI_CTRL, pEdit, GetLastResult(), "Unable to get pEdit.");
1611 _EditPresenter* pEditPresenter = pEdit->GetPresenter();
1612 SysTryReturnResult(NID_UI_CTRL, pEdit, GetLastResult(), "Unable to get pEditPresenter.");
1614 _Form* pParentForm = pEditPresenter->GetParentForm();
1617 SetOwner(pParentForm);
1621 _Form* pForm = null;
1622 _Frame* pCurrentFrame = dynamic_cast <_Frame*>(_ControlManager::GetInstance()->GetCurrentFrame());
1625 pForm = pCurrentFrame->GetCurrentForm();
1632 SetOwner(pCurrentFrame);
1642 _EditCopyPasteHandler::OnBoundsChanging(const FloatRectangle& bounds)
1644 result r = E_SUCCESS;
1646 __windowBounds = bounds;
1648 if (!GetVisibleState())
1653 if (!__reverseCheck)
1655 _EcoreEvas* pEcoreEvas = GetEcoreEvasMgr()->GetEcoreEvas();
1656 SysTryReturn(NID_UI, pEcoreEvas, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error occurred.");
1658 pEcoreEvas->SetWindowBounds(*GetRootWindow(), _CoordinateSystemUtils::ConvertToInteger(bounds));
1659 result r = GetLastResult();
1660 SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1667 _EditCopyPasteHandler::OnBoundsChanging(const Rectangle& bounds)
1669 result r = E_SUCCESS;
1674 _EditCopyPasteHandler::SetWindowBounds(const Rectangle& bounds)
1676 _EcoreEvas* pEcoreEvas = GetEcoreEvasMgr()->GetEcoreEvas();
1677 SysTryReturn(NID_UI, pEcoreEvas, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error occurred.");
1679 pEcoreEvas->SetWindowBounds(*GetRootWindow(), bounds);
1680 result r = GetLastResult();
1681 SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1687 _EditCopyPasteHandler::SetWindowBounds(const FloatRectangle& bounds)
1689 _EcoreEvas* pEcoreEvas = GetEcoreEvasMgr()->GetEcoreEvas();
1690 SysTryReturn(NID_UI, pEcoreEvas, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error occurred.");
1692 pEcoreEvas->SetWindowBounds(*GetRootWindow(), _CoordinateSystemUtils::ConvertToInteger(bounds));
1693 result r = GetLastResult();
1694 SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1699 _EditCopyPasteManager::_EditCopyPasteManager(_Edit& parenEdit)
1700 : __pCopyPastePopup(null)
1701 , __contextMenuAlign(CONTEXT_MENU_CORE_ALIGN_UP)
1702 , __pCoreCopyPasteEvent(null)
1703 , __pEdit(&parenEdit)
1704 , __pEditPresenter(null)
1705 , __contextMenuHeight(0.0f)
1706 , __needToReleaseBlock(true)
1707 , __isHandlerMoving(false)
1708 , __editVisibleArea(0.0f, 0.0f, 0.0f, 0.0f)
1710 __pEditPresenter = __pEdit->GetPresenter();
1711 __pHandle[HANDLER_TYPE_CENTER] = null;
1712 __pHandle[HANDLER_TYPE_LEFT] = null;
1713 __pHandle[HANDLER_TYPE_RIGHT] = null;
1718 _EditCopyPasteManager::~_EditCopyPasteManager(void)
1722 if (__pCoreCopyPasteEvent)
1724 delete __pCoreCopyPasteEvent;
1725 __pCoreCopyPasteEvent = null;
1730 _EditCopyPasteManager::Release(void)
1732 if (__pCopyPastePopup)
1734 __pCopyPastePopup->Close();
1735 delete __pCopyPastePopup;
1736 __pCopyPastePopup = null;
1739 if (__pHandle[HANDLER_TYPE_CENTER])
1741 __pHandle[HANDLER_TYPE_CENTER]->Close();
1742 delete __pHandle[HANDLER_TYPE_CENTER];
1743 __pHandle[HANDLER_TYPE_CENTER] = null;
1746 if (__pHandle[HANDLER_TYPE_LEFT])
1748 __pHandle[HANDLER_TYPE_LEFT]->Close();
1749 delete __pHandle[HANDLER_TYPE_LEFT];
1750 __pHandle[HANDLER_TYPE_LEFT] = null;
1753 if (__pHandle[HANDLER_TYPE_RIGHT])
1755 __pHandle[HANDLER_TYPE_RIGHT]->Close();
1756 delete __pHandle[HANDLER_TYPE_RIGHT];
1757 __pHandle[HANDLER_TYPE_RIGHT] = null;
1762 _EditCopyPasteManager::ReleaseCopyPastePopup(void)
1764 if (__pCopyPastePopup)
1766 __pCopyPastePopup->Close();
1767 delete __pCopyPastePopup;
1768 __pCopyPastePopup = null;
1773 _EditCopyPasteManager::IsCopyPastePopup(const _Control& control) const
1775 if (__pCopyPastePopup == &control)
1784 _EditCopyPasteManager::IsCopyPasteHandle(const _Control& control) const
1786 if (__pHandle[HANDLER_TYPE_CENTER] == &control)
1791 if (__pHandle[HANDLER_TYPE_LEFT] == &control)
1796 if (__pHandle[HANDLER_TYPE_RIGHT] == &control)
1805 _EditCopyPasteManager::AddCopyPasteEventListener(const _IEditCopyPasteEventListener& listener)
1809 if (__pCoreCopyPasteEvent == null)
1811 __pCoreCopyPasteEvent = _EditCopyPasteEvent::CreateInstanceN(*this);
1812 SysTryReturn(NID_UI_CTRL, __pCoreCopyPasteEvent, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] System error occurred.\n");
1815 return __pCoreCopyPasteEvent->AddListener(listener);
1819 _EditCopyPasteManager::SendCopyPasteEvent(CoreCopyPasteStatus status, CoreCopyPasteAction action)
1821 if (__pCoreCopyPasteEvent)
1823 IEventArg* pCopyPasteEventArg = _EditCopyPasteEvent::CreateCopyPasteEventArgN(status, action);
1824 SysTryReturn(NID_UI_CTRL, pCopyPasteEventArg, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Unable to create _LinkEventArg.");
1826 __pCoreCopyPasteEvent->Fire(*pCopyPasteEventArg);
1833 _EditCopyPasteManager::CreateCopyPastePopup(void)
1835 if (__pHandle[HANDLER_TYPE_CENTER])
1837 __pHandle[HANDLER_TYPE_CENTER]->DestroyCopyPasteMagnifier();
1839 if (__pCopyPastePopup)
1841 __pCopyPastePopup->Close();
1842 delete __pCopyPastePopup;
1843 __pCopyPastePopup = null;
1846 FloatRectangle startRect;
1847 FloatRectangle endRect;
1848 FloatRectangle editAbsRect;
1849 FloatRectangle editShowAreaAbsRect;
1850 FloatRectangle commandButtonBounds;
1851 FloatRectangle keypadBounds(0.0f, 0.0f, 0.0f, 0.0f);
1852 FloatRectangle formClientBounds(0.0f, 0.0f, 0.0f, 0.0f);
1853 FloatRectangle panelAbsoulteBounds(0.0f, 0.0f, 0.0f, 0.0f);
1854 bool commandButtonExist = false;
1855 FloatRectangle cursorRect = GetCursorBoundsF(true);
1857 float contextMenuHeight = 0.0f;
1858 float contextMenuTopMargin = 0.0f;
1859 float contextMenuBottomMargin = 0.0f;
1860 float contextMenuArrowHeight = 0.0f;
1861 float handlerHeight = 0.0f;
1862 bool isPasswordStyle = false;
1863 bool isClipped = false;
1864 if (__pEdit->GetEditStyle() & EDIT_STYLE_PASSWORD)
1866 isPasswordStyle = true;
1869 _ControlOrientation orientation = __pEdit->GetOrientation();
1871 FloatDimension screenSize;
1872 _ControlManager* pControlManager = _ControlManager::GetInstance();
1873 if (orientation == _CONTROL_ORIENTATION_PORTRAIT)
1875 screenSize = pControlManager->GetScreenSizeF();
1879 screenSize.width = pControlManager->GetScreenSizeF().height;
1880 screenSize.height = pControlManager->GetScreenSizeF().width;
1883 GET_SHAPE_CONFIG(EDIT::COPYPASTE_HANDLER_HEIGHT, orientation, handlerHeight);
1885 GET_SHAPE_CONFIG(CONTEXTMENU::GRID_ITEM_HEIGHT, orientation, contextMenuHeight);
1886 GET_SHAPE_CONFIG(CONTEXTMENU::GRID_TOP_MARGIN, orientation, contextMenuTopMargin);
1887 GET_SHAPE_CONFIG(CONTEXTMENU::GRID_BOTTOM_MARGIN, orientation, contextMenuBottomMargin);
1888 GET_SHAPE_CONFIG(CONTEXTMENU::ANCHOR_HEIGHT, orientation, contextMenuArrowHeight);
1890 isClipped = __pEdit->IsClipped();
1891 if ((__pEdit->GetTextLength() == 0 || __pEdit->GetEditStyle() & EDIT_STYLE_PASSWORD) && !isClipped)
1896 if (__pEdit->GetTextLength() == 0 && (__pEdit->GetEditStyle() & EDIT_STYLE_VIEWER))
1901 __contextMenuHeight = contextMenuHeight + contextMenuTopMargin + contextMenuBottomMargin + contextMenuArrowHeight;
1902 if (isClipped && __pEdit->IsViewModeEnabled() == false && __pEdit->GetTextLength() > 0 && orientation == _CONTROL_ORIENTATION_PORTRAIT)
1904 __contextMenuHeight = __contextMenuHeight + contextMenuHeight;
1907 editAbsRect = __pEdit->GetAbsoluteBoundsF();
1909 _Toolbar* pCommandButton = __pEditPresenter->GetKeypadCommandButton();
1912 commandButtonBounds = pCommandButton->GetAbsoluteBoundsF();
1913 commandButtonExist = true;
1915 _Form* pForm = __pEditPresenter->GetParentForm();
1918 formClientBounds = pForm->GetClientBoundsF();
1920 _ScrollPanel* pPanel = __pEditPresenter->GetParentPanel();
1923 panelAbsoulteBounds = pPanel->GetAbsoluteBoundsF();
1925 __pEdit->GetKeypadBounds(keypadBounds);
1929 editShowAreaAbsRect = editAbsRect;
1930 FloatRectangle textObjectBounds = __pEditPresenter->GetTextBoundsF();
1931 editShowAreaAbsRect.x += textObjectBounds.x;
1932 editShowAreaAbsRect.y += textObjectBounds.y;
1933 editShowAreaAbsRect.width = textObjectBounds.width;
1934 if (!(__pEdit->GetEditStyle() & EDIT_STYLE_SINGLE_LINE))
1936 editShowAreaAbsRect.height = textObjectBounds.height;
1939 if (commandButtonExist)
1941 if (editShowAreaAbsRect.y + editShowAreaAbsRect.height > commandButtonBounds.y)
1943 editShowAreaAbsRect.height -= (editShowAreaAbsRect.y + editShowAreaAbsRect.height - commandButtonBounds.y);
1948 if (editShowAreaAbsRect.y + editShowAreaAbsRect.height > keypadBounds.y)
1950 editShowAreaAbsRect.height -= (editShowAreaAbsRect.y + editShowAreaAbsRect.height - keypadBounds.y);
1953 if (editShowAreaAbsRect.y < formClientBounds.y)
1955 editShowAreaAbsRect.y = formClientBounds.y;
1956 editShowAreaAbsRect.height -= formClientBounds.y;
1958 if (editShowAreaAbsRect.y < panelAbsoulteBounds.y)
1960 editShowAreaAbsRect.y = panelAbsoulteBounds.y;
1961 editShowAreaAbsRect.height -= (panelAbsoulteBounds.y - editShowAreaAbsRect.y);
1963 __editVisibleArea = editShowAreaAbsRect;
1965 FloatPoint copyPastePoint(0.0f, 0.0f);
1966 __contextMenuAlign = CONTEXT_MENU_CORE_ALIGN_UP;
1968 if (__pEdit->IsBlocked())
1972 __pEdit->GetBlockRange(start, end);
1973 if (start == -1 || end == -1)
1975 SysLog(NID_UI_CTRL, "[EditCopyPasteManager] There is no blocked Range");
1979 __pEdit->CalculateAbsoluteCursorBounds(start, startRect);
1980 __pEdit->CalculateAbsoluteCursorBounds(end, endRect);
1981 if (startRect.x > endRect.x)
1983 copyPastePoint.x = endRect.x + (startRect.x - endRect.x)/2;
1985 else if (startRect.x < endRect.x)
1987 copyPastePoint.x = startRect.x + (endRect.x - startRect.x)/2;
1991 copyPastePoint.x = startRect.x;
1994 if (copyPastePoint.x < editShowAreaAbsRect.x)
1996 copyPastePoint.x = editShowAreaAbsRect.x;
1998 else if (copyPastePoint.x > (editShowAreaAbsRect.x + editShowAreaAbsRect.width))
2000 copyPastePoint.x = editShowAreaAbsRect.x + editShowAreaAbsRect.width;
2003 //Both of handlers are located on the top of the Editor.
2004 if ( ((startRect.y + startRect.height) < editShowAreaAbsRect.y) && ((endRect.y + endRect.height) < editShowAreaAbsRect.y))
2006 SysLog(NID_UI_CTRL, "Both of handlers are located on the top of the Editor.\n");
2009 //Both of handlers are located on the bottom of the Editor.
2010 else if( ((startRect.y + startRect.height) > editShowAreaAbsRect.y + editShowAreaAbsRect.height ) && ((endRect.y + endRect.height) > editShowAreaAbsRect.y + editShowAreaAbsRect.height))
2012 SysLog(NID_UI_CTRL, "Both of handlers are located on the bottom of the Editor.\n");
2015 // Left handler is located on the top of the Editor and Right handler is located on the bottom of the Editor.
2016 else if ( ((startRect.y + startRect.height) < editShowAreaAbsRect.y) && ((endRect.y + endRect.height) > (editShowAreaAbsRect.y + editShowAreaAbsRect.height)))
2018 copyPastePoint.y = editShowAreaAbsRect.y + editShowAreaAbsRect.height/2;
2020 if (copyPastePoint.y < __contextMenuHeight)
2022 __contextMenuAlign = CONTEXT_MENU_CORE_ALIGN_DOWN;
2026 // Left handler is located on the top of the Editor and Right handler is located on the Editor
2027 else if ( ((startRect.y + startRect.height) < editShowAreaAbsRect.y) && ((endRect.y + endRect.height) <= (editShowAreaAbsRect.y + editShowAreaAbsRect.height)) )
2029 if ( (endRect.y + endRect.height + handlerHeight + __contextMenuHeight) < keypadBounds.y)
2031 __contextMenuAlign = CONTEXT_MENU_CORE_ALIGN_DOWN;
2032 copyPastePoint.y = endRect.y + endRect.height + handlerHeight;
2034 else if (endRect.y - editShowAreaAbsRect.y > __contextMenuHeight)
2036 copyPastePoint.y = editShowAreaAbsRect.y + __contextMenuHeight;
2038 else if (endRect.y > __contextMenuHeight)
2040 copyPastePoint.y = endRect.y;
2044 SysLog(NID_UI_CTRL, "There is no space to draw the copy&paste popup\n");
2048 // Left handler is located on the Editor and Right handler is located on the bottom of the Editor
2049 else if ( ((startRect.y + startRect.height) >= editShowAreaAbsRect.y) && ((endRect.y + endRect.height) > (editShowAreaAbsRect.y + editShowAreaAbsRect.height)) )
2051 if (__contextMenuHeight < startRect.y)
2053 copyPastePoint.y = startRect.y;
2057 copyPastePoint.y = startRect.y + (editShowAreaAbsRect.y + editShowAreaAbsRect.height - startRect.y)/2;
2060 // There is a space on the top of the Editor.
2061 else if (__contextMenuHeight < startRect.y)
2063 copyPastePoint.y = startRect.y;
2065 // There is a space on the bottom of the Editor.
2066 else if ( screenSize.height > (endRect.y + endRect.height + handlerHeight + __contextMenuHeight))
2068 __contextMenuAlign = CONTEXT_MENU_CORE_ALIGN_DOWN;
2070 copyPastePoint.y = endRect.y + endRect.height + handlerHeight;
2072 // There is no space on the top and bottom of the Editor. The Popup should be drawn on the center of the Editor.
2075 if (endRect.y - startRect.y < __contextMenuHeight)
2077 SysLog(NID_UI_CTRL, "There is no space to draw the copy&paste popup\n");
2080 copyPastePoint.y = startRect.y + __contextMenuHeight;
2086 if (editShowAreaAbsRect.height <= 0)
2090 FloatRectangle cursorRect;
2091 int cursorPosition = GetCursorPosition();
2092 __pEdit->CalculateAbsoluteCursorBounds(cursorPosition, cursorRect);
2093 copyPastePoint.x = cursorRect.x;
2094 copyPastePoint.y = cursorRect.y;
2096 if (__editVisibleArea.y > copyPastePoint.y || __editVisibleArea.y + __editVisibleArea.height < copyPastePoint.y)
2101 if (copyPastePoint.y < __contextMenuHeight)
2103 FloatRectangle cursorRect = GetCursorBoundsF(true);
2105 copyPastePoint.y += cursorRect.height;
2106 __contextMenuAlign = CONTEXT_MENU_CORE_ALIGN_DOWN;
2107 if (__pHandle[HANDLER_TYPE_CENTER])
2109 copyPastePoint.y += __pHandle[HANDLER_TYPE_CENTER]->GetBounds().height;
2114 //Todo: Create API ex)CreateContrexMenuFN
2115 __pCopyPastePopup = _ContextMenu::CreateContextMenuN(copyPastePoint, CONTEXT_MENU_CORE_STYLE_GRID, __contextMenuAlign);
2116 SysTryReturnVoidResult(NID_UI_CTRL, __pCopyPastePopup, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2118 if ( __pEdit->GetTextLength() != 0 && !isPasswordStyle)
2120 if (__pEdit->IsBlocked())
2125 GET_STRING_CONFIG(IDS_TPLATFORM_OPT_COPY, copyText);
2126 GET_STRING_CONFIG(IDS_TPLATFORM_OPT_CUT, cutText);
2128 __pCopyPastePopup->AddItem(copyText, COPY_PASTE_COPY_ID, null, null, null);
2129 if (!__pEdit->IsViewModeEnabled())
2131 __pCopyPastePopup->AddItem(cutText, COPY_PASTE_CUT_ID, null, null, null);
2137 String selectAllText;
2139 GET_STRING_CONFIG(IDS_TPLATFORM_OPT_SELECT, selectText);
2140 GET_STRING_CONFIG(IDS_TPLATFORM_OPT_SELECT_ALL, selectAllText);
2142 __pCopyPastePopup->AddItem(selectText, COPY_PASTE_SELECT_ID, null, null, null);
2143 __pCopyPastePopup->AddItem(selectAllText, COPY_PASTE_SELECT_ALL_ID, null, null, null);
2149 if (!__pEdit->IsViewModeEnabled())
2152 String clipboardText;
2154 GET_STRING_CONFIG(IDS_TPLATFORM_OPT_PASTE, pasteText);
2155 GET_STRING_CONFIG(IDS_TPLATFORM_OPT_CLIPBOARD, clipboardText);
2157 __pCopyPastePopup->AddItem(pasteText, COPY_PASTE_PASTE_ID, null, null, null);
2158 if (!isPasswordStyle && __pEdit->IsKeypadEnabled())
2160 __pCopyPastePopup->AddItem(clipboardText, COPY_PASTE_CLIPBOARD_ID, null, null, null);
2165 __pCopyPastePopup->AddActionEventListener(*this);
2168 Bitmap* pSearchBitmap = null;
2169 Bitmap* pReplacedSearchBitmap = null;
2170 Bitmap* pReplacedSearchPressedBitmap = null;
2172 Color searchPressedColor;
2173 result r = E_SUCCESS;
2175 if (__pEdit->IsBlocked() && !isPasswordStyle)
2177 r = GET_BITMAP_CONFIG_N(EDIT::COPY_PASTE_SEARCH_ICON, BITMAP_PIXEL_FORMAT_ARGB8888, pSearchBitmap);
2178 SysTryReturnVoidResult(NID_UI_CTRL, (r == E_SUCCESS), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2180 GET_COLOR_CONFIG(CONTEXTMENU::ITEM_TEXT_NORMAL, searchColor);
2181 GET_COLOR_CONFIG(CONTEXTMENU::ITEM_TEXT_PRESSED, searchPressedColor);
2183 pReplacedSearchBitmap = _BitmapImpl::GetColorReplacedBitmapN(*pSearchBitmap, Color::GetColor(COLOR_ID_MAGENTA), searchColor);
2184 SysTryCatch(NID_UI_CTRL, pReplacedSearchBitmap, r = GetLastResult(), GetLastResult(),"[%s] Propagating.", GetErrorMessage(GetLastResult()));
2186 pReplacedSearchPressedBitmap = _BitmapImpl::GetColorReplacedBitmapN(*pSearchBitmap, Color::GetColor(COLOR_ID_MAGENTA), searchPressedColor);
2187 SysTryCatch(NID_UI_CTRL, pReplacedSearchPressedBitmap, r = GetLastResult(), GetLastResult(),"[%s] Propagating.", GetErrorMessage(GetLastResult()));
2189 __pCopyPastePopup->AddItem(null, COPY_PASTE_SEARCH_ID, pReplacedSearchBitmap, pReplacedSearchPressedBitmap, null);
2194 delete pSearchBitmap;
2195 pSearchBitmap = null;
2197 if (pReplacedSearchBitmap)
2199 delete pReplacedSearchBitmap;
2200 pReplacedSearchBitmap = null;
2203 if (pReplacedSearchPressedBitmap)
2205 delete pReplacedSearchPressedBitmap;
2206 pReplacedSearchPressedBitmap = null;
2208 __pCopyPastePopup->AddActionEventListener(*this);
2213 delete pSearchBitmap;
2214 pSearchBitmap = null;
2216 delete pReplacedSearchBitmap;
2217 pReplacedSearchBitmap = null;
2224 _EditCopyPasteManager::CreateHandle(void)
2228 if (__pEdit->IsBlocked())
2232 FloatRectangle startRect;
2233 FloatRectangle endRect;
2235 __pEdit->GetBlockRange(start, end);
2237 __pEdit->CalculateAbsoluteCursorBounds(start, startRect);
2238 __pEdit->CalculateAbsoluteCursorBounds(end, endRect);
2240 Point leftHandler(startRect.x, startRect.y + startRect.height);
2241 Point rightHandler(endRect.x, endRect.y + endRect.height);
2243 __pHandle[HANDLER_TYPE_LEFT] = _EditCopyPasteHandler::CreateInstanceN(leftHandler, start, this, false, true);
2244 __pHandle[HANDLER_TYPE_RIGHT] = _EditCopyPasteHandler::CreateInstanceN(rightHandler, end, this, false, false);
2248 FloatRectangle centerRect;
2249 __pEdit->CalculateAbsoluteCursorBounds(__pEdit->GetCursorPosition(), centerRect);
2250 Point centerHandler(centerRect.x, centerRect.y + centerRect.height);
2252 __pHandle[HANDLER_TYPE_CENTER] = _EditCopyPasteHandler::CreateInstanceN(centerHandler, __pEdit->GetCursorPosition(), this, true, true);
2253 #if EDIT_COPY_PASTE_MAGNIFIER
2254 // __pHandle[HANDLER_TYPE_CENTER]->CreateCopyPasteMagnifier();
2260 _EditCopyPasteManager::Show(void)
2262 if (__pHandle[HANDLER_TYPE_CENTER])
2264 if (__pEdit->GetCursorPosition() != __pHandle[HANDLER_TYPE_CENTER]->GetHandlerCursorPosition())
2266 __pHandle[HANDLER_TYPE_CENTER]->SetHandlerCursorPosition(__pEdit->GetCursorPosition());
2267 // __pHandle[HANDLER_TYPE_CENTER]->MoveCopyPasteMagnifier();
2269 __pHandle[HANDLER_TYPE_CENTER]->AdjustBounds();
2270 __pHandle[HANDLER_TYPE_CENTER]->CheckReverseStatus();
2271 __pEdit->Invalidate();
2274 if (__pHandle[HANDLER_TYPE_LEFT] && __pHandle[HANDLER_TYPE_RIGHT])
2277 __pHandle[HANDLER_TYPE_LEFT]->CheckReverseStatus();
2278 __pHandle[HANDLER_TYPE_RIGHT]->CheckReverseStatus();
2279 __pHandle[HANDLER_TYPE_LEFT]->Invalidate();
2280 __pHandle[HANDLER_TYPE_RIGHT]->Invalidate();
2281 __pEdit->Invalidate();
2284 if (__pCopyPastePopup)
2286 __pCopyPastePopup->Open();
2287 __pCopyPastePopup->ReleaseTouchCapture();
2289 _Control* pControl = __pCopyPastePopup->GetOwner();
2292 pControl->UnlockInputEvent();
2298 _EditCopyPasteManager::CheckHandleBounds(const FloatPoint& point)
2300 bool hasCommandButton = false;
2301 bool hasParentForm = false;
2302 bool hasParentPanel = false;
2303 bool showCheck = true;
2304 FloatRectangle commandButtonBounds(0.0f, 0.0f, 0.0f, 0.0f);
2305 FloatRectangle formClientBounds(0.0f, 0.0f, 0.0f, 0.0f);
2306 FloatRectangle panelAbsoulteBounds(0.0f, 0.0f, 0.0f, 0.0f);
2307 FloatRectangle editAbsBounds = __pEdit->GetAbsoluteBoundsF();
2308 FloatRectangle textObjectBounds = __pEditPresenter->GetTextBoundsF();
2309 editAbsBounds.x += textObjectBounds.x;
2310 editAbsBounds.y += textObjectBounds.y;
2311 editAbsBounds.width = textObjectBounds.width;
2313 if (!(__pEdit->GetEditStyle() & EDIT_STYLE_SINGLE_LINE))
2315 editAbsBounds.height = textObjectBounds.height;
2318 _Toolbar* pCommandButton = __pEditPresenter->GetKeypadCommandButton();
2321 commandButtonBounds = pCommandButton->GetAbsoluteBoundsF();
2322 hasCommandButton = true;
2324 _Form* pForm = __pEditPresenter->GetParentForm();
2327 formClientBounds = pForm->GetClientBoundsF();
2328 hasParentForm = true;
2331 _ScrollPanel* pPanel = __pEditPresenter->GetParentPanel();
2334 panelAbsoulteBounds = pPanel->GetAbsoluteBoundsF();
2335 hasParentPanel = true;
2338 if ((!_FloatCompare(editAbsBounds.x, point.x) && (editAbsBounds.x > point.x)) || (!_FloatCompare(point.x, editAbsBounds.x + editAbsBounds.width) && point.x > (editAbsBounds.x + editAbsBounds.width)))
2343 if ((!_FloatCompare(editAbsBounds.y, point.y) && (editAbsBounds.y > point.y)) || (!_FloatCompare(point.y, editAbsBounds.y + editAbsBounds.height) && point.y > (editAbsBounds.y + editAbsBounds.height)))
2347 if (hasParentForm && ((!_FloatCompare(formClientBounds.y, point.y) && formClientBounds.y > point.y) || (!_FloatCompare(point.y, formClientBounds.y + formClientBounds.height) && point.y > (formClientBounds.y + formClientBounds.height))))
2351 if (hasParentPanel && ((!_FloatCompare(panelAbsoulteBounds.y, point.y) && panelAbsoulteBounds.y > point.y) || (!_FloatCompare(point.y, panelAbsoulteBounds.y + panelAbsoulteBounds.height) && point.y > (panelAbsoulteBounds.y + panelAbsoulteBounds.height))))
2355 if (hasCommandButton && commandButtonBounds.Contains(point))
2363 _EditCopyPasteManager::CheckHandlePosition(bool leftHandle, int cursorPosition)
2365 int leftHandlerPosition = __pHandle[HANDLER_TYPE_LEFT]->GetHandlerCursorPosition();
2366 int rightHandlerPosition = __pHandle[HANDLER_TYPE_RIGHT]->GetHandlerCursorPosition();
2370 if (cursorPosition + 1 <= rightHandlerPosition)
2381 if (cursorPosition >= leftHandlerPosition + 1)
2393 _EditCopyPasteManager::RefreshBlock(bool isLeftHandle)
2395 int leftRowIndex = -1;
2396 int leftColumnIndex = -1;
2397 int rightRowIndex = -1;
2398 int rightColumnIndex = -1;
2400 int leftHandlerPos = __pHandle[HANDLER_TYPE_LEFT]->GetHandlerCursorPosition();
2401 int rightHandlerPos = __pHandle[HANDLER_TYPE_RIGHT]->GetHandlerCursorPosition();
2402 __pHandle[HANDLER_TYPE_RIGHT]->GetHandlerRowColumnIndex(leftRowIndex, leftColumnIndex);
2403 __pHandle[HANDLER_TYPE_RIGHT]->GetHandlerRowColumnIndex(rightRowIndex, rightColumnIndex);
2405 __pEditPresenter->SetBlockRange(leftHandlerPos, rightHandlerPos, leftColumnIndex, leftColumnIndex, rightRowIndex, rightColumnIndex);
2407 __pEditPresenter->SetCursorChangedFlag(!isLeftHandle);
2408 __pEditPresenter->DrawText();
2413 _EditCopyPasteManager::GetCursorBoundsF(bool isAbsRect) const
2415 FloatRectangle cursorBounds;
2417 __pEdit->GetCursorBounds(isAbsRect, cursorBounds);
2419 return cursorBounds;
2423 _EditCopyPasteManager::GetCursorPositionAt(const FloatPoint& touchPoint) const
2425 return __pEdit->GetCursorPositionAt(touchPoint);
2429 _EditCopyPasteManager::SetCursorPosition(int position)
2431 return __pEdit->SetCursorPosition(position);
2435 _EditCopyPasteManager::GetCursorPosition(void) const
2437 return __pEdit->GetCursorPosition();
2441 _EditCopyPasteManager::GetHandlerCursorPosition(HandlerType handlerType) const
2443 return __pHandle[handlerType]->GetHandlerCursorPosition();
2447 _EditCopyPasteManager::SendTextBlockEvent(void)
2451 result r = E_SUCCESS;
2453 __pEdit->GetBlockRange(start, end);
2454 if (start != -1 && end != -1)
2456 r = __pEdit->SendTextBlockEvent(start, end);
2457 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
2462 _EditCopyPasteManager::OnActionPerformed(const _Control& source, int actionId)
2464 _Clipboard* pClipBoard = _Clipboard::GetInstance();
2465 SysTryReturnVoidResult(NID_UI_CTRL, pClipBoard, E_SYSTEM, "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2467 ReleaseCopyPastePopup();
2471 case COPY_PASTE_SELECT_ID:
2473 int cursorPos = GetCursorPosition();
2476 __pEdit->GetWordPosition(cursorPos, start, end);
2477 __pEdit->SetBlockRange(start, end);
2478 SendTextBlockEvent();
2482 CreateCopyPastePopup();
2489 case COPY_PASTE_SELECT_ALL_ID:
2491 int textLength = __pEdit->GetTextLength();
2492 __pEdit->SetBlockRange(0, textLength);
2493 SendTextBlockEvent();
2494 __pEditPresenter->UpdateComponentInformation();
2498 CreateCopyPastePopup();
2505 case COPY_PASTE_COPY_ID:
2506 ReleaseCopyPastePopup();
2507 SendCopyPasteEvent(CORE_COPY_PASTE_STATUS_HIDE, CORE_COPY_PASTE_ACTION_COPY);
2510 case COPY_PASTE_CUT_ID:
2511 SendCopyPasteEvent(CORE_COPY_PASTE_STATUS_HIDE, CORE_COPY_PASTE_ACTION_CUT);
2514 case COPY_PASTE_PASTE_ID:
2515 SendCopyPasteEvent(CORE_COPY_PASTE_STATUS_HIDE, CORE_COPY_PASTE_ACTION_PASTE);
2518 case COPY_PASTE_CLIPBOARD_ID:
2519 __needToReleaseBlock = false;
2520 pClipBoard->ShowPopup(CLIPBOARD_DATA_TYPE_TEXT, *__pEdit);
2521 ReleaseCopyPastePopup();
2522 SendCopyPasteEvent(CORE_COPY_PASTE_STATUS_HIDE, CORE_COPY_PASTE_ACTION_CLIPBOARD);
2524 case COPY_PASTE_SEARCH_ID:
2526 SendCopyPasteEvent(CORE_COPY_PASTE_STATUS_HIDE, CORE_COPY_PASTE_ACTION_SEARCH);
2536 _EditCopyPasteManager::AdjustBounds(void)
2538 if (__pHandle[HANDLER_TYPE_CENTER])
2540 __pHandle[HANDLER_TYPE_CENTER]->AdjustBounds();
2542 if (__pHandle[HANDLER_TYPE_LEFT])
2544 __pHandle[HANDLER_TYPE_LEFT]->AdjustBounds();
2546 if (__pHandle[HANDLER_TYPE_RIGHT])
2548 __pHandle[HANDLER_TYPE_RIGHT]->AdjustBounds();
2553 _EditCopyPasteManager::LaunchSearch(void)
2555 result r = E_SUCCESS;
2558 __pEdit->GetBlockRange(start, end);
2559 String blockText = __pEditPresenter->GetText(start, end-1);
2561 _AppMessageImpl msg;
2563 msg.AddData(APPSVC_DATA_KEYWORD, blockText);
2564 r = _AppControlManager::GetInstance()->LaunchPkg(msg, null, APPSVC_OPERATION_SEARCH, null, null, 0, 0);
2568 _EditCopyPasteManager::GetTextBlockReleaseFlag(void) const
2570 return __needToReleaseBlock;
2574 _EditCopyPasteManager::SetTextBlockReleaseFlag(bool enabled)
2576 __needToReleaseBlock = enabled;
2580 _EditCopyPasteManager::IsCopyPasteHandleExist(void) const
2582 if (__pHandle[HANDLER_TYPE_CENTER] || (__pHandle[HANDLER_TYPE_LEFT] && __pHandle[HANDLER_TYPE_RIGHT]))
2593 _EditCopyPasteManager::IsCopyPasteSingleHandleExist(void) const
2595 if (__pHandle[HANDLER_TYPE_CENTER])
2606 _EditCopyPasteManager::UpdateCopyPasteMagnifier(void)
2608 for (int i = 0; i < HANDLER_TYPE_MAX; i++)
2612 __pHandle[i]->UpdateCopyPasteMagnifier();
2618 _EditCopyPasteManager::GetEdit(void) const
2624 _EditCopyPasteManager::MoveHandler(HandlerMoveType moveType)
2626 if (!__pHandle[HANDLER_TYPE_RIGHT] || ! __pHandle[HANDLER_TYPE_LEFT])
2631 int leftHandlerPosition = __pHandle[HANDLER_TYPE_LEFT]->GetHandlerCursorPosition();
2632 int rightHandlerPosition = __pHandle[HANDLER_TYPE_RIGHT]->GetHandlerCursorPosition();
2633 int textLength = __pEdit->GetTextLength();
2634 FloatRectangle cursorBounds;
2635 int newCursorPosition;
2636 __pEdit->GetCursorBounds(false, cursorBounds);
2637 FloatPoint cursorPoint(cursorBounds.x, cursorBounds.y);
2639 TextObject* pTextObject = __pEditPresenter->GetTextObject();
2643 case HANDLER_MOVE_TYPE_LEFT:
2644 if (leftHandlerPosition < rightHandlerPosition-1)
2646 __pHandle[HANDLER_TYPE_RIGHT]->SetHandlerCursorPosition(--rightHandlerPosition);
2648 __pHandle[HANDLER_TYPE_RIGHT]->CheckReverseStatus();
2649 __pHandle[HANDLER_TYPE_RIGHT]->Invalidate();
2656 case HANDLER_MOVE_TYPE_UP:
2657 cursorPoint.y -= cursorBounds.height/2.0f;
2658 newCursorPosition = GetCursorPositionAt(cursorPoint);
2660 if (newCursorPosition <= 0)
2662 int curCursorLine = pTextObject->GetLineIndexAtTextIndex(pTextObject->GetCursorIndex());
2664 if (curCursorLine !=0 )
2666 int offset = rightHandlerPosition - pTextObject->GetFirstTextIndexAt(curCursorLine);
2667 int firstTextIndex = pTextObject->GetFirstTextIndexAt(curCursorLine-1);
2668 newCursorPosition = offset + firstTextIndex;
2669 int textLength = pTextObject->GetTextLengthAt(curCursorLine-1);
2670 if (offset > textLength)
2672 newCursorPosition = firstTextIndex+textLength;
2675 if (leftHandlerPosition >= newCursorPosition)
2677 newCursorPosition = leftHandlerPosition + 1;
2682 if (newCursorPosition >= 0 && leftHandlerPosition < newCursorPosition)
2684 __pHandle[HANDLER_TYPE_RIGHT]->SetHandlerCursorPosition(newCursorPosition);
2686 __pHandle[HANDLER_TYPE_RIGHT]->CheckReverseStatus();
2687 __pHandle[HANDLER_TYPE_RIGHT]->Invalidate();
2694 case HANDLER_MOVE_TYPE_DOWN:
2695 cursorPoint.y += cursorBounds.height + cursorBounds.height/2.0f;
2696 newCursorPosition = GetCursorPositionAt(cursorPoint);
2698 if (newCursorPosition < 0)
2700 int curCursorLine = pTextObject->GetLineIndexAtTextIndex(pTextObject->GetCursorIndex());
2701 int totalLine = pTextObject->GetTotalLineCount();
2702 if (curCursorLine < totalLine - 1)
2704 int offset = rightHandlerPosition - pTextObject->GetFirstTextIndexAt(curCursorLine);
2705 int firstTextIndex = pTextObject->GetFirstTextIndexAt(curCursorLine+1);
2706 newCursorPosition = offset + firstTextIndex;
2707 int textLength = pTextObject->GetTextLengthAt(curCursorLine+1);
2708 if (offset > textLength)
2710 newCursorPosition = firstTextIndex+textLength;
2714 else if (curCursorLine == totalLine - 1)
2716 int firstTextIndex = pTextObject->GetFirstTextIndexAt(curCursorLine);
2717 int textLength = pTextObject->GetTextLengthAt(curCursorLine);
2718 newCursorPosition = firstTextIndex + textLength;
2722 if (newCursorPosition >= 0)
2724 __pHandle[HANDLER_TYPE_RIGHT]->SetHandlerCursorPosition(newCursorPosition);
2726 __pHandle[HANDLER_TYPE_RIGHT]->CheckReverseStatus();
2727 __pHandle[HANDLER_TYPE_RIGHT]->Invalidate();
2734 case HANDLER_MOVE_TYPE_RIGHT:
2735 if (textLength >= rightHandlerPosition+1)
2737 __pHandle[HANDLER_TYPE_RIGHT]->SetHandlerCursorPosition(++rightHandlerPosition);
2739 __pHandle[HANDLER_TYPE_RIGHT]->CheckReverseStatus();
2740 __pHandle[HANDLER_TYPE_RIGHT]->Invalidate();
2751 ReleaseCopyPastePopup();
2752 __isHandlerMoving = true;
2757 _EditCopyPasteManager::IsHandlerMovingEnabled(void) const
2759 return __isHandlerMoving;
2763 _EditCopyPasteManager::SetHandlerMovingEnabled(bool enabled)
2765 __isHandlerMoving = enabled;
2769 _EditCopyPasteManager::GetEditVisibleArea(void) const
2771 return _CoordinateSystemUtils::ConvertToInteger(GetEditVisibleAreaF());
2775 _EditCopyPasteManager::GetEditVisibleAreaF(void) const
2777 return __editVisibleArea;
2781 _EditCopyPasteManager::GetCopyPastePopup(void) const
2783 return __pCopyPastePopup;
2787 _EditCopyPasteManager::GetHandlerRowColumnIndex(bool singleHandler, bool leftHandler, int& rowIndex, int& columnIndex) const
2789 HandlerType handlerType = HANDLER_TYPE_MAX;
2792 handlerType = HANDLER_TYPE_CENTER;
2794 else if (leftHandler)
2796 handlerType = HANDLER_TYPE_LEFT;
2800 handlerType = HANDLER_TYPE_RIGHT;
2803 if (__pHandle[handlerType])
2805 __pHandle[handlerType]->GetHandlerRowColumnIndex(rowIndex, columnIndex);
2816 }}} // Tizen::Ui::Controls