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