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