2 * Copyright (c) 2015 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/internal/controls/text-controls/text-label-impl.h>
22 #include <dali/public-api/object/type-registry.h>
23 #include <dali/integration-api/debug.h>
36 const Property::Index TextLabel::PROPERTY_TEXT( Internal::TextLabel::TEXTLABEL_PROPERTY_START_INDEX );
47 return Toolkit::TextLabel::New();
50 TypeRegistration mType( typeid(Toolkit::TextLabel), typeid(Toolkit::Control), Create );
52 PropertyRegistration property1( mType, "text", Toolkit::TextLabel::PROPERTY_TEXT, Property::STRING, &TextLabel::SetProperty, &TextLabel::GetProperty );
56 Toolkit::TextLabel TextLabel::New()
58 // Create the implementation, temporarily owned by this handle on stack
59 IntrusivePtr< TextLabel > impl = new TextLabel();
61 // Pass ownership to CustomActor handle
62 Toolkit::TextLabel handle( *impl );
64 // Second-phase init of the implementation
65 // This can only be done after the CustomActor connection has been made...
71 void TextLabel::SetRenderer( Text::RendererPtr renderer )
76 void TextLabel::SetProperty( BaseObject* object, Property::Index index, const Property::Value& value )
78 Toolkit::TextLabel label = Toolkit::TextLabel::DownCast( Dali::BaseHandle( object ) );
82 TextLabel& labelImpl( GetImpl( label ) );
85 case Toolkit::TextLabel::PROPERTY_TEXT:
87 labelImpl.SetText( value.Get< std::string >() );
94 Property::Value TextLabel::GetProperty( BaseObject* object, Property::Index index )
96 Property::Value value;
98 Toolkit::TextLabel label = Toolkit::TextLabel::DownCast( Dali::BaseHandle( object ) );
104 case Toolkit::TextLabel::PROPERTY_TEXT:
106 DALI_LOG_WARNING( "UTF-8 text representation was discarded\n" );
115 void TextLabel::OnInitialize()
117 mController = Text::Controller::New();
120 void TextLabel::SetText( const std::string& text )
124 // The Controller updates the View for the renderer
125 mController->SetText( text );
129 Actor renderableActor = mRenderer->Render( mController->GetView() );
131 if( renderableActor )
133 Self().Add( renderableActor );
139 TextLabel::TextLabel()
140 : Control( ControlBehaviour( CONTROL_BEHAVIOUR_NONE ) )
144 TextLabel::~TextLabel()
148 } // namespace Internal
150 } // namespace Toolkit