2 // Open Service Platform
3 // Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
5 // Licensed under the Flora License, Version 1.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://floralicense.org/license/
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 <FGrp_BitmapImpl.h>
27 #include "FUi_Clipboard.h"
28 #include "FUi_ClipboardItem.h"
29 #include "FUi_EcoreEvasMgr.h"
30 #include "FUiCtrl_EditCopyPasteManager.h"
31 #include "FUiCtrl_EditCopyPasteEvent.h"
32 #include "FUiCtrl_EditPresenter.h"
33 #include "FUiCtrl_Form.h"
34 #include "FUiCtrl_Frame.h"
37 #if defined(MULTI_WINDOW)
38 #include "FUi_EcoreEvas.h"
39 #include "FUi_Window.h"
40 using namespace Tizen::Ui;
43 using namespace Tizen::App;
44 using namespace Tizen::Base;
45 using namespace Tizen::Base::Runtime;
46 using namespace Tizen::Graphics;
47 using namespace Tizen::Graphics::_Text;
48 using namespace Tizen::Ui::Animations;
50 namespace Tizen { namespace Ui { namespace Controls
53 const int COPY_PASTE_SELECT_ID = 231;
54 const int COPY_PASTE_SELECT_ALL_ID = 232;
55 const int COPY_PASTE_COPY_ID = 233;
56 const int COPY_PASTE_CUT_ID = 234;
57 const int COPY_PASTE_PASTE_ID = 235;
58 const int COPY_PASTE_CLIPBOARD_ID = 236;
61 * @class _EditCopyPasteHandler
62 * @brief This class defines the common behavior for the %_EditCopyPasteHandler.
65 class _EditCopyPasteHandler
67 , virtual public IEventListener
68 , virtual public _IUiEventListener
69 , virtual public _IUiEventPreviewer
75 * This is the default class constructor.
78 _EditCopyPasteHandler(const Point& point, int handlerCursorPos, _EditCopyPasteManager* pCopyPasteManager, bool singleHandler, bool leftHandler);
81 * This is the default class destructor.
84 virtual ~_EditCopyPasteHandler(void);
88 static _EditCopyPasteHandler* CreateInstanceN(const Point& point, int handlerCursorPos, _EditCopyPasteManager* pCopyPasteManager, bool singleHandler, bool leftHandler = true);
89 int GetHandlerCursorPosition(void) const;
90 void SetHandlerCursorPosition(int handlerCursorPos);
91 void SetLeftHandler(bool set);
92 void AdjustBounds(void);
93 #if defined(MULTI_WINDOW)
94 Bitmap* GetHandlerBitmap(void) const;
98 virtual void OnDraw(void);
99 virtual bool OnTouchPressed(const _Control& source, const _TouchInfo& touchinfo);
100 virtual bool OnTouchMoved(const _Control& source, const _TouchInfo& touchinfo);
101 virtual bool OnTouchReleased(const _Control& source, const _TouchInfo& touchinfo);
103 virtual bool IsActivatedOnOpen(void) const;
106 _EditCopyPasteHandler(const _EditCopyPasteHandler& value);
107 _EditCopyPasteHandler& operator =(const _EditCopyPasteHandler& value);
111 _VisualElement* __pRoot;
112 Bitmap* __pHandlerBitmap;
113 Bitmap* __pHandlerPressedBitmap;
114 Point __touchPressedPoint;
115 _EditCopyPasteManager* __pCopyPasteManager;
117 int __handlerCursorPos;
118 bool __isTouchPressed;
119 bool __isReverseBitmap;
120 }; // _EditCopyPasteHandler
122 #if defined(MULTI_WINDOW)
124 _EditCopyPasteHandler::GetHandlerBitmap(void) const
126 return __pHandlerBitmap;
130 _EditCopyPasteHandler::_EditCopyPasteHandler(const Point& point, int handlerCursorPos, _EditCopyPasteManager* pCopyPasteManager, bool singleHandler, bool leftHandler)
132 , __pHandlerBitmap(null)
133 , __pHandlerPressedBitmap(null)
134 , __touchPressedPoint(0, 0)
135 , __pCopyPasteManager(pCopyPasteManager)
136 , __leftHandler(leftHandler)
137 , __handlerCursorPos(handlerCursorPos)
138 , __isTouchPressed(false)
139 , __isReverseBitmap(false)
143 __pRoot = GetVisualElement();
144 __pRoot->SetSurfaceOpaque(false);
146 Point handlerPoint(point);
150 GET_BITMAP_CONFIG_N(EDIT::COPY_PASTE_ICON_LEFT_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, __pHandlerBitmap);
151 handlerPoint.x = handlerPoint.x - (__pHandlerBitmap->GetWidth() / 2);
157 GET_BITMAP_CONFIG_N(EDIT::COPY_PASTE_ICON_LEFT_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, __pHandlerBitmap);
158 GET_BITMAP_CONFIG_N(EDIT::COPY_PASTE_ICON_LEFT_PRESSED, BITMAP_PIXEL_FORMAT_ARGB8888, __pHandlerPressedBitmap);
159 handlerPoint.x = handlerPoint.x - __pHandlerBitmap->GetWidth();
163 GET_BITMAP_CONFIG_N(EDIT::COPY_PASTE_ICON_RIGHT_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, __pHandlerBitmap);
164 GET_BITMAP_CONFIG_N(EDIT::COPY_PASTE_ICON_RIGHT_PRESSED, BITMAP_PIXEL_FORMAT_ARGB8888, __pHandlerPressedBitmap);
168 Rectangle bounds(handlerPoint.x, handlerPoint.y, __pHandlerBitmap->GetWidth(), __pHandlerBitmap->GetHeight());
169 #if !defined(MULTI_WINDOW)
171 _Window::Open(false);
173 _Edit* pEdit = __pCopyPasteManager->GetEdit();
174 SysTryReturnVoidResult(NID_UI_CTRL, pEdit, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
176 _EditPresenter* pEditPresenter = pEdit->GetPresenter();
177 SysTryReturnVoidResult(NID_UI_CTRL, pEdit, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
179 _Form* pParentForm = pEditPresenter->GetParentForm();
182 SetOwner(pParentForm);
187 _Frame* pCurrentFrame = dynamic_cast <_Frame*>(_ControlManager::GetInstance()->GetCurrentFrame());
190 pForm = pCurrentFrame->GetCurrentForm();
197 SetOwner(pCurrentFrame);
203 _EditCopyPasteHandler::~_EditCopyPasteHandler(void)
205 if (__pHandlerBitmap)
207 delete __pHandlerBitmap;
208 __pHandlerBitmap = null;
210 if (__pHandlerPressedBitmap)
212 delete __pHandlerPressedBitmap;
213 __pHandlerPressedBitmap = null;
217 _EditCopyPasteHandler*
218 _EditCopyPasteHandler::CreateInstanceN(const Point& point, int handlerCursorPos, _EditCopyPasteManager* pCopyPasteManager, bool singleHandler, bool leftHandler)
220 _EditCopyPasteHandler* pCopyPasteHandler = new (std::nothrow) _EditCopyPasteHandler(point, handlerCursorPos, pCopyPasteManager, singleHandler, leftHandler);
221 SysTryReturn(NID_UI_CTRL, pCopyPasteHandler != null, null, E_OUT_OF_MEMORY, "pContextMenu is null");
223 #if defined(MULTI_WINDOW)
224 Point handlerPoint(point);
225 Rectangle bounds(0, 0, 0, 0);
226 Bitmap* pHandlerBitmap = pCopyPasteHandler->GetHandlerBitmap();
228 result r = pCopyPasteHandler->CreateRootVisualElement();
229 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
231 pCopyPasteHandler->SetActivationEnabled(false);
235 handlerPoint.x = handlerPoint.x - (pHandlerBitmap->GetWidth() / 2);
241 handlerPoint.x = handlerPoint.x - pHandlerBitmap->GetWidth();
245 bounds.x = handlerPoint.x;
246 bounds.y = handlerPoint.y;
247 bounds.width = pHandlerBitmap->GetWidth();
248 bounds.height = pHandlerBitmap->GetHeight();
250 pCopyPasteHandler->SetBounds(bounds);
252 pCopyPasteHandler->Open(false);
255 return pCopyPasteHandler;
257 #if defined(MULTI_WINDOW)
259 pCopyPasteHandler->Close();
260 delete pCopyPasteHandler;
267 _EditCopyPasteHandler::GetHandlerCursorPosition(void) const
269 return __handlerCursorPos;
273 _EditCopyPasteHandler::SetHandlerCursorPosition(int handlerCursorPos)
275 __handlerCursorPos = handlerCursorPos;
279 _EditCopyPasteHandler::SetLeftHandler(bool set)
285 _EditCopyPasteHandler::AdjustBounds(void)
287 int previousCursorPos;
288 Rectangle cursorRect;
289 Rectangle rect = GetBounds();
291 previousCursorPos = __pCopyPasteManager->GetCursorPosition();
292 __pCopyPasteManager->SetCursorPosition(__handlerCursorPos);
293 cursorRect = __pCopyPasteManager->GetCursorBounds(true);
294 __pCopyPasteManager->SetCursorPosition(previousCursorPos);
296 rect.x = cursorRect.x;
297 rect.y = cursorRect.y + cursorRect.height;
301 rect.x = rect.x - __pHandlerBitmap->GetWidth();
308 _EditCopyPasteHandler::OnDraw(void)
310 Canvas* pCanvas = GetCanvasN();
315 pCanvas->SetBackgroundColor(Color(0, 0, 0, 0));
317 if (__isTouchPressed)
319 if (__pHandlerPressedBitmap->IsNinePatchedBitmap())
321 pCanvas->DrawNinePatchedBitmap(pCanvas->GetBounds(), *__pHandlerPressedBitmap);
325 pCanvas->DrawBitmap(pCanvas->GetBounds(), *__pHandlerPressedBitmap);
330 if (__pHandlerBitmap->IsNinePatchedBitmap())
332 pCanvas->DrawNinePatchedBitmap(pCanvas->GetBounds(), *__pHandlerBitmap);
336 pCanvas->DrawBitmap(pCanvas->GetBounds(), *__pHandlerBitmap);
344 _EditCopyPasteHandler::OnTouchPressed(const _Control& source, const _TouchInfo& touchinfo)
346 __pCopyPasteManager->ReleaseCopyPastePopup();
347 __touchPressedPoint = touchinfo.GetCurrentPosition();
348 __isTouchPressed = true;
354 _EditCopyPasteHandler::OnTouchReleased(const _Control& source, const _TouchInfo& touchinfo)
356 __isTouchPressed = false;
357 __pCopyPasteManager->CreateCopyPastePopup();
358 __pCopyPasteManager->Show();
359 __pCopyPasteManager->SendTextBlockEvent();
365 _EditCopyPasteHandler::OnTouchMoved(const _Control& source, const _TouchInfo& touchinfo)
368 int previousCursorPos;
369 Rectangle cursorRect;
370 Rectangle absCursorRect;
371 Rectangle rect = GetBounds();
372 Point point = touchinfo.GetCurrentPosition();
375 _Edit* pEdit = __pCopyPasteManager->GetEdit();
376 SysTryReturn(NID_UI_CTRL, pEdit, false, E_INVALID_STATE, "[E_INVALID_STATE] pEdit is null.\n");
378 _EditPresenter* pEditPresenter = pEdit->GetPresenter();
379 SysTryReturn(NID_UI_CTRL, pEditPresenter, false, E_INVALID_STATE, "[E_INVALID_STATE] pEditPresenter is null.\n");
381 if (__touchPressedPoint.x == point.x && __touchPressedPoint.y == point.y)
386 previousCursorPos = __pCopyPasteManager->GetCursorPosition();
387 __pCopyPasteManager->SetCursorPosition(__handlerCursorPos);
388 cursorRect = __pCopyPasteManager->GetCursorBounds(false);
389 absCursorRect = __pCopyPasteManager->GetCursorBounds(true);
390 touchPoint.x = cursorRect.x + (point.x - __touchPressedPoint.x);
391 touchPoint.y = cursorRect.y + cursorRect.height/2 + (point.y - __touchPressedPoint.y);
392 cursorPos = __pCopyPasteManager->GetCursorPositionAt(touchPoint);
394 if (cursorPos == -1 || (!__pCopyPasteManager->CheckHandleBounds(Point(absCursorRect.x, absCursorRect.y + absCursorRect.height))))
396 TextObject* pTextObject = pEditPresenter->GetTextObject();
397 int curCursorLine = pTextObject->GetLineIndexAtTextIndex(__handlerCursorPos);
398 int totalLine = pTextObject->GetTotalLineCount();
399 Rectangle editVisibleArea = __pCopyPasteManager->GetEditVisibleArea();
403 if (editVisibleArea.y <= absCursorRect.y) // DownSide
405 if (curCursorLine < totalLine - 1)
407 int offset = __handlerCursorPos - pTextObject->GetFirstTextIndexAt(curCursorLine);
408 int firstTextIndex = pTextObject->GetFirstTextIndexAt(curCursorLine+1);
409 cursorPos = offset + firstTextIndex;
410 int textLength = pTextObject->GetTextLengthAt(curCursorLine+1);
411 if (offset > textLength)
413 cursorPos = firstTextIndex+textLength;
416 if (cursorPos != -1 && __leftHandler)
418 int line = pTextObject->GetFirstDisplayLineIndex();
419 pTextObject->SetFirstDisplayLineIndex(line+1);
420 __pCopyPasteManager->SetCursorPosition(cursorPos);
421 absCursorRect = __pCopyPasteManager->GetCursorBounds(true);
422 int firstDisplayY = pTextObject->GetFirstDisplayPositionY();
423 int gapY = absCursorRect.y + absCursorRect.height - (editVisibleArea.y + editVisibleArea.height);
427 pTextObject->SetFirstDisplayPositionY(firstDisplayY + gapY + tempMargin);
434 if (curCursorLine !=0 )
436 int offset = __handlerCursorPos - pTextObject->GetFirstTextIndexAt(curCursorLine);
437 int firstTextIndex = pTextObject->GetFirstTextIndexAt(curCursorLine-1);
438 cursorPos = offset + firstTextIndex;
439 int textLength = pTextObject->GetTextLengthAt(curCursorLine-1);
440 if (offset > textLength)
442 cursorPos = firstTextIndex+textLength;
445 if (cursorPos != -1 && __leftHandler)
447 int line = pTextObject->GetFirstDisplayLineIndex();
450 pTextObject->SetFirstDisplayLineIndexFromTextIndex(cursorPos);
454 pTextObject->SetFirstDisplayLineIndex(line-1);
462 if (pEdit->GetEditStyle() & EDIT_STYLE_SINGLE_LINE)
464 if (point.x - __touchPressedPoint.x >= 0) // RightSide
466 if (__handlerCursorPos == pEditPresenter->GetTextLength())
468 cursorPos = __handlerCursorPos;
472 cursorPos = __handlerCursorPos + 1;
474 if (__leftHandler && (cursorPos == pEditPresenter->GetTextLength()))
476 cursorPos = __handlerCursorPos;
482 if (__handlerCursorPos != 0)
484 cursorPos = __handlerCursorPos - 1;
488 pTextObject->SetFirstDisplayLineIndexFromTextIndex(cursorPos);
493 if (point.y < 0 || (point.y > GetBounds().height))
500 if (point.y - __touchPressedPoint.y >= 0) // DownSide
502 if (curCursorLine < totalLine - 1)
504 int offset = __handlerCursorPos - pTextObject->GetFirstTextIndexAt(curCursorLine);
505 int firstTextIndex = pTextObject->GetFirstTextIndexAt(curCursorLine+1);
506 cursorPos = offset + firstTextIndex;
507 int textLength = pTextObject->GetTextLengthAt(curCursorLine+1);
508 if (offset > textLength)
510 cursorPos = firstTextIndex+textLength;
513 if (cursorPos != -1 && __leftHandler)
515 int line = pTextObject->GetFirstDisplayLineIndex();
518 pTextObject->SetFirstDisplayLineIndexFromTextIndex(cursorPos);
522 pTextObject->SetFirstDisplayLineIndex(line+1);
529 if (curCursorLine !=0 )
531 int offset = __handlerCursorPos - pTextObject->GetFirstTextIndexAt(curCursorLine);
532 int firstTextIndex = pTextObject->GetFirstTextIndexAt(curCursorLine-1);
533 cursorPos = offset + firstTextIndex;
534 int textLength = pTextObject->GetTextLengthAt(curCursorLine-1);
535 if (offset > textLength)
537 cursorPos = firstTextIndex+textLength;
540 if (!__leftHandler && cursorPos <= __pCopyPasteManager->GetHandlerCursorPosition(false))
542 cursorPos = __pCopyPasteManager->GetHandlerCursorPosition(false) + 1;
545 if (cursorPos != -1 && __leftHandler)
547 int line = pTextObject->GetFirstDisplayLineIndex();
550 pTextObject->SetFirstDisplayLineIndexFromTextIndex(cursorPos);
554 pTextObject->SetFirstDisplayLineIndex(line-1);
563 if (cursorPos == -1 || __handlerCursorPos == cursorPos ||!__pCopyPasteManager->CheckHandlePosition(__leftHandler, cursorPos))
565 __pCopyPasteManager->SetCursorPosition(previousCursorPos);
566 pEditPresenter->SetCursorChangedFlag(!__leftHandler);
570 __pCopyPasteManager->SetCursorPosition(cursorPos);
572 cursorRect = __pCopyPasteManager->GetCursorBounds(true);
574 rect.x = cursorRect.x;
575 rect.y = cursorRect.y + cursorRect.height;
579 rect.x = rect.x - __pHandlerBitmap->GetWidth();
582 __handlerCursorPos = cursorPos;
586 __pCopyPasteManager->RefreshBlock(true, __leftHandler);
592 _EditCopyPasteHandler::IsActivatedOnOpen(void) const
597 _EditCopyPasteManager::_EditCopyPasteManager(_Edit& parenEdit)
598 : __pCopyPastePopup(null)
599 , __contextMenuAlign(CONTEXT_MENU_CORE_ALIGN_UP)
600 , __pCoreCopyPasteEvent(null)
601 , __pEdit(&parenEdit)
602 , __contextMenuHeight(0)
603 , __needToReleaseBlock(true)
604 , __isHandlerMoving(false)
605 , __editVisibleArea(0, 0, 0, 0)
607 __pHandle[HANDLER_TYPE_LEFT] = null;
608 __pHandle[HANDLER_TYPE_RIGHT] = null;
610 if (__pEdit->IsBlocked())
616 _EditCopyPasteManager::~_EditCopyPasteManager(void)
620 if (__pCoreCopyPasteEvent)
622 delete __pCoreCopyPasteEvent;
623 __pCoreCopyPasteEvent = null;
628 _EditCopyPasteManager::Release(void)
630 if (__pCopyPastePopup)
632 __pCopyPastePopup->Close();
633 delete __pCopyPastePopup;
634 __pCopyPastePopup = null;
637 if (__pHandle[HANDLER_TYPE_LEFT])
639 __pHandle[HANDLER_TYPE_LEFT]->Close();
640 delete __pHandle[HANDLER_TYPE_LEFT];
641 __pHandle[HANDLER_TYPE_LEFT] = null;
644 if (__pHandle[HANDLER_TYPE_RIGHT])
646 __pHandle[HANDLER_TYPE_RIGHT]->Close();
647 delete __pHandle[HANDLER_TYPE_RIGHT];
648 __pHandle[HANDLER_TYPE_RIGHT] = null;
653 _EditCopyPasteManager::ReleaseCopyPastePopup(void)
655 if (__pCopyPastePopup)
657 __pCopyPastePopup->Close();
658 delete __pCopyPastePopup;
659 __pCopyPastePopup = null;
664 _EditCopyPasteManager::IsCopyPastePopup(const _Control& control) const
666 if (__pHandle[HANDLER_TYPE_LEFT] == &control)
671 if (__pHandle[HANDLER_TYPE_RIGHT] == &control)
676 if (__pCopyPastePopup == &control)
685 _EditCopyPasteManager::AddCopyPasteEventListener(const _IEditCopyPasteEventListener& listener)
689 if (__pCoreCopyPasteEvent == null)
691 __pCoreCopyPasteEvent = _EditCopyPasteEvent::CreateInstanceN(*this);
692 SysTryReturn(NID_UI_CTRL, __pCoreCopyPasteEvent, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] System error occurred.\n");
695 return __pCoreCopyPasteEvent->AddListener(listener);
699 _EditCopyPasteManager::SendCopyPasteEvent(CoreCopyPasteStatus status, CoreCopyPasteAction action)
701 if (__pCoreCopyPasteEvent)
703 IEventArg* pCopyPasteEventArg = _EditCopyPasteEvent::CreateCopyPasteEventArgN(status, action);
704 SysTryReturn(NID_UI_CTRL, pCopyPasteEventArg, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Unable to create _LinkEventArg.");
706 __pCoreCopyPasteEvent->Fire(*pCopyPasteEventArg);
713 _EditCopyPasteManager::CreateCopyPastePopup(void)
715 if (__pCopyPastePopup)
717 __pCopyPastePopup->Close();
718 delete __pCopyPastePopup;
719 __pCopyPastePopup = null;
724 Rectangle editAbsRect;
725 Rectangle editShowAreaAbsRect;
726 Rectangle commandButtonBounds;
727 Rectangle keypadBounds(0, 0, 0, 0);
728 bool keypadExist = false;
729 bool commandButtonExist = false;
730 Rectangle cursorRect = GetCursorBounds(true);
732 int contextMenuHeight = 0;
733 int contextMenuTopMargin = 0;
734 int contextMenuBottomMargin = 0;
735 int contextMenuArrowHeight = 0;
736 int contextMenuLeftMargin = 0;
737 int contextMenuArrowWidth = 0;
738 int handlerHeight = 0;
739 bool isPasswordStyle = false;
740 if (__pEdit->GetEditStyle() & EDIT_STYLE_PASSWORD)
742 isPasswordStyle = true;
745 _ControlOrientation orientation = __pEdit->GetOrientation();
747 GET_SHAPE_CONFIG(EDIT::COPYPASTE_HANDLER_HEIGHT, orientation, handlerHeight);
749 GET_SHAPE_CONFIG(CONTEXTMENU::GRID_ITEM_HEIGHT, orientation, contextMenuHeight);
750 GET_SHAPE_CONFIG(CONTEXTMENU::GRID_TOP_MARGIN, orientation, contextMenuTopMargin);
751 GET_SHAPE_CONFIG(CONTEXTMENU::GRID_BOTTOM_MARGIN, orientation, contextMenuBottomMargin);
752 GET_SHAPE_CONFIG(CONTEXTMENU::ARROW_HEIGHT, orientation, contextMenuArrowHeight);
753 GET_SHAPE_CONFIG(CONTEXTMENU::SCREEN_LEFT_MARGIN, orientation, contextMenuLeftMargin);
754 GET_SHAPE_CONFIG(CONTEXTMENU::ARROW_WIDTH, orientation, contextMenuArrowWidth);
756 __contextMenuHeight = contextMenuHeight + contextMenuTopMargin + contextMenuBottomMargin + contextMenuArrowHeight;
757 if (__pEdit->IsClipped() == true && __pEdit->IsViewModeEnabled() == false && __pEdit->GetTextLength() > 0 && orientation == _CONTROL_ORIENTATION_PORTRAIT)
759 __contextMenuHeight = __contextMenuHeight + contextMenuHeight;
762 editAbsRect = __pEdit->GetAbsoluteBounds();
763 _EditPresenter* pEditPresenter = __pEdit->GetPresenter();
764 _Toolbar* pCommandButton = pEditPresenter->GetKeypadCommandButton();
767 commandButtonBounds = pCommandButton->GetAbsoluteBounds();
768 commandButtonExist = true;
770 __pEdit->GetKeypadBounds(keypadBounds);
771 Dimension screenSize(0, 0);
772 screenSize = _ControlManager::GetInstance()->GetScreenSize();
773 if (keypadBounds.y != screenSize.height)
780 editShowAreaAbsRect = editAbsRect;
782 if (commandButtonExist)
784 if (editShowAreaAbsRect.y + editShowAreaAbsRect.height > commandButtonBounds.y)
786 editShowAreaAbsRect.height -= (editShowAreaAbsRect.y + editShowAreaAbsRect.height - commandButtonBounds.y);
791 if (editShowAreaAbsRect.y + editShowAreaAbsRect.height > keypadBounds.y)
793 editShowAreaAbsRect.height -= (editShowAreaAbsRect.y + editShowAreaAbsRect.height - keypadBounds.y);
796 __editVisibleArea = editShowAreaAbsRect;
798 Point copyPastePoint(0, 0);
799 __contextMenuAlign = CONTEXT_MENU_CORE_ALIGN_UP;
801 if (__pEdit->IsBlocked())
805 __pEdit->GetBlockRange(start, end);
806 if (start == -1 || end == -1)
808 SysLog(NID_UI_CTRL, "[EditCopyPasteManager] There is no blocked Range");
812 __pEdit->CalculateAbsoluteCursorBounds(start, startRect);
813 __pEdit->CalculateAbsoluteCursorBounds(end, endRect);
814 if (startRect.x > endRect.x)
816 copyPastePoint.x = endRect.x + (startRect.x - endRect.x)/2;
818 else if (startRect.x < endRect.x)
820 copyPastePoint.x = startRect.x + (endRect.x - startRect.x)/2;
824 copyPastePoint.x = startRect.x;
826 //Both of handlers are located on the top of the Editor.
827 if ( ((startRect.y + startRect.height) < editShowAreaAbsRect.y) && ((endRect.y + endRect.height) < editShowAreaAbsRect.y))
829 SysLog(NID_UI_CTRL, "Both of handlers are located on the top of the Editor.\n");
830 PrintLog(copyPastePoint);
833 //Both of handlers are located on the bottom of the Editor.
834 else if( ((startRect.y + startRect.height) > editShowAreaAbsRect.y + editShowAreaAbsRect.height ) && ((endRect.y + endRect.height) > editShowAreaAbsRect.y + editShowAreaAbsRect.height))
836 SysLog(NID_UI_CTRL, "Both of handlers are located on the bottom of the Editor.\n");
837 PrintLog(copyPastePoint);
840 // Left handler is located on the top of the Editor and Right handler is located on the bottom of the Editor.
841 else if ( ((startRect.y + startRect.height) < editShowAreaAbsRect.y) && ((endRect.y + endRect.height) > (editShowAreaAbsRect.y + editShowAreaAbsRect.height)))
843 copyPastePoint.y = editShowAreaAbsRect.y + editShowAreaAbsRect.height/2;
845 if (copyPastePoint.y < __contextMenuHeight)
847 __contextMenuAlign = CONTEXT_MENU_CORE_ALIGN_DOWN;
851 // Left handler is located on the top of the Editor and Right handler is located on the Editor
852 else if ( ((startRect.y + startRect.height) < editShowAreaAbsRect.y) && ((endRect.y + endRect.height) < (editShowAreaAbsRect.y + editShowAreaAbsRect.height)) )
854 if ( (endRect.y + endRect.height + handlerHeight + __contextMenuHeight) < keypadBounds.y)
856 __contextMenuAlign = CONTEXT_MENU_CORE_ALIGN_DOWN;
857 copyPastePoint.y = endRect.y + endRect.height + handlerHeight;
859 else if (endRect.y - editShowAreaAbsRect.y > __contextMenuHeight)
861 copyPastePoint.y = editShowAreaAbsRect.y + __contextMenuHeight;
863 else if (endRect.y > __contextMenuHeight)
865 copyPastePoint.y = endRect.y;
869 SysLog(NID_UI_CTRL, "There is no space to draw the copy&paste popup\n");
870 PrintLog(copyPastePoint);
874 // Left handler is located on the Editor and Right handler is located on the bottom of the Editor
875 else if ( ((startRect.y + startRect.height) > editShowAreaAbsRect.y) && ((endRect.y + endRect.height) > (editShowAreaAbsRect.y + editShowAreaAbsRect.height)) )
877 if (__contextMenuHeight < startRect.y)
879 copyPastePoint.y = startRect.y;
883 copyPastePoint.y = startRect.y + (editShowAreaAbsRect.y + editShowAreaAbsRect.height - startRect.y)/2;
886 // There is a space on the top of the Editor.
887 else if (__contextMenuHeight < startRect.y)
889 copyPastePoint.y = startRect.y;
891 // There is a space on the bottom of the Editor.
892 else if ( keypadBounds.y > (endRect.y + endRect.height + handlerHeight + __contextMenuHeight))
894 __contextMenuAlign = CONTEXT_MENU_CORE_ALIGN_DOWN;
896 copyPastePoint.y = endRect.y + endRect.height + handlerHeight;
898 // There is no space on the top and bottom of the Editor. The Popup should be drawn on the center of the Editor.
901 if (endRect.y - startRect.y < __contextMenuHeight)
903 SysLog(NID_UI_CTRL, "There is no space to draw the copy&paste popup\n");
904 PrintLog(copyPastePoint);
907 copyPastePoint.y = startRect.y + __contextMenuHeight;
913 Rectangle cursorRect;
914 int cursorPosition = GetCursorPosition();
915 __pEdit->CalculateAbsoluteCursorBounds(cursorPosition, cursorRect);
916 copyPastePoint.x = cursorRect.x;
917 copyPastePoint.y = cursorRect.y;
918 if (copyPastePoint.y < __contextMenuHeight)
920 Rectangle cursorRect = GetCursorBounds(true);
922 copyPastePoint.y += cursorRect.height;
923 __contextMenuAlign = CONTEXT_MENU_CORE_ALIGN_DOWN;
927 __pCopyPastePopup = _ContextMenu::CreateContextMenuN(copyPastePoint, CONTEXT_MENU_CORE_STYLE_GRID, __contextMenuAlign);
928 SysTryReturnVoidResult(NID_UI_CTRL, __pCopyPastePopup, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
930 if ( __pEdit->GetTextLength() != 0 && !isPasswordStyle)
932 if (__pEdit->IsBlocked())
937 GET_STRING_CONFIG(IDS_COM_BODY_COPY, copyText);
938 GET_STRING_CONFIG(IDS_COM_BODY_CUT, cutText);
940 __pCopyPastePopup->AddItem(copyText, COPY_PASTE_COPY_ID, null, null, null);
941 if (!__pEdit->IsViewModeEnabled())
943 __pCopyPastePopup->AddItem(cutText, COPY_PASTE_CUT_ID, null, null, null);
949 String selectAllText;
951 GET_STRING_CONFIG(IDS_COM_SK_SELECT, selectText);
952 GET_STRING_CONFIG(IDS_COM_BODY_SELECT_ALL, selectAllText);
954 __pCopyPastePopup->AddItem(selectText, COPY_PASTE_SELECT_ID, null, null, null);
955 __pCopyPastePopup->AddItem(selectAllText, COPY_PASTE_SELECT_ALL_ID, null, null, null);
959 if (__pEdit->IsClipped() == true)
961 if (!__pEdit->IsViewModeEnabled())
964 String clipboardText;
966 GET_STRING_CONFIG(IDS_COM_BODY_PASTE, pasteText);
967 GET_STRING_CONFIG(IDS_COM_BODY_CLIPBOARD, clipboardText);
969 __pCopyPastePopup->AddItem(pasteText, COPY_PASTE_PASTE_ID, null, null, null);
970 if (!isPasswordStyle)
972 __pCopyPastePopup->AddItem(clipboardText, COPY_PASTE_CLIPBOARD_ID, null, null, null);
977 __pCopyPastePopup->AddActionEventListener(*this);
983 _EditCopyPasteManager::PrintLog(const Point& point)
987 Rectangle editAbsRect;
988 Rectangle keypadBounds;
989 Rectangle editShowAreaAbsRect;
990 Rectangle commandButtonBounds;
991 Rectangle formClientBounds(0, 0, 0, 0);
992 bool hasParentForm = false;
993 bool hasCommandButton = false;
994 Rectangle cursorRect = GetCursorBounds(true);
995 int indicatorHeight = 0;
997 editAbsRect = __pEdit->GetAbsoluteBounds();
998 _EditPresenter* pEditPresenter = __pEdit->GetPresenter();
999 _Toolbar* pCommandButton = pEditPresenter->GetKeypadCommandButton();
1002 commandButtonBounds = pCommandButton->GetAbsoluteBounds();
1003 hasCommandButton = true;
1005 _Form* pForm = pEditPresenter->GetParentForm();
1008 formClientBounds = pForm->GetClientBounds();
1009 hasParentForm = true;
1013 __pEdit->GetBlockRange(start, end);
1014 if (start == -1 || end == -1)
1016 SysLog(NID_UI_CTRL, "[EditCopyPasteManager] There is no blocked Range");
1019 __pEdit->GetKeypadBounds(keypadBounds);
1021 if (pForm && pForm->IsIndicatorVisible())
1023 indicatorHeight = pForm->GetIndicatorBounds().height;
1027 editShowAreaAbsRect = editAbsRect;
1028 if (indicatorHeight)
1030 if (editShowAreaAbsRect.y < indicatorHeight)
1032 editShowAreaAbsRect.y = indicatorHeight;
1036 if (hasCommandButton)
1038 if (editShowAreaAbsRect.y + editShowAreaAbsRect.height > commandButtonBounds.y)
1040 editShowAreaAbsRect.height -= (editShowAreaAbsRect.y + editShowAreaAbsRect.height - commandButtonBounds.y);
1045 if (editShowAreaAbsRect.y + editShowAreaAbsRect.height > keypadBounds.y)
1047 editShowAreaAbsRect.height -= (editShowAreaAbsRect.y + editShowAreaAbsRect.height - keypadBounds.y);
1052 __pEdit->CalculateAbsoluteCursorBounds(start, startRect);
1053 __pEdit->CalculateAbsoluteCursorBounds(end, endRect);
1055 SysLog(NID_UI_CTRL, "copyPastePoint (x=%d), (y=%d)\n", point.x, point.y );
1056 SysLog(NID_UI_CTRL, "startRect (x=%d), (y=%d), (width=%d), (height=%d) \n", startRect.x, startRect.y ,startRect.width, startRect.height);
1057 SysLog(NID_UI_CTRL, "endRect (x=%d), (y=%d), (width=%d), (height=%d) \n", endRect.x, endRect.y ,endRect.width, endRect.height);
1058 SysLog(NID_UI_CTRL, "editAbsRect (x=%d), (y=%d), (width=%d), (height=%d) \n", editAbsRect.x, editAbsRect.y ,editAbsRect.width, editAbsRect.height);
1059 SysLog(NID_UI_CTRL, "editShowAreaAbsRect (x=%d), (y=%d), (width=%d), (height=%d) \n", editShowAreaAbsRect.x, editShowAreaAbsRect.y ,editShowAreaAbsRect.width, editShowAreaAbsRect.height);
1060 SysLog(NID_UI_CTRL, "keypadBounds (x=%d), (y=%d), (width=%d), (height=%d) \n", keypadBounds.x, keypadBounds.y ,keypadBounds.width, keypadBounds.height);
1061 SysLog(NID_UI_CTRL, "commandButtonBounds (x=%d), (y=%d), (width=%d), (height=%d) \n", commandButtonBounds.x, commandButtonBounds.y ,commandButtonBounds.width, commandButtonBounds.height);
1062 SysLog(NID_UI_CTRL, "formClientBounds (x=%d), (y=%d), (width=%d), (height=%d) \n", formClientBounds.x, formClientBounds.y ,formClientBounds.width, formClientBounds.height);
1063 SysLog(NID_UI_CTRL, "contextMenuHeight = %d\n", __contextMenuHeight);
1067 _EditCopyPasteManager::CreateHandle(void)
1071 Rectangle startRect;
1074 __pEdit->GetBlockRange(start, end);
1076 __pEdit->CalculateAbsoluteCursorBounds(start, startRect);
1077 __pEdit->CalculateAbsoluteCursorBounds(end, endRect);
1079 Point leftHandler(startRect.x, startRect.y + startRect.height);
1080 Point rightHandler(endRect.x, endRect.y + endRect.height);
1082 __pHandle[HANDLER_TYPE_LEFT] = _EditCopyPasteHandler::CreateInstanceN(leftHandler, start, this, false, true);
1083 __pHandle[HANDLER_TYPE_RIGHT] = _EditCopyPasteHandler::CreateInstanceN(rightHandler, end, this, false, false);
1087 _EditCopyPasteManager::Show(void)
1089 bool hasParentForm = false;
1090 Rectangle formClientBounds(0, 0, 0, 0);
1091 _EditPresenter* pEditPresenter = __pEdit->GetPresenter();
1093 _Form* pForm = pEditPresenter->GetParentForm();
1096 formClientBounds = pForm->GetClientBounds();
1097 hasParentForm = true;
1100 if (__pHandle[HANDLER_TYPE_LEFT] && __pHandle[HANDLER_TYPE_RIGHT])
1102 CheckVisibleState(true);
1103 CheckVisibleState(false);
1106 if (__pCopyPastePopup)
1108 __pCopyPastePopup->Open();
1109 __pCopyPastePopup->ReleaseTouchCapture();
1111 _Control* pControl = __pCopyPastePopup->GetOwner();
1114 pControl->SetInputEnableState(true);
1120 _EditCopyPasteManager::CheckHandleBounds(const Point& point)
1122 bool hasCommandButton = false;
1123 bool hasParentForm = false;
1124 bool showCheck = true;
1125 Rectangle commandButtonBounds(0, 0, 0, 0);
1126 Rectangle formClientBounds(0, 0, 0, 0);
1127 Rectangle editAbsBounds = __pEdit->GetAbsoluteBounds();
1128 _EditPresenter* pEditPresenter = __pEdit->GetPresenter();
1129 _Toolbar* pCommandButton = pEditPresenter->GetKeypadCommandButton();
1132 commandButtonBounds = pCommandButton->GetAbsoluteBounds();
1133 hasCommandButton = true;
1135 _Form* pForm = pEditPresenter->GetParentForm();
1138 formClientBounds = pForm->GetClientBounds();
1139 hasParentForm = true;
1142 if (editAbsBounds.x > point.x || point.x > (editAbsBounds.x + editAbsBounds.width))
1147 if (editAbsBounds.y > point.y || point.y > (editAbsBounds.y + editAbsBounds.height))
1151 if (hasParentForm && (formClientBounds.y > point.y || point.y > (formClientBounds.y + formClientBounds.height)))
1155 if (hasCommandButton && commandButtonBounds.Contains(point))
1163 _EditCopyPasteManager::CheckHandlePosition(bool leftHandle, int cursorPosition)
1165 int leftHandlerPosition = __pHandle[HANDLER_TYPE_LEFT]->GetHandlerCursorPosition();
1166 int rightHandlerPosition = __pHandle[HANDLER_TYPE_RIGHT]->GetHandlerCursorPosition();
1170 if (cursorPosition + 1 <= rightHandlerPosition)
1181 if (cursorPosition >= leftHandlerPosition + 1)
1193 _EditCopyPasteManager::CheckVisibleState(bool leftHandle)
1197 Point leftHandleXY(__pHandle[HANDLER_TYPE_LEFT]->GetAbsoluteBounds().x + __pHandle[HANDLER_TYPE_LEFT]->GetAbsoluteBounds().width, __pHandle[HANDLER_TYPE_LEFT]->GetAbsoluteBounds().y);
1198 if (!CheckHandleBounds(leftHandleXY))
1200 __pHandle[HANDLER_TYPE_LEFT]->SetVisibleState(false);
1204 __pHandle[HANDLER_TYPE_LEFT]->SetVisibleState(true);
1205 __pHandle[HANDLER_TYPE_LEFT]->Open();
1210 Point rightHandleXY(__pHandle[HANDLER_TYPE_RIGHT]->GetAbsoluteBounds().x, __pHandle[HANDLER_TYPE_RIGHT]->GetAbsoluteBounds().y);
1211 if (!CheckHandleBounds(rightHandleXY))
1213 __pHandle[HANDLER_TYPE_RIGHT]->SetVisibleState(false);
1217 __pHandle[HANDLER_TYPE_RIGHT]->SetVisibleState(true);
1218 __pHandle[HANDLER_TYPE_RIGHT]->Open();
1224 _EditCopyPasteManager::HideHandle(void)
1226 __pEdit->ReleaseTextBlock();
1227 if (__pHandle[HANDLER_TYPE_LEFT])
1229 __pHandle[HANDLER_TYPE_LEFT]->SetVisibleState(false);
1231 if (__pHandle[HANDLER_TYPE_RIGHT])
1233 __pHandle[HANDLER_TYPE_RIGHT]->SetVisibleState(false);
1238 _EditCopyPasteManager::RefreshBlock(bool changeVisibleState, bool isLeftHandle)
1240 int leftHandlerPos = __pHandle[HANDLER_TYPE_LEFT]->GetHandlerCursorPosition();
1241 int rightHandlerPos = __pHandle[HANDLER_TYPE_RIGHT]->GetHandlerCursorPosition();
1243 _EditPresenter* pEditPresenter = __pEdit->GetPresenter();
1244 SysTryReturnVoidResult(NID_UI_CTRL, pEditPresenter, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
1248 pEditPresenter->ScrollPanelToCursorPosition();
1252 pEditPresenter->SetCursorPosition(leftHandlerPos);
1253 pEditPresenter->ScrollPanelToCursorPosition();
1254 pEditPresenter->SetCursorPosition(rightHandlerPos);
1256 __pEdit->SetBlockRange(leftHandlerPos, rightHandlerPos);
1257 pEditPresenter->SetCursorChangedFlag(!isLeftHandle);
1258 pEditPresenter->DrawText();
1260 __pHandle[HANDLER_TYPE_LEFT]->AdjustBounds();
1261 __pHandle[HANDLER_TYPE_RIGHT]->AdjustBounds();
1263 if (changeVisibleState)
1265 CheckVisibleState(!isLeftHandle);
1270 _EditCopyPasteManager::GetCursorBounds(bool isAbsRect) const
1272 Rectangle cursorBounds;
1274 __pEdit->GetCursorBounds(isAbsRect, cursorBounds);
1276 return cursorBounds;
1280 _EditCopyPasteManager::GetCursorPositionAt(const Point& touchPoint) const
1282 return __pEdit->GetCursorPositionAt(touchPoint);
1286 _EditCopyPasteManager::SetCursorPosition(int position)
1288 return __pEdit->SetCursorPosition(position);
1292 _EditCopyPasteManager::GetCursorPosition(void) const
1294 return __pEdit->GetCursorPosition();
1298 _EditCopyPasteManager::GetHandlerCursorPosition(bool rightHandler) const
1300 return __pHandle[rightHandler]->GetHandlerCursorPosition();
1304 _EditCopyPasteManager::SendTextBlockEvent(void)
1308 result r = E_SUCCESS;
1310 __pEdit->GetBlockRange(start, end);
1311 if (start != -1 && end != -1)
1313 r = __pEdit->SendTextBlockEvent(start, end);
1314 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1319 _EditCopyPasteManager::OnActionPerformed(const _Control& source, int actionId)
1321 _Clipboard* pClipBoard = _Clipboard::GetInstance();
1322 SysTryReturnVoidResult(NID_UI_CTRL, pClipBoard, E_SYSTEM, "[%s] Propagating.", GetErrorMessage(GetLastResult()));
1324 _EditPresenter* pEditPresenter = __pEdit->GetPresenter();
1326 ReleaseCopyPastePopup();
1330 case COPY_PASTE_SELECT_ID:
1332 int cursorPos = GetCursorPosition();
1335 __pEdit->GetWordPosition(cursorPos, start, end);
1336 __pEdit->SetBlockRange(start, end);
1337 SendTextBlockEvent();
1341 CreateCopyPastePopup();
1348 case COPY_PASTE_SELECT_ALL_ID:
1350 int textLength = __pEdit->GetTextLength();
1351 __pEdit->SetBlockRange(0, textLength);
1352 SendTextBlockEvent();
1353 pEditPresenter->UpdateComponentInformation();
1357 CreateCopyPastePopup();
1364 case COPY_PASTE_COPY_ID:
1365 SendCopyPasteEvent(CORE_COPY_PASTE_STATUS_HIDE, CORE_COPY_PASTE_ACTION_COPY);
1368 case COPY_PASTE_CUT_ID:
1369 SendCopyPasteEvent(CORE_COPY_PASTE_STATUS_HIDE, CORE_COPY_PASTE_ACTION_CUT);
1372 case COPY_PASTE_PASTE_ID:
1373 SendCopyPasteEvent(CORE_COPY_PASTE_STATUS_HIDE, CORE_COPY_PASTE_ACTION_PASTE);
1376 case COPY_PASTE_CLIPBOARD_ID:
1377 __needToReleaseBlock = false;
1378 pEditPresenter->SetKeypadClosedEventSkipped(true);
1379 pClipBoard->ShowPopup(CLIPBOARD_DATA_TYPE_TEXT, *__pEdit);
1389 _EditCopyPasteManager::ScrollText(int distance)
1391 _EditPresenter* pEditPresenter = __pEdit->GetPresenter();
1392 TextObject* pTextObject = pEditPresenter->GetTextObject();
1394 int newFirstDisplayY = pTextObject->GetFirstDisplayPositionY();
1395 newFirstDisplayY += distance;
1396 int moveLine = pTextObject->GetLineIndexAtPositionY(newFirstDisplayY);
1397 pTextObject->SetFirstDisplayLineIndex(moveLine);
1398 pTextObject->SetFirstDisplayPositionY(newFirstDisplayY);
1404 _EditCopyPasteManager::AdjustBounds(void)
1406 if (__pHandle[HANDLER_TYPE_LEFT])
1408 __pHandle[HANDLER_TYPE_LEFT]->AdjustBounds();
1410 if (__pHandle[HANDLER_TYPE_RIGHT])
1412 __pHandle[HANDLER_TYPE_RIGHT]->AdjustBounds();
1414 if (__pCopyPastePopup)
1421 _EditCopyPasteManager::GetTextBlockReleaseFlag(void) const
1423 return __needToReleaseBlock;
1427 _EditCopyPasteManager::SetTextBlockReleaseFlag(bool enabled)
1429 __needToReleaseBlock = enabled;
1433 _EditCopyPasteManager::GetEdit(void) const
1439 _EditCopyPasteManager::MoveHandler(HandlerMoveType moveType)
1441 if (!__pHandle[HANDLER_TYPE_RIGHT] || ! __pHandle[HANDLER_TYPE_LEFT])
1446 int leftHandlerPosition = __pHandle[HANDLER_TYPE_LEFT]->GetHandlerCursorPosition();
1447 int rightHandlerPosition = __pHandle[HANDLER_TYPE_RIGHT]->GetHandlerCursorPosition();
1448 int textLength = __pEdit->GetTextLength();
1449 Rectangle cursorBounds;
1450 int newCursorPosition;
1451 __pEdit->GetCursorBounds(false, cursorBounds);
1452 Point cursorPoint(cursorBounds.x, cursorBounds.y);
1454 _EditPresenter* pEditPresenter = __pEdit->GetPresenter();
1455 TextObject* pTextObject = pEditPresenter->GetTextObject();
1459 case HANDLER_MOVE_TYPE_LEFT:
1460 if (leftHandlerPosition < rightHandlerPosition-1)
1462 __pHandle[HANDLER_TYPE_RIGHT]->SetHandlerCursorPosition(--rightHandlerPosition);
1463 RefreshBlock(false);
1470 case HANDLER_MOVE_TYPE_UP:
1471 cursorPoint.y -= cursorBounds.height/2;
1472 newCursorPosition = GetCursorPositionAt(cursorPoint);
1474 if (newCursorPosition <= 0)
1476 int curCursorLine = pTextObject->GetLineIndexAtTextIndex(pTextObject->GetCursorIndex());
1478 if (curCursorLine !=0 )
1480 int offset = rightHandlerPosition - pTextObject->GetFirstTextIndexAt(curCursorLine);
1481 int firstTextIndex = pTextObject->GetFirstTextIndexAt(curCursorLine-1);
1482 newCursorPosition = offset + firstTextIndex;
1483 int textLength = pTextObject->GetTextLengthAt(curCursorLine-1);
1484 if (offset > textLength)
1486 newCursorPosition = firstTextIndex+textLength;
1489 if (leftHandlerPosition >= newCursorPosition)
1491 newCursorPosition = leftHandlerPosition + 1;
1496 if (newCursorPosition >= 0 && leftHandlerPosition < newCursorPosition)
1498 __pHandle[HANDLER_TYPE_RIGHT]->SetHandlerCursorPosition(newCursorPosition);
1499 RefreshBlock(false);
1506 case HANDLER_MOVE_TYPE_DOWN:
1507 cursorPoint.y += cursorBounds.height + cursorBounds.height/2;
1508 newCursorPosition = GetCursorPositionAt(cursorPoint);
1510 if (newCursorPosition < 0)
1512 int curCursorLine = pTextObject->GetLineIndexAtTextIndex(pTextObject->GetCursorIndex());
1513 int totalLine = pTextObject->GetTotalLineCount();
1514 if (curCursorLine < totalLine - 1)
1516 int offset = rightHandlerPosition - pTextObject->GetFirstTextIndexAt(curCursorLine);
1517 int firstTextIndex = pTextObject->GetFirstTextIndexAt(curCursorLine+1);
1518 newCursorPosition = offset + firstTextIndex;
1519 int textLength = pTextObject->GetTextLengthAt(curCursorLine+1);
1520 if (offset > textLength)
1522 newCursorPosition = firstTextIndex+textLength;
1526 else if (curCursorLine == totalLine - 1)
1528 int firstTextIndex = pTextObject->GetFirstTextIndexAt(curCursorLine);
1529 int textLength = pTextObject->GetTextLengthAt(curCursorLine);
1530 newCursorPosition = firstTextIndex + textLength;
1534 if (newCursorPosition >= 0)
1536 __pHandle[HANDLER_TYPE_RIGHT]->SetHandlerCursorPosition(newCursorPosition);
1537 RefreshBlock(false);
1544 case HANDLER_MOVE_TYPE_RIGHT:
1545 if (textLength >= rightHandlerPosition+1)
1547 __pHandle[HANDLER_TYPE_RIGHT]->SetHandlerCursorPosition(++rightHandlerPosition);
1548 RefreshBlock(false);
1559 CheckVisibleState(true);
1561 ReleaseCopyPastePopup();
1562 __isHandlerMoving = true;
1567 _EditCopyPasteManager::IsHandlerMovingEnabled(void) const
1569 return __isHandlerMoving;
1573 _EditCopyPasteManager::SetHandlerMovingEnabled(bool enabled)
1575 __isHandlerMoving = enabled;
1579 _EditCopyPasteManager::GetEditVisibleArea(void) const
1581 return __editVisibleArea;
1585 }}} // Tizen::Ui::Controls