1 #ifndef __DALI_TOOLKIT_TEXT_FIELD_H__
2 #define __DALI_TOOLKIT_TEXT_FIELD_H__
5 * Copyright (c) 2015 Samsung Electronics Co., Ltd.
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
11 * http://www.apache.org/licenses/LICENSE-2.0
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.
22 #include <dali-toolkit/public-api/controls/control.h>
30 namespace Internal DALI_INTERNAL
35 * @addtogroup dali_toolkit_controls_text_controls
40 * @brief A control which provides a single-line editable text field.
43 * | %Signal Name | Method |
44 * |------------------------|-----------------------------------------------------|
45 * | text-changed | @ref TextChangedSignal() |
46 * | max-length-reached | @ref MaxLengthReachedSignal() |
49 class DALI_IMPORT_API TextField : public Control
54 * @brief The start and end property ranges for this control.
58 PROPERTY_START_INDEX = Control::CONTROL_PROPERTY_END_INDEX + 1,
59 PROPERTY_END_INDEX = PROPERTY_START_INDEX + 1000 ///< Reserve property indices
63 * @brief An enumeration of properties belonging to the TextLabel class.
69 RENDERING_BACKEND = PROPERTY_START_INDEX, ///< name "rendering-backend", The type or rendering e.g. bitmap-based, type INT
70 TEXT, ///< name "text", The text to display in UTF-8 format, type STRING
71 PLACEHOLDER_TEXT, ///< name "placeholder-text", The text to display when the TextField is empty and inactive, type STRING
72 PLACEHOLDER_TEXT_FOCUSED, ///< name "placeholder-text-focused", The text to display when the TextField is empty with key-input focus, type STRING
73 FONT_FAMILY, ///< name "font-family", The requested font family, type STRING
74 FONT_STYLE, ///< name "font-style", The requested font style, type STRING
75 POINT_SIZE, ///< name "point-size", The size of font in points, type FLOAT
76 MAX_LENGTH, ///< name "max-length" The maximum number of characters that can be inserted, type INTEGER
77 EXCEED_POLICY, ///< name "exceed-policy" Specifies how the text is truncated when it does not fit, type INTEGER
78 HORIZONTAL_ALIGNMENT, ///< name "horizontal-alignment", The line horizontal alignment, type STRING, values "BEGIN", "CENTER", "END"
79 VERTICAL_ALIGNMENT, ///< name "vertical-alignment", The line vertical alignment, type STRING, values "TOP", "CENTER", "BOTTOM"
80 TEXT_COLOR, ///< name "text-color", The text color, type VECTOR4
81 PLACEHOLDER_TEXT_COLOR, ///< name "placeholder-text-color", The placeholder-text color, type VECTOR4
82 SHADOW_OFFSET, ///< name "shadow-offset", The drop shadow offset 0 indicates no shadow, type VECTOR2
83 SHADOW_COLOR, ///< name "shadow-color", The color of a drop shadow, type VECTOR4
84 PRIMARY_CURSOR_COLOR, ///< name "primary-cursor-color", The color to apply to the primary cursor, type VECTOR4
85 SECONDARY_CURSOR_COLOR, ///< name "secondary-cursor-color", The color to apply to the secondary cursor, type VECTOR4
86 ENABLE_CURSOR_BLINK, ///< name "enable-cursor-blink", Whether the cursor should blink or not, type BOOLEAN
87 CURSOR_BLINK_INTERVAL, ///< name "cursor-blink-interval", The time interval in seconds between cursor on/off states, type FLOAT
88 CURSOR_BLINK_DURATION, ///< name "cursor-blink-duration", The cursor will stop blinking after this number of seconds (if non-zero), type FLOAT
89 CURSOR_WIDTH, ///< name "cursor-width", The cursor width, type INTEGER
90 GRAB_HANDLE_IMAGE, ///< name "grab-handle-image", The image to display for the grab handle, type STRING
91 GRAB_HANDLE_PRESSED_IMAGE, ///< name "grab-handle-pressed-image", The image to display when the grab handle is pressed, type STRING
92 SCROLL_THRESHOLD, ///< name "scroll-threshold" Scrolling will occur if the cursor is this close to the control border, type FLOAT
93 SCROLL_SPEED, ///< name "scroll-speed" The scroll speed in pixels per second, type FLOAT
94 SELECTION_HANDLE_IMAGE_LEFT, ///< name "selection-handle-image-left", The image to display for the left selection handle, type MAP
95 SELECTION_HANDLE_IMAGE_RIGHT, ///< name "selection-handle-image-right", The image to display for the right selection handle, type MAP
96 SELECTION_HANDLE_PRESSED_IMAGE_LEFT, ///< name "selection-handle-pressed-image-left" The image to display when the left selection handle is pressed, type MAP
97 SELECTION_HANDLE_PRESSED_IMAGE_RIGHT, ///< name "selection-handle-pressed-image-right" The image to display when the right selection handle is pressed, type MAP
98 SELECTION_HANDLE_MARKER_IMAGE_LEFT, ///< name "selection-handle-marker-image-left", The image to display for the left selection handle marker, type MAP
99 SELECTION_HANDLE_MARKER_IMAGE_RIGHT, ///< name "selection-handle-marker-image-right", The image to display for the right selection handle marker, type MAP
100 SELECTION_HIGHLIGHT_COLOR, ///< name "selection-highlight-color" The color of the selection highlight, type VECTOR4
101 DECORATION_BOUNDING_BOX, ///< name "decoration-bounding-box" The decorations (handles etc) will positioned within this area on-screen, type RECTANGLE
102 INPUT_METHOD_SETTINGS ///< name "input-method-settings" The settings to relating to the System's Input Method, Key and Value type MAP
107 * @brief Specifies how the text is truncated when it does not fit
109 * The default value is \e EXCEED_POLICY_CLIP.
113 EXCEED_POLICY_ORIGINAL, ///< The text will be display at original size, and may exceed the TextField boundary.
114 EXCEED_POLICY_CLIP ///< The end of text will be clipped to fit within the TextField.
119 /// @brief Max Characters Exceed signal type;
120 typedef Signal<void ( TextField ) > TextChangedSignalType;
121 typedef Signal<void ( TextField ) > MaxLengthReachedSignalType;
124 * Create the TextField control.
125 * @return A handle to the TextField control.
127 static TextField New();
130 * @brief Creates an empty handle.
135 * @brief Copy constructor.
137 * @param[in] handle The handle to copy from.
139 TextField( const TextField& handle );
142 * @brief Assignment operator.
144 * @param[in] handle The handle to copy from.
145 * @return A reference to this.
147 TextField& operator=( const TextField& handle );
152 * This is non-virtual since derived Handle types must not contain data or virtual methods.
157 * @brief Downcast a handle to TextField.
159 * If the BaseHandle points is a TextField the downcast returns a valid handle.
160 * If not the returned handle is left empty.
162 * @param[in] handle Handle to an object
163 * @return handle to a TextField or an empty handle
165 static TextField DownCast( BaseHandle handle );
170 * @brief This signal is emitted when the text changes.
172 * A callback of the following type may be connected:
174 * void YourCallbackName( TextField textField );
176 * @return The signal to connect to.
178 TextChangedSignalType& TextChangedSignal();
181 * @brief This signal is emitted when inserted text exceeds the maximum character limit.
183 * A callback of the following type may be connected:
185 * void YourCallbackName( TextField textField );
187 * @return The signal to connect to.
189 MaxLengthReachedSignalType& MaxLengthReachedSignal();
191 public: // Not intended for application developers
194 * @brief Creates a handle using the Toolkit::Internal implementation.
196 * @param[in] implementation The Control implementation.
198 DALI_INTERNAL TextField( Internal::TextField& implementation );
201 * @brief Allows the creation of this Control from an Internal::CustomActor pointer.
203 * @param[in] internal A pointer to the internal CustomActor.
205 explicit DALI_INTERNAL TextField( Dali::Internal::CustomActor* internal );
211 } // namespace Toolkit
215 #endif // __DALI_TOOLKIT_TEXT_FIELD_H__