X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=dali-toolkit%2Finternal%2Fcontrols%2Ftext-controls%2Ftext-field-impl.cpp;h=d6e763d085416956d13fe69cfaf6bddd70e103fc;hb=620ac79821b89142af1926f3577c7fa003f16ad3;hp=5074cdc2b9a5872a6efb385d4022da1e0c8e1a4c;hpb=9cbb34fdf7a5cdec7a7bf2feba20f948d6c0e6a3;p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git diff --git a/dali-toolkit/internal/controls/text-controls/text-field-impl.cpp b/dali-toolkit/internal/controls/text-controls/text-field-impl.cpp index 5074cdc..d6e763d 100644 --- a/dali-toolkit/internal/controls/text-controls/text-field-impl.cpp +++ b/dali-toolkit/internal/controls/text-controls/text-field-impl.cpp @@ -20,6 +20,7 @@ // EXTERNAL INCLUDES #include +#include #include #include #include @@ -85,6 +86,7 @@ DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "text", DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "font-family", STRING, FONT_FAMILY ) DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "font-style", STRING, FONT_STYLE ) DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "point-size", FLOAT, POINT_SIZE ) +DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "max-length", INTEGER, MAX_LENGTH ) DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "exceed-policy", INTEGER, EXCEED_POLICY ) DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "horizontal-alignment", STRING, HORIZONTAL_ALIGNMENT ) DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "vertical-alignment", STRING, VERTICAL_ALIGNMENT ) @@ -107,6 +109,8 @@ DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "selection-handle-pressed-image- DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "selection-highlight-color", STRING, SELECTION_HIGHLIGHT_COLOR ) DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "decoration-bounding-box", RECTANGLE, DECORATION_BOUNDING_BOX ) +DALI_SIGNAL_REGISTRATION( Toolkit, TextField, "max-length-reached", SIGNAL_MAX_LENGTH_REACHED ) + DALI_TYPE_REGISTRATION_END() } // namespace @@ -323,7 +327,7 @@ void TextField::SetProperty( BaseObject* object, Property::Index index, const Pr if( impl.mDecorator ) { - impl.mDecorator->SetGrabHandleImage( GRAB_HANDLE_IMAGE_RELEASED, image ); + impl.mDecorator->SetHandleImage( GRAB_HANDLE, HANDLE_IMAGE_RELEASED, image ); } break; } @@ -333,7 +337,7 @@ void TextField::SetProperty( BaseObject* object, Property::Index index, const Pr if( impl.mDecorator ) { - impl.mDecorator->SetGrabHandleImage( GRAB_HANDLE_IMAGE_PRESSED, image ); + impl.mDecorator->SetHandleImage( GRAB_HANDLE, HANDLE_IMAGE_PRESSED, image ); } break; } @@ -363,7 +367,7 @@ void TextField::SetProperty( BaseObject* object, Property::Index index, const Pr if( impl.mDecorator ) { - impl.mDecorator->SetLeftSelectionImage( SELECTION_HANDLE_RELEASED, image ); + impl.mDecorator->SetHandleImage( LEFT_SELECTION_HANDLE, HANDLE_IMAGE_RELEASED, image ); } break; } @@ -373,7 +377,7 @@ void TextField::SetProperty( BaseObject* object, Property::Index index, const Pr if( impl.mDecorator ) { - impl.mDecorator->SetRightSelectionImage( SELECTION_HANDLE_RELEASED, image ); + impl.mDecorator->SetHandleImage( RIGHT_SELECTION_HANDLE, HANDLE_IMAGE_RELEASED, image ); } break; } @@ -383,7 +387,7 @@ void TextField::SetProperty( BaseObject* object, Property::Index index, const Pr if( impl.mDecorator ) { - impl.mDecorator->SetLeftSelectionImage( SELECTION_HANDLE_PRESSED, image ); + impl.mDecorator->SetHandleImage( LEFT_SELECTION_HANDLE, HANDLE_IMAGE_PRESSED, image ); } break; } @@ -393,7 +397,7 @@ void TextField::SetProperty( BaseObject* object, Property::Index index, const Pr if( impl.mDecorator ) { - impl.mDecorator->SetLeftSelectionImage( SELECTION_HANDLE_PRESSED, image ); + impl.mDecorator->SetHandleImage( RIGHT_SELECTION_HANDLE, HANDLE_IMAGE_PRESSED, image ); } break; } @@ -415,6 +419,14 @@ void TextField::SetProperty( BaseObject* object, Property::Index index, const Pr } break; } + case Toolkit::TextField::Property::MAX_LENGTH: + { + if( impl.mController ) + { + impl.mController->SetMaximumNumberOfCharacters( value.Get< int >() ); + } + break; + } } // switch } // textfield } @@ -546,7 +558,7 @@ Property::Value TextField::GetProperty( BaseObject* object, Property::Index inde { if( impl.mDecorator ) { - ResourceImage image = ResourceImage::DownCast( impl.mDecorator->GetGrabHandleImage( GRAB_HANDLE_IMAGE_RELEASED ) ); + ResourceImage image = ResourceImage::DownCast( impl.mDecorator->GetHandleImage( GRAB_HANDLE, HANDLE_IMAGE_RELEASED ) ); if( image ) { value = image.GetUrl(); @@ -558,7 +570,7 @@ Property::Value TextField::GetProperty( BaseObject* object, Property::Index inde { if( impl.mDecorator ) { - ResourceImage image = ResourceImage::DownCast( impl.mDecorator->GetGrabHandleImage( GRAB_HANDLE_IMAGE_PRESSED ) ); + ResourceImage image = ResourceImage::DownCast( impl.mDecorator->GetHandleImage( GRAB_HANDLE, HANDLE_IMAGE_PRESSED ) ); if( image ) { value = image.GetUrl(); @@ -586,7 +598,7 @@ Property::Value TextField::GetProperty( BaseObject* object, Property::Index inde { if( impl.mDecorator ) { - ResourceImage image = ResourceImage::DownCast( impl.mDecorator->GetLeftSelectionImage( SELECTION_HANDLE_RELEASED ) ); + ResourceImage image = ResourceImage::DownCast( impl.mDecorator->GetHandleImage( LEFT_SELECTION_HANDLE, HANDLE_IMAGE_RELEASED ) ); if( image ) { value = image.GetUrl(); @@ -598,7 +610,7 @@ Property::Value TextField::GetProperty( BaseObject* object, Property::Index inde { if( impl.mDecorator ) { - ResourceImage image = ResourceImage::DownCast( impl.mDecorator->GetRightSelectionImage( SELECTION_HANDLE_RELEASED ) ); + ResourceImage image = ResourceImage::DownCast( impl.mDecorator->GetHandleImage( RIGHT_SELECTION_HANDLE, HANDLE_IMAGE_RELEASED ) ); if( image ) { value = image.GetUrl(); @@ -610,7 +622,7 @@ Property::Value TextField::GetProperty( BaseObject* object, Property::Index inde { if( impl.mDecorator ) { - ResourceImage image = ResourceImage::DownCast( impl.mDecorator->GetLeftSelectionImage( SELECTION_HANDLE_PRESSED ) ); + ResourceImage image = ResourceImage::DownCast( impl.mDecorator->GetHandleImage( LEFT_SELECTION_HANDLE, HANDLE_IMAGE_PRESSED ) ); if( image ) { value = image.GetUrl(); @@ -622,7 +634,7 @@ Property::Value TextField::GetProperty( BaseObject* object, Property::Index inde { if( impl.mDecorator ) { - ResourceImage image = ResourceImage::DownCast( impl.mDecorator->GetRightSelectionImage( SELECTION_HANDLE_PRESSED ) ); + ResourceImage image = ResourceImage::DownCast( impl.mDecorator->GetHandleImage( RIGHT_SELECTION_HANDLE, HANDLE_IMAGE_PRESSED ) ); if( image ) { value = image.GetUrl(); @@ -646,12 +658,45 @@ Property::Value TextField::GetProperty( BaseObject* object, Property::Index inde } break; } + case Toolkit::TextField::Property::MAX_LENGTH: + { + if( impl.mController ) + { + value = impl.mController->GetMaximumNumberOfCharacters(); + } + break; + } } //switch } return value; } +bool TextField::DoConnectSignal( BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor ) +{ + Dali::BaseHandle handle( object ); + + bool connected( true ); + Toolkit::TextField field = Toolkit::TextField::DownCast( handle ); + + if( 0 == strcmp( signalName.c_str(), SIGNAL_MAX_LENGTH_REACHED ) ) + { + field.MaxLengthReachedSignal().Connect( tracker, functor ); + } + else + { + // signalName does not match any signal + connected = false; + } + + return connected; +} + +Toolkit::TextField::MaxLengthReachedSignalType& TextField::MaxLengthReachedSignal() +{ + return mMaxLengthReachedSignal; +} + void TextField::OnInitialize() { Actor self = Self(); @@ -842,6 +887,12 @@ void TextField::RequestTextRelayout() RelayoutRequest(); } +void TextField::MaxLengthReached() +{ + Dali::Toolkit::TextField handle( GetOwner() ); + mMaxLengthReachedSignal.Emit( handle ); +} + void TextField::EnableClipping( bool clipping, const Vector2& size ) { if( clipping )