2 * Copyright (c) 2014 Samsung Electronics Co., Ltd.
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
19 #include <dali-toolkit/public-api/controls/text-input/text-input.h>
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>
29 #include <dali-toolkit/public-api/controls/text-input/text-input.h>
30 #include <dali-toolkit/internal/controls/text-input/text-input-impl.h>
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";
45 TextInput::TextInput()
49 TextInput::TextInput(Internal::TextInput& implementation)
50 : Control(implementation)
54 TextInput::TextInput( const TextInput& textInput )
55 : Control( textInput )
59 TextInput& TextInput::operator=( const TextInput& textInput )
61 if( &textInput != this )
63 Control::operator=( textInput );
69 TextInput TextInput::New()
71 return Internal::TextInput::New();
74 TextInput TextInput::DownCast( BaseHandle actor )
76 return Control::DownCast<TextInput, Internal::TextInput>(actor);
79 TextInput::~TextInput()
83 std::string TextInput::GetText() const
85 return GetImpl(*this).GetText();
88 std::string TextInput::GetMarkupText() const
90 return GetImpl(*this).GetMarkupText();
93 void TextInput::SetMaxCharacterLength(std::size_t maxChars)
95 GetImpl(*this).SetMaxCharacterLength(maxChars);
98 void TextInput::SetNumberOfLinesLimit(std::size_t maxLines)
100 GetImpl(*this).SetNumberOfLinesLimit( maxLines );
103 std::size_t TextInput::GetNumberOfLinesLimit() const
105 return GetImpl(*this).GetNumberOfLinesLimit();
108 std::size_t TextInput::GetNumberOfCharacters() const
110 return GetImpl(*this).GetNumberOfCharacters();
113 void TextInput::SetPlaceholderText( const std::string& placeHolderText )
115 GetImpl(*this).SetPlaceholderText( placeHolderText );
118 std::string TextInput::GetPlaceholderText()
120 return GetImpl(*this).GetPlaceholderText();
123 void TextInput::SetInitialText(const std::string& initialText)
125 GetImpl(*this).SetInitialText(initialText);
128 void TextInput::SetEditable(bool editMode)
130 GetImpl(*this).SetEditable(editMode, false);
133 void TextInput::SetEditable(bool editMode, const Vector2& touchPoint)
135 GetImpl(*this).SetEditable(editMode, true, touchPoint);
138 bool TextInput::IsEditable() const
140 return GetImpl(*this).IsEditable();
143 void TextInput::SetEditOnTouch( bool editOnTouch )
145 GetImpl(*this).SetEditOnTouch( editOnTouch );
148 bool TextInput::IsEditOnTouch() const
150 return GetImpl(*this).IsEditOnTouch();
153 void TextInput::SetTextSelectable( bool textSelectable )
155 GetImpl(*this).SetTextSelectable( textSelectable );
158 bool TextInput::IsTextSelectable() const
160 return GetImpl(*this).IsTextSelectable();
163 bool TextInput::IsTextSelected() const
165 return GetImpl(*this).IsTextSelected();
168 void TextInput::SelectText(std::size_t start, std::size_t end)
170 GetImpl(*this).SelectText( start, end );
173 void TextInput::DeSelectText()
175 GetImpl(*this).DeSelectText();
178 void TextInput::SetGrabHandleImage( Image image )
180 GetImpl(*this).SetGrabHandleImage(image);
183 void TextInput::SetCursorImage(Dali::Image image, const Vector4& border )
185 GetImpl(*this).SetCursorImage(image, border );
188 Vector3 TextInput::GetSelectionHandleSize()
190 return GetImpl(*this).GetSelectionHandleSize();
193 void TextInput::SetRTLCursorImage(Dali::Image image, const Vector4& border )
195 GetImpl(*this).SetRTLCursorImage(image, border );
198 void TextInput::EnableGrabHandle(bool toggle)
200 GetImpl(*this).EnableGrabHandle( toggle );
203 bool TextInput::IsGrabHandleEnabled()
205 return GetImpl(*this).IsGrabHandleEnabled();
208 void TextInput::SetBoundingRectangle( const Rect<float>& boundingOriginAndSize )
210 GetImpl(*this).SetBoundingRectangle( boundingOriginAndSize );
213 const Rect<float> TextInput::GetBoundingRectangle() const
215 return GetImpl(*this).GetBoundingRectangle();
218 void TextInput::SetActiveStyle( const TextStyle& style, const TextStyle::Mask mask )
220 GetImpl(*this).SetActiveStyle(style,mask);
223 void TextInput::ApplyStyle( const TextStyle& style, const TextStyle::Mask mask )
225 GetImpl(*this).ApplyStyle( style, mask );
228 void TextInput::ApplyStyleToAll( const TextStyle& style, const TextStyle::Mask mask )
230 GetImpl(*this).ApplyStyleToAll( style, mask );
233 TextStyle TextInput::GetStyleAtCursor() const
235 return GetImpl(*this).GetStyleAtCursor();
238 void TextInput::SetTextAlignment( Toolkit::Alignment::Type align )
240 GetImpl(*this).SetTextAlignment(align);
243 void TextInput::SetTextLineJustification( Toolkit::TextView::LineJustification justification )
245 GetImpl(*this).SetTextLineJustification(justification);
248 void TextInput::SetFadeBoundary( const Toolkit::TextView::FadeBoundary& fadeBoundary )
250 GetImpl(*this).SetFadeBoundary( fadeBoundary );
253 const Toolkit::TextView::FadeBoundary& TextInput::GetFadeBoundary() const
255 return GetImpl(*this).GetFadeBoundary();
258 Alignment::Type TextInput::GetTextAlignment() const
260 return GetImpl(*this).GetTextAlignment();
263 void TextInput::SetMultilinePolicy( TextView::MultilinePolicy policy )
265 GetImpl(*this).SetMultilinePolicy(policy);
268 TextView::MultilinePolicy TextInput::GetMultilinePolicy() const
270 return GetImpl(*this).GetMultilinePolicy();
273 void TextInput::SetWidthExceedPolicy( TextView::ExceedPolicy policy )
275 GetImpl(*this).SetWidthExceedPolicy(policy);
278 TextView::ExceedPolicy TextInput::GetWidthExceedPolicy() const
280 return GetImpl(*this).GetWidthExceedPolicy();
283 void TextInput::SetHeightExceedPolicy( TextView::ExceedPolicy policy )
285 GetImpl(*this).SetHeightExceedPolicy(policy);
288 TextView::ExceedPolicy TextInput::GetHeightExceedPolicy() const
290 return GetImpl(*this).GetHeightExceedPolicy();
293 void TextInput::SetExceedEnabled( bool enable )
295 GetImpl(*this).SetExceedEnabled( enable );
298 bool TextInput::GetExceedEnabled() const
300 return GetImpl(*this).GetExceedEnabled();
303 void TextInput::SetSortModifier( float depthOffset )
305 GetImpl( *this ).SetSortModifier( depthOffset );
308 void TextInput::SetSnapshotModeEnabled( bool enable )
310 GetImpl( *this ).SetSnapshotModeEnabled( enable );
313 bool TextInput::IsSnapshotModeEnabled() const
315 return GetImpl( *this ).IsSnapshotModeEnabled();
318 void TextInput::SetScrollEnabled( bool enable )
320 GetImpl( *this ).SetScrollEnabled( enable );
323 bool TextInput::IsScrollEnabled() const
325 return GetImpl( *this ).IsScrollEnabled();
328 void TextInput::SetScrollPosition( const Vector2& position )
330 GetImpl( *this ).SetScrollPosition( position );
333 Vector2 TextInput::GetScrollPosition() const
335 return GetImpl( *this ).GetScrollPosition();
338 TextInput::InputSignalType& TextInput::InputStartedSignal()
340 return GetImpl(*this).InputStartedSignal();
343 TextInput::InputSignalType& TextInput::InputFinishedSignal()
345 return GetImpl(*this).InputFinishedSignal();
348 TextInput::InputSignalType& TextInput::CutAndPasteToolBarDisplayedSignal()
350 return GetImpl(*this).CutAndPasteToolBarDisplayedSignal();
353 TextInput::StyleChangedSignalType& TextInput::StyleChangedSignal()
355 return GetImpl(*this).StyleChangedSignal();
358 TextInput::TextModifiedSignalType& TextInput::TextModifiedSignal()
360 return GetImpl(*this).TextModifiedSignal();
363 TextInput::MaxInputCharactersReachedSignalType& TextInput::MaxInputCharactersReachedSignal()
365 return GetImpl(*this).MaxInputCharactersReachedSignal();
368 TextInput::InputTextExceedBoundariesSignalType& TextInput::InputTextExceedBoundariesSignal()
370 return GetImpl(*this).InputTextExceedBoundariesSignal();
373 void TextInput::SetMarkupProcessingEnabled( bool enable )
375 return GetImpl( *this ).SetMarkupProcessingEnabled( enable );
378 bool TextInput::IsMarkupProcessingEnabled() const
380 return GetImpl( *this ).IsMarkupProcessingEnabled();
384 TextInput::TextInput( Dali::Internal::CustomActor* internal )
385 : Control( internal )
387 VerifyCustomActorPointer<Internal::TextInput>(internal);
390 } // namespace Toolkit