fix prevent
[platform/framework/native/uifw.git] / src / ui / controls / FUiCtrl_EditCopyPasteManager.cpp
1 //
2 // Open Service Platform
3 // Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
4 //
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
8 //
9 //     http://www.apache.org/licenses/LICENSE-2.0/
10 //
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.
16 //
17
18 /**
19  * @file                FUiCtrl_EditCopyPasteManager.cpp
20  * @brief               This is the implementation file for the _EditCopyPasteManager class.
21  */
22
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"
38 #include "FUi_Math.h"
39 #include "FUi_Window.h"
40
41 #define EDIT_COPY_PASTE_MAGNIFIER 1
42
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;
51
52 namespace Tizen { namespace Ui { namespace Controls
53 {
54
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;
62
63 class _EditCopyPasteMagnifier
64         : public _Window
65 {
66 public:
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);
78
79 private:
80         _EditCopyPasteMagnifier(const _EditCopyPasteMagnifier& value);
81         _EditCopyPasteMagnifier& operator =(const _EditCopyPasteMagnifier& value);
82
83 private:
84         _EditCopyPasteManager* __pCopyPasteManager;
85         Bitmap* __pMagnifierBitmap;
86         _VisualElement* __pRoot;
87         int __handlerCursorPos;
88         FloatRectangle __windowBounds;
89         int __rowIndex;
90         int __columnIndex;
91 };
92
93 _EditCopyPasteMagnifier::_EditCopyPasteMagnifier(_EditCopyPasteManager* pCopyPasteManager, int handlerCursorPos)
94         : __pCopyPasteManager(pCopyPasteManager)
95         , __pMagnifierBitmap(null)
96         , __pRoot(null)
97         , __handlerCursorPos(handlerCursorPos)
98         , __windowBounds(0.0f, 0.0f, 0.0f, 0.0f)
99         , __rowIndex(-1)
100         , __columnIndex(-1)
101 {
102         AcquireHandle();
103         __pRoot = GetVisualElement();
104         __pRoot->SetSurfaceOpaque(false);
105
106         GET_BITMAP_CONFIG_N(EDIT::COPY_PASTE_MAGNIFIER, BITMAP_PIXEL_FORMAT_ARGB8888, __pMagnifierBitmap);
107 }
108
109 _EditCopyPasteMagnifier::~_EditCopyPasteMagnifier(void)
110 {
111         if (__pMagnifierBitmap)
112         {
113                 delete __pMagnifierBitmap;
114                 __pMagnifierBitmap = null;
115         }
116 }
117
118 Bitmap*
119 _EditCopyPasteMagnifier::GetMagnifierBitmap(void) const
120 {
121         return __pMagnifierBitmap;
122 }
123
124 _EditCopyPasteMagnifier*
125 _EditCopyPasteMagnifier::CreateInstanceN(const FloatPoint& point, int handlerCursorPos, _EditCopyPasteManager* pCopyPasteManager)
126 {
127         _EditCopyPasteMagnifier* pCopyPasteMagnifier = new (std::nothrow) _EditCopyPasteMagnifier(pCopyPasteManager, handlerCursorPos);
128         SysTryReturn(NID_UI_CTRL, pCopyPasteMagnifier != null, null, E_OUT_OF_MEMORY, "pCopyPasteMagnifier is null");
129
130         FloatPoint cursorPoint(point);
131         FloatRectangle bounds(0.0f, 0.0f, 0.0f, 0.0f);
132         float width = 0.0f;
133         float height = 0.0f;
134         _Edit* pEdit = pCopyPasteManager->GetEdit();
135         _ControlOrientation orientation = pEdit->GetOrientation();
136
137         Bitmap* pMagnifierBitmap = pCopyPasteMagnifier->GetMagnifierBitmap();
138         SysTryReturn(NID_UI_CTRL, pMagnifierBitmap != null, null, E_OUT_OF_MEMORY, "pMagnifierBitmap is null");
139
140         result r = pCopyPasteMagnifier->CreateRootVisualElement();
141         SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
142
143         pCopyPasteMagnifier->SetActivationEnabled(false);
144
145         GET_SHAPE_CONFIG(EDIT::COPYPASTE_MAGNIFIER_WIDTH, orientation, width);
146         GET_SHAPE_CONFIG(EDIT::COPYPASTE_MAGNIFIER_HEIGHT, orientation, height);
147
148         bounds = FloatRectangle(cursorPoint.x - width/2, cursorPoint.y - height, width, height);
149         if (bounds.y < 0.0f)
150         {
151                 bounds.y = 0.0f;
152         }
153         pCopyPasteMagnifier->SetBounds(bounds);
154         pCopyPasteMagnifier->Open();
155
156         return pCopyPasteMagnifier;
157
158 CATCH:
159         pCopyPasteMagnifier->Close();
160         delete pCopyPasteMagnifier;
161
162         return null;
163 }
164
165 result
166 _EditCopyPasteMagnifier::OnAttachedToMainTree(void)
167 {
168         result r = E_SUCCESS;
169
170         if (GetOwner() == null)
171         {
172                 _Edit* pEdit = __pCopyPasteManager->GetEdit();
173                 SysTryReturnResult(NID_UI_CTRL, pEdit, GetLastResult(), "Unable to get pEdit.");
174
175                 _EditPresenter* pEditPresenter = pEdit->GetPresenter();
176                 SysTryReturnResult(NID_UI_CTRL, pEdit, GetLastResult(), "Unable to get pEditPresenter.");
177
178                 _Form* pParentForm = pEditPresenter->GetParentForm();
179                 if (pParentForm)
180                 {
181                         SetOwner(pParentForm);
182                 }
183                 else
184                 {
185                         _Form* pForm = null;
186                         _Frame* pCurrentFrame = dynamic_cast <_Frame*>(_ControlManager::GetInstance()->GetCurrentFrame());
187                         if (pCurrentFrame)
188                         {
189                                 pForm = pCurrentFrame->GetCurrentForm();
190                                 if (pForm)
191                                 {
192                                         SetOwner(pForm);
193                                 }
194                                 else
195                                 {
196                                         SetOwner(pCurrentFrame);
197                                 }
198                         }
199                 }
200         }
201
202         return r;
203 }
204
205 void
206 _EditCopyPasteMagnifier::OnDraw(void)
207 {
208         _EcoreEvas* pEcoreEvas = GetEcoreEvasMgr()->GetEcoreEvas();
209         SysTryReturnVoidResult(NID_UI_CTRL, pEcoreEvas, E_INVALID_STATE, "pEcoreEvas is null.");
210
211         pEcoreEvas->SetWindowBounds(*GetRootWindow(), __windowBounds);
212
213         Canvas* pCanvas = GetCanvasN();
214         if (pCanvas == null)
215         {
216                 return;
217         }
218         pCanvas->SetBackgroundColor(Color(0, 0, 0, 0));
219         pCanvas->Clear();
220         if (_BitmapImpl::CheckNinePatchedBitmapStrictly(*__pMagnifierBitmap))
221         {
222                 pCanvas->DrawNinePatchedBitmap(pCanvas->GetBoundsF(), *__pMagnifierBitmap);
223         }
224         else
225         {
226                 pCanvas->DrawBitmap(pCanvas->GetBoundsF(), *__pMagnifierBitmap);
227         }
228
229         CaptureTextArea(*pCanvas);
230
231         delete pCanvas;
232
233 }
234
235 void
236 _EditCopyPasteMagnifier::CaptureTextArea(Canvas& canvas)
237 {
238         result r = E_SUCCESS;
239         float captureWidth = 0.0f;
240         float captureHeight = 0.0f;
241         float capturePosX = 0.0f;
242         float capturePosY = 0.0f;
243         float adjustPoxX = 0.0f;
244         float adjustPoxY = 0.0f;
245         FloatRectangle cursorBounds(0.0f, 0.0f, 0.0f, 0.0f);
246         FloatRectangle captureBounds(0.0f, 0.0f, 0.0f, 0.0f);
247
248         _Edit* pEdit = __pCopyPasteManager->GetEdit();
249         SysTryReturnVoidResult(NID_UI_CTRL, pEdit, E_INVALID_STATE, "pEdit is null.");
250
251         _EditPresenter* pEditPresenter = pEdit->GetPresenter();
252         SysTryReturnVoidResult(NID_UI_CTRL, pEditPresenter, E_INVALID_STATE, "pEditPresenter is null.");
253
254         pEditPresenter->CalculateCursorBounds(pEditPresenter->GetTextBoundsF(), cursorBounds, __handlerCursorPos);
255
256         GET_SHAPE_CONFIG(EDIT::COPYPASTE_MAGNIFIER_CAPTURE_WIDTH, pEdit->GetOrientation(), captureWidth);
257         GET_SHAPE_CONFIG(EDIT::COPYPASTE_MAGNIFIER_CAPTURE_HEIGHT, pEdit->GetOrientation(), captureHeight);
258         GET_SHAPE_CONFIG(EDIT::COPYPASTE_MAGNIFIER_CAPTURE_POSITION_X, pEdit->GetOrientation(), capturePosX);
259         GET_SHAPE_CONFIG(EDIT::COPYPASTE_MAGNIFIER_CAPTURE_POSITION_Y, pEdit->GetOrientation(), capturePosY);
260
261         FloatRectangle textObjectBounds = pEditPresenter->GetTextBoundsF();
262         captureBounds.x = cursorBounds.x - captureWidth/2.0f;
263         captureBounds.y = cursorBounds.y + cursorBounds.height/2 - captureHeight/2;
264         captureBounds.width = captureWidth;
265         captureBounds.height = captureHeight;
266         captureBounds = textObjectBounds.GetIntersection(captureBounds);
267
268         if (captureBounds.width < captureWidth && captureBounds.x < textObjectBounds.x + textObjectBounds.width - captureBounds.width)
269         {
270                 adjustPoxX = captureWidth - captureBounds.width;
271         }
272         if (captureBounds.height < captureHeight && captureBounds.y < captureHeight)
273         {
274                 adjustPoxY = captureHeight - captureBounds.height;
275         }
276
277         Bitmap* pOriginalBitmp = pEdit->GetCapturedBitmapN(true);
278         SysTryReturnVoidResult(NID_UI_CTRL, pOriginalBitmp, E_INVALID_STATE, "pOriginalBitmp is null.");
279
280         Bitmap bitmap;
281         r = bitmap.Construct(captureBounds);
282         SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
283
284         r = bitmap.Merge(FloatPoint(0.0f, 0.0f), *pOriginalBitmp, captureBounds);
285         SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
286
287         r = bitmap.SetScalingQuality(BITMAP_SCALING_QUALITY_HIGH);
288         SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
289
290         r = bitmap.Scale(FloatDimension(bitmap.GetWidth()*1.5f, bitmap.GetHeight()*1.5f));
291         SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
292
293         canvas.DrawBitmap(FloatPoint(capturePosX + adjustPoxX*1.5f, capturePosY + adjustPoxY*1.5f), bitmap);
294
295         delete pOriginalBitmp;
296
297         return;
298
299 CATCH:
300         delete pOriginalBitmp;
301
302         return;
303 }
304
305 void
306 _EditCopyPasteMagnifier::MoveMagnifier(const FloatPoint& point, int handlerCursorPos)
307 {
308         FloatRectangle bounds = FloatRectangle(point.x - GetBoundsF().width/2, point.y - GetBoundsF().height, GetBoundsF().width, GetBoundsF().height);
309         __handlerCursorPos = handlerCursorPos;
310         if (bounds.y < 0.0f)
311         {
312                 bounds.y = 0.0f;
313         }
314         SetBounds(bounds);
315         Invalidate();
316 }
317
318 result
319 _EditCopyPasteMagnifier::OnBoundsChanging(const FloatRectangle& bounds)
320 {
321         result r = E_SUCCESS;
322
323         __windowBounds = bounds;
324
325         return r;
326 }
327
328 result
329 _EditCopyPasteMagnifier::OnBoundsChanging(const Rectangle& bounds)
330 {
331         result r = E_SUCCESS;
332
333         return r;
334 }
335
336 void
337 _EditCopyPasteMagnifier::SetRowColumnIndex(int rowIndex, int columnIndex)
338 {
339         __rowIndex = rowIndex;
340         __columnIndex = columnIndex;
341 }
342
343 /**
344 * @class        _EditCopyPasteHandler
345 * @brief        This class defines the common behavior for the %_EditCopyPasteHandler.
346 *
347 */
348 class _EditCopyPasteHandler
349         : public _Window
350         , virtual public IEventListener
351         , virtual public _IUiEventListener
352         , virtual public _IUiEventPreviewer
353 {
354
355 // Lifecycle
356 public:
357         /**
358         * This is the default class constructor.
359         *
360         */
361         _EditCopyPasteHandler(const Point& point, int handlerCursorPos, _EditCopyPasteManager* pCopyPasteManager, bool singleHandler, bool leftHandler);
362         _EditCopyPasteHandler(const FloatPoint& point, int handlerCursorPos, _EditCopyPasteManager* pCopyPasteManager, bool singleHandler, bool leftHandler);
363
364         /**
365         * This is the default class destructor.
366         *
367         */
368         virtual ~_EditCopyPasteHandler(void);
369
370 // Operations
371 public:
372         enum HandlerDirection
373         {
374                 HANDLER_DIRECTION_NONE = 0,
375                 HANDLER_DIRECTION_REVERSE_1,//horizontal reverse
376                 HANDLER_DIRECTION_REVERSE_2,//vertical reverse
377                 HANDLER_DIRECTION_REVERSE_3,//horizontal vertical reverse
378         };
379
380         static _EditCopyPasteHandler* CreateInstanceN(const Point& point, int handlerCursorPos, _EditCopyPasteManager* pCopyPasteManager, bool singleHandler, bool leftHandler = true);
381         static _EditCopyPasteHandler* CreateInstanceN(const FloatPoint& point, int handlerCursorPos, _EditCopyPasteManager* pCopyPasteManager, bool singleHandler, bool leftHandler = true);
382         int GetHandlerCursorPosition(void) const;
383         void GetHandlerRowColumnIndex(int& rowIndex, int& columnIndex) const;
384         void SetHandlerCursorPosition(int handlerCursorPos);
385         void AdjustBounds(void);
386         void CheckReverseStatus(void);
387         void ChangeHandlerBitmap(void);
388         Bitmap* GetHandlerBitmap(void) const;
389         bool CreateCopyPasteMagnifier(void);
390         void DestroyCopyPasteMagnifier(void);
391         void MoveCopyPasteMagnifier(void);
392         void UpdateCopyPasteMagnifier(void);
393
394 // virtual function
395         virtual void OnDraw(void);
396         virtual bool OnTouchPressed(const _Control& source, const _TouchInfo& touchinfo);
397         virtual bool OnTouchMoved(const _Control& source, const _TouchInfo& touchinfo);
398         virtual bool OnTouchReleased(const _Control& source, const _TouchInfo& touchinfo);
399         virtual bool IsActivatedOnOpen(void) const;
400         virtual void OnChangeLayout(_ControlOrientation orientation);
401         virtual result OnAttachedToMainTree(void);
402
403         result OnBoundsChanging(const Rectangle& bounds);
404         result OnBoundsChanging(const FloatRectangle& bounds);
405         result SetWindowBounds(const Rectangle& bounds);
406         result SetWindowBounds(const FloatRectangle& bounds);
407
408 private:
409         _EditCopyPasteHandler(const _EditCopyPasteHandler& value);
410         _EditCopyPasteHandler& operator =(const _EditCopyPasteHandler& value);
411
412 // Attribute
413 private:
414         _VisualElement* __pRoot;
415         Bitmap* __pHandlerBitmap;
416         FloatPoint __touchPressedPoint;
417         FloatPoint __absoluteTouchPressedPoint;
418         _EditCopyPasteManager* __pCopyPasteManager;
419         bool __leftHandler;
420         bool __reverseCheck;
421         int __handlerCursorPos;
422         bool __isTouchPressed;
423         FloatRectangle __windowBounds;
424         HandlerDirection __handlerDirection;
425         bool __singleHandler;
426         _EditCopyPasteMagnifier* __pCopyPasteMagnifier;
427         bool __isTouchMoving;
428         int __rowIndex;
429         int __columnIndex;
430 }; // _EditCopyPasteHandler
431
432 Bitmap*
433 _EditCopyPasteHandler::GetHandlerBitmap(void) const
434 {
435         return __pHandlerBitmap;
436 }
437
438 bool
439 _EditCopyPasteHandler::CreateCopyPasteMagnifier(void)
440 {
441         if (!__pCopyPasteMagnifier)
442         {
443                 _Edit* pEdit = __pCopyPasteManager->GetEdit();
444                 SysTryReturn(NID_UI_CTRL, pEdit, false, E_INVALID_STATE, "[E_INVALID_STATE] pEdit is null.\n");
445
446                 _EditPresenter* pEditPresenter = pEdit->GetPresenter();
447                 SysTryReturn(NID_UI_CTRL, pEditPresenter, false, E_INVALID_STATE, "[E_INVALID_STATE] pEditPresenter is null.\n");
448
449                 FloatRectangle cursorBounds(0.0f, 0.0f, 0.0f, 0.0f);
450                 if (__rowIndex == -1 && __columnIndex == -1)
451                 {
452                         pEditPresenter->CalculateAbsoluteCursorBounds(__handlerCursorPos, cursorBounds);
453                 }
454                 else
455                 {
456                         pEditPresenter->CalculateAbsoluteCursorBounds(__rowIndex, __columnIndex, cursorBounds);
457                 }
458                 __pCopyPasteMagnifier = _EditCopyPasteMagnifier::CreateInstanceN(FloatPoint(cursorBounds.x, cursorBounds.y), __handlerCursorPos, __pCopyPasteManager);
459                 SysTryReturn(NID_UI_CTRL, __pCopyPasteMagnifier, false, E_INVALID_STATE, "[E_INVALID_STATE] __pCopyPasteMagnifier is null.\n");
460
461                 __pCopyPasteMagnifier->SetRowColumnIndex(__rowIndex, __columnIndex);
462         }
463         return true;
464 }
465
466 void
467 _EditCopyPasteHandler::DestroyCopyPasteMagnifier(void)
468 {
469         if (__pCopyPasteMagnifier)
470         {
471                 __pCopyPasteMagnifier->Close();
472                 delete __pCopyPasteMagnifier;
473                 __pCopyPasteMagnifier = null;
474         }
475 }
476
477 void
478 _EditCopyPasteHandler::MoveCopyPasteMagnifier(void)
479 {
480         if (__pCopyPasteMagnifier)
481         {
482                 _Edit* pEdit = __pCopyPasteManager->GetEdit();
483                 SysTryReturnVoidResult(NID_UI_CTRL, pEdit, E_INVALID_STATE, "pEdit is null.");
484
485                 _EditPresenter* pEditPresenter = pEdit->GetPresenter();
486                 SysTryReturnVoidResult(NID_UI_CTRL, pEditPresenter, E_INVALID_STATE, "pEditPresenter is null.");
487
488                 FloatRectangle cursorBounds(0.0f, 0.0f, 0.0f, 0.0f);
489                 if (__rowIndex == -1 && __columnIndex == -1)
490                 {
491                         pEditPresenter->CalculateAbsoluteCursorBounds(__handlerCursorPos, cursorBounds);
492                 }
493                 else
494                 {
495                         pEditPresenter->CalculateAbsoluteCursorBounds(__rowIndex, __columnIndex, cursorBounds);
496                         __pCopyPasteMagnifier->SetRowColumnIndex(__rowIndex, __columnIndex);
497                 }
498                 __pCopyPasteMagnifier->MoveMagnifier(FloatPoint(cursorBounds.x, cursorBounds.y), __handlerCursorPos);
499         }
500 }
501
502 void
503 _EditCopyPasteHandler::UpdateCopyPasteMagnifier(void)
504 {
505         if (__pCopyPasteMagnifier)
506         {
507                 __pCopyPasteMagnifier->Invalidate();
508         }
509 }
510
511 void
512 _EditCopyPasteHandler::ChangeHandlerBitmap(void)
513 {
514         if (__pHandlerBitmap)
515         {
516                 delete __pHandlerBitmap;
517                 __pHandlerBitmap = null;
518         }
519         if (__singleHandler)
520         {
521                 if (__handlerDirection == HANDLER_DIRECTION_NONE)
522                 {
523                         GET_BITMAP_CONFIG_N(EDIT::COPY_PASTE_ICON_CENTER_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, __pHandlerBitmap);
524                 }
525                 else
526                 {
527                         GET_BITMAP_CONFIG_N(EDIT::COPY_PASTE_ICON_REVERSE_CENTER_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, __pHandlerBitmap);
528                 }
529                 return;
530         }
531         if (__leftHandler)
532         {
533                 switch(__handlerDirection)
534                 {
535                         case HANDLER_DIRECTION_REVERSE_1:
536                                 GET_BITMAP_CONFIG_N(EDIT::COPY_PASTE_ICON_RIGHT_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, __pHandlerBitmap);
537                                 break;
538                         case HANDLER_DIRECTION_REVERSE_2:
539                                 GET_BITMAP_CONFIG_N(EDIT::COPY_PASTE_ICON_REVERSE_LEFT_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, __pHandlerBitmap);
540                                 break;
541                         case HANDLER_DIRECTION_REVERSE_3:
542                                 GET_BITMAP_CONFIG_N(EDIT::COPY_PASTE_ICON_REVERSE_RIGHT_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, __pHandlerBitmap);
543                                 break;
544                         case HANDLER_DIRECTION_NONE:
545                                 //fall through
546                         default:
547                                 GET_BITMAP_CONFIG_N(EDIT::COPY_PASTE_ICON_LEFT_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, __pHandlerBitmap);
548                                 break;
549                 }
550         }
551         else
552         {
553                 switch(__handlerDirection)
554                 {
555                         case HANDLER_DIRECTION_REVERSE_1:
556                                 GET_BITMAP_CONFIG_N(EDIT::COPY_PASTE_ICON_LEFT_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, __pHandlerBitmap);
557                                 break;
558                         case HANDLER_DIRECTION_REVERSE_2:
559                                 GET_BITMAP_CONFIG_N(EDIT::COPY_PASTE_ICON_REVERSE_RIGHT_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, __pHandlerBitmap);
560                                 break;
561                         case HANDLER_DIRECTION_REVERSE_3:
562                                 GET_BITMAP_CONFIG_N(EDIT::COPY_PASTE_ICON_REVERSE_LEFT_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, __pHandlerBitmap);
563                                 break;
564                         case HANDLER_DIRECTION_NONE:
565                                 //fall through
566                         default:
567                                 GET_BITMAP_CONFIG_N(EDIT::COPY_PASTE_ICON_RIGHT_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, __pHandlerBitmap);
568                                 break;
569                 }
570         }
571 }
572
573 _EditCopyPasteHandler::_EditCopyPasteHandler(const Point& point, int handlerCursorPos, _EditCopyPasteManager* pCopyPasteManager, bool singleHandler, bool leftHandler)
574         : __pRoot(null)
575         , __pHandlerBitmap(null)
576         , __touchPressedPoint(0.0f, 0.0f)
577         , __absoluteTouchPressedPoint(0.0f, 0.0f)
578         , __pCopyPasteManager(pCopyPasteManager)
579         , __leftHandler(leftHandler)
580         , __reverseCheck(false)
581         , __handlerCursorPos(handlerCursorPos)
582         , __isTouchPressed(false)
583         , __windowBounds(0.0f, 0.0f, 0.0f, 0.0f)
584         , __handlerDirection(HANDLER_DIRECTION_NONE)
585         , __singleHandler(false)
586         , __pCopyPasteMagnifier(null)
587         , __isTouchMoving(false)
588         , __rowIndex(-1)
589         , __columnIndex(-1)
590 {
591         AcquireHandle();
592
593         __pRoot = GetVisualElement();
594         __pRoot->SetSurfaceOpaque(false);
595
596         Point handlerPoint(point);
597
598         if (singleHandler)
599         {
600                 GET_BITMAP_CONFIG_N(EDIT::COPY_PASTE_ICON_CENTER_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, __pHandlerBitmap);
601                 handlerPoint.x = handlerPoint.x - (__pHandlerBitmap->GetWidth() / 2);
602                 __singleHandler = true;
603         }
604         else
605         {
606                 if (leftHandler)
607                 {
608                         GET_BITMAP_CONFIG_N(EDIT::COPY_PASTE_ICON_LEFT_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, __pHandlerBitmap);
609                         handlerPoint.x = handlerPoint.x - __pHandlerBitmap->GetWidth();
610                 }
611                 else
612                 {
613                         GET_BITMAP_CONFIG_N(EDIT::COPY_PASTE_ICON_RIGHT_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, __pHandlerBitmap);
614                 }
615         }
616
617         FloatRectangle bounds(handlerPoint.x, handlerPoint.y, __pHandlerBitmap->GetWidth(), __pHandlerBitmap->GetHeight());
618 }
619
620 _EditCopyPasteHandler::_EditCopyPasteHandler(const FloatPoint& point, int handlerCursorPos, _EditCopyPasteManager* pCopyPasteManager, bool singleHandler, bool leftHandler)
621         : __pRoot(null)
622         , __pHandlerBitmap(null)
623         , __touchPressedPoint(0.0f, 0.0f)
624         , __absoluteTouchPressedPoint(0.0f, 0.0f)
625         , __pCopyPasteManager(pCopyPasteManager)
626         , __leftHandler(leftHandler)
627         , __reverseCheck(false)
628         , __handlerCursorPos(handlerCursorPos)
629         , __isTouchPressed(false)
630         , __windowBounds(0.0f, 0.0f, 0.0f, 0.0f)
631         , __handlerDirection(HANDLER_DIRECTION_NONE)
632         , __singleHandler(false)
633         , __pCopyPasteMagnifier(null)
634         , __isTouchMoving(false)
635         , __rowIndex(-1)
636         , __columnIndex(-1)
637 {
638         AcquireHandle();
639
640         __pRoot = GetVisualElement();
641         __pRoot->SetSurfaceOpaque(false);
642 //To do .....
643
644         //Point handlerPoint(_CoordinateSystemUtils::ConvertToInteger(point));
645         FloatPoint handlerPoint(point);
646         if (singleHandler)
647         {
648                 GET_BITMAP_CONFIG_N(EDIT::COPY_PASTE_ICON_CENTER_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, __pHandlerBitmap);
649                 handlerPoint.x = handlerPoint.x - (__pHandlerBitmap->GetWidthF() / 2.0f);
650                 __singleHandler = true;
651         }
652         else
653         {
654                 if (leftHandler)
655                 {
656                         GET_BITMAP_CONFIG_N(EDIT::COPY_PASTE_ICON_LEFT_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, __pHandlerBitmap);
657                         handlerPoint.x = handlerPoint.x - __pHandlerBitmap->GetWidthF();
658                 }
659                 else
660                 {
661                         GET_BITMAP_CONFIG_N(EDIT::COPY_PASTE_ICON_RIGHT_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, __pHandlerBitmap);
662                 }
663         }
664
665         FloatRectangle bounds(handlerPoint.x, handlerPoint.y, _CoordinateSystemUtils::ConvertToFloat(__pHandlerBitmap->GetWidth()), _CoordinateSystemUtils::ConvertToFloat(__pHandlerBitmap->GetHeight()));
666 }
667
668 _EditCopyPasteHandler::~_EditCopyPasteHandler(void)
669 {
670         DestroyCopyPasteMagnifier();
671
672         if (__pHandlerBitmap)
673         {
674                 delete __pHandlerBitmap;
675                 __pHandlerBitmap = null;
676         }
677 }
678
679 _EditCopyPasteHandler*
680 _EditCopyPasteHandler::CreateInstanceN(const Point& point, int handlerCursorPos, _EditCopyPasteManager* pCopyPasteManager, bool singleHandler, bool leftHandler)
681 {
682         _EditCopyPasteHandler* pCopyPasteHandler = new (std::nothrow) _EditCopyPasteHandler(point, handlerCursorPos, pCopyPasteManager, singleHandler, leftHandler);
683         SysTryReturn(NID_UI_CTRL, pCopyPasteHandler != null, null, E_OUT_OF_MEMORY, "pContextMenu is null");
684
685         Point handlerPoint(point);
686         Rectangle bounds(0, 0, 0, 0);
687         Bitmap* pHandlerBitmap = pCopyPasteHandler->GetHandlerBitmap();
688
689         result r = pCopyPasteHandler->CreateRootVisualElement();
690         SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
691
692         pCopyPasteHandler->SetActivationEnabled(false);
693
694         if (singleHandler)
695         {
696                 handlerPoint.x = handlerPoint.x - (pHandlerBitmap->GetWidth() / 2);
697         }
698         else
699         {
700                 if (leftHandler)
701                 {
702                         handlerPoint.x = handlerPoint.x - pHandlerBitmap->GetWidth();
703                 }
704         }
705
706         bounds.x = handlerPoint.x;
707         bounds.y = handlerPoint.y;
708         bounds.width = pHandlerBitmap->GetWidth();
709         bounds.height = pHandlerBitmap->GetHeight();
710
711         pCopyPasteHandler->SetBounds(bounds);
712         pCopyPasteHandler->CheckReverseStatus();
713         pCopyPasteHandler->Open(false);
714
715         return pCopyPasteHandler;
716
717 CATCH:
718         pCopyPasteHandler->Close();
719         delete pCopyPasteHandler;
720
721         return null;
722 }
723
724 _EditCopyPasteHandler*
725 _EditCopyPasteHandler::CreateInstanceN(const FloatPoint& point, int handlerCursorPos, _EditCopyPasteManager* pCopyPasteManager, bool singleHandler, bool leftHandler)
726 {
727         _EditCopyPasteHandler* pCopyPasteHandler = new (std::nothrow) _EditCopyPasteHandler(point, handlerCursorPos, pCopyPasteManager, singleHandler, leftHandler);
728         SysTryReturn(NID_UI_CTRL, pCopyPasteHandler != null, null, E_OUT_OF_MEMORY, "pContextMenu is null");
729
730         FloatPoint handlerPoint(point);
731         FloatRectangle bounds(0.0f, 0.0f, 0.0f, 0.0f);
732         Bitmap* pHandlerBitmap = pCopyPasteHandler->GetHandlerBitmap();
733
734         result r = pCopyPasteHandler->CreateRootVisualElement();
735         SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
736
737         pCopyPasteHandler->SetActivationEnabled(false);
738
739         if (singleHandler)
740         {
741                 handlerPoint.x = handlerPoint.x - (pHandlerBitmap->GetWidthF() / 2.0f);
742         }
743         else
744         {
745                 if (leftHandler)
746                 {
747                         handlerPoint.x = handlerPoint.x - pHandlerBitmap->GetWidthF();
748                 }
749         }
750
751         bounds.x = handlerPoint.x;
752         bounds.y = handlerPoint.y;
753         bounds.width = pHandlerBitmap->GetWidthF();
754         bounds.height = pHandlerBitmap->GetHeightF();
755
756         pCopyPasteHandler->SetBounds(bounds);
757         pCopyPasteHandler->CheckReverseStatus();
758         pCopyPasteHandler->Open(false);
759
760         return pCopyPasteHandler;
761
762 CATCH:
763         pCopyPasteHandler->Close();
764         delete pCopyPasteHandler;
765
766         return null;
767 }
768
769 int
770 _EditCopyPasteHandler::GetHandlerCursorPosition(void) const
771 {
772         return __handlerCursorPos;
773 }
774
775 void
776 _EditCopyPasteHandler::GetHandlerRowColumnIndex(int& rowIndex, int& columnIndex) const
777 {
778         rowIndex = __rowIndex;
779         columnIndex = __columnIndex;
780 }
781
782 void
783 _EditCopyPasteHandler::SetHandlerCursorPosition(int handlerCursorPos)
784 {
785         __handlerCursorPos = handlerCursorPos;
786 }
787
788 void
789 _EditCopyPasteHandler::AdjustBounds(void)
790 {
791         FloatRectangle cursorRect;
792         FloatRectangle rect = GetBoundsF();
793         FloatPoint checkPoint(0.0f, 0.0f);
794         _Edit* pEdit = __pCopyPasteManager->GetEdit();
795         _EditPresenter* pEditPresenter = pEdit->GetPresenter();
796
797         if (__singleHandler)
798         {
799                 if (__rowIndex == -1 && __columnIndex == -1)
800                 {
801                         pEditPresenter->CalculateAbsoluteCursorBounds(__handlerCursorPos, cursorRect);
802                 }
803                 else
804                 {
805                         pEditPresenter->CalculateAbsoluteCursorBounds(__rowIndex, __columnIndex, cursorRect);
806                 }
807                 rect.x = cursorRect.x - __pHandlerBitmap->GetWidthF()/2.0f;
808                 rect.y = cursorRect.y + cursorRect.height;
809                 checkPoint = FloatPoint(cursorRect.x , cursorRect.y + cursorRect.height);
810                 if (__handlerDirection == HANDLER_DIRECTION_REVERSE_2)
811                 {
812                         rect.y -= (cursorRect.height + __pHandlerBitmap->GetHeightF());
813                 }
814         }
815         else
816         {
817                 if (__rowIndex == -1 && __columnIndex == -1)
818                 {
819                         pEditPresenter->CalculateAbsoluteCursorBounds(__handlerCursorPos, cursorRect);
820                 }
821                 else
822                 {
823                         pEditPresenter->CalculateAbsoluteCursorBounds(__rowIndex, __columnIndex, cursorRect);
824                 }
825
826                 rect.x = cursorRect.x;
827                 rect.y = cursorRect.y + cursorRect.height;
828
829                 checkPoint = FloatPoint(cursorRect.x, cursorRect.y + cursorRect.height);
830
831                 if (__leftHandler)
832                 {
833                         if (__handlerDirection == HANDLER_DIRECTION_NONE)
834                         {
835                                 rect.x = rect.x - __pHandlerBitmap->GetWidthF();
836                         }
837                         else if (__handlerDirection == HANDLER_DIRECTION_REVERSE_2)
838                         {
839                                 rect.x = rect.x - __pHandlerBitmap->GetWidthF();
840                                 rect.y -= (rect.height + cursorRect.height);
841                         }
842                         else if (__handlerDirection == HANDLER_DIRECTION_REVERSE_3)
843                         {
844                                 rect.y -= (rect.height + cursorRect.height);
845                         }
846                 }
847                 else
848                 {
849                         if (__handlerDirection == HANDLER_DIRECTION_REVERSE_1)
850                         {
851                                 rect.x = rect.x - __pHandlerBitmap->GetWidthF();
852                         }
853                         else if (__handlerDirection == HANDLER_DIRECTION_REVERSE_2)
854                         {
855                                 rect.y -= (rect.height + cursorRect.height);
856                         }
857                         else if (__handlerDirection == HANDLER_DIRECTION_REVERSE_3)
858                         {
859                                 rect.x = rect.x - __pHandlerBitmap->GetWidthF();
860                                 rect.y -= (rect.height + cursorRect.height);
861                         }
862                 }
863         }
864
865         if (!__isTouchMoving)
866         {
867                 bool visibleState = __pCopyPasteManager->CheckHandleBounds(checkPoint);
868                 if (visibleState && !GetVisibleState())
869                 {
870                         SetVisibleState(true);
871                         Open();
872                 }
873                 else if (!visibleState && GetVisibleState())
874                 {
875                         SetVisibleState(false);
876                         Close();
877                 }
878         }
879
880         SetBounds(rect);
881         return;
882 }
883
884 void
885 _EditCopyPasteHandler::OnDraw(void)
886 {
887         Canvas* pCanvas = GetCanvasN();
888         if (pCanvas == null)
889         {
890                 return;
891         }
892         pCanvas->SetBackgroundColor(Color(0, 0, 0, 0));
893         pCanvas->Clear();
894         if (_BitmapImpl::CheckNinePatchedBitmapStrictly(*__pHandlerBitmap))
895         {
896                 pCanvas->DrawNinePatchedBitmap(pCanvas->GetBoundsF(), *__pHandlerBitmap);
897         }
898         else
899         {
900                 pCanvas->DrawBitmap(pCanvas->GetBoundsF(), *__pHandlerBitmap);
901         }
902
903         delete pCanvas;
904
905         if (__reverseCheck)
906         {
907                 SetWindowBounds(__windowBounds);
908                 __reverseCheck = false;
909         }
910         else
911         {
912                 SetWindowBounds(__windowBounds);
913         }
914 }
915
916 bool
917 _EditCopyPasteHandler::OnTouchPressed(const _Control& source, const _TouchInfo& touchinfo)
918 {
919         __pCopyPasteManager->ReleaseCopyPastePopup();
920 #if EDIT_COPY_PASTE_MAGNIFIER
921         CreateCopyPasteMagnifier();
922 #endif
923         __touchPressedPoint = touchinfo.GetCurrentPosition();
924         __absoluteTouchPressedPoint = FloatPoint(GetBoundsF().x + __touchPressedPoint.x, GetBoundsF().y + __touchPressedPoint.y);
925         __isTouchPressed = true;
926         Invalidate();
927         return true;
928 }
929
930 void
931 _EditCopyPasteHandler::CheckReverseStatus(void)
932 {
933         FloatDimension screenSize;
934         _ControlManager* pControlManager = _ControlManager::GetInstance();
935         _Edit* pEdit = __pCopyPasteManager->GetEdit();
936         _ControlOrientation orientation = pEdit->GetOrientation();
937         FloatRectangle rect = GetBoundsF();
938         FloatRectangle cursorAbsBounds = __pCopyPasteManager->GetCursorBoundsF(true);
939
940         if (orientation == _CONTROL_ORIENTATION_PORTRAIT)
941         {
942                 screenSize = pControlManager->GetScreenSizeF();
943         }
944         else
945         {
946                 screenSize.width = pControlManager->GetScreenSizeF().height;
947                 screenSize.height = pControlManager->GetScreenSizeF().width;
948         }
949
950         if (__singleHandler)
951         {
952                 if ((__handlerDirection == HANDLER_DIRECTION_NONE) && ((cursorAbsBounds.y + cursorAbsBounds.height + rect.height) > screenSize.height))
953                 {
954                         __handlerDirection = HANDLER_DIRECTION_REVERSE_2;
955                         rect.y -= (cursorAbsBounds.height + rect.height);
956                         __reverseCheck = true;
957                 }
958                 else if ((__handlerDirection == HANDLER_DIRECTION_REVERSE_2) && ((cursorAbsBounds.y + cursorAbsBounds.height + rect.height) <= screenSize.height))
959                 {
960                         __handlerDirection = HANDLER_DIRECTION_NONE;
961                         rect.y += (cursorAbsBounds.height + rect.height);
962                         __reverseCheck = true;
963                 }
964                 ChangeHandlerBitmap();
965                 SetBounds(rect);
966                 return;
967         }
968
969         if (__leftHandler)
970         {
971                 if (((__handlerDirection == HANDLER_DIRECTION_NONE) || (__handlerDirection == HANDLER_DIRECTION_REVERSE_2)) && rect.x < 0.0f)
972                 {
973                         if ((__handlerDirection == HANDLER_DIRECTION_NONE) && ((rect.y + rect.height) > screenSize.height))
974                         {
975                                 __handlerDirection = HANDLER_DIRECTION_REVERSE_3;
976                                 rect.y -= (rect.height + cursorAbsBounds.height);
977                         }
978                         else if ((__handlerDirection == HANDLER_DIRECTION_NONE) && ((rect.y + rect.height) <= screenSize.height))
979                         {
980                                 __handlerDirection = HANDLER_DIRECTION_REVERSE_1;
981                         }
982                         else if ((__handlerDirection == HANDLER_DIRECTION_REVERSE_2) && ((rect.y + 2*rect.height) > screenSize.height))
983                         {
984                                 __handlerDirection = HANDLER_DIRECTION_REVERSE_3;
985                         }
986                         else if ((__handlerDirection == HANDLER_DIRECTION_REVERSE_2) && ((rect.y + 2*rect.height) <= screenSize.height))
987                         {
988                                 __handlerDirection = HANDLER_DIRECTION_REVERSE_1;
989                                 rect.y += (rect.height + cursorAbsBounds.height);
990                         }
991                         ChangeHandlerBitmap();
992                         rect.x += rect.width;
993                         __reverseCheck = true;
994                 }
995                 else if (((__handlerDirection == HANDLER_DIRECTION_REVERSE_1) || (__handlerDirection == HANDLER_DIRECTION_REVERSE_3)) && rect.x >= rect.width)
996                 {
997                         if ((__handlerDirection == HANDLER_DIRECTION_REVERSE_1) && ((rect.y + rect.height) > screenSize.height))
998                         {
999                                 __handlerDirection = HANDLER_DIRECTION_REVERSE_2;
1000                                 rect.y -= (rect.height + cursorAbsBounds.height);
1001                         }
1002                         else if ((__handlerDirection == HANDLER_DIRECTION_REVERSE_1) && ((rect.y + rect.height) <= screenSize.height))
1003                         {
1004                                 __handlerDirection = HANDLER_DIRECTION_NONE;
1005                         }
1006                         else if ((__handlerDirection == HANDLER_DIRECTION_REVERSE_3) && ((rect.y + 2*rect.height) > screenSize.height))
1007                         {
1008                                 __handlerDirection = HANDLER_DIRECTION_REVERSE_2;
1009                         }
1010                         else if ((__handlerDirection == HANDLER_DIRECTION_REVERSE_3) && ((rect.y + 2*rect.height) <= screenSize.height))
1011                         {
1012                                 __handlerDirection = HANDLER_DIRECTION_NONE;
1013                                 rect.y += (rect.height + cursorAbsBounds.height);
1014                         }
1015                         ChangeHandlerBitmap();
1016                         rect.x -= rect.width;
1017                         __reverseCheck = true;
1018                 }
1019                 else if (((__handlerDirection == HANDLER_DIRECTION_NONE) || (__handlerDirection == HANDLER_DIRECTION_REVERSE_1)) && ((rect.y + rect.height) > screenSize.height))
1020                 {
1021                         if ((__handlerDirection == HANDLER_DIRECTION_NONE) && rect.x < rect.width)
1022                         {
1023                                 __handlerDirection = HANDLER_DIRECTION_REVERSE_3;
1024                                 rect.x += rect.width;
1025                         }
1026                         else if ((__handlerDirection == HANDLER_DIRECTION_NONE) && rect.x >= rect.width)
1027                         {
1028                                 __handlerDirection = HANDLER_DIRECTION_REVERSE_2;
1029                         }
1030                         else if ((__handlerDirection == HANDLER_DIRECTION_REVERSE_1) && ((rect.x - rect.width) >= 0.0f))
1031                         {
1032                                 __handlerDirection = HANDLER_DIRECTION_REVERSE_2;
1033                                 rect.x -= rect.width;
1034                         }
1035                         else if ((__handlerDirection == HANDLER_DIRECTION_REVERSE_1) && ((rect.x - rect.width) < 0.0f))
1036                         {
1037                                 __handlerDirection = HANDLER_DIRECTION_REVERSE_3;
1038                         }
1039                         rect.y -= (rect.height + cursorAbsBounds.height);
1040                         ChangeHandlerBitmap();
1041                         __reverseCheck = true;
1042                 }
1043                 else if (((__handlerDirection == HANDLER_DIRECTION_REVERSE_2) || (__handlerDirection == HANDLER_DIRECTION_REVERSE_3)) && ((rect.y + 2*rect.height + cursorAbsBounds.height) <= screenSize.height))
1044                 {
1045                         if ((__handlerDirection == HANDLER_DIRECTION_REVERSE_2) && rect.x < 0.0f)
1046                         {
1047                                 __handlerDirection = HANDLER_DIRECTION_REVERSE_1;
1048                                 rect.x += rect.width;
1049                         }
1050                         else if ((__handlerDirection == HANDLER_DIRECTION_REVERSE_2) && rect.x >= rect.width)
1051                         {
1052                                 __handlerDirection = HANDLER_DIRECTION_NONE;
1053                         }
1054                         else if ((__handlerDirection == HANDLER_DIRECTION_REVERSE_3) && ((rect.x - rect.width) >= 0.0f))
1055                         {
1056                                 __handlerDirection = HANDLER_DIRECTION_NONE;
1057                                 rect.x -= rect.width;
1058                         }
1059                         else if ((__handlerDirection == HANDLER_DIRECTION_REVERSE_3) && ((rect.x - rect.width) < 0.0f))
1060                         {
1061                                 __handlerDirection = HANDLER_DIRECTION_REVERSE_1;
1062                         }
1063                         rect.y += (rect.height + cursorAbsBounds.height);
1064                         ChangeHandlerBitmap();
1065                         __reverseCheck = true;
1066                 }
1067         }
1068         else
1069         {
1070                 if (((__handlerDirection == HANDLER_DIRECTION_NONE) || (__handlerDirection == HANDLER_DIRECTION_REVERSE_2)) && (rect.x + rect.width) > screenSize.width)
1071                 {
1072                         if ((__handlerDirection == HANDLER_DIRECTION_NONE) && ((rect.y + rect.height) > screenSize.height))
1073                         {
1074                                 __handlerDirection = HANDLER_DIRECTION_REVERSE_3;
1075                                 rect.y -= (rect.height + cursorAbsBounds.height);
1076                         }
1077                         else if ((__handlerDirection == HANDLER_DIRECTION_NONE) && ((rect.y + rect.height) <= screenSize.height))
1078                         {
1079                                 __handlerDirection = HANDLER_DIRECTION_REVERSE_1;
1080                         }
1081                         else if ((__handlerDirection == HANDLER_DIRECTION_REVERSE_2) && ((rect.y + 2*rect.height) > screenSize.height))
1082                         {
1083                                 __handlerDirection = HANDLER_DIRECTION_REVERSE_3;
1084                         }
1085                         else if ((__handlerDirection == HANDLER_DIRECTION_REVERSE_2) && ((rect.y + 2*rect.height) <= screenSize.height))
1086                         {
1087                                 __handlerDirection = HANDLER_DIRECTION_REVERSE_1;
1088                                 rect.y += (rect.height + cursorAbsBounds.height);
1089                         }
1090                         ChangeHandlerBitmap();
1091                         rect.x -= rect.width;
1092                         __reverseCheck = true;
1093                 }
1094                 else if (((__handlerDirection == HANDLER_DIRECTION_REVERSE_1) || (__handlerDirection == HANDLER_DIRECTION_REVERSE_3)) && (rect.x + 2*rect.width) <= screenSize.width)
1095                 {
1096                         if ((__handlerDirection == HANDLER_DIRECTION_REVERSE_1) && ((rect.y + rect.height) > screenSize.height))
1097                         {
1098                                 __handlerDirection = HANDLER_DIRECTION_REVERSE_2;
1099                                 rect.y -= (rect.height + cursorAbsBounds.height);
1100                         }
1101                         else if ((__handlerDirection == HANDLER_DIRECTION_REVERSE_1) && ((rect.y + rect.height) <= screenSize.height))
1102                         {
1103                                 __handlerDirection = HANDLER_DIRECTION_NONE;
1104                         }
1105                         else if ((__handlerDirection == HANDLER_DIRECTION_REVERSE_3) && ((rect.y + 2*rect.height) > screenSize.height))
1106                         {
1107                                 __handlerDirection = HANDLER_DIRECTION_REVERSE_2;
1108                         }
1109                         else if ((__handlerDirection == HANDLER_DIRECTION_REVERSE_3) && ((rect.y + 2*rect.height) <= screenSize.height))
1110                         {
1111                                 __handlerDirection = HANDLER_DIRECTION_NONE;
1112                                 rect.y += (rect.height + cursorAbsBounds.height);
1113                         }
1114                         ChangeHandlerBitmap();
1115                         rect.x += rect.width;
1116                         __reverseCheck = true;
1117                 }
1118                 else if (((__handlerDirection == HANDLER_DIRECTION_NONE) || (__handlerDirection == HANDLER_DIRECTION_REVERSE_1)) && ((rect.y + rect.height) > screenSize.height))
1119                 {
1120                         if ((__handlerDirection == HANDLER_DIRECTION_NONE) && (rect.x + rect.width) > screenSize.width)
1121                         {
1122                                 __handlerDirection = HANDLER_DIRECTION_REVERSE_3;
1123                                 rect.x -= rect.width;
1124                         }
1125                         else if ((__handlerDirection == HANDLER_DIRECTION_NONE) && (rect.x + rect.width) <= screenSize.width)
1126                         {
1127                                 __handlerDirection = HANDLER_DIRECTION_REVERSE_2;
1128                         }
1129                         else if ((__handlerDirection == HANDLER_DIRECTION_REVERSE_1) && (rect.x + 2*rect.width) <= screenSize.width)
1130                         {
1131                                 __handlerDirection = HANDLER_DIRECTION_REVERSE_2;
1132                                 rect.x += rect.width;
1133                         }
1134                         else if ((__handlerDirection == HANDLER_DIRECTION_REVERSE_1) && (rect.x + 2*rect.width) > screenSize.width)
1135                         {
1136                                 __handlerDirection = HANDLER_DIRECTION_REVERSE_3;
1137                         }
1138                         rect.y -= (rect.height + cursorAbsBounds.height);
1139                         ChangeHandlerBitmap();
1140                         __reverseCheck = true;
1141                 }
1142                 else if (((__handlerDirection == HANDLER_DIRECTION_REVERSE_2) || (__handlerDirection == HANDLER_DIRECTION_REVERSE_3)) && ((rect.y + 2*rect.height + cursorAbsBounds.height) <= screenSize.height))
1143                 {
1144                         if ((__handlerDirection == HANDLER_DIRECTION_REVERSE_2) && ((rect.x + rect.width) <= screenSize.width))
1145                         {
1146                                 __handlerDirection = HANDLER_DIRECTION_NONE;
1147                         }
1148                         else if ((__handlerDirection == HANDLER_DIRECTION_REVERSE_2) && ((rect.x + rect.width) > screenSize.width))
1149                         {
1150                                 __handlerDirection = HANDLER_DIRECTION_REVERSE_1;
1151                                 rect.x -= rect.width;
1152                         }
1153                         else if ((__handlerDirection == HANDLER_DIRECTION_REVERSE_3) && ((rect.x + 2*rect.width) <= screenSize.width))
1154                         {
1155                                 __handlerDirection = HANDLER_DIRECTION_NONE;
1156                                 rect.x += rect.width;
1157                         }
1158                         else if ((__handlerDirection == HANDLER_DIRECTION_REVERSE_3) && ((rect.x + 2*rect.width) > screenSize.width))
1159                         {
1160                                 __handlerDirection = HANDLER_DIRECTION_REVERSE_1;
1161                         }
1162                         rect.y += (rect.height + cursorAbsBounds.height);
1163                         ChangeHandlerBitmap();
1164                         __reverseCheck = true;
1165                 }
1166         }
1167
1168         SetBounds(rect);
1169 }
1170
1171 bool
1172 _EditCopyPasteHandler::OnTouchReleased(const _Control& source, const _TouchInfo& touchinfo)
1173 {
1174         CheckReverseStatus();
1175         __isTouchPressed = false;
1176         __absoluteTouchPressedPoint = FloatPoint(0.0f, 0.0f);
1177         DestroyCopyPasteMagnifier();
1178         __pCopyPasteManager->CreateCopyPastePopup();
1179         __pCopyPasteManager->Show();
1180         __pCopyPasteManager->SendTextBlockEvent();
1181         Invalidate();
1182         __isTouchMoving = false;
1183         return true;
1184 }
1185
1186 bool
1187 _EditCopyPasteHandler::OnTouchMoved(const _Control& source, const _TouchInfo& touchinfo)
1188 {
1189         int cursorPos = -1;
1190         int previousCursorPos = -1;
1191         FloatRectangle cursorRect(0.0f, 0.0f, 0.0f, 0.0f);
1192         FloatRectangle absCursorRect(0.0f, 0.0f, 0.0f, 0.0f);
1193         FloatRectangle rect = GetBoundsF();
1194         FloatPoint point = touchinfo.GetCurrentPosition();
1195         FloatPoint touchPoint(0.0f, 0.0f);
1196         FloatPoint checkPoint(0.0f, 0.0f);
1197         __isTouchMoving = true;
1198         bool cursorChange = false;
1199
1200         _Edit* pEdit = __pCopyPasteManager->GetEdit();
1201         SysTryReturn(NID_UI_CTRL, pEdit, false, E_INVALID_STATE, "[E_INVALID_STATE] pEdit is null.\n");
1202
1203         _EditPresenter* pEditPresenter = pEdit->GetPresenter();
1204         SysTryReturn(NID_UI_CTRL, pEditPresenter, false, E_INVALID_STATE, "[E_INVALID_STATE] pEditPresenter is null.\n");
1205
1206         TextObject* pTextObject = pEditPresenter->GetTextObject();
1207         SysTryReturn(NID_UI_CTRL, pTextObject, false, E_INVALID_STATE, "[E_INVALID_STATE] pEditPresenter is null.\n");
1208
1209         int curCursorLine = pTextObject->GetLineIndexAtTextIndex(__handlerCursorPos);
1210         int totalLine = pTextObject->GetTotalLineCount();
1211
1212         float totalHeight = pTextObject->GetTotalHeightF();
1213         float firstDisplayY = pTextObject->GetFirstDisplayPositionYF();
1214         FloatRectangle absTextObjectBounds(0.0f, 0.0f, 0.0f, 0.0f);
1215         FloatRectangle textObjectBounds = pEditPresenter->GetTextBoundsF();
1216         FloatRectangle absEditBounds = pEdit->GetAbsoluteBoundsF();
1217         absTextObjectBounds.x = absEditBounds.x + textObjectBounds.x;
1218         absTextObjectBounds.y = absEditBounds.y + textObjectBounds.y;
1219         absTextObjectBounds.width = textObjectBounds.width;
1220         absTextObjectBounds.height  = textObjectBounds.height;
1221         bool  needToFixYPosition= false;
1222
1223         if (__touchPressedPoint.x == point.x && __touchPressedPoint.y == point.y)
1224         {
1225                 return true;
1226         }
1227
1228         if (!__singleHandler)
1229         {
1230                 previousCursorPos = __pCopyPasteManager->GetCursorPosition();
1231         }
1232
1233         FloatPoint absoluteTouchMovedPoint = FloatPoint(GetBoundsF().x + point.x, GetBoundsF().y + point.y);
1234         if (__handlerDirection == HANDLER_DIRECTION_REVERSE_2 || __handlerDirection == HANDLER_DIRECTION_REVERSE_3)
1235         {
1236                 absoluteTouchMovedPoint.y += (GetBoundsF().height + absCursorRect.height);
1237         }
1238         if (__rowIndex == -1 && __columnIndex == -1)
1239         {
1240                 pEditPresenter->CalculateCursorBounds(pEditPresenter->GetTextBoundsF(), cursorRect,__handlerCursorPos);
1241                 pEditPresenter->CalculateAbsoluteCursorBounds(__handlerCursorPos, absCursorRect);
1242         }
1243         else
1244         {
1245                 pEditPresenter->CalculateCursorBounds(pEditPresenter->GetTextBoundsF(), cursorRect, __rowIndex, __columnIndex);
1246                 pEditPresenter->CalculateAbsoluteCursorBounds(__rowIndex, __columnIndex, absCursorRect);
1247         }
1248
1249         if (absTextObjectBounds.height >= (totalHeight - firstDisplayY))
1250         {
1251                 absTextObjectBounds.height = totalHeight - firstDisplayY;
1252                 absTextObjectBounds.y += absCursorRect.height/2.0f;
1253                 if (absTextObjectBounds.y > absoluteTouchMovedPoint.y || (absTextObjectBounds.y + absTextObjectBounds.height) < absoluteTouchMovedPoint.y)
1254                 {
1255                         needToFixYPosition = true;
1256                 }
1257         }
1258         else
1259         {
1260                 absTextObjectBounds.y += absCursorRect.height/2.0f;
1261                 if (firstDisplayY == 0.0f && absTextObjectBounds.y > absoluteTouchMovedPoint.y)
1262                 {
1263                         needToFixYPosition = true;
1264                 }
1265                 else if ((totalHeight - firstDisplayY) == absTextObjectBounds.height && (absTextObjectBounds.y + absTextObjectBounds.height) < absoluteTouchMovedPoint.y)
1266                 {
1267                         needToFixYPosition = true;
1268                 }
1269         }
1270
1271         if (!__singleHandler)
1272         {
1273                 int nextHandlerLine = -1;
1274                 if (__leftHandler)
1275                 {
1276                         nextHandlerLine = pTextObject->GetLineIndexAtTextIndex(__pCopyPasteManager->GetHandlerCursorPosition(Tizen::Ui::Controls::_EditCopyPasteManager::HANDLER_TYPE_RIGHT));
1277                 }
1278                 else
1279                 {
1280                         nextHandlerLine = pTextObject->GetLineIndexAtTextIndex(__pCopyPasteManager->GetHandlerCursorPosition(Tizen::Ui::Controls::_EditCopyPasteManager::HANDLER_TYPE_LEFT));
1281                 }
1282
1283                 if (curCursorLine == nextHandlerLine)
1284                 {
1285                         if (__leftHandler && absoluteTouchMovedPoint.y > absCursorRect.y)
1286                         {
1287                                 needToFixYPosition = true;
1288                         }
1289                         else if (!__leftHandler && absoluteTouchMovedPoint.y < absCursorRect.y)
1290                         {
1291                                 needToFixYPosition = true;
1292                         }
1293                 }
1294         }
1295
1296         touchPoint.x = cursorRect.x + (point.x - __touchPressedPoint.x);
1297         if (totalLine == 1 || needToFixYPosition)
1298         {
1299                 touchPoint.y = cursorRect.y + cursorRect.height/2;
1300         }
1301         else
1302         {
1303                 touchPoint.y = cursorRect.y + cursorRect.height + (point.y - __touchPressedPoint.y);
1304         }
1305         int rowIndex = -1;
1306         int columnIndex = -1;
1307         bool cursorPosFromTouch = false;
1308         cursorPos = pEditPresenter->GetCursorPositionAt(touchPoint, rowIndex, columnIndex, true);
1309
1310         if (cursorPos != -1 && __handlerCursorPos != cursorPos)
1311         {
1312                 cursorPosFromTouch = true;
1313                 FloatRectangle cursorBounds(0.0f, 0.0f, 0.0f, 0.0f);
1314                 if (__rowIndex == -1 && __columnIndex == -1)
1315                 {
1316                         pEdit->CalculateAbsoluteCursorBounds(cursorPos, cursorBounds);
1317                 }
1318                 else
1319                 {
1320                         pEditPresenter->CalculateAbsoluteCursorBounds(__rowIndex, __columnIndex, cursorBounds);
1321                 }
1322                 cursorChange = true;
1323                 checkPoint.x = cursorBounds.x;
1324
1325                 if (absoluteTouchMovedPoint.y -__absoluteTouchPressedPoint.y >= 0.0f || totalLine == 1)
1326                 {
1327                         checkPoint.y = cursorBounds.y + cursorBounds.height;
1328                 }
1329                 else
1330                 {
1331                         checkPoint.y = cursorBounds.y;
1332                 }
1333         }
1334
1335         if (cursorPos == -1 || (cursorChange && !__pCopyPasteManager->CheckHandleBounds(FloatPoint(checkPoint.x, checkPoint.y))))
1336         {
1337                 if (cursorPos != -1)
1338                 {
1339                         if (totalLine == 1)
1340                         {
1341                                 pTextObject->SetFirstDisplayLineIndexFromTextIndex(cursorPos);
1342                         }
1343                         else
1344                         {
1345                                 if (absoluteTouchMovedPoint.y -__absoluteTouchPressedPoint.y >= 0.0f)
1346                                 {
1347                                         if (curCursorLine < totalLine - 1)
1348                                         {
1349                                                 if (!pTextObject->IsDisplayedLastLine())
1350                                                 {
1351                                                         int line = pTextObject->GetFirstDisplayLineIndex();
1352                                                         pTextObject->SetFirstDisplayLineIndex(line+1);
1353                                                 }
1354                                                 else
1355                                                 {
1356                                                         if (__singleHandler || __pCopyPasteManager->CheckHandlePosition(__leftHandler, cursorPos))
1357                                                         {
1358                                                                 __pCopyPasteManager->SetCursorPosition(cursorPos);
1359                                                                 pEditPresenter->ScrollPanelToCursorPosition(true);
1360                                                         }
1361                                                         else
1362                                                         {
1363                                                                 return true;
1364                                                         }
1365                                                 }
1366                                         }
1367                                 }
1368                                 else
1369                                 {
1370                                         if (curCursorLine !=0)
1371                                         {
1372                                                 if (!pTextObject->IsDisplayedFirstLine())
1373                                                 {
1374                                                         int line = pTextObject->GetFirstDisplayLineIndex();
1375                                                         pTextObject->SetFirstDisplayLineIndex(line-1);
1376                                                 }
1377                                                 else
1378                                                 {
1379                                                         __pCopyPasteManager->SetCursorPosition(cursorPos);
1380                                                         pEditPresenter->ScrollPanelToCursorPosition(true);
1381                                                 }
1382                                         }
1383                                 }
1384                         }
1385                 }
1386                 else
1387                 {
1388                         if (totalLine == 1)
1389                         {
1390                                 if (point.x - __touchPressedPoint.x == 0.0f)
1391                                 {
1392                                         return true;
1393
1394                                 }
1395                                 else if (point.x - __touchPressedPoint.x > 0.0f)
1396                                 {
1397                                         if (__handlerCursorPos == pEditPresenter->GetTextLength())
1398                                         {
1399                                                 cursorPos = __handlerCursorPos;
1400                                         }
1401                                         else
1402                                         {
1403                                                 cursorPos = __handlerCursorPos + 1;
1404
1405                                                 if (!__singleHandler && __leftHandler && (cursorPos == pEditPresenter->GetTextLength()))
1406                                                 {
1407                                                         cursorPos = __handlerCursorPos;
1408                                                 }
1409                                         }
1410                                 }
1411                                 else
1412                                 {
1413                                         if (__handlerCursorPos != 0)
1414                                         {
1415                                                 cursorPos = __handlerCursorPos - 1;
1416
1417                                                 if (!__singleHandler && __leftHandler)
1418                                                 {
1419                                                         pTextObject->SetFirstDisplayLineIndexFromTextIndex(cursorPos);
1420                                                 }
1421                                         }
1422                                 }
1423                                 if (point.y < 0.0f || (point.y > GetBoundsF().height))
1424                                 {
1425                                         return true;
1426                                 }
1427                         }
1428                         else
1429                         {
1430                                 if (absoluteTouchMovedPoint.y -__absoluteTouchPressedPoint.y >= 0.0f)
1431                                 {
1432                                         if (curCursorLine < totalLine - 1)
1433                                         {
1434                                                 int offset = __handlerCursorPos - pTextObject->GetFirstTextIndexAt(curCursorLine);
1435                                                 int firstTextIndex = pTextObject->GetFirstTextIndexAt(curCursorLine+1);
1436                                                 cursorPos = offset + firstTextIndex;
1437                                                 int textLength = pTextObject->GetTextLengthAt(curCursorLine+1);
1438                                                 if (offset > textLength)
1439                                                 {
1440                                                         cursorPos = firstTextIndex+textLength;
1441                                                 }
1442                                                 if (!pTextObject->IsDisplayedLastLine())
1443                                                 {
1444                                                         int line = pTextObject->GetFirstDisplayLineIndex();
1445                                                         pTextObject->SetFirstDisplayLineIndex(line+1);
1446                                                         __pCopyPasteManager->SetCursorPosition(cursorPos);
1447                                                         pEditPresenter->ScrollPanelToCursorPosition(true);
1448                                                 }
1449                                                 else
1450                                                 {
1451                                                         if (__singleHandler || __pCopyPasteManager->CheckHandlePosition(__leftHandler, cursorPos))
1452                                                         {
1453                                                                 __pCopyPasteManager->SetCursorPosition(cursorPos);
1454                                                                 pEditPresenter->ScrollPanelToCursorPosition(true);
1455                                                         }
1456                                                         else
1457                                                         {
1458                                                                 return true;
1459                                                         }
1460                                                 }
1461                                         }
1462                                 }
1463                                 else
1464                                 {
1465                                         if (curCursorLine !=0)
1466                                         {
1467                                                 if (__rowIndex == 0)
1468                                                 {
1469                                                         return true;
1470                                                 }
1471                                                 int offset = __handlerCursorPos - pTextObject->GetFirstTextIndexAt(curCursorLine);
1472                                                 int firstTextIndex = pTextObject->GetFirstTextIndexAt(curCursorLine-1);
1473                                                 cursorPos = offset + firstTextIndex;
1474                                                 int textLength = pTextObject->GetTextLengthAt(curCursorLine-1);
1475                                                 if (offset > textLength)
1476                                                 {
1477                                                         cursorPos = firstTextIndex+textLength;
1478                                                 }
1479                                                 if (!pTextObject->IsDisplayedFirstLine())
1480                                                 {
1481                                                         int line = pTextObject->GetFirstDisplayLineIndex();
1482                                                         pTextObject->SetFirstDisplayLineIndex(line-1);
1483                                                         __pCopyPasteManager->SetCursorPosition(cursorPos);
1484                                                         pEditPresenter->ScrollPanelToCursorPosition(true);
1485                                                 }
1486                                                 else
1487                                                 {
1488                                                         __pCopyPasteManager->SetCursorPosition(cursorPos);
1489                                                         pEditPresenter->ScrollPanelToCursorPosition(true);
1490                                                 }
1491                                         }
1492                                 }
1493                         }
1494                 }
1495         }
1496
1497         if (!__singleHandler && !__pCopyPasteManager->CheckHandlePosition(__leftHandler, cursorPos))
1498         {
1499                 __pCopyPasteManager->SetCursorPosition(previousCursorPos);
1500                 pEditPresenter->SetCursorChangedFlag(!__leftHandler);
1501
1502                 if ((__pCopyPasteManager->GetEdit()->GetEditStyle() & EDIT_STYLE_SINGLE_LINE))
1503                 {
1504                         _EditCopyPasteManager::HandlerType nextHandlerType = _EditCopyPasteManager::HANDLER_TYPE_MAX;
1505                         if (__leftHandler)
1506                         {
1507                                 nextHandlerType = _EditCopyPasteManager::HANDLER_TYPE_RIGHT;
1508                         }
1509                         else
1510                         {
1511                                 nextHandlerType = _EditCopyPasteManager::HANDLER_TYPE_LEFT;
1512                         }
1513                         int nextHandler = __pCopyPasteManager->GetHandlerCursorPosition(nextHandlerType);
1514                         if (Math::Abs(nextHandler - __handlerCursorPos) <= 1)
1515                         {
1516                                 pTextObject->SetFirstDisplayLineIndexFromTextIndex(nextHandler);
1517                         }
1518                 }
1519                 return true;
1520         }
1521
1522         if (cursorPos == -1 || __handlerCursorPos == cursorPos)
1523         {
1524                 if (!__singleHandler)
1525                 {
1526                         __pCopyPasteManager->SetCursorPosition(previousCursorPos);
1527                         pEditPresenter->SetCursorChangedFlag(!__leftHandler);
1528                 }
1529                 if (!__singleHandler && (__pCopyPasteManager->GetEdit()->GetEditStyle() & EDIT_STYLE_SINGLE_LINE))
1530                 {
1531                         _EditCopyPasteManager::HandlerType nextHandlerType = _EditCopyPasteManager::HANDLER_TYPE_MAX;
1532                         if (__leftHandler)
1533                         {
1534                                 nextHandlerType = _EditCopyPasteManager::HANDLER_TYPE_RIGHT;
1535                         }
1536                         else
1537                         {
1538                                 nextHandlerType = _EditCopyPasteManager::HANDLER_TYPE_LEFT;
1539                         }
1540                         int nextHandler = __pCopyPasteManager->GetHandlerCursorPosition(nextHandlerType);
1541                         if (Math::Abs(nextHandler - __handlerCursorPos) <= 1)
1542                         {
1543                                 pTextObject->SetFirstDisplayLineIndexFromTextIndex(nextHandler);
1544                         }
1545                 }
1546                 return true;
1547         }
1548
1549         if (cursorPosFromTouch && (rowIndex != -1 && columnIndex != -1))
1550         {
1551                 __rowIndex = rowIndex;
1552                 __columnIndex =  columnIndex;
1553         }
1554         else
1555         {
1556                 __rowIndex = -1;
1557                 __columnIndex  = -1;
1558         }
1559
1560         pTextObject->SetFirstDisplayLineIndexFromTextIndex(cursorPos);
1561
1562         __handlerCursorPos = cursorPos;
1563         __pCopyPasteManager->SetCursorPosition(__handlerCursorPos);
1564         pEditPresenter->ScrollPanelToCursorPosition(true);
1565
1566         if (!__singleHandler)
1567         {
1568                 __pCopyPasteManager->RefreshBlock(__leftHandler);
1569         }
1570         else
1571         {
1572                 if (__rowIndex == -1 && __columnIndex == -1)
1573                 {
1574                         __pCopyPasteManager->SetCursorPosition(cursorPos);
1575                 }
1576                 else
1577                 {
1578                         pEditPresenter->SetCursorPosition(cursorPos, __rowIndex, __columnIndex);
1579                 }
1580                 pEditPresenter->DrawText();
1581                 AdjustBounds();
1582         }
1583         MoveCopyPasteMagnifier();
1584
1585         return true;
1586 }
1587
1588 bool
1589 _EditCopyPasteHandler::IsActivatedOnOpen(void) const
1590 {
1591         return false;
1592 }
1593
1594 void
1595 _EditCopyPasteHandler::OnChangeLayout(_ControlOrientation orientation)
1596 {
1597         AdjustBounds();
1598         return;
1599 }
1600
1601 result
1602 _EditCopyPasteHandler::OnAttachedToMainTree(void)
1603 {
1604         result r = E_SUCCESS;
1605
1606         if (GetOwner() == null)
1607         {
1608                 _Edit* pEdit = __pCopyPasteManager->GetEdit();
1609                 SysTryReturnResult(NID_UI_CTRL, pEdit, GetLastResult(), "Unable to get pEdit.");
1610
1611                 _EditPresenter* pEditPresenter = pEdit->GetPresenter();
1612                 SysTryReturnResult(NID_UI_CTRL, pEdit, GetLastResult(), "Unable to get pEditPresenter.");
1613
1614                 _Form* pParentForm = pEditPresenter->GetParentForm();
1615                 if (pParentForm)
1616                 {
1617                         SetOwner(pParentForm);
1618                 }
1619                 else
1620                 {
1621                         _Form* pForm = null;
1622                         _Frame* pCurrentFrame = dynamic_cast <_Frame*>(_ControlManager::GetInstance()->GetCurrentFrame());
1623                         if (pCurrentFrame)
1624                         {
1625                                 pForm = pCurrentFrame->GetCurrentForm();
1626                                 if (pForm)
1627                                 {
1628                                         SetOwner(pForm);
1629                                 }
1630                                 else
1631                                 {
1632                                         SetOwner(pCurrentFrame);
1633                                 }
1634                         }
1635                 }
1636         }
1637
1638         return r;
1639 }
1640
1641 result
1642 _EditCopyPasteHandler::OnBoundsChanging(const FloatRectangle& bounds)
1643 {
1644         result r = E_SUCCESS;
1645
1646         __windowBounds = bounds;
1647
1648         if (!GetVisibleState())
1649         {
1650                 return r;
1651         }
1652
1653         if (!__reverseCheck)
1654         {
1655                 _EcoreEvas* pEcoreEvas = GetEcoreEvasMgr()->GetEcoreEvas();
1656                 SysTryReturn(NID_UI, pEcoreEvas, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error occurred.");
1657
1658                 pEcoreEvas->SetWindowBounds(*GetRootWindow(), _CoordinateSystemUtils::ConvertToInteger(bounds));
1659                 result r = GetLastResult();
1660                 SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1661         }
1662
1663         return r;
1664 }
1665
1666 result
1667 _EditCopyPasteHandler::OnBoundsChanging(const Rectangle& bounds)
1668 {
1669         result r = E_SUCCESS;
1670         //To do
1671         return r;
1672 }
1673 result
1674 _EditCopyPasteHandler::SetWindowBounds(const Rectangle& bounds)
1675 {
1676         _EcoreEvas* pEcoreEvas = GetEcoreEvasMgr()->GetEcoreEvas();
1677         SysTryReturn(NID_UI, pEcoreEvas, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error occurred.");
1678
1679         pEcoreEvas->SetWindowBounds(*GetRootWindow(), bounds);
1680         result r = GetLastResult();
1681         SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1682
1683         return r;
1684 }
1685
1686 result
1687 _EditCopyPasteHandler::SetWindowBounds(const FloatRectangle& bounds)
1688 {
1689         _EcoreEvas* pEcoreEvas = GetEcoreEvasMgr()->GetEcoreEvas();
1690         SysTryReturn(NID_UI, pEcoreEvas, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error occurred.");
1691
1692         pEcoreEvas->SetWindowBounds(*GetRootWindow(), _CoordinateSystemUtils::ConvertToInteger(bounds));
1693         result r = GetLastResult();
1694         SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1695
1696         return r;
1697 }
1698
1699 _EditCopyPasteManager::_EditCopyPasteManager(_Edit& parenEdit)
1700         : __pCopyPastePopup(null)
1701         , __contextMenuAlign(CONTEXT_MENU_CORE_ALIGN_UP)
1702         , __pCoreCopyPasteEvent(null)
1703         , __pEdit(&parenEdit)
1704         , __pEditPresenter(null)
1705         , __contextMenuHeight(0.0f)
1706         , __needToReleaseBlock(true)
1707         , __isHandlerMoving(false)
1708         , __editVisibleArea(0.0f, 0.0f, 0.0f, 0.0f)
1709 {
1710         __pEditPresenter = __pEdit->GetPresenter();
1711         __pHandle[HANDLER_TYPE_CENTER] = null;
1712         __pHandle[HANDLER_TYPE_LEFT] = null;
1713         __pHandle[HANDLER_TYPE_RIGHT] = null;
1714
1715                 CreateHandle();
1716 }
1717
1718 _EditCopyPasteManager::~_EditCopyPasteManager(void)
1719 {
1720         Release();
1721
1722         if (__pCoreCopyPasteEvent)
1723         {
1724                 delete __pCoreCopyPasteEvent;
1725                 __pCoreCopyPasteEvent = null;
1726         }
1727 }
1728
1729 void
1730 _EditCopyPasteManager::Release(void)
1731 {
1732         if (__pCopyPastePopup)
1733         {
1734                 __pCopyPastePopup->Close();
1735                 delete __pCopyPastePopup;
1736                 __pCopyPastePopup = null;
1737         }
1738
1739         if (__pHandle[HANDLER_TYPE_CENTER])
1740         {
1741                 __pHandle[HANDLER_TYPE_CENTER]->Close();
1742                 delete __pHandle[HANDLER_TYPE_CENTER];
1743                 __pHandle[HANDLER_TYPE_CENTER] = null;
1744         }
1745
1746         if (__pHandle[HANDLER_TYPE_LEFT])
1747         {
1748                 __pHandle[HANDLER_TYPE_LEFT]->Close();
1749                 delete __pHandle[HANDLER_TYPE_LEFT];
1750                 __pHandle[HANDLER_TYPE_LEFT] = null;
1751         }
1752
1753         if (__pHandle[HANDLER_TYPE_RIGHT])
1754         {
1755                 __pHandle[HANDLER_TYPE_RIGHT]->Close();
1756                 delete __pHandle[HANDLER_TYPE_RIGHT];
1757                 __pHandle[HANDLER_TYPE_RIGHT] = null;
1758         }
1759 }
1760
1761 void
1762 _EditCopyPasteManager::ReleaseCopyPastePopup(void)
1763 {
1764         if (__pCopyPastePopup)
1765         {
1766                 __pCopyPastePopup->Close();
1767                 delete __pCopyPastePopup;
1768                 __pCopyPastePopup = null;
1769         }
1770 }
1771
1772 bool
1773 _EditCopyPasteManager::IsCopyPastePopup(const _Control& control) const
1774 {
1775         if (__pCopyPastePopup == &control)
1776         {
1777                 return true;
1778         }
1779
1780         return false;
1781 }
1782
1783 bool
1784 _EditCopyPasteManager::IsCopyPasteHandle(const _Control& control) const
1785 {
1786         if (__pHandle[HANDLER_TYPE_CENTER] == &control)
1787         {
1788                 return true;
1789         }
1790
1791         if (__pHandle[HANDLER_TYPE_LEFT] == &control)
1792         {
1793                 return true;
1794         }
1795
1796         if (__pHandle[HANDLER_TYPE_RIGHT] == &control)
1797         {
1798                 return true;
1799         }
1800
1801         return false;
1802 }
1803
1804 result
1805 _EditCopyPasteManager::AddCopyPasteEventListener(const _IEditCopyPasteEventListener& listener)
1806 {
1807         ClearLastResult();
1808
1809         if (__pCoreCopyPasteEvent == null)
1810         {
1811                 __pCoreCopyPasteEvent = _EditCopyPasteEvent::CreateInstanceN(*this);
1812                 SysTryReturn(NID_UI_CTRL, __pCoreCopyPasteEvent, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] System error occurred.\n");
1813         }
1814
1815         return __pCoreCopyPasteEvent->AddListener(listener);
1816 }
1817
1818 result
1819 _EditCopyPasteManager::SendCopyPasteEvent(CoreCopyPasteStatus status, CoreCopyPasteAction action)
1820 {
1821         if (__pCoreCopyPasteEvent)
1822         {
1823                 IEventArg* pCopyPasteEventArg = _EditCopyPasteEvent::CreateCopyPasteEventArgN(status, action);
1824                 SysTryReturn(NID_UI_CTRL, pCopyPasteEventArg, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Unable to create _LinkEventArg.");
1825
1826                 __pCoreCopyPasteEvent->Fire(*pCopyPasteEventArg);
1827         }
1828
1829         return E_SUCCESS;
1830 }
1831
1832 void
1833 _EditCopyPasteManager::CreateCopyPastePopup(void)
1834 {
1835         if (__pHandle[HANDLER_TYPE_CENTER])
1836         {
1837                 __pHandle[HANDLER_TYPE_CENTER]->DestroyCopyPasteMagnifier();
1838         }
1839         if (__pCopyPastePopup)
1840         {
1841                 __pCopyPastePopup->Close();
1842                 delete __pCopyPastePopup;
1843                 __pCopyPastePopup = null;
1844         }
1845
1846         FloatRectangle startRect;
1847         FloatRectangle endRect;
1848         FloatRectangle editAbsRect;
1849         FloatRectangle editShowAreaAbsRect;
1850         FloatRectangle commandButtonBounds;
1851         FloatRectangle keypadBounds(0.0f, 0.0f, 0.0f, 0.0f);
1852         FloatRectangle formClientBounds(0.0f, 0.0f, 0.0f, 0.0f);
1853         FloatRectangle panelAbsoulteBounds(0.0f, 0.0f, 0.0f, 0.0f);
1854         bool commandButtonExist = false;
1855         FloatRectangle cursorRect = GetCursorBoundsF(true);
1856
1857         float contextMenuHeight = 0.0f;
1858         float contextMenuTopMargin = 0.0f;
1859         float contextMenuBottomMargin = 0.0f;
1860         float contextMenuArrowHeight = 0.0f;
1861         float handlerHeight = 0.0f;
1862         bool isPasswordStyle = false;
1863         bool isClipped = false;
1864         if (__pEdit->GetEditStyle() & EDIT_STYLE_PASSWORD)
1865         {
1866                 isPasswordStyle = true;
1867         }
1868
1869         _ControlOrientation orientation = __pEdit->GetOrientation();
1870
1871         FloatDimension screenSize;
1872         _ControlManager* pControlManager = _ControlManager::GetInstance();
1873         if (orientation == _CONTROL_ORIENTATION_PORTRAIT)
1874         {
1875                 screenSize = pControlManager->GetScreenSizeF();
1876         }
1877         else
1878         {
1879                 screenSize.width = pControlManager->GetScreenSizeF().height;
1880                 screenSize.height = pControlManager->GetScreenSizeF().width;
1881         }
1882
1883         GET_SHAPE_CONFIG(EDIT::COPYPASTE_HANDLER_HEIGHT, orientation, handlerHeight);
1884
1885         GET_SHAPE_CONFIG(CONTEXTMENU::GRID_ITEM_HEIGHT, orientation, contextMenuHeight);
1886         GET_SHAPE_CONFIG(CONTEXTMENU::GRID_TOP_MARGIN, orientation, contextMenuTopMargin);
1887         GET_SHAPE_CONFIG(CONTEXTMENU::GRID_BOTTOM_MARGIN, orientation, contextMenuBottomMargin);
1888         GET_SHAPE_CONFIG(CONTEXTMENU::ANCHOR_HEIGHT, orientation, contextMenuArrowHeight);
1889
1890         isClipped = __pEdit->IsClipped();
1891         if ((__pEdit->GetTextLength() == 0 || __pEdit->GetEditStyle() & EDIT_STYLE_PASSWORD) && !isClipped)
1892         {
1893                 return;
1894         }
1895
1896         if (__pEdit->GetTextLength() == 0 && (__pEdit->GetEditStyle() & EDIT_STYLE_VIEWER))
1897         {
1898                 return;
1899         }
1900
1901         __contextMenuHeight = contextMenuHeight + contextMenuTopMargin + contextMenuBottomMargin + contextMenuArrowHeight;
1902         if (isClipped && __pEdit->IsViewModeEnabled() == false && __pEdit->GetTextLength() > 0 && orientation == _CONTROL_ORIENTATION_PORTRAIT)
1903         {
1904                 __contextMenuHeight = __contextMenuHeight + contextMenuHeight;
1905         }
1906
1907         editAbsRect = __pEdit->GetAbsoluteBoundsF();
1908
1909         _Toolbar* pCommandButton = __pEditPresenter->GetKeypadCommandButton();
1910         if (pCommandButton)
1911         {
1912                 commandButtonBounds = pCommandButton->GetAbsoluteBoundsF();
1913                 commandButtonExist = true;
1914         }
1915         _Form* pForm = __pEditPresenter->GetParentForm();
1916         if (pForm)
1917         {
1918                 formClientBounds = pForm->GetClientBoundsF();
1919         }
1920         _ScrollPanel* pPanel = __pEditPresenter->GetParentPanel();
1921         if (pPanel)
1922         {
1923                 panelAbsoulteBounds = pPanel->GetAbsoluteBoundsF();
1924         }
1925         __pEdit->GetKeypadBounds(keypadBounds);
1926
1927         // Edit Show Area
1928         {
1929                 editShowAreaAbsRect = editAbsRect;
1930                 FloatRectangle textObjectBounds = __pEditPresenter->GetTextBoundsF();
1931                 editShowAreaAbsRect.x += textObjectBounds.x;
1932                 editShowAreaAbsRect.y += textObjectBounds.y;
1933                 editShowAreaAbsRect.width = textObjectBounds.width;
1934                 if (!(__pEdit->GetEditStyle() & EDIT_STYLE_SINGLE_LINE))
1935                 {
1936                         editShowAreaAbsRect.height = textObjectBounds.height;
1937                 }
1938
1939                 if (commandButtonExist)
1940                 {
1941                         if (editShowAreaAbsRect.y + editShowAreaAbsRect.height > commandButtonBounds.y)
1942                         {
1943                                 editShowAreaAbsRect.height -= (editShowAreaAbsRect.y + editShowAreaAbsRect.height - commandButtonBounds.y);
1944                         }
1945                 }
1946                 else
1947                 {
1948                         if (editShowAreaAbsRect.y + editShowAreaAbsRect.height > keypadBounds.y)
1949                         {
1950                                 editShowAreaAbsRect.height -= (editShowAreaAbsRect.y + editShowAreaAbsRect.height - keypadBounds.y);
1951                         }
1952                 }
1953                 if (editShowAreaAbsRect.y < formClientBounds.y)
1954                 {
1955                         editShowAreaAbsRect.y = formClientBounds.y;
1956                         editShowAreaAbsRect.height -= formClientBounds.y;
1957                 }
1958                 if (editShowAreaAbsRect.y < panelAbsoulteBounds.y)
1959                 {
1960                         editShowAreaAbsRect.y = panelAbsoulteBounds.y;
1961                         editShowAreaAbsRect.height -= (panelAbsoulteBounds.y - editShowAreaAbsRect.y);
1962                 }
1963                 __editVisibleArea = editShowAreaAbsRect;
1964         }
1965         FloatPoint copyPastePoint(0.0f, 0.0f);
1966         __contextMenuAlign = CONTEXT_MENU_CORE_ALIGN_UP;
1967
1968         if (__pEdit->IsBlocked())
1969         {
1970                 int start = -1;
1971                 int end = -1;
1972                 __pEdit->GetBlockRange(start, end);
1973                 if (start == -1 || end == -1)
1974                 {
1975                         SysLog(NID_UI_CTRL, "[EditCopyPasteManager] There is no blocked Range");
1976                         return;
1977                 }
1978
1979                 __pEdit->CalculateAbsoluteCursorBounds(start, startRect);
1980                 __pEdit->CalculateAbsoluteCursorBounds(end, endRect);
1981                 if (startRect.x > endRect.x)
1982                 {
1983                         copyPastePoint.x = endRect.x + (startRect.x - endRect.x)/2;
1984                 }
1985                 else if (startRect.x < endRect.x)
1986                 {
1987                         copyPastePoint.x = startRect.x + (endRect.x - startRect.x)/2;
1988                 }
1989                 else
1990                 {
1991                         copyPastePoint.x = startRect.x;
1992                 }
1993
1994                 if (copyPastePoint.x < editShowAreaAbsRect.x)
1995                 {
1996                         copyPastePoint.x = editShowAreaAbsRect.x;
1997                 }
1998                 else if (copyPastePoint.x > (editShowAreaAbsRect.x + editShowAreaAbsRect.width))
1999                 {
2000                         copyPastePoint.x = editShowAreaAbsRect.x + editShowAreaAbsRect.width;
2001                 }
2002
2003                 //Both of handlers are located on the top of the Editor.
2004                 if ( ((startRect.y + startRect.height) < editShowAreaAbsRect.y) && ((endRect.y + endRect.height) < editShowAreaAbsRect.y))
2005                 {
2006                         SysLog(NID_UI_CTRL, "Both of handlers are located on the top of the Editor.\n");
2007                         return;
2008                 }
2009                 //Both of handlers are located on the bottom of the Editor.
2010                 else if( ((startRect.y + startRect.height) > editShowAreaAbsRect.y + editShowAreaAbsRect.height ) && ((endRect.y + endRect.height) > editShowAreaAbsRect.y + editShowAreaAbsRect.height))
2011                 {
2012                         SysLog(NID_UI_CTRL, "Both of handlers are located on the bottom of the Editor.\n");
2013                         return;
2014                 }
2015                 // Left handler is located on the top of the Editor and Right handler is located on the bottom of the Editor.
2016                 else if ( ((startRect.y + startRect.height) < editShowAreaAbsRect.y) && ((endRect.y + endRect.height) > (editShowAreaAbsRect.y + editShowAreaAbsRect.height)))
2017                 {
2018                         copyPastePoint.y = editShowAreaAbsRect.y + editShowAreaAbsRect.height/2;
2019
2020                         if (copyPastePoint.y < __contextMenuHeight)
2021                         {
2022                                 __contextMenuAlign = CONTEXT_MENU_CORE_ALIGN_DOWN;
2023                         }
2024
2025                 }
2026                 // Left handler is located on the top of the Editor and Right handler is located on the Editor
2027                 else if ( ((startRect.y + startRect.height) < editShowAreaAbsRect.y) && ((endRect.y + endRect.height) <= (editShowAreaAbsRect.y + editShowAreaAbsRect.height)) )
2028                 {
2029                         if ( (endRect.y + endRect.height + handlerHeight + __contextMenuHeight) < keypadBounds.y)
2030                         {
2031                                 __contextMenuAlign = CONTEXT_MENU_CORE_ALIGN_DOWN;
2032                                 copyPastePoint.y = endRect.y + endRect.height + handlerHeight;
2033                         }
2034                         else if (endRect.y - editShowAreaAbsRect.y > __contextMenuHeight)
2035                         {
2036                                 copyPastePoint.y = editShowAreaAbsRect.y + __contextMenuHeight;
2037                         }
2038                         else if (endRect.y > __contextMenuHeight)
2039                         {
2040                                 copyPastePoint.y = endRect.y;
2041                         }
2042                         else
2043                         {
2044                                 SysLog(NID_UI_CTRL, "There is no space to draw the copy&paste popup\n");
2045                                 return;
2046                         }
2047                 }
2048                 // Left handler is located on the Editor and Right handler is located on the bottom of the Editor
2049                 else if ( ((startRect.y + startRect.height) >= editShowAreaAbsRect.y) && ((endRect.y + endRect.height) > (editShowAreaAbsRect.y + editShowAreaAbsRect.height)) )
2050                 {
2051                         if (__contextMenuHeight < startRect.y)
2052                         {
2053                                 copyPastePoint.y = startRect.y;
2054                         }
2055                         else
2056                         {
2057                                 copyPastePoint.y = startRect.y + (editShowAreaAbsRect.y + editShowAreaAbsRect.height - startRect.y)/2;
2058                         }
2059                 }
2060                 // There is a  space on the top of the Editor.
2061                 else if (__contextMenuHeight < startRect.y)
2062                 {
2063                         copyPastePoint.y = startRect.y;
2064                 }
2065                 // There is a  space on the bottom of the Editor.
2066                 else if ( screenSize.height  > (endRect.y + endRect.height + handlerHeight + __contextMenuHeight))
2067                 {
2068                         __contextMenuAlign = CONTEXT_MENU_CORE_ALIGN_DOWN;
2069
2070                         copyPastePoint.y = endRect.y + endRect.height + handlerHeight;
2071                 }
2072                 // There is no space on the top and bottom of the Editor. The Popup should be drawn on the center of the Editor.
2073                 else
2074                 {
2075                         if (endRect.y - startRect.y < __contextMenuHeight)
2076                         {
2077                                 SysLog(NID_UI_CTRL, "There is no space to draw the copy&paste popup\n");
2078                                 return;
2079                         }
2080                         copyPastePoint.y = startRect.y + __contextMenuHeight;
2081                 }
2082         }
2083
2084         else
2085         {
2086                 if (editShowAreaAbsRect.height <= 0)
2087                 {
2088                         return;
2089                 }
2090                 FloatRectangle cursorRect;
2091                 int cursorPosition = GetCursorPosition();
2092                 __pEdit->CalculateAbsoluteCursorBounds(cursorPosition, cursorRect);
2093                 copyPastePoint.x = cursorRect.x;
2094                 copyPastePoint.y = cursorRect.y;
2095
2096                 if (__editVisibleArea.y > copyPastePoint.y || __editVisibleArea.y + __editVisibleArea.height < copyPastePoint.y)
2097                 {
2098                         return;
2099                 }
2100
2101                 if (copyPastePoint.y < __contextMenuHeight)
2102                 {
2103                         FloatRectangle cursorRect = GetCursorBoundsF(true);
2104
2105                         copyPastePoint.y += cursorRect.height;
2106                         __contextMenuAlign = CONTEXT_MENU_CORE_ALIGN_DOWN;
2107                         if (__pHandle[HANDLER_TYPE_CENTER])
2108                         {
2109                                 copyPastePoint.y += __pHandle[HANDLER_TYPE_CENTER]->GetBounds().height;
2110                         }
2111                 }
2112         }
2113
2114         //Todo: Create API  ex)CreateContrexMenuFN
2115         __pCopyPastePopup = _ContextMenu::CreateContextMenuN(copyPastePoint, CONTEXT_MENU_CORE_STYLE_GRID, __contextMenuAlign);
2116         SysTryReturnVoidResult(NID_UI_CTRL, __pCopyPastePopup, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2117
2118         if ( __pEdit->GetTextLength() != 0  && !isPasswordStyle)
2119         {
2120                 if (__pEdit->IsBlocked())
2121                 {
2122                         String copyText;
2123                         String cutText;
2124
2125                         GET_STRING_CONFIG(IDS_TPLATFORM_OPT_COPY, copyText);
2126                         GET_STRING_CONFIG(IDS_TPLATFORM_OPT_CUT, cutText);
2127
2128                         __pCopyPastePopup->AddItem(copyText, COPY_PASTE_COPY_ID, null, null, null);
2129                         if (!__pEdit->IsViewModeEnabled())
2130                         {
2131                                 __pCopyPastePopup->AddItem(cutText, COPY_PASTE_CUT_ID, null, null, null);
2132                         }
2133                 }
2134                 else
2135                 {
2136                         String selectText;
2137                         String selectAllText;
2138
2139                         GET_STRING_CONFIG(IDS_TPLATFORM_OPT_SELECT, selectText);
2140                         GET_STRING_CONFIG(IDS_TPLATFORM_OPT_SELECT_ALL, selectAllText);
2141
2142                         __pCopyPastePopup->AddItem(selectText, COPY_PASTE_SELECT_ID, null, null, null);
2143                         __pCopyPastePopup->AddItem(selectAllText, COPY_PASTE_SELECT_ALL_ID, null, null, null);
2144                 }
2145         }
2146
2147         if (isClipped)
2148         {
2149                 if (!__pEdit->IsViewModeEnabled())
2150                 {
2151                         String pasteText;
2152                         String clipboardText;
2153
2154                         GET_STRING_CONFIG(IDS_TPLATFORM_OPT_PASTE, pasteText);
2155                         GET_STRING_CONFIG(IDS_TPLATFORM_OPT_CLIPBOARD, clipboardText);
2156
2157                         __pCopyPastePopup->AddItem(pasteText, COPY_PASTE_PASTE_ID, null, null, null);
2158                         if (!isPasswordStyle && __pEdit->IsKeypadEnabled())
2159                         {
2160                                 __pCopyPastePopup->AddItem(clipboardText, COPY_PASTE_CLIPBOARD_ID, null, null, null);
2161                         }
2162                 }
2163         }
2164
2165         __pCopyPastePopup->AddActionEventListener(*this);
2166         return;
2167 /*
2168         Bitmap* pSearchBitmap = null;
2169         Bitmap* pReplacedSearchBitmap = null;
2170         Bitmap* pReplacedSearchPressedBitmap = null;
2171         Color searchColor;
2172         Color searchPressedColor;
2173         result r = E_SUCCESS;
2174
2175         if (__pEdit->IsBlocked() && !isPasswordStyle)
2176         {
2177                 r = GET_BITMAP_CONFIG_N(EDIT::COPY_PASTE_SEARCH_ICON, BITMAP_PIXEL_FORMAT_ARGB8888, pSearchBitmap);
2178                 SysTryReturnVoidResult(NID_UI_CTRL, (r == E_SUCCESS), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2179
2180                 GET_COLOR_CONFIG(CONTEXTMENU::ITEM_TEXT_NORMAL, searchColor);
2181                 GET_COLOR_CONFIG(CONTEXTMENU::ITEM_TEXT_PRESSED, searchPressedColor);
2182
2183                 pReplacedSearchBitmap = _BitmapImpl::GetColorReplacedBitmapN(*pSearchBitmap, Color::GetColor(COLOR_ID_MAGENTA), searchColor);
2184                 SysTryCatch(NID_UI_CTRL, pReplacedSearchBitmap, r = GetLastResult(), GetLastResult(),"[%s] Propagating.", GetErrorMessage(GetLastResult()));
2185
2186                 pReplacedSearchPressedBitmap = _BitmapImpl::GetColorReplacedBitmapN(*pSearchBitmap, Color::GetColor(COLOR_ID_MAGENTA), searchPressedColor);
2187                 SysTryCatch(NID_UI_CTRL, pReplacedSearchPressedBitmap, r = GetLastResult(), GetLastResult(),"[%s] Propagating.", GetErrorMessage(GetLastResult()));
2188
2189                 __pCopyPastePopup->AddItem(null, COPY_PASTE_SEARCH_ID, pReplacedSearchBitmap, pReplacedSearchPressedBitmap, null);
2190         }
2191
2192         if (pSearchBitmap)
2193         {
2194                 delete pSearchBitmap;
2195                 pSearchBitmap = null;
2196         }
2197         if (pReplacedSearchBitmap)
2198         {
2199                 delete pReplacedSearchBitmap;
2200                 pReplacedSearchBitmap = null;
2201         }
2202
2203         if (pReplacedSearchPressedBitmap)
2204         {
2205                 delete pReplacedSearchPressedBitmap;
2206                 pReplacedSearchPressedBitmap = null;
2207         }
2208         __pCopyPastePopup->AddActionEventListener(*this);
2209
2210         return;
2211
2212 CATCH:
2213         delete pSearchBitmap;
2214         pSearchBitmap = null;
2215
2216         delete pReplacedSearchBitmap;
2217         pReplacedSearchBitmap = null;
2218
2219         return;
2220 */
2221 }
2222
2223 void
2224 _EditCopyPasteManager::CreateHandle(void)
2225 {
2226         Release();
2227
2228         if (__pEdit->IsBlocked())
2229         {
2230                 int start = -1;
2231                 int end = -1;
2232                 FloatRectangle startRect;
2233                 FloatRectangle endRect;
2234
2235                 __pEdit->GetBlockRange(start, end);
2236
2237                 __pEdit->CalculateAbsoluteCursorBounds(start, startRect);
2238                 __pEdit->CalculateAbsoluteCursorBounds(end, endRect);
2239
2240                 Point leftHandler(startRect.x, startRect.y + startRect.height);
2241                 Point rightHandler(endRect.x, endRect.y + endRect.height);
2242
2243                 __pHandle[HANDLER_TYPE_LEFT] = _EditCopyPasteHandler::CreateInstanceN(leftHandler, start, this, false, true);
2244                 __pHandle[HANDLER_TYPE_RIGHT] = _EditCopyPasteHandler::CreateInstanceN(rightHandler, end, this, false, false);
2245         }
2246         else
2247         {
2248                 FloatRectangle centerRect;
2249                 __pEdit->CalculateAbsoluteCursorBounds(__pEdit->GetCursorPosition(), centerRect);
2250                 Point centerHandler(centerRect.x, centerRect.y + centerRect.height);
2251
2252                 __pHandle[HANDLER_TYPE_CENTER] = _EditCopyPasteHandler::CreateInstanceN(centerHandler, __pEdit->GetCursorPosition(), this, true, true);
2253 #if EDIT_COPY_PASTE_MAGNIFIER
2254 //              __pHandle[HANDLER_TYPE_CENTER]->CreateCopyPasteMagnifier();
2255 #endif
2256         }
2257 }
2258
2259 void
2260 _EditCopyPasteManager::Show(void)
2261 {
2262         if (__pHandle[HANDLER_TYPE_CENTER])
2263         {
2264                 if (__pEdit->GetCursorPosition() != __pHandle[HANDLER_TYPE_CENTER]->GetHandlerCursorPosition())
2265                 {
2266                         __pHandle[HANDLER_TYPE_CENTER]->SetHandlerCursorPosition(__pEdit->GetCursorPosition());
2267 //                      __pHandle[HANDLER_TYPE_CENTER]->MoveCopyPasteMagnifier();
2268                 }
2269                 __pHandle[HANDLER_TYPE_CENTER]->AdjustBounds();
2270                 __pHandle[HANDLER_TYPE_CENTER]->CheckReverseStatus();
2271                 __pEdit->Invalidate();
2272         }
2273
2274         if (__pHandle[HANDLER_TYPE_LEFT] && __pHandle[HANDLER_TYPE_RIGHT])
2275         {
2276                 AdjustBounds();
2277                 __pHandle[HANDLER_TYPE_LEFT]->CheckReverseStatus();
2278                 __pHandle[HANDLER_TYPE_RIGHT]->CheckReverseStatus();
2279                 __pHandle[HANDLER_TYPE_LEFT]->Invalidate();
2280                 __pHandle[HANDLER_TYPE_RIGHT]->Invalidate();
2281                 __pEdit->Invalidate();
2282         }
2283
2284         if (__pCopyPastePopup)
2285         {
2286                 __pCopyPastePopup->Open();
2287                 __pCopyPastePopup->ReleaseTouchCapture();
2288
2289                 _Control* pControl = __pCopyPastePopup->GetOwner();
2290                 if (pControl)
2291                 {
2292                         pControl->UnlockInputEvent();
2293                 }
2294         }
2295 }
2296
2297 bool
2298 _EditCopyPasteManager::CheckHandleBounds(const FloatPoint& point)
2299 {
2300         bool hasCommandButton = false;
2301         bool hasParentForm = false;
2302         bool hasParentPanel = false;
2303         bool showCheck = true;
2304         FloatRectangle commandButtonBounds(0.0f, 0.0f, 0.0f, 0.0f);
2305         FloatRectangle formClientBounds(0.0f, 0.0f, 0.0f, 0.0f);
2306         FloatRectangle panelAbsoulteBounds(0.0f, 0.0f, 0.0f, 0.0f);
2307         FloatRectangle editAbsBounds = __pEdit->GetAbsoluteBoundsF();
2308         FloatRectangle textObjectBounds = __pEditPresenter->GetTextBoundsF();
2309         editAbsBounds.x += textObjectBounds.x;
2310         editAbsBounds.y += textObjectBounds.y;
2311         editAbsBounds.width = textObjectBounds.width;
2312
2313         if (!(__pEdit->GetEditStyle() & EDIT_STYLE_SINGLE_LINE))
2314         {
2315                 editAbsBounds.height = textObjectBounds.height;
2316         }
2317
2318         _Toolbar* pCommandButton = __pEditPresenter->GetKeypadCommandButton();
2319         if (pCommandButton)
2320         {
2321                 commandButtonBounds = pCommandButton->GetAbsoluteBoundsF();
2322                 hasCommandButton = true;
2323         }
2324         _Form* pForm = __pEditPresenter->GetParentForm();
2325         if (pForm)
2326         {
2327                 formClientBounds = pForm->GetClientBoundsF();
2328                 hasParentForm = true;
2329         }
2330
2331         _ScrollPanel* pPanel = __pEditPresenter->GetParentPanel();
2332         if (pPanel)
2333         {
2334                 panelAbsoulteBounds = pPanel->GetAbsoluteBoundsF();
2335                 hasParentPanel = true;
2336         }
2337
2338         if ((!_FloatCompare(editAbsBounds.x, point.x) && (editAbsBounds.x > point.x)) || (!_FloatCompare(point.x, editAbsBounds.x + editAbsBounds.width) && point.x > (editAbsBounds.x + editAbsBounds.width)))
2339         {
2340                 showCheck = false;
2341         }
2342
2343         if ((!_FloatCompare(editAbsBounds.y, point.y) && (editAbsBounds.y > point.y)) || (!_FloatCompare(point.y, editAbsBounds.y + editAbsBounds.height) && point.y > (editAbsBounds.y + editAbsBounds.height)))
2344         {
2345                 showCheck = false;
2346         }
2347         if (hasParentForm && ((!_FloatCompare(formClientBounds.y, point.y) && formClientBounds.y > point.y) || (!_FloatCompare(point.y, formClientBounds.y + formClientBounds.height) && point.y > (formClientBounds.y + formClientBounds.height))))
2348         {
2349                 showCheck = false;
2350         }
2351         if (hasParentPanel && ((!_FloatCompare(panelAbsoulteBounds.y, point.y) && panelAbsoulteBounds.y > point.y) || (!_FloatCompare(point.y, panelAbsoulteBounds.y + panelAbsoulteBounds.height) && point.y > (panelAbsoulteBounds.y + panelAbsoulteBounds.height))))
2352         {
2353                 showCheck = false;
2354         }
2355         if (hasCommandButton && commandButtonBounds.Contains(point))
2356         {
2357                 showCheck = false;
2358         }
2359         return showCheck;
2360 }
2361
2362 bool
2363 _EditCopyPasteManager::CheckHandlePosition(bool leftHandle, int cursorPosition)
2364 {
2365         int leftHandlerPosition = __pHandle[HANDLER_TYPE_LEFT]->GetHandlerCursorPosition();
2366         int rightHandlerPosition = __pHandle[HANDLER_TYPE_RIGHT]->GetHandlerCursorPosition();
2367
2368         if (leftHandle)
2369         {
2370                 if (cursorPosition + 1 <= rightHandlerPosition)
2371                 {
2372                         return true;
2373                 }
2374                 else
2375                 {
2376                         return false;
2377                 }
2378         }
2379         else
2380         {
2381                 if (cursorPosition >= leftHandlerPosition + 1)
2382                 {
2383                         return true;
2384                 }
2385                 else
2386                 {
2387                         return false;
2388                 }
2389         }
2390 }
2391
2392 void
2393 _EditCopyPasteManager::RefreshBlock(bool isLeftHandle)
2394 {
2395         int leftRowIndex = -1;
2396         int leftColumnIndex = -1;
2397         int rightRowIndex = -1;
2398         int rightColumnIndex = -1;
2399
2400         int leftHandlerPos = __pHandle[HANDLER_TYPE_LEFT]->GetHandlerCursorPosition();
2401         int rightHandlerPos = __pHandle[HANDLER_TYPE_RIGHT]->GetHandlerCursorPosition();
2402         __pHandle[HANDLER_TYPE_RIGHT]->GetHandlerRowColumnIndex(leftRowIndex, leftColumnIndex);
2403         __pHandle[HANDLER_TYPE_RIGHT]->GetHandlerRowColumnIndex(rightRowIndex, rightColumnIndex);
2404
2405         __pEditPresenter->SetBlockRange(leftHandlerPos, rightHandlerPos, leftColumnIndex, leftColumnIndex, rightRowIndex, rightColumnIndex);
2406
2407         __pEditPresenter->SetCursorChangedFlag(!isLeftHandle);
2408         __pEditPresenter->DrawText();
2409         AdjustBounds();
2410 }
2411
2412 FloatRectangle
2413 _EditCopyPasteManager::GetCursorBoundsF(bool isAbsRect) const
2414 {
2415         FloatRectangle cursorBounds;
2416
2417         __pEdit->GetCursorBounds(isAbsRect, cursorBounds);
2418
2419         return cursorBounds;
2420 }
2421
2422 int
2423 _EditCopyPasteManager::GetCursorPositionAt(const FloatPoint& touchPoint) const
2424 {
2425         return __pEdit->GetCursorPositionAt(touchPoint);
2426 }
2427
2428 result
2429 _EditCopyPasteManager::SetCursorPosition(int position)
2430 {
2431         return __pEdit->SetCursorPosition(position);
2432 }
2433
2434 int
2435 _EditCopyPasteManager::GetCursorPosition(void) const
2436 {
2437         return __pEdit->GetCursorPosition();
2438 }
2439
2440 int
2441 _EditCopyPasteManager::GetHandlerCursorPosition(HandlerType handlerType) const
2442 {
2443         return __pHandle[handlerType]->GetHandlerCursorPosition();
2444 }
2445
2446 void
2447 _EditCopyPasteManager::SendTextBlockEvent(void)
2448 {
2449         int start = -1;
2450         int end = -1;
2451         result r = E_SUCCESS;
2452
2453         __pEdit->GetBlockRange(start, end);
2454         if (start != -1 && end != -1)
2455         {
2456                 r = __pEdit->SendTextBlockEvent(start, end);
2457                 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
2458         }
2459 }
2460
2461 void
2462 _EditCopyPasteManager::OnActionPerformed(const _Control& source, int actionId)
2463 {
2464         _Clipboard* pClipBoard = _Clipboard::GetInstance();
2465         SysTryReturnVoidResult(NID_UI_CTRL, pClipBoard, E_SYSTEM, "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2466
2467         ReleaseCopyPastePopup();
2468
2469         switch (actionId)
2470         {
2471         case COPY_PASTE_SELECT_ID:
2472                 {
2473                         int cursorPos = GetCursorPosition();
2474                         int start, end;
2475
2476                         __pEdit->GetWordPosition(cursorPos, start, end);
2477                         __pEdit->SetBlockRange(start, end);
2478                         SendTextBlockEvent();
2479
2480                         Release();
2481                         CreateHandle();
2482                         CreateCopyPastePopup();
2483                         Show();
2484
2485                         __pEdit->Draw();
2486                 }
2487                 break;
2488
2489         case COPY_PASTE_SELECT_ALL_ID:
2490                 {
2491                         int textLength = __pEdit->GetTextLength();
2492                         __pEdit->SetBlockRange(0, textLength);
2493                         SendTextBlockEvent();
2494                         __pEditPresenter->UpdateComponentInformation();
2495
2496                         Release();
2497                         CreateHandle();
2498                         CreateCopyPastePopup();
2499                         Show();
2500
2501                         __pEdit->Draw();
2502                 }
2503                 break;
2504
2505         case COPY_PASTE_COPY_ID:
2506                 ReleaseCopyPastePopup();
2507                 SendCopyPasteEvent(CORE_COPY_PASTE_STATUS_HIDE, CORE_COPY_PASTE_ACTION_COPY);
2508                 break;
2509
2510         case COPY_PASTE_CUT_ID:
2511                 SendCopyPasteEvent(CORE_COPY_PASTE_STATUS_HIDE, CORE_COPY_PASTE_ACTION_CUT);
2512                 break;
2513
2514         case COPY_PASTE_PASTE_ID:
2515                 SendCopyPasteEvent(CORE_COPY_PASTE_STATUS_HIDE, CORE_COPY_PASTE_ACTION_PASTE);
2516                 break;
2517
2518         case COPY_PASTE_CLIPBOARD_ID:
2519                 __needToReleaseBlock = false;
2520                 pClipBoard->ShowPopup(CLIPBOARD_DATA_TYPE_TEXT, *__pEdit);
2521                 ReleaseCopyPastePopup();
2522                 SendCopyPasteEvent(CORE_COPY_PASTE_STATUS_HIDE, CORE_COPY_PASTE_ACTION_CLIPBOARD);
2523                 break;
2524         case COPY_PASTE_SEARCH_ID:
2525                 LaunchSearch();
2526                 SendCopyPasteEvent(CORE_COPY_PASTE_STATUS_HIDE, CORE_COPY_PASTE_ACTION_SEARCH);
2527                 break;
2528         default:
2529                 break;
2530         }
2531
2532         return;
2533 }
2534
2535 void
2536 _EditCopyPasteManager::AdjustBounds(void)
2537 {
2538         if (__pHandle[HANDLER_TYPE_CENTER])
2539         {
2540                 __pHandle[HANDLER_TYPE_CENTER]->AdjustBounds();
2541         }
2542         if (__pHandle[HANDLER_TYPE_LEFT])
2543         {
2544                 __pHandle[HANDLER_TYPE_LEFT]->AdjustBounds();
2545         }
2546         if (__pHandle[HANDLER_TYPE_RIGHT])
2547         {
2548                 __pHandle[HANDLER_TYPE_RIGHT]->AdjustBounds();
2549         }
2550 }
2551
2552 void
2553 _EditCopyPasteManager::LaunchSearch(void)
2554 {
2555         result r = E_SUCCESS;
2556         int start = -1;
2557         int end = -1;
2558         __pEdit->GetBlockRange(start, end);
2559         String blockText = __pEditPresenter->GetText(start, end-1);
2560
2561         _AppMessageImpl msg;
2562
2563         msg.AddData(APPSVC_DATA_KEYWORD, blockText);
2564         r = _AppControlManager::GetInstance()->LaunchPkg(msg, null, APPSVC_OPERATION_SEARCH, null, null, 0, 0);
2565 }
2566
2567 bool
2568 _EditCopyPasteManager::GetTextBlockReleaseFlag(void) const
2569 {
2570         return __needToReleaseBlock;
2571 }
2572
2573 void
2574 _EditCopyPasteManager::SetTextBlockReleaseFlag(bool enabled)
2575 {
2576         __needToReleaseBlock = enabled;
2577 }
2578
2579 bool
2580 _EditCopyPasteManager::IsCopyPasteHandleExist(void) const
2581 {
2582         if (__pHandle[HANDLER_TYPE_CENTER] || (__pHandle[HANDLER_TYPE_LEFT] && __pHandle[HANDLER_TYPE_RIGHT]))
2583         {
2584                 return true;
2585         }
2586         else
2587         {
2588                 return false;
2589         }
2590 }
2591
2592 bool
2593 _EditCopyPasteManager::IsCopyPasteSingleHandleExist(void) const
2594 {
2595         if (__pHandle[HANDLER_TYPE_CENTER])
2596         {
2597                 return true;
2598         }
2599         else
2600         {
2601                 return false;
2602         }
2603 }
2604
2605 void
2606 _EditCopyPasteManager::UpdateCopyPasteMagnifier(void)
2607 {
2608         for (int i = 0; i < HANDLER_TYPE_MAX; i++)
2609         {
2610                 if (__pHandle[i])
2611                 {
2612                         __pHandle[i]->UpdateCopyPasteMagnifier();
2613                 }
2614         }
2615 }
2616
2617 _Edit*
2618 _EditCopyPasteManager::GetEdit(void) const
2619 {
2620         return __pEdit;
2621 }
2622
2623 void
2624 _EditCopyPasteManager::MoveHandler(HandlerMoveType moveType)
2625 {
2626         if (!__pHandle[HANDLER_TYPE_RIGHT] || ! __pHandle[HANDLER_TYPE_LEFT])
2627         {
2628                 return;
2629         }
2630
2631         int leftHandlerPosition = __pHandle[HANDLER_TYPE_LEFT]->GetHandlerCursorPosition();
2632         int rightHandlerPosition = __pHandle[HANDLER_TYPE_RIGHT]->GetHandlerCursorPosition();
2633         int textLength = __pEdit->GetTextLength();
2634        FloatRectangle cursorBounds;
2635         int newCursorPosition;
2636         __pEdit->GetCursorBounds(false, cursorBounds);
2637         FloatPoint cursorPoint(cursorBounds.x, cursorBounds.y);
2638
2639         TextObject* pTextObject = __pEditPresenter->GetTextObject();
2640
2641         switch(moveType)
2642         {
2643                 case HANDLER_MOVE_TYPE_LEFT:
2644                         if (leftHandlerPosition < rightHandlerPosition-1)
2645                         {
2646                                 __pHandle[HANDLER_TYPE_RIGHT]->SetHandlerCursorPosition(--rightHandlerPosition);
2647                                 RefreshBlock();
2648                                 __pHandle[HANDLER_TYPE_RIGHT]->CheckReverseStatus();
2649                                 __pHandle[HANDLER_TYPE_RIGHT]->Invalidate();
2650                         }
2651                         else
2652                         {
2653                                 return;
2654                         }
2655                         break;
2656                 case HANDLER_MOVE_TYPE_UP:
2657                         cursorPoint.y -= cursorBounds.height/2.0f;
2658                         newCursorPosition = GetCursorPositionAt(cursorPoint);
2659
2660                         if (newCursorPosition <= 0)
2661                         {
2662                                 int curCursorLine = pTextObject->GetLineIndexAtTextIndex(pTextObject->GetCursorIndex());
2663
2664                                 if (curCursorLine !=0 )
2665                                 {
2666                                         int offset = rightHandlerPosition - pTextObject->GetFirstTextIndexAt(curCursorLine);
2667                                         int firstTextIndex = pTextObject->GetFirstTextIndexAt(curCursorLine-1);
2668                                         newCursorPosition = offset + firstTextIndex;
2669                                         int textLength = pTextObject->GetTextLengthAt(curCursorLine-1);
2670                                         if (offset > textLength)
2671                                         {
2672                                                 newCursorPosition = firstTextIndex+textLength;
2673                                         }
2674
2675                                         if (leftHandlerPosition >= newCursorPosition)
2676                                         {
2677                                                 newCursorPosition = leftHandlerPosition + 1;
2678                                         }
2679                                 }
2680                         }
2681
2682                         if (newCursorPosition >= 0 && leftHandlerPosition < newCursorPosition)
2683                         {
2684                                 __pHandle[HANDLER_TYPE_RIGHT]->SetHandlerCursorPosition(newCursorPosition);
2685                                 RefreshBlock();
2686                                 __pHandle[HANDLER_TYPE_RIGHT]->CheckReverseStatus();
2687                                 __pHandle[HANDLER_TYPE_RIGHT]->Invalidate();
2688                         }
2689                         else
2690                         {
2691                                 return;
2692                         }
2693                         break;
2694                 case HANDLER_MOVE_TYPE_DOWN:
2695                         cursorPoint.y += cursorBounds.height + cursorBounds.height/2.0f;
2696                         newCursorPosition = GetCursorPositionAt(cursorPoint);
2697
2698                         if (newCursorPosition < 0)
2699                         {
2700                                 int curCursorLine = pTextObject->GetLineIndexAtTextIndex(pTextObject->GetCursorIndex());
2701                                 int totalLine = pTextObject->GetTotalLineCount();
2702                                 if (curCursorLine < totalLine - 1)
2703                                 {
2704                                         int offset = rightHandlerPosition - pTextObject->GetFirstTextIndexAt(curCursorLine);
2705                                         int firstTextIndex = pTextObject->GetFirstTextIndexAt(curCursorLine+1);
2706                                         newCursorPosition = offset + firstTextIndex;
2707                                         int textLength = pTextObject->GetTextLengthAt(curCursorLine+1);
2708                                         if (offset > textLength)
2709                                         {
2710                                                 newCursorPosition = firstTextIndex+textLength;
2711
2712                                         }
2713                                 }
2714                                 else if (curCursorLine == totalLine - 1)
2715                                 {
2716                                         int firstTextIndex = pTextObject->GetFirstTextIndexAt(curCursorLine);
2717                                         int textLength = pTextObject->GetTextLengthAt(curCursorLine);
2718                                         newCursorPosition = firstTextIndex + textLength;
2719                                 }
2720                         }
2721
2722                         if (newCursorPosition >= 0)
2723                         {
2724                                 __pHandle[HANDLER_TYPE_RIGHT]->SetHandlerCursorPosition(newCursorPosition);
2725                                 RefreshBlock();
2726                                 __pHandle[HANDLER_TYPE_RIGHT]->CheckReverseStatus();
2727                                 __pHandle[HANDLER_TYPE_RIGHT]->Invalidate();
2728                         }
2729                         else
2730                         {
2731                                 return;
2732                         }
2733                         break;
2734                 case HANDLER_MOVE_TYPE_RIGHT:
2735                         if (textLength >= rightHandlerPosition+1)
2736                         {
2737                                 __pHandle[HANDLER_TYPE_RIGHT]->SetHandlerCursorPosition(++rightHandlerPosition);
2738                                 RefreshBlock();
2739                                 __pHandle[HANDLER_TYPE_RIGHT]->CheckReverseStatus();
2740                                 __pHandle[HANDLER_TYPE_RIGHT]->Invalidate();
2741                         }
2742                         else
2743                         {
2744                                 return;
2745                         }
2746                         break;
2747                 default:
2748                         break;
2749         }
2750
2751         ReleaseCopyPastePopup();
2752         __isHandlerMoving = true;
2753         return;
2754 }
2755
2756 bool
2757 _EditCopyPasteManager::IsHandlerMovingEnabled(void) const
2758 {
2759         return __isHandlerMoving;
2760 }
2761
2762 void
2763 _EditCopyPasteManager::SetHandlerMovingEnabled(bool enabled)
2764 {
2765         __isHandlerMoving = enabled;
2766 }
2767
2768 Rectangle
2769 _EditCopyPasteManager::GetEditVisibleArea(void) const
2770 {
2771         return _CoordinateSystemUtils::ConvertToInteger(GetEditVisibleAreaF());
2772 }
2773
2774 FloatRectangle
2775 _EditCopyPasteManager::GetEditVisibleAreaF(void) const
2776 {
2777         return __editVisibleArea;
2778 }
2779
2780 _ContextMenu*
2781 _EditCopyPasteManager::GetCopyPastePopup(void) const
2782 {
2783         return __pCopyPastePopup;
2784 }
2785
2786 void
2787 _EditCopyPasteManager::GetHandlerRowColumnIndex(bool singleHandler, bool leftHandler, int& rowIndex, int& columnIndex) const
2788 {
2789         HandlerType handlerType = HANDLER_TYPE_MAX;
2790         if (singleHandler)
2791         {
2792                 handlerType = HANDLER_TYPE_CENTER;
2793         }
2794         else if (leftHandler)
2795         {
2796                 handlerType = HANDLER_TYPE_LEFT;
2797         }
2798         else
2799         {
2800                 handlerType = HANDLER_TYPE_RIGHT;
2801         }
2802
2803         if (__pHandle[handlerType])
2804         {
2805                 __pHandle[handlerType]->GetHandlerRowColumnIndex(rowIndex, columnIndex);
2806         }
2807         else
2808         {
2809                 rowIndex = -1;
2810                 columnIndex = -1;
2811         }
2812
2813         return;
2814 }
2815
2816 }}} // Tizen::Ui::Controls