Merge base & optional
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / public-api / controls / text-input / text-input.cpp
1 /*
2  * Copyright (c) 2014 Samsung Electronics Co., Ltd.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  */
17
18 // CLASS HEADER
19 #include <dali-toolkit/public-api/controls/text-input/text-input.h>
20
21 // EXTERNAL INCLUDES
22 #include <dali/public-api/actors/mesh-actor.h>
23 #include <dali/public-api/adaptor-framework/clipboard.h>
24 #include <dali/public-api/adaptor-framework/clipboard-event-notifier.h>
25 #include <dali/public-api/adaptor-framework/imf-manager.h>
26 #include <dali/public-api/adaptor-framework/timer.h>
27
28 // INTERNAL INCLUDES
29 #include <dali-toolkit/public-api/controls/text-input/text-input.h>
30 #include <dali-toolkit/internal/controls/text-input/text-input-impl.h>
31
32 namespace Dali
33 {
34
35 namespace Toolkit
36 {
37
38 const char* const TextInput::SIGNAL_START_INPUT( "start-input" );
39 const char* const TextInput::SIGNAL_END_INPUT( "end-input" );
40 const char* const TextInput::SIGNAL_STYLE_CHANGED( "style-changed" );
41 const char* const TextInput::SIGNAL_MAX_INPUT_CHARACTERS_REACHED( "max-input-characters-reached" );
42 const char* const TextInput::SIGNAL_TOOLBAR_DISPLAYED = "toolbar-displayed";
43 const char* const TextInput::SIGNAL_TEXT_EXCEED_BOUNDARIES = "text-exceed-boundaries";
44
45 TextInput::TextInput()
46 {
47 }
48
49 TextInput::TextInput(Internal::TextInput& implementation)
50 : Control(implementation)
51 {
52 }
53
54 TextInput::TextInput( const TextInput& textInput )
55 : Control( textInput )
56 {
57 }
58
59 TextInput& TextInput::operator=( const TextInput& textInput )
60 {
61   if( &textInput != this )
62   {
63     Control::operator=( textInput );
64   }
65
66   return *this;
67 }
68
69 TextInput TextInput::New()
70 {
71   return Internal::TextInput::New();
72 }
73
74 TextInput TextInput::DownCast( BaseHandle actor )
75 {
76   return Control::DownCast<TextInput, Internal::TextInput>(actor);
77 }
78
79 TextInput::~TextInput()
80 {
81 }
82
83 std::string TextInput::GetText() const
84 {
85   return GetImpl(*this).GetText();
86 }
87
88 std::string TextInput::GetMarkupText() const
89 {
90   return GetImpl(*this).GetMarkupText();
91 }
92
93 void TextInput::SetMaxCharacterLength(std::size_t maxChars)
94 {
95   GetImpl(*this).SetMaxCharacterLength(maxChars);
96 }
97
98 void TextInput::SetNumberOfLinesLimit(std::size_t maxLines)
99 {
100   GetImpl(*this).SetNumberOfLinesLimit( maxLines );
101 }
102
103 std::size_t TextInput::GetNumberOfLinesLimit() const
104 {
105   return GetImpl(*this).GetNumberOfLinesLimit();
106 }
107
108 std::size_t TextInput::GetNumberOfCharacters() const
109 {
110   return GetImpl(*this).GetNumberOfCharacters();
111 }
112
113 void TextInput::SetPlaceholderText( const std::string& placeHolderText )
114 {
115   GetImpl(*this).SetPlaceholderText( placeHolderText );
116 }
117
118 std::string TextInput::GetPlaceholderText()
119 {
120   return GetImpl(*this).GetPlaceholderText();
121 }
122
123 void TextInput::SetInitialText(const std::string& initialText)
124 {
125   GetImpl(*this).SetInitialText(initialText);
126 }
127
128 void TextInput::SetEditable(bool editMode)
129 {
130   GetImpl(*this).SetEditable(editMode, false);
131 }
132
133 void TextInput::SetEditable(bool editMode, const Vector2& touchPoint)
134 {
135   GetImpl(*this).SetEditable(editMode, true, touchPoint);
136 }
137
138 bool TextInput::IsEditable() const
139 {
140   return GetImpl(*this).IsEditable();
141 }
142
143 void TextInput::SetEditOnTouch( bool editOnTouch )
144 {
145   GetImpl(*this).SetEditOnTouch( editOnTouch );
146 }
147
148 bool TextInput::IsEditOnTouch() const
149 {
150   return GetImpl(*this).IsEditOnTouch();
151 }
152
153 void TextInput::SetTextSelectable( bool textSelectable )
154 {
155   GetImpl(*this).SetTextSelectable( textSelectable );
156 }
157
158 bool TextInput::IsTextSelectable() const
159 {
160   return GetImpl(*this).IsTextSelectable();
161 }
162
163 bool TextInput::IsTextSelected() const
164 {
165   return GetImpl(*this).IsTextSelected();
166 }
167
168 void TextInput::SelectText(std::size_t start, std::size_t end)
169 {
170   GetImpl(*this).SelectText( start, end );
171 }
172
173 void TextInput::DeSelectText()
174 {
175   GetImpl(*this).DeSelectText();
176 }
177
178 void TextInput::SetGrabHandleImage( Image image )
179 {
180   GetImpl(*this).SetGrabHandleImage(image);
181 }
182
183 void TextInput::SetCursorImage(Dali::Image image, const Vector4& border )
184 {
185   GetImpl(*this).SetCursorImage(image, border );
186 }
187
188 Vector3 TextInput::GetSelectionHandleSize()
189 {
190   return GetImpl(*this).GetSelectionHandleSize();
191 }
192
193 void TextInput::SetRTLCursorImage(Dali::Image image, const Vector4& border )
194 {
195   GetImpl(*this).SetRTLCursorImage(image, border );
196 }
197
198 void TextInput::EnableGrabHandle(bool toggle)
199 {
200   GetImpl(*this).EnableGrabHandle( toggle );
201 }
202
203 bool TextInput::IsGrabHandleEnabled()
204 {
205   return GetImpl(*this).IsGrabHandleEnabled();
206 }
207
208 void TextInput::SetBoundingRectangle( const Rect<float>& boundingOriginAndSize )
209 {
210   GetImpl(*this).SetBoundingRectangle( boundingOriginAndSize );
211 }
212
213 const Rect<float> TextInput::GetBoundingRectangle() const
214 {
215   return GetImpl(*this).GetBoundingRectangle();
216 }
217
218 void TextInput::SetActiveStyle( const TextStyle& style, const TextStyle::Mask mask )
219 {
220   GetImpl(*this).SetActiveStyle(style,mask);
221 }
222
223 void TextInput::ApplyStyle( const TextStyle& style, const TextStyle::Mask mask )
224 {
225   GetImpl(*this).ApplyStyle( style, mask );
226 }
227
228 void TextInput::ApplyStyleToAll( const TextStyle& style, const TextStyle::Mask mask )
229 {
230   GetImpl(*this).ApplyStyleToAll( style, mask );
231 }
232
233 TextStyle TextInput::GetStyleAtCursor() const
234 {
235   return GetImpl(*this).GetStyleAtCursor();
236 }
237
238 void TextInput::SetTextAlignment( Toolkit::Alignment::Type align )
239 {
240   GetImpl(*this).SetTextAlignment(align);
241 }
242
243 void TextInput::SetTextLineJustification( Toolkit::TextView::LineJustification justification )
244 {
245   GetImpl(*this).SetTextLineJustification(justification);
246 }
247
248 void TextInput::SetFadeBoundary( const Toolkit::TextView::FadeBoundary& fadeBoundary )
249 {
250   GetImpl(*this).SetFadeBoundary( fadeBoundary );
251 }
252
253 const Toolkit::TextView::FadeBoundary& TextInput::GetFadeBoundary() const
254 {
255   return GetImpl(*this).GetFadeBoundary();
256 }
257
258 Alignment::Type TextInput::GetTextAlignment() const
259 {
260   return GetImpl(*this).GetTextAlignment();
261 }
262
263 void TextInput::SetMultilinePolicy( TextView::MultilinePolicy policy )
264 {
265   GetImpl(*this).SetMultilinePolicy(policy);
266 }
267
268 TextView::MultilinePolicy TextInput::GetMultilinePolicy() const
269 {
270   return GetImpl(*this).GetMultilinePolicy();
271 }
272
273 void TextInput::SetWidthExceedPolicy( TextView::ExceedPolicy policy )
274 {
275   GetImpl(*this).SetWidthExceedPolicy(policy);
276 }
277
278 TextView::ExceedPolicy TextInput::GetWidthExceedPolicy() const
279 {
280   return GetImpl(*this).GetWidthExceedPolicy();
281 }
282
283 void TextInput::SetHeightExceedPolicy( TextView::ExceedPolicy policy )
284 {
285   GetImpl(*this).SetHeightExceedPolicy(policy);
286 }
287
288 TextView::ExceedPolicy TextInput::GetHeightExceedPolicy() const
289 {
290   return GetImpl(*this).GetHeightExceedPolicy();
291 }
292
293 void TextInput::SetExceedEnabled( bool enable )
294 {
295   GetImpl(*this).SetExceedEnabled( enable );
296 }
297
298 bool TextInput::GetExceedEnabled() const
299 {
300   return GetImpl(*this).GetExceedEnabled();
301 }
302
303 void TextInput::SetSortModifier( float depthOffset )
304 {
305   GetImpl( *this ).SetSortModifier( depthOffset );
306 }
307
308 void TextInput::SetSnapshotModeEnabled( bool enable )
309 {
310   GetImpl( *this ).SetSnapshotModeEnabled( enable );
311 }
312
313 bool TextInput::IsSnapshotModeEnabled() const
314 {
315   return GetImpl( *this ).IsSnapshotModeEnabled();
316 }
317
318 void TextInput::SetScrollEnabled( bool enable )
319 {
320   GetImpl( *this ).SetScrollEnabled( enable );
321 }
322
323 bool TextInput::IsScrollEnabled() const
324 {
325   return GetImpl( *this ).IsScrollEnabled();
326 }
327
328 void TextInput::SetScrollPosition( const Vector2& position )
329 {
330   GetImpl( *this ).SetScrollPosition( position );
331 }
332
333 Vector2 TextInput::GetScrollPosition() const
334 {
335   return GetImpl( *this ).GetScrollPosition();
336 }
337
338 TextInput::InputSignalType& TextInput::InputStartedSignal()
339 {
340   return GetImpl(*this).InputStartedSignal();
341 }
342
343 TextInput::InputSignalType& TextInput::InputFinishedSignal()
344 {
345   return GetImpl(*this).InputFinishedSignal();
346 }
347
348 TextInput::InputSignalType& TextInput::CutAndPasteToolBarDisplayedSignal()
349 {
350   return GetImpl(*this).CutAndPasteToolBarDisplayedSignal();
351 }
352
353 TextInput::StyleChangedSignalType& TextInput::StyleChangedSignal()
354 {
355   return GetImpl(*this).StyleChangedSignal();
356 }
357
358 TextInput::TextModifiedSignalType& TextInput::TextModifiedSignal()
359 {
360   return GetImpl(*this).TextModifiedSignal();
361 }
362
363 TextInput::MaxInputCharactersReachedSignalType& TextInput::MaxInputCharactersReachedSignal()
364 {
365   return GetImpl(*this).MaxInputCharactersReachedSignal();
366 }
367
368 TextInput::InputTextExceedBoundariesSignalType& TextInput::InputTextExceedBoundariesSignal()
369 {
370   return GetImpl(*this).InputTextExceedBoundariesSignal();
371 }
372
373 void TextInput::SetMarkupProcessingEnabled( bool enable )
374 {
375   return GetImpl( *this ).SetMarkupProcessingEnabled( enable );
376 }
377
378 bool TextInput::IsMarkupProcessingEnabled() const
379 {
380   return GetImpl( *this ).IsMarkupProcessingEnabled();
381 }
382
383
384 TextInput::TextInput( Dali::Internal::CustomActor* internal )
385 : Control( internal )
386 {
387   VerifyCustomActorPointer<Internal::TextInput>(internal);
388 }
389
390 } // namespace Toolkit
391
392 } // namespace Dali