Merge "Added Control::SetSubState handling" into devel/master
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / devel-api / controls / text-controls / text-selection-popup.h
1 #ifndef __DALI_TOOLKIT_TEXT_SELECTION_POPUP_H__
2 #define __DALI_TOOLKIT_TEXT_SELECTION_POPUP_H__
3
4 /*
5  * Copyright (c) 2015 Samsung Electronics Co., Ltd.
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  *
19  */
20
21 // INTERNAL INCLUDES
22 #include <dali-toolkit/public-api/controls/control.h>
23
24 namespace Dali
25 {
26
27 namespace Toolkit
28 {
29
30 class TextSelectionPopupCallbackInterface;
31
32 namespace Internal DALI_INTERNAL
33 {
34 class TextSelectionPopup;
35 }
36
37 /**
38  * @brief A control which provides a Popup with a number of buttons
39  *
40  * The style of the pop can be set through style sheets, this includes the images for the buttons
41  * A Show and Hide API is provided.
42  *
43  * If the buttons exceed the size constraints of the popup then it will offer scrolling.
44  *
45  *
46  */
47 class DALI_IMPORT_API TextSelectionPopup : public Control
48 {
49 public:
50
51   enum Buttons
52   {
53     CUT = 1u << 0,
54     COPY = 1u << 1,
55     PASTE = 1u << 2,
56     SELECT = 1u << 3,
57     SELECT_ALL = 1u << 4,
58     CLIPBOARD = 1u << 5,
59     NONE = 1u << 6,
60   };
61
62   /**
63    * @brief The start and end property ranges for this control.
64    */
65   enum PropertyRange
66   {
67     PROPERTY_START_INDEX = Control::CONTROL_PROPERTY_END_INDEX + 1,
68     PROPERTY_END_INDEX =   PROPERTY_START_INDEX + 1000              ///< Reserve property indices
69   };
70
71   /**
72    * @brief An enumeration of properties belonging to the TextSelectionPopup class.
73    */
74   struct Property
75   {
76     enum
77     {
78       /**
79        * @brief The maximum size the Popup can be.
80        * @details Name "popupMaxSize", type Vector2.
81        */
82       POPUP_MAX_SIZE =  PROPERTY_START_INDEX,
83
84       /**
85        * @brief The minimum size the Popup can be.
86        * @details Name "popupMinSize", type Vector2.
87        */
88       POPUP_MIN_SIZE,
89
90       /**
91        * @brief The maximum size an option can be.
92        * @details Name "optionMaxSize", type Vector2.
93        */
94       OPTION_MAX_SIZE,
95
96       /**
97        * @brief The minimum size an option can be.
98        * @details Name "optionMinSize", type Vector2.
99        */
100       OPTION_MIN_SIZE,
101
102       /**
103        * @brief The size of the divider between options.
104        * @details Name "optionDividerSize", type Vector2.
105        */
106       OPTION_DIVIDER_SIZE,
107
108       /**
109        * @brief The image to use as the popup clipboard icon.
110        * @details Name "popupClipboardButtonImage", type string.
111        */
112       POPUP_CLIPBOARD_BUTTON_ICON_IMAGE,
113
114       /**
115        * @brief The image to use as the popup cut icon.
116        * @details Name "popupCutButtonImage", type string.
117        */
118       POPUP_CUT_BUTTON_ICON_IMAGE,
119
120       /**
121        * @brief The image to use as the popup copy icon.
122        * @details Name "popupCopyButtonImage", type string.
123        */
124       POPUP_COPY_BUTTON_ICON_IMAGE,
125
126       /**
127        * @brief The image to use as the popup paste icon.
128        * @details Name "popupPasteButtonImage", type string.
129        */
130       POPUP_PASTE_BUTTON_ICON_IMAGE,
131
132       /**
133        * @brief The image to use as the popup select icon.
134        * @details Name "popupSelectButtonImage", type string.
135        */
136       POPUP_SELECT_BUTTON_ICON_IMAGE,
137
138       /**
139        * @brief The image to use as the popup select all icon.
140        * @details Name "popupSelectAllButtonImage", type string.
141        */
142       POPUP_SELECT_ALL_BUTTON_ICON_IMAGE,
143
144       /**
145        * @brief The color of the divider between options.
146        * @details Name "popupDividerColor", type Vector4.
147        */
148       POPUP_DIVIDER_COLOR,
149
150       /**
151        * @brief The color of the icons (if supplied).
152        * @details Name "popupIconColor", type Vector4.
153        */
154       POPUP_ICON_COLOR,
155
156       /**
157        * @brief The color of the option when pressed.
158        * @details Name "popupPressedColor", type Vector4.
159        */
160       POPUP_PRESSED_COLOR,
161
162       /**
163        * @brief The image to use for the option when pressed.
164        * @details Name "popupPressedImage", type string.
165        */
166       POPUP_PRESSED_IMAGE,
167
168       /**
169        * @brief The duration of the fade-in animation.
170        * @details Name "popupFadeInDuration", type float.
171        */
172       POPUP_FADE_IN_DURATION,
173
174       /**
175        * @brief The duration of the fade-out animation.
176        * @details Name "popupFadeOutDuration", type float.
177        */
178       POPUP_FADE_OUT_DURATION,
179
180       /**
181        * @brief The popup background can have a separate border with a different color.
182        * @details Name "backgroundBorder", type Property::Map.
183        * @note Optional.
184        */
185       BACKGROUND_BORDER
186     };
187   };
188
189   /**
190    * Create the TextSelectionPopup control.
191    * @param[in] callbackInterface The text popup callback interface which receives the button click callbacks.
192    * @return A handle to the TextSelectionPopup control.
193    */
194   static TextSelectionPopup New( TextSelectionPopupCallbackInterface* callbackInterface );
195
196   /**
197    * @brief Creates an empty handle.
198    */
199   TextSelectionPopup();
200
201   /**
202    * @brief Copy constructor.
203    *
204    * @param[in] handle The handle to copy from.
205    */
206   TextSelectionPopup( const TextSelectionPopup& handle );
207
208   /**
209    * @brief Assignment operator.
210    *
211    * @param[in] handle The handle to copy from.
212    * @return A reference to this.
213    */
214   TextSelectionPopup& operator=( const TextSelectionPopup& handle );
215
216   /**
217    * @brief Destructor
218    *
219    * This is non-virtual since derived Handle types must not contain data or virtual methods.
220    */
221   ~TextSelectionPopup();
222
223   /**
224    * @brief Downcast a handle to TextSelectionPopup.
225    *
226    * If the BaseHandle points is a TextSelectionPopup the downcast returns a valid handle.
227    * If not the returned handle is left empty.
228    *
229    * @param[in] handle Handle to an object
230    * @return handle to a TextSelectionPopup or an empty handle
231    */
232   static TextSelectionPopup DownCast( BaseHandle handle );
233
234   /**
235    * @brief Specify which buttons to show in Popup
236    * @param[in] buttonsToEnable Buttons to enable
237    */
238   void EnableButtons( Toolkit::TextSelectionPopup::Buttons buttonsToEnable );
239
240   /**
241    * @brief Raises the toolbar's layer above the given @e target layer.
242    *
243    * @param[in] target The layer to get above of.
244    */
245   void RaiseAbove( Layer target );
246
247   /**
248    * @brief Show the Popup if not being shown
249    */
250   void ShowPopup();
251
252   /**
253    * @brief Hide the Popup if shown
254    */
255   void HidePopup();
256
257 public: // Not intended for application developers
258
259   /**
260    * @brief Creates a handle using the Toolkit::Internal implementation.
261    *
262    * @param[in] implementation The Control implementation.
263    */
264   DALI_INTERNAL TextSelectionPopup( Internal::TextSelectionPopup& implementation );
265
266   /**
267    * @brief Allows the creation of this Control from an Internal::CustomActor pointer.
268    *
269    * @param[in]  internal  A pointer to the internal CustomActor.
270    */
271   explicit DALI_INTERNAL TextSelectionPopup( Dali::Internal::CustomActor* internal );
272
273 }; // Class TextSelectionPopup
274
275 } // namespace Toolkit
276
277 } // namespace Dali
278
279 #endif // __DALI_TOOLKIT_TEXT_SELECTION_POPUP_H__