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 adjustPoxX = 0.0f;
278 float adjustPoxY = 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();
296 captureBounds.x = cursorBounds.x - captureWidth/2.0f;
297 captureBounds.y = cursorBounds.y + cursorBounds.height/2.0f - captureHeight/2.0f;
298 captureBounds.width = captureWidth;
299 captureBounds.height = captureHeight;
300 captureBounds = textObjectBounds.GetIntersection(captureBounds);
302 if (captureBounds.width < captureWidth && captureBounds.x < textObjectBounds.x + textObjectBounds.width - captureBounds.width)
304 adjustPoxX = captureWidth - captureBounds.width;
306 if (captureBounds.height < captureHeight && captureBounds.y < captureHeight)
308 adjustPoxY = captureHeight - captureBounds.height;
311 Bitmap* pOriginalBitmp = pEdit->GetCapturedBitmapN(true);
312 SysTryReturnVoidResult(NID_UI_CTRL, pOriginalBitmp, E_INVALID_STATE, "pOriginalBitmp is null.");
315 r = bitmap.Construct(FloatRectangle(0, 0, captureBounds.width, captureBounds.height));
316 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
318 r = bitmap.Merge(FloatPoint(0.0f, 0.0f), *pOriginalBitmp, CoordinateSystem::AlignToDevice(FloatRectangle(captureBounds.x, captureBounds.y, captureBounds.width, captureBounds.height)));
319 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
321 r = bitmap.SetScalingQuality(BITMAP_SCALING_QUALITY_HIGH);
322 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
324 r = bitmap.Scale(CoordinateSystem::AlignToDevice(FloatDimension(bitmap.GetActualWidth()*1.5f, bitmap.GetActualHeight()*1.5f)));
325 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
327 canvas.DrawBitmap(CoordinateSystem::AlignToDevice(FloatPoint(capturePosX + adjustPoxX*1.5f, capturePosY + adjustPoxY*1.5f)), bitmap);
329 delete pOriginalBitmp;
334 delete pOriginalBitmp;
340 _EditCopyPasteMagnifier::MoveMagnifier(const FloatPoint& point, int handlerCursorPos)
342 FloatRectangle bounds = FloatRectangle(point.x - GetBoundsF().width/2.0f, point.y - GetBoundsF().height, GetBoundsF().width, GetBoundsF().height);
343 __handlerCursorPos = handlerCursorPos;
353 _EditCopyPasteMagnifier::OnBoundsChanging(const FloatRectangle& bounds)
355 result r = E_SUCCESS;
357 __windowBounds = bounds;
363 _EditCopyPasteMagnifier::OnBoundsChanging(const Rectangle& bounds)
365 result r = E_SUCCESS;
371 _EditCopyPasteMagnifier::SetRowColumnIndex(int rowIndex, int columnIndex)
373 __rowIndex = rowIndex;
374 __columnIndex = columnIndex;
378 * @class _EditCopyPasteHandler
379 * @brief This class defines the common behavior for the %_EditCopyPasteHandler.
382 class _EditCopyPasteHandler
384 , virtual public IEventListener
385 , virtual public _IUiEventListener
386 , virtual public _IUiEventPreviewer
392 * This is the default class constructor.
395 _EditCopyPasteHandler(const Point& point, int handlerCursorPos, _EditCopyPasteManager* pCopyPasteManager, bool singleHandler, bool leftHandler);
396 _EditCopyPasteHandler(const FloatPoint& point, int handlerCursorPos, _EditCopyPasteManager* pCopyPasteManager, bool singleHandler, bool leftHandler);
399 * This is the default class destructor.
402 virtual ~_EditCopyPasteHandler(void);
406 enum HandlerDirection
408 HANDLER_DIRECTION_NONE = 0,
409 HANDLER_DIRECTION_REVERSE_1,//horizontal reverse
410 HANDLER_DIRECTION_REVERSE_2,//vertical reverse
411 HANDLER_DIRECTION_REVERSE_3,//horizontal vertical reverse
414 static _EditCopyPasteHandler* CreateInstanceN(const Point& point, int handlerCursorPos, _EditCopyPasteManager* pCopyPasteManager, bool singleHandler, bool leftHandler = true);
415 static _EditCopyPasteHandler* CreateInstanceN(const FloatPoint& point, int handlerCursorPos, _EditCopyPasteManager* pCopyPasteManager, bool singleHandler, bool leftHandler = true);
416 int GetHandlerCursorPosition(void) const;
417 void GetHandlerRowColumnIndex(int& rowIndex, int& columnIndex) const;
418 void SetHandlerCursorPosition(int handlerCursorPos);
419 void AdjustBounds(void);
420 void CheckReverseStatus(void);
421 void ChangeHandlerBitmap(void);
422 Bitmap* GetHandlerBitmap(void) const;
423 bool CreateCopyPasteMagnifier(void);
424 void DestroyCopyPasteMagnifier(void);
425 void MoveCopyPasteMagnifier(void);
426 void UpdateCopyPasteMagnifier(void);
429 virtual void OnDraw(void);
430 virtual bool OnTouchPressed(const _Control& source, const _TouchInfo& touchinfo);
431 virtual bool OnTouchMoved(const _Control& source, const _TouchInfo& touchinfo);
432 virtual bool OnTouchReleased(const _Control& source, const _TouchInfo& touchinfo);
433 virtual bool IsActivatedOnOpen(void) const;
434 virtual void OnChangeLayout(_ControlOrientation orientation);
435 virtual result OnAttachedToMainTree(void);
437 result OnBoundsChanging(const Rectangle& bounds);
438 result OnBoundsChanging(const FloatRectangle& bounds);
439 result SetWindowBounds(const Rectangle& bounds);
440 result SetWindowBounds(const FloatRectangle& bounds);
443 _EditCopyPasteHandler(const _EditCopyPasteHandler& value);
444 _EditCopyPasteHandler& operator =(const _EditCopyPasteHandler& value);
448 _VisualElement* __pRoot;
449 Bitmap* __pHandlerBitmap;
450 FloatPoint __touchPressedPoint;
451 FloatPoint __absoluteTouchPressedPoint;
452 _EditCopyPasteManager* __pCopyPasteManager;
455 int __handlerCursorPos;
456 bool __isTouchPressed;
457 FloatRectangle __windowBounds;
458 HandlerDirection __handlerDirection;
459 bool __singleHandler;
460 _EditCopyPasteMagnifier* __pCopyPasteMagnifier;
461 bool __isTouchMoving;
464 }; // _EditCopyPasteHandler
467 _EditCopyPasteHandler::GetHandlerBitmap(void) const
469 return __pHandlerBitmap;
473 _EditCopyPasteHandler::CreateCopyPasteMagnifier(void)
475 if (!__pCopyPasteMagnifier)
477 _Edit* pEdit = __pCopyPasteManager->GetEdit();
478 SysTryReturn(NID_UI_CTRL, pEdit, false, E_INVALID_STATE, "[E_INVALID_STATE] pEdit is null.\n");
480 _EditPresenter* pEditPresenter = pEdit->GetPresenter();
481 SysTryReturn(NID_UI_CTRL, pEditPresenter, false, E_INVALID_STATE, "[E_INVALID_STATE] pEditPresenter is null.\n");
483 FloatRectangle cursorBounds(0.0f, 0.0f, 0.0f, 0.0f);
484 if (__rowIndex == -1 && __columnIndex == -1)
486 pEditPresenter->CalculateAbsoluteCursorBounds(__handlerCursorPos, cursorBounds);
490 pEditPresenter->CalculateAbsoluteCursorBounds(__rowIndex, __columnIndex, cursorBounds);
492 __pCopyPasteMagnifier = _EditCopyPasteMagnifier::CreateInstanceN(FloatPoint(cursorBounds.x, cursorBounds.y), __handlerCursorPos, __pCopyPasteManager);
493 SysTryReturn(NID_UI_CTRL, __pCopyPasteMagnifier, false, E_INVALID_STATE, "[E_INVALID_STATE] __pCopyPasteMagnifier is null.\n");
495 __pCopyPasteMagnifier->SetRowColumnIndex(__rowIndex, __columnIndex);
501 _EditCopyPasteHandler::DestroyCopyPasteMagnifier(void)
503 if (__pCopyPasteMagnifier)
505 __pCopyPasteMagnifier->Close();
506 delete __pCopyPasteMagnifier;
507 __pCopyPasteMagnifier = null;
512 _EditCopyPasteHandler::MoveCopyPasteMagnifier(void)
514 if (__pCopyPasteMagnifier)
516 _Edit* pEdit = __pCopyPasteManager->GetEdit();
517 SysTryReturnVoidResult(NID_UI_CTRL, pEdit, E_INVALID_STATE, "pEdit is null.");
519 _EditPresenter* pEditPresenter = pEdit->GetPresenter();
520 SysTryReturnVoidResult(NID_UI_CTRL, pEditPresenter, E_INVALID_STATE, "pEditPresenter is null.");
522 FloatRectangle cursorBounds(0.0f, 0.0f, 0.0f, 0.0f);
523 if (__rowIndex == -1 && __columnIndex == -1)
525 pEditPresenter->CalculateAbsoluteCursorBounds(__handlerCursorPos, cursorBounds);
529 pEditPresenter->CalculateAbsoluteCursorBounds(__rowIndex, __columnIndex, cursorBounds);
530 __pCopyPasteMagnifier->SetRowColumnIndex(__rowIndex, __columnIndex);
532 __pCopyPasteMagnifier->MoveMagnifier(FloatPoint(cursorBounds.x, cursorBounds.y), __handlerCursorPos);
537 _EditCopyPasteHandler::UpdateCopyPasteMagnifier(void)
539 if (__pCopyPasteMagnifier)
541 __pCopyPasteMagnifier->Invalidate();
546 _EditCopyPasteHandler::ChangeHandlerBitmap(void)
548 if (__pHandlerBitmap)
550 delete __pHandlerBitmap;
551 __pHandlerBitmap = null;
555 if (__handlerDirection == HANDLER_DIRECTION_NONE)
557 GET_BITMAP_CONFIG_N(EDIT::COPY_PASTE_ICON_CENTER_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, __pHandlerBitmap);
561 GET_BITMAP_CONFIG_N(EDIT::COPY_PASTE_ICON_REVERSE_CENTER_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, __pHandlerBitmap);
567 switch(__handlerDirection)
569 case HANDLER_DIRECTION_REVERSE_1:
570 GET_BITMAP_CONFIG_N(EDIT::COPY_PASTE_ICON_RIGHT_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, __pHandlerBitmap);
572 case HANDLER_DIRECTION_REVERSE_2:
573 GET_BITMAP_CONFIG_N(EDIT::COPY_PASTE_ICON_REVERSE_LEFT_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, __pHandlerBitmap);
575 case HANDLER_DIRECTION_REVERSE_3:
576 GET_BITMAP_CONFIG_N(EDIT::COPY_PASTE_ICON_REVERSE_RIGHT_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, __pHandlerBitmap);
578 case HANDLER_DIRECTION_NONE:
581 GET_BITMAP_CONFIG_N(EDIT::COPY_PASTE_ICON_LEFT_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, __pHandlerBitmap);
587 switch(__handlerDirection)
589 case HANDLER_DIRECTION_REVERSE_1:
590 GET_BITMAP_CONFIG_N(EDIT::COPY_PASTE_ICON_LEFT_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, __pHandlerBitmap);
592 case HANDLER_DIRECTION_REVERSE_2:
593 GET_BITMAP_CONFIG_N(EDIT::COPY_PASTE_ICON_REVERSE_RIGHT_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, __pHandlerBitmap);
595 case HANDLER_DIRECTION_REVERSE_3:
596 GET_BITMAP_CONFIG_N(EDIT::COPY_PASTE_ICON_REVERSE_LEFT_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, __pHandlerBitmap);
598 case HANDLER_DIRECTION_NONE:
601 GET_BITMAP_CONFIG_N(EDIT::COPY_PASTE_ICON_RIGHT_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, __pHandlerBitmap);
607 _EditCopyPasteHandler::_EditCopyPasteHandler(const Point& point, int handlerCursorPos, _EditCopyPasteManager* pCopyPasteManager, bool singleHandler, bool leftHandler)
609 , __pHandlerBitmap(null)
610 , __touchPressedPoint(0.0f, 0.0f)
611 , __absoluteTouchPressedPoint(0.0f, 0.0f)
612 , __pCopyPasteManager(pCopyPasteManager)
613 , __leftHandler(leftHandler)
614 , __reverseCheck(false)
615 , __handlerCursorPos(handlerCursorPos)
616 , __isTouchPressed(false)
617 , __windowBounds(0.0f, 0.0f, 0.0f, 0.0f)
618 , __handlerDirection(HANDLER_DIRECTION_NONE)
619 , __singleHandler(false)
620 , __pCopyPasteMagnifier(null)
621 , __isTouchMoving(false)
627 __pRoot = GetVisualElement();
628 __pRoot->SetSurfaceOpaque(false);
630 Point handlerPoint(point);
634 GET_BITMAP_CONFIG_N(EDIT::COPY_PASTE_ICON_CENTER_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, __pHandlerBitmap);
635 handlerPoint.x = handlerPoint.x - (__pHandlerBitmap->GetWidth() / 2);
636 __singleHandler = true;
642 GET_BITMAP_CONFIG_N(EDIT::COPY_PASTE_ICON_LEFT_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, __pHandlerBitmap);
643 handlerPoint.x = handlerPoint.x - __pHandlerBitmap->GetWidth();
647 GET_BITMAP_CONFIG_N(EDIT::COPY_PASTE_ICON_RIGHT_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, __pHandlerBitmap);
651 FloatRectangle bounds(handlerPoint.x, handlerPoint.y, __pHandlerBitmap->GetWidth(), __pHandlerBitmap->GetHeight());
654 _EditCopyPasteHandler::_EditCopyPasteHandler(const FloatPoint& point, int handlerCursorPos, _EditCopyPasteManager* pCopyPasteManager, bool singleHandler, bool leftHandler)
656 , __pHandlerBitmap(null)
657 , __touchPressedPoint(0.0f, 0.0f)
658 , __absoluteTouchPressedPoint(0.0f, 0.0f)
659 , __pCopyPasteManager(pCopyPasteManager)
660 , __leftHandler(leftHandler)
661 , __reverseCheck(false)
662 , __handlerCursorPos(handlerCursorPos)
663 , __isTouchPressed(false)
664 , __windowBounds(0.0f, 0.0f, 0.0f, 0.0f)
665 , __handlerDirection(HANDLER_DIRECTION_NONE)
666 , __singleHandler(false)
667 , __pCopyPasteMagnifier(null)
668 , __isTouchMoving(false)
674 __pRoot = GetVisualElement();
675 __pRoot->SetSurfaceOpaque(false);
678 //Point handlerPoint(_CoordinateSystemUtils::ConvertToInteger(point));
679 FloatPoint handlerPoint(point);
682 GET_BITMAP_CONFIG_N(EDIT::COPY_PASTE_ICON_CENTER_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, __pHandlerBitmap);
683 handlerPoint.x = handlerPoint.x - (__pHandlerBitmap->GetWidthF() / 2.0f);
684 __singleHandler = true;
690 GET_BITMAP_CONFIG_N(EDIT::COPY_PASTE_ICON_LEFT_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, __pHandlerBitmap);
691 handlerPoint.x = handlerPoint.x - __pHandlerBitmap->GetWidthF();
695 GET_BITMAP_CONFIG_N(EDIT::COPY_PASTE_ICON_RIGHT_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, __pHandlerBitmap);
699 FloatRectangle bounds(handlerPoint.x, handlerPoint.y, _CoordinateSystemUtils::ConvertToFloat(__pHandlerBitmap->GetWidth()), _CoordinateSystemUtils::ConvertToFloat(__pHandlerBitmap->GetHeight()));
702 _EditCopyPasteHandler::~_EditCopyPasteHandler(void)
704 DestroyCopyPasteMagnifier();
706 if (__pHandlerBitmap)
708 delete __pHandlerBitmap;
709 __pHandlerBitmap = null;
713 _EditCopyPasteHandler*
714 _EditCopyPasteHandler::CreateInstanceN(const Point& point, int handlerCursorPos, _EditCopyPasteManager* pCopyPasteManager, bool singleHandler, bool leftHandler)
716 _EditCopyPasteHandler* pCopyPasteHandler = new (std::nothrow) _EditCopyPasteHandler(point, handlerCursorPos, pCopyPasteManager, singleHandler, leftHandler);
717 SysTryReturn(NID_UI_CTRL, pCopyPasteHandler != null, null, E_OUT_OF_MEMORY, "pContextMenu is null");
719 Point handlerPoint(point);
720 Rectangle bounds(0, 0, 0, 0);
721 Bitmap* pHandlerBitmap = pCopyPasteHandler->GetHandlerBitmap();
723 result r = pCopyPasteHandler->CreateRootVisualElement();
724 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
726 pCopyPasteHandler->SetActivationEnabled(false);
730 handlerPoint.x = handlerPoint.x - (pHandlerBitmap->GetWidth() / 2);
736 handlerPoint.x = handlerPoint.x - pHandlerBitmap->GetWidth();
740 bounds.x = handlerPoint.x;
741 bounds.y = handlerPoint.y;
742 bounds.width = pHandlerBitmap->GetWidth();
743 bounds.height = pHandlerBitmap->GetHeight();
745 pCopyPasteHandler->SetBounds(bounds);
746 pCopyPasteHandler->CheckReverseStatus();
747 pCopyPasteHandler->Open(false);
749 return pCopyPasteHandler;
752 pCopyPasteHandler->Close();
753 delete pCopyPasteHandler;
758 _EditCopyPasteHandler*
759 _EditCopyPasteHandler::CreateInstanceN(const FloatPoint& point, int handlerCursorPos, _EditCopyPasteManager* pCopyPasteManager, bool singleHandler, bool leftHandler)
761 _EditCopyPasteHandler* pCopyPasteHandler = new (std::nothrow) _EditCopyPasteHandler(point, handlerCursorPos, pCopyPasteManager, singleHandler, leftHandler);
762 SysTryReturn(NID_UI_CTRL, pCopyPasteHandler != null, null, E_OUT_OF_MEMORY, "pContextMenu is null");
764 FloatPoint handlerPoint(point);
765 FloatRectangle bounds(0.0f, 0.0f, 0.0f, 0.0f);
766 Bitmap* pHandlerBitmap = pCopyPasteHandler->GetHandlerBitmap();
768 result r = pCopyPasteHandler->CreateRootVisualElement();
769 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
771 pCopyPasteHandler->SetActivationEnabled(false);
775 handlerPoint.x = handlerPoint.x - (pHandlerBitmap->GetWidthF() / 2.0f);
781 handlerPoint.x = handlerPoint.x - pHandlerBitmap->GetWidthF();
785 bounds.x = handlerPoint.x;
786 bounds.y = handlerPoint.y;
787 bounds.width = pHandlerBitmap->GetWidthF();
788 bounds.height = pHandlerBitmap->GetHeightF();
790 pCopyPasteHandler->SetBounds(bounds);
791 pCopyPasteHandler->CheckReverseStatus();
792 pCopyPasteHandler->Open(false);
794 return pCopyPasteHandler;
797 pCopyPasteHandler->Close();
798 delete pCopyPasteHandler;
804 _EditCopyPasteHandler::GetHandlerCursorPosition(void) const
806 return __handlerCursorPos;
810 _EditCopyPasteHandler::GetHandlerRowColumnIndex(int& rowIndex, int& columnIndex) const
812 rowIndex = __rowIndex;
813 columnIndex = __columnIndex;
817 _EditCopyPasteHandler::SetHandlerCursorPosition(int handlerCursorPos)
819 __handlerCursorPos = handlerCursorPos;
823 _EditCopyPasteHandler::AdjustBounds(void)
825 FloatRectangle cursorRect;
826 FloatRectangle rect = GetBoundsF();
827 FloatPoint checkPoint(0.0f, 0.0f);
828 _Edit* pEdit = __pCopyPasteManager->GetEdit();
829 _EditPresenter* pEditPresenter = pEdit->GetPresenter();
833 if (__rowIndex == -1 && __columnIndex == -1)
835 pEditPresenter->CalculateAbsoluteCursorBounds(__handlerCursorPos, cursorRect);
839 pEditPresenter->CalculateAbsoluteCursorBounds(__rowIndex, __columnIndex, cursorRect);
841 rect.x = cursorRect.x - __pHandlerBitmap->GetWidthF()/2.0f;
842 rect.y = cursorRect.y + cursorRect.height;
843 checkPoint = FloatPoint(cursorRect.x , cursorRect.y + cursorRect.height);
844 if (__handlerDirection == HANDLER_DIRECTION_REVERSE_2)
846 rect.y -= (cursorRect.height + __pHandlerBitmap->GetHeightF());
851 if (__rowIndex == -1 && __columnIndex == -1)
853 pEditPresenter->CalculateAbsoluteCursorBounds(__handlerCursorPos, cursorRect);
857 pEditPresenter->CalculateAbsoluteCursorBounds(__rowIndex, __columnIndex, cursorRect);
860 rect.x = cursorRect.x;
861 rect.y = cursorRect.y + cursorRect.height;
863 checkPoint = FloatPoint(cursorRect.x, cursorRect.y + cursorRect.height);
867 if (__handlerDirection == HANDLER_DIRECTION_NONE)
869 rect.x = rect.x - __pHandlerBitmap->GetWidthF();
871 else if (__handlerDirection == HANDLER_DIRECTION_REVERSE_2)
873 rect.x = rect.x - __pHandlerBitmap->GetWidthF();
874 rect.y -= (rect.height + cursorRect.height);
876 else if (__handlerDirection == HANDLER_DIRECTION_REVERSE_3)
878 rect.y -= (rect.height + cursorRect.height);
883 if (__handlerDirection == HANDLER_DIRECTION_REVERSE_1)
885 rect.x = rect.x - __pHandlerBitmap->GetWidthF();
887 else if (__handlerDirection == HANDLER_DIRECTION_REVERSE_2)
889 rect.y -= (rect.height + cursorRect.height);
891 else if (__handlerDirection == HANDLER_DIRECTION_REVERSE_3)
893 rect.x = rect.x - __pHandlerBitmap->GetWidthF();
894 rect.y -= (rect.height + cursorRect.height);
899 if (!__isTouchMoving)
901 bool visibleState = __pCopyPasteManager->CheckHandleBounds(checkPoint);
902 if (visibleState && !GetVisibleState())
904 SetVisibleState(true);
907 else if (!visibleState && GetVisibleState())
909 SetVisibleState(false);
919 _EditCopyPasteHandler::OnDraw(void)
921 Canvas* pCanvas = GetCanvasN();
926 pCanvas->SetBackgroundColor(Color(0, 0, 0, 0));
928 if (_BitmapImpl::CheckNinePatchedBitmapStrictly(*__pHandlerBitmap))
930 pCanvas->DrawNinePatchedBitmap(pCanvas->GetBoundsF(), *__pHandlerBitmap);
934 pCanvas->DrawBitmap(pCanvas->GetBoundsF(), *__pHandlerBitmap);
941 SetWindowBounds(__windowBounds);
942 __reverseCheck = false;
946 SetWindowBounds(__windowBounds);
951 _EditCopyPasteHandler::OnTouchPressed(const _Control& source, const _TouchInfo& touchinfo)
953 __pCopyPasteManager->ReleaseCopyPastePopup();
954 #if EDIT_COPY_PASTE_MAGNIFIER
955 CreateCopyPasteMagnifier();
957 __touchPressedPoint = touchinfo.GetCurrentPosition();
958 __absoluteTouchPressedPoint = FloatPoint(GetBoundsF().x + __touchPressedPoint.x, GetBoundsF().y + __touchPressedPoint.y);
959 __isTouchPressed = true;
965 _EditCopyPasteHandler::CheckReverseStatus(void)
967 FloatDimension screenSize;
968 _ControlManager* pControlManager = _ControlManager::GetInstance();
969 _Edit* pEdit = __pCopyPasteManager->GetEdit();
970 _ControlOrientation orientation = pEdit->GetOrientation();
971 FloatRectangle rect = GetBoundsF();
972 FloatRectangle cursorAbsBounds = __pCopyPasteManager->GetCursorBoundsF(true);
973 float clipboardHeight = 0.0f;
974 FloatRectangle keypadBounds(0.0f, 0.0f, 0.0f, 0.0f);
975 float adjustHeight = 0.0f;
977 _EditPresenter* pEditPresenter = pEdit->GetPresenter();
978 SysTryReturnVoidResult(NID_UI_CTRL, pEditPresenter, E_INVALID_STATE, "pEditPresenter is null.\n");
980 clipboardHeight = pEditPresenter->GetClipboardHeight();
981 pEditPresenter->GetKeypadBoundsEx(keypadBounds);
982 if (clipboardHeight > keypadBounds.height)
984 adjustHeight = clipboardHeight;
988 adjustHeight = keypadBounds.height;
991 if (orientation == _CONTROL_ORIENTATION_PORTRAIT)
993 screenSize = pControlManager->GetScreenSizeF();
997 screenSize.width = pControlManager->GetScreenSizeF().height;
998 screenSize.height = pControlManager->GetScreenSizeF().width;
1000 if (adjustHeight > 0.0f)
1002 screenSize.height -= adjustHeight;
1005 if (__singleHandler)
1007 if ((__handlerDirection == HANDLER_DIRECTION_NONE) && ((cursorAbsBounds.y + cursorAbsBounds.height + rect.height) > screenSize.height))
1009 __handlerDirection = HANDLER_DIRECTION_REVERSE_2;
1010 rect.y -= (cursorAbsBounds.height + rect.height);
1011 __reverseCheck = true;
1013 else if ((__handlerDirection == HANDLER_DIRECTION_REVERSE_2) && ((cursorAbsBounds.y + cursorAbsBounds.height + rect.height) <= screenSize.height))
1015 __handlerDirection = HANDLER_DIRECTION_NONE;
1016 rect.y += (cursorAbsBounds.height + rect.height);
1017 __reverseCheck = true;
1019 ChangeHandlerBitmap();
1026 if (((__handlerDirection == HANDLER_DIRECTION_NONE) || (__handlerDirection == HANDLER_DIRECTION_REVERSE_2)) && rect.x < 0.0f)
1028 if ((__handlerDirection == HANDLER_DIRECTION_NONE) && ((rect.y + rect.height) > screenSize.height))
1030 __handlerDirection = HANDLER_DIRECTION_REVERSE_3;
1031 rect.y -= (rect.height + cursorAbsBounds.height);
1033 else if ((__handlerDirection == HANDLER_DIRECTION_NONE) && ((rect.y + rect.height) <= screenSize.height))
1035 __handlerDirection = HANDLER_DIRECTION_REVERSE_1;
1037 else if ((__handlerDirection == HANDLER_DIRECTION_REVERSE_2) && ((rect.y + 2*rect.height) > screenSize.height))
1039 __handlerDirection = HANDLER_DIRECTION_REVERSE_3;
1041 else if ((__handlerDirection == HANDLER_DIRECTION_REVERSE_2) && ((rect.y + 2*rect.height) <= screenSize.height))
1043 __handlerDirection = HANDLER_DIRECTION_REVERSE_1;
1044 rect.y += (rect.height + cursorAbsBounds.height);
1046 ChangeHandlerBitmap();
1047 rect.x += rect.width;
1048 __reverseCheck = true;
1050 else if (((__handlerDirection == HANDLER_DIRECTION_REVERSE_1) || (__handlerDirection == HANDLER_DIRECTION_REVERSE_3)) && rect.x >= rect.width)
1052 if ((__handlerDirection == HANDLER_DIRECTION_REVERSE_1) && ((rect.y + rect.height) > screenSize.height))
1054 __handlerDirection = HANDLER_DIRECTION_REVERSE_2;
1055 rect.y -= (rect.height + cursorAbsBounds.height);
1057 else if ((__handlerDirection == HANDLER_DIRECTION_REVERSE_1) && ((rect.y + rect.height) <= screenSize.height))
1059 __handlerDirection = HANDLER_DIRECTION_NONE;
1061 else if ((__handlerDirection == HANDLER_DIRECTION_REVERSE_3) && ((rect.y + 2*rect.height) > screenSize.height))
1063 __handlerDirection = HANDLER_DIRECTION_REVERSE_2;
1065 else if ((__handlerDirection == HANDLER_DIRECTION_REVERSE_3) && ((rect.y + 2*rect.height) <= screenSize.height))
1067 __handlerDirection = HANDLER_DIRECTION_NONE;
1068 rect.y += (rect.height + cursorAbsBounds.height);
1070 ChangeHandlerBitmap();
1071 rect.x -= rect.width;
1072 __reverseCheck = true;
1074 else if (((__handlerDirection == HANDLER_DIRECTION_NONE) || (__handlerDirection == HANDLER_DIRECTION_REVERSE_1)) && ((rect.y + rect.height) > screenSize.height))
1076 if ((__handlerDirection == HANDLER_DIRECTION_NONE) && rect.x < rect.width)
1078 __handlerDirection = HANDLER_DIRECTION_REVERSE_3;
1079 rect.x += rect.width;
1081 else if ((__handlerDirection == HANDLER_DIRECTION_NONE) && rect.x >= rect.width)
1083 __handlerDirection = HANDLER_DIRECTION_REVERSE_2;
1085 else if ((__handlerDirection == HANDLER_DIRECTION_REVERSE_1) && ((rect.x - rect.width) >= 0.0f))
1087 __handlerDirection = HANDLER_DIRECTION_REVERSE_2;
1088 rect.x -= rect.width;
1090 else if ((__handlerDirection == HANDLER_DIRECTION_REVERSE_1) && ((rect.x - rect.width) < 0.0f))
1092 __handlerDirection = HANDLER_DIRECTION_REVERSE_3;
1094 rect.y -= (rect.height + cursorAbsBounds.height);
1095 ChangeHandlerBitmap();
1096 __reverseCheck = true;
1098 else if (((__handlerDirection == HANDLER_DIRECTION_REVERSE_2) || (__handlerDirection == HANDLER_DIRECTION_REVERSE_3)) && ((rect.y + 2*rect.height + cursorAbsBounds.height) <= screenSize.height))
1100 if ((__handlerDirection == HANDLER_DIRECTION_REVERSE_2) && rect.x < 0.0f)
1102 __handlerDirection = HANDLER_DIRECTION_REVERSE_1;
1103 rect.x += rect.width;
1105 else if ((__handlerDirection == HANDLER_DIRECTION_REVERSE_2) && rect.x >= rect.width)
1107 __handlerDirection = HANDLER_DIRECTION_NONE;
1109 else if ((__handlerDirection == HANDLER_DIRECTION_REVERSE_3) && ((rect.x - rect.width) >= 0.0f))
1111 __handlerDirection = HANDLER_DIRECTION_NONE;
1112 rect.x -= rect.width;
1114 else if ((__handlerDirection == HANDLER_DIRECTION_REVERSE_3) && ((rect.x - rect.width) < 0.0f))
1116 __handlerDirection = HANDLER_DIRECTION_REVERSE_1;
1118 rect.y += (rect.height + cursorAbsBounds.height);
1119 ChangeHandlerBitmap();
1120 __reverseCheck = true;
1125 if (((__handlerDirection == HANDLER_DIRECTION_NONE) || (__handlerDirection == HANDLER_DIRECTION_REVERSE_2)) && (rect.x + rect.width) > screenSize.width)
1127 if ((__handlerDirection == HANDLER_DIRECTION_NONE) && ((rect.y + rect.height) > screenSize.height))
1129 __handlerDirection = HANDLER_DIRECTION_REVERSE_3;
1130 rect.y -= (rect.height + cursorAbsBounds.height);
1132 else if ((__handlerDirection == HANDLER_DIRECTION_NONE) && ((rect.y + rect.height) <= screenSize.height))
1134 __handlerDirection = HANDLER_DIRECTION_REVERSE_1;
1136 else if ((__handlerDirection == HANDLER_DIRECTION_REVERSE_2) && ((rect.y + 2*rect.height) > screenSize.height))
1138 __handlerDirection = HANDLER_DIRECTION_REVERSE_3;
1140 else if ((__handlerDirection == HANDLER_DIRECTION_REVERSE_2) && ((rect.y + 2*rect.height) <= screenSize.height))
1142 __handlerDirection = HANDLER_DIRECTION_REVERSE_1;
1143 rect.y += (rect.height + cursorAbsBounds.height);
1145 ChangeHandlerBitmap();
1146 rect.x -= rect.width;
1147 __reverseCheck = true;
1149 else if (((__handlerDirection == HANDLER_DIRECTION_REVERSE_1) || (__handlerDirection == HANDLER_DIRECTION_REVERSE_3)) && (rect.x + 2*rect.width) <= screenSize.width)
1151 if ((__handlerDirection == HANDLER_DIRECTION_REVERSE_1) && ((rect.y + rect.height) > screenSize.height))
1153 __handlerDirection = HANDLER_DIRECTION_REVERSE_2;
1154 rect.y -= (rect.height + cursorAbsBounds.height);
1156 else if ((__handlerDirection == HANDLER_DIRECTION_REVERSE_1) && ((rect.y + rect.height) <= screenSize.height))
1158 __handlerDirection = HANDLER_DIRECTION_NONE;
1160 else if ((__handlerDirection == HANDLER_DIRECTION_REVERSE_3) && ((rect.y + 2*rect.height) > screenSize.height))
1162 __handlerDirection = HANDLER_DIRECTION_REVERSE_2;
1164 else if ((__handlerDirection == HANDLER_DIRECTION_REVERSE_3) && ((rect.y + 2*rect.height) <= screenSize.height))
1166 __handlerDirection = HANDLER_DIRECTION_NONE;
1167 rect.y += (rect.height + cursorAbsBounds.height);
1169 ChangeHandlerBitmap();
1170 rect.x += rect.width;
1171 __reverseCheck = true;
1173 else if (((__handlerDirection == HANDLER_DIRECTION_NONE) || (__handlerDirection == HANDLER_DIRECTION_REVERSE_1)) && ((rect.y + rect.height) > screenSize.height))
1175 if ((__handlerDirection == HANDLER_DIRECTION_NONE) && (rect.x + rect.width) > screenSize.width)
1177 __handlerDirection = HANDLER_DIRECTION_REVERSE_3;
1178 rect.x -= rect.width;
1180 else if ((__handlerDirection == HANDLER_DIRECTION_NONE) && (rect.x + rect.width) <= screenSize.width)
1182 __handlerDirection = HANDLER_DIRECTION_REVERSE_2;
1184 else if ((__handlerDirection == HANDLER_DIRECTION_REVERSE_1) && (rect.x + 2*rect.width) <= screenSize.width)
1186 __handlerDirection = HANDLER_DIRECTION_REVERSE_2;
1187 rect.x += rect.width;
1189 else if ((__handlerDirection == HANDLER_DIRECTION_REVERSE_1) && (rect.x + 2*rect.width) > screenSize.width)
1191 __handlerDirection = HANDLER_DIRECTION_REVERSE_3;
1193 rect.y -= (rect.height + cursorAbsBounds.height);
1194 ChangeHandlerBitmap();
1195 __reverseCheck = true;
1197 else if (((__handlerDirection == HANDLER_DIRECTION_REVERSE_2) || (__handlerDirection == HANDLER_DIRECTION_REVERSE_3)) && ((rect.y + 2*rect.height + cursorAbsBounds.height) <= screenSize.height))
1199 if ((__handlerDirection == HANDLER_DIRECTION_REVERSE_2) && ((rect.x + rect.width) <= screenSize.width))
1201 __handlerDirection = HANDLER_DIRECTION_NONE;
1203 else if ((__handlerDirection == HANDLER_DIRECTION_REVERSE_2) && ((rect.x + rect.width) > screenSize.width))
1205 __handlerDirection = HANDLER_DIRECTION_REVERSE_1;
1206 rect.x -= rect.width;
1208 else if ((__handlerDirection == HANDLER_DIRECTION_REVERSE_3) && ((rect.x + 2*rect.width) <= screenSize.width))
1210 __handlerDirection = HANDLER_DIRECTION_NONE;
1211 rect.x += rect.width;
1213 else if ((__handlerDirection == HANDLER_DIRECTION_REVERSE_3) && ((rect.x + 2*rect.width) > screenSize.width))
1215 __handlerDirection = HANDLER_DIRECTION_REVERSE_1;
1217 rect.y += (rect.height + cursorAbsBounds.height);
1218 ChangeHandlerBitmap();
1219 __reverseCheck = true;
1227 _EditCopyPasteHandler::OnTouchReleased(const _Control& source, const _TouchInfo& touchinfo)
1229 CheckReverseStatus();
1230 __isTouchPressed = false;
1231 __absoluteTouchPressedPoint = FloatPoint(0.0f, 0.0f);
1232 DestroyCopyPasteMagnifier();
1233 __pCopyPasteManager->CreateCopyPastePopup();
1234 __pCopyPasteManager->Show();
1235 __pCopyPasteManager->SendTextBlockEvent();
1237 __isTouchMoving = false;
1242 _EditCopyPasteHandler::OnTouchMoved(const _Control& source, const _TouchInfo& touchinfo)
1245 FloatRectangle cursorRect(0.0f, 0.0f, 0.0f, 0.0f);
1246 FloatRectangle absCursorRect(0.0f, 0.0f, 0.0f, 0.0f);
1247 FloatRectangle rect = GetBoundsF();
1248 FloatPoint point = touchinfo.GetCurrentPosition();
1249 FloatPoint touchPoint(0.0f, 0.0f);
1250 FloatPoint checkPoint(0.0f, 0.0f);
1251 __isTouchMoving = true;
1253 _Edit* pEdit = __pCopyPasteManager->GetEdit();
1254 SysTryReturn(NID_UI_CTRL, pEdit, false, E_INVALID_STATE, "[E_INVALID_STATE] pEdit is null.\n");
1256 _EditPresenter* pEditPresenter = pEdit->GetPresenter();
1257 SysTryReturn(NID_UI_CTRL, pEditPresenter, false, E_INVALID_STATE, "[E_INVALID_STATE] pEditPresenter is null.\n");
1259 TextObject* pTextObject = pEditPresenter->GetTextObject();
1260 SysTryReturn(NID_UI_CTRL, pTextObject, false, E_INVALID_STATE, "[E_INVALID_STATE] pEditPresenter is null.\n");
1262 int curCursorLine = pTextObject->GetLineIndexAtTextIndex(__handlerCursorPos);
1263 int totalLine = pTextObject->GetTotalLineCount();
1265 float totalHeight = pTextObject->GetTotalHeightF();
1266 float firstDisplayY = pTextObject->GetFirstDisplayPositionYF();
1267 FloatRectangle absTextObjectBounds(0.0f, 0.0f, 0.0f, 0.0f);
1268 FloatRectangle textObjectBounds = pEditPresenter->GetTextBoundsF();
1269 FloatRectangle absEditBounds = pEdit->GetAbsoluteBoundsF();
1270 absTextObjectBounds.x = absEditBounds.x + textObjectBounds.x;
1271 absTextObjectBounds.y = absEditBounds.y + textObjectBounds.y;
1272 absTextObjectBounds.width = textObjectBounds.width;
1273 absTextObjectBounds.height = textObjectBounds.height;
1274 if (__touchPressedPoint.x == point.x && __touchPressedPoint.y == point.y)
1279 if (__rowIndex == -1 && __columnIndex == -1)
1281 pEditPresenter->CalculateCursorBounds(pEditPresenter->GetTextBoundsF(), cursorRect,__handlerCursorPos);
1282 pEditPresenter->CalculateAbsoluteCursorBounds(__handlerCursorPos, absCursorRect);
1286 pEditPresenter->CalculateCursorBounds(pEditPresenter->GetTextBoundsF(), cursorRect, __rowIndex, __columnIndex);
1287 pEditPresenter->CalculateAbsoluteCursorBounds(__rowIndex, __columnIndex, absCursorRect);
1290 FloatPoint absoluteTouchMovedPoint = FloatPoint(GetBoundsF().x + point.x, GetBoundsF().y + point.y);
1291 //Calculate handler's position
1292 if (__singleHandler)
1294 touchPoint.x = absoluteTouchMovedPoint.x;
1295 if (__handlerDirection == HANDLER_DIRECTION_NONE)
1297 touchPoint.y = absoluteTouchMovedPoint.y - GetBoundsF().height/2.0f;
1299 else // HANDLER_DIRECTION_REVERSE_2
1301 touchPoint.y = absoluteTouchMovedPoint.y + GetBoundsF().height/2.0f;
1308 if (__handlerDirection == HANDLER_DIRECTION_NONE)
1310 touchPoint.x = absoluteTouchMovedPoint.x + GetBoundsF().width/2.0f;
1311 touchPoint.y = absoluteTouchMovedPoint.y - GetBoundsF().height/2.0f;
1313 else if (__handlerDirection == HANDLER_DIRECTION_REVERSE_1)
1315 touchPoint.x = absoluteTouchMovedPoint.x - GetBoundsF().width/2.0f;
1316 touchPoint.y = absoluteTouchMovedPoint.y - GetBoundsF().height/2.0f;
1318 else if (__handlerDirection == HANDLER_DIRECTION_REVERSE_2)
1320 touchPoint.x = absoluteTouchMovedPoint.x + GetBoundsF().width/2.0f;
1321 touchPoint.y = absoluteTouchMovedPoint.y + GetBoundsF().height/2.0f;
1323 else if (__handlerDirection == HANDLER_DIRECTION_REVERSE_3)
1325 touchPoint.x = absoluteTouchMovedPoint.x - GetBoundsF().width/2.0f;
1326 touchPoint.y = absoluteTouchMovedPoint.y + GetBoundsF().height/2.0f;
1331 if (__handlerDirection == HANDLER_DIRECTION_NONE)
1333 touchPoint.x = absoluteTouchMovedPoint.x - GetBoundsF().width/2.0f;
1334 touchPoint.y = absoluteTouchMovedPoint.y - GetBoundsF().height/2.0f;
1336 else if (__handlerDirection == HANDLER_DIRECTION_REVERSE_1)
1338 touchPoint.x = absoluteTouchMovedPoint.x + GetBoundsF().width/2.0f;
1339 touchPoint.y = absoluteTouchMovedPoint.y - GetBoundsF().height/2.0f;
1341 else if (__handlerDirection == HANDLER_DIRECTION_REVERSE_2)
1343 touchPoint.x = absoluteTouchMovedPoint.x - GetBoundsF().width/2.0f;
1344 touchPoint.y = absoluteTouchMovedPoint.y + GetBoundsF().height/2.0f;
1346 else if (__handlerDirection == HANDLER_DIRECTION_REVERSE_3)
1348 touchPoint.x = absoluteTouchMovedPoint.x + GetBoundsF().width/2.0f;
1349 touchPoint.y = absoluteTouchMovedPoint.y + GetBoundsF().height/2.0f;
1353 if (totalHeight - firstDisplayY < absTextObjectBounds.height)
1355 absTextObjectBounds.height = totalHeight - firstDisplayY - 1.0f; // check TextObject
1358 if (totalLine != 1) //single line edit doesn't need to adjust horizontal value.
1360 if (absTextObjectBounds.x > touchPoint.x)
1362 touchPoint.x = absTextObjectBounds.x;
1364 if (absTextObjectBounds.x + absTextObjectBounds.width <= touchPoint.x) // check FloatRectangle Contains?
1366 touchPoint.x = absTextObjectBounds.x + absTextObjectBounds.width - 1.0f;
1369 if (absTextObjectBounds.y > touchPoint.y)
1371 if (totalLine == 1 || firstDisplayY == 0.0f) // whether need to scroll the text or not
1373 touchPoint.y = absTextObjectBounds.y; //not need to scroll the text.
1376 if (absTextObjectBounds.y + absTextObjectBounds.height < touchPoint.y)
1378 if (totalLine == 1 || (totalHeight - firstDisplayY < textObjectBounds.height) || curCursorLine == (totalLine - 1)) // || pTextObject->IsDisplayedLastLine()) // whether need to scroll the text or not
1380 touchPoint.y = absTextObjectBounds.y + absTextObjectBounds.height - 1.0f; // check TextObject
1384 if (!__singleHandler)
1386 int nextHandlerLine = -1;
1389 nextHandlerLine = pTextObject->GetLineIndexAtTextIndex(__pCopyPasteManager->GetHandlerCursorPosition(Tizen::Ui::Controls::_EditCopyPasteManager::HANDLER_TYPE_RIGHT));
1393 nextHandlerLine = pTextObject->GetLineIndexAtTextIndex(__pCopyPasteManager->GetHandlerCursorPosition(Tizen::Ui::Controls::_EditCopyPasteManager::HANDLER_TYPE_LEFT));
1396 if (curCursorLine == nextHandlerLine)
1398 if (__leftHandler && absoluteTouchMovedPoint.y >= absCursorRect.y + absCursorRect.height)
1400 touchPoint.y = absCursorRect.y + absCursorRect.height/2.0f;
1402 else if (!__leftHandler && absoluteTouchMovedPoint.y <= absCursorRect.y + absCursorRect.height)
1404 touchPoint.y = absCursorRect.y + absCursorRect.height/2.0f;
1409 touchPoint.x = touchPoint.x - absEditBounds.x - textObjectBounds.x;
1410 touchPoint.y = touchPoint.y - absEditBounds.y - textObjectBounds.y;
1412 if (Math::Abs(touchPoint.y) < 1)
1414 touchPoint.y = 0.0f;
1418 int columnIndex = -1;
1419 cursorPos = pTextObject->GetTextIndexFromPosition(touchPoint.x, touchPoint.y, rowIndex, columnIndex, true);
1421 if (__handlerCursorPos == cursorPos)
1426 if (cursorPos == -1)
1431 if (absoluteTouchMovedPoint.y > (absCursorRect.y + absCursorRect.height))
1433 if (curCursorLine < totalLine - 1)
1435 int offset = __handlerCursorPos - pTextObject->GetFirstTextIndexAt(curCursorLine);
1436 int firstTextIndex = pTextObject->GetFirstTextIndexAt(curCursorLine+1);
1437 cursorPos = offset + firstTextIndex;
1438 int textLength = pTextObject->GetTextLengthAt(curCursorLine+1);
1439 if (offset > textLength)
1441 cursorPos = firstTextIndex+textLength;
1447 if (curCursorLine !=0)
1449 if (__rowIndex == 0)
1453 int offset = __handlerCursorPos - pTextObject->GetFirstTextIndexAt(curCursorLine);
1454 int firstTextIndex = pTextObject->GetFirstTextIndexAt(curCursorLine-1);
1455 cursorPos = offset + firstTextIndex;
1456 int textLength = pTextObject->GetTextLengthAt(curCursorLine-1);
1457 if (offset > textLength)
1459 cursorPos = firstTextIndex+textLength;
1464 if (cursorPos == -1)
1470 if (__handlerCursorPos == cursorPos)
1474 if (!__singleHandler)
1476 if (!__pCopyPasteManager->CheckHandlePosition(__leftHandler, cursorPos))
1480 _EditCopyPasteManager::HandlerType nextHandlerType = _EditCopyPasteManager::HANDLER_TYPE_MAX;
1483 nextHandlerType = _EditCopyPasteManager::HANDLER_TYPE_RIGHT;
1487 nextHandlerType = _EditCopyPasteManager::HANDLER_TYPE_LEFT;
1489 int nextHandler = __pCopyPasteManager->GetHandlerCursorPosition(nextHandlerType);
1490 if (Math::Abs(nextHandler - __handlerCursorPos) <= 1)
1492 pTextObject->SetFirstDisplayLineIndexFromTextIndex(nextHandler);
1499 if (rowIndex > -1 && columnIndex > -1)
1501 __rowIndex = rowIndex;
1502 __columnIndex = columnIndex;
1510 pTextObject->SetFirstDisplayLineIndexFromTextIndex(cursorPos);
1512 __handlerCursorPos = cursorPos;
1513 __pCopyPasteManager->SetCursorPosition(__handlerCursorPos);
1514 pEditPresenter->ScrollPanelToCursorPosition(true);
1516 if (!__singleHandler)
1518 __pCopyPasteManager->RefreshBlock(__leftHandler);
1522 if (__rowIndex == -1 && __columnIndex == -1)
1524 __pCopyPasteManager->SetCursorPosition(cursorPos);
1528 pEditPresenter->SetCursorPosition(cursorPos, __rowIndex, __columnIndex);
1530 pEditPresenter->DrawText();
1533 MoveCopyPasteMagnifier();
1539 _EditCopyPasteHandler::IsActivatedOnOpen(void) const
1545 _EditCopyPasteHandler::OnChangeLayout(_ControlOrientation orientation)
1552 _EditCopyPasteHandler::OnAttachedToMainTree(void)
1554 result r = E_SUCCESS;
1556 if (GetOwner() == null)
1558 _Edit* pEdit = __pCopyPasteManager->GetEdit();
1559 SysTryReturnResult(NID_UI_CTRL, pEdit, GetLastResult(), "Unable to get pEdit.");
1561 _EditPresenter* pEditPresenter = pEdit->GetPresenter();
1562 SysTryReturnResult(NID_UI_CTRL, pEdit, GetLastResult(), "Unable to get pEditPresenter.");
1564 _Form* pParentForm = pEditPresenter->GetParentForm();
1567 SetOwner(pParentForm);
1571 _Form* pForm = null;
1572 _Frame* pCurrentFrame = dynamic_cast <_Frame*>(_ControlManager::GetInstance()->GetCurrentFrame());
1575 pForm = pCurrentFrame->GetCurrentForm();
1582 SetOwner(pCurrentFrame);
1592 _EditCopyPasteHandler::OnBoundsChanging(const FloatRectangle& bounds)
1594 result r = E_SUCCESS;
1596 __windowBounds = bounds;
1598 if (!GetVisibleState())
1603 if (!__reverseCheck)
1605 _EcoreEvas* pEcoreEvas = GetEcoreEvasMgr()->GetEcoreEvas();
1606 SysTryReturn(NID_UI, pEcoreEvas, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error occurred.");
1608 pEcoreEvas->SetWindowBounds(*GetRootWindow(), bounds);
1609 result r = GetLastResult();
1610 SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1617 _EditCopyPasteHandler::OnBoundsChanging(const Rectangle& bounds)
1619 result r = E_SUCCESS;
1624 _EditCopyPasteHandler::SetWindowBounds(const Rectangle& bounds)
1626 _EcoreEvas* pEcoreEvas = GetEcoreEvasMgr()->GetEcoreEvas();
1627 SysTryReturn(NID_UI, pEcoreEvas, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error occurred.");
1629 pEcoreEvas->SetWindowBounds(*GetRootWindow(), bounds);
1630 result r = GetLastResult();
1631 SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1637 _EditCopyPasteHandler::SetWindowBounds(const FloatRectangle& bounds)
1639 _EcoreEvas* pEcoreEvas = GetEcoreEvasMgr()->GetEcoreEvas();
1640 SysTryReturn(NID_UI, pEcoreEvas, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error occurred.");
1642 pEcoreEvas->SetWindowBounds(*GetRootWindow(), bounds);
1643 result r = GetLastResult();
1644 SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1649 _EditCopyPasteManager::_EditCopyPasteManager(_Edit& parenEdit)
1650 : __pCopyPastePopup(null)
1651 , __contextMenuAlign(CONTEXT_MENU_CORE_ALIGN_UP)
1652 , __pCoreCopyPasteEvent(null)
1653 , __pEdit(&parenEdit)
1654 , __pEditPresenter(null)
1655 , __contextMenuHeight(0.0f)
1656 , __needToReleaseBlock(true)
1657 , __isHandlerMoving(false)
1658 , __editVisibleArea(0.0f, 0.0f, 0.0f, 0.0f)
1660 __pEditPresenter = __pEdit->GetPresenter();
1661 __pHandle[HANDLER_TYPE_CENTER] = null;
1662 __pHandle[HANDLER_TYPE_LEFT] = null;
1663 __pHandle[HANDLER_TYPE_RIGHT] = null;
1668 _EditCopyPasteManager::~_EditCopyPasteManager(void)
1672 if (__pCoreCopyPasteEvent)
1674 delete __pCoreCopyPasteEvent;
1675 __pCoreCopyPasteEvent = null;
1680 _EditCopyPasteManager::Release(void)
1682 if (__pCopyPastePopup)
1684 __pCopyPastePopup->Close();
1685 delete __pCopyPastePopup;
1686 __pCopyPastePopup = null;
1689 if (__pHandle[HANDLER_TYPE_CENTER])
1691 __pHandle[HANDLER_TYPE_CENTER]->Close();
1692 delete __pHandle[HANDLER_TYPE_CENTER];
1693 __pHandle[HANDLER_TYPE_CENTER] = null;
1696 if (__pHandle[HANDLER_TYPE_LEFT])
1698 __pHandle[HANDLER_TYPE_LEFT]->Close();
1699 delete __pHandle[HANDLER_TYPE_LEFT];
1700 __pHandle[HANDLER_TYPE_LEFT] = null;
1703 if (__pHandle[HANDLER_TYPE_RIGHT])
1705 __pHandle[HANDLER_TYPE_RIGHT]->Close();
1706 delete __pHandle[HANDLER_TYPE_RIGHT];
1707 __pHandle[HANDLER_TYPE_RIGHT] = null;
1712 _EditCopyPasteManager::ReleaseCopyPastePopup(void)
1714 if (__pCopyPastePopup)
1716 __pCopyPastePopup->Close();
1717 delete __pCopyPastePopup;
1718 __pCopyPastePopup = null;
1723 _EditCopyPasteManager::IsCopyPastePopup(const _Control& control) const
1725 if (__pCopyPastePopup == &control)
1734 _EditCopyPasteManager::IsCopyPasteHandle(const _Control& control) const
1736 if (__pHandle[HANDLER_TYPE_CENTER] == &control)
1741 if (__pHandle[HANDLER_TYPE_LEFT] == &control)
1746 if (__pHandle[HANDLER_TYPE_RIGHT] == &control)
1755 _EditCopyPasteManager::AddCopyPasteEventListener(const _IEditCopyPasteEventListener& listener)
1759 if (__pCoreCopyPasteEvent == null)
1761 __pCoreCopyPasteEvent = _EditCopyPasteEvent::CreateInstanceN(*this);
1762 SysTryReturn(NID_UI_CTRL, __pCoreCopyPasteEvent, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] System error occurred.\n");
1765 return __pCoreCopyPasteEvent->AddListener(listener);
1769 _EditCopyPasteManager::SendCopyPasteEvent(CoreCopyPasteStatus status, CoreCopyPasteAction action)
1771 if (__pCoreCopyPasteEvent)
1773 IEventArg* pCopyPasteEventArg = _EditCopyPasteEvent::CreateCopyPasteEventArgN(status, action);
1774 SysTryReturn(NID_UI_CTRL, pCopyPasteEventArg, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Unable to create _LinkEventArg.");
1776 __pCoreCopyPasteEvent->Fire(*pCopyPasteEventArg);
1783 _EditCopyPasteManager::CreateCopyPastePopup(void)
1785 if (__pHandle[HANDLER_TYPE_CENTER])
1787 __pHandle[HANDLER_TYPE_CENTER]->DestroyCopyPasteMagnifier();
1789 if (__pCopyPastePopup)
1791 __pCopyPastePopup->Close();
1792 delete __pCopyPastePopup;
1793 __pCopyPastePopup = null;
1796 FloatRectangle startRect;
1797 FloatRectangle endRect;
1798 FloatRectangle editAbsRect;
1799 FloatRectangle editShowAreaAbsRect;
1800 FloatRectangle commandButtonBounds;
1801 FloatRectangle keypadBounds(0.0f, 0.0f, 0.0f, 0.0f);
1802 FloatRectangle formClientBounds(0.0f, 0.0f, 0.0f, 0.0f);
1803 FloatRectangle panelAbsoulteBounds(0.0f, 0.0f, 0.0f, 0.0f);
1804 bool commandButtonExist = false;
1805 FloatRectangle cursorRect = GetCursorBoundsF(true);
1807 float contextMenuHeight = 0.0f;
1808 float contextMenuTopMargin = 0.0f;
1809 float contextMenuBottomMargin = 0.0f;
1810 float contextMenuArrowHeight = 0.0f;
1811 float handlerHeight = 0.0f;
1812 bool isPasswordStyle = false;
1813 bool isClipped = false;
1814 if (__pEdit->GetEditStyle() & EDIT_STYLE_PASSWORD)
1816 isPasswordStyle = true;
1819 _ControlOrientation orientation = __pEdit->GetOrientation();
1821 FloatDimension screenSize;
1822 _ControlManager* pControlManager = _ControlManager::GetInstance();
1823 if (orientation == _CONTROL_ORIENTATION_PORTRAIT)
1825 screenSize = pControlManager->GetScreenSizeF();
1829 screenSize.width = pControlManager->GetScreenSizeF().height;
1830 screenSize.height = pControlManager->GetScreenSizeF().width;
1833 GET_SHAPE_CONFIG(EDIT::COPYPASTE_HANDLER_HEIGHT, orientation, handlerHeight);
1835 GET_SHAPE_CONFIG(CONTEXTMENU::GRID_ITEM_HEIGHT, orientation, contextMenuHeight);
1836 GET_SHAPE_CONFIG(CONTEXTMENU::GRID_TOP_MARGIN, orientation, contextMenuTopMargin);
1837 GET_SHAPE_CONFIG(CONTEXTMENU::GRID_BOTTOM_MARGIN, orientation, contextMenuBottomMargin);
1838 GET_SHAPE_CONFIG(CONTEXTMENU::ANCHOR_HEIGHT, orientation, contextMenuArrowHeight);
1840 isClipped = __pEdit->IsClipped();
1841 if ((__pEdit->GetTextLength() == 0 || __pEdit->GetEditStyle() & EDIT_STYLE_PASSWORD) && !isClipped)
1846 if (__pEdit->GetTextLength() == 0 && (__pEditPresenter->IsViewModeEnabled()))
1851 __contextMenuHeight = contextMenuHeight + contextMenuTopMargin + contextMenuBottomMargin + contextMenuArrowHeight;
1852 if (isClipped && __pEditPresenter->IsViewModeEnabled() == false && __pEdit->GetTextLength() > 0 && orientation == _CONTROL_ORIENTATION_PORTRAIT)
1854 __contextMenuHeight = __contextMenuHeight + contextMenuHeight;
1857 editAbsRect = __pEdit->GetAbsoluteBoundsF();
1859 _Toolbar* pCommandButton = __pEditPresenter->GetKeypadCommandButton();
1862 commandButtonBounds = pCommandButton->GetAbsoluteBoundsF();
1863 commandButtonExist = true;
1865 _Form* pForm = __pEditPresenter->GetParentForm();
1868 formClientBounds = pForm->GetClientBoundsF();
1870 _ScrollPanel* pPanel = __pEditPresenter->GetParentPanel();
1873 panelAbsoulteBounds = pPanel->GetAbsoluteBoundsF();
1875 __pEdit->GetKeypadBounds(keypadBounds);
1879 editShowAreaAbsRect = editAbsRect;
1880 FloatRectangle textObjectBounds = __pEditPresenter->GetTextBoundsF();
1882 if (!(__pEdit->GetEditStyle() & EDIT_STYLE_TOKEN))
1884 editShowAreaAbsRect.x += textObjectBounds.x;
1885 editShowAreaAbsRect.y += textObjectBounds.y;
1886 editShowAreaAbsRect.width = textObjectBounds.width;
1888 if (!(__pEdit->GetEditStyle() & EDIT_STYLE_SINGLE_LINE))
1890 editShowAreaAbsRect.height = textObjectBounds.height;
1894 if (commandButtonExist)
1896 if (editShowAreaAbsRect.y + editShowAreaAbsRect.height > commandButtonBounds.y)
1898 editShowAreaAbsRect.height -= (editShowAreaAbsRect.y + editShowAreaAbsRect.height - commandButtonBounds.y);
1903 if (editShowAreaAbsRect.y + editShowAreaAbsRect.height > keypadBounds.y)
1905 editShowAreaAbsRect.height -= (editShowAreaAbsRect.y + editShowAreaAbsRect.height - keypadBounds.y);
1908 if (editShowAreaAbsRect.y < formClientBounds.y)
1910 editShowAreaAbsRect.y = formClientBounds.y;
1911 editShowAreaAbsRect.height -= formClientBounds.y;
1913 if (editShowAreaAbsRect.y < panelAbsoulteBounds.y)
1915 editShowAreaAbsRect.y = panelAbsoulteBounds.y;
1916 editShowAreaAbsRect.height -= (panelAbsoulteBounds.y - editShowAreaAbsRect.y);
1918 __editVisibleArea = editShowAreaAbsRect;
1920 FloatPoint copyPastePoint(0.0f, 0.0f);
1921 __contextMenuAlign = CONTEXT_MENU_CORE_ALIGN_UP;
1923 if (__pEdit->IsBlocked())
1927 __pEdit->GetBlockRange(start, end);
1928 if (start == -1 || end == -1)
1930 SysLog(NID_UI_CTRL, "[EditCopyPasteManager] There is no blocked Range");
1934 __pEdit->CalculateAbsoluteCursorBounds(start, startRect);
1935 __pEdit->CalculateAbsoluteCursorBounds(end, endRect);
1936 if (startRect.x > endRect.x)
1938 copyPastePoint.x = endRect.x + (startRect.x - endRect.x)/2;
1940 else if (startRect.x < endRect.x)
1942 copyPastePoint.x = startRect.x + (endRect.x - startRect.x)/2;
1946 copyPastePoint.x = startRect.x;
1949 if (copyPastePoint.x < editShowAreaAbsRect.x)
1951 copyPastePoint.x = editShowAreaAbsRect.x;
1953 else if (copyPastePoint.x > (editShowAreaAbsRect.x + editShowAreaAbsRect.width))
1955 copyPastePoint.x = editShowAreaAbsRect.x + editShowAreaAbsRect.width;
1958 //Both of handlers are located on the top of the Editor.
1959 if ( ((startRect.y + startRect.height) < editShowAreaAbsRect.y) && ((endRect.y + endRect.height) < editShowAreaAbsRect.y))
1961 SysLog(NID_UI_CTRL, "Both of handlers are located on the top of the Editor.\n");
1964 //Both of handlers are located on the bottom of the Editor.
1965 else if( ((startRect.y + startRect.height) > editShowAreaAbsRect.y + editShowAreaAbsRect.height ) && ((endRect.y + endRect.height) > editShowAreaAbsRect.y + editShowAreaAbsRect.height))
1967 SysLog(NID_UI_CTRL, "Both of handlers are located on the bottom of the Editor.\n");
1970 // Left handler is located on the top of the Editor and Right handler is located on the bottom of the Editor.
1971 else if ( ((startRect.y + startRect.height) < editShowAreaAbsRect.y) && ((endRect.y + endRect.height) > (editShowAreaAbsRect.y + editShowAreaAbsRect.height)))
1973 copyPastePoint.y = editShowAreaAbsRect.y + editShowAreaAbsRect.height/2;
1975 if (copyPastePoint.y < __contextMenuHeight)
1977 __contextMenuAlign = CONTEXT_MENU_CORE_ALIGN_DOWN;
1981 // Left handler is located on the top of the Editor and Right handler is located on the Editor
1982 else if ( ((startRect.y + startRect.height) < editShowAreaAbsRect.y) && ((endRect.y + endRect.height) <= (editShowAreaAbsRect.y + editShowAreaAbsRect.height)) )
1984 if ( (endRect.y + endRect.height + handlerHeight + __contextMenuHeight) < keypadBounds.y)
1986 __contextMenuAlign = CONTEXT_MENU_CORE_ALIGN_DOWN;
1987 copyPastePoint.y = endRect.y + endRect.height + handlerHeight;
1989 else if (endRect.y - editShowAreaAbsRect.y > __contextMenuHeight)
1991 copyPastePoint.y = editShowAreaAbsRect.y + __contextMenuHeight;
1993 else if (endRect.y > __contextMenuHeight)
1995 copyPastePoint.y = endRect.y;
1999 SysLog(NID_UI_CTRL, "There is no space to draw the copy&paste popup\n");
2003 // Left handler is located on the Editor and Right handler is located on the bottom of the Editor
2004 else if ( ((startRect.y + startRect.height) >= editShowAreaAbsRect.y) && ((endRect.y + endRect.height) > (editShowAreaAbsRect.y + editShowAreaAbsRect.height)) )
2006 if (__contextMenuHeight < startRect.y)
2008 copyPastePoint.y = startRect.y;
2012 copyPastePoint.y = startRect.y + (editShowAreaAbsRect.y + editShowAreaAbsRect.height - startRect.y)/2;
2015 // There is a space on the top of the Editor.
2016 else if (__contextMenuHeight < startRect.y)
2018 copyPastePoint.y = startRect.y;
2020 // There is a space on the bottom of the Editor.
2021 else if ( screenSize.height > (endRect.y + endRect.height + handlerHeight + __contextMenuHeight))
2023 __contextMenuAlign = CONTEXT_MENU_CORE_ALIGN_DOWN;
2025 copyPastePoint.y = endRect.y + endRect.height + handlerHeight;
2027 // There is no space on the top and bottom of the Editor. The Popup should be drawn on the center of the Editor.
2030 if (endRect.y - startRect.y < __contextMenuHeight)
2032 SysLog(NID_UI_CTRL, "There is no space to draw the copy&paste popup\n");
2035 copyPastePoint.y = startRect.y + __contextMenuHeight;
2041 if (editShowAreaAbsRect.height <= 0)
2045 FloatRectangle cursorRect;
2046 int cursorPosition = GetCursorPosition();
2047 __pEdit->CalculateAbsoluteCursorBounds(cursorPosition, cursorRect);
2048 copyPastePoint.x = cursorRect.x;
2049 copyPastePoint.y = cursorRect.y;
2051 if (__editVisibleArea.y > copyPastePoint.y || __editVisibleArea.y + __editVisibleArea.height < copyPastePoint.y)
2056 if (copyPastePoint.y < __contextMenuHeight)
2058 FloatRectangle cursorRect = GetCursorBoundsF(true);
2060 copyPastePoint.y += cursorRect.height;
2061 __contextMenuAlign = CONTEXT_MENU_CORE_ALIGN_DOWN;
2062 if (__pHandle[HANDLER_TYPE_CENTER])
2064 copyPastePoint.y += __pHandle[HANDLER_TYPE_CENTER]->GetBounds().height;
2069 //Todo: Create API ex)CreateContrexMenuFN
2070 __pCopyPastePopup = _ContextMenu::CreateContextMenuN(copyPastePoint, CONTEXT_MENU_CORE_STYLE_GRID, __contextMenuAlign);
2071 SysTryReturnVoidResult(NID_UI_CTRL, __pCopyPastePopup, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2073 if ( __pEdit->GetTextLength() != 0 && !isPasswordStyle)
2075 if (__pEdit->IsBlocked())
2080 GET_STRING_CONFIG(IDS_TPLATFORM_OPT_COPY, copyText);
2081 GET_STRING_CONFIG(IDS_TPLATFORM_OPT_CUT, cutText);
2083 __pCopyPastePopup->AddItem(copyText, COPY_PASTE_COPY_ID, null, null, null);
2084 if (!__pEditPresenter->IsViewModeEnabled())
2086 __pCopyPastePopup->AddItem(cutText, COPY_PASTE_CUT_ID, null, null, null);
2092 String selectAllText;
2094 GET_STRING_CONFIG(IDS_TPLATFORM_OPT_SELECT, selectText);
2095 GET_STRING_CONFIG(IDS_TPLATFORM_OPT_SELECT_ALL, selectAllText);
2097 __pCopyPastePopup->AddItem(selectText, COPY_PASTE_SELECT_ID, null, null, null);
2098 __pCopyPastePopup->AddItem(selectAllText, COPY_PASTE_SELECT_ALL_ID, null, null, null);
2104 if (!__pEditPresenter->IsViewModeEnabled())
2107 String clipboardText;
2109 GET_STRING_CONFIG(IDS_TPLATFORM_OPT_PASTE, pasteText);
2110 GET_STRING_CONFIG(IDS_TPLATFORM_OPT_CLIPBOARD, clipboardText);
2112 __pCopyPastePopup->AddItem(pasteText, COPY_PASTE_PASTE_ID, null, null, null);
2113 if (!isPasswordStyle && __pEdit->IsKeypadEnabled())
2115 __pCopyPastePopup->AddItem(clipboardText, COPY_PASTE_CLIPBOARD_ID, null, null, null);
2120 __pCopyPastePopup->AddActionEventListener(*this);
2123 Bitmap* pSearchBitmap = null;
2124 Bitmap* pReplacedSearchBitmap = null;
2125 Bitmap* pReplacedSearchPressedBitmap = null;
2127 Color searchPressedColor;
2128 result r = E_SUCCESS;
2130 if (__pEdit->IsBlocked() && !isPasswordStyle)
2132 r = GET_BITMAP_CONFIG_N(EDIT::COPY_PASTE_SEARCH_ICON, BITMAP_PIXEL_FORMAT_ARGB8888, pSearchBitmap);
2133 SysTryReturnVoidResult(NID_UI_CTRL, (r == E_SUCCESS), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2135 GET_COLOR_CONFIG(CONTEXTMENU::ITEM_TEXT_NORMAL, searchColor);
2136 GET_COLOR_CONFIG(CONTEXTMENU::ITEM_TEXT_PRESSED, searchPressedColor);
2138 pReplacedSearchBitmap = _BitmapImpl::GetColorReplacedBitmapN(*pSearchBitmap, Color::GetColor(COLOR_ID_MAGENTA), searchColor);
2139 SysTryCatch(NID_UI_CTRL, pReplacedSearchBitmap, r = GetLastResult(), GetLastResult(),"[%s] Propagating.", GetErrorMessage(GetLastResult()));
2141 pReplacedSearchPressedBitmap = _BitmapImpl::GetColorReplacedBitmapN(*pSearchBitmap, Color::GetColor(COLOR_ID_MAGENTA), searchPressedColor);
2142 SysTryCatch(NID_UI_CTRL, pReplacedSearchPressedBitmap, r = GetLastResult(), GetLastResult(),"[%s] Propagating.", GetErrorMessage(GetLastResult()));
2144 __pCopyPastePopup->AddItem(null, COPY_PASTE_SEARCH_ID, pReplacedSearchBitmap, pReplacedSearchPressedBitmap, null);
2149 delete pSearchBitmap;
2150 pSearchBitmap = null;
2152 if (pReplacedSearchBitmap)
2154 delete pReplacedSearchBitmap;
2155 pReplacedSearchBitmap = null;
2158 if (pReplacedSearchPressedBitmap)
2160 delete pReplacedSearchPressedBitmap;
2161 pReplacedSearchPressedBitmap = null;
2163 __pCopyPastePopup->AddActionEventListener(*this);
2168 delete pSearchBitmap;
2169 pSearchBitmap = null;
2171 delete pReplacedSearchBitmap;
2172 pReplacedSearchBitmap = null;
2179 _EditCopyPasteManager::CreateHandle(void)
2183 if (__pEdit->IsBlocked())
2187 FloatRectangle startRect;
2188 FloatRectangle endRect;
2190 __pEdit->GetBlockRange(start, end);
2192 __pEdit->CalculateAbsoluteCursorBounds(start, startRect);
2193 __pEdit->CalculateAbsoluteCursorBounds(end, endRect);
2195 FloatPoint leftHandler(startRect.x, startRect.y + startRect.height);
2196 FloatPoint rightHandler(endRect.x, endRect.y + endRect.height);
2198 __pHandle[HANDLER_TYPE_LEFT] = _EditCopyPasteHandler::CreateInstanceN(leftHandler, start, this, false, true);
2199 __pHandle[HANDLER_TYPE_RIGHT] = _EditCopyPasteHandler::CreateInstanceN(rightHandler, end, this, false, false);
2203 FloatRectangle centerRect;
2204 __pEdit->CalculateAbsoluteCursorBounds(__pEdit->GetCursorPosition(), centerRect);
2205 FloatPoint centerHandler(centerRect.x, centerRect.y + centerRect.height);
2207 __pHandle[HANDLER_TYPE_CENTER] = _EditCopyPasteHandler::CreateInstanceN(centerHandler, __pEdit->GetCursorPosition(), this, true, true);
2208 #if EDIT_COPY_PASTE_MAGNIFIER
2209 // __pHandle[HANDLER_TYPE_CENTER]->CreateCopyPasteMagnifier();
2215 _EditCopyPasteManager::Show(void)
2217 if (__pHandle[HANDLER_TYPE_CENTER])
2219 if (__pEdit->GetCursorPosition() != __pHandle[HANDLER_TYPE_CENTER]->GetHandlerCursorPosition())
2221 __pHandle[HANDLER_TYPE_CENTER]->SetHandlerCursorPosition(__pEdit->GetCursorPosition());
2223 __pHandle[HANDLER_TYPE_CENTER]->AdjustBounds();
2224 __pHandle[HANDLER_TYPE_CENTER]->CheckReverseStatus();
2225 __pHandle[HANDLER_TYPE_CENTER]->Invalidate();
2226 __pEditPresenter->DrawText();
2229 if (__pHandle[HANDLER_TYPE_LEFT] && __pHandle[HANDLER_TYPE_RIGHT])
2232 __pHandle[HANDLER_TYPE_LEFT]->CheckReverseStatus();
2233 __pHandle[HANDLER_TYPE_RIGHT]->CheckReverseStatus();
2234 __pHandle[HANDLER_TYPE_LEFT]->Invalidate();
2235 __pHandle[HANDLER_TYPE_RIGHT]->Invalidate();
2236 __pEditPresenter->DrawText();
2239 if (__pCopyPastePopup)
2241 __pCopyPastePopup->Open();
2242 __pCopyPastePopup->ReleaseTouchCapture();
2244 _Control* pControl = __pCopyPastePopup->GetOwner();
2247 pControl->UnlockInputEvent();
2253 _EditCopyPasteManager::CheckHandleBounds(const FloatPoint& point)
2255 bool hasCommandButton = false;
2256 bool hasParentForm = false;
2257 bool hasParentPanel = false;
2258 bool showCheck = true;
2259 FloatRectangle commandButtonBounds(0.0f, 0.0f, 0.0f, 0.0f);
2260 FloatRectangle formClientBounds(0.0f, 0.0f, 0.0f, 0.0f);
2261 FloatRectangle panelAbsoulteBounds(0.0f, 0.0f, 0.0f, 0.0f);
2262 FloatRectangle editAbsBounds = __pEdit->GetAbsoluteBoundsF();
2263 FloatRectangle textObjectBounds = __pEditPresenter->GetTextBoundsF();
2265 if (!(__pEdit->GetEditStyle() & EDIT_STYLE_TOKEN))
2267 editAbsBounds.x += textObjectBounds.x;
2268 editAbsBounds.y += textObjectBounds.y;
2269 editAbsBounds.width = textObjectBounds.width;
2271 if (!(__pEdit->GetEditStyle() & EDIT_STYLE_SINGLE_LINE))
2273 editAbsBounds.height = textObjectBounds.height;
2277 _Toolbar* pCommandButton = __pEditPresenter->GetKeypadCommandButton();
2280 commandButtonBounds = pCommandButton->GetAbsoluteBoundsF();
2281 hasCommandButton = true;
2283 _Form* pForm = __pEditPresenter->GetParentForm();
2286 formClientBounds = pForm->GetClientBoundsF();
2287 hasParentForm = true;
2290 _ScrollPanel* pPanel = __pEditPresenter->GetParentPanel();
2293 panelAbsoulteBounds = pPanel->GetAbsoluteBoundsF();
2294 hasParentPanel = true;
2297 if ((!_FloatCompare(editAbsBounds.x, point.x) && (editAbsBounds.x > point.x)) || (!_FloatCompare(point.x, editAbsBounds.x + editAbsBounds.width) && point.x > (editAbsBounds.x + editAbsBounds.width)))
2302 if ((!_FloatCompare(editAbsBounds.y, point.y) && (editAbsBounds.y > point.y)) || (!_FloatCompare(point.y, editAbsBounds.y + editAbsBounds.height) && point.y > (editAbsBounds.y + editAbsBounds.height)))
2306 if (hasParentForm && ((!_FloatCompare(formClientBounds.y, point.y) && formClientBounds.y > point.y) || (!_FloatCompare(point.y, formClientBounds.y + formClientBounds.height) && point.y > (formClientBounds.y + formClientBounds.height))))
2310 if (hasParentPanel && ((!_FloatCompare(panelAbsoulteBounds.y, point.y) && panelAbsoulteBounds.y > point.y) || (!_FloatCompare(point.y, panelAbsoulteBounds.y + panelAbsoulteBounds.height) && point.y > (panelAbsoulteBounds.y + panelAbsoulteBounds.height))))
2314 if (hasCommandButton && commandButtonBounds.Contains(point))
2322 _EditCopyPasteManager::CheckHandlePosition(bool leftHandle, int cursorPosition)
2324 int leftHandlerPosition = __pHandle[HANDLER_TYPE_LEFT]->GetHandlerCursorPosition();
2325 int rightHandlerPosition = __pHandle[HANDLER_TYPE_RIGHT]->GetHandlerCursorPosition();
2329 if (cursorPosition + 1 <= rightHandlerPosition)
2340 if (cursorPosition >= leftHandlerPosition + 1)
2352 _EditCopyPasteManager::RefreshBlock(bool isLeftHandle)
2354 int leftRowIndex = -1;
2355 int leftColumnIndex = -1;
2356 int rightRowIndex = -1;
2357 int rightColumnIndex = -1;
2359 int leftHandlerPos = __pHandle[HANDLER_TYPE_LEFT]->GetHandlerCursorPosition();
2360 int rightHandlerPos = __pHandle[HANDLER_TYPE_RIGHT]->GetHandlerCursorPosition();
2361 __pHandle[HANDLER_TYPE_RIGHT]->GetHandlerRowColumnIndex(leftRowIndex, leftColumnIndex);
2362 __pHandle[HANDLER_TYPE_RIGHT]->GetHandlerRowColumnIndex(rightRowIndex, rightColumnIndex);
2364 __pEditPresenter->SetBlockRange(leftHandlerPos, rightHandlerPos, leftColumnIndex, leftColumnIndex, rightRowIndex, rightColumnIndex);
2366 __pEditPresenter->SetCursorChangedFlag(!isLeftHandle);
2367 __pEditPresenter->DrawText();
2372 _EditCopyPasteManager::GetCursorBoundsF(bool isAbsRect) const
2374 FloatRectangle cursorBounds;
2376 __pEdit->GetCursorBounds(isAbsRect, cursorBounds);
2378 return cursorBounds;
2382 _EditCopyPasteManager::GetCursorPositionAt(const FloatPoint& touchPoint) const
2384 return __pEdit->GetCursorPositionAt(touchPoint);
2388 _EditCopyPasteManager::SetCursorPosition(int position)
2390 return __pEdit->SetCursorPosition(position);
2394 _EditCopyPasteManager::GetCursorPosition(void) const
2396 return __pEdit->GetCursorPosition();
2400 _EditCopyPasteManager::GetHandlerCursorPosition(HandlerType handlerType) const
2402 return __pHandle[handlerType]->GetHandlerCursorPosition();
2406 _EditCopyPasteManager::SendTextBlockEvent(void)
2410 result r = E_SUCCESS;
2412 __pEdit->GetBlockRange(start, end);
2413 if (start != -1 && end != -1)
2415 r = __pEdit->SendTextBlockEvent(start, end);
2416 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
2421 _EditCopyPasteManager::OnActionPerformed(const _Control& source, int actionId)
2423 _Clipboard* pClipBoard = _Clipboard::GetInstance();
2424 SysTryReturnVoidResult(NID_UI_CTRL, pClipBoard, E_SYSTEM, "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2426 ReleaseCopyPastePopup();
2430 case COPY_PASTE_SELECT_ID:
2432 int cursorPos = GetCursorPosition();
2435 __pEdit->GetWordPosition(cursorPos, start, end);
2436 __pEdit->SetBlockRange(start, end);
2437 SendTextBlockEvent();
2441 CreateCopyPastePopup();
2448 case COPY_PASTE_SELECT_ALL_ID:
2450 int textLength = __pEdit->GetTextLength();
2451 __pEdit->SetBlockRange(0, textLength);
2452 SendTextBlockEvent();
2453 __pEditPresenter->UpdateComponentInformation();
2457 CreateCopyPastePopup();
2464 case COPY_PASTE_COPY_ID:
2465 ReleaseCopyPastePopup();
2466 SendCopyPasteEvent(CORE_COPY_PASTE_STATUS_HIDE, CORE_COPY_PASTE_ACTION_COPY);
2469 case COPY_PASTE_CUT_ID:
2470 SendCopyPasteEvent(CORE_COPY_PASTE_STATUS_HIDE, CORE_COPY_PASTE_ACTION_CUT);
2473 case COPY_PASTE_PASTE_ID:
2474 SendCopyPasteEvent(CORE_COPY_PASTE_STATUS_HIDE, CORE_COPY_PASTE_ACTION_PASTE);
2477 case COPY_PASTE_CLIPBOARD_ID:
2478 pClipBoard->ShowPopup(CLIPBOARD_DATA_TYPE_TEXT, *__pEdit);
2479 ReleaseCopyPastePopup();
2480 SendCopyPasteEvent(CORE_COPY_PASTE_STATUS_HIDE, CORE_COPY_PASTE_ACTION_CLIPBOARD);
2482 case COPY_PASTE_SEARCH_ID:
2484 SendCopyPasteEvent(CORE_COPY_PASTE_STATUS_HIDE, CORE_COPY_PASTE_ACTION_SEARCH);
2494 _EditCopyPasteManager::AdjustBounds(void)
2496 if (__pHandle[HANDLER_TYPE_CENTER])
2498 __pHandle[HANDLER_TYPE_CENTER]->AdjustBounds();
2500 if (__pHandle[HANDLER_TYPE_LEFT])
2502 __pHandle[HANDLER_TYPE_LEFT]->AdjustBounds();
2504 if (__pHandle[HANDLER_TYPE_RIGHT])
2506 __pHandle[HANDLER_TYPE_RIGHT]->AdjustBounds();
2511 _EditCopyPasteManager::LaunchSearch(void)
2513 result r = E_SUCCESS;
2516 __pEdit->GetBlockRange(start, end);
2517 String blockText = __pEditPresenter->GetText(start, end-1);
2519 _AppMessageImpl msg;
2521 msg.AddData(APPSVC_DATA_KEYWORD, blockText);
2522 r = _AppControlManager::GetInstance()->LaunchPkg(msg, null, APPSVC_OPERATION_SEARCH, null, null, 0, 0);
2526 _EditCopyPasteManager::GetTextBlockReleaseFlag(void) const
2528 return __needToReleaseBlock;
2532 _EditCopyPasteManager::SetTextBlockReleaseFlag(bool enabled)
2534 __needToReleaseBlock = enabled;
2538 _EditCopyPasteManager::IsCopyPasteHandleExist(void) const
2540 if (__pHandle[HANDLER_TYPE_CENTER] || (__pHandle[HANDLER_TYPE_LEFT] && __pHandle[HANDLER_TYPE_RIGHT]))
2551 _EditCopyPasteManager::IsCopyPasteSingleHandleExist(void) const
2553 if (__pHandle[HANDLER_TYPE_CENTER])
2564 _EditCopyPasteManager::UpdateCopyPasteMagnifier(void)
2566 for (int i = 0; i < HANDLER_TYPE_MAX; i++)
2570 __pHandle[i]->UpdateCopyPasteMagnifier();
2576 _EditCopyPasteManager::GetEdit(void) const
2582 _EditCopyPasteManager::MoveHandler(HandlerMoveType moveType)
2584 if (!__pHandle[HANDLER_TYPE_RIGHT] || ! __pHandle[HANDLER_TYPE_LEFT])
2589 int leftHandlerPosition = __pHandle[HANDLER_TYPE_LEFT]->GetHandlerCursorPosition();
2590 int rightHandlerPosition = __pHandle[HANDLER_TYPE_RIGHT]->GetHandlerCursorPosition();
2591 int textLength = __pEdit->GetTextLength();
2592 FloatRectangle cursorBounds;
2593 int newCursorPosition;
2594 __pEdit->GetCursorBounds(false, cursorBounds);
2595 FloatPoint cursorPoint(cursorBounds.x, cursorBounds.y);
2597 TextObject* pTextObject = __pEditPresenter->GetTextObject();
2601 case HANDLER_MOVE_TYPE_LEFT:
2602 if (leftHandlerPosition < rightHandlerPosition-1)
2604 __pHandle[HANDLER_TYPE_RIGHT]->SetHandlerCursorPosition(--rightHandlerPosition);
2606 __pHandle[HANDLER_TYPE_RIGHT]->CheckReverseStatus();
2607 __pHandle[HANDLER_TYPE_RIGHT]->Invalidate();
2614 case HANDLER_MOVE_TYPE_UP:
2615 cursorPoint.y -= cursorBounds.height/2.0f;
2616 newCursorPosition = GetCursorPositionAt(cursorPoint);
2618 if (newCursorPosition <= 0)
2620 int curCursorLine = pTextObject->GetLineIndexAtTextIndex(pTextObject->GetCursorIndex());
2622 if (curCursorLine !=0 )
2624 int offset = rightHandlerPosition - pTextObject->GetFirstTextIndexAt(curCursorLine);
2625 int firstTextIndex = pTextObject->GetFirstTextIndexAt(curCursorLine-1);
2626 newCursorPosition = offset + firstTextIndex;
2627 int textLength = pTextObject->GetTextLengthAt(curCursorLine-1);
2628 if (offset > textLength)
2630 newCursorPosition = firstTextIndex+textLength;
2633 if (leftHandlerPosition >= newCursorPosition)
2635 newCursorPosition = leftHandlerPosition + 1;
2640 if (newCursorPosition >= 0 && leftHandlerPosition < newCursorPosition)
2642 __pHandle[HANDLER_TYPE_RIGHT]->SetHandlerCursorPosition(newCursorPosition);
2644 __pHandle[HANDLER_TYPE_RIGHT]->CheckReverseStatus();
2645 __pHandle[HANDLER_TYPE_RIGHT]->Invalidate();
2652 case HANDLER_MOVE_TYPE_DOWN:
2653 cursorPoint.y += cursorBounds.height + cursorBounds.height/2.0f;
2654 newCursorPosition = GetCursorPositionAt(cursorPoint);
2656 if (newCursorPosition < 0)
2658 int curCursorLine = pTextObject->GetLineIndexAtTextIndex(pTextObject->GetCursorIndex());
2659 int totalLine = pTextObject->GetTotalLineCount();
2660 if (curCursorLine < totalLine - 1)
2662 int offset = rightHandlerPosition - pTextObject->GetFirstTextIndexAt(curCursorLine);
2663 int firstTextIndex = pTextObject->GetFirstTextIndexAt(curCursorLine+1);
2664 newCursorPosition = offset + firstTextIndex;
2665 int textLength = pTextObject->GetTextLengthAt(curCursorLine+1);
2666 if (offset > textLength)
2668 newCursorPosition = firstTextIndex+textLength;
2672 else if (curCursorLine == totalLine - 1)
2674 int firstTextIndex = pTextObject->GetFirstTextIndexAt(curCursorLine);
2675 int textLength = pTextObject->GetTextLengthAt(curCursorLine);
2676 newCursorPosition = firstTextIndex + textLength;
2680 if (newCursorPosition >= 0)
2682 __pHandle[HANDLER_TYPE_RIGHT]->SetHandlerCursorPosition(newCursorPosition);
2684 __pHandle[HANDLER_TYPE_RIGHT]->CheckReverseStatus();
2685 __pHandle[HANDLER_TYPE_RIGHT]->Invalidate();
2692 case HANDLER_MOVE_TYPE_RIGHT:
2693 if (textLength >= rightHandlerPosition+1)
2695 __pHandle[HANDLER_TYPE_RIGHT]->SetHandlerCursorPosition(++rightHandlerPosition);
2697 __pHandle[HANDLER_TYPE_RIGHT]->CheckReverseStatus();
2698 __pHandle[HANDLER_TYPE_RIGHT]->Invalidate();
2709 ReleaseCopyPastePopup();
2710 __isHandlerMoving = true;
2715 _EditCopyPasteManager::IsHandlerMovingEnabled(void) const
2717 return __isHandlerMoving;
2721 _EditCopyPasteManager::SetHandlerMovingEnabled(bool enabled)
2723 __isHandlerMoving = enabled;
2727 _EditCopyPasteManager::GetEditVisibleArea(void) const
2729 return _CoordinateSystemUtils::ConvertToInteger(GetEditVisibleAreaF());
2733 _EditCopyPasteManager::GetEditVisibleAreaF(void) const
2735 return __editVisibleArea;
2739 _EditCopyPasteManager::GetCopyPastePopup(void) const
2741 return __pCopyPastePopup;
2745 _EditCopyPasteManager::GetHandlerRowColumnIndex(bool singleHandler, bool leftHandler, int& rowIndex, int& columnIndex) const
2747 HandlerType handlerType = HANDLER_TYPE_MAX;
2750 handlerType = HANDLER_TYPE_CENTER;
2752 else if (leftHandler)
2754 handlerType = HANDLER_TYPE_LEFT;
2758 handlerType = HANDLER_TYPE_RIGHT;
2761 if (__pHandle[handlerType])
2763 __pHandle[handlerType]->GetHandlerRowColumnIndex(rowIndex, columnIndex);
2774 }}} // Tizen::Ui::Controls