0e1f9bb51e32aaedcf7fff57cfd94232780c8ad2
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / devel-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()                            |
46  *
47  */
48 class DALI_IMPORT_API TextEditor : public Control
49 {
50 public:
51
52   /**
53    * @brief The start and end property ranges for this control.
54    */
55   enum PropertyRange
56   {
57     PROPERTY_START_INDEX = Control::CONTROL_PROPERTY_END_INDEX + 1,
58     PROPERTY_END_INDEX =   PROPERTY_START_INDEX + 1000              ///< Reserve property indices
59   };
60
61   /**
62    * @brief An enumeration of properties belonging to the TextEditor class.
63    */
64   struct Property
65   {
66     enum
67     {
68       RENDERING_BACKEND = PROPERTY_START_INDEX, ///< name "renderingBackend",                    The type or rendering e.g. bitmap-based,                                         type INT
69       TEXT,                                     ///< name "text",                                The text to display in UTF-8 format,                                             type STRING
70       TEXT_COLOR,                               ///< name "textColor",                           The text color,                                                                  type VECTOR4
71       FONT_FAMILY,                              ///< name "fontFamily",                          The requested font family,                                                       type STRING
72       FONT_STYLE,                               ///< name "fontStyle",                           The requested font style,                                                        type STRING
73       POINT_SIZE,                               ///< name "pointSize",                           The size of font in points,                                                      type FLOAT
74       HORIZONTAL_ALIGNMENT,                     ///< name "horizontalAlignment",                 The text horizontal alignment,                                                   type STRING,  values "BEGIN", "CENTER", "END"
75       SCROLL_THRESHOLD,                         ///< name "scrollThreshold"                      Vertical scrolling will occur if the cursor is this close to the control border, type FLOAT
76       SCROLL_SPEED,                             ///< name "scrollSpeed"                          The scroll speed in pixels per second,                                           type FLOAT
77       PRIMARY_CURSOR_COLOR,                     ///< name "primaryCursorColor",                  The color to apply to the primary cursor,                                        type VECTOR4
78       SECONDARY_CURSOR_COLOR,                   ///< name "secondaryCursorColor",                The color to apply to the secondary cursor,                                      type VECTOR4
79       ENABLE_CURSOR_BLINK,                      ///< name "enableCursorBlink",                   Whether the cursor should blink or not,                                          type BOOLEAN
80       CURSOR_BLINK_INTERVAL,                    ///< name "cursorBlinkInterval",                 The time interval in seconds between cursor on/off states,                       type FLOAT
81       CURSOR_BLINK_DURATION,                    ///< name "cursorBlinkDuration",                 The cursor will stop blinking after this number of seconds (if non-zero),        type FLOAT
82       CURSOR_WIDTH,                             ///< name "cursorWidth",                         The cursor width,                                                                type INTEGER
83       GRAB_HANDLE_IMAGE,                        ///< name "grabHandleImage",                     The image to display for the grab handle,                                        type STRING
84       GRAB_HANDLE_PRESSED_IMAGE,                ///< name "grabHandlePressedImage",              The image to display when the grab handle is pressed,                            type STRING
85       SELECTION_HANDLE_IMAGE_LEFT,              ///< name "selectionHandleImageLeft",            The image to display for the left selection handle,                              type MAP
86       SELECTION_HANDLE_IMAGE_RIGHT,             ///< name "selectionHandleImageRight",           The image to display for the right selection handle,                             type MAP
87       SELECTION_HANDLE_PRESSED_IMAGE_LEFT,      ///< name "selectionHandlePressedImageLeft",     The image to display when the left selection handle is pressed,                  type MAP
88       SELECTION_HANDLE_PRESSED_IMAGE_RIGHT,     ///< name "selectionHandlePressedImageRight",    The image to display when the right selection handle is pressed,                 type MAP
89       SELECTION_HANDLE_MARKER_IMAGE_LEFT,       ///< name "selectionHandleMarkerImageLeft",      The image to display for the left selection handle marker,                       type MAP
90       SELECTION_HANDLE_MARKER_IMAGE_RIGHT,      ///< name "selectionHandleMarkerImageRight",     The image to display for the right selection handle marker,                      type MAP
91       SELECTION_HIGHLIGHT_COLOR,                ///< name "selectionHighlightColor",             The color of the selection highlight,                                            type VECTOR4
92       DECORATION_BOUNDING_BOX,                  ///< name "decorationBoundingBox",               The decorations (handles etc) will positioned within this area on-screen,        type RECTANGLE
93       ENABLE_MARKUP,                            ///< name "enableMarkup",                        Whether the mark-up processing is enabled.                                       type BOOLEAN
94       INPUT_COLOR,                              ///< name "inputColor",                          The color of the new input text,                                                 type VECTOR4
95       INPUT_FONT_FAMILY,                        ///< name "inputFontFamily",                     The font's family of the new input text,                                         type STRING
96       INPUT_FONT_STYLE,                         ///< name "inputFontStyle",                      The font's style of the new input text,                                          type STRING
97       INPUT_POINT_SIZE                          ///< name "inputPointSize",                      The font's size of the new input text in points,                                 type FLOAT
98     };
99   };
100
101   // Type Defs
102
103   /// @brief Text changed signal type.
104   typedef Signal<void ( TextEditor ) > TextChangedSignalType;
105
106   /**
107    * @brief Create the TextEditor control.
108    * @return A handle to the TextEditor control.
109    */
110   static TextEditor New();
111
112   /**
113    * @brief Creates an empty handle.
114    */
115   TextEditor();
116
117   /**
118    * @brief Copy constructor.
119    *
120    * @param[in] handle The handle to copy from.
121    */
122   TextEditor( const TextEditor& handle );
123
124   /**
125    * @brief Assignment operator.
126    *
127    * @param[in] handle The handle to copy from.
128    * @return A reference to this.
129    */
130   TextEditor& operator=( const TextEditor& handle );
131
132   /**
133    * @brief Destructor.
134    *
135    * This is non-virtual since derived Handle types must not contain data or virtual methods.
136    */
137   ~TextEditor();
138
139   /**
140    * @brief Downcast a handle to TextEditor.
141    *
142    * If the BaseHandle points is a TextEditor the downcast returns a valid handle.
143    * If not the returned handle is left empty.
144    *
145    * @param[in] handle Handle to an object.
146    * @return handle to a TextEditor or an empty handle.
147    */
148   static TextEditor DownCast( BaseHandle handle );
149
150   // Signals
151
152   /**
153    * @brief This signal is emitted when the text changes.
154    *
155    * A callback of the following type may be connected:
156    * @code
157    *   void YourCallbackName( TextEditor textEditor );
158    * @endcode
159    * @return The signal to connect to.
160    */
161   TextChangedSignalType& TextChangedSignal();
162
163 public: // Not intended for application developers
164
165   /**
166    * @brief Creates a handle using the Toolkit::Internal implementation.
167    *
168    * @param[in] implementation The Control implementation.
169    */
170   DALI_INTERNAL TextEditor( Internal::TextEditor& implementation );
171
172   /**
173    * @brief Allows the creation of this Control from an Internal::CustomActor pointer.
174    *
175    * @param[in]  internal  A pointer to the internal CustomActor.
176    */
177   explicit DALI_INTERNAL TextEditor( Dali::Internal::CustomActor* internal );
178 };
179
180 /**
181  * @}
182  */
183 } // namespace Toolkit
184
185 } // namespace Dali
186
187 #endif // __DALI_TOOLKIT_TEXT_EDITOR_H__