Remove @ref tag in front of namespace
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / public-api / controls / text-controls / text-field.h
1 #ifndef __DALI_TOOLKIT_TEXT_FIELD_H__
2 #define __DALI_TOOLKIT_TEXT_FIELD_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 TextField;
33 }
34 /**
35  * @addtogroup dali_toolkit_controls_text_controls
36  * @{
37  */
38
39 /**
40  * @brief A control which provides a single-line editable text field.
41  *
42  * Signals
43  * | %Signal Name         | Method                         |                    |
44  * |----------------------|--------------------------------|--------------------|
45  * | textChanged          | @ref TextChangedSignal()       | @SINCE_1_0.0       |
46  * | maxLengthReached     | @ref MaxLengthReachedSignal()  | @SINCE_1_0.0       |
47  * | inputStyleChanged    | @ref InputStyleChangedSignal() | @SINCE_1_2_2       |
48  */
49 class DALI_IMPORT_API TextField : public Control
50 {
51 public:
52
53   /**
54    * @brief The start and end property ranges for this control.
55    * @SINCE_1_0.0
56    */
57   enum PropertyRange
58   {
59     PROPERTY_START_INDEX = Control::CONTROL_PROPERTY_END_INDEX + 1, ///< @SINCE_1_0.0
60     PROPERTY_END_INDEX =   PROPERTY_START_INDEX + 1000              ///< Reserve property indices @SINCE_1_0.0
61   };
62
63   /**
64    * @brief Enumeration for the instance of properties belonging to the TextField class.
65    * @SINCE_1_0.0
66    */
67   struct Property
68   {
69     /**
70      * @brief Enumeration for the instance of properties belonging to the TextField class.
71      * @SINCE_1_0.0
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_0.0
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_0.0
86        */
87       TEXT,
88
89       /**
90        * @brief The text to display when the TextField is empty and inactive.
91        * @details Name "placeholderText", type Property::STRING.
92        * @SINCE_1_0.0
93        */
94       PLACEHOLDER_TEXT,
95
96       /**
97        * @brief The text to display when the TextField is empty with key-input focus.
98        * @details Name "placeholderTextFocused", type Property::STRING.
99        * @SINCE_1_0.0
100        */
101       PLACEHOLDER_TEXT_FOCUSED,
102
103       /**
104        * @brief The requested font family.
105        * @details Name "fontFamily", type Property::STRING.
106        * @SINCE_1_0.0
107        */
108       FONT_FAMILY,
109
110       /**
111        * @brief The requested font style
112        * @details Name "fontStyle", type Property::STRING or Property::MAP.
113        * @SINCE_1_2.13
114        */
115       FONT_STYLE,
116
117       /**
118        * @brief The size of font in points.
119        * @details Name "pointSize", type Property::FLOAT.
120        *          (Conversion from Pixel size to Point size : Point size = Pixel size * 72 / DPI).
121        * @SINCE_1_0.0
122        */
123       POINT_SIZE,
124
125       /**
126        * @brief The maximum number of characters that can be inserted.
127        * @details Name "maxLength", type Property::INTEGER.
128        * @SINCE_1_0.0
129        */
130       MAX_LENGTH,
131
132       /**
133        * @brief Specifies how the text is truncated when it does not fit.
134        * @details Name "exceedPolicy", type Property::INTEGER.
135        * @SINCE_1_0.0
136        */
137       EXCEED_POLICY,
138
139       /**
140        * @brief The line horizontal alignment.
141        * @details Name "horizontalAlignment", type Property::STRING or type HorizontalAlignment::Type (Property::INTEGER)
142        *          Values "BEGIN", "CENTER", "END".
143        * @note Return type is Property::STRING
144        * @SINCE_1_0.0
145        */
146       HORIZONTAL_ALIGNMENT,
147
148       /**
149        * @brief The line vertical alignment.
150        * @details Name "verticalAlignment", type Property::STRING type VerticalAlignment::Type (Property::INTEGER)
151        *          Values "TOP",   "CENTER", "BOTTOM".
152        * @note Return type is Property::STRING
153        * @SINCE_1_0.0
154        */
155       VERTICAL_ALIGNMENT,
156
157       /**
158        * @brief The text color.
159        * @details Name "textColor", type Property::VECTOR4.
160        * @SINCE_1_0.0
161        */
162       TEXT_COLOR,
163
164       /**
165        * @brief The placeholder-text color.
166        * @details Name "placeholderTextColor", type Property::VECTOR4.
167        * @SINCE_1_0.0
168        */
169       PLACEHOLDER_TEXT_COLOR,
170
171       /**
172        * @DEPRECATED_1_1.37 Use SHADOW instead.
173        * @brief The drop shadow offset 0 indicates no shadow.
174        * @details Name "shadowOffset", type Property::VECTOR2.
175        * @SINCE_1_0.0
176        */
177       SHADOW_OFFSET,
178
179       /**
180        * @DEPRECATED_1_1.37 Use SHADOW instead.
181        * @brief The color of a drop shadow.
182        * @details Name "shadowColor", type Property::VECTOR4.
183        * @SINCE_1_0.0
184        */
185       SHADOW_COLOR,
186
187       /**
188        * @brief The color to apply to the primary cursor.
189        * @details Name "primaryCursorColor", type Property::VECTOR4.
190        * @SINCE_1_0.0
191        */
192       PRIMARY_CURSOR_COLOR,
193
194       /**
195        * @brief The color to apply to the secondary cursor.
196        * @details Name "secondaryCursorColor", type Property::VECTOR4.
197        * @SINCE_1_0.0
198        */
199       SECONDARY_CURSOR_COLOR,
200
201       /**
202        * @brief Whether the cursor should blink or not.
203        * @details Name "enableCursorBlink", type Property::BOOLEAN.
204        * @SINCE_1_0.0
205        */
206       ENABLE_CURSOR_BLINK,
207
208       /**
209        * @brief The time interval in seconds between cursor on/off states.
210        * @details Name "cursorBlinkInterval", type Property::FLOAT.
211        * @SINCE_1_0.0
212        */
213       CURSOR_BLINK_INTERVAL,
214
215       /**
216        * @brief The cursor will stop blinking after this number of seconds (if non-zero)
217        * @details Name "cursorBlinkDuration", type Property::FLOAT.
218        * @SINCE_1_0.0
219        */
220       CURSOR_BLINK_DURATION,
221
222       /**
223        * @brief The cursor width.
224        * @details Name "cursorWidth", type Property::INTEGER.
225        * @SINCE_1_0.0
226        */
227       CURSOR_WIDTH,
228
229       /**
230        * @brief The image to display for the grab handle.
231        * @details Name "grabHandleImage", type Property::STRING.
232        * @SINCE_1_0.0
233        */
234       GRAB_HANDLE_IMAGE,
235
236       /**
237        * @brief The image to display when the grab handle is pressed
238        * @details Name "grabHandlePressedImage", type Property::STRING.
239        * @SINCE_1_0.0
240        */
241       GRAB_HANDLE_PRESSED_IMAGE,
242
243       /**
244        * @brief Horizontal scrolling will occur if the cursor is this close to the control border.
245        * @details Name "scrollThreshold", type Property::FLOAT.
246        * @SINCE_1_0.0
247        */
248       SCROLL_THRESHOLD,
249
250       /**
251        * @brief The scroll speed in pixels per second.
252        * @details Name "scrollSpeed", type Property::FLOAT.
253        * @SINCE_1_0.0
254        */
255       SCROLL_SPEED,
256
257       /**
258        * @brief The image to display for the left selection handle.
259        * @details Name "selectionHandleImageLeft", type Property::MAP.
260        * @SINCE_1_0.0
261        */
262       SELECTION_HANDLE_IMAGE_LEFT,
263
264       /**
265        * @brief The image to display for the right selection handle.
266        * @details Name "selectionHandleImageRight", type Property::MAP.
267        * @SINCE_1_0.0
268        */
269       SELECTION_HANDLE_IMAGE_RIGHT,
270
271       /**
272        * @brief The image to display when the left selection handle is pressed.
273        * @details Name "selectionHandlePressedImageLeft", type Property::MAP.
274        * @SINCE_1_0.0
275        */
276       SELECTION_HANDLE_PRESSED_IMAGE_LEFT,
277
278       /**
279        * @brief The image to display when the right selection handle is pressed.
280        * @details Name "selectionHandlePressedImageRight", type Property::MAP.
281        * @SINCE_1_0.0
282        */
283       SELECTION_HANDLE_PRESSED_IMAGE_RIGHT,
284
285       /**
286        * @brief The image to display for the left selection handle marker.
287        * @details Name "selectionHandleMarkerImageLeft", type Property::MAP.
288        * @SINCE_1_0.0
289        */
290       SELECTION_HANDLE_MARKER_IMAGE_LEFT,
291
292       /**
293        * @brief The image to display for the right selection handle marker.
294        * @details Name "selectionHandleMarkerImageRight", type Property::MAP.
295        * @SINCE_1_0.0
296        */
297       SELECTION_HANDLE_MARKER_IMAGE_RIGHT,
298
299       /**
300        * @brief The color of the selection highlight.
301        * @details Name "selectionHighlightColor", type Property::VECTOR4.
302        * @SINCE_1_0.0
303        */
304       SELECTION_HIGHLIGHT_COLOR,
305
306       /**
307        * @brief The decorations (handles etc) will positioned within this area on-screen.
308        * @details Name "decorationBoundingBox", type Property::RECTANGLE.
309        * @SINCE_1_0.0
310        */
311       DECORATION_BOUNDING_BOX,
312
313       /**
314        * @brief The settings to relating to the System's Input Method, Key and Value.
315        * @details Name "inputMethodSettings", type Property::MAP.
316        *
317        * @note VARIATION key can be changed depending on PANEL_LAYOUT.
318        * For example, when PANEL_LAYOUT key is InputMethod::PanelLayout::NORMAL,
319        * then VARIATION would be among NORMAL, WITH_FILENAME, and WITH_PERSON_NAME in Dali::InputMethod::NormalLayout.
320        * For more information, see Dali::InputMethod::Category.
321        *
322        * Example Usage:
323        * @code
324        *   Property::Map propertyMap;
325        *   InputMethod::PanelLayout::Type panelLayout = InputMethod::PanelLayout::NUMBER;
326        *   InputMethod::AutoCapital::Type autoCapital = InputMethod::AutoCapital::WORD;
327        *   InputMethod::ButtonAction::Type buttonAction = InputMethod::ButtonAction::GO;
328        *   int inputVariation = 1;
329        *   propertyMap["PANEL_LAYOUT"] = panelLayout;
330        *   propertyMap["AUTO_CAPITALIZE"] = autoCapital;
331        *   propertyMap["BUTTON_ACTION"] = buttonAction;
332        *   propertyMap["VARIATION"] = inputVariation;
333        *
334        *   field.SetProperty( TextField::Property::INPUT_METHOD_SETTINGS, propertyMap );
335        * @endcode
336        * @SINCE_1_0.0
337        */
338       INPUT_METHOD_SETTINGS,
339
340       /**
341        * @brief The color of the new input text.
342        * @details Name "inputColor", type Property::VECTOR4.
343        * @SINCE_1_0.0
344        */
345       INPUT_COLOR,
346
347       /**
348        * @brief Whether the mark-up processing is enabled.
349        * @details Name "enableMarkup", type Property::BOOLEAN.
350        * @SINCE_1_0.0
351        */
352       ENABLE_MARKUP,
353
354       /**
355        * @brief The font's family of the new input text.
356        * @details Name "inputFontFamily", type Property::STRING.
357        * @SINCE_1_0.0
358        */
359       INPUT_FONT_FAMILY,
360
361       /**
362        * @brief The font's style of the new input text.
363        * @details Name "inputFontStyle", type Property::MAP.
364        * @SINCE_1_2.13
365        */
366       INPUT_FONT_STYLE,
367
368       /**
369        * @brief The font's size of the new input text in points.
370        * @details Name "inputPointSize", type Property::FLOAT.
371        * @SINCE_1_0.0
372        */
373       INPUT_POINT_SIZE,
374
375       /**
376        * @copydoc Dali::Toolkit::TextLabel::Property::UNDERLINE
377        */
378       UNDERLINE,
379
380       /**
381        * @brief The underline parameters of the new input text.
382        * @details Name "inputUnderline", type Property::MAP.
383        * @SINCE_1_2.13
384        */
385       INPUT_UNDERLINE,
386
387       /**
388        * @copydoc Dali::Toolkit::TextLabel::Property::SHADOW
389        */
390       SHADOW,
391
392       /**
393        * @brief The shadow parameters of the new input text.
394        * @details Name "inputShadow", type Property::MAP.
395        * @SINCE_1_2.13
396        */
397       INPUT_SHADOW,
398
399       /**
400        * @brief The default emboss parameters.
401        * @details Name "emboss", type Property::MAP.
402        * @SINCE_1_2.13
403        */
404       EMBOSS,
405
406       /**
407        * @brief The emboss parameters of the new input text.
408        * @details Name "inputEmboss", type Property::MAP.
409        * @SINCE_1_2.13
410        */
411       INPUT_EMBOSS,
412
413       /**
414        * @copydoc Dali::Toolkit::TextLabel::Property::OUTLINE
415        */
416       OUTLINE,
417
418       /**
419        * @brief The outline parameters of the new input text.
420        * @details Name "inputOutline", type Property::MAP.
421        * @SINCE_1_2.13
422        */
423       INPUT_OUTLINE,
424
425       /**
426        * @brief Hides the input characters and instead shows a default character for password or pin entry.
427        * @details Name "hiddenInputSettings", type Property::MAP.
428        * @SINCE_1_2.60
429        * @note Optional.
430        * @see HiddenInput::Property
431        */
432       HIDDEN_INPUT_SETTINGS,
433
434       /**
435        * @brief The size of font in pixels.
436        * @details Name "pixelSize", type Property::FLOAT.
437        *          Conversion from Point size to Pixel size:
438        *           Pixel size = Point size * DPI / 72
439        * @SINCE_1_2.60
440        */
441       PIXEL_SIZE,
442
443       /**
444        * @brief Enables Text selection, such as the cursor, handle, clipboard, and highlight color.
445        * @details Name "enableSelection", type Property::BOOLEAN.
446        * @SINCE_1_2.60
447        */
448       ENABLE_SELECTION,
449
450       /**
451        * @brief Sets the placeholder : text, color, font family, font style, point size, and pixel size.
452        * @details Name "placeholder", type Property::MAP.
453        * Example Usage:
454        * @code
455        *   Property::Map propertyMap;
456        *   propertyMap[ Text::PlaceHolder::Property::TEXT ] = "Setting Placeholder Text";
457        *   propertyMap[ Text::PlaceHolder::Property::TEXT_FOCUSED] = "Setting Placeholder Text Focused";
458        *   propertyMap[ Text::PlaceHolder::Property::COLOR] = Color::RED;
459        *   propertyMap[ Text::PlaceHolder::Property::FONT_FAMILY ] = "Arial";
460        *   propertyMap[ Text::PlaceHolder::Property::POINT_SIZE ] = 12.0f;
461        *   propertyMap[ Text::PlaceHolder::Property::ELLIPSIS ] = true;
462        *
463        *   Property::Map fontStyleMap;
464        *   fontStyleMap.Insert( "weight", "bold" );
465        *   fontStyleMap.Insert( "width", "condensed" );
466        *   fontStyleMap.Insert( "slant", "italic" );
467        *   propertyMap[ Text::PlaceHolder::Property::FONT_STYLE] = fontStyleMap;
468        *
469        *   field.SetProperty( TextField::Property::PLACEHOLDER, propertyMap );
470        * @endcode
471        * @SINCE_1_2.60
472        */
473       PLACEHOLDER,
474
475       /**
476        * @brief Whether we should show the ellipsis if it is required.
477        * @details Name "ellipsis", type Property::BOOLEAN.
478        * @SINCE_1_2.60
479        * @note PLACEHOLDER map is used to add ellipsis to placeholder text.
480        */
481       ELLIPSIS,
482     };
483   };
484
485   /**
486    * @brief Enumeration for specifying how the text is truncated when it does not fit.
487    *
488    * The default value is \e EXCEED_POLICY_CLIP.
489    * @SINCE_1_0.0
490    */
491   enum ExceedPolicy
492   {
493     EXCEED_POLICY_ORIGINAL,        ///< The text will be display at original size, and may exceed the TextField boundary. @SINCE_1_0.0
494     EXCEED_POLICY_CLIP             ///< The end of text will be clipped to fit within the TextField. @SINCE_1_0.0
495   };
496
497   /**
498    * @brief Mask used by the signal InputStyleChangedSignal(). Notifies which parameters of the input style have changed.
499    *
500    * @SINCE_1_2_2
501    */
502   struct InputStyle
503   {
504   /**
505    * @brief Mask used by the signal InputStyleChangedSignal().
506    *
507    * @SINCE_1_2_2
508    */
509     enum Mask
510     {
511       NONE         = 0x0000, ///< @SINCE_1_2_2
512       COLOR        = 0x0001, ///< @SINCE_1_2_2
513       FONT_FAMILY  = 0x0002, ///< @SINCE_1_2_2
514       POINT_SIZE   = 0x0004, ///< @SINCE_1_2_2
515       FONT_STYLE   = 0x0008, ///< @SINCE_1_2_2
516       UNDERLINE    = 0x0010, ///< @SINCE_1_2_2
517       SHADOW       = 0x0020, ///< @SINCE_1_2_2
518       EMBOSS       = 0x0040, ///< @SINCE_1_2_2
519       OUTLINE      = 0x0080  ///< @SINCE_1_2_2
520     };
521   };
522
523   // Type Defs
524
525   /**
526    * @brief Text changed signal type.
527    * @SINCE_1_0.0
528    */
529   typedef Signal<void ( TextField ) > TextChangedSignalType;
530
531   /**
532    * @brief Max Characters Exceed signal type.
533    * @SINCE_1_0.0
534    */
535   typedef Signal<void ( TextField ) > MaxLengthReachedSignalType;
536
537   /**
538    * @brief Input Style changed signal type.
539    * @SINCE_1_2_2
540    */
541   typedef Signal<void ( TextField, InputStyle::Mask ) > InputStyleChangedSignalType;
542
543   /**
544    * @brief Creates the TextField control.
545    * @SINCE_1_0.0
546    * @return A handle to the TextField control
547    */
548   static TextField New();
549
550   /**
551    * @brief Creates an empty handle.
552    * @SINCE_1_0.0
553    */
554   TextField();
555
556   /**
557    * @brief Copy constructor.
558    *
559    * @SINCE_1_0.0
560    * @param[in] handle The handle to copy from
561    */
562   TextField( const TextField& handle );
563
564   /**
565    * @brief Assignment operator.
566    *
567    * @SINCE_1_0.0
568    * @param[in] handle The handle to copy from
569    * @return A reference to this
570    */
571   TextField& operator=( const TextField& handle );
572
573   /**
574    * @brief Destructor.
575    *
576    * This is non-virtual since derived Handle types must not contain data or virtual methods.
577    * @SINCE_1_0.0
578    */
579   ~TextField();
580
581   /**
582    * @brief Downcasts a handle to TextField.
583    *
584    * If the BaseHandle points is a TextField, the downcast returns a valid handle.
585    * If not, the returned handle is left empty.
586    *
587    * @SINCE_1_0.0
588    * @param[in] handle Handle to an object
589    * @return Handle to a TextField or an empty handle
590    */
591   static TextField DownCast( BaseHandle handle );
592
593   // Signals
594
595   /**
596    * @brief This signal is emitted when the text changes.
597    *
598    * A callback of the following type may be connected:
599    * @code
600    *   void YourCallbackName( TextField textField );
601    * @endcode
602    * @SINCE_1_0.0
603    * @return The signal to connect to.
604    */
605   TextChangedSignalType& TextChangedSignal();
606
607   /**
608    * @brief This signal is emitted when inserted text exceeds the maximum character limit.
609    *
610    * A callback of the following type may be connected:
611    * @code
612    *   void YourCallbackName( TextField textField );
613    * @endcode
614    * @SINCE_1_0.0
615    * @return The signal to connect to
616    */
617   MaxLengthReachedSignalType& MaxLengthReachedSignal();
618
619   /**
620    * @brief This signal is emitted when the input style is updated as a consequence of a change in the cursor position.
621    * i.e. The signal is not emitted when the input style is updated through the property system.
622    *
623    * A callback of the following type may be connected. The @p mask parameter notifies which parts of the style have changed.
624    * @code
625    *   void YourCallbackName( TextField textField, TextField::InputStyle::Mask mask );
626    * @endcode
627    *
628    * @SINCE_1_2_2
629    * @return The signal to connect to
630    */
631   InputStyleChangedSignalType& InputStyleChangedSignal();
632
633 public: // Not intended for application developers
634
635   /**
636    * @brief Creates a handle using the Toolkit::Internal implementation.
637    *
638    * @SINCE_1_0.0
639    * @param[in] implementation The Control implementation
640    */
641   DALI_INTERNAL TextField( Internal::TextField& implementation );
642
643   /**
644    * @brief Allows the creation of this Control from an Internal::CustomActor pointer.
645    *
646    * @SINCE_1_0.0
647    * @param[in] internal A pointer to the internal CustomActor
648    */
649   explicit DALI_INTERNAL TextField( Dali::Internal::CustomActor* internal );
650 };
651
652 /**
653  * @}
654  */
655 } // namespace Toolkit
656
657 } // namespace Dali
658
659 #endif // __DALI_TOOLKIT_TEXT_FIELD_H__