Tizen 2.1 base
[framework/osp/uifw.git] / src / ui / inc / FUiCtrl_EditCopyPasteManager.h
1 //
2 // Open Service Platform
3 // Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
4 //
5 // Licensed under the Flora License, Version 1.0 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
8 //
9 //     http://floralicense.org/license/
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 * @file                 FUiCtrl_EditCopyPasteManager.h
19 * @brief                This is the header file for _EditCopyPasteManager class.
20 *
21 * This header file contains declaration of _EditCopyPasteManager class.
22 */
23
24 #ifndef _FUI_CTRL_INTERNAL_EDIT_COPY_PASTE_MANAGER_H_
25 #define _FUI_CTRL_INTERNAL_EDIT_COPY_PASTE_MANAGER_H_
26
27 #include <FGrpPoint.h>
28 #include <FGrpRectangle.h>
29 #include "FUi_Control.h"
30 #include "FUiCtrl_ContextMenu.h"
31 #include "FUiCtrl_Edit.h"
32 #include "FUiCtrl_IActionEventListener.h"
33 #include "FUiCtrl_IEditCopyPasteEventListener.h"
34
35 namespace Tizen {namespace Ui {namespace Controls
36 {
37
38 //forward declaration
39 class _EditCopyPasteHandler;
40 class _EditCopyPasteEvent;
41
42 /**
43 * @class        _EditCopyPasteManager
44 * @brief        This class handles CopyPastePopup and Handler Windows.
45 *
46 */
47 class _EditCopyPasteManager
48         : virtual public Tizen::Base::Runtime::IEventListener
49         , virtual public Tizen::Ui::_IUiEventListener
50         , virtual public Tizen::Ui::_IUiEventPreviewer
51         , public _IActionEventListener
52 {
53 public:
54         enum HandlerType
55         {
56                 HANDLER_TYPE_LEFT = 0,
57                 HANDLER_TYPE_RIGHT,
58                 HANDLER_TYPE_MAX
59         };
60
61         enum HandlerMoveType
62         {
63                 HANDLER_MOVE_TYPE_LEFT = 0,
64                 HANDLER_MOVE_TYPE_UP,
65                 HANDLER_MOVE_TYPE_DOWN,
66                 HANDLER_MOVE_TYPE_RIGHT
67         };
68
69 // Lifecycle
70 public:
71         /**
72         * This is the default class constructor.
73         *
74         */
75         _EditCopyPasteManager(_Edit& parenEdit);
76
77         /**
78         * This is the default class destructor.
79         *
80         */
81         virtual ~_EditCopyPasteManager(void);
82
83 // Operations
84 public:
85         void CreateCopyPastePopup(void);
86         void CreateHandle(void);
87         void Show(void);
88         bool CheckHandleBounds(const Tizen::Graphics::Point& point);
89         bool CheckHandlePosition(bool leftHandle, int cursorPosition);
90         void CheckVisibleState(bool leftHandle);
91         void HideHandle(void);
92         void RefreshBlock(bool changeVisibleState, bool isLeftHandle = false);
93         Tizen::Graphics::Rectangle GetCursorBounds(bool isAbsRect) const;
94         int GetCursorPositionAt(const Tizen::Graphics::Point& touchPoint) const;
95         result SetCursorPosition(int position);
96         int GetCursorPosition(void) const;
97         int GetHandlerCursorPosition(bool rightHandler) const;
98         void SendTextBlockEvent(void);
99         void Release(void);
100         void ReleaseCopyPastePopup(void);
101         void SwitchHandle(void);
102         bool IsCopyPastePopup(const _Control& control) const;
103         void AdjustBounds(void);
104
105         result AddCopyPasteEventListener(const _IEditCopyPasteEventListener& listener);
106         result SendCopyPasteEvent(Tizen::Ui::Controls::CoreCopyPasteStatus status, Tizen::Ui::Controls::CoreCopyPasteAction action);
107         void PrintLog(const Tizen::Graphics::Point& point);
108         bool GetTextBlockReleaseFlag(void) const;
109         void SetTextBlockReleaseFlag(bool enabled);
110
111 // virtual function
112         virtual void OnActionPerformed(const Tizen::Ui::_Control& source, int actionId);
113         void ScrollText(int distance);
114         _Edit* GetEdit(void) const;
115         void MoveHandler(HandlerMoveType moveType);
116         bool IsHandlerMovingEnabled(void) const;
117         void SetHandlerMovingEnabled(bool enabled);
118         Tizen::Graphics::Rectangle GetEditVisibleArea(void) const;
119 private:
120         _EditCopyPasteManager(const _EditCopyPasteManager& value);
121         _EditCopyPasteManager& operator =(const _EditCopyPasteManager& value);
122
123 private:
124         _ContextMenu* __pCopyPastePopup;
125         ContextMenuCoreAlign __contextMenuAlign;
126         _EditCopyPasteHandler* __pHandle[HANDLER_TYPE_MAX];
127         _EditCopyPasteEvent* __pCoreCopyPasteEvent;
128         _Edit* __pEdit;
129         int __contextMenuHeight;
130         bool __needToReleaseBlock;
131         bool __isHandlerMoving;
132         Tizen::Graphics::Rectangle __editVisibleArea;
133 }; // _EditCopyPasteManager
134
135 }}} // Tizen::Ui::Controls
136
137 #endif // _FUI_CTRL_INTERNAL_EDIT_COPY_PASTE_MANAGER_H_