(TextEditor) Moved some Devel properties to the Public API
[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) 2017 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 Enumeration for 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 Enumeration for the instance of properties belonging to the TextEditor class.
65    * @SINCE_1_1.37
66    */
67   struct Property
68   {
69     /**
70      * @brief Enumeration for the instance of properties belonging to the TextEditor class.
71      * @SINCE_1_1.37
72      */
73     enum
74     {
75       /**
76        * @brief The type or rendering e.g. bitmap-based.
77        * @details Name "renderingBackend", type Property::INTEGER.
78        * @SINCE_1_1.37
79        */
80       RENDERING_BACKEND = PROPERTY_START_INDEX,
81
82       /**
83        * @brief The text to display in UTF-8 format.
84        * @details Name "text", type Property::STRING.
85        * @SINCE_1_1.37
86        */
87       TEXT,
88
89       /**
90        * @brief The text color.
91        * @details Name "textColor", type Property::VECTOR4.
92        * @SINCE_1_1.37
93        */
94       TEXT_COLOR,
95
96       /**
97        * @brief The requested font family.
98        * @details Name "fontFamily", type Property::STRING.
99        * @SINCE_1_1.37
100        */
101       FONT_FAMILY,
102
103       /**
104        * @brief The requested font style.
105        * @details Name "fontStyle", type Property::STRING or Property::MAP.
106        * @SINCE_1_2.13
107        */
108       FONT_STYLE,
109
110       /**
111        * @brief The size of font in points.
112        * @details Name "pointSize", type Property::FLOAT.
113        *          Conversion from Pixel size to Point size : Point size = Pixel size * 72 / DPI.
114        * @SINCE_1_1.37
115        */
116       POINT_SIZE,
117
118       /**
119        * @brief The text horizontal alignment.
120        * @details Name "horizontalAlignment", type Property::STRING.
121        *          Values "BEGIN" "CENTER" "END".
122        * @SINCE_1_1.37
123        */
124       HORIZONTAL_ALIGNMENT,
125
126       /**
127        * @brief Vertical scrolling will occur if the cursor is this close to the control border.
128        * @details Name "scrollThreshold", type Property::FLOAT.
129        * @SINCE_1_1.37
130        */
131       SCROLL_THRESHOLD,
132
133       /**
134        * @brief The scroll speed in pixels per second.
135        * @details Name "scrollSpeed", type Property::FLOAT.
136        * @SINCE_1_1.37
137        */
138       SCROLL_SPEED,
139
140       /**
141        * @brief The color to apply to the primary cursor.
142        * @details Name "primaryCursorColor", type Property::VECTOR4.
143        * @SINCE_1_1.37
144        */
145       PRIMARY_CURSOR_COLOR,
146
147       /**
148        * @brief The color to apply to the secondary cursor.
149        * @details Name "secondaryCursorColor", type Property::VECTOR4.
150        * @SINCE_1_1.37
151        */
152       SECONDARY_CURSOR_COLOR,
153
154       /**
155        * @brief Whether the cursor should blink or not.
156        * @details Name "enableCursorBlink", type Property::BOOLEAN.
157        * @SINCE_1_1.37
158        */
159       ENABLE_CURSOR_BLINK,
160
161       /**
162        * @brief The time interval in seconds between cursor on/off states.
163        * @details Name "cursorBlinkInterval", type Property::FLOAT.
164        * @SINCE_1_1.37
165        */
166       CURSOR_BLINK_INTERVAL,
167
168       /**
169        * @brief The cursor will stop blinking after this number of seconds (if non-zero).
170        * @details Name "cursorBlinkDuration", type Property::FLOAT.
171        * @SINCE_1_1.37
172        */
173       CURSOR_BLINK_DURATION,
174
175       /**
176        * @brief The cursor width.
177        * @details Name "cursorWidth", type Property::INTEGER.
178        * @SINCE_1_1.37
179        */
180       CURSOR_WIDTH,
181
182       /**
183        * @brief The image to display for the grab handle.
184        * @details Name "grabHandleImage", type Property::STRING.
185        * @SINCE_1_1.37
186        */
187       GRAB_HANDLE_IMAGE,
188
189       /**
190        * @brief The image to display when the grab handle is pressed.
191        * @details Name "grabHandlePressedImage", type Property::STRING.
192        * @SINCE_1_1.37
193        */
194       GRAB_HANDLE_PRESSED_IMAGE,
195
196       /**
197        * @brief The image to display for the left selection handle.
198        * @details Name "selectionHandleImageLeft", type Property::MAP.
199        * @SINCE_1_1.37
200        */
201       SELECTION_HANDLE_IMAGE_LEFT,
202
203       /**
204        * @brief The image to display for the right selection handle.
205        * @details Name "selectionHandleImageRight", type Property::MAP.
206        * @SINCE_1_1.37
207        */
208       SELECTION_HANDLE_IMAGE_RIGHT,
209
210       /**
211        * @brief The image to display when the left selection handle is pressed.
212        * @details Name "selectionHandlePressedImageLeft", type Property::MAP.
213        * @SINCE_1_1.37
214        */
215       SELECTION_HANDLE_PRESSED_IMAGE_LEFT,
216
217       /**
218        * @brief The image to display when the right selection handle is pressed.
219        * @details Name "selectionHandlePressedImageRight", type Property::MAP.
220        * @SINCE_1_1.37
221        */
222       SELECTION_HANDLE_PRESSED_IMAGE_RIGHT,
223
224       /**
225        * @brief The image to display for the left selection handle marker.
226        * @details Name "selectionHandleMarkerImageLeft", type Property::MAP.
227        * @SINCE_1_1.37
228        */
229       SELECTION_HANDLE_MARKER_IMAGE_LEFT,
230
231       /**
232        * @brief The image to display for the right selection handle marker.
233        * @details Name "selectionHandleMarkerImageRight", type Property::MAP.
234        * @SINCE_1_1.37
235        */
236       SELECTION_HANDLE_MARKER_IMAGE_RIGHT,
237
238       /**
239        * @brief The color of the selection highlight.
240        * @details Name "selectionHighlightColor", type Property::VECTOR4.
241        * @SINCE_1_1.37
242        */
243       SELECTION_HIGHLIGHT_COLOR,
244
245       /**
246        * @brief The decorations (handles etc) will positioned within this area on-screen.
247        * @details Name "decorationBoundingBox", type Property::RECTANGLE.
248        * @SINCE_1_1.37
249        */
250       DECORATION_BOUNDING_BOX,
251
252       /**
253        * @brief Whether the mark-up processing is enabled.
254        * @details Name "enableMarkup", type Property::BOOLEAN.
255        * @SINCE_1_1.37
256        */
257       ENABLE_MARKUP,
258
259       /**
260        * @brief The color of the new input text.
261        * @details Name "inputColor", type Property::VECTOR4.
262        * @SINCE_1_1.37
263        */
264       INPUT_COLOR,
265
266       /**
267        * @brief The font's family of the new input text.
268        * @details Name "inputFontFamily", type Property::STRING.
269        * @SINCE_1_1.37
270        */
271       INPUT_FONT_FAMILY,
272
273       /**
274        * @brief The font's style of the new input text.
275        * @details Name "inputFontStyle", type Property::MAP.
276        * @SINCE_1_2.13
277        */
278       INPUT_FONT_STYLE,
279
280       /**
281        * @brief The font's size of the new input text in points.
282        * @details Name "inputPointSize", type Property::FLOAT.
283        * @SINCE_1_1.37
284        */
285       INPUT_POINT_SIZE,
286
287       /**
288        * @brief The default extra space between lines in points.
289        * @details Name "lineSpacing", type Property::FLOAT.
290        * @SINCE_1_1.37
291        */
292       LINE_SPACING,
293
294       /**
295        * @brief The extra space between lines in points.
296        * @details Name "inputLineSpacing",  type Property::FLOAT.
297        * @SINCE_1_1.37
298        * @note This affects the whole paragraph where the new input text is inserted.
299        */
300       INPUT_LINE_SPACING,
301
302       /**
303        * @brief The default underline parameters.
304        * @details Name "underline", type Property::MAP.
305        * @SINCE_1_2.13
306        */
307       UNDERLINE,
308
309       /**
310        * @brief The underline parameters of the new input text.
311        * @details Name "inputUnderline", type Property::MAP.
312        * @SINCE_1_2.13
313        */
314       INPUT_UNDERLINE,
315
316       /**
317        * @brief The default shadow parameters.
318        * @details Name "shadow", type Property::MAP.
319        * @SINCE_1_2.13
320        */
321       SHADOW,
322
323       /**
324        * @brief The shadow parameters of the new input text.
325        * @details Name "inputShadow", type Property::MAP.
326        * @SINCE_1_2.13
327        */
328       INPUT_SHADOW,
329
330       /**
331        * @brief The default emboss parameters.
332        * @details Name "emboss", type Property::MAP.
333        * @SINCE_1_2.13
334        */
335       EMBOSS,
336
337       /**
338        * @brief The emboss parameters of the new input text.
339        * @details Name "inputEmboss", type Property::MAP.
340        * @SINCE_1_2.13
341        */
342       INPUT_EMBOSS,
343
344       /**
345        * @brief The default outline parameters.
346        * @details Name "outline", type Property::MAP.
347        * @SINCE_1_2.13
348        */
349       OUTLINE,
350
351       /**
352        * @brief The outline parameters of the new input text.
353        * @details Name "inputOutline", type Property::MAP.
354        * @SINCE_1_2.13
355        */
356       INPUT_OUTLINE,
357
358       /**
359        * @brief Enable or disable the smooth scroll animation.
360        * @details Name "smoothScroll", type Property::BOOLEAN.
361        * @SINCE_1_2.60
362        */
363       SMOOTH_SCROLL,
364
365       /**
366        * @brief Sets the duration of smooth scroll animation.
367        * @details Name "smoothScrollDuration", type Property::FLOAT.
368        * @SINCE_1_2.60
369        */
370       SMOOTH_SCROLL_DURATION,
371
372       /**
373        * @brief Enable or disable the scroll bar.
374        * @details Name "enableScrollBar", type Property::BOOLEAN.
375        * @SINCE_1_2.60
376        */
377       ENABLE_SCROLL_BAR,
378
379       /**
380        * @brief Sets the duration of scroll bar to show.
381        * @details Name "scrollBarShowDuration", type Property::FLOAT.
382        * @SINCE_1_2.60
383        */
384       SCROLL_BAR_SHOW_DURATION,
385
386       /**
387        * @brief Sets the duration of scroll bar to fade out.
388        * @details Name "scrollBarFadeDuration", type Property::FLOAT.
389        * @SINCE_1_2.60
390        */
391       SCROLL_BAR_FADE_DURATION,
392
393       /**
394        * @brief The size of font in pixels.
395        * @details Name "pixelSize", type Property::FLOAT.
396        *          Conversion from Point size to Pixel size:
397        *           Pixel size = Point size * DPI / 72
398        * @SINCE_1_2.60
399        */
400       PIXEL_SIZE,
401
402       /**
403        * @brief The line count of text.
404        * @details Name "lineCount", type Property::INTEGER.
405        * @SINCE_1_2.60
406        * @note This property is read-only.
407        */
408       LINE_COUNT,
409
410       /**
411        * @brief Enables Text selection, such as the cursor, handle, clipboard, and highlight color.
412        * @details Name "enableSelection", type Property::BOOLEAN.
413        * @SINCE_1_2.60
414        */
415       ENABLE_SELECTION,
416
417       /**
418        * @brief Sets the placeholder : text, color, font family, font style, point size, and pixel size.
419        * @details Name "placeholder", type Property::MAP.
420        * Example:
421        * @code
422        *   Property::Map propertyMap;
423        *   propertyMap["placeholderText"] = "Setting Placeholder Text";
424        *   propertyMap["placeholderTextFocused"] = "Setting Placeholder Text Focused";
425        *   propertyMap["placeholderColor"] = Color::RED;
426        *   propertyMap["placeholderFontFamily"] = "Arial";
427        *   propertyMap["placeholderPointSize"] = 12.0f;
428        *
429        *   Property::Map fontStyleMap;
430        *   fontStyleMap.Insert( "weight", "bold" );
431        *   fontStyleMap.Insert( "width", "condensed" );
432        *   fontStyleMap.Insert( "slant", "italic" );
433        *   propertyMap["placeholderFontStyle"] = fontStyleMap;
434        *
435        *   editor.SetProperty( TextEditor::Property::PLACEHOLDER, propertyMap );
436        * @endcode
437        *
438        * @SINCE_1_2.60
439        */
440       PLACEHOLDER,
441
442       /**
443        * @brief line wrap mode when the text lines over layout width.
444        * @details Name "lineWrapMode", type Property::STRING.
445        * @SINCE_1_2.60
446        */
447       LINE_WRAP_MODE,
448     };
449   };
450
451   /**
452    * @brief Mask used by the signal InputStyleChangedSignal(). Notifies which parameters of the input style have changed.
453    *
454    * @SINCE_1_2_2
455    */
456   struct InputStyle
457   {
458   /**
459    * @brief Enumeration for mask used by the signal InputStyleChangedSignal().
460    * @SINCE_1_2_2
461    */
462     enum Mask
463     {
464       NONE         = 0x0000, ///< @SINCE_1_2_2
465       COLOR        = 0x0001, ///< @SINCE_1_2_2
466       FONT_FAMILY  = 0x0002, ///< @SINCE_1_2_2
467       POINT_SIZE   = 0x0004, ///< @SINCE_1_2_2
468       FONT_STYLE   = 0x0008, ///< @SINCE_1_2_2
469       LINE_SPACING = 0x0010, ///< @SINCE_1_2_2
470       UNDERLINE    = 0x0020, ///< @SINCE_1_2_2
471       SHADOW       = 0x0040, ///< @SINCE_1_2_2
472       EMBOSS       = 0x0080, ///< @SINCE_1_2_2
473       OUTLINE      = 0x0100  ///< @SINCE_1_2_2
474     };
475   };
476
477   /**
478    * @brief Enumerations for the type of scrolling.
479    * @SINCE_1_2.60
480    * @see ScrollStateChangedSignal()
481    */
482   struct Scroll
483   {
484     /**
485      * @brief Enumerations for the type of scrolling.
486      * @SINCE_1_2.60
487      * @see ScrollStateChangedSignal()
488      */
489     enum Type
490     {
491       STARTED,   ///< Scrolling has started. @SINCE_1_2.60
492       FINISHED   ///< Scrolling has finished. @SINCE_1_2.60
493     };
494   };
495
496   // Type Defs
497
498   /**
499    * @brief Text changed signal type.
500    * @SINCE_1_1.37
501    */
502   typedef Signal<void ( TextEditor ) > TextChangedSignalType;
503
504   /**
505    * @brief Input Style changed signal type.
506    * @SINCE_1_2_2
507    */
508   typedef Signal<void ( TextEditor, InputStyle::Mask ) > InputStyleChangedSignalType;
509
510   /**
511    * @brief Scroll state changed signal type.
512    * @SINCE_1_2.60
513    */
514   typedef Signal< void ( TextEditor, Scroll::Type ) > ScrollStateChangedSignalType;
515
516   /**
517    * @brief Creates the TextEditor control.
518    *
519    * @SINCE_1_1.37
520    * @return A handle to the TextEditor control
521    */
522   static TextEditor New();
523
524   /**
525    * @brief Creates an empty handle.
526    *
527    * @SINCE_1_1.37
528    */
529   TextEditor();
530
531   /**
532    * @brief Copy constructor.
533    *
534    * @SINCE_1_1.37
535    * @param[in] handle The handle to copy from
536    */
537   TextEditor( const TextEditor& handle );
538
539   /**
540    * @brief Assignment operator.
541    *
542    * @SINCE_1_1.37
543    * @param[in] handle The handle to copy from
544    * @return A reference to this
545    */
546   TextEditor& operator=( const TextEditor& handle );
547
548   /**
549    * @brief Destructor.
550    *
551    * This is non-virtual since derived Handle types must not contain data or virtual methods.
552    * @SINCE_1_1.37
553    */
554   ~TextEditor();
555
556   /**
557    * @brief Downcasts a handle to TextEditor.
558    *
559    * If the BaseHandle points is a TextEditor, the downcast returns a valid handle.
560    * If not, the returned handle is left empty.
561    *
562    * @SINCE_1_1.37
563    * @param[in] handle Handle to an object
564    * @return Handle to a TextEditor or an empty handle
565    */
566   static TextEditor DownCast( BaseHandle handle );
567
568   // Signals
569
570   /**
571    * @brief This signal is emitted when the text changes.
572    *
573    * A callback of the following type may be connected:
574    * @code
575    *   void YourCallbackName( TextEditor textEditor );
576    * @endcode
577    *
578    * @SINCE_1_1.37
579    * @return The signal to connect to
580    */
581   TextChangedSignalType& TextChangedSignal();
582
583   /**
584    * @brief This signal is emitted when the input style is updated as a consequence of a change in the cursor position.
585    * i.e. The signal is not emitted when the input style is updated through the property system.
586    *
587    * A callback of the following type may be connected. The @p mask parameter notifies which parts of the style have changed.
588    * @code
589    *   void YourCallbackName( TextEditor textEditor, TextEditor::InputStyle::Mask mask );
590    * @endcode
591    *
592    * @SINCE_1_2_2
593    * @return The signal to connect to
594    */
595   InputStyleChangedSignalType& InputStyleChangedSignal();
596
597   /**
598    * @brief This signal is emitted when TextEditor scrolling is started or finished.
599    *
600    * A callback of the following type may be connected:
601    * @code
602    *   void YourCallbackName( Scroll::Type type );
603    * @endcode
604    * type: Whether the scrolling is started or finished.
605    *
606    * @SINCE_1_2.60
607    * @return The signal to connect to
608    */
609   ScrollStateChangedSignalType& ScrollStateChangedSignal();
610
611 public: // Not intended for application developers
612
613   /// @cond internal
614   /**
615    * @brief Creates a handle using the Toolkit::Internal implementation.
616    *
617    * @SINCE_1_1.37
618    * @param[in] implementation The Control implementation
619    */
620   DALI_INTERNAL TextEditor( Internal::TextEditor& implementation );
621
622   /**
623    * @brief Allows the creation of this Control from an Internal::CustomActor pointer.
624    *
625    * @SINCE_1_1.37
626    * @param[in] internal A pointer to the internal CustomActor
627    */
628   explicit DALI_INTERNAL TextEditor( Dali::Internal::CustomActor* internal );
629   /// @endcond
630 };
631
632 /**
633  * @}
634  */
635 } // namespace Toolkit
636
637 } // namespace Dali
638
639 #endif // __DALI_TOOLKIT_TEXT_EDITOR_H__