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 SysTryReturnVoidResult(NID_UI_CTRL, pReplacedMaskBitmap, GetLastResult(), "pReplacedMaskBitmap is null.");
248 pCanvas->DrawNinePatchedBitmap(pCanvas->GetBoundsF(), *pReplacedMaskBitmap);
252 pCanvas->DrawBitmap(pCanvas->GetBoundsF(), *__pMagnifierMaskBitmap);
255 CaptureTextArea(*pCanvas);
262 _EditCopyPasteMagnifier::CaptureTextArea(Canvas& canvas)
264 result r = E_SUCCESS;
265 float captureWidth = 0.0f;
266 float captureHeight = 0.0f;
267 float capturePosX = 0.0f;
268 float capturePosY = 0.0f;
269 float adjustPoxX = 0.0f;
270 float adjustPoxY = 0.0f;
271 FloatRectangle cursorBounds(0.0f, 0.0f, 0.0f, 0.0f);
272 FloatRectangle captureBounds(0.0f, 0.0f, 0.0f, 0.0f);
274 _Edit* pEdit = __pCopyPasteManager->GetEdit();
275 SysTryReturnVoidResult(NID_UI_CTRL, pEdit, E_INVALID_STATE, "pEdit is null.");
277 _EditPresenter* pEditPresenter = pEdit->GetPresenter();
278 SysTryReturnVoidResult(NID_UI_CTRL, pEditPresenter, E_INVALID_STATE, "pEditPresenter is null.");
280 pEditPresenter->CalculateCursorBounds(pEditPresenter->GetTextBoundsF(), cursorBounds, __handlerCursorPos);
282 GET_SHAPE_CONFIG(EDIT::COPYPASTE_MAGNIFIER_CAPTURE_WIDTH, pEdit->GetOrientation(), captureWidth);
283 GET_SHAPE_CONFIG(EDIT::COPYPASTE_MAGNIFIER_CAPTURE_HEIGHT, pEdit->GetOrientation(), captureHeight);
284 GET_SHAPE_CONFIG(EDIT::COPYPASTE_MAGNIFIER_CAPTURE_POSITION_X, pEdit->GetOrientation(), capturePosX);
285 GET_SHAPE_CONFIG(EDIT::COPYPASTE_MAGNIFIER_CAPTURE_POSITION_Y, pEdit->GetOrientation(), capturePosY);
287 FloatRectangle textObjectBounds = pEditPresenter->GetTextBoundsF();
288 captureBounds.x = cursorBounds.x - captureWidth/2.0f;
289 captureBounds.y = cursorBounds.y + cursorBounds.height/2.0f - captureHeight/2.0f;
290 captureBounds.width = captureWidth;
291 captureBounds.height = captureHeight;
292 captureBounds = textObjectBounds.GetIntersection(captureBounds);
294 if (captureBounds.width < captureWidth && captureBounds.x < textObjectBounds.x + textObjectBounds.width - captureBounds.width)
296 adjustPoxX = captureWidth - captureBounds.width;
298 if (captureBounds.height < captureHeight && captureBounds.y < captureHeight)
300 adjustPoxY = captureHeight - captureBounds.height;
303 Bitmap* pOriginalBitmp = pEdit->GetCapturedBitmapN(true);
304 SysTryReturnVoidResult(NID_UI_CTRL, pOriginalBitmp, E_INVALID_STATE, "pOriginalBitmp is null.");
307 r = bitmap.Construct(FloatRectangle(0, 0, captureBounds.width, captureBounds.height));
308 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
310 r = bitmap.Merge(FloatPoint(0.0f, 0.0f), *pOriginalBitmp, CoordinateSystem::AlignToDevice(FloatRectangle(captureBounds.x, captureBounds.y, captureBounds.width, captureBounds.height)));
311 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
313 r = bitmap.SetScalingQuality(BITMAP_SCALING_QUALITY_HIGH);
314 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
316 r = bitmap.Scale(CoordinateSystem::AlignToDevice(FloatDimension(bitmap.GetActualWidth()*1.5f, bitmap.GetActualHeight()*1.5f)));
317 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
319 canvas.DrawBitmap(CoordinateSystem::AlignToDevice(FloatPoint(capturePosX + adjustPoxX*1.5f, capturePosY + adjustPoxY*1.5f)), bitmap);
321 delete pOriginalBitmp;
326 delete pOriginalBitmp;
332 _EditCopyPasteMagnifier::MoveMagnifier(const FloatPoint& point, int handlerCursorPos)
334 FloatRectangle bounds = FloatRectangle(point.x - GetBoundsF().width/2.0f, point.y - GetBoundsF().height, GetBoundsF().width, GetBoundsF().height);
335 __handlerCursorPos = handlerCursorPos;
345 _EditCopyPasteMagnifier::OnBoundsChanging(const FloatRectangle& bounds)
347 result r = E_SUCCESS;
349 __windowBounds = bounds;
355 _EditCopyPasteMagnifier::OnBoundsChanging(const Rectangle& bounds)
357 result r = E_SUCCESS;
363 _EditCopyPasteMagnifier::SetRowColumnIndex(int rowIndex, int columnIndex)
365 __rowIndex = rowIndex;
366 __columnIndex = columnIndex;
370 * @class _EditCopyPasteHandler
371 * @brief This class defines the common behavior for the %_EditCopyPasteHandler.
374 class _EditCopyPasteHandler
376 , virtual public IEventListener
377 , virtual public _IUiEventListener
378 , virtual public _IUiEventPreviewer
384 * This is the default class constructor.
387 _EditCopyPasteHandler(const Point& point, int handlerCursorPos, _EditCopyPasteManager* pCopyPasteManager, bool singleHandler, bool leftHandler);
388 _EditCopyPasteHandler(const FloatPoint& point, int handlerCursorPos, _EditCopyPasteManager* pCopyPasteManager, bool singleHandler, bool leftHandler);
391 * This is the default class destructor.
394 virtual ~_EditCopyPasteHandler(void);
398 enum HandlerDirection
400 HANDLER_DIRECTION_NONE = 0,
401 HANDLER_DIRECTION_REVERSE_1,//horizontal reverse
402 HANDLER_DIRECTION_REVERSE_2,//vertical reverse
403 HANDLER_DIRECTION_REVERSE_3,//horizontal vertical reverse
406 static _EditCopyPasteHandler* CreateInstanceN(const Point& point, int handlerCursorPos, _EditCopyPasteManager* pCopyPasteManager, bool singleHandler, bool leftHandler = true);
407 static _EditCopyPasteHandler* CreateInstanceN(const FloatPoint& point, int handlerCursorPos, _EditCopyPasteManager* pCopyPasteManager, bool singleHandler, bool leftHandler = true);
408 int GetHandlerCursorPosition(void) const;
409 void GetHandlerRowColumnIndex(int& rowIndex, int& columnIndex) const;
410 void SetHandlerCursorPosition(int handlerCursorPos);
411 void AdjustBounds(void);
412 void CheckReverseStatus(void);
413 void ChangeHandlerBitmap(void);
414 Bitmap* GetHandlerBitmap(void) const;
415 bool CreateCopyPasteMagnifier(void);
416 void DestroyCopyPasteMagnifier(void);
417 void MoveCopyPasteMagnifier(void);
418 void UpdateCopyPasteMagnifier(void);
421 virtual void OnDraw(void);
422 virtual bool OnTouchPressed(const _Control& source, const _TouchInfo& touchinfo);
423 virtual bool OnTouchMoved(const _Control& source, const _TouchInfo& touchinfo);
424 virtual bool OnTouchReleased(const _Control& source, const _TouchInfo& touchinfo);
425 virtual bool IsActivatedOnOpen(void) const;
426 virtual void OnChangeLayout(_ControlOrientation orientation);
427 virtual result OnAttachedToMainTree(void);
429 result OnBoundsChanging(const Rectangle& bounds);
430 result OnBoundsChanging(const FloatRectangle& bounds);
431 result SetWindowBounds(const Rectangle& bounds);
432 result SetWindowBounds(const FloatRectangle& bounds);
435 _EditCopyPasteHandler(const _EditCopyPasteHandler& value);
436 _EditCopyPasteHandler& operator =(const _EditCopyPasteHandler& value);
440 _VisualElement* __pRoot;
441 Bitmap* __pHandlerBitmap;
442 FloatPoint __touchPressedPoint;
443 FloatPoint __absoluteTouchPressedPoint;
444 _EditCopyPasteManager* __pCopyPasteManager;
447 int __handlerCursorPos;
448 bool __isTouchPressed;
449 FloatRectangle __windowBounds;
450 HandlerDirection __handlerDirection;
451 bool __singleHandler;
452 _EditCopyPasteMagnifier* __pCopyPasteMagnifier;
453 bool __isTouchMoving;
456 }; // _EditCopyPasteHandler
459 _EditCopyPasteHandler::GetHandlerBitmap(void) const
461 return __pHandlerBitmap;
465 _EditCopyPasteHandler::CreateCopyPasteMagnifier(void)
467 if (!__pCopyPasteMagnifier)
469 _Edit* pEdit = __pCopyPasteManager->GetEdit();
470 SysTryReturn(NID_UI_CTRL, pEdit, false, E_INVALID_STATE, "[E_INVALID_STATE] pEdit is null.\n");
472 _EditPresenter* pEditPresenter = pEdit->GetPresenter();
473 SysTryReturn(NID_UI_CTRL, pEditPresenter, false, E_INVALID_STATE, "[E_INVALID_STATE] pEditPresenter is null.\n");
475 FloatRectangle cursorBounds(0.0f, 0.0f, 0.0f, 0.0f);
476 if (__rowIndex == -1 && __columnIndex == -1)
478 pEditPresenter->CalculateAbsoluteCursorBounds(__handlerCursorPos, cursorBounds);
482 pEditPresenter->CalculateAbsoluteCursorBounds(__rowIndex, __columnIndex, cursorBounds);
484 __pCopyPasteMagnifier = _EditCopyPasteMagnifier::CreateInstanceN(FloatPoint(cursorBounds.x, cursorBounds.y), __handlerCursorPos, __pCopyPasteManager);
485 SysTryReturn(NID_UI_CTRL, __pCopyPasteMagnifier, false, E_INVALID_STATE, "[E_INVALID_STATE] __pCopyPasteMagnifier is null.\n");
487 __pCopyPasteMagnifier->SetRowColumnIndex(__rowIndex, __columnIndex);
493 _EditCopyPasteHandler::DestroyCopyPasteMagnifier(void)
495 if (__pCopyPasteMagnifier)
497 __pCopyPasteMagnifier->Close();
498 delete __pCopyPasteMagnifier;
499 __pCopyPasteMagnifier = null;
504 _EditCopyPasteHandler::MoveCopyPasteMagnifier(void)
506 if (__pCopyPasteMagnifier)
508 _Edit* pEdit = __pCopyPasteManager->GetEdit();
509 SysTryReturnVoidResult(NID_UI_CTRL, pEdit, E_INVALID_STATE, "pEdit is null.");
511 _EditPresenter* pEditPresenter = pEdit->GetPresenter();
512 SysTryReturnVoidResult(NID_UI_CTRL, pEditPresenter, E_INVALID_STATE, "pEditPresenter is null.");
514 FloatRectangle cursorBounds(0.0f, 0.0f, 0.0f, 0.0f);
515 if (__rowIndex == -1 && __columnIndex == -1)
517 pEditPresenter->CalculateAbsoluteCursorBounds(__handlerCursorPos, cursorBounds);
521 pEditPresenter->CalculateAbsoluteCursorBounds(__rowIndex, __columnIndex, cursorBounds);
522 __pCopyPasteMagnifier->SetRowColumnIndex(__rowIndex, __columnIndex);
524 __pCopyPasteMagnifier->MoveMagnifier(FloatPoint(cursorBounds.x, cursorBounds.y), __handlerCursorPos);
529 _EditCopyPasteHandler::UpdateCopyPasteMagnifier(void)
531 if (__pCopyPasteMagnifier)
533 __pCopyPasteMagnifier->Invalidate();
538 _EditCopyPasteHandler::ChangeHandlerBitmap(void)
540 if (__pHandlerBitmap)
542 delete __pHandlerBitmap;
543 __pHandlerBitmap = null;
547 if (__handlerDirection == HANDLER_DIRECTION_NONE)
549 GET_BITMAP_CONFIG_N(EDIT::COPY_PASTE_ICON_CENTER_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, __pHandlerBitmap);
553 GET_BITMAP_CONFIG_N(EDIT::COPY_PASTE_ICON_REVERSE_CENTER_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, __pHandlerBitmap);
559 switch(__handlerDirection)
561 case HANDLER_DIRECTION_REVERSE_1:
562 GET_BITMAP_CONFIG_N(EDIT::COPY_PASTE_ICON_RIGHT_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, __pHandlerBitmap);
564 case HANDLER_DIRECTION_REVERSE_2:
565 GET_BITMAP_CONFIG_N(EDIT::COPY_PASTE_ICON_REVERSE_LEFT_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, __pHandlerBitmap);
567 case HANDLER_DIRECTION_REVERSE_3:
568 GET_BITMAP_CONFIG_N(EDIT::COPY_PASTE_ICON_REVERSE_RIGHT_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, __pHandlerBitmap);
570 case HANDLER_DIRECTION_NONE:
573 GET_BITMAP_CONFIG_N(EDIT::COPY_PASTE_ICON_LEFT_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, __pHandlerBitmap);
579 switch(__handlerDirection)
581 case HANDLER_DIRECTION_REVERSE_1:
582 GET_BITMAP_CONFIG_N(EDIT::COPY_PASTE_ICON_LEFT_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, __pHandlerBitmap);
584 case HANDLER_DIRECTION_REVERSE_2:
585 GET_BITMAP_CONFIG_N(EDIT::COPY_PASTE_ICON_REVERSE_RIGHT_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, __pHandlerBitmap);
587 case HANDLER_DIRECTION_REVERSE_3:
588 GET_BITMAP_CONFIG_N(EDIT::COPY_PASTE_ICON_REVERSE_LEFT_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, __pHandlerBitmap);
590 case HANDLER_DIRECTION_NONE:
593 GET_BITMAP_CONFIG_N(EDIT::COPY_PASTE_ICON_RIGHT_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, __pHandlerBitmap);
599 _EditCopyPasteHandler::_EditCopyPasteHandler(const Point& point, int handlerCursorPos, _EditCopyPasteManager* pCopyPasteManager, bool singleHandler, bool leftHandler)
601 , __pHandlerBitmap(null)
602 , __touchPressedPoint(0.0f, 0.0f)
603 , __absoluteTouchPressedPoint(0.0f, 0.0f)
604 , __pCopyPasteManager(pCopyPasteManager)
605 , __leftHandler(leftHandler)
606 , __reverseCheck(false)
607 , __handlerCursorPos(handlerCursorPos)
608 , __isTouchPressed(false)
609 , __windowBounds(0.0f, 0.0f, 0.0f, 0.0f)
610 , __handlerDirection(HANDLER_DIRECTION_NONE)
611 , __singleHandler(false)
612 , __pCopyPasteMagnifier(null)
613 , __isTouchMoving(false)
619 __pRoot = GetVisualElement();
620 __pRoot->SetSurfaceOpaque(false);
622 Point handlerPoint(point);
626 GET_BITMAP_CONFIG_N(EDIT::COPY_PASTE_ICON_CENTER_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, __pHandlerBitmap);
627 handlerPoint.x = handlerPoint.x - (__pHandlerBitmap->GetWidth() / 2);
628 __singleHandler = true;
634 GET_BITMAP_CONFIG_N(EDIT::COPY_PASTE_ICON_LEFT_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, __pHandlerBitmap);
635 handlerPoint.x = handlerPoint.x - __pHandlerBitmap->GetWidth();
639 GET_BITMAP_CONFIG_N(EDIT::COPY_PASTE_ICON_RIGHT_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, __pHandlerBitmap);
643 FloatRectangle bounds(handlerPoint.x, handlerPoint.y, __pHandlerBitmap->GetWidth(), __pHandlerBitmap->GetHeight());
646 _EditCopyPasteHandler::_EditCopyPasteHandler(const FloatPoint& point, int handlerCursorPos, _EditCopyPasteManager* pCopyPasteManager, bool singleHandler, bool leftHandler)
648 , __pHandlerBitmap(null)
649 , __touchPressedPoint(0.0f, 0.0f)
650 , __absoluteTouchPressedPoint(0.0f, 0.0f)
651 , __pCopyPasteManager(pCopyPasteManager)
652 , __leftHandler(leftHandler)
653 , __reverseCheck(false)
654 , __handlerCursorPos(handlerCursorPos)
655 , __isTouchPressed(false)
656 , __windowBounds(0.0f, 0.0f, 0.0f, 0.0f)
657 , __handlerDirection(HANDLER_DIRECTION_NONE)
658 , __singleHandler(false)
659 , __pCopyPasteMagnifier(null)
660 , __isTouchMoving(false)
666 __pRoot = GetVisualElement();
667 __pRoot->SetSurfaceOpaque(false);
670 //Point handlerPoint(_CoordinateSystemUtils::ConvertToInteger(point));
671 FloatPoint handlerPoint(point);
674 GET_BITMAP_CONFIG_N(EDIT::COPY_PASTE_ICON_CENTER_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, __pHandlerBitmap);
675 handlerPoint.x = handlerPoint.x - (__pHandlerBitmap->GetWidthF() / 2.0f);
676 __singleHandler = true;
682 GET_BITMAP_CONFIG_N(EDIT::COPY_PASTE_ICON_LEFT_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, __pHandlerBitmap);
683 handlerPoint.x = handlerPoint.x - __pHandlerBitmap->GetWidthF();
687 GET_BITMAP_CONFIG_N(EDIT::COPY_PASTE_ICON_RIGHT_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, __pHandlerBitmap);
691 FloatRectangle bounds(handlerPoint.x, handlerPoint.y, _CoordinateSystemUtils::ConvertToFloat(__pHandlerBitmap->GetWidth()), _CoordinateSystemUtils::ConvertToFloat(__pHandlerBitmap->GetHeight()));
694 _EditCopyPasteHandler::~_EditCopyPasteHandler(void)
696 DestroyCopyPasteMagnifier();
698 if (__pHandlerBitmap)
700 delete __pHandlerBitmap;
701 __pHandlerBitmap = null;
705 _EditCopyPasteHandler*
706 _EditCopyPasteHandler::CreateInstanceN(const Point& point, int handlerCursorPos, _EditCopyPasteManager* pCopyPasteManager, bool singleHandler, bool leftHandler)
708 _EditCopyPasteHandler* pCopyPasteHandler = new (std::nothrow) _EditCopyPasteHandler(point, handlerCursorPos, pCopyPasteManager, singleHandler, leftHandler);
709 SysTryReturn(NID_UI_CTRL, pCopyPasteHandler != null, null, E_OUT_OF_MEMORY, "pContextMenu is null");
711 Point handlerPoint(point);
712 Rectangle bounds(0, 0, 0, 0);
713 Bitmap* pHandlerBitmap = pCopyPasteHandler->GetHandlerBitmap();
715 result r = pCopyPasteHandler->CreateRootVisualElement();
716 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
718 pCopyPasteHandler->SetActivationEnabled(false);
722 handlerPoint.x = handlerPoint.x - (pHandlerBitmap->GetWidth() / 2);
728 handlerPoint.x = handlerPoint.x - pHandlerBitmap->GetWidth();
732 bounds.x = handlerPoint.x;
733 bounds.y = handlerPoint.y;
734 bounds.width = pHandlerBitmap->GetWidth();
735 bounds.height = pHandlerBitmap->GetHeight();
737 pCopyPasteHandler->SetBounds(bounds);
738 pCopyPasteHandler->CheckReverseStatus();
739 pCopyPasteHandler->Open(false);
741 return pCopyPasteHandler;
744 pCopyPasteHandler->Close();
745 delete pCopyPasteHandler;
750 _EditCopyPasteHandler*
751 _EditCopyPasteHandler::CreateInstanceN(const FloatPoint& point, int handlerCursorPos, _EditCopyPasteManager* pCopyPasteManager, bool singleHandler, bool leftHandler)
753 _EditCopyPasteHandler* pCopyPasteHandler = new (std::nothrow) _EditCopyPasteHandler(point, handlerCursorPos, pCopyPasteManager, singleHandler, leftHandler);
754 SysTryReturn(NID_UI_CTRL, pCopyPasteHandler != null, null, E_OUT_OF_MEMORY, "pContextMenu is null");
756 FloatPoint handlerPoint(point);
757 FloatRectangle bounds(0.0f, 0.0f, 0.0f, 0.0f);
758 Bitmap* pHandlerBitmap = pCopyPasteHandler->GetHandlerBitmap();
760 result r = pCopyPasteHandler->CreateRootVisualElement();
761 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
763 pCopyPasteHandler->SetActivationEnabled(false);
767 handlerPoint.x = handlerPoint.x - (pHandlerBitmap->GetWidthF() / 2.0f);
773 handlerPoint.x = handlerPoint.x - pHandlerBitmap->GetWidthF();
777 bounds.x = handlerPoint.x;
778 bounds.y = handlerPoint.y;
779 bounds.width = pHandlerBitmap->GetWidthF();
780 bounds.height = pHandlerBitmap->GetHeightF();
782 pCopyPasteHandler->SetBounds(bounds);
783 pCopyPasteHandler->CheckReverseStatus();
784 pCopyPasteHandler->Open(false);
786 return pCopyPasteHandler;
789 pCopyPasteHandler->Close();
790 delete pCopyPasteHandler;
796 _EditCopyPasteHandler::GetHandlerCursorPosition(void) const
798 return __handlerCursorPos;
802 _EditCopyPasteHandler::GetHandlerRowColumnIndex(int& rowIndex, int& columnIndex) const
804 rowIndex = __rowIndex;
805 columnIndex = __columnIndex;
809 _EditCopyPasteHandler::SetHandlerCursorPosition(int handlerCursorPos)
811 __handlerCursorPos = handlerCursorPos;
815 _EditCopyPasteHandler::AdjustBounds(void)
817 FloatRectangle cursorRect;
818 FloatRectangle rect = GetBoundsF();
819 FloatPoint checkPoint(0.0f, 0.0f);
820 _Edit* pEdit = __pCopyPasteManager->GetEdit();
821 _EditPresenter* pEditPresenter = pEdit->GetPresenter();
825 if (__rowIndex == -1 && __columnIndex == -1)
827 pEditPresenter->CalculateAbsoluteCursorBounds(__handlerCursorPos, cursorRect);
831 pEditPresenter->CalculateAbsoluteCursorBounds(__rowIndex, __columnIndex, cursorRect);
833 rect.x = cursorRect.x - __pHandlerBitmap->GetWidthF()/2.0f;
834 rect.y = cursorRect.y + cursorRect.height;
835 checkPoint = FloatPoint(cursorRect.x , cursorRect.y + cursorRect.height);
836 if (__handlerDirection == HANDLER_DIRECTION_REVERSE_2)
838 rect.y -= (cursorRect.height + __pHandlerBitmap->GetHeightF());
843 if (__rowIndex == -1 && __columnIndex == -1)
845 pEditPresenter->CalculateAbsoluteCursorBounds(__handlerCursorPos, cursorRect);
849 pEditPresenter->CalculateAbsoluteCursorBounds(__rowIndex, __columnIndex, cursorRect);
852 rect.x = cursorRect.x;
853 rect.y = cursorRect.y + cursorRect.height;
855 checkPoint = FloatPoint(cursorRect.x, cursorRect.y + cursorRect.height);
859 if (__handlerDirection == HANDLER_DIRECTION_NONE)
861 rect.x = rect.x - __pHandlerBitmap->GetWidthF();
863 else if (__handlerDirection == HANDLER_DIRECTION_REVERSE_2)
865 rect.x = rect.x - __pHandlerBitmap->GetWidthF();
866 rect.y -= (rect.height + cursorRect.height);
868 else if (__handlerDirection == HANDLER_DIRECTION_REVERSE_3)
870 rect.y -= (rect.height + cursorRect.height);
875 if (__handlerDirection == HANDLER_DIRECTION_REVERSE_1)
877 rect.x = rect.x - __pHandlerBitmap->GetWidthF();
879 else if (__handlerDirection == HANDLER_DIRECTION_REVERSE_2)
881 rect.y -= (rect.height + cursorRect.height);
883 else if (__handlerDirection == HANDLER_DIRECTION_REVERSE_3)
885 rect.x = rect.x - __pHandlerBitmap->GetWidthF();
886 rect.y -= (rect.height + cursorRect.height);
891 if (!__isTouchMoving)
893 bool visibleState = __pCopyPasteManager->CheckHandleBounds(checkPoint);
894 if (visibleState && !GetVisibleState())
896 SetVisibleState(true);
899 else if (!visibleState && GetVisibleState())
901 SetVisibleState(false);
911 _EditCopyPasteHandler::OnDraw(void)
913 Canvas* pCanvas = GetCanvasN();
918 pCanvas->SetBackgroundColor(Color(0, 0, 0, 0));
920 if (_BitmapImpl::CheckNinePatchedBitmapStrictly(*__pHandlerBitmap))
922 pCanvas->DrawNinePatchedBitmap(pCanvas->GetBoundsF(), *__pHandlerBitmap);
926 pCanvas->DrawBitmap(pCanvas->GetBoundsF(), *__pHandlerBitmap);
933 SetWindowBounds(__windowBounds);
934 __reverseCheck = false;
938 SetWindowBounds(__windowBounds);
943 _EditCopyPasteHandler::OnTouchPressed(const _Control& source, const _TouchInfo& touchinfo)
945 __pCopyPasteManager->ReleaseCopyPastePopup();
946 #if EDIT_COPY_PASTE_MAGNIFIER
947 CreateCopyPasteMagnifier();
949 __touchPressedPoint = touchinfo.GetCurrentPosition();
950 __absoluteTouchPressedPoint = FloatPoint(GetBoundsF().x + __touchPressedPoint.x, GetBoundsF().y + __touchPressedPoint.y);
951 __isTouchPressed = true;
957 _EditCopyPasteHandler::CheckReverseStatus(void)
959 FloatDimension screenSize;
960 _ControlManager* pControlManager = _ControlManager::GetInstance();
961 _Edit* pEdit = __pCopyPasteManager->GetEdit();
962 _ControlOrientation orientation = pEdit->GetOrientation();
963 FloatRectangle rect = GetBoundsF();
964 FloatRectangle cursorAbsBounds = __pCopyPasteManager->GetCursorBoundsF(true);
965 float clipboardHeight = 0.0f;
966 FloatRectangle keypadBounds(0.0f, 0.0f, 0.0f, 0.0f);
967 float adjustHeight = 0.0f;
969 _EditPresenter* pEditPresenter = pEdit->GetPresenter();
970 SysTryReturnVoidResult(NID_UI_CTRL, pEditPresenter, E_INVALID_STATE, "pEditPresenter is null.\n");
972 clipboardHeight = pEditPresenter->GetClipboardHeight();
973 pEditPresenter->GetKeypadBoundsEx(keypadBounds);
974 if (clipboardHeight > keypadBounds.height)
976 adjustHeight = clipboardHeight;
980 adjustHeight = keypadBounds.height;
983 if (orientation == _CONTROL_ORIENTATION_PORTRAIT)
985 screenSize = pControlManager->GetScreenSizeF();
989 screenSize.width = pControlManager->GetScreenSizeF().height;
990 screenSize.height = pControlManager->GetScreenSizeF().width;
992 if (adjustHeight > 0.0f)
994 screenSize.height -= adjustHeight;
999 if ((__handlerDirection == HANDLER_DIRECTION_NONE) && ((cursorAbsBounds.y + cursorAbsBounds.height + rect.height) > screenSize.height))
1001 __handlerDirection = HANDLER_DIRECTION_REVERSE_2;
1002 rect.y -= (cursorAbsBounds.height + rect.height);
1003 __reverseCheck = true;
1005 else if ((__handlerDirection == HANDLER_DIRECTION_REVERSE_2) && ((cursorAbsBounds.y + cursorAbsBounds.height + rect.height) <= screenSize.height))
1007 __handlerDirection = HANDLER_DIRECTION_NONE;
1008 rect.y += (cursorAbsBounds.height + rect.height);
1009 __reverseCheck = true;
1011 ChangeHandlerBitmap();
1018 if (((__handlerDirection == HANDLER_DIRECTION_NONE) || (__handlerDirection == HANDLER_DIRECTION_REVERSE_2)) && rect.x < 0.0f)
1020 if ((__handlerDirection == HANDLER_DIRECTION_NONE) && ((rect.y + rect.height) > screenSize.height))
1022 __handlerDirection = HANDLER_DIRECTION_REVERSE_3;
1023 rect.y -= (rect.height + cursorAbsBounds.height);
1025 else if ((__handlerDirection == HANDLER_DIRECTION_NONE) && ((rect.y + rect.height) <= screenSize.height))
1027 __handlerDirection = HANDLER_DIRECTION_REVERSE_1;
1029 else if ((__handlerDirection == HANDLER_DIRECTION_REVERSE_2) && ((rect.y + 2*rect.height) > screenSize.height))
1031 __handlerDirection = HANDLER_DIRECTION_REVERSE_3;
1033 else if ((__handlerDirection == HANDLER_DIRECTION_REVERSE_2) && ((rect.y + 2*rect.height) <= screenSize.height))
1035 __handlerDirection = HANDLER_DIRECTION_REVERSE_1;
1036 rect.y += (rect.height + cursorAbsBounds.height);
1038 ChangeHandlerBitmap();
1039 rect.x += rect.width;
1040 __reverseCheck = true;
1042 else if (((__handlerDirection == HANDLER_DIRECTION_REVERSE_1) || (__handlerDirection == HANDLER_DIRECTION_REVERSE_3)) && rect.x >= rect.width)
1044 if ((__handlerDirection == HANDLER_DIRECTION_REVERSE_1) && ((rect.y + rect.height) > screenSize.height))
1046 __handlerDirection = HANDLER_DIRECTION_REVERSE_2;
1047 rect.y -= (rect.height + cursorAbsBounds.height);
1049 else if ((__handlerDirection == HANDLER_DIRECTION_REVERSE_1) && ((rect.y + rect.height) <= screenSize.height))
1051 __handlerDirection = HANDLER_DIRECTION_NONE;
1053 else if ((__handlerDirection == HANDLER_DIRECTION_REVERSE_3) && ((rect.y + 2*rect.height) > screenSize.height))
1055 __handlerDirection = HANDLER_DIRECTION_REVERSE_2;
1057 else if ((__handlerDirection == HANDLER_DIRECTION_REVERSE_3) && ((rect.y + 2*rect.height) <= screenSize.height))
1059 __handlerDirection = HANDLER_DIRECTION_NONE;
1060 rect.y += (rect.height + cursorAbsBounds.height);
1062 ChangeHandlerBitmap();
1063 rect.x -= rect.width;
1064 __reverseCheck = true;
1066 else if (((__handlerDirection == HANDLER_DIRECTION_NONE) || (__handlerDirection == HANDLER_DIRECTION_REVERSE_1)) && ((rect.y + rect.height) > screenSize.height))
1068 if ((__handlerDirection == HANDLER_DIRECTION_NONE) && rect.x < rect.width)
1070 __handlerDirection = HANDLER_DIRECTION_REVERSE_3;
1071 rect.x += rect.width;
1073 else if ((__handlerDirection == HANDLER_DIRECTION_NONE) && rect.x >= rect.width)
1075 __handlerDirection = HANDLER_DIRECTION_REVERSE_2;
1077 else if ((__handlerDirection == HANDLER_DIRECTION_REVERSE_1) && ((rect.x - rect.width) >= 0.0f))
1079 __handlerDirection = HANDLER_DIRECTION_REVERSE_2;
1080 rect.x -= rect.width;
1082 else if ((__handlerDirection == HANDLER_DIRECTION_REVERSE_1) && ((rect.x - rect.width) < 0.0f))
1084 __handlerDirection = HANDLER_DIRECTION_REVERSE_3;
1086 rect.y -= (rect.height + cursorAbsBounds.height);
1087 ChangeHandlerBitmap();
1088 __reverseCheck = true;
1090 else if (((__handlerDirection == HANDLER_DIRECTION_REVERSE_2) || (__handlerDirection == HANDLER_DIRECTION_REVERSE_3)) && ((rect.y + 2*rect.height + cursorAbsBounds.height) <= screenSize.height))
1092 if ((__handlerDirection == HANDLER_DIRECTION_REVERSE_2) && rect.x < 0.0f)
1094 __handlerDirection = HANDLER_DIRECTION_REVERSE_1;
1095 rect.x += rect.width;
1097 else if ((__handlerDirection == HANDLER_DIRECTION_REVERSE_2) && rect.x >= rect.width)
1099 __handlerDirection = HANDLER_DIRECTION_NONE;
1101 else if ((__handlerDirection == HANDLER_DIRECTION_REVERSE_3) && ((rect.x - rect.width) >= 0.0f))
1103 __handlerDirection = HANDLER_DIRECTION_NONE;
1104 rect.x -= rect.width;
1106 else if ((__handlerDirection == HANDLER_DIRECTION_REVERSE_3) && ((rect.x - rect.width) < 0.0f))
1108 __handlerDirection = HANDLER_DIRECTION_REVERSE_1;
1110 rect.y += (rect.height + cursorAbsBounds.height);
1111 ChangeHandlerBitmap();
1112 __reverseCheck = true;
1117 if (((__handlerDirection == HANDLER_DIRECTION_NONE) || (__handlerDirection == HANDLER_DIRECTION_REVERSE_2)) && (rect.x + rect.width) > screenSize.width)
1119 if ((__handlerDirection == HANDLER_DIRECTION_NONE) && ((rect.y + rect.height) > screenSize.height))
1121 __handlerDirection = HANDLER_DIRECTION_REVERSE_3;
1122 rect.y -= (rect.height + cursorAbsBounds.height);
1124 else if ((__handlerDirection == HANDLER_DIRECTION_NONE) && ((rect.y + rect.height) <= screenSize.height))
1126 __handlerDirection = HANDLER_DIRECTION_REVERSE_1;
1128 else if ((__handlerDirection == HANDLER_DIRECTION_REVERSE_2) && ((rect.y + 2*rect.height) > screenSize.height))
1130 __handlerDirection = HANDLER_DIRECTION_REVERSE_3;
1132 else if ((__handlerDirection == HANDLER_DIRECTION_REVERSE_2) && ((rect.y + 2*rect.height) <= screenSize.height))
1134 __handlerDirection = HANDLER_DIRECTION_REVERSE_1;
1135 rect.y += (rect.height + cursorAbsBounds.height);
1137 ChangeHandlerBitmap();
1138 rect.x -= rect.width;
1139 __reverseCheck = true;
1141 else if (((__handlerDirection == HANDLER_DIRECTION_REVERSE_1) || (__handlerDirection == HANDLER_DIRECTION_REVERSE_3)) && (rect.x + 2*rect.width) <= screenSize.width)
1143 if ((__handlerDirection == HANDLER_DIRECTION_REVERSE_1) && ((rect.y + rect.height) > screenSize.height))
1145 __handlerDirection = HANDLER_DIRECTION_REVERSE_2;
1146 rect.y -= (rect.height + cursorAbsBounds.height);
1148 else if ((__handlerDirection == HANDLER_DIRECTION_REVERSE_1) && ((rect.y + rect.height) <= screenSize.height))
1150 __handlerDirection = HANDLER_DIRECTION_NONE;
1152 else if ((__handlerDirection == HANDLER_DIRECTION_REVERSE_3) && ((rect.y + 2*rect.height) > screenSize.height))
1154 __handlerDirection = HANDLER_DIRECTION_REVERSE_2;
1156 else if ((__handlerDirection == HANDLER_DIRECTION_REVERSE_3) && ((rect.y + 2*rect.height) <= screenSize.height))
1158 __handlerDirection = HANDLER_DIRECTION_NONE;
1159 rect.y += (rect.height + cursorAbsBounds.height);
1161 ChangeHandlerBitmap();
1162 rect.x += rect.width;
1163 __reverseCheck = true;
1165 else if (((__handlerDirection == HANDLER_DIRECTION_NONE) || (__handlerDirection == HANDLER_DIRECTION_REVERSE_1)) && ((rect.y + rect.height) > screenSize.height))
1167 if ((__handlerDirection == HANDLER_DIRECTION_NONE) && (rect.x + rect.width) > screenSize.width)
1169 __handlerDirection = HANDLER_DIRECTION_REVERSE_3;
1170 rect.x -= rect.width;
1172 else if ((__handlerDirection == HANDLER_DIRECTION_NONE) && (rect.x + rect.width) <= screenSize.width)
1174 __handlerDirection = HANDLER_DIRECTION_REVERSE_2;
1176 else if ((__handlerDirection == HANDLER_DIRECTION_REVERSE_1) && (rect.x + 2*rect.width) <= screenSize.width)
1178 __handlerDirection = HANDLER_DIRECTION_REVERSE_2;
1179 rect.x += rect.width;
1181 else if ((__handlerDirection == HANDLER_DIRECTION_REVERSE_1) && (rect.x + 2*rect.width) > screenSize.width)
1183 __handlerDirection = HANDLER_DIRECTION_REVERSE_3;
1185 rect.y -= (rect.height + cursorAbsBounds.height);
1186 ChangeHandlerBitmap();
1187 __reverseCheck = true;
1189 else if (((__handlerDirection == HANDLER_DIRECTION_REVERSE_2) || (__handlerDirection == HANDLER_DIRECTION_REVERSE_3)) && ((rect.y + 2*rect.height + cursorAbsBounds.height) <= screenSize.height))
1191 if ((__handlerDirection == HANDLER_DIRECTION_REVERSE_2) && ((rect.x + rect.width) <= screenSize.width))
1193 __handlerDirection = HANDLER_DIRECTION_NONE;
1195 else if ((__handlerDirection == HANDLER_DIRECTION_REVERSE_2) && ((rect.x + rect.width) > screenSize.width))
1197 __handlerDirection = HANDLER_DIRECTION_REVERSE_1;
1198 rect.x -= rect.width;
1200 else if ((__handlerDirection == HANDLER_DIRECTION_REVERSE_3) && ((rect.x + 2*rect.width) <= screenSize.width))
1202 __handlerDirection = HANDLER_DIRECTION_NONE;
1203 rect.x += rect.width;
1205 else if ((__handlerDirection == HANDLER_DIRECTION_REVERSE_3) && ((rect.x + 2*rect.width) > screenSize.width))
1207 __handlerDirection = HANDLER_DIRECTION_REVERSE_1;
1209 rect.y += (rect.height + cursorAbsBounds.height);
1210 ChangeHandlerBitmap();
1211 __reverseCheck = true;
1219 _EditCopyPasteHandler::OnTouchReleased(const _Control& source, const _TouchInfo& touchinfo)
1221 CheckReverseStatus();
1222 __isTouchPressed = false;
1223 __absoluteTouchPressedPoint = FloatPoint(0.0f, 0.0f);
1224 DestroyCopyPasteMagnifier();
1225 __pCopyPasteManager->CreateCopyPastePopup();
1226 __pCopyPasteManager->Show();
1227 __pCopyPasteManager->SendTextBlockEvent();
1229 __isTouchMoving = false;
1234 _EditCopyPasteHandler::OnTouchMoved(const _Control& source, const _TouchInfo& touchinfo)
1237 FloatRectangle cursorRect(0.0f, 0.0f, 0.0f, 0.0f);
1238 FloatRectangle absCursorRect(0.0f, 0.0f, 0.0f, 0.0f);
1239 FloatRectangle rect = GetBoundsF();
1240 FloatPoint point = touchinfo.GetCurrentPosition();
1241 FloatPoint touchPoint(0.0f, 0.0f);
1242 FloatPoint checkPoint(0.0f, 0.0f);
1243 __isTouchMoving = true;
1245 _Edit* pEdit = __pCopyPasteManager->GetEdit();
1246 SysTryReturn(NID_UI_CTRL, pEdit, false, E_INVALID_STATE, "[E_INVALID_STATE] pEdit is null.\n");
1248 _EditPresenter* pEditPresenter = pEdit->GetPresenter();
1249 SysTryReturn(NID_UI_CTRL, pEditPresenter, false, E_INVALID_STATE, "[E_INVALID_STATE] pEditPresenter is null.\n");
1251 TextObject* pTextObject = pEditPresenter->GetTextObject();
1252 SysTryReturn(NID_UI_CTRL, pTextObject, false, E_INVALID_STATE, "[E_INVALID_STATE] pEditPresenter is null.\n");
1254 int curCursorLine = pTextObject->GetLineIndexAtTextIndex(__handlerCursorPos);
1255 int totalLine = pTextObject->GetTotalLineCount();
1257 float totalHeight = pTextObject->GetTotalHeightF();
1258 float firstDisplayY = pTextObject->GetFirstDisplayPositionYF();
1259 FloatRectangle absTextObjectBounds(0.0f, 0.0f, 0.0f, 0.0f);
1260 FloatRectangle textObjectBounds = pEditPresenter->GetTextBoundsF();
1261 FloatRectangle absEditBounds = pEdit->GetAbsoluteBoundsF();
1262 absTextObjectBounds.x = absEditBounds.x + textObjectBounds.x;
1263 absTextObjectBounds.y = absEditBounds.y + textObjectBounds.y;
1264 absTextObjectBounds.width = textObjectBounds.width;
1265 absTextObjectBounds.height = textObjectBounds.height;
1266 if (__touchPressedPoint.x == point.x && __touchPressedPoint.y == point.y)
1271 if (__rowIndex == -1 && __columnIndex == -1)
1273 pEditPresenter->CalculateCursorBounds(pEditPresenter->GetTextBoundsF(), cursorRect,__handlerCursorPos);
1274 pEditPresenter->CalculateAbsoluteCursorBounds(__handlerCursorPos, absCursorRect);
1278 pEditPresenter->CalculateCursorBounds(pEditPresenter->GetTextBoundsF(), cursorRect, __rowIndex, __columnIndex);
1279 pEditPresenter->CalculateAbsoluteCursorBounds(__rowIndex, __columnIndex, absCursorRect);
1282 FloatPoint absoluteTouchMovedPoint = FloatPoint(GetBoundsF().x + point.x, GetBoundsF().y + point.y);
1283 //Calculate handler's position
1284 if (__singleHandler)
1286 touchPoint.x = absoluteTouchMovedPoint.x;
1287 if (__handlerDirection == HANDLER_DIRECTION_NONE)
1289 touchPoint.y = absoluteTouchMovedPoint.y - GetBoundsF().height/2.0f;
1291 else // HANDLER_DIRECTION_REVERSE_2
1293 touchPoint.y = absoluteTouchMovedPoint.y + GetBoundsF().height/2.0f;
1300 if (__handlerDirection == HANDLER_DIRECTION_NONE)
1302 touchPoint.x = absoluteTouchMovedPoint.x + GetBoundsF().width/2.0f;
1303 touchPoint.y = absoluteTouchMovedPoint.y - GetBoundsF().height/2.0f;
1305 else if (__handlerDirection == HANDLER_DIRECTION_REVERSE_1)
1307 touchPoint.x = absoluteTouchMovedPoint.x - GetBoundsF().width/2.0f;
1308 touchPoint.y = absoluteTouchMovedPoint.y - GetBoundsF().height/2.0f;
1310 else if (__handlerDirection == HANDLER_DIRECTION_REVERSE_2)
1312 touchPoint.x = absoluteTouchMovedPoint.x + GetBoundsF().width/2.0f;
1313 touchPoint.y = absoluteTouchMovedPoint.y + GetBoundsF().height/2.0f;
1315 else if (__handlerDirection == HANDLER_DIRECTION_REVERSE_3)
1317 touchPoint.x = absoluteTouchMovedPoint.x - GetBoundsF().width/2.0f;
1318 touchPoint.y = absoluteTouchMovedPoint.y + GetBoundsF().height/2.0f;
1323 if (__handlerDirection == HANDLER_DIRECTION_NONE)
1325 touchPoint.x = absoluteTouchMovedPoint.x - GetBoundsF().width/2.0f;
1326 touchPoint.y = absoluteTouchMovedPoint.y - GetBoundsF().height/2.0f;
1328 else if (__handlerDirection == HANDLER_DIRECTION_REVERSE_1)
1330 touchPoint.x = absoluteTouchMovedPoint.x + GetBoundsF().width/2.0f;
1331 touchPoint.y = absoluteTouchMovedPoint.y - GetBoundsF().height/2.0f;
1333 else if (__handlerDirection == HANDLER_DIRECTION_REVERSE_2)
1335 touchPoint.x = absoluteTouchMovedPoint.x - GetBoundsF().width/2.0f;
1336 touchPoint.y = absoluteTouchMovedPoint.y + GetBoundsF().height/2.0f;
1338 else if (__handlerDirection == HANDLER_DIRECTION_REVERSE_3)
1340 touchPoint.x = absoluteTouchMovedPoint.x + GetBoundsF().width/2.0f;
1341 touchPoint.y = absoluteTouchMovedPoint.y + GetBoundsF().height/2.0f;
1345 if (totalHeight - firstDisplayY < absTextObjectBounds.height)
1347 absTextObjectBounds.height = totalHeight - firstDisplayY - 1.0f; // check TextObject
1350 if (totalLine != 1) //single line edit doesn't need to adjust horizontal value.
1352 if (absTextObjectBounds.x > touchPoint.x)
1354 touchPoint.x = absTextObjectBounds.x;
1356 if (absTextObjectBounds.x + absTextObjectBounds.width <= touchPoint.x) // check FloatRectangle Contains?
1358 touchPoint.x = absTextObjectBounds.x + absTextObjectBounds.width - 1.0f;
1361 if (absTextObjectBounds.y > touchPoint.y)
1363 if (totalLine == 1 || firstDisplayY == 0.0f) // whether need to scroll the text or not
1365 touchPoint.y = absTextObjectBounds.y; //not need to scroll the text.
1368 if (absTextObjectBounds.y + absTextObjectBounds.height < touchPoint.y)
1370 if (totalLine == 1 || (totalHeight - firstDisplayY < textObjectBounds.height) || curCursorLine == (totalLine - 1)) // || pTextObject->IsDisplayedLastLine()) // whether need to scroll the text or not
1372 touchPoint.y = absTextObjectBounds.y + absTextObjectBounds.height - 1.0f; // check TextObject
1376 if (!__singleHandler)
1378 int nextHandlerLine = -1;
1381 nextHandlerLine = pTextObject->GetLineIndexAtTextIndex(__pCopyPasteManager->GetHandlerCursorPosition(Tizen::Ui::Controls::_EditCopyPasteManager::HANDLER_TYPE_RIGHT));
1385 nextHandlerLine = pTextObject->GetLineIndexAtTextIndex(__pCopyPasteManager->GetHandlerCursorPosition(Tizen::Ui::Controls::_EditCopyPasteManager::HANDLER_TYPE_LEFT));
1388 if (curCursorLine == nextHandlerLine)
1390 if (__leftHandler && absoluteTouchMovedPoint.y >= absCursorRect.y + absCursorRect.height)
1392 touchPoint.y = absCursorRect.y + absCursorRect.height/2.0f;
1394 else if (!__leftHandler && absoluteTouchMovedPoint.y <= absCursorRect.y + absCursorRect.height)
1396 touchPoint.y = absCursorRect.y + absCursorRect.height/2.0f;
1401 touchPoint.x = touchPoint.x - absEditBounds.x - textObjectBounds.x;
1402 touchPoint.y = touchPoint.y - absEditBounds.y - textObjectBounds.y;
1404 if (Math::Abs(touchPoint.y) < 1)
1406 touchPoint.y = 0.0f;
1410 int columnIndex = -1;
1411 cursorPos = pTextObject->GetTextIndexFromPosition(touchPoint.x, touchPoint.y, rowIndex, columnIndex, true);
1413 if (__handlerCursorPos == cursorPos)
1418 if (cursorPos == -1)
1423 if (absoluteTouchMovedPoint.y > (absCursorRect.y + absCursorRect.height))
1425 if (curCursorLine < totalLine - 1)
1427 int offset = __handlerCursorPos - pTextObject->GetFirstTextIndexAt(curCursorLine);
1428 int firstTextIndex = pTextObject->GetFirstTextIndexAt(curCursorLine+1);
1429 cursorPos = offset + firstTextIndex;
1430 int textLength = pTextObject->GetTextLengthAt(curCursorLine+1);
1431 if (offset > textLength)
1433 cursorPos = firstTextIndex+textLength;
1439 if (curCursorLine !=0)
1441 if (__rowIndex == 0)
1445 int offset = __handlerCursorPos - pTextObject->GetFirstTextIndexAt(curCursorLine);
1446 int firstTextIndex = pTextObject->GetFirstTextIndexAt(curCursorLine-1);
1447 cursorPos = offset + firstTextIndex;
1448 int textLength = pTextObject->GetTextLengthAt(curCursorLine-1);
1449 if (offset > textLength)
1451 cursorPos = firstTextIndex+textLength;
1456 if (cursorPos == -1)
1462 if (__handlerCursorPos == cursorPos)
1466 if (!__singleHandler)
1468 if (!__pCopyPasteManager->CheckHandlePosition(__leftHandler, cursorPos))
1472 _EditCopyPasteManager::HandlerType nextHandlerType = _EditCopyPasteManager::HANDLER_TYPE_MAX;
1475 nextHandlerType = _EditCopyPasteManager::HANDLER_TYPE_RIGHT;
1479 nextHandlerType = _EditCopyPasteManager::HANDLER_TYPE_LEFT;
1481 int nextHandler = __pCopyPasteManager->GetHandlerCursorPosition(nextHandlerType);
1482 if (Math::Abs(nextHandler - __handlerCursorPos) <= 1)
1484 pTextObject->SetFirstDisplayLineIndexFromTextIndex(nextHandler);
1491 if (rowIndex > -1 && columnIndex > -1)
1493 __rowIndex = rowIndex;
1494 __columnIndex = columnIndex;
1502 pTextObject->SetFirstDisplayLineIndexFromTextIndex(cursorPos);
1504 __handlerCursorPos = cursorPos;
1505 __pCopyPasteManager->SetCursorPosition(__handlerCursorPos);
1506 pEditPresenter->ScrollPanelToCursorPosition(true);
1508 if (!__singleHandler)
1510 __pCopyPasteManager->RefreshBlock(__leftHandler);
1514 if (__rowIndex == -1 && __columnIndex == -1)
1516 __pCopyPasteManager->SetCursorPosition(cursorPos);
1520 pEditPresenter->SetCursorPosition(cursorPos, __rowIndex, __columnIndex);
1522 pEditPresenter->DrawText();
1525 MoveCopyPasteMagnifier();
1531 _EditCopyPasteHandler::IsActivatedOnOpen(void) const
1537 _EditCopyPasteHandler::OnChangeLayout(_ControlOrientation orientation)
1544 _EditCopyPasteHandler::OnAttachedToMainTree(void)
1546 result r = E_SUCCESS;
1548 if (GetOwner() == null)
1550 _Edit* pEdit = __pCopyPasteManager->GetEdit();
1551 SysTryReturnResult(NID_UI_CTRL, pEdit, GetLastResult(), "Unable to get pEdit.");
1553 _EditPresenter* pEditPresenter = pEdit->GetPresenter();
1554 SysTryReturnResult(NID_UI_CTRL, pEdit, GetLastResult(), "Unable to get pEditPresenter.");
1556 _Form* pParentForm = pEditPresenter->GetParentForm();
1559 SetOwner(pParentForm);
1563 _Form* pForm = null;
1564 _Frame* pCurrentFrame = dynamic_cast <_Frame*>(_ControlManager::GetInstance()->GetCurrentFrame());
1567 pForm = pCurrentFrame->GetCurrentForm();
1574 SetOwner(pCurrentFrame);
1584 _EditCopyPasteHandler::OnBoundsChanging(const FloatRectangle& bounds)
1586 result r = E_SUCCESS;
1588 __windowBounds = bounds;
1590 if (!GetVisibleState())
1595 if (!__reverseCheck)
1597 _EcoreEvas* pEcoreEvas = GetEcoreEvasMgr()->GetEcoreEvas();
1598 SysTryReturn(NID_UI, pEcoreEvas, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error occurred.");
1600 pEcoreEvas->SetWindowBounds(*GetRootWindow(), bounds);
1601 result r = GetLastResult();
1602 SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1609 _EditCopyPasteHandler::OnBoundsChanging(const Rectangle& bounds)
1611 result r = E_SUCCESS;
1616 _EditCopyPasteHandler::SetWindowBounds(const Rectangle& bounds)
1618 _EcoreEvas* pEcoreEvas = GetEcoreEvasMgr()->GetEcoreEvas();
1619 SysTryReturn(NID_UI, pEcoreEvas, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error occurred.");
1621 pEcoreEvas->SetWindowBounds(*GetRootWindow(), bounds);
1622 result r = GetLastResult();
1623 SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1629 _EditCopyPasteHandler::SetWindowBounds(const FloatRectangle& bounds)
1631 _EcoreEvas* pEcoreEvas = GetEcoreEvasMgr()->GetEcoreEvas();
1632 SysTryReturn(NID_UI, pEcoreEvas, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error occurred.");
1634 pEcoreEvas->SetWindowBounds(*GetRootWindow(), bounds);
1635 result r = GetLastResult();
1636 SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1641 _EditCopyPasteManager::_EditCopyPasteManager(_Edit& parenEdit)
1642 : __pCopyPastePopup(null)
1643 , __contextMenuAlign(CONTEXT_MENU_CORE_ALIGN_UP)
1644 , __pCoreCopyPasteEvent(null)
1645 , __pEdit(&parenEdit)
1646 , __pEditPresenter(null)
1647 , __contextMenuHeight(0.0f)
1648 , __needToReleaseBlock(true)
1649 , __isHandlerMoving(false)
1650 , __editVisibleArea(0.0f, 0.0f, 0.0f, 0.0f)
1652 __pEditPresenter = __pEdit->GetPresenter();
1653 __pHandle[HANDLER_TYPE_CENTER] = null;
1654 __pHandle[HANDLER_TYPE_LEFT] = null;
1655 __pHandle[HANDLER_TYPE_RIGHT] = null;
1660 _EditCopyPasteManager::~_EditCopyPasteManager(void)
1664 if (__pCoreCopyPasteEvent)
1666 delete __pCoreCopyPasteEvent;
1667 __pCoreCopyPasteEvent = null;
1672 _EditCopyPasteManager::Release(void)
1674 if (__pCopyPastePopup)
1676 __pCopyPastePopup->Close();
1677 delete __pCopyPastePopup;
1678 __pCopyPastePopup = null;
1681 if (__pHandle[HANDLER_TYPE_CENTER])
1683 __pHandle[HANDLER_TYPE_CENTER]->Close();
1684 delete __pHandle[HANDLER_TYPE_CENTER];
1685 __pHandle[HANDLER_TYPE_CENTER] = null;
1688 if (__pHandle[HANDLER_TYPE_LEFT])
1690 __pHandle[HANDLER_TYPE_LEFT]->Close();
1691 delete __pHandle[HANDLER_TYPE_LEFT];
1692 __pHandle[HANDLER_TYPE_LEFT] = null;
1695 if (__pHandle[HANDLER_TYPE_RIGHT])
1697 __pHandle[HANDLER_TYPE_RIGHT]->Close();
1698 delete __pHandle[HANDLER_TYPE_RIGHT];
1699 __pHandle[HANDLER_TYPE_RIGHT] = null;
1704 _EditCopyPasteManager::ReleaseCopyPastePopup(void)
1706 if (__pCopyPastePopup)
1708 __pCopyPastePopup->Close();
1709 delete __pCopyPastePopup;
1710 __pCopyPastePopup = null;
1715 _EditCopyPasteManager::IsCopyPastePopup(const _Control& control) const
1717 if (__pCopyPastePopup == &control)
1726 _EditCopyPasteManager::IsCopyPasteHandle(const _Control& control) const
1728 if (__pHandle[HANDLER_TYPE_CENTER] == &control)
1733 if (__pHandle[HANDLER_TYPE_LEFT] == &control)
1738 if (__pHandle[HANDLER_TYPE_RIGHT] == &control)
1747 _EditCopyPasteManager::AddCopyPasteEventListener(const _IEditCopyPasteEventListener& listener)
1751 if (__pCoreCopyPasteEvent == null)
1753 __pCoreCopyPasteEvent = _EditCopyPasteEvent::CreateInstanceN(*this);
1754 SysTryReturn(NID_UI_CTRL, __pCoreCopyPasteEvent, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] System error occurred.\n");
1757 return __pCoreCopyPasteEvent->AddListener(listener);
1761 _EditCopyPasteManager::SendCopyPasteEvent(CoreCopyPasteStatus status, CoreCopyPasteAction action)
1763 if (__pCoreCopyPasteEvent)
1765 IEventArg* pCopyPasteEventArg = _EditCopyPasteEvent::CreateCopyPasteEventArgN(status, action);
1766 SysTryReturn(NID_UI_CTRL, pCopyPasteEventArg, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Unable to create _LinkEventArg.");
1768 __pCoreCopyPasteEvent->Fire(*pCopyPasteEventArg);
1775 _EditCopyPasteManager::CreateCopyPastePopup(void)
1777 if (__pHandle[HANDLER_TYPE_CENTER])
1779 __pHandle[HANDLER_TYPE_CENTER]->DestroyCopyPasteMagnifier();
1781 if (__pCopyPastePopup)
1783 __pCopyPastePopup->Close();
1784 delete __pCopyPastePopup;
1785 __pCopyPastePopup = null;
1788 FloatRectangle startRect;
1789 FloatRectangle endRect;
1790 FloatRectangle editAbsRect;
1791 FloatRectangle editShowAreaAbsRect;
1792 FloatRectangle commandButtonBounds;
1793 FloatRectangle keypadBounds(0.0f, 0.0f, 0.0f, 0.0f);
1794 FloatRectangle formClientBounds(0.0f, 0.0f, 0.0f, 0.0f);
1795 FloatRectangle panelAbsoulteBounds(0.0f, 0.0f, 0.0f, 0.0f);
1796 bool commandButtonExist = false;
1797 FloatRectangle cursorRect = GetCursorBoundsF(true);
1799 float contextMenuHeight = 0.0f;
1800 float contextMenuTopMargin = 0.0f;
1801 float contextMenuBottomMargin = 0.0f;
1802 float contextMenuArrowHeight = 0.0f;
1803 float handlerHeight = 0.0f;
1804 bool isPasswordStyle = false;
1805 bool isClipped = false;
1806 if (__pEdit->GetEditStyle() & EDIT_STYLE_PASSWORD)
1808 isPasswordStyle = true;
1811 _ControlOrientation orientation = __pEdit->GetOrientation();
1813 FloatDimension screenSize;
1814 _ControlManager* pControlManager = _ControlManager::GetInstance();
1815 if (orientation == _CONTROL_ORIENTATION_PORTRAIT)
1817 screenSize = pControlManager->GetScreenSizeF();
1821 screenSize.width = pControlManager->GetScreenSizeF().height;
1822 screenSize.height = pControlManager->GetScreenSizeF().width;
1825 GET_SHAPE_CONFIG(EDIT::COPYPASTE_HANDLER_HEIGHT, orientation, handlerHeight);
1827 GET_SHAPE_CONFIG(CONTEXTMENU::GRID_ITEM_HEIGHT, orientation, contextMenuHeight);
1828 GET_SHAPE_CONFIG(CONTEXTMENU::GRID_TOP_MARGIN, orientation, contextMenuTopMargin);
1829 GET_SHAPE_CONFIG(CONTEXTMENU::GRID_BOTTOM_MARGIN, orientation, contextMenuBottomMargin);
1830 GET_SHAPE_CONFIG(CONTEXTMENU::ANCHOR_HEIGHT, orientation, contextMenuArrowHeight);
1832 isClipped = __pEdit->IsClipped();
1833 if ((__pEdit->GetTextLength() == 0 || __pEdit->GetEditStyle() & EDIT_STYLE_PASSWORD) && !isClipped)
1838 if (__pEdit->GetTextLength() == 0 && (__pEditPresenter->IsViewModeEnabled()))
1843 __contextMenuHeight = contextMenuHeight + contextMenuTopMargin + contextMenuBottomMargin + contextMenuArrowHeight;
1844 if (isClipped && __pEditPresenter->IsViewModeEnabled() == false && __pEdit->GetTextLength() > 0 && orientation == _CONTROL_ORIENTATION_PORTRAIT)
1846 __contextMenuHeight = __contextMenuHeight + contextMenuHeight;
1849 editAbsRect = __pEdit->GetAbsoluteBoundsF();
1851 _Toolbar* pCommandButton = __pEditPresenter->GetKeypadCommandButton();
1854 commandButtonBounds = pCommandButton->GetAbsoluteBoundsF();
1855 commandButtonExist = true;
1857 _Form* pForm = __pEditPresenter->GetParentForm();
1860 formClientBounds = pForm->GetClientBoundsF();
1862 _ScrollPanel* pPanel = __pEditPresenter->GetParentPanel();
1865 panelAbsoulteBounds = pPanel->GetAbsoluteBoundsF();
1867 __pEdit->GetKeypadBounds(keypadBounds);
1871 editShowAreaAbsRect = editAbsRect;
1872 FloatRectangle textObjectBounds = __pEditPresenter->GetTextBoundsF();
1874 if (!(__pEdit->GetEditStyle() & EDIT_STYLE_TOKEN))
1876 editShowAreaAbsRect.x += textObjectBounds.x;
1877 editShowAreaAbsRect.y += textObjectBounds.y;
1878 editShowAreaAbsRect.width = textObjectBounds.width;
1880 if (!(__pEdit->GetEditStyle() & EDIT_STYLE_SINGLE_LINE))
1882 editShowAreaAbsRect.height = textObjectBounds.height;
1886 if (commandButtonExist)
1888 if (editShowAreaAbsRect.y + editShowAreaAbsRect.height > commandButtonBounds.y)
1890 editShowAreaAbsRect.height -= (editShowAreaAbsRect.y + editShowAreaAbsRect.height - commandButtonBounds.y);
1895 if (editShowAreaAbsRect.y + editShowAreaAbsRect.height > keypadBounds.y)
1897 editShowAreaAbsRect.height -= (editShowAreaAbsRect.y + editShowAreaAbsRect.height - keypadBounds.y);
1900 if (editShowAreaAbsRect.y < formClientBounds.y)
1902 editShowAreaAbsRect.y = formClientBounds.y;
1903 editShowAreaAbsRect.height -= formClientBounds.y;
1905 if (editShowAreaAbsRect.y < panelAbsoulteBounds.y)
1907 editShowAreaAbsRect.y = panelAbsoulteBounds.y;
1908 editShowAreaAbsRect.height -= (panelAbsoulteBounds.y - editShowAreaAbsRect.y);
1910 __editVisibleArea = editShowAreaAbsRect;
1912 FloatPoint copyPastePoint(0.0f, 0.0f);
1913 __contextMenuAlign = CONTEXT_MENU_CORE_ALIGN_UP;
1915 if (__pEdit->IsBlocked())
1919 __pEdit->GetBlockRange(start, end);
1920 if (start == -1 || end == -1)
1922 SysLog(NID_UI_CTRL, "[EditCopyPasteManager] There is no blocked Range");
1926 __pEdit->CalculateAbsoluteCursorBounds(start, startRect);
1927 __pEdit->CalculateAbsoluteCursorBounds(end, endRect);
1928 if (startRect.x > endRect.x)
1930 copyPastePoint.x = endRect.x + (startRect.x - endRect.x)/2;
1932 else if (startRect.x < endRect.x)
1934 copyPastePoint.x = startRect.x + (endRect.x - startRect.x)/2;
1938 copyPastePoint.x = startRect.x;
1941 if (copyPastePoint.x < editShowAreaAbsRect.x)
1943 copyPastePoint.x = editShowAreaAbsRect.x;
1945 else if (copyPastePoint.x > (editShowAreaAbsRect.x + editShowAreaAbsRect.width))
1947 copyPastePoint.x = editShowAreaAbsRect.x + editShowAreaAbsRect.width;
1950 //Both of handlers are located on the top of the Editor.
1951 if ( ((startRect.y + startRect.height) < editShowAreaAbsRect.y) && ((endRect.y + endRect.height) < editShowAreaAbsRect.y))
1953 SysLog(NID_UI_CTRL, "Both of handlers are located on the top of the Editor.\n");
1956 //Both of handlers are located on the bottom of the Editor.
1957 else if( ((startRect.y + startRect.height) > editShowAreaAbsRect.y + editShowAreaAbsRect.height ) && ((endRect.y + endRect.height) > editShowAreaAbsRect.y + editShowAreaAbsRect.height))
1959 SysLog(NID_UI_CTRL, "Both of handlers are located on the bottom of the Editor.\n");
1962 // Left handler is located on the top of the Editor and Right handler is located on the bottom of the Editor.
1963 else if ( ((startRect.y + startRect.height) < editShowAreaAbsRect.y) && ((endRect.y + endRect.height) > (editShowAreaAbsRect.y + editShowAreaAbsRect.height)))
1965 copyPastePoint.y = editShowAreaAbsRect.y + editShowAreaAbsRect.height/2;
1967 if (copyPastePoint.y < __contextMenuHeight)
1969 __contextMenuAlign = CONTEXT_MENU_CORE_ALIGN_DOWN;
1973 // Left handler is located on the top of the Editor and Right handler is located on the Editor
1974 else if ( ((startRect.y + startRect.height) < editShowAreaAbsRect.y) && ((endRect.y + endRect.height) <= (editShowAreaAbsRect.y + editShowAreaAbsRect.height)) )
1976 if ( (endRect.y + endRect.height + handlerHeight + __contextMenuHeight) < keypadBounds.y)
1978 __contextMenuAlign = CONTEXT_MENU_CORE_ALIGN_DOWN;
1979 copyPastePoint.y = endRect.y + endRect.height + handlerHeight;
1981 else if (endRect.y - editShowAreaAbsRect.y > __contextMenuHeight)
1983 copyPastePoint.y = editShowAreaAbsRect.y + __contextMenuHeight;
1985 else if (endRect.y > __contextMenuHeight)
1987 copyPastePoint.y = endRect.y;
1991 SysLog(NID_UI_CTRL, "There is no space to draw the copy&paste popup\n");
1995 // Left handler is located on the Editor and Right handler is located on the bottom of the Editor
1996 else if ( ((startRect.y + startRect.height) >= editShowAreaAbsRect.y) && ((endRect.y + endRect.height) > (editShowAreaAbsRect.y + editShowAreaAbsRect.height)) )
1998 if (__contextMenuHeight < startRect.y)
2000 copyPastePoint.y = startRect.y;
2004 copyPastePoint.y = startRect.y + (editShowAreaAbsRect.y + editShowAreaAbsRect.height - startRect.y)/2;
2007 // There is a space on the top of the Editor.
2008 else if (__contextMenuHeight < startRect.y)
2010 copyPastePoint.y = startRect.y;
2012 // There is a space on the bottom of the Editor.
2013 else if ( screenSize.height > (endRect.y + endRect.height + handlerHeight + __contextMenuHeight))
2015 __contextMenuAlign = CONTEXT_MENU_CORE_ALIGN_DOWN;
2017 copyPastePoint.y = endRect.y + endRect.height + handlerHeight;
2019 // There is no space on the top and bottom of the Editor. The Popup should be drawn on the center of the Editor.
2022 if (endRect.y - startRect.y < __contextMenuHeight)
2024 SysLog(NID_UI_CTRL, "There is no space to draw the copy&paste popup\n");
2027 copyPastePoint.y = startRect.y + __contextMenuHeight;
2033 if (editShowAreaAbsRect.height <= 0)
2037 FloatRectangle cursorRect;
2038 int cursorPosition = GetCursorPosition();
2039 __pEdit->CalculateAbsoluteCursorBounds(cursorPosition, cursorRect);
2040 copyPastePoint.x = cursorRect.x;
2041 copyPastePoint.y = cursorRect.y;
2043 if (__editVisibleArea.y > copyPastePoint.y || __editVisibleArea.y + __editVisibleArea.height < copyPastePoint.y)
2048 if (copyPastePoint.y < __contextMenuHeight)
2050 FloatRectangle cursorRect = GetCursorBoundsF(true);
2052 copyPastePoint.y += cursorRect.height;
2053 __contextMenuAlign = CONTEXT_MENU_CORE_ALIGN_DOWN;
2054 if (__pHandle[HANDLER_TYPE_CENTER])
2056 copyPastePoint.y += __pHandle[HANDLER_TYPE_CENTER]->GetBounds().height;
2061 //Todo: Create API ex)CreateContrexMenuFN
2062 __pCopyPastePopup = _ContextMenu::CreateContextMenuN(copyPastePoint, CONTEXT_MENU_CORE_STYLE_GRID, __contextMenuAlign);
2063 SysTryReturnVoidResult(NID_UI_CTRL, __pCopyPastePopup, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2065 if ( __pEdit->GetTextLength() != 0 && !isPasswordStyle)
2067 if (__pEdit->IsBlocked())
2072 GET_STRING_CONFIG(IDS_TPLATFORM_OPT_COPY, copyText);
2073 GET_STRING_CONFIG(IDS_TPLATFORM_OPT_CUT, cutText);
2075 __pCopyPastePopup->AddItem(copyText, COPY_PASTE_COPY_ID, null, null, null);
2076 if (!__pEditPresenter->IsViewModeEnabled())
2078 __pCopyPastePopup->AddItem(cutText, COPY_PASTE_CUT_ID, null, null, null);
2084 String selectAllText;
2086 GET_STRING_CONFIG(IDS_TPLATFORM_OPT_SELECT, selectText);
2087 GET_STRING_CONFIG(IDS_TPLATFORM_OPT_SELECT_ALL, selectAllText);
2089 __pCopyPastePopup->AddItem(selectText, COPY_PASTE_SELECT_ID, null, null, null);
2090 __pCopyPastePopup->AddItem(selectAllText, COPY_PASTE_SELECT_ALL_ID, null, null, null);
2096 if (!__pEditPresenter->IsViewModeEnabled())
2099 String clipboardText;
2101 GET_STRING_CONFIG(IDS_TPLATFORM_OPT_PASTE, pasteText);
2102 GET_STRING_CONFIG(IDS_TPLATFORM_OPT_CLIPBOARD, clipboardText);
2104 __pCopyPastePopup->AddItem(pasteText, COPY_PASTE_PASTE_ID, null, null, null);
2105 if (!isPasswordStyle && __pEdit->IsKeypadEnabled())
2107 __pCopyPastePopup->AddItem(clipboardText, COPY_PASTE_CLIPBOARD_ID, null, null, null);
2112 __pCopyPastePopup->AddActionEventListener(*this);
2115 Bitmap* pSearchBitmap = null;
2116 Bitmap* pReplacedSearchBitmap = null;
2117 Bitmap* pReplacedSearchPressedBitmap = null;
2119 Color searchPressedColor;
2120 result r = E_SUCCESS;
2122 if (__pEdit->IsBlocked() && !isPasswordStyle)
2124 r = GET_BITMAP_CONFIG_N(EDIT::COPY_PASTE_SEARCH_ICON, BITMAP_PIXEL_FORMAT_ARGB8888, pSearchBitmap);
2125 SysTryReturnVoidResult(NID_UI_CTRL, (r == E_SUCCESS), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2127 GET_COLOR_CONFIG(CONTEXTMENU::ITEM_TEXT_NORMAL, searchColor);
2128 GET_COLOR_CONFIG(CONTEXTMENU::ITEM_TEXT_PRESSED, searchPressedColor);
2130 pReplacedSearchBitmap = _BitmapImpl::GetColorReplacedBitmapN(*pSearchBitmap, Color::GetColor(COLOR_ID_MAGENTA), searchColor);
2131 SysTryCatch(NID_UI_CTRL, pReplacedSearchBitmap, r = GetLastResult(), GetLastResult(),"[%s] Propagating.", GetErrorMessage(GetLastResult()));
2133 pReplacedSearchPressedBitmap = _BitmapImpl::GetColorReplacedBitmapN(*pSearchBitmap, Color::GetColor(COLOR_ID_MAGENTA), searchPressedColor);
2134 SysTryCatch(NID_UI_CTRL, pReplacedSearchPressedBitmap, r = GetLastResult(), GetLastResult(),"[%s] Propagating.", GetErrorMessage(GetLastResult()));
2136 __pCopyPastePopup->AddItem(null, COPY_PASTE_SEARCH_ID, pReplacedSearchBitmap, pReplacedSearchPressedBitmap, null);
2141 delete pSearchBitmap;
2142 pSearchBitmap = null;
2144 if (pReplacedSearchBitmap)
2146 delete pReplacedSearchBitmap;
2147 pReplacedSearchBitmap = null;
2150 if (pReplacedSearchPressedBitmap)
2152 delete pReplacedSearchPressedBitmap;
2153 pReplacedSearchPressedBitmap = null;
2155 __pCopyPastePopup->AddActionEventListener(*this);
2160 delete pSearchBitmap;
2161 pSearchBitmap = null;
2163 delete pReplacedSearchBitmap;
2164 pReplacedSearchBitmap = null;
2171 _EditCopyPasteManager::CreateHandle(void)
2175 if (__pEdit->IsBlocked())
2179 FloatRectangle startRect;
2180 FloatRectangle endRect;
2182 __pEdit->GetBlockRange(start, end);
2184 __pEdit->CalculateAbsoluteCursorBounds(start, startRect);
2185 __pEdit->CalculateAbsoluteCursorBounds(end, endRect);
2187 FloatPoint leftHandler(startRect.x, startRect.y + startRect.height);
2188 FloatPoint rightHandler(endRect.x, endRect.y + endRect.height);
2190 __pHandle[HANDLER_TYPE_LEFT] = _EditCopyPasteHandler::CreateInstanceN(leftHandler, start, this, false, true);
2191 __pHandle[HANDLER_TYPE_RIGHT] = _EditCopyPasteHandler::CreateInstanceN(rightHandler, end, this, false, false);
2195 FloatRectangle centerRect;
2196 __pEdit->CalculateAbsoluteCursorBounds(__pEdit->GetCursorPosition(), centerRect);
2197 FloatPoint centerHandler(centerRect.x, centerRect.y + centerRect.height);
2199 __pHandle[HANDLER_TYPE_CENTER] = _EditCopyPasteHandler::CreateInstanceN(centerHandler, __pEdit->GetCursorPosition(), this, true, true);
2200 #if EDIT_COPY_PASTE_MAGNIFIER
2201 // __pHandle[HANDLER_TYPE_CENTER]->CreateCopyPasteMagnifier();
2207 _EditCopyPasteManager::Show(void)
2209 if (__pHandle[HANDLER_TYPE_CENTER])
2211 if (__pEdit->GetCursorPosition() != __pHandle[HANDLER_TYPE_CENTER]->GetHandlerCursorPosition())
2213 __pHandle[HANDLER_TYPE_CENTER]->SetHandlerCursorPosition(__pEdit->GetCursorPosition());
2215 __pHandle[HANDLER_TYPE_CENTER]->AdjustBounds();
2216 __pHandle[HANDLER_TYPE_CENTER]->CheckReverseStatus();
2217 __pHandle[HANDLER_TYPE_CENTER]->Invalidate();
2218 __pEditPresenter->DrawText();
2221 if (__pHandle[HANDLER_TYPE_LEFT] && __pHandle[HANDLER_TYPE_RIGHT])
2224 __pHandle[HANDLER_TYPE_LEFT]->CheckReverseStatus();
2225 __pHandle[HANDLER_TYPE_RIGHT]->CheckReverseStatus();
2226 __pHandle[HANDLER_TYPE_LEFT]->Invalidate();
2227 __pHandle[HANDLER_TYPE_RIGHT]->Invalidate();
2228 __pEditPresenter->DrawText();
2231 if (__pCopyPastePopup)
2233 __pCopyPastePopup->Open();
2234 __pCopyPastePopup->ReleaseTouchCapture();
2236 _Control* pControl = __pCopyPastePopup->GetOwner();
2239 pControl->UnlockInputEvent();
2245 _EditCopyPasteManager::CheckHandleBounds(const FloatPoint& point)
2247 bool hasCommandButton = false;
2248 bool hasParentForm = false;
2249 bool hasParentPanel = false;
2250 bool showCheck = true;
2251 FloatRectangle commandButtonBounds(0.0f, 0.0f, 0.0f, 0.0f);
2252 FloatRectangle formClientBounds(0.0f, 0.0f, 0.0f, 0.0f);
2253 FloatRectangle panelAbsoulteBounds(0.0f, 0.0f, 0.0f, 0.0f);
2254 FloatRectangle editAbsBounds = __pEdit->GetAbsoluteBoundsF();
2255 FloatRectangle textObjectBounds = __pEditPresenter->GetTextBoundsF();
2257 if (!(__pEdit->GetEditStyle() & EDIT_STYLE_TOKEN))
2259 editAbsBounds.x += textObjectBounds.x;
2260 editAbsBounds.y += textObjectBounds.y;
2261 editAbsBounds.width = textObjectBounds.width;
2263 if (!(__pEdit->GetEditStyle() & EDIT_STYLE_SINGLE_LINE))
2265 editAbsBounds.height = textObjectBounds.height;
2269 _Toolbar* pCommandButton = __pEditPresenter->GetKeypadCommandButton();
2272 commandButtonBounds = pCommandButton->GetAbsoluteBoundsF();
2273 hasCommandButton = true;
2275 _Form* pForm = __pEditPresenter->GetParentForm();
2278 formClientBounds = pForm->GetClientBoundsF();
2279 hasParentForm = true;
2282 _ScrollPanel* pPanel = __pEditPresenter->GetParentPanel();
2285 panelAbsoulteBounds = pPanel->GetAbsoluteBoundsF();
2286 hasParentPanel = true;
2289 if ((!_FloatCompare(editAbsBounds.x, point.x) && (editAbsBounds.x > point.x)) || (!_FloatCompare(point.x, editAbsBounds.x + editAbsBounds.width) && point.x > (editAbsBounds.x + editAbsBounds.width)))
2294 if ((!_FloatCompare(editAbsBounds.y, point.y) && (editAbsBounds.y > point.y)) || (!_FloatCompare(point.y, editAbsBounds.y + editAbsBounds.height) && point.y > (editAbsBounds.y + editAbsBounds.height)))
2298 if (hasParentForm && ((!_FloatCompare(formClientBounds.y, point.y) && formClientBounds.y > point.y) || (!_FloatCompare(point.y, formClientBounds.y + formClientBounds.height) && point.y > (formClientBounds.y + formClientBounds.height))))
2302 if (hasParentPanel && ((!_FloatCompare(panelAbsoulteBounds.y, point.y) && panelAbsoulteBounds.y > point.y) || (!_FloatCompare(point.y, panelAbsoulteBounds.y + panelAbsoulteBounds.height) && point.y > (panelAbsoulteBounds.y + panelAbsoulteBounds.height))))
2306 if (hasCommandButton && commandButtonBounds.Contains(point))
2314 _EditCopyPasteManager::CheckHandlePosition(bool leftHandle, int cursorPosition)
2316 int leftHandlerPosition = __pHandle[HANDLER_TYPE_LEFT]->GetHandlerCursorPosition();
2317 int rightHandlerPosition = __pHandle[HANDLER_TYPE_RIGHT]->GetHandlerCursorPosition();
2321 if (cursorPosition + 1 <= rightHandlerPosition)
2332 if (cursorPosition >= leftHandlerPosition + 1)
2344 _EditCopyPasteManager::RefreshBlock(bool isLeftHandle)
2346 int leftRowIndex = -1;
2347 int leftColumnIndex = -1;
2348 int rightRowIndex = -1;
2349 int rightColumnIndex = -1;
2351 int leftHandlerPos = __pHandle[HANDLER_TYPE_LEFT]->GetHandlerCursorPosition();
2352 int rightHandlerPos = __pHandle[HANDLER_TYPE_RIGHT]->GetHandlerCursorPosition();
2353 __pHandle[HANDLER_TYPE_RIGHT]->GetHandlerRowColumnIndex(leftRowIndex, leftColumnIndex);
2354 __pHandle[HANDLER_TYPE_RIGHT]->GetHandlerRowColumnIndex(rightRowIndex, rightColumnIndex);
2356 __pEditPresenter->SetBlockRange(leftHandlerPos, rightHandlerPos, leftColumnIndex, leftColumnIndex, rightRowIndex, rightColumnIndex);
2358 __pEditPresenter->SetCursorChangedFlag(!isLeftHandle);
2359 __pEditPresenter->DrawText();
2364 _EditCopyPasteManager::GetCursorBoundsF(bool isAbsRect) const
2366 FloatRectangle cursorBounds;
2368 __pEdit->GetCursorBounds(isAbsRect, cursorBounds);
2370 return cursorBounds;
2374 _EditCopyPasteManager::GetCursorPositionAt(const FloatPoint& touchPoint) const
2376 return __pEdit->GetCursorPositionAt(touchPoint);
2380 _EditCopyPasteManager::SetCursorPosition(int position)
2382 return __pEdit->SetCursorPosition(position);
2386 _EditCopyPasteManager::GetCursorPosition(void) const
2388 return __pEdit->GetCursorPosition();
2392 _EditCopyPasteManager::GetHandlerCursorPosition(HandlerType handlerType) const
2394 return __pHandle[handlerType]->GetHandlerCursorPosition();
2398 _EditCopyPasteManager::SendTextBlockEvent(void)
2402 result r = E_SUCCESS;
2404 __pEdit->GetBlockRange(start, end);
2405 if (start != -1 && end != -1)
2407 r = __pEdit->SendTextBlockEvent(start, end);
2408 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
2413 _EditCopyPasteManager::OnActionPerformed(const _Control& source, int actionId)
2415 _Clipboard* pClipBoard = _Clipboard::GetInstance();
2416 SysTryReturnVoidResult(NID_UI_CTRL, pClipBoard, E_SYSTEM, "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2418 ReleaseCopyPastePopup();
2422 case COPY_PASTE_SELECT_ID:
2424 int cursorPos = GetCursorPosition();
2427 __pEdit->GetWordPosition(cursorPos, start, end);
2428 __pEdit->SetBlockRange(start, end);
2429 SendTextBlockEvent();
2433 CreateCopyPastePopup();
2440 case COPY_PASTE_SELECT_ALL_ID:
2442 int textLength = __pEdit->GetTextLength();
2443 __pEdit->SetBlockRange(0, textLength);
2444 SendTextBlockEvent();
2445 __pEditPresenter->UpdateComponentInformation();
2449 CreateCopyPastePopup();
2456 case COPY_PASTE_COPY_ID:
2457 ReleaseCopyPastePopup();
2458 SendCopyPasteEvent(CORE_COPY_PASTE_STATUS_HIDE, CORE_COPY_PASTE_ACTION_COPY);
2461 case COPY_PASTE_CUT_ID:
2462 SendCopyPasteEvent(CORE_COPY_PASTE_STATUS_HIDE, CORE_COPY_PASTE_ACTION_CUT);
2465 case COPY_PASTE_PASTE_ID:
2466 SendCopyPasteEvent(CORE_COPY_PASTE_STATUS_HIDE, CORE_COPY_PASTE_ACTION_PASTE);
2469 case COPY_PASTE_CLIPBOARD_ID:
2470 pClipBoard->ShowPopup(CLIPBOARD_DATA_TYPE_TEXT, *__pEdit);
2471 ReleaseCopyPastePopup();
2472 SendCopyPasteEvent(CORE_COPY_PASTE_STATUS_HIDE, CORE_COPY_PASTE_ACTION_CLIPBOARD);
2474 case COPY_PASTE_SEARCH_ID:
2476 SendCopyPasteEvent(CORE_COPY_PASTE_STATUS_HIDE, CORE_COPY_PASTE_ACTION_SEARCH);
2486 _EditCopyPasteManager::AdjustBounds(void)
2488 if (__pHandle[HANDLER_TYPE_CENTER])
2490 __pHandle[HANDLER_TYPE_CENTER]->AdjustBounds();
2492 if (__pHandle[HANDLER_TYPE_LEFT])
2494 __pHandle[HANDLER_TYPE_LEFT]->AdjustBounds();
2496 if (__pHandle[HANDLER_TYPE_RIGHT])
2498 __pHandle[HANDLER_TYPE_RIGHT]->AdjustBounds();
2503 _EditCopyPasteManager::LaunchSearch(void)
2505 result r = E_SUCCESS;
2508 __pEdit->GetBlockRange(start, end);
2509 String blockText = __pEditPresenter->GetText(start, end-1);
2511 _AppMessageImpl msg;
2513 msg.AddData(APPSVC_DATA_KEYWORD, blockText);
2514 r = _AppControlManager::GetInstance()->LaunchPkg(msg, null, APPSVC_OPERATION_SEARCH, null, null, 0, 0);
2518 _EditCopyPasteManager::GetTextBlockReleaseFlag(void) const
2520 return __needToReleaseBlock;
2524 _EditCopyPasteManager::SetTextBlockReleaseFlag(bool enabled)
2526 __needToReleaseBlock = enabled;
2530 _EditCopyPasteManager::IsCopyPasteHandleExist(void) const
2532 if (__pHandle[HANDLER_TYPE_CENTER] || (__pHandle[HANDLER_TYPE_LEFT] && __pHandle[HANDLER_TYPE_RIGHT]))
2543 _EditCopyPasteManager::IsCopyPasteSingleHandleExist(void) const
2545 if (__pHandle[HANDLER_TYPE_CENTER])
2556 _EditCopyPasteManager::UpdateCopyPasteMagnifier(void)
2558 for (int i = 0; i < HANDLER_TYPE_MAX; i++)
2562 __pHandle[i]->UpdateCopyPasteMagnifier();
2568 _EditCopyPasteManager::GetEdit(void) const
2574 _EditCopyPasteManager::MoveHandler(HandlerMoveType moveType)
2576 if (!__pHandle[HANDLER_TYPE_RIGHT] || ! __pHandle[HANDLER_TYPE_LEFT])
2581 int leftHandlerPosition = __pHandle[HANDLER_TYPE_LEFT]->GetHandlerCursorPosition();
2582 int rightHandlerPosition = __pHandle[HANDLER_TYPE_RIGHT]->GetHandlerCursorPosition();
2583 int textLength = __pEdit->GetTextLength();
2584 FloatRectangle cursorBounds;
2585 int newCursorPosition;
2586 __pEdit->GetCursorBounds(false, cursorBounds);
2587 FloatPoint cursorPoint(cursorBounds.x, cursorBounds.y);
2589 TextObject* pTextObject = __pEditPresenter->GetTextObject();
2593 case HANDLER_MOVE_TYPE_LEFT:
2594 if (leftHandlerPosition < rightHandlerPosition-1)
2596 __pHandle[HANDLER_TYPE_RIGHT]->SetHandlerCursorPosition(--rightHandlerPosition);
2598 __pHandle[HANDLER_TYPE_RIGHT]->CheckReverseStatus();
2599 __pHandle[HANDLER_TYPE_RIGHT]->Invalidate();
2606 case HANDLER_MOVE_TYPE_UP:
2607 cursorPoint.y -= cursorBounds.height/2.0f;
2608 newCursorPosition = GetCursorPositionAt(cursorPoint);
2610 if (newCursorPosition <= 0)
2612 int curCursorLine = pTextObject->GetLineIndexAtTextIndex(pTextObject->GetCursorIndex());
2614 if (curCursorLine !=0 )
2616 int offset = rightHandlerPosition - pTextObject->GetFirstTextIndexAt(curCursorLine);
2617 int firstTextIndex = pTextObject->GetFirstTextIndexAt(curCursorLine-1);
2618 newCursorPosition = offset + firstTextIndex;
2619 int textLength = pTextObject->GetTextLengthAt(curCursorLine-1);
2620 if (offset > textLength)
2622 newCursorPosition = firstTextIndex+textLength;
2625 if (leftHandlerPosition >= newCursorPosition)
2627 newCursorPosition = leftHandlerPosition + 1;
2632 if (newCursorPosition >= 0 && leftHandlerPosition < newCursorPosition)
2634 __pHandle[HANDLER_TYPE_RIGHT]->SetHandlerCursorPosition(newCursorPosition);
2636 __pHandle[HANDLER_TYPE_RIGHT]->CheckReverseStatus();
2637 __pHandle[HANDLER_TYPE_RIGHT]->Invalidate();
2644 case HANDLER_MOVE_TYPE_DOWN:
2645 cursorPoint.y += cursorBounds.height + cursorBounds.height/2.0f;
2646 newCursorPosition = GetCursorPositionAt(cursorPoint);
2648 if (newCursorPosition < 0)
2650 int curCursorLine = pTextObject->GetLineIndexAtTextIndex(pTextObject->GetCursorIndex());
2651 int totalLine = pTextObject->GetTotalLineCount();
2652 if (curCursorLine < totalLine - 1)
2654 int offset = rightHandlerPosition - pTextObject->GetFirstTextIndexAt(curCursorLine);
2655 int firstTextIndex = pTextObject->GetFirstTextIndexAt(curCursorLine+1);
2656 newCursorPosition = offset + firstTextIndex;
2657 int textLength = pTextObject->GetTextLengthAt(curCursorLine+1);
2658 if (offset > textLength)
2660 newCursorPosition = firstTextIndex+textLength;
2664 else if (curCursorLine == totalLine - 1)
2666 int firstTextIndex = pTextObject->GetFirstTextIndexAt(curCursorLine);
2667 int textLength = pTextObject->GetTextLengthAt(curCursorLine);
2668 newCursorPosition = firstTextIndex + textLength;
2672 if (newCursorPosition >= 0)
2674 __pHandle[HANDLER_TYPE_RIGHT]->SetHandlerCursorPosition(newCursorPosition);
2676 __pHandle[HANDLER_TYPE_RIGHT]->CheckReverseStatus();
2677 __pHandle[HANDLER_TYPE_RIGHT]->Invalidate();
2684 case HANDLER_MOVE_TYPE_RIGHT:
2685 if (textLength >= rightHandlerPosition+1)
2687 __pHandle[HANDLER_TYPE_RIGHT]->SetHandlerCursorPosition(++rightHandlerPosition);
2689 __pHandle[HANDLER_TYPE_RIGHT]->CheckReverseStatus();
2690 __pHandle[HANDLER_TYPE_RIGHT]->Invalidate();
2701 ReleaseCopyPastePopup();
2702 __isHandlerMoving = true;
2707 _EditCopyPasteManager::IsHandlerMovingEnabled(void) const
2709 return __isHandlerMoving;
2713 _EditCopyPasteManager::SetHandlerMovingEnabled(bool enabled)
2715 __isHandlerMoving = enabled;
2719 _EditCopyPasteManager::GetEditVisibleArea(void) const
2721 return _CoordinateSystemUtils::ConvertToInteger(GetEditVisibleAreaF());
2725 _EditCopyPasteManager::GetEditVisibleAreaF(void) const
2727 return __editVisibleArea;
2731 _EditCopyPasteManager::GetCopyPastePopup(void) const
2733 return __pCopyPastePopup;
2737 _EditCopyPasteManager::GetHandlerRowColumnIndex(bool singleHandler, bool leftHandler, int& rowIndex, int& columnIndex) const
2739 HandlerType handlerType = HANDLER_TYPE_MAX;
2742 handlerType = HANDLER_TYPE_CENTER;
2744 else if (leftHandler)
2746 handlerType = HANDLER_TYPE_LEFT;
2750 handlerType = HANDLER_TYPE_RIGHT;
2753 if (__pHandle[handlerType])
2755 __pHandle[handlerType]->GetHandlerRowColumnIndex(rowIndex, columnIndex);
2766 }}} // Tizen::Ui::Controls