Framework for Font styles
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / internal / controls / text-controls / text-label-impl.cpp
index 8b1cb70..00ae80d 100644 (file)
 
 // EXTERNAL INCLUDES
 #include <dali/public-api/object/type-registry.h>
+#include <dali/public-api/object/type-registry-helper.h>
 #include <dali/integration-api/debug.h>
 
 // INTERNAL INCLUDES
+#include <dali-toolkit/public-api/text/rendering-backend.h>
 #include <dali-toolkit/internal/text/layouts/layout-engine.h>
 #include <dali-toolkit/internal/text/rendering/text-backend.h>
+#include <dali-toolkit/internal/styling/style-manager-impl.h>
 
 using Dali::Toolkit::Text::LayoutEngine;
 using Dali::Toolkit::Text::Backend;
 
-namespace
-{
-
-const unsigned int DEFAULT_RENDERING_BACKEND = 0;
-
-} // namespace
-
 namespace Dali
 {
 
@@ -47,6 +43,11 @@ namespace Internal
 
 namespace
 {
+  const unsigned int DEFAULT_RENDERING_BACKEND = Dali::Toolkit::Text::DEFAULT_RENDERING_BACKEND;
+}
+
+namespace
+{
 
 // Type registration
 BaseHandle Create()
@@ -57,7 +58,7 @@ BaseHandle Create()
 // Setup properties, signals and actions using the type-registry.
 DALI_TYPE_REGISTRATION_BEGIN( Toolkit::TextLabel, Toolkit::Control, Create );
 
-DALI_PROPERTY_REGISTRATION( TextLabel, "rendering-backend", INT,     RENDERING_BACKEND )
+DALI_PROPERTY_REGISTRATION( TextLabel, "rendering-backend", INTEGER, RENDERING_BACKEND )
 DALI_PROPERTY_REGISTRATION( TextLabel, "text",              STRING,  TEXT              )
 DALI_PROPERTY_REGISTRATION( TextLabel, "font-family",       STRING,  FONT_FAMILY       )
 DALI_PROPERTY_REGISTRATION( TextLabel, "font-style",        STRING,  FONT_STYLE        )
@@ -92,19 +93,19 @@ void TextLabel::SetProperty( BaseObject* object, Property::Index index, const Pr
     TextLabel& impl( GetImpl( label ) );
     switch( index )
     {
-      case Toolkit::TextLabel::PROPERTY_RENDERING_BACKEND:
+      case Toolkit::TextLabel::Property::RENDERING_BACKEND:
       {
-        unsigned int backend = value.Get< int >();
+        int backend = value.Get< int >();
 
         if( impl.mRenderingBackend != backend )
         {
-          impl.mRenderingBackend = static_cast< unsigned int >( backend );
+          impl.mRenderingBackend = backend;
           impl.mRenderer.Reset();
           impl.RequestTextRelayout();
         }
         break;
       }
-      case Toolkit::TextLabel::PROPERTY_TEXT:
+      case Toolkit::TextLabel::Property::TEXT:
       {
         if( impl.mController )
         {
@@ -113,7 +114,7 @@ void TextLabel::SetProperty( BaseObject* object, Property::Index index, const Pr
         }
         break;
       }
-      case Toolkit::TextLabel::PROPERTY_FONT_FAMILY:
+      case Toolkit::TextLabel::Property::FONT_FAMILY:
       {
         if( impl.mController )
         {
@@ -127,7 +128,7 @@ void TextLabel::SetProperty( BaseObject* object, Property::Index index, const Pr
         }
         break;
       }
-      case Toolkit::TextLabel::PROPERTY_FONT_STYLE:
+      case Toolkit::TextLabel::Property::FONT_STYLE:
       {
         if( impl.mController )
         {
@@ -141,7 +142,7 @@ void TextLabel::SetProperty( BaseObject* object, Property::Index index, const Pr
         }
         break;
       }
-      case Toolkit::TextLabel::PROPERTY_POINT_SIZE:
+      case Toolkit::TextLabel::Property::POINT_SIZE:
       {
         if( impl.mController )
         {
@@ -155,7 +156,7 @@ void TextLabel::SetProperty( BaseObject* object, Property::Index index, const Pr
         }
         break;
       }
-      case Toolkit::TextLabel::PROPERTY_MULTI_LINE:
+      case Toolkit::TextLabel::Property::MULTI_LINE:
       {
         if( impl.mController )
         {
@@ -185,12 +186,12 @@ Property::Value TextLabel::GetProperty( BaseObject* object, Property::Index inde
     TextLabel& impl( GetImpl( label ) );
     switch( index )
     {
-      case Toolkit::TextLabel::PROPERTY_RENDERING_BACKEND:
+      case Toolkit::TextLabel::Property::RENDERING_BACKEND:
       {
         value = impl.mRenderingBackend;
         break;
       }
-      case Toolkit::TextLabel::PROPERTY_TEXT:
+      case Toolkit::TextLabel::Property::TEXT:
       {
         if( impl.mController )
         {
@@ -198,11 +199,9 @@ Property::Value TextLabel::GetProperty( BaseObject* object, Property::Index inde
           impl.mController->GetText( text );
           value = text;
         }
-
-        DALI_LOG_WARNING( "UTF-8 text representation was discarded\n" );
         break;
       }
-      case Toolkit::TextLabel::PROPERTY_MULTI_LINE:
+      case Toolkit::TextLabel::Property::MULTI_LINE:
       {
         if( impl.mController )
         {
@@ -221,6 +220,11 @@ void TextLabel::OnInitialize()
   mController = Text::Controller::New( *this );
 }
 
+void TextLabel::OnStyleChange( Toolkit::StyleManager styleManager, StyleChange change )
+{
+  GetImpl( styleManager ).ApplyThemeStyle( Toolkit::Control( GetOwner() ) );
+}
+
 Vector3 TextLabel::GetNaturalSize()
 {
   return mController->GetNaturalSize();
@@ -267,7 +271,7 @@ void TextLabel::RequestTextRelayout()
 }
 
 TextLabel::TextLabel()
-: Control( ControlBehaviour( CONTROL_BEHAVIOUR_NONE ) ),
+: Control( ControlBehaviour( REQUIRES_STYLE_CHANGE_SIGNALS ) ),
   mRenderingBackend( DEFAULT_RENDERING_BACKEND )
 {
 }