5201c08f1bd8977d60bd2a31d2e4244a0562042b
[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       POPUP_MAX_SIZE =  PROPERTY_START_INDEX,   ///< name "popupMaxSize",                  maximum size the Popup can be,                  type VECTOR2
79       POPUP_MIN_SIZE,                           ///< name "popupMinSize",                  minimum size the Popup can be,                  type VECTOR2
80       OPTION_MAX_SIZE,                          ///< name "optionMaxSize",                 maximum size an option can be,                  type VECTOR2
81       OPTION_MIN_SIZE,                          ///< name "optionMinSize",                 minimum size an option can be,                  type VECTOR2
82       OPTION_DIVIDER_SIZE,                      ///< name "optionDividerSize",             size of the divider between options             type VECTOR2
83       POPUP_CLIPBOARD_BUTTON_ICON_IMAGE,        ///< name "popupClipboardButtonImage",     The image to use as the popup clipboard icon,   type STRING
84       POPUP_CUT_BUTTON_ICON_IMAGE,              ///< name "popupCutButtonImage",           The image to use as the popup cut icon,         type STRING
85       POPUP_COPY_BUTTON_ICON_IMAGE,             ///< name "popupCopyButtonImage",          The image to use as the popup copy icon,        type STRING
86       POPUP_PASTE_BUTTON_ICON_IMAGE,            ///< name "popupPasteButtonImage",         The image to use as the popup paste icon,       type STRING
87       POPUP_SELECT_BUTTON_ICON_IMAGE,           ///< name "popupSelectButtonImage",        The image to use as the popup select icon,      type STRING
88       POPUP_SELECT_ALL_BUTTON_ICON_IMAGE,       ///< name "popupSelectAllButtonImage",     The image to use as the popup select all icon,  type STRING
89       POPUP_DIVIDER_COLOR,                      ///< name "popupDividerColor",             The color of the divider between options,       type VECTOR4
90       POPUP_ICON_COLOR,                         ///< name "popupIconColor",                The color of the icons (if supplied),           type VECTOR4
91       POPUP_PRESSED_COLOR,                      ///< name "popupPressedColor",             The color of the option when pressed,           type VECTOR4
92       POPUP_PRESSED_IMAGE,                      ///< name "popupPressedImage",             The image to use for the option when pressed,   type STRING
93       POPUP_FADE_IN_DURATION,                   ///< name "popupFadeInDuration",           The duration of the fade-in animation,          type FLOAT
94       POPUP_FADE_OUT_DURATION,                  ///< name "popupFadeOutDuration",          The duration of the fade-out animation,         type FLOAT
95     };
96   };
97
98   /**
99    * Create the TextSelectionPopup control.
100    * @param[in] callbackInterface The text popup callback interface which receives the button click callbacks.
101    * @return A handle to the TextSelectionPopup control.
102    */
103   static TextSelectionPopup New( TextSelectionPopupCallbackInterface* callbackInterface );
104
105   /**
106    * @brief Creates an empty handle.
107    */
108   TextSelectionPopup();
109
110   /**
111    * @brief Copy constructor.
112    *
113    * @param[in] handle The handle to copy from.
114    */
115   TextSelectionPopup( const TextSelectionPopup& handle );
116
117   /**
118    * @brief Assignment operator.
119    *
120    * @param[in] handle The handle to copy from.
121    * @return A reference to this.
122    */
123   TextSelectionPopup& operator=( const TextSelectionPopup& handle );
124
125   /**
126    * @brief Destructor
127    *
128    * This is non-virtual since derived Handle types must not contain data or virtual methods.
129    */
130   ~TextSelectionPopup();
131
132   /**
133    * @brief Downcast a handle to TextSelectionPopup.
134    *
135    * If the BaseHandle points is a TextSelectionPopup the downcast returns a valid handle.
136    * If not the returned handle is left empty.
137    *
138    * @param[in] handle Handle to an object
139    * @return handle to a TextSelectionPopup or an empty handle
140    */
141   static TextSelectionPopup DownCast( BaseHandle handle );
142
143   /**
144    * @brief Specify which buttons to show in Popup
145    * @param[in] buttonsToEnable Buttons to enable
146    */
147   void EnableButtons( Toolkit::TextSelectionPopup::Buttons buttonsToEnable );
148
149   /**
150    * @brief Raises the toolbar's layer above the given @e target layer.
151    *
152    * @param[in] target The layer to get above of.
153    */
154   void RaiseAbove( Layer target );
155
156   /**
157    * @brief Show the Popup if not being shown
158    */
159   void ShowPopup();
160
161   /**
162    * @brief Hide the Popup if shown
163    */
164   void HidePopup();
165
166 public: // Not intended for application developers
167
168   /**
169    * @brief Creates a handle using the Toolkit::Internal implementation.
170    *
171    * @param[in] implementation The Control implementation.
172    */
173   DALI_INTERNAL TextSelectionPopup( Internal::TextSelectionPopup& implementation );
174
175   /**
176    * @brief Allows the creation of this Control from an Internal::CustomActor pointer.
177    *
178    * @param[in]  internal  A pointer to the internal CustomActor.
179    */
180   explicit DALI_INTERNAL TextSelectionPopup( Dali::Internal::CustomActor* internal );
181
182 }; // Class TextSelectionPopup
183
184 } // namespace Toolkit
185
186 } // namespace Dali
187
188 #endif // __DALI_TOOLKIT_TEXT_SELECTION_POPUP_H__