Merge "Add deprecated tag and missed doxygen" into devel/master
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / public-api / controls / text-controls / text-editor.h
1 #ifndef __DALI_TOOLKIT_TEXT_EDITOR_H__
2 #define __DALI_TOOLKIT_TEXT_EDITOR_H__
3
4 /*
5  * Copyright (c) 2016 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 namespace Internal DALI_INTERNAL
31 {
32 class TextEditor;
33 }
34 /**
35  * @addtogroup dali_toolkit_controls_text_controls
36  * @{
37  */
38
39 /**
40  * @brief A control which provides a multi-line editable text editor.
41  *
42  *  * Signals
43  * | %Signal Name         | Method                         |                    |
44  * |----------------------|--------------------------------|--------------------|
45  * | textChanged          | @ref TextChangedSignal()       | @SINCE_1_1.37      |
46  * | inputStyleChanged    | @ref InputStyleChangedSignal() | @SINCE_1_2_2       |
47  *
48  */
49 class DALI_IMPORT_API TextEditor : public Control
50 {
51 public:
52
53   /**
54    * @brief The start and end property ranges for this control.
55    * @SINCE_1_1.37
56    */
57   enum PropertyRange
58   {
59     PROPERTY_START_INDEX = Control::CONTROL_PROPERTY_END_INDEX + 1,
60     PROPERTY_END_INDEX =   PROPERTY_START_INDEX + 1000              ///< Reserve property indices
61   };
62
63   /**
64    * @brief An enumeration of properties belonging to the TextEditor class.
65    * @SINCE_1_1.37
66    */
67   struct Property
68   {
69     /**
70      * @brief An enumeration of properties belonging to the TextEditor class.
71      * @SINCE_1_1.37
72      */
73     enum
74     {
75       RENDERING_BACKEND = PROPERTY_START_INDEX, ///< name "renderingBackend",                    The type or rendering e.g. bitmap-based,                                         type INT @SINCE_1_1.37
76       TEXT,                                     ///< name "text",                                The text to display in UTF-8 format,                                             type STRING @SINCE_1_1.37
77       TEXT_COLOR,                               ///< name "textColor",                           The text color,                                                                  type VECTOR4 @SINCE_1_1.37
78       FONT_FAMILY,                              ///< name "fontFamily",                          The requested font family,                                                       type STRING @SINCE_1_1.37
79       FONT_STYLE,                               ///< name "fontStyle",                           The requested font style,                                                        type STRING or MAP @SINCE_1_2.13
80       POINT_SIZE,                               ///< name "pointSize",                           The size of font in points,                                                      type FLOAT @SINCE_1_1.37
81       HORIZONTAL_ALIGNMENT,                     ///< name "horizontalAlignment",                 The text horizontal alignment,                                                   type STRING,  values "BEGIN", "CENTER", "END" @SINCE_1_1.37
82       SCROLL_THRESHOLD,                         ///< name "scrollThreshold"                      Vertical scrolling will occur if the cursor is this close to the control border, type FLOAT @SINCE_1_1.37
83       SCROLL_SPEED,                             ///< name "scrollSpeed"                          The scroll speed in pixels per second,                                           type FLOAT @SINCE_1_1.37
84       PRIMARY_CURSOR_COLOR,                     ///< name "primaryCursorColor",                  The color to apply to the primary cursor,                                        type VECTOR4 @SINCE_1_1.37
85       SECONDARY_CURSOR_COLOR,                   ///< name "secondaryCursorColor",                The color to apply to the secondary cursor,                                      type VECTOR4 @SINCE_1_1.37
86       ENABLE_CURSOR_BLINK,                      ///< name "enableCursorBlink",                   Whether the cursor should blink or not,                                          type BOOLEAN @SINCE_1_1.37
87       CURSOR_BLINK_INTERVAL,                    ///< name "cursorBlinkInterval",                 The time interval in seconds between cursor on/off states,                       type FLOAT @SINCE_1_1.37
88       CURSOR_BLINK_DURATION,                    ///< name "cursorBlinkDuration",                 The cursor will stop blinking after this number of seconds (if non-zero),        type FLOAT @SINCE_1_1.37
89       CURSOR_WIDTH,                             ///< name "cursorWidth",                         The cursor width,                                                                type INTEGER @SINCE_1_1.37
90       GRAB_HANDLE_IMAGE,                        ///< name "grabHandleImage",                     The image to display for the grab handle,                                        type STRING @SINCE_1_1.37
91       GRAB_HANDLE_PRESSED_IMAGE,                ///< name "grabHandlePressedImage",              The image to display when the grab handle is pressed,                            type STRING @SINCE_1_1.37
92       SELECTION_HANDLE_IMAGE_LEFT,              ///< name "selectionHandleImageLeft",            The image to display for the left selection handle,                              type MAP @SINCE_1_1.37
93       SELECTION_HANDLE_IMAGE_RIGHT,             ///< name "selectionHandleImageRight",           The image to display for the right selection handle,                             type MAP @SINCE_1_1.37
94       SELECTION_HANDLE_PRESSED_IMAGE_LEFT,      ///< name "selectionHandlePressedImageLeft",     The image to display when the left selection handle is pressed,                  type MAP @SINCE_1_1.37
95       SELECTION_HANDLE_PRESSED_IMAGE_RIGHT,     ///< name "selectionHandlePressedImageRight",    The image to display when the right selection handle is pressed,                 type MAP @SINCE_1_1.37
96       SELECTION_HANDLE_MARKER_IMAGE_LEFT,       ///< name "selectionHandleMarkerImageLeft",      The image to display for the left selection handle marker,                       type MAP @SINCE_1_1.37
97       SELECTION_HANDLE_MARKER_IMAGE_RIGHT,      ///< name "selectionHandleMarkerImageRight",     The image to display for the right selection handle marker,                      type MAP @SINCE_1_1.37
98       SELECTION_HIGHLIGHT_COLOR,                ///< name "selectionHighlightColor",             The color of the selection highlight,                                            type VECTOR4 @SINCE_1_1.37
99       DECORATION_BOUNDING_BOX,                  ///< name "decorationBoundingBox",               The decorations (handles etc) will positioned within this area on-screen,        type RECTANGLE @SINCE_1_1.37
100       ENABLE_MARKUP,                            ///< name "enableMarkup",                        Whether the mark-up processing is enabled.                                       type BOOLEAN @SINCE_1_1.37
101       INPUT_COLOR,                              ///< name "inputColor",                          The color of the new input text,                                                 type VECTOR4 @SINCE_1_1.37
102       INPUT_FONT_FAMILY,                        ///< name "inputFontFamily",                     The font's family of the new input text,                                         type STRING @SINCE_1_1.37
103       INPUT_FONT_STYLE,                         ///< name "inputFontStyle",                      The font's style of the new input text,                                          type STRING or MAP @SINCE_1_2.13
104       INPUT_POINT_SIZE,                         ///< name "inputPointSize",                      The font's size of the new input text in points,                                 type FLOAT @SINCE_1_1.37
105       LINE_SPACING,                             ///< name "lineSpacing",                         The default extra space between lines in points,                                 type FLOAT @SINCE_1_1.37
106       INPUT_LINE_SPACING,                       ///< name "inputLineSpacing"                     The extra space between lines in points. It affects the whole paragraph where the new input text is inserted, type FLOAT @SINCE_1_1.37
107       UNDERLINE,                                ///< name "underline"                            The default underline parameters,                                                type STRING or MAP @SINCE_1_2.13
108       INPUT_UNDERLINE,                          ///< name "inputUnderline"                       The underline parameters of the new input text,                                  type STRING or MAP @SINCE_1_2.13
109       SHADOW,                                   ///< name "shadow"                               The default shadow parameters,                                                   type STRING or MAP @SINCE_1_2.13
110       INPUT_SHADOW,                             ///< name "inputShadow"                          The shadow parameters of the new input text,                                     type STRING or MAP @SINCE_1_2.13
111       EMBOSS,                                   ///< name "emboss"                               The default emboss parameters,                                                   type STRING or MAP @SINCE_1_2.13
112       INPUT_EMBOSS,                             ///< name "inputEmboss"                          The emboss parameters of the new input text,                                     type STRING or MAP @SINCE_1_2.13
113       OUTLINE,                                  ///< name "outline"                              The default outline parameters,                                                  type STRING or MAP @SINCE_1_2.13
114       INPUT_OUTLINE,                            ///< name "inputOutline"                         The outline parameters of the new input text,                                    type STRING or MAP @SINCE_1_2.13
115     };
116   };
117
118   /**
119    * @brief Mask used by the signal InputStyleChangedSignal(). Notifies which parameters of the input style have changed.
120    *
121    * @SINCE_1_2_2
122    */
123   struct InputStyle
124   {
125   /**
126    * @brief Mask used by the signal InputStyleChangedSignal().
127    *
128    * @SINCE_1_2_2
129    */
130     enum Mask
131     {
132       NONE         = 0x0000, ///< @SINCE_1_2_2
133       COLOR        = 0x0001, ///< @SINCE_1_2_2
134       FONT_FAMILY  = 0x0002, ///< @SINCE_1_2_2
135       POINT_SIZE   = 0x0004, ///< @SINCE_1_2_2
136       FONT_STYLE   = 0x0008, ///< @SINCE_1_2_2
137       LINE_SPACING = 0x0010, ///< @SINCE_1_2_2
138       UNDERLINE    = 0x0020, ///< @SINCE_1_2_2
139       SHADOW       = 0x0040, ///< @SINCE_1_2_2
140       EMBOSS       = 0x0080, ///< @SINCE_1_2_2
141       OUTLINE      = 0x0100  ///< @SINCE_1_2_2
142     };
143   };
144
145   // Type Defs
146
147   /**
148    * @brief Text changed signal type.
149    * @SINCE_1_1.37
150    */
151   typedef Signal<void ( TextEditor ) > TextChangedSignalType;
152
153   /**
154    * @brief Input Style changed signal type.
155    * @SINCE_1_2_2
156    */
157   typedef Signal<void ( TextEditor, InputStyle::Mask ) > InputStyleChangedSignalType;
158
159   /**
160    * @brief Create the TextEditor control.
161    *
162    * @SINCE_1_1.37
163    * @return A handle to the TextEditor control.
164    */
165   static TextEditor New();
166
167   /**
168    * @brief Creates an empty handle.
169    *
170    * @SINCE_1_1.37
171    */
172   TextEditor();
173
174   /**
175    * @brief Copy constructor.
176    *
177    * @SINCE_1_1.37
178    * @param[in] handle The handle to copy from.
179    */
180   TextEditor( const TextEditor& handle );
181
182   /**
183    * @brief Assignment operator.
184    *
185    * @SINCE_1_1.37
186    * @param[in] handle The handle to copy from.
187    * @return A reference to this.
188    */
189   TextEditor& operator=( const TextEditor& handle );
190
191   /**
192    * @brief Destructor.
193    *
194    * This is non-virtual since derived Handle types must not contain data or virtual methods.
195    * @SINCE_1_1.37
196    */
197   ~TextEditor();
198
199   /**
200    * @brief Downcast a handle to TextEditor.
201    *
202    * If the BaseHandle points is a TextEditor the downcast returns a valid handle.
203    * If not the returned handle is left empty.
204    *
205    * @SINCE_1_1.37
206    * @param[in] handle Handle to an object.
207    * @return handle to a TextEditor or an empty handle.
208    */
209   static TextEditor DownCast( BaseHandle handle );
210
211   // Signals
212
213   /**
214    * @brief This signal is emitted when the text changes.
215    *
216    * A callback of the following type may be connected:
217    * @code
218    *   void YourCallbackName( TextEditor textEditor );
219    * @endcode
220    *
221    * @SINCE_1_1.37
222    * @return The signal to connect to.
223    */
224   TextChangedSignalType& TextChangedSignal();
225
226   /**
227    * @brief This signal is emitted when the input style is updated as a consequence of a change in the cursor position.
228    * i.e. The signal is not emitted when the input style is updated through the property system.
229    *
230    * A callback of the following type may be connected. The @p mask parameter notifies which parts of the style have changed.
231    * @code
232    *   void YourCallbackName( TextEditor textEditor, TextEditor::InputStyle::Mask mask );
233    * @endcode
234    *
235    * @SINCE_1_2_2
236    * @return The signal to connect to.
237    */
238   InputStyleChangedSignalType& InputStyleChangedSignal();
239
240 public: // Not intended for application developers
241
242   /// @cond internal
243   /**
244    * @brief Creates a handle using the Toolkit::Internal implementation.
245    *
246    * @SINCE_1_1.37
247    * @param[in] implementation The Control implementation.
248    */
249   DALI_INTERNAL TextEditor( Internal::TextEditor& implementation );
250
251   /**
252    * @brief Allows the creation of this Control from an Internal::CustomActor pointer.
253    *
254    * @SINCE_1_1.37
255    * @param[in]  internal  A pointer to the internal CustomActor.
256    */
257   explicit DALI_INTERNAL TextEditor( Dali::Internal::CustomActor* internal );
258   /// @endcond
259 };
260
261 /**
262  * @}
263  */
264 } // namespace Toolkit
265
266 } // namespace Dali
267
268 #endif // __DALI_TOOLKIT_TEXT_EDITOR_H__