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