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 "FUiAnim_ControlVisualElement.h"
24 #include "FUiAnim_VisualElementImpl.h"
25 #include <appsvc/appsvc.h>
26 #include <FApp_AppControlManager.h>
27 #include <FApp_AppMessageImpl.h>
28 #include <FBaseUtilMath.h>
29 #include <FGrp_BitmapImpl.h>
30 #include "FUi_Clipboard.h"
31 #include "FUi_ClipboardItem.h"
32 #include "FUi_CoordinateSystemUtils.h"
33 #include "FUi_EcoreEvasMgr.h"
34 #include "FUiCtrl_EditCopyPasteManager.h"
35 #include "FUiCtrl_EditCopyPasteEvent.h"
36 #include "FUiCtrl_EditPresenter.h"
37 #include "FUiCtrl_Form.h"
38 #include "FUiCtrl_Frame.h"
39 #include "FUi_EcoreEvas.h"
41 #include "FUi_Window.h"
43 #define EDIT_COPY_PASTE_MAGNIFIER 1
45 using namespace Tizen::Ui;
46 using namespace Tizen::App;
47 using namespace Tizen::Base;
48 using namespace Tizen::Base::Runtime;
49 using namespace Tizen::Base::Utility;
50 using namespace Tizen::Graphics;
51 using namespace Tizen::Graphics::_Text;
52 using namespace Tizen::Ui::Animations;
54 namespace Tizen { namespace Ui { namespace Controls
57 const int COPY_PASTE_SELECT_ID = 231;
58 const int COPY_PASTE_SELECT_ALL_ID = 232;
59 const int COPY_PASTE_COPY_ID = 233;
60 const int COPY_PASTE_CUT_ID = 234;
61 const int COPY_PASTE_PASTE_ID = 235;
62 const int COPY_PASTE_CLIPBOARD_ID = 236;
63 const int COPY_PASTE_SEARCH_ID = 237;
65 class _EditCopyPasteMagnifier
69 _EditCopyPasteMagnifier(_EditCopyPasteManager* pCopyPasteManager, int handlerCursorPos);
70 virtual ~_EditCopyPasteMagnifier(void);
71 static _EditCopyPasteMagnifier* CreateInstanceN(const FloatPoint& point, int handlerCursorPos, _EditCopyPasteManager* pCopyPasteManager);
72 virtual void OnDraw(void);
73 void CaptureTextArea(Canvas& canvas);
74 void MoveMagnifier(const FloatPoint& point, int handlerCursorPos);
75 Bitmap* GetMagnifierBitmap(void) const;
76 virtual result OnAttachedToMainTree(void);
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;
93 _EditCopyPasteMagnifier::_EditCopyPasteMagnifier(_EditCopyPasteManager* pCopyPasteManager, int handlerCursorPos)
94 : __pCopyPasteManager(pCopyPasteManager)
95 , __pMagnifierBitmap(null)
96 , __pMagnifierMaskBitmap(null)
98 , __handlerCursorPos(handlerCursorPos)
103 __pRoot = GetVisualElement();
104 __pRoot->SetSurfaceOpaque(false);
106 GET_BITMAP_CONFIG_N(EDIT::COPY_PASTE_MAGNIFIER, BITMAP_PIXEL_FORMAT_ARGB8888, __pMagnifierBitmap);
107 GET_BITMAP_CONFIG_N(EDIT::COPY_PASTE_MAGNIFIER_MASK, BITMAP_PIXEL_FORMAT_ARGB8888, __pMagnifierMaskBitmap);
110 _EditCopyPasteMagnifier::~_EditCopyPasteMagnifier(void)
112 if (__pMagnifierBitmap)
114 delete __pMagnifierBitmap;
115 __pMagnifierBitmap = null;
117 if (__pMagnifierMaskBitmap)
119 delete __pMagnifierMaskBitmap;
120 __pMagnifierMaskBitmap = null;
125 _EditCopyPasteMagnifier::GetMagnifierBitmap(void) const
127 return __pMagnifierBitmap;
130 _EditCopyPasteMagnifier*
131 _EditCopyPasteMagnifier::CreateInstanceN(const FloatPoint& point, int handlerCursorPos, _EditCopyPasteManager* pCopyPasteManager)
133 _EditCopyPasteMagnifier* pCopyPasteMagnifier = new (std::nothrow) _EditCopyPasteMagnifier(pCopyPasteManager, handlerCursorPos);
134 SysTryReturn(NID_UI_CTRL, pCopyPasteMagnifier != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
136 FloatPoint cursorPoint(point);
137 FloatRectangle bounds(0.0f, 0.0f, 0.0f, 0.0f);
140 _Edit* pEdit = pCopyPasteManager->GetEdit();
141 _ControlOrientation orientation = pEdit->GetOrientation();
143 Bitmap* pMagnifierBitmap = pCopyPasteMagnifier->GetMagnifierBitmap();
144 SysTryReturn(NID_UI_CTRL, pMagnifierBitmap != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
146 result r = pCopyPasteMagnifier->CreateRootVisualElement(_WINDOW_TYPE_VE);
147 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
149 pCopyPasteMagnifier->SetActivationEnabled(false);
151 GET_SHAPE_CONFIG(EDIT::COPYPASTE_MAGNIFIER_WIDTH, orientation, width);
152 GET_SHAPE_CONFIG(EDIT::COPYPASTE_MAGNIFIER_HEIGHT, orientation, height);
154 bounds = FloatRectangle(cursorPoint.x - width/2.0f, cursorPoint.y - height, width, height);
159 pCopyPasteMagnifier->Open();
160 pCopyPasteMagnifier->SetBounds(bounds);
162 return pCopyPasteMagnifier;
165 pCopyPasteMagnifier->Close();
166 delete pCopyPasteMagnifier;
172 _EditCopyPasteMagnifier::OnAttachedToMainTree(void)
174 result r = E_SUCCESS;
176 if (GetOwner() == null)
178 _Edit* pEdit = __pCopyPasteManager->GetEdit();
179 SysTryReturnResult(NID_UI_CTRL, pEdit, GetLastResult(), "Unable to get pEdit.");
181 _Window* pWindow = null;
182 _Control* pControlCore = null;
184 for (pControlCore = pEdit->GetParent(); pWindow == null; pControlCore = pControlCore->GetParent())
186 if (pControlCore == null)
191 pWindow = dynamic_cast<_Window*>(pControlCore);
199 _EditPresenter* pEditPresenter = pEdit->GetPresenter();
200 SysTryReturnResult(NID_UI_CTRL, pEdit, GetLastResult(), "Unable to get pEditPresenter.");
202 _Form* pParentForm = pEditPresenter->GetParentForm();
205 SetOwner(pParentForm);
210 _Frame* pCurrentFrame = dynamic_cast <_Frame*>(_ControlManager::GetInstance()->GetCurrentFrame());
213 pForm = pCurrentFrame->GetCurrentForm();
220 SetOwner(pCurrentFrame);
230 _EditCopyPasteMagnifier::OnDraw(void)
232 Canvas* pCanvas = GetCanvasN();
237 pCanvas->SetBackgroundColor(Color(0, 0, 0, 0));
239 if (_BitmapImpl::CheckNinePatchedBitmapStrictly(*__pMagnifierBitmap))
241 pCanvas->DrawNinePatchedBitmap(pCanvas->GetBoundsF(), *__pMagnifierBitmap);
245 pCanvas->DrawBitmap(pCanvas->GetBoundsF(), *__pMagnifierBitmap);
248 if (_BitmapImpl::CheckNinePatchedBitmapStrictly(*__pMagnifierMaskBitmap))
250 Color editColor = __pCopyPasteManager->GetEdit()->GetColor(EDIT_STATUS_HIGHLIGHTED);
251 if (editColor.GetAlpha() == 0x00)
254 editColor = __pCopyPasteManager->GetEdit()->GetTextColor(EDIT_STATUS_HIGHLIGHTED);
255 editColor.GetColorComponents(r,g,b,a);
256 byte max = (r >= g) ? r:g;
257 max = (max >= b) ? max:b;
260 editColor = Color::GetColor(COLOR_ID_BLACK);
264 editColor = Color::GetColor(COLOR_ID_WHITE);
268 Bitmap* pReplacedMaskBitmap = _BitmapImpl::GetColorReplacedBitmapN(*__pMagnifierMaskBitmap, Color::GetColor(COLOR_ID_MAGENTA), editColor);
269 SysTryCatch(NID_UI_CTRL, pReplacedMaskBitmap, , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
271 pCanvas->DrawNinePatchedBitmap(pCanvas->GetBoundsF(), *pReplacedMaskBitmap);
273 delete pReplacedMaskBitmap;
277 pCanvas->DrawBitmap(pCanvas->GetBoundsF(), *__pMagnifierMaskBitmap);
280 CaptureTextArea(*pCanvas);
293 _EditCopyPasteMagnifier::CaptureTextArea(Canvas& canvas)
295 result r = E_SUCCESS;
296 float captureWidth = 0.0f;
297 float captureHeight = 0.0f;
298 float capturePosX = 0.0f;
299 float capturePosY = 0.0f;
300 float adjustPosX = 0.0f;
301 float adjustPosY = 0.0f;
302 FloatRectangle cursorBounds(0.0f, 0.0f, 0.0f, 0.0f);
303 FloatRectangle captureBounds(0.0f, 0.0f, 0.0f, 0.0f);
304 _VisualElementImpl* pEditVisualElementImpl = null;
306 _Edit* pEdit = __pCopyPasteManager->GetEdit();
307 SysTryReturnVoidResult(NID_UI_CTRL, pEdit, E_INVALID_STATE, "[E_INVALID_STATE] pEdit is null.");
309 _VisualElement* pEditVisualElement = pEdit->GetVisualElement();
310 SysTryReturnVoidResult(NID_UI_CTRL, pEditVisualElement, E_INVALID_STATE, "[E_INVALID_STATE] pEditVisualElement is null.");
312 _EditPresenter* pEditPresenter = pEdit->GetPresenter();
313 SysTryReturnVoidResult(NID_UI_CTRL, pEditPresenter, E_INVALID_STATE, "[E_INVALID_STATE] pEditPresenter is null.");
315 if (__rowIndex >= 0 && __columnIndex >= 0)
317 pEditPresenter->CalculateCursorBounds(pEditPresenter->GetTextBoundsF(), cursorBounds, __rowIndex, __columnIndex);
321 pEditPresenter->CalculateCursorBounds(pEditPresenter->GetTextBoundsF(), cursorBounds,__handlerCursorPos);
324 GET_SHAPE_CONFIG(EDIT::COPYPASTE_MAGNIFIER_CAPTURE_WIDTH, pEdit->GetOrientation(), captureWidth);
325 GET_SHAPE_CONFIG(EDIT::COPYPASTE_MAGNIFIER_CAPTURE_HEIGHT, pEdit->GetOrientation(), captureHeight);
326 GET_SHAPE_CONFIG(EDIT::COPYPASTE_MAGNIFIER_CAPTURE_POSITION_X, pEdit->GetOrientation(), capturePosX);
327 GET_SHAPE_CONFIG(EDIT::COPYPASTE_MAGNIFIER_CAPTURE_POSITION_Y, pEdit->GetOrientation(), capturePosY);
329 FloatRectangle textObjectBounds = pEditPresenter->GetTextBoundsF();
331 // textobject minimum width/height
332 if (pEdit->GetBoundsF().width < textObjectBounds.width)
334 textObjectBounds.width = pEdit->GetBoundsF().width - pEdit->GetHorizontalMarginF(EDIT_TEXT_LEFT_MARGIN) - pEdit->GetHorizontalMarginF(EDIT_TEXT_RIGHT_MARGIN);
337 captureBounds.x = cursorBounds.x + cursorBounds.width/2.0f - captureWidth/2.0f;
338 captureBounds.y = cursorBounds.y + cursorBounds.height/2.0f - captureHeight/2.0f;
339 captureBounds.width = captureWidth;
340 captureBounds.height = captureHeight;
341 captureBounds = textObjectBounds.GetIntersection(captureBounds);
343 if ((cursorBounds.x + cursorBounds.width/2.0f) - captureBounds.x < captureWidth/2.0f)
345 adjustPosX = captureWidth/2.0f - (cursorBounds.x + cursorBounds.width/2.0f - captureBounds.x);
348 if (captureBounds.height < captureHeight && captureBounds.y < captureHeight)
350 adjustPosY = captureHeight - captureBounds.height;
353 Bitmap* pOriginalBitmp = null;
354 Canvas* pCanvas = new (std::nothrow) Canvas;
355 SysTryReturnVoidResult(NID_UI_CTRL, pCanvas, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
357 r = pCanvas->Construct(FloatRectangle(0, 0, captureBounds.width, captureBounds.height));
358 SysTryCatch(NID_UI, r == E_SUCCESS, , r, "[%s] Propagated.", GetErrorMessage(r));
360 pEditVisualElementImpl = _VisualElementImpl::GetInstance(*pEditVisualElement);
362 pEditVisualElementImpl->Capture(*pCanvas, CoordinateSystem::AlignToDevice(FloatRectangle(0, 0, captureBounds.width, captureBounds.height)), CoordinateSystem::AlignToDevice(captureBounds), true);
364 pOriginalBitmp = new (std::nothrow) Bitmap;
365 SysTryCatch(NID_UI, pOriginalBitmp != null, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
367 r = pOriginalBitmp->Construct(*pCanvas, CoordinateSystem::AlignToDevice(FloatRectangle(0, 0, captureBounds.width, captureBounds.height)));
369 r = pOriginalBitmp->SetScalingQuality(BITMAP_SCALING_QUALITY_HIGH);
370 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
372 r = pOriginalBitmp->Scale(CoordinateSystem::AlignToDevice(FloatDimension(pOriginalBitmp->GetActualWidth()*1.5f, pOriginalBitmp->GetActualHeight()*1.5f)));
373 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
375 canvas.DrawBitmap(CoordinateSystem::AlignToDevice(FloatPoint(capturePosX + adjustPosX*1.5f, capturePosY + adjustPosY*1.5f)), *pOriginalBitmp);
378 delete pOriginalBitmp;
384 delete pOriginalBitmp;
390 _EditCopyPasteMagnifier::MoveMagnifier(const FloatPoint& point, int handlerCursorPos)
392 FloatRectangle bounds = FloatRectangle(point.x - GetBoundsF().width/2.0f, point.y - GetBoundsF().height, GetBoundsF().width, GetBoundsF().height);
393 __handlerCursorPos = handlerCursorPos;
403 _EditCopyPasteMagnifier::SetRowColumnIndex(int rowIndex, int columnIndex)
405 __rowIndex = rowIndex;
406 __columnIndex = columnIndex;
410 * @class _EditCopyPasteHandler
411 * @brief This class defines the common behavior for the %_EditCopyPasteHandler.
414 class _EditCopyPasteHandler
416 , virtual public IEventListener
417 , virtual public _IUiEventListener
418 , virtual public _IUiEventPreviewer
424 * This is the default class constructor.
427 _EditCopyPasteHandler(const Point& point, int handlerCursorPos, _EditCopyPasteManager* pCopyPasteManager, bool singleHandler, bool leftHandler);
428 _EditCopyPasteHandler(const FloatPoint& point, int handlerCursorPos, _EditCopyPasteManager* pCopyPasteManager, bool singleHandler, bool leftHandler);
431 * This is the default class destructor.
434 virtual ~_EditCopyPasteHandler(void);
438 enum HandlerDirection
440 HANDLER_DIRECTION_NONE = 0,
441 HANDLER_DIRECTION_REVERSE_1,//horizontal reverse
442 HANDLER_DIRECTION_REVERSE_2,//vertical reverse
443 HANDLER_DIRECTION_REVERSE_3,//horizontal vertical reverse
446 static _EditCopyPasteHandler* CreateInstanceN(const Point& point, int handlerCursorPos, _EditCopyPasteManager* pCopyPasteManager, bool singleHandler, bool leftHandler = true);
447 static _EditCopyPasteHandler* CreateInstanceN(const FloatPoint& point, int handlerCursorPos, _EditCopyPasteManager* pCopyPasteManager, bool singleHandler, bool leftHandler = true);
448 int GetHandlerCursorPosition(void) const;
449 void SetHandlerRowColumnIndex(int rowIndex, int columnIndex);
450 void GetHandlerRowColumnIndex(int& rowIndex, int& columnIndex) const;
451 void SetHandlerCursorPosition(int handlerCursorPos);
452 void AdjustBounds(void);
453 void CheckReverseStatus(void);
454 void ChangeHandlerBitmap(void);
455 Bitmap* GetHandlerBitmap(void) const;
456 bool CreateCopyPasteMagnifier(void);
457 void DestroyCopyPasteMagnifier(void);
458 void MoveCopyPasteMagnifier(void);
459 void UpdateCopyPasteMagnifier(void);
462 virtual void OnDraw(void);
463 virtual bool OnTouchPressed(const _Control& source, const _TouchInfo& touchinfo);
464 virtual bool OnTouchMoved(const _Control& source, const _TouchInfo& touchinfo);
465 virtual bool OnTouchReleased(const _Control& source, const _TouchInfo& touchinfo);
466 virtual bool IsActivatedOnOpen(void) const;
467 virtual void OnChangeLayout(_ControlOrientation orientation);
468 virtual result OnAttachedToMainTree(void);
472 _EditCopyPasteHandler(const _EditCopyPasteHandler& value);
473 _EditCopyPasteHandler& operator =(const _EditCopyPasteHandler& value);
477 _VisualElement* __pRoot;
478 Bitmap* __pHandlerBitmap;
479 FloatPoint __touchPressedPoint;
480 FloatPoint __absoluteTouchPressedPoint;
481 _EditCopyPasteManager* __pCopyPasteManager;
484 int __handlerCursorPos;
485 bool __isTouchPressed;
486 HandlerDirection __handlerDirection;
487 bool __singleHandler;
488 _EditCopyPasteMagnifier* __pCopyPasteMagnifier;
489 bool __isTouchMoving;
492 }; // _EditCopyPasteHandler
495 _EditCopyPasteHandler::GetHandlerBitmap(void) const
497 return __pHandlerBitmap;
501 _EditCopyPasteHandler::CreateCopyPasteMagnifier(void)
503 if (!__pCopyPasteMagnifier)
505 _Edit* pEdit = __pCopyPasteManager->GetEdit();
506 SysTryReturn(NID_UI_CTRL, pEdit, false, E_INVALID_STATE, "[E_INVALID_STATE] pEdit is null.\n");
508 _EditPresenter* pEditPresenter = pEdit->GetPresenter();
509 SysTryReturn(NID_UI_CTRL, pEditPresenter, false, E_INVALID_STATE, "[E_INVALID_STATE] pEditPresenter is null.\n");
511 FloatRectangle cursorBounds(0.0f, 0.0f, 0.0f, 0.0f);
512 if (__rowIndex >= 0 && __columnIndex >= 0)
514 pEditPresenter->CalculateAbsoluteCursorBounds(__rowIndex, __columnIndex, cursorBounds);
518 pEditPresenter->CalculateAbsoluteCursorBounds(__handlerCursorPos, cursorBounds);
520 __pCopyPasteMagnifier = _EditCopyPasteMagnifier::CreateInstanceN(FloatPoint(cursorBounds.x, cursorBounds.y), __handlerCursorPos, __pCopyPasteManager);
521 SysTryReturn(NID_UI_CTRL, __pCopyPasteMagnifier, false, E_INVALID_STATE, "[E_INVALID_STATE] __pCopyPasteMagnifier is null.\n");
523 __pCopyPasteMagnifier->SetRowColumnIndex(__rowIndex, __columnIndex);
529 _EditCopyPasteHandler::DestroyCopyPasteMagnifier(void)
531 if (__pCopyPasteMagnifier)
533 __pCopyPasteMagnifier->Close();
534 delete __pCopyPasteMagnifier;
535 __pCopyPasteMagnifier = null;
540 _EditCopyPasteHandler::MoveCopyPasteMagnifier(void)
542 if (__pCopyPasteMagnifier)
544 _Edit* pEdit = __pCopyPasteManager->GetEdit();
545 SysTryReturnVoidResult(NID_UI_CTRL, pEdit, E_INVALID_STATE, "[E_INVALID_STATE] pEdit is null.");
547 _EditPresenter* pEditPresenter = pEdit->GetPresenter();
548 SysTryReturnVoidResult(NID_UI_CTRL, pEditPresenter, E_INVALID_STATE, "[E_INVALID_STATE] pEditPresenter is null.");
550 FloatRectangle cursorBounds(0.0f, 0.0f, 0.0f, 0.0f);
551 if (__rowIndex >= 0 && __columnIndex >= 0)
553 pEditPresenter->CalculateAbsoluteCursorBounds(__rowIndex, __columnIndex, cursorBounds);
557 pEditPresenter->CalculateAbsoluteCursorBounds(__handlerCursorPos, cursorBounds);
559 __pCopyPasteMagnifier->SetRowColumnIndex(__rowIndex, __columnIndex);
560 __pCopyPasteMagnifier->MoveMagnifier(FloatPoint(cursorBounds.x, cursorBounds.y), __handlerCursorPos);
565 _EditCopyPasteHandler::UpdateCopyPasteMagnifier(void)
567 if (__pCopyPasteMagnifier)
569 __pCopyPasteMagnifier->Invalidate();
574 _EditCopyPasteHandler::ChangeHandlerBitmap(void)
576 if (__pHandlerBitmap)
578 delete __pHandlerBitmap;
579 __pHandlerBitmap = null;
583 if (__handlerDirection == HANDLER_DIRECTION_NONE)
585 GET_BITMAP_CONFIG_N(EDIT::COPY_PASTE_ICON_CENTER_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, __pHandlerBitmap);
589 GET_BITMAP_CONFIG_N(EDIT::COPY_PASTE_ICON_REVERSE_CENTER_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, __pHandlerBitmap);
595 switch(__handlerDirection)
597 case HANDLER_DIRECTION_REVERSE_1:
598 GET_BITMAP_CONFIG_N(EDIT::COPY_PASTE_ICON_RIGHT_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, __pHandlerBitmap);
600 case HANDLER_DIRECTION_REVERSE_2:
601 GET_BITMAP_CONFIG_N(EDIT::COPY_PASTE_ICON_REVERSE_LEFT_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, __pHandlerBitmap);
603 case HANDLER_DIRECTION_REVERSE_3:
604 GET_BITMAP_CONFIG_N(EDIT::COPY_PASTE_ICON_REVERSE_RIGHT_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, __pHandlerBitmap);
606 case HANDLER_DIRECTION_NONE:
609 GET_BITMAP_CONFIG_N(EDIT::COPY_PASTE_ICON_LEFT_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, __pHandlerBitmap);
615 switch(__handlerDirection)
617 case HANDLER_DIRECTION_REVERSE_1:
618 GET_BITMAP_CONFIG_N(EDIT::COPY_PASTE_ICON_LEFT_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, __pHandlerBitmap);
620 case HANDLER_DIRECTION_REVERSE_2:
621 GET_BITMAP_CONFIG_N(EDIT::COPY_PASTE_ICON_REVERSE_RIGHT_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, __pHandlerBitmap);
623 case HANDLER_DIRECTION_REVERSE_3:
624 GET_BITMAP_CONFIG_N(EDIT::COPY_PASTE_ICON_REVERSE_LEFT_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, __pHandlerBitmap);
626 case HANDLER_DIRECTION_NONE:
629 GET_BITMAP_CONFIG_N(EDIT::COPY_PASTE_ICON_RIGHT_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, __pHandlerBitmap);
635 _EditCopyPasteHandler::_EditCopyPasteHandler(const Point& point, int handlerCursorPos, _EditCopyPasteManager* pCopyPasteManager, bool singleHandler, bool leftHandler)
637 , __pHandlerBitmap(null)
638 , __touchPressedPoint(0.0f, 0.0f)
639 , __absoluteTouchPressedPoint(0.0f, 0.0f)
640 , __pCopyPasteManager(pCopyPasteManager)
641 , __leftHandler(leftHandler)
642 , __reverseCheck(false)
643 , __handlerCursorPos(handlerCursorPos)
644 , __isTouchPressed(false)
645 , __handlerDirection(HANDLER_DIRECTION_NONE)
646 , __singleHandler(false)
647 , __pCopyPasteMagnifier(null)
648 , __isTouchMoving(false)
654 __pRoot = GetVisualElement();
655 __pRoot->SetSurfaceOpaque(false);
657 Point handlerPoint(point);
661 GET_BITMAP_CONFIG_N(EDIT::COPY_PASTE_ICON_CENTER_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, __pHandlerBitmap);
662 handlerPoint.x = handlerPoint.x - (__pHandlerBitmap->GetWidth() / 2);
663 __singleHandler = true;
669 GET_BITMAP_CONFIG_N(EDIT::COPY_PASTE_ICON_LEFT_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, __pHandlerBitmap);
670 handlerPoint.x = handlerPoint.x - __pHandlerBitmap->GetWidth();
674 GET_BITMAP_CONFIG_N(EDIT::COPY_PASTE_ICON_RIGHT_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, __pHandlerBitmap);
678 FloatRectangle bounds(handlerPoint.x, handlerPoint.y, __pHandlerBitmap->GetWidth(), __pHandlerBitmap->GetHeight());
681 _EditCopyPasteHandler::_EditCopyPasteHandler(const FloatPoint& point, int handlerCursorPos, _EditCopyPasteManager* pCopyPasteManager, bool singleHandler, bool leftHandler)
683 , __pHandlerBitmap(null)
684 , __touchPressedPoint(0.0f, 0.0f)
685 , __absoluteTouchPressedPoint(0.0f, 0.0f)
686 , __pCopyPasteManager(pCopyPasteManager)
687 , __leftHandler(leftHandler)
688 , __reverseCheck(false)
689 , __handlerCursorPos(handlerCursorPos)
690 , __isTouchPressed(false)
691 , __handlerDirection(HANDLER_DIRECTION_NONE)
692 , __singleHandler(false)
693 , __pCopyPasteMagnifier(null)
694 , __isTouchMoving(false)
702 //Point handlerPoint(_CoordinateSystemUtils::ConvertToInteger(point));
703 FloatPoint handlerPoint(point);
706 GET_BITMAP_CONFIG_N(EDIT::COPY_PASTE_ICON_CENTER_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, __pHandlerBitmap);
707 handlerPoint.x = handlerPoint.x - (__pHandlerBitmap->GetWidthF() / 2.0f);
708 __singleHandler = true;
714 GET_BITMAP_CONFIG_N(EDIT::COPY_PASTE_ICON_LEFT_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, __pHandlerBitmap);
715 handlerPoint.x = handlerPoint.x - __pHandlerBitmap->GetWidthF();
719 GET_BITMAP_CONFIG_N(EDIT::COPY_PASTE_ICON_RIGHT_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, __pHandlerBitmap);
723 FloatRectangle bounds(handlerPoint.x, handlerPoint.y, _CoordinateSystemUtils::ConvertToFloat(__pHandlerBitmap->GetWidth()), _CoordinateSystemUtils::ConvertToFloat(__pHandlerBitmap->GetHeight()));
726 _EditCopyPasteHandler::~_EditCopyPasteHandler(void)
728 DestroyCopyPasteMagnifier();
730 if (__pHandlerBitmap)
732 delete __pHandlerBitmap;
733 __pHandlerBitmap = null;
737 _EditCopyPasteHandler*
738 _EditCopyPasteHandler::CreateInstanceN(const Point& point, int handlerCursorPos, _EditCopyPasteManager* pCopyPasteManager, bool singleHandler, bool leftHandler)
740 _EditCopyPasteHandler* pCopyPasteHandler = new (std::nothrow) _EditCopyPasteHandler(point, handlerCursorPos, pCopyPasteManager, singleHandler, leftHandler);
741 SysTryReturn(NID_UI_CTRL, pCopyPasteHandler != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
743 Point handlerPoint(point);
744 Rectangle bounds(0, 0, 0, 0);
745 Bitmap* pHandlerBitmap = pCopyPasteHandler->GetHandlerBitmap();
747 result r = pCopyPasteHandler->CreateRootVisualElement(_WINDOW_TYPE_VE);
748 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
750 pCopyPasteHandler->SetActivationEnabled(false);
754 handlerPoint.x = handlerPoint.x - (pHandlerBitmap->GetWidth() / 2);
760 handlerPoint.x = handlerPoint.x - pHandlerBitmap->GetWidth();
764 bounds.x = handlerPoint.x;
765 bounds.y = handlerPoint.y;
766 bounds.width = pHandlerBitmap->GetWidth();
767 bounds.height = pHandlerBitmap->GetHeight();
769 pCopyPasteHandler->Open(false);
770 pCopyPasteHandler->SetBounds(bounds);
771 pCopyPasteHandler->CheckReverseStatus();
772 pCopyPasteHandler->AdjustBounds();
774 return pCopyPasteHandler;
777 pCopyPasteHandler->Close();
778 delete pCopyPasteHandler;
783 _EditCopyPasteHandler*
784 _EditCopyPasteHandler::CreateInstanceN(const FloatPoint& point, int handlerCursorPos, _EditCopyPasteManager* pCopyPasteManager, bool singleHandler, bool leftHandler)
786 _EditCopyPasteHandler* pCopyPasteHandler = new (std::nothrow) _EditCopyPasteHandler(point, handlerCursorPos, pCopyPasteManager, singleHandler, leftHandler);
787 SysTryReturn(NID_UI_CTRL, pCopyPasteHandler != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
789 FloatPoint handlerPoint(point);
790 FloatRectangle bounds(0.0f, 0.0f, 0.0f, 0.0f);
791 Bitmap* pHandlerBitmap = pCopyPasteHandler->GetHandlerBitmap();
793 result r = pCopyPasteHandler->CreateRootVisualElement(_WINDOW_TYPE_VE);
794 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
796 pCopyPasteHandler->SetActivationEnabled(false);
800 handlerPoint.x = handlerPoint.x - (pHandlerBitmap->GetWidthF() / 2.0f);
806 handlerPoint.x = handlerPoint.x - pHandlerBitmap->GetWidthF();
810 bounds.x = handlerPoint.x;
811 bounds.y = handlerPoint.y;
812 bounds.width = pHandlerBitmap->GetWidthF();
813 bounds.height = pHandlerBitmap->GetHeightF();
815 pCopyPasteHandler->Open(false);
816 pCopyPasteHandler->SetBounds(bounds);
817 pCopyPasteHandler->CheckReverseStatus();
818 pCopyPasteHandler->AdjustBounds();
820 return pCopyPasteHandler;
823 pCopyPasteHandler->Close();
824 delete pCopyPasteHandler;
830 _EditCopyPasteHandler::GetHandlerCursorPosition(void) const
832 return __handlerCursorPos;
836 _EditCopyPasteHandler::SetHandlerRowColumnIndex(int rowIndex, int columnIndex)
838 __rowIndex = rowIndex;
839 __columnIndex = columnIndex;
843 _EditCopyPasteHandler::GetHandlerRowColumnIndex(int& rowIndex, int& columnIndex) const
845 rowIndex = __rowIndex;
846 columnIndex = __columnIndex;
850 _EditCopyPasteHandler::SetHandlerCursorPosition(int handlerCursorPos)
852 __handlerCursorPos = handlerCursorPos;
858 _EditCopyPasteHandler::AdjustBounds(void)
860 FloatRectangle cursorRect;
861 FloatRectangle rect = GetBoundsF();
862 FloatPoint checkPoint(0.0f, 0.0f);
863 _Edit* pEdit = __pCopyPasteManager->GetEdit();
864 _EditPresenter* pEditPresenter = pEdit->GetPresenter();
868 if (__rowIndex >= 0 && __columnIndex >= 0)
870 pEditPresenter->CalculateAbsoluteCursorBounds(__rowIndex, __columnIndex, cursorRect, false);
874 pEditPresenter->CalculateAbsoluteCursorBounds(__handlerCursorPos, cursorRect, false);
876 rect.x = cursorRect.x - __pHandlerBitmap->GetWidthF()/2.0f;
877 rect.y = cursorRect.y + cursorRect.height;
878 checkPoint = FloatPoint(cursorRect.x , cursorRect.y + cursorRect.height);
879 if (__handlerDirection == HANDLER_DIRECTION_REVERSE_2)
881 rect.y -= (cursorRect.height + __pHandlerBitmap->GetHeightF());
886 if (__rowIndex >= 0 && __columnIndex >= 0)
888 pEditPresenter->CalculateAbsoluteCursorBounds(__rowIndex, __columnIndex, cursorRect, false);
892 pEditPresenter->CalculateAbsoluteCursorBounds(__handlerCursorPos, cursorRect, false);
895 rect.x = cursorRect.x;
896 rect.y = cursorRect.y + cursorRect.height;
898 checkPoint = FloatPoint(cursorRect.x, cursorRect.y + cursorRect.height);
902 if (__handlerDirection == HANDLER_DIRECTION_NONE)
904 rect.x = rect.x - __pHandlerBitmap->GetWidthF();
906 else if (__handlerDirection == HANDLER_DIRECTION_REVERSE_2)
908 rect.x = rect.x - __pHandlerBitmap->GetWidthF();
909 rect.y -= (rect.height + cursorRect.height);
911 else if (__handlerDirection == HANDLER_DIRECTION_REVERSE_3)
913 rect.y -= (rect.height + cursorRect.height);
918 if (__handlerDirection == HANDLER_DIRECTION_REVERSE_1)
920 rect.x = rect.x - __pHandlerBitmap->GetWidthF();
922 else if (__handlerDirection == HANDLER_DIRECTION_REVERSE_2)
924 rect.y -= (rect.height + cursorRect.height);
926 else if (__handlerDirection == HANDLER_DIRECTION_REVERSE_3)
928 rect.x = rect.x - __pHandlerBitmap->GetWidthF();
929 rect.y -= (rect.height + cursorRect.height);
934 if (!__isTouchMoving)
936 bool visibleState = __pCopyPasteManager->CheckHandleBounds(checkPoint);
937 if (visibleState && !GetVisibleState())
939 SetVisibleState(true);
942 else if (!visibleState && GetVisibleState())
944 SetVisibleState(false);
949 if (__singleHandler && pEditPresenter->IsViewModeEnabled())
951 SetVisibleState(false);
959 _EditCopyPasteHandler::OnDraw(void)
961 Canvas* pCanvas = GetCanvasN();
966 pCanvas->SetBackgroundColor(Color(0, 0, 0, 0));
968 if (_BitmapImpl::CheckNinePatchedBitmapStrictly(*__pHandlerBitmap))
970 pCanvas->DrawNinePatchedBitmap(pCanvas->GetBoundsF(), *__pHandlerBitmap);
974 pCanvas->DrawBitmap(pCanvas->GetBoundsF(), *__pHandlerBitmap);
981 _EditCopyPasteHandler::OnTouchPressed(const _Control& source, const _TouchInfo& touchinfo)
983 _ContextMenu* pCopyPastePopup = __pCopyPasteManager->GetCopyPastePopup();
986 pCopyPastePopup->SetVisibleState(false);
987 pCopyPastePopup->Close();
990 #if EDIT_COPY_PASTE_MAGNIFIER
991 if (!__pCopyPasteMagnifier)
993 CreateCopyPasteMagnifier();
997 __pCopyPasteMagnifier->SetVisibleState(true);
998 __pCopyPasteMagnifier->Open();
1001 __touchPressedPoint = touchinfo.GetCurrentPosition();
1002 __absoluteTouchPressedPoint = FloatPoint(GetBoundsF().x + __touchPressedPoint.x, GetBoundsF().y + __touchPressedPoint.y);
1003 __isTouchPressed = true;
1009 _EditCopyPasteHandler::CheckReverseStatus(void)
1011 FloatDimension screenSize;
1012 _ControlManager* pControlManager = _ControlManager::GetInstance();
1013 _Edit* pEdit = __pCopyPasteManager->GetEdit();
1014 _ControlOrientation orientation = pEdit->GetOrientation();
1015 FloatRectangle rect = GetBoundsF();
1016 FloatRectangle cursorAbsBounds = __pCopyPasteManager->GetCursorBoundsF(true);
1017 float clipboardHeight = 0.0f;
1018 FloatRectangle keypadBounds(0.0f, 0.0f, 0.0f, 0.0f);
1019 float adjustHeight = 0.0f;
1021 _EditPresenter* pEditPresenter = pEdit->GetPresenter();
1022 SysTryReturnVoidResult(NID_UI_CTRL, pEditPresenter, E_INVALID_STATE, "[E_INVALID_STATE] pEditPresenter is null.\n");
1024 clipboardHeight = pEditPresenter->GetClipboardHeight();
1025 pEditPresenter->GetKeypadBoundsEx(keypadBounds);
1026 if (clipboardHeight > keypadBounds.height)
1028 adjustHeight = clipboardHeight;
1032 adjustHeight = keypadBounds.height;
1035 if (orientation == _CONTROL_ORIENTATION_PORTRAIT)
1037 screenSize = pControlManager->GetScreenSizeF();
1041 screenSize.width = pControlManager->GetScreenSizeF().height;
1042 screenSize.height = pControlManager->GetScreenSizeF().width;
1044 if (adjustHeight > 0.0f)
1046 screenSize.height -= adjustHeight;
1049 if (__singleHandler)
1051 if ((__handlerDirection == HANDLER_DIRECTION_NONE) && ((cursorAbsBounds.y + cursorAbsBounds.height + rect.height) > screenSize.height))
1053 __handlerDirection = HANDLER_DIRECTION_REVERSE_2;
1054 rect.y -= (cursorAbsBounds.height + rect.height);
1055 __reverseCheck = true;
1056 ChangeHandlerBitmap();
1059 else if ((__handlerDirection == HANDLER_DIRECTION_REVERSE_2) && ((cursorAbsBounds.y + cursorAbsBounds.height + rect.height) <= screenSize.height))
1061 __handlerDirection = HANDLER_DIRECTION_NONE;
1062 rect.y += (cursorAbsBounds.height + rect.height);
1063 __reverseCheck = true;
1064 ChangeHandlerBitmap();
1072 if (((__handlerDirection == HANDLER_DIRECTION_NONE) || (__handlerDirection == HANDLER_DIRECTION_REVERSE_2)) && rect.x < 0.0f)
1074 if ((__handlerDirection == HANDLER_DIRECTION_NONE) && ((rect.y + rect.height) > screenSize.height))
1076 __handlerDirection = HANDLER_DIRECTION_REVERSE_3;
1077 rect.y -= (rect.height + cursorAbsBounds.height);
1079 else if ((__handlerDirection == HANDLER_DIRECTION_NONE) && ((rect.y + rect.height) <= screenSize.height))
1081 __handlerDirection = HANDLER_DIRECTION_REVERSE_1;
1083 else if ((__handlerDirection == HANDLER_DIRECTION_REVERSE_2) && ((rect.y + 2*rect.height) > screenSize.height))
1085 __handlerDirection = HANDLER_DIRECTION_REVERSE_3;
1087 else if ((__handlerDirection == HANDLER_DIRECTION_REVERSE_2) && ((rect.y + 2*rect.height) <= screenSize.height))
1089 __handlerDirection = HANDLER_DIRECTION_REVERSE_1;
1090 rect.y += (rect.height + cursorAbsBounds.height);
1092 ChangeHandlerBitmap();
1093 rect.x += rect.width;
1094 __reverseCheck = true;
1096 else if (((__handlerDirection == HANDLER_DIRECTION_REVERSE_1) || (__handlerDirection == HANDLER_DIRECTION_REVERSE_3)) && rect.x >= rect.width)
1098 if ((__handlerDirection == HANDLER_DIRECTION_REVERSE_1) && ((rect.y + rect.height) > screenSize.height))
1100 __handlerDirection = HANDLER_DIRECTION_REVERSE_2;
1101 rect.y -= (rect.height + cursorAbsBounds.height);
1103 else if ((__handlerDirection == HANDLER_DIRECTION_REVERSE_1) && ((rect.y + rect.height) <= screenSize.height))
1105 __handlerDirection = HANDLER_DIRECTION_NONE;
1107 else if ((__handlerDirection == HANDLER_DIRECTION_REVERSE_3) && ((rect.y + 2*rect.height) > screenSize.height))
1109 __handlerDirection = HANDLER_DIRECTION_REVERSE_2;
1111 else if ((__handlerDirection == HANDLER_DIRECTION_REVERSE_3) && ((rect.y + 2*rect.height) <= screenSize.height))
1113 __handlerDirection = HANDLER_DIRECTION_NONE;
1114 rect.y += (rect.height + cursorAbsBounds.height);
1116 ChangeHandlerBitmap();
1117 rect.x -= rect.width;
1118 __reverseCheck = true;
1120 else if (((__handlerDirection == HANDLER_DIRECTION_NONE) || (__handlerDirection == HANDLER_DIRECTION_REVERSE_1)) && ((rect.y + rect.height) > screenSize.height))
1122 if ((__handlerDirection == HANDLER_DIRECTION_NONE) && rect.x < rect.width)
1124 __handlerDirection = HANDLER_DIRECTION_REVERSE_3;
1125 rect.x += rect.width;
1127 else if ((__handlerDirection == HANDLER_DIRECTION_NONE) && rect.x >= rect.width)
1129 __handlerDirection = HANDLER_DIRECTION_REVERSE_2;
1131 else if ((__handlerDirection == HANDLER_DIRECTION_REVERSE_1) && ((rect.x - rect.width) >= 0.0f))
1133 __handlerDirection = HANDLER_DIRECTION_REVERSE_2;
1134 rect.x -= rect.width;
1136 else if ((__handlerDirection == HANDLER_DIRECTION_REVERSE_1) && ((rect.x - rect.width) < 0.0f))
1138 __handlerDirection = HANDLER_DIRECTION_REVERSE_3;
1140 rect.y -= (rect.height + cursorAbsBounds.height);
1141 ChangeHandlerBitmap();
1142 __reverseCheck = true;
1144 else if (((__handlerDirection == HANDLER_DIRECTION_REVERSE_2) || (__handlerDirection == HANDLER_DIRECTION_REVERSE_3)) && ((rect.y + 2*rect.height + cursorAbsBounds.height) <= screenSize.height))
1146 if ((__handlerDirection == HANDLER_DIRECTION_REVERSE_2) && rect.x < 0.0f)
1148 __handlerDirection = HANDLER_DIRECTION_REVERSE_1;
1149 rect.x += rect.width;
1151 else if ((__handlerDirection == HANDLER_DIRECTION_REVERSE_2) && rect.x >= rect.width)
1153 __handlerDirection = HANDLER_DIRECTION_NONE;
1155 else if ((__handlerDirection == HANDLER_DIRECTION_REVERSE_3) && ((rect.x - rect.width) >= 0.0f))
1157 __handlerDirection = HANDLER_DIRECTION_NONE;
1158 rect.x -= rect.width;
1160 else if ((__handlerDirection == HANDLER_DIRECTION_REVERSE_3) && ((rect.x - rect.width) < 0.0f))
1162 __handlerDirection = HANDLER_DIRECTION_REVERSE_1;
1164 rect.y += (rect.height + cursorAbsBounds.height);
1165 ChangeHandlerBitmap();
1166 __reverseCheck = true;
1171 if (((__handlerDirection == HANDLER_DIRECTION_NONE) || (__handlerDirection == HANDLER_DIRECTION_REVERSE_2)) && (rect.x + rect.width) > screenSize.width)
1173 if ((__handlerDirection == HANDLER_DIRECTION_NONE) && ((rect.y + rect.height) > screenSize.height))
1175 __handlerDirection = HANDLER_DIRECTION_REVERSE_3;
1176 rect.y -= (rect.height + cursorAbsBounds.height);
1178 else if ((__handlerDirection == HANDLER_DIRECTION_NONE) && ((rect.y + rect.height) <= screenSize.height))
1180 __handlerDirection = HANDLER_DIRECTION_REVERSE_1;
1182 else if ((__handlerDirection == HANDLER_DIRECTION_REVERSE_2) && ((rect.y + 2*rect.height) > screenSize.height))
1184 __handlerDirection = HANDLER_DIRECTION_REVERSE_3;
1186 else if ((__handlerDirection == HANDLER_DIRECTION_REVERSE_2) && ((rect.y + 2*rect.height) <= screenSize.height))
1188 __handlerDirection = HANDLER_DIRECTION_REVERSE_1;
1189 rect.y += (rect.height + cursorAbsBounds.height);
1191 ChangeHandlerBitmap();
1192 rect.x -= rect.width;
1193 __reverseCheck = true;
1195 else if (((__handlerDirection == HANDLER_DIRECTION_REVERSE_1) || (__handlerDirection == HANDLER_DIRECTION_REVERSE_3)) && (rect.x + 2*rect.width) <= screenSize.width)
1197 if ((__handlerDirection == HANDLER_DIRECTION_REVERSE_1) && ((rect.y + rect.height) > screenSize.height))
1199 __handlerDirection = HANDLER_DIRECTION_REVERSE_2;
1200 rect.y -= (rect.height + cursorAbsBounds.height);
1202 else if ((__handlerDirection == HANDLER_DIRECTION_REVERSE_1) && ((rect.y + rect.height) <= screenSize.height))
1204 __handlerDirection = HANDLER_DIRECTION_NONE;
1206 else if ((__handlerDirection == HANDLER_DIRECTION_REVERSE_3) && ((rect.y + 2*rect.height) > screenSize.height))
1208 __handlerDirection = HANDLER_DIRECTION_REVERSE_2;
1210 else if ((__handlerDirection == HANDLER_DIRECTION_REVERSE_3) && ((rect.y + 2*rect.height) <= screenSize.height))
1212 __handlerDirection = HANDLER_DIRECTION_NONE;
1213 rect.y += (rect.height + cursorAbsBounds.height);
1215 ChangeHandlerBitmap();
1216 rect.x += rect.width;
1217 __reverseCheck = true;
1219 else if (((__handlerDirection == HANDLER_DIRECTION_NONE) || (__handlerDirection == HANDLER_DIRECTION_REVERSE_1)) && ((rect.y + rect.height) > screenSize.height))
1221 if ((__handlerDirection == HANDLER_DIRECTION_NONE) && (rect.x + rect.width) > screenSize.width)
1223 __handlerDirection = HANDLER_DIRECTION_REVERSE_3;
1224 rect.x -= rect.width;
1226 else if ((__handlerDirection == HANDLER_DIRECTION_NONE) && (rect.x + rect.width) <= screenSize.width)
1228 __handlerDirection = HANDLER_DIRECTION_REVERSE_2;
1230 else if ((__handlerDirection == HANDLER_DIRECTION_REVERSE_1) && (rect.x + 2*rect.width) <= screenSize.width)
1232 __handlerDirection = HANDLER_DIRECTION_REVERSE_2;
1233 rect.x += rect.width;
1235 else if ((__handlerDirection == HANDLER_DIRECTION_REVERSE_1) && (rect.x + 2*rect.width) > screenSize.width)
1237 __handlerDirection = HANDLER_DIRECTION_REVERSE_3;
1239 rect.y -= (rect.height + cursorAbsBounds.height);
1240 ChangeHandlerBitmap();
1241 __reverseCheck = true;
1243 else if (((__handlerDirection == HANDLER_DIRECTION_REVERSE_2) || (__handlerDirection == HANDLER_DIRECTION_REVERSE_3)) && ((rect.y + 2*rect.height + cursorAbsBounds.height) <= screenSize.height))
1245 if ((__handlerDirection == HANDLER_DIRECTION_REVERSE_2) && ((rect.x + rect.width) <= screenSize.width))
1247 __handlerDirection = HANDLER_DIRECTION_NONE;
1249 else if ((__handlerDirection == HANDLER_DIRECTION_REVERSE_2) && ((rect.x + rect.width) > screenSize.width))
1251 __handlerDirection = HANDLER_DIRECTION_REVERSE_1;
1252 rect.x -= rect.width;
1254 else if ((__handlerDirection == HANDLER_DIRECTION_REVERSE_3) && ((rect.x + 2*rect.width) <= screenSize.width))
1256 __handlerDirection = HANDLER_DIRECTION_NONE;
1257 rect.x += rect.width;
1259 else if ((__handlerDirection == HANDLER_DIRECTION_REVERSE_3) && ((rect.x + 2*rect.width) > screenSize.width))
1261 __handlerDirection = HANDLER_DIRECTION_REVERSE_1;
1263 rect.y += (rect.height + cursorAbsBounds.height);
1264 ChangeHandlerBitmap();
1265 __reverseCheck = true;
1273 _EditCopyPasteHandler::OnTouchReleased(const _Control& source, const _TouchInfo& touchinfo)
1275 CheckReverseStatus();
1276 __isTouchPressed = false;
1277 __absoluteTouchPressedPoint = FloatPoint(0.0f, 0.0f);
1278 if (__pCopyPasteMagnifier)
1280 __pCopyPasteMagnifier->SetVisibleState(false);
1281 __pCopyPasteMagnifier->Close();
1283 _ContextMenu* pCopyPastePopup = __pCopyPasteManager->GetCopyPastePopup();
1284 if (pCopyPastePopup && !__isTouchMoving)
1286 pCopyPastePopup->SetVisibleState(true);
1287 pCopyPastePopup->Open();
1291 __pCopyPasteManager->CreateCopyPastePopup();
1293 __pCopyPasteManager->Show();
1294 __pCopyPasteManager->SendTextBlockEvent();
1296 __isTouchMoving = false;
1298 if (!__singleHandler)
1300 int leftRowIndex = -1;
1301 int leftColumnIndex = -1;
1302 int rightRowIndex = -1;
1303 int rightColumnIndex = -1;
1304 int leftHandlerCursorPos = -1;
1305 int rightHandlerCursorPos = -1;
1307 __pCopyPasteManager->GetHandlerRowColumnIndex(false, true, leftRowIndex, leftColumnIndex);
1308 __pCopyPasteManager->GetHandlerRowColumnIndex(false, false, rightRowIndex, rightColumnIndex);
1309 leftHandlerCursorPos = __pCopyPasteManager->GetHandlerCursorPosition(_EditCopyPasteManager::HANDLER_TYPE_LEFT);
1310 rightHandlerCursorPos = __pCopyPasteManager->GetHandlerCursorPosition(_EditCopyPasteManager::HANDLER_TYPE_RIGHT);
1312 _ContextMenu* pCopyPastePopup = __pCopyPasteManager->GetCopyPastePopup();
1314 if(__leftHandler && __handlerCursorPos > rightHandlerCursorPos)
1316 __pCopyPasteManager->CreateHandle(rightHandlerCursorPos, leftHandlerCursorPos, rightRowIndex, rightColumnIndex, leftRowIndex, leftColumnIndex);
1318 if (pCopyPastePopup)
1320 pCopyPastePopup->ReleaseTouchCapture();
1323 else if (!__leftHandler && __handlerCursorPos < leftHandlerCursorPos)
1325 __pCopyPasteManager->CreateHandle(rightHandlerCursorPos, leftHandlerCursorPos, rightRowIndex, rightColumnIndex, leftRowIndex, leftColumnIndex);
1326 if (pCopyPastePopup)
1328 pCopyPastePopup->ReleaseTouchCapture();
1336 _EditCopyPasteHandler::OnTouchMoved(const _Control& source, const _TouchInfo& touchinfo)
1339 FloatRectangle cursorRect(0.0f, 0.0f, 0.0f, 0.0f);
1340 FloatRectangle absCursorRect(0.0f, 0.0f, 0.0f, 0.0f);
1341 FloatRectangle rect = GetBoundsF();
1342 FloatPoint point = touchinfo.GetCurrentPosition();
1343 FloatPoint touchPoint(0.0f, 0.0f);
1344 FloatPoint checkPoint(0.0f, 0.0f);
1345 __isTouchMoving = true;
1347 _Edit* pEdit = __pCopyPasteManager->GetEdit();
1348 SysTryReturn(NID_UI_CTRL, pEdit, false, E_INVALID_STATE, "[E_INVALID_STATE] pEdit is null.\n");
1350 _EditPresenter* pEditPresenter = pEdit->GetPresenter();
1351 SysTryReturn(NID_UI_CTRL, pEditPresenter, false, E_INVALID_STATE, "[E_INVALID_STATE] pEditPresenter is null.\n");
1353 TextObject* pTextObject = pEditPresenter->GetTextObject();
1354 SysTryReturn(NID_UI_CTRL, pTextObject, false, E_INVALID_STATE, "[E_INVALID_STATE] pEditPresenter is null.\n");
1356 int curCursorLine = pTextObject->GetLineIndexAtTextIndex(__handlerCursorPos);
1357 int totalLine = pTextObject->GetTotalLineCount();
1359 float totalHeight = pTextObject->GetTotalHeightF();
1360 float firstDisplayY = pTextObject->GetFirstDisplayPositionYF();
1361 FloatRectangle absTextObjectBounds(0.0f, 0.0f, 0.0f, 0.0f);
1362 FloatRectangle textObjectBounds = pEditPresenter->GetTextBoundsF();
1363 FloatRectangle absEditBounds = pEdit->GetAbsoluteBoundsF(true);
1364 absTextObjectBounds.x = absEditBounds.x + textObjectBounds.x;
1365 absTextObjectBounds.y = absEditBounds.y + textObjectBounds.y;
1366 absTextObjectBounds.width = textObjectBounds.width;
1367 absTextObjectBounds.height = textObjectBounds.height;
1368 if (__touchPressedPoint.x == point.x && __touchPressedPoint.y == point.y)
1373 if (__rowIndex >= 0 && __columnIndex >= 0)
1375 pEditPresenter->CalculateCursorBounds(pEditPresenter->GetTextBoundsF(), cursorRect, __rowIndex, __columnIndex);
1376 pEditPresenter->CalculateAbsoluteCursorBounds(__rowIndex, __columnIndex, absCursorRect);
1380 pEditPresenter->CalculateCursorBounds(pEditPresenter->GetTextBoundsF(), cursorRect,__handlerCursorPos);
1381 pEditPresenter->CalculateAbsoluteCursorBounds(__handlerCursorPos, absCursorRect);
1384 FloatPoint absoluteTouchMovedPoint = FloatPoint(GetBoundsF().x + point.x, GetBoundsF().y + point.y);
1385 //Calculate handler's position
1386 if (__singleHandler)
1388 touchPoint.x = absoluteTouchMovedPoint.x;
1389 if (__handlerDirection == HANDLER_DIRECTION_NONE)
1391 touchPoint.y = absoluteTouchMovedPoint.y - GetBoundsF().height/2.0f;
1393 else // HANDLER_DIRECTION_REVERSE_2
1395 touchPoint.y = absoluteTouchMovedPoint.y + GetBoundsF().height/2.0f;
1402 if (__handlerDirection == HANDLER_DIRECTION_NONE)
1404 touchPoint.x = absoluteTouchMovedPoint.x + GetBoundsF().width/2.0f;
1405 touchPoint.y = absoluteTouchMovedPoint.y - GetBoundsF().height/2.0f;
1407 else if (__handlerDirection == HANDLER_DIRECTION_REVERSE_1)
1409 touchPoint.x = absoluteTouchMovedPoint.x - GetBoundsF().width/2.0f;
1410 touchPoint.y = absoluteTouchMovedPoint.y - GetBoundsF().height/2.0f;
1412 else if (__handlerDirection == HANDLER_DIRECTION_REVERSE_2)
1414 touchPoint.x = absoluteTouchMovedPoint.x + GetBoundsF().width/2.0f;
1415 touchPoint.y = absoluteTouchMovedPoint.y + GetBoundsF().height/2.0f;
1417 else if (__handlerDirection == HANDLER_DIRECTION_REVERSE_3)
1419 touchPoint.x = absoluteTouchMovedPoint.x - GetBoundsF().width/2.0f;
1420 touchPoint.y = absoluteTouchMovedPoint.y + GetBoundsF().height/2.0f;
1425 if (__handlerDirection == HANDLER_DIRECTION_NONE)
1427 touchPoint.x = absoluteTouchMovedPoint.x - GetBoundsF().width/2.0f;
1428 touchPoint.y = absoluteTouchMovedPoint.y - GetBoundsF().height/2.0f;
1430 else if (__handlerDirection == HANDLER_DIRECTION_REVERSE_1)
1432 touchPoint.x = absoluteTouchMovedPoint.x + GetBoundsF().width/2.0f;
1433 touchPoint.y = absoluteTouchMovedPoint.y - GetBoundsF().height/2.0f;
1435 else if (__handlerDirection == HANDLER_DIRECTION_REVERSE_2)
1437 touchPoint.x = absoluteTouchMovedPoint.x - GetBoundsF().width/2.0f;
1438 touchPoint.y = absoluteTouchMovedPoint.y + GetBoundsF().height/2.0f;
1440 else if (__handlerDirection == HANDLER_DIRECTION_REVERSE_3)
1442 touchPoint.x = absoluteTouchMovedPoint.x + GetBoundsF().width/2.0f;
1443 touchPoint.y = absoluteTouchMovedPoint.y + GetBoundsF().height/2.0f;
1447 if (totalHeight - firstDisplayY < absTextObjectBounds.height)
1449 absTextObjectBounds.height = totalHeight - firstDisplayY - 1.0f; // check TextObject
1452 if (totalLine != 1) //single line edit doesn't need to adjust horizontal value.
1454 if (absTextObjectBounds.x > touchPoint.x)
1456 touchPoint.x = absTextObjectBounds.x;
1458 if (absTextObjectBounds.x + absTextObjectBounds.width <= touchPoint.x) // check FloatRectangle Contains?
1460 touchPoint.x = absTextObjectBounds.x + absTextObjectBounds.width - 1.0f;
1463 if (absTextObjectBounds.y > touchPoint.y)
1465 if (totalLine == 1 || firstDisplayY == 0.0f) // whether need to scroll the text or not
1467 touchPoint.y = absTextObjectBounds.y; //not need to scroll the text.
1470 if (absTextObjectBounds.y + absTextObjectBounds.height < touchPoint.y)
1472 if (totalLine == 1 || (totalHeight - firstDisplayY < textObjectBounds.height) || curCursorLine == (totalLine - 1)) // || pTextObject->IsDisplayedLastLine()) // whether need to scroll the text or not
1474 touchPoint.y = absTextObjectBounds.y + absTextObjectBounds.height - 1.0f; // check TextObject
1478 touchPoint.x = touchPoint.x - absEditBounds.x - textObjectBounds.x;
1479 touchPoint.y = touchPoint.y - absEditBounds.y - textObjectBounds.y;
1481 if (Math::Abs(touchPoint.y) < 1)
1483 touchPoint.y = 0.0f;
1487 int columnIndex = -1;
1488 cursorPos = pTextObject->GetTextIndexFromPosition(touchPoint.x, touchPoint.y, rowIndex, columnIndex, true);
1490 if (__handlerCursorPos == cursorPos)
1495 if (cursorPos == -1)
1500 if (absoluteTouchMovedPoint.y > (absCursorRect.y + absCursorRect.height))
1502 if (curCursorLine < totalLine - 1)
1504 int offset = __handlerCursorPos - pTextObject->GetFirstTextIndexAt(curCursorLine);
1505 int firstTextIndex = pTextObject->GetFirstTextIndexAt(curCursorLine+1);
1506 cursorPos = offset + firstTextIndex;
1507 int textLength = pTextObject->GetTextLengthAt(curCursorLine+1);
1508 if (offset > textLength)
1510 cursorPos = firstTextIndex+textLength;
1516 if (curCursorLine !=0)
1518 if (__rowIndex == 0)
1522 int offset = __handlerCursorPos - pTextObject->GetFirstTextIndexAt(curCursorLine);
1523 int firstTextIndex = pTextObject->GetFirstTextIndexAt(curCursorLine-1);
1524 cursorPos = offset + firstTextIndex;
1525 int textLength = pTextObject->GetTextLengthAt(curCursorLine-1);
1526 if (offset > textLength)
1528 cursorPos = firstTextIndex+textLength;
1533 if (cursorPos == -1)
1539 if (__handlerCursorPos == cursorPos)
1544 if (!__singleHandler)
1546 _EditCopyPasteManager::HandlerType nextHandlerType = _EditCopyPasteManager::HANDLER_TYPE_MAX;
1549 nextHandlerType = _EditCopyPasteManager::HANDLER_TYPE_RIGHT;
1553 nextHandlerType = _EditCopyPasteManager::HANDLER_TYPE_LEFT;
1555 int nextHandler = __pCopyPasteManager->GetHandlerCursorPosition(nextHandlerType);
1556 if (totalLine == 1 && (nextHandler == 0 || nextHandler == pEditPresenter->GetTextLength()))
1558 if (Math::Abs(nextHandler - cursorPos) == 1)
1560 pTextObject->SetFirstDisplayLineIndexFromTextIndex(nextHandler);
1563 if (nextHandler == cursorPos)
1569 if (rowIndex > -1 && columnIndex > -1)
1571 __rowIndex = rowIndex;
1572 __columnIndex = columnIndex;
1580 pTextObject->SetFirstDisplayLineIndexFromTextIndex(cursorPos);
1582 __handlerCursorPos = cursorPos;
1584 if (__rowIndex >= 0 && __columnIndex >= 0)
1586 pEditPresenter->SetCursorPosition(cursorPos, __rowIndex, __columnIndex);
1590 __pCopyPasteManager->SetCursorPosition(cursorPos);
1593 pEditPresenter->ScrollPanelToCursorPosition(true);
1595 if (!__singleHandler)
1597 __pCopyPasteManager->RefreshBlock(__leftHandler);
1601 pEditPresenter->DrawText();
1604 CheckReverseStatus();
1606 MoveCopyPasteMagnifier();
1612 _EditCopyPasteHandler::IsActivatedOnOpen(void) const
1618 _EditCopyPasteHandler::OnChangeLayout(_ControlOrientation orientation)
1625 _EditCopyPasteHandler::OnAttachedToMainTree(void)
1627 result r = E_SUCCESS;
1629 if (GetOwner() == null)
1631 _Edit* pEdit = __pCopyPasteManager->GetEdit();
1632 SysTryReturnResult(NID_UI_CTRL, pEdit, GetLastResult(), "Unable to get pEdit.");
1634 _Window* pWindow = null;
1635 _Control* pControlCore = null;
1637 for (pControlCore = pEdit->GetParent(); pWindow == null; pControlCore = pControlCore->GetParent())
1639 if (pControlCore == null)
1644 pWindow = dynamic_cast<_Window*>(pControlCore);
1652 _EditPresenter* pEditPresenter = pEdit->GetPresenter();
1653 SysTryReturnResult(NID_UI_CTRL, pEdit, GetLastResult(), "Unable to get pEditPresenter.");
1655 _Form* pParentForm = pEditPresenter->GetParentForm();
1658 SetOwner(pParentForm);
1662 _Form* pForm = null;
1663 _Frame* pCurrentFrame = dynamic_cast <_Frame*>(_ControlManager::GetInstance()->GetCurrentFrame());
1666 pForm = pCurrentFrame->GetCurrentForm();
1673 SetOwner(pCurrentFrame);
1682 _EditCopyPasteManager::_EditCopyPasteManager(_Edit& parenEdit)
1683 : __pCopyPastePopup(null)
1684 , __contextMenuAlign(CONTEXT_MENU_CORE_ALIGN_UP)
1685 , __pCoreCopyPasteEvent(null)
1686 , __pEdit(&parenEdit)
1687 , __pEditPresenter(null)
1688 , __contextMenuHeight(0.0f)
1689 , __needToReleaseBlock(true)
1690 , __isHandlerMoving(false)
1691 , __editVisibleArea(0.0f, 0.0f, 0.0f, 0.0f)
1693 __pEditPresenter = __pEdit->GetPresenter();
1694 __pHandle[HANDLER_TYPE_CENTER] = null;
1695 __pHandle[HANDLER_TYPE_LEFT] = null;
1696 __pHandle[HANDLER_TYPE_RIGHT] = null;
1701 _EditCopyPasteManager::~_EditCopyPasteManager(void)
1703 ReleaseCopyPastePopup();
1706 if (__pCoreCopyPasteEvent)
1708 delete __pCoreCopyPasteEvent;
1709 __pCoreCopyPasteEvent = null;
1714 _EditCopyPasteManager::ReleaseHandle(void)
1716 if (__pHandle[HANDLER_TYPE_CENTER])
1718 __pHandle[HANDLER_TYPE_CENTER]->Close();
1719 delete __pHandle[HANDLER_TYPE_CENTER];
1720 __pHandle[HANDLER_TYPE_CENTER] = null;
1723 if (__pHandle[HANDLER_TYPE_LEFT])
1725 __pHandle[HANDLER_TYPE_LEFT]->Close();
1726 delete __pHandle[HANDLER_TYPE_LEFT];
1727 __pHandle[HANDLER_TYPE_LEFT] = null;
1730 if (__pHandle[HANDLER_TYPE_RIGHT])
1732 __pHandle[HANDLER_TYPE_RIGHT]->Close();
1733 delete __pHandle[HANDLER_TYPE_RIGHT];
1734 __pHandle[HANDLER_TYPE_RIGHT] = null;
1739 _EditCopyPasteManager::ReleaseCopyPastePopup(void)
1741 if (__pCopyPastePopup)
1743 __pCopyPastePopup->Close();
1744 delete __pCopyPastePopup;
1745 __pCopyPastePopup = null;
1750 _EditCopyPasteManager::IsCopyPastePopup(const _Control& control) const
1752 if (__pCopyPastePopup == &control)
1761 _EditCopyPasteManager::IsCopyPasteHandle(const _Control& control) const
1763 if (__pHandle[HANDLER_TYPE_CENTER] == &control)
1768 if (__pHandle[HANDLER_TYPE_LEFT] == &control)
1773 if (__pHandle[HANDLER_TYPE_RIGHT] == &control)
1782 _EditCopyPasteManager::AddCopyPasteEventListener(const _IEditCopyPasteEventListener& listener)
1786 if (__pCoreCopyPasteEvent == null)
1788 __pCoreCopyPasteEvent = _EditCopyPasteEvent::CreateInstanceN(*this);
1789 SysTryReturn(NID_UI_CTRL, __pCoreCopyPasteEvent, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] System error occurred.\n");
1792 return __pCoreCopyPasteEvent->AddListener(listener);
1796 _EditCopyPasteManager::SendCopyPasteEvent(CoreCopyPasteStatus status, CoreCopyPasteAction action)
1798 if (__pCoreCopyPasteEvent)
1800 IEventArg* pCopyPasteEventArg = _EditCopyPasteEvent::CreateCopyPasteEventArgN(status, action);
1801 SysTryReturn(NID_UI_CTRL, pCopyPasteEventArg, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
1803 __pCoreCopyPasteEvent->Fire(*pCopyPasteEventArg);
1810 _EditCopyPasteManager::CreateCopyPastePopup(void)
1812 if (__pHandle[HANDLER_TYPE_CENTER])
1814 __pHandle[HANDLER_TYPE_CENTER]->DestroyCopyPasteMagnifier();
1816 if (__pCopyPastePopup)
1818 __pCopyPastePopup->Close();
1819 delete __pCopyPastePopup;
1820 __pCopyPastePopup = null;
1823 FloatRectangle startRect;
1824 FloatRectangle endRect;
1825 FloatRectangle editAbsRect;
1826 FloatRectangle editShowAreaAbsRect;
1827 FloatRectangle commandButtonBounds;
1828 FloatRectangle keypadBounds(0.0f, 0.0f, 0.0f, 0.0f);
1829 FloatRectangle formClientBounds(0.0f, 0.0f, 0.0f, 0.0f);
1830 FloatRectangle panelAbsoulteBounds(0.0f, 0.0f, 0.0f, 0.0f);
1831 bool commandButtonExist = false;
1832 bool formExist = false;
1833 bool panelExist = false;
1834 FloatRectangle cursorRect = GetCursorBoundsF(true);
1836 float contextMenuHeight = 0.0f;
1837 float contextMenuTopMargin = 0.0f;
1838 float contextMenuBottomMargin = 0.0f;
1839 float contextMenuArrowHeight = 0.0f;
1840 float handlerHeight = 0.0f;
1841 bool isPasswordStyle = false;
1842 bool isClipped = false;
1843 if (__pEdit->GetEditStyle() & EDIT_STYLE_PASSWORD)
1845 isPasswordStyle = true;
1848 _ControlOrientation orientation = __pEdit->GetOrientation();
1850 FloatDimension screenSize;
1851 _ControlManager* pControlManager = _ControlManager::GetInstance();
1852 if (orientation == _CONTROL_ORIENTATION_PORTRAIT)
1854 screenSize = pControlManager->GetScreenSizeF();
1858 screenSize.width = pControlManager->GetScreenSizeF().height;
1859 screenSize.height = pControlManager->GetScreenSizeF().width;
1862 GET_SHAPE_CONFIG(EDIT::COPYPASTE_HANDLER_HEIGHT, orientation, handlerHeight);
1863 GET_SHAPE_CONFIG(CONTEXTMENU::GRID_ITEM_HEIGHT, orientation, contextMenuHeight);
1864 GET_SHAPE_CONFIG(CONTEXTMENU::GRID_TOP_MARGIN, orientation, contextMenuTopMargin);
1865 GET_SHAPE_CONFIG(CONTEXTMENU::GRID_BOTTOM_MARGIN, orientation, contextMenuBottomMargin);
1866 GET_SHAPE_CONFIG(CONTEXTMENU::ANCHOR_HEIGHT, orientation, contextMenuArrowHeight);
1868 isClipped = __pEdit->IsClipped();
1869 if ((__pEdit->GetTextLength() == 0 || __pEdit->GetEditStyle() & EDIT_STYLE_PASSWORD) && !isClipped)
1874 if (__pEdit->GetTextLength() == 0 && (__pEditPresenter->IsViewModeEnabled()))
1879 __contextMenuHeight = contextMenuHeight + contextMenuTopMargin + contextMenuBottomMargin + contextMenuArrowHeight;
1880 if (isClipped && __pEditPresenter->IsViewModeEnabled() == false && __pEdit->GetTextLength() > 0 && orientation == _CONTROL_ORIENTATION_PORTRAIT)
1882 __contextMenuHeight = __contextMenuHeight + contextMenuHeight;
1885 editAbsRect = __pEdit->GetAbsoluteBoundsF(true);
1887 _Toolbar* pCommandButton = __pEditPresenter->GetKeypadCommandButton();
1890 commandButtonBounds = pCommandButton->GetAbsoluteBoundsF(true);
1891 commandButtonExist = true;
1893 _Form* pForm = __pEditPresenter->GetParentForm();
1896 formClientBounds = pForm->GetClientBoundsF();
1899 _ScrollPanel* pPanel = __pEditPresenter->GetParentPanel();
1902 panelAbsoulteBounds = pPanel->GetAbsoluteBoundsF(true);
1905 __pEdit->GetKeypadBounds(keypadBounds);
1909 editShowAreaAbsRect = editAbsRect;
1910 FloatRectangle textObjectBounds = __pEditPresenter->GetTextBoundsF();
1912 if (!(__pEdit->GetEditStyle() & EDIT_STYLE_TOKEN))
1914 editShowAreaAbsRect.x += textObjectBounds.x;
1915 editShowAreaAbsRect.y += textObjectBounds.y;
1916 editShowAreaAbsRect.width = textObjectBounds.width;
1918 if (!(__pEdit->GetEditStyle() & EDIT_STYLE_SINGLE_LINE))
1920 editShowAreaAbsRect.height = textObjectBounds.height;
1923 if (editShowAreaAbsRect.y < 0.0f)
1925 editShowAreaAbsRect.height += editShowAreaAbsRect.y;
1926 editShowAreaAbsRect.y = 0.0f;
1929 if (commandButtonExist)
1931 if (editShowAreaAbsRect.y + editShowAreaAbsRect.height > commandButtonBounds.y)
1933 editShowAreaAbsRect.height -= (editShowAreaAbsRect.y + editShowAreaAbsRect.height - commandButtonBounds.y);
1938 if (editShowAreaAbsRect.y + editShowAreaAbsRect.height > keypadBounds.y)
1940 editShowAreaAbsRect.height -= (editShowAreaAbsRect.y + editShowAreaAbsRect.height - keypadBounds.y);
1945 if (editShowAreaAbsRect.y < formClientBounds.y)
1947 editShowAreaAbsRect.y = formClientBounds.y;
1948 editShowAreaAbsRect.height -= formClientBounds.y;
1953 if (editShowAreaAbsRect.y < panelAbsoulteBounds.y)
1955 editShowAreaAbsRect.height -= (panelAbsoulteBounds.y - editShowAreaAbsRect.y);
1956 editShowAreaAbsRect.y = panelAbsoulteBounds.y;
1959 __editVisibleArea = CoordinateSystem::AlignToDevice(editShowAreaAbsRect);
1961 FloatPoint copyPastePoint(0.0f, 0.0f);
1962 __contextMenuAlign = CONTEXT_MENU_CORE_ALIGN_UP;
1964 if (__pEdit->IsBlocked())
1968 __pEdit->GetBlockRange(start, end);
1969 if (start == -1 || end == -1)
1971 SysLog(NID_UI_CTRL, "[EditCopyPasteManager] There is no blocked Range");
1975 __pEdit->CalculateAbsoluteCursorBounds(start, startRect);
1976 __pEdit->CalculateAbsoluteCursorBounds(end, endRect);
1977 if (startRect.x > endRect.x)
1979 copyPastePoint.x = endRect.x + (startRect.x - endRect.x)/2;
1981 else if (startRect.x < endRect.x)
1983 copyPastePoint.x = startRect.x + (endRect.x - startRect.x)/2;
1987 copyPastePoint.x = startRect.x;
1990 if (copyPastePoint.x < editShowAreaAbsRect.x)
1992 copyPastePoint.x = editShowAreaAbsRect.x;
1994 else if (copyPastePoint.x > (editShowAreaAbsRect.x + editShowAreaAbsRect.width))
1996 copyPastePoint.x = editShowAreaAbsRect.x + editShowAreaAbsRect.width;
1999 //Both of handlers are located on the top of the Editor.
2000 if ( ((startRect.y + startRect.height) < editShowAreaAbsRect.y) && ((endRect.y + endRect.height) < editShowAreaAbsRect.y))
2002 SysLog(NID_UI_CTRL, "Both of handlers are located on the top of the Editor.\n");
2005 //Both of handlers are located on the bottom of the Editor.
2006 else if( ((startRect.y + startRect.height) > editShowAreaAbsRect.y + editShowAreaAbsRect.height ) && ((endRect.y + endRect.height) > editShowAreaAbsRect.y + editShowAreaAbsRect.height))
2008 SysLog(NID_UI_CTRL, "Both of handlers are located on the bottom of the Editor.\n");
2011 // Left handler is located on the top of the Editor and Right handler is located on the bottom of the Editor.
2012 else if ( ((startRect.y + startRect.height) < editShowAreaAbsRect.y) && ((endRect.y + endRect.height) > (editShowAreaAbsRect.y + editShowAreaAbsRect.height)))
2014 copyPastePoint.y = editShowAreaAbsRect.y + editShowAreaAbsRect.height/2;
2016 if (copyPastePoint.y < __contextMenuHeight)
2018 __contextMenuAlign = CONTEXT_MENU_CORE_ALIGN_DOWN;
2022 // Left handler is located on the top of the Editor and Right handler is located on the Editor
2023 else if ( ((startRect.y + startRect.height) < editShowAreaAbsRect.y) && ((endRect.y + endRect.height) <= (editShowAreaAbsRect.y + editShowAreaAbsRect.height)) )
2025 if ( (endRect.y + endRect.height + handlerHeight + __contextMenuHeight) < keypadBounds.y)
2027 __contextMenuAlign = CONTEXT_MENU_CORE_ALIGN_DOWN;
2028 copyPastePoint.y = endRect.y + endRect.height + handlerHeight;
2030 else if (endRect.y - editShowAreaAbsRect.y > __contextMenuHeight)
2032 copyPastePoint.y = editShowAreaAbsRect.y + __contextMenuHeight;
2034 else if (endRect.y > __contextMenuHeight)
2036 copyPastePoint.y = endRect.y;
2040 SysLog(NID_UI_CTRL, "There is no space to draw the copy&paste popup\n");
2044 // Left handler is located on the Editor and Right handler is located on the bottom of the Editor
2045 else if ( ((startRect.y + startRect.height) >= editShowAreaAbsRect.y) && ((endRect.y + endRect.height) > (editShowAreaAbsRect.y + editShowAreaAbsRect.height)) )
2047 if (__contextMenuHeight < startRect.y)
2049 copyPastePoint.y = startRect.y;
2053 copyPastePoint.y = startRect.y + (editShowAreaAbsRect.y + editShowAreaAbsRect.height - startRect.y)/2;
2056 // There is a space on the top of the Editor.
2057 else if (__contextMenuHeight < startRect.y)
2059 copyPastePoint.y = startRect.y;
2061 // There is a space on the bottom of the Editor.
2062 else if ( screenSize.height > (endRect.y + endRect.height + handlerHeight + __contextMenuHeight))
2064 __contextMenuAlign = CONTEXT_MENU_CORE_ALIGN_DOWN;
2066 copyPastePoint.y = endRect.y + endRect.height + handlerHeight;
2068 // There is no space on the top and bottom of the Editor. The Popup should be drawn on the center of the Editor.
2071 if (endRect.y - startRect.y < __contextMenuHeight)
2073 SysLog(NID_UI_CTRL, "There is no space to draw the copy&paste popup\n");
2076 copyPastePoint.y = startRect.y + __contextMenuHeight;
2082 if (editShowAreaAbsRect.height <= 0)
2086 FloatRectangle cursorRect;
2087 bool reverseHandler = false;
2088 int cursorPosition = GetCursorPosition();
2089 __pEdit->CalculateAbsoluteCursorBounds(cursorPosition, cursorRect);
2090 copyPastePoint.x = cursorRect.x;
2091 copyPastePoint.y = cursorRect.y;
2093 if (!_FloatCompare(__editVisibleArea.y + __editVisibleArea.height, copyPastePoint.y) && __editVisibleArea.y + __editVisibleArea.height < copyPastePoint.y)
2098 if (!_FloatCompare(__editVisibleArea.y, copyPastePoint.y) && __editVisibleArea.y > copyPastePoint.y)
2100 if (!_FloatCompare(__editVisibleArea.y + __editVisibleArea.height, copyPastePoint.y + cursorRect.height) && (__editVisibleArea.y + __editVisibleArea.height > copyPastePoint.y + cursorRect.height))
2102 reverseHandler = true;
2110 if (copyPastePoint.y < __contextMenuHeight || reverseHandler)
2112 FloatRectangle cursorRect = GetCursorBoundsF(true);
2114 copyPastePoint.y += cursorRect.height;
2115 __contextMenuAlign = CONTEXT_MENU_CORE_ALIGN_DOWN;
2116 if (__pHandle[HANDLER_TYPE_CENTER])
2118 copyPastePoint.y += __pHandle[HANDLER_TYPE_CENTER]->GetBounds().height;
2123 //Todo: Create API ex)CreateContrexMenuFN
2124 __pCopyPastePopup = _ContextMenu::CreateContextMenuN(copyPastePoint, CONTEXT_MENU_CORE_STYLE_GRID, __contextMenuAlign);
2125 SysTryReturnVoidResult(NID_UI_CTRL, __pCopyPastePopup, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2127 if ( __pEdit->GetTextLength() != 0 && !isPasswordStyle)
2129 if (__pEdit->IsBlocked())
2134 GET_STRING_CONFIG(IDS_TPLATFORM_OPT_COPY, copyText);
2135 GET_STRING_CONFIG(IDS_TPLATFORM_OPT_CUT, cutText);
2137 __pCopyPastePopup->AddItem(copyText, COPY_PASTE_COPY_ID, null, null, null);
2138 if (!__pEditPresenter->IsViewModeEnabled())
2140 __pCopyPastePopup->AddItem(cutText, COPY_PASTE_CUT_ID, null, null, null);
2146 String selectAllText;
2148 GET_STRING_CONFIG(IDS_TPLATFORM_OPT_SELECT, selectText);
2149 GET_STRING_CONFIG(IDS_TPLATFORM_OPT_SELECT_ALL, selectAllText);
2151 __pCopyPastePopup->AddItem(selectText, COPY_PASTE_SELECT_ID, null, null, null);
2152 __pCopyPastePopup->AddItem(selectAllText, COPY_PASTE_SELECT_ALL_ID, null, null, null);
2158 if (!__pEditPresenter->IsViewModeEnabled())
2161 String clipboardText;
2163 GET_STRING_CONFIG(IDS_TPLATFORM_OPT_PASTE, pasteText);
2164 GET_STRING_CONFIG(IDS_TPLATFORM_OPT_CLIPBOARD, clipboardText);
2166 __pCopyPastePopup->AddItem(pasteText, COPY_PASTE_PASTE_ID, null, null, null);
2167 if (!isPasswordStyle && __pEdit->IsKeypadEnabled())
2169 __pCopyPastePopup->AddItem(clipboardText, COPY_PASTE_CLIPBOARD_ID, null, null, null);
2174 __pCopyPastePopup->AddActionEventListener(*this);
2177 Bitmap* pSearchNormalBitmap = null;
2178 Bitmap* pSearchPressedBitmap = null;
2181 Color searchPressedColor;
2182 result r = E_SUCCESS;
2184 if (__pEdit->IsBlocked() && !isPasswordStyle)
2186 GET_COLOR_CONFIG(CONTEXTMENU::ITEM_TEXT_NORMAL, searchColor);
2187 GET_COLOR_CONFIG(CONTEXTMENU::ITEM_TEXT_PRESSED, searchPressedColor);
2189 r = GET_REPLACED_BITMAP_CONFIG_N(EDIT::COPY_PASTE_SEARCH_ICON, BITMAP_PIXEL_FORMAT_ARGB8888, searchColor, pSearchNormalBitmap);
2190 SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), r, r,"[%s] Propagating.", GetErrorMessage(r));
2192 r = GET_REPLACED_BITMAP_CONFIG_N(EDIT::COPY_PASTE_SEARCH_ICON, BITMAP_PIXEL_FORMAT_ARGB8888, searchPressedColor, pSearchPressedBitmap);
2193 SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), r, r,"[%s] Propagating.", GetErrorMessage(r));
2195 __pCopyPastePopup->AddItem(null, COPY_PASTE_SEARCH_ID, pSearchNormalBitmap, pSearchPressedBitmap, null);
2198 if (pSearchNormalBitmap)
2200 delete pSearchNormalBitmap;
2201 pSearchNormalBitmap = null;
2203 if (pSearchPressedBitmap)
2205 delete pSearchPressedBitmap;
2206 pSearchPressedBitmap = null;
2208 __pCopyPastePopup->AddActionEventListener(*this);
2213 delete pSearchNormalBitmap;
2214 pSearchNormalBitmap = null;
2216 delete pSearchPressedBitmap;
2217 pSearchPressedBitmap = 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 FloatPoint leftHandler(startRect.x, startRect.y + startRect.height);
2241 FloatPoint 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 FloatPoint 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::CreateHandle(int start, int end, int startRowIndex, int startColumnIndex, int endRowIndex, int endColumnIndex)
2264 if (__pEdit->IsBlocked())
2266 FloatRectangle startRect;
2267 FloatRectangle endRect;
2269 if (startRowIndex > -1 && startColumnIndex > -1)
2271 __pEditPresenter->CalculateAbsoluteCursorBounds(startRowIndex, startColumnIndex, startRect);
2275 __pEditPresenter->CalculateAbsoluteCursorBounds(start, startRect);
2277 if (endRowIndex > -1 && endColumnIndex > -1)
2279 __pEditPresenter->CalculateAbsoluteCursorBounds(endRowIndex, endColumnIndex, endRect);
2283 __pEditPresenter->CalculateAbsoluteCursorBounds(end, endRect);
2286 FloatPoint leftHandler(startRect.x, startRect.y + startRect.height);
2287 FloatPoint rightHandler(endRect.x, endRect.y + endRect.height);
2289 __pHandle[HANDLER_TYPE_LEFT] = _EditCopyPasteHandler::CreateInstanceN(leftHandler, start, this, false, true);
2290 __pHandle[HANDLER_TYPE_RIGHT] = _EditCopyPasteHandler::CreateInstanceN(rightHandler, end, this, false, false);
2292 if (startRowIndex > -1 && startColumnIndex > -1)
2294 __pHandle[HANDLER_TYPE_LEFT]->SetHandlerRowColumnIndex(startRowIndex, startColumnIndex);
2296 if (endRowIndex > -1 && endColumnIndex > -1)
2298 __pHandle[HANDLER_TYPE_RIGHT]->SetHandlerRowColumnIndex(endRowIndex, endColumnIndex);
2305 _EditCopyPasteManager::Show(void)
2307 if (__pHandle[HANDLER_TYPE_CENTER])
2309 if (__pEdit->GetCursorPosition() != __pHandle[HANDLER_TYPE_CENTER]->GetHandlerCursorPosition())
2311 __pHandle[HANDLER_TYPE_CENTER]->SetHandlerCursorPosition(__pEdit->GetCursorPosition());
2313 __pHandle[HANDLER_TYPE_CENTER]->AdjustBounds();
2314 __pHandle[HANDLER_TYPE_CENTER]->CheckReverseStatus();
2315 __pHandle[HANDLER_TYPE_CENTER]->Invalidate();
2316 __pEditPresenter->DrawText();
2317 __pHandle[HANDLER_TYPE_CENTER]->MoveCopyPasteMagnifier();
2320 if (__pHandle[HANDLER_TYPE_LEFT] && __pHandle[HANDLER_TYPE_RIGHT])
2323 __pHandle[HANDLER_TYPE_LEFT]->CheckReverseStatus();
2324 __pHandle[HANDLER_TYPE_RIGHT]->CheckReverseStatus();
2325 __pHandle[HANDLER_TYPE_LEFT]->Invalidate();
2326 __pHandle[HANDLER_TYPE_RIGHT]->Invalidate();
2327 __pEditPresenter->DrawText();
2330 if (__pCopyPastePopup)
2332 __pCopyPastePopup->Open();
2333 __pCopyPastePopup->ReleaseTouchCapture();
2335 _Control* pControl = __pCopyPastePopup->GetOwner();
2338 pControl->UnlockInputEvent();
2344 _EditCopyPasteManager::CheckHandleBounds(const FloatPoint& point)
2346 bool hasCommandButton = false;
2347 bool hasParentForm = false;
2348 bool hasParentPanel = false;
2349 bool showCheck = true;
2350 FloatRectangle commandButtonBounds(0.0f, 0.0f, 0.0f, 0.0f);
2351 FloatRectangle formClientBounds(0.0f, 0.0f, 0.0f, 0.0f);
2352 FloatRectangle panelAbsoulteBounds(0.0f, 0.0f, 0.0f, 0.0f);
2353 FloatRectangle editAbsBounds = __pEdit->GetAbsoluteBoundsF(true);
2354 FloatRectangle textObjectBounds = __pEditPresenter->GetTextBoundsF();
2356 if (!(__pEdit->GetEditStyle() & EDIT_STYLE_TOKEN))
2358 editAbsBounds.x += textObjectBounds.x;
2359 editAbsBounds.y += textObjectBounds.y;
2360 editAbsBounds.width = textObjectBounds.width;
2362 if (!(__pEdit->GetEditStyle() & EDIT_STYLE_SINGLE_LINE))
2364 editAbsBounds.height = textObjectBounds.height;
2368 _Toolbar* pCommandButton = __pEditPresenter->GetKeypadCommandButton();
2371 commandButtonBounds = pCommandButton->GetAbsoluteBoundsF(true);
2372 hasCommandButton = true;
2374 _Form* pForm = __pEditPresenter->GetParentForm();
2377 formClientBounds = pForm->GetClientBoundsF();
2378 hasParentForm = true;
2381 _ScrollPanel* pPanel = __pEditPresenter->GetParentPanel();
2384 panelAbsoulteBounds = pPanel->GetAbsoluteBoundsF(true);
2385 hasParentPanel = true;
2388 if ((!_FloatCompare(editAbsBounds.x, point.x) && (editAbsBounds.x > point.x)) || (!_FloatCompare(point.x, editAbsBounds.x + editAbsBounds.width) && point.x > (editAbsBounds.x + editAbsBounds.width)))
2393 if ((!_FloatCompare(editAbsBounds.y, point.y) && (editAbsBounds.y > point.y)) || (!_FloatCompare(point.y, editAbsBounds.y + editAbsBounds.height) && point.y > (editAbsBounds.y + editAbsBounds.height)))
2397 if (hasParentForm && ((!_FloatCompare(formClientBounds.y, point.y) && formClientBounds.y > point.y) || (!_FloatCompare(point.y, formClientBounds.y + formClientBounds.height) && point.y > (formClientBounds.y + formClientBounds.height))))
2401 if (hasParentPanel && ((!_FloatCompare(panelAbsoulteBounds.y, point.y) && panelAbsoulteBounds.y > point.y) || (!_FloatCompare(point.y, panelAbsoulteBounds.y + panelAbsoulteBounds.height) && point.y > (panelAbsoulteBounds.y + panelAbsoulteBounds.height))))
2405 if (hasCommandButton && commandButtonBounds.Contains(point))
2413 _EditCopyPasteManager::RefreshBlock(bool isLeftHandle)
2415 int leftRowIndex = -1;
2416 int leftColumnIndex = -1;
2417 int rightRowIndex = -1;
2418 int rightColumnIndex = -1;
2420 int leftHandlerPos = __pHandle[HANDLER_TYPE_LEFT]->GetHandlerCursorPosition();
2421 int rightHandlerPos = __pHandle[HANDLER_TYPE_RIGHT]->GetHandlerCursorPosition();
2422 __pHandle[HANDLER_TYPE_LEFT]->GetHandlerRowColumnIndex(leftRowIndex, leftColumnIndex);
2423 __pHandle[HANDLER_TYPE_RIGHT]->GetHandlerRowColumnIndex(rightRowIndex, rightColumnIndex);
2425 if (leftHandlerPos <= rightHandlerPos)
2427 if (leftRowIndex != -1 && leftColumnIndex != -1 && rightRowIndex != -1 && rightColumnIndex != -1)
2429 __pEditPresenter->SetBlockRange(leftHandlerPos, rightHandlerPos, leftRowIndex, leftColumnIndex, rightRowIndex, rightColumnIndex);
2433 __pEditPresenter->SetBlockRange(leftHandlerPos, rightHandlerPos);
2435 __pEditPresenter->SetCursorChangedFlag(!isLeftHandle);
2439 if (leftRowIndex != -1 && leftColumnIndex != -1 && rightRowIndex != -1 && rightColumnIndex != -1)
2441 __pEditPresenter->SetBlockRange(rightHandlerPos, leftHandlerPos, rightRowIndex, rightColumnIndex, leftRowIndex, leftColumnIndex);
2445 __pEditPresenter->SetBlockRange(rightHandlerPos, leftHandlerPos);
2447 __pEditPresenter->SetCursorChangedFlag(isLeftHandle);
2449 __pEditPresenter->DrawText();
2454 _EditCopyPasteManager::GetCursorBoundsF(bool isAbsRect) const
2456 FloatRectangle cursorBounds;
2458 __pEdit->GetCursorBounds(isAbsRect, cursorBounds);
2460 return cursorBounds;
2464 _EditCopyPasteManager::GetCursorPositionAt(const FloatPoint& touchPoint) const
2466 return __pEdit->GetCursorPositionAt(touchPoint);
2470 _EditCopyPasteManager::SetCursorPosition(int position)
2472 return __pEdit->SetCursorPosition(position);
2476 _EditCopyPasteManager::GetCursorPosition(void) const
2478 return __pEdit->GetCursorPosition();
2482 _EditCopyPasteManager::GetHandlerCursorPosition(HandlerType handlerType) const
2484 if (__pHandle[handlerType])
2486 return __pHandle[handlerType]->GetHandlerCursorPosition();
2495 _EditCopyPasteManager::SendTextBlockEvent(void)
2499 result r = E_SUCCESS;
2501 __pEdit->GetBlockRange(start, end);
2502 if (start != -1 && end != -1)
2504 r = __pEdit->SendTextBlockEvent(start, end);
2505 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
2510 _EditCopyPasteManager::OnActionPerformed(const _Control& source, int actionId)
2512 _Clipboard* pClipBoard = _Clipboard::GetInstance();
2513 SysTryReturnVoidResult(NID_UI_CTRL, pClipBoard, E_SYSTEM, "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2515 ReleaseCopyPastePopup();
2519 case COPY_PASTE_SELECT_ID:
2521 int cursorPos = GetCursorPosition();
2524 __pEdit->GetWordPosition(cursorPos, start, end);
2525 __pEdit->SetBlockRange(start, end);
2526 SendTextBlockEvent();
2527 __pEditPresenter->UpdateComponentInformation();
2529 CreateCopyPastePopup();
2536 case COPY_PASTE_SELECT_ALL_ID:
2538 int textLength = __pEdit->GetTextLength();
2539 __pEdit->SetBlockRange(0, textLength);
2540 SendTextBlockEvent();
2541 __pEditPresenter->UpdateComponentInformation();
2543 CreateCopyPastePopup();
2550 case COPY_PASTE_COPY_ID:
2551 ReleaseCopyPastePopup();
2552 SendCopyPasteEvent(CORE_COPY_PASTE_STATUS_HIDE, CORE_COPY_PASTE_ACTION_COPY);
2555 case COPY_PASTE_CUT_ID:
2556 SendCopyPasteEvent(CORE_COPY_PASTE_STATUS_HIDE, CORE_COPY_PASTE_ACTION_CUT);
2559 case COPY_PASTE_PASTE_ID:
2560 SendCopyPasteEvent(CORE_COPY_PASTE_STATUS_HIDE, CORE_COPY_PASTE_ACTION_PASTE);
2563 case COPY_PASTE_CLIPBOARD_ID:
2564 pClipBoard->ShowPopup(CLIPBOARD_DATA_TYPE_TEXT, *__pEdit, true);
2565 ReleaseCopyPastePopup();
2566 SendCopyPasteEvent(CORE_COPY_PASTE_STATUS_HIDE, CORE_COPY_PASTE_ACTION_CLIPBOARD);
2568 case COPY_PASTE_SEARCH_ID:
2570 SendCopyPasteEvent(CORE_COPY_PASTE_STATUS_HIDE, CORE_COPY_PASTE_ACTION_SEARCH);
2580 _EditCopyPasteManager::AdjustBounds(void)
2582 if (__pHandle[HANDLER_TYPE_CENTER])
2584 __pHandle[HANDLER_TYPE_CENTER]->AdjustBounds();
2586 if (__pHandle[HANDLER_TYPE_LEFT])
2588 __pHandle[HANDLER_TYPE_LEFT]->AdjustBounds();
2590 if (__pHandle[HANDLER_TYPE_RIGHT])
2592 __pHandle[HANDLER_TYPE_RIGHT]->AdjustBounds();
2597 _EditCopyPasteManager::LaunchSearch(void)
2599 result r = E_SUCCESS;
2602 __pEdit->GetBlockRange(start, end);
2603 String blockText = __pEditPresenter->GetText(start, end-1);
2605 _AppMessageImpl msg;
2607 msg.AddData(APPSVC_DATA_KEYWORD, blockText);
2608 r = _AppControlManager::GetInstance()->LaunchPkg(msg, null, APPSVC_OPERATION_SEARCH, null, null, 0, 0);
2612 _EditCopyPasteManager::GetTextBlockReleaseFlag(void) const
2614 return __needToReleaseBlock;
2618 _EditCopyPasteManager::SetTextBlockReleaseFlag(bool enabled)
2620 __needToReleaseBlock = enabled;
2624 _EditCopyPasteManager::IsCopyPasteHandleExist(void) const
2626 if (__pHandle[HANDLER_TYPE_CENTER] || (__pHandle[HANDLER_TYPE_LEFT] && __pHandle[HANDLER_TYPE_RIGHT]))
2637 _EditCopyPasteManager::IsCopyPasteSingleHandleExist(void) const
2639 if (__pHandle[HANDLER_TYPE_CENTER])
2650 _EditCopyPasteManager::UpdateCopyPasteMagnifier(void)
2652 for (int i = 0; i < HANDLER_TYPE_MAX; i++)
2656 __pHandle[i]->UpdateCopyPasteMagnifier();
2662 _EditCopyPasteManager::GetEdit(void) const
2668 _EditCopyPasteManager::MoveHandler(HandlerMoveType moveType)
2670 if (!__pHandle[HANDLER_TYPE_RIGHT] || !__pHandle[HANDLER_TYPE_LEFT])
2675 int leftHandlerPosition = __pHandle[HANDLER_TYPE_LEFT]->GetHandlerCursorPosition();
2676 int rightHandlerPosition = __pHandle[HANDLER_TYPE_RIGHT]->GetHandlerCursorPosition();
2677 int textLength = __pEdit->GetTextLength();
2678 FloatRectangle rightHandlerCursorBounds;
2679 int newCursorPosition;
2680 __pEditPresenter->CalculateCursorBounds(__pEditPresenter->GetTextBoundsF(), rightHandlerCursorBounds, rightHandlerPosition);
2681 FloatPoint cursorPoint(rightHandlerCursorBounds.x, rightHandlerCursorBounds.y);
2683 TextObject* pTextObject = __pEditPresenter->GetTextObject();
2687 case HANDLER_MOVE_TYPE_LEFT:
2688 if (leftHandlerPosition == rightHandlerPosition-1)
2690 if (leftHandlerPosition == 0)
2694 --rightHandlerPosition;
2696 if (rightHandlerPosition - 1 < 0)
2700 newCursorPosition = --rightHandlerPosition;
2701 __pHandle[HANDLER_TYPE_RIGHT]->SetHandlerCursorPosition(newCursorPosition);
2702 pTextObject->SetFirstDisplayLineIndexFromTextIndex(newCursorPosition);
2703 __pEditPresenter->ScrollPanelToCursorPosition(true);
2705 __pHandle[HANDLER_TYPE_RIGHT]->CheckReverseStatus();
2706 __pHandle[HANDLER_TYPE_RIGHT]->Invalidate();
2708 case HANDLER_MOVE_TYPE_UP:
2709 cursorPoint.y -= rightHandlerCursorBounds.height/2.0f;
2710 newCursorPosition = GetCursorPositionAt(cursorPoint);
2712 if (newCursorPosition <= 0)
2714 int curCursorLine = pTextObject->GetLineIndexAtTextIndex(pTextObject->GetCursorIndex());
2716 if (curCursorLine !=0 )
2718 int offset = rightHandlerPosition - pTextObject->GetFirstTextIndexAt(curCursorLine);
2719 int firstTextIndex = pTextObject->GetFirstTextIndexAt(curCursorLine-1);
2720 newCursorPosition = offset + firstTextIndex;
2721 int textLength = pTextObject->GetTextLengthAt(curCursorLine-1);
2722 if (offset > textLength)
2724 newCursorPosition = firstTextIndex+textLength;
2729 if (newCursorPosition >= 0)
2731 if (leftHandlerPosition == newCursorPosition)
2733 ++newCursorPosition;
2735 __pHandle[HANDLER_TYPE_RIGHT]->SetHandlerCursorPosition(newCursorPosition);
2736 pTextObject->SetFirstDisplayLineIndexFromTextIndex(newCursorPosition);
2737 __pEditPresenter->ScrollPanelToCursorPosition(true);
2739 __pHandle[HANDLER_TYPE_RIGHT]->CheckReverseStatus();
2740 __pHandle[HANDLER_TYPE_RIGHT]->Invalidate();
2747 case HANDLER_MOVE_TYPE_DOWN:
2748 cursorPoint.y += rightHandlerCursorBounds.height + rightHandlerCursorBounds.height/2.0f;
2749 newCursorPosition = GetCursorPositionAt(cursorPoint);
2751 if (newCursorPosition < 0)
2753 int curCursorLine = pTextObject->GetLineIndexAtTextIndex(pTextObject->GetCursorIndex());
2754 int totalLine = pTextObject->GetTotalLineCount();
2755 if (curCursorLine < totalLine - 1)
2757 int offset = rightHandlerPosition - pTextObject->GetFirstTextIndexAt(curCursorLine);
2758 int firstTextIndex = pTextObject->GetFirstTextIndexAt(curCursorLine+1);
2759 newCursorPosition = offset + firstTextIndex;
2760 int textLength = pTextObject->GetTextLengthAt(curCursorLine+1);
2761 if (offset > textLength)
2763 newCursorPosition = firstTextIndex+textLength;
2767 else if (curCursorLine == totalLine - 1)
2769 int firstTextIndex = pTextObject->GetFirstTextIndexAt(curCursorLine);
2770 int textLength = pTextObject->GetTextLengthAt(curCursorLine);
2771 newCursorPosition = firstTextIndex + textLength;
2775 if (newCursorPosition >= 0)
2777 if (leftHandlerPosition == newCursorPosition)
2779 ++newCursorPosition;
2781 __pHandle[HANDLER_TYPE_RIGHT]->SetHandlerCursorPosition(newCursorPosition);
2782 pTextObject->SetFirstDisplayLineIndexFromTextIndex(newCursorPosition);
2783 __pEditPresenter->ScrollPanelToCursorPosition(true);
2785 __pHandle[HANDLER_TYPE_RIGHT]->CheckReverseStatus();
2786 __pHandle[HANDLER_TYPE_RIGHT]->Invalidate();
2793 case HANDLER_MOVE_TYPE_RIGHT:
2794 if (textLength >= rightHandlerPosition+1)
2796 if (leftHandlerPosition == rightHandlerPosition+1)
2798 ++rightHandlerPosition;
2800 newCursorPosition = ++rightHandlerPosition;
2801 __pHandle[HANDLER_TYPE_RIGHT]->SetHandlerCursorPosition(newCursorPosition);
2802 pTextObject->SetFirstDisplayLineIndexFromTextIndex(newCursorPosition);
2803 __pEditPresenter->ScrollPanelToCursorPosition(true);
2805 __pHandle[HANDLER_TYPE_RIGHT]->CheckReverseStatus();
2806 __pHandle[HANDLER_TYPE_RIGHT]->Invalidate();
2817 ReleaseCopyPastePopup();
2818 __isHandlerMoving = true;
2823 _EditCopyPasteManager::IsHandlerMovingEnabled(void) const
2825 return __isHandlerMoving;
2829 _EditCopyPasteManager::SetHandlerMovingEnabled(bool enabled)
2831 __isHandlerMoving = enabled;
2835 _EditCopyPasteManager::GetEditVisibleArea(void) const
2837 return _CoordinateSystemUtils::ConvertToInteger(GetEditVisibleAreaF());
2841 _EditCopyPasteManager::GetEditVisibleAreaF(void) const
2843 return __editVisibleArea;
2847 _EditCopyPasteManager::GetCopyPastePopup(void) const
2849 return __pCopyPastePopup;
2853 _EditCopyPasteManager::GetHandlerRowColumnIndex(bool singleHandler, bool leftHandler, int& rowIndex, int& columnIndex) const
2855 HandlerType handlerType = HANDLER_TYPE_MAX;
2858 handlerType = HANDLER_TYPE_CENTER;
2860 else if (leftHandler)
2862 handlerType = HANDLER_TYPE_LEFT;
2866 handlerType = HANDLER_TYPE_RIGHT;
2869 if (__pHandle[handlerType])
2871 __pHandle[handlerType]->GetHandlerRowColumnIndex(rowIndex, columnIndex);
2883 _EditCopyPasteManager::DestroyCopyPasteMagnifier(void)
2886 if (__pHandle[HANDLER_TYPE_CENTER])
2888 __pHandle[HANDLER_TYPE_CENTER]->DestroyCopyPasteMagnifier();
2893 _EditCopyPasteManager::CreateCopyPasteMagnifier(void)
2896 if (__pHandle[HANDLER_TYPE_CENTER])
2898 __pHandle[HANDLER_TYPE_CENTER]->CreateCopyPasteMagnifier();
2902 }}} // Tizen::Ui::Controls