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