X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=blobdiff_plain;f=dali-toolkit%2Finternal%2Ftext%2Ftext-controller.h;h=5cb079cc5c78e611379337ee7e16cf4082c851d6;hp=7b1e2ba18c020945145cabbb6b324a04d1b85bef;hb=3a23cbcd64ab5780928e4a141e497242c9989110;hpb=6b7c807d4a72e4fae1bbcc7aa64c024f5f84944d diff --git a/dali-toolkit/internal/text/text-controller.h b/dali-toolkit/internal/text/text-controller.h index 7b1e2ba..5cb079c 100644 --- a/dali-toolkit/internal/text/text-controller.h +++ b/dali-toolkit/internal/text/text-controller.h @@ -1,8 +1,8 @@ -#ifndef __DALI_TOOLKIT_TEXT_CONTROLLER_H__ -#define __DALI_TOOLKIT_TEXT_CONTROLLER_H__ +#ifndef DALI_TOOLKIT_TEXT_CONTROLLER_H +#define DALI_TOOLKIT_TEXT_CONTROLLER_H /* - * Copyright (c) 2016 Samsung Electronics Co., Ltd. + * Copyright (c) 2017 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -26,7 +26,10 @@ #include #include #include -#include +#include +#include +#include + namespace Dali { @@ -38,19 +41,12 @@ namespace Text { class Controller; +class ControlInterface; +class EditableControlInterface; class View; +class RenderingController; typedef IntrusivePtr ControllerPtr; -typedef Dali::Toolkit::Text::ControlInterface ControlInterface; - -/** - * @brief Different placeholder-text can be shown when the control is active/inactive. - */ -enum PlaceholderType -{ - PLACEHOLDER_TYPE_ACTIVE, - PLACEHOLDER_TYPE_INACTIVE, -}; /** * @brief A Text Controller is used by UI Controls which display text. @@ -63,9 +59,9 @@ enum PlaceholderType * * The text selection popup button callbacks are as well handled via the TextSelectionPopupCallbackInterface interface. */ -class Controller : public RefObject, public Decorator::ControllerInterface, public TextSelectionPopupCallbackInterface +class Controller : public RefObject, public Decorator::ControllerInterface, public TextSelectionPopupCallbackInterface, public HiddenText::Observer { -public: +public: // Enumerated types. /** * @brief Text related operations to be done in the relayout process. @@ -108,20 +104,74 @@ public: DONT_UPDATE_INPUT_STYLE }; + /** + * @brief Used to specify what has been updated after the Relayout() method has been called. + */ enum UpdateTextType { - NONE_UPDATED = 0x0, - MODEL_UPDATED = 0x1, - DECORATOR_UPDATED = 0x2 + NONE_UPDATED = 0x0, ///< Nothing has been updated. + MODEL_UPDATED = 0x1, ///< The text's model has been updated. + DECORATOR_UPDATED = 0x2 ///< The decoration has been updated. + }; + + /** + * @brief Different placeholder-text can be shown when the control is active/inactive. + */ + enum PlaceholderType + { + PLACEHOLDER_TYPE_ACTIVE, + PLACEHOLDER_TYPE_INACTIVE, + }; + + /** + * @brief Enumeration for Font Size Type. + */ + enum FontSizeType + { + POINT_SIZE, // The size of font in points. + PIXEL_SIZE // The size of font in pixels. + }; + + struct NoTextTap + { + enum Action + { + NO_ACTION, ///< Does no action if there is a tap on top of an area with no text. + HIGHLIGHT, ///< Highlights the nearest text (at the beginning or end of the text) and shows the text's selection popup. + SHOW_SELECTION_POPUP ///< Shows the text's selection popup. + }; }; +public: // Constructor. + + /** + * @brief Create a new instance of a Controller. + * + * @return A pointer to a new Controller. + */ + static ControllerPtr New(); + + /** + * @brief Create a new instance of a Controller. + * + * @param[in] controlInterface The control's interface. + * + * @return A pointer to a new Controller. + */ + static ControllerPtr New( ControlInterface* controlInterface ); + /** * @brief Create a new instance of a Controller. * - * @param[in] controlInterface An interface used to request a text relayout. + * @param[in] controlInterface The control's interface. + * @param[in] editableControlInterface The editable control's interface. + * * @return A pointer to a new Controller. */ - static ControllerPtr New( ControlInterface& controlInterface ); + static ControllerPtr New( ControlInterface* controlInterface, + EditableControlInterface* editableControlInterface ); + +public: // Configure the text controller. /** * @brief Called to enable text input. @@ -230,6 +280,189 @@ public: bool IsSmoothHandlePanEnabled() const; /** + * @brief Sets the maximum number of characters that can be inserted into the TextModel + * + * @param[in] maxCharacters maximum number of characters to be accepted + */ + void SetMaximumNumberOfCharacters( Length maxCharacters ); + + /** + * @brief Sets the maximum number of characters that can be inserted into the TextModel + * + * @param[in] maxCharacters maximum number of characters to be accepted + */ + int GetMaximumNumberOfCharacters(); + + /** + * @brief Called to enable/disable cursor blink. + * + * @note Only editable controls should calls this. + * @param[in] enabled Whether the cursor should blink or not. + */ + void SetEnableCursorBlink( bool enable ); + + /** + * @brief Query whether cursor blink is enabled. + * + * @return Whether the cursor should blink or not. + */ + bool GetEnableCursorBlink() const; + + /** + * @brief Whether to enable the multi-line layout. + * + * @param[in] enable \e true enables the multi-line (by default) + */ + void SetMultiLineEnabled( bool enable ); + + /** + * @return Whether the multi-line layout is enabled. + */ + bool IsMultiLineEnabled() const; + + /** + * @brief Sets the text's horizontal alignment. + * + * @param[in] alignment The horizontal alignment. + */ + void SetHorizontalAlignment( Layout::HorizontalAlignment alignment ); + + /** + * @copydoc ModelInterface::GetHorizontalAlignment() + */ + Layout::HorizontalAlignment GetHorizontalAlignment() const; + + /** + * @brief Sets the text's vertical alignment. + * + * @param[in] alignment The vertical alignment. + */ + void SetVerticalAlignment( Layout::VerticalAlignment alignment ); + + /** + * @copydoc ModelInterface::GetVerticalAlignment() + */ + Layout::VerticalAlignment GetVerticalAlignment() const; + + /** + * @brief Sets the text's wrap mode + * @param[in] text wrap mode The unit of wrapping + */ + void SetLineWrapMode( Layout::LineWrap::Mode textWarpMode ); + + /** + * @brief Retrieve text wrap mode previously set. + * @return text wrap mode + */ + Layout::LineWrap::Mode GetLineWrapMode() const; + + /** + * @brief Enable or disable the text elide. + * + * @param[in] enabled Whether to enable the text elide. + */ + void SetTextElideEnabled( bool enabled ); + + /** + * @copydoc ModelInterface::IsTextElideEnabled() + */ + bool IsTextElideEnabled() const; + + /** + * @brief Enable or disable the text selection. + * @param[in] enabled Whether to enable the text selection. + */ + void SetSelectionEnabled( bool enabled ); + + /** + * @brief Whether the text selection is enabled or not. + * @return True if the text selection is enabled + */ + bool IsSelectionEnabled() const; + + /** + * @brief Sets input type to password + * + * @note The string is displayed hidden character + * + * @param[in] passwordInput True if password input is enabled. + */ + void SetInputModePassword( bool passwordInput ); + + /** + * @brief Returns whether the input mode type is set as password. + * + * @return True if input mode type is password + */ + bool IsInputModePassword(); + + /** + * @brief Sets the action when there is a double tap event on top of a text area with no text. + * + * @param[in] action The action to do. + */ + void SetNoTextDoubleTapAction( NoTextTap::Action action ); + + /** + * @brief Retrieves the action when there is a double tap event on top of a text area with no text. + * + * @return The action to do. + */ + NoTextTap::Action GetNoTextDoubleTapAction() const; + + /** + * @briefSets the action when there is a long press event on top of a text area with no text. + * + * @param[in] action The action to do. + */ + void SetNoTextLongPressAction( NoTextTap::Action action ); + + /** + * @brief Retrieves the action when there is a long press event on top of a text area with no text. + * + * @return The action to do. + */ + NoTextTap::Action GetNoTextLongPressAction() const; + + /** + * @brief Query if Underline settings were provided by string or map + * @return bool true if set by string + */ + bool IsUnderlineSetByString(); + + /** + * Set method underline setting were set by + * @param[in] bool, true if set by string + */ + void UnderlineSetByString( bool setByString ); + + /** + * @brief Query if shadow settings were provided by string or map + * @return bool true if set by string + */ + bool IsShadowSetByString(); + + /** + * Set method shadow setting were set by + * @param[in] bool, true if set by string + */ + void ShadowSetByString( bool setByString ); + + /** + * @brief Query if font style settings were provided by string or map + * @return bool true if set by string + */ + bool IsFontStyleSetByString(); + + /** + * Set method font style setting were set by + * @param[in] bool, true if set by string + */ + void FontStyleSetByString( bool setByString ); + +public: // Update. + + /** * @brief Replaces any text previously set. * * @note This will be converted into UTF-32 when stored in the text model. @@ -245,22 +478,6 @@ public: void GetText( std::string& text ) const; /** - * @brief Remove a given number of characters - * - * When predictve text is used the pre-edit text is removed and inserted again with the new characters. - * The UpdateInputStyleType @type parameter if set to DONT_UPDATE_INPUT_STYLE avoids to update the input - * style when pre-edit text is removed. - * - * @param[in] cursorOffset Start position from the current cursor position to start deleting characters. - * @param[in] numberOfCharacters The number of characters to delete from the cursorOffset. - * @param[in] type Whether to update the input style. - * @return True if the remove was successful. - */ - bool RemoveText( int cursorOffset, - int numberOfCharacters, - UpdateInputStyleType type ); - - /** * @brief Replaces any placeholder text previously set. * * @param[in] type Different placeholder-text can be shown when the control is active/inactive. @@ -277,18 +494,12 @@ public: void GetPlaceholderText( PlaceholderType type, std::string& text ) const; /** - * @brief Sets the maximum number of characters that can be inserted into the TextModel - * - * @param[in] maxCharacters maximum number of characters to be accepted + * @ brief Update the text after a font change + * @param[in] newDefaultFont The new font to change to */ - void SetMaximumNumberOfCharacters( Length maxCharacters ); + void UpdateAfterFontChange( const std::string& newDefaultFont ); - /** - * @brief Sets the maximum number of characters that can be inserted into the TextModel - * - * @param[in] maxCharacters maximum number of characters to be accepted - */ - int GetMaximumNumberOfCharacters(); +public: // Default style & Input style /** * @brief Set the default font family. @@ -305,6 +516,19 @@ public: const std::string& GetDefaultFontFamily() const; /** + * @brief Sets the placeholder text font family. + * @param[in] placeholderTextFontFamily The placeholder text font family. + */ + void SetPlaceholderFontFamily( const std::string& placeholderTextFontFamily ); + + /** + * @brief Retrieves the placeholder text font family. + * + * @return The placeholder text font family + */ + const std::string& GetPlaceholderFontFamily() const; + + /** * @brief Sets the default font weight. * * @param[in] weight The font weight. @@ -324,6 +548,27 @@ public: FontWeight GetDefaultFontWeight() const; /** + * @brief Sets the placeholder text font weight. + * + * @param[in] weight The font weight + */ + void SetPlaceholderTextFontWeight( FontWeight weight ); + + /** + * @brief Whether the font's weight has been defined. + * + * @return True if the placeholder text font weight is defined + */ + bool IsPlaceholderTextFontWeightDefined() const; + + /** + * @brief Retrieves the placeholder text font weight. + * + * @return The placeholder text font weight + */ + FontWeight GetPlaceholderTextFontWeight() const; + + /** * @brief Sets the default font width. * * @param[in] width The font width. @@ -343,6 +588,27 @@ public: FontWidth GetDefaultFontWidth() const; /** + * @brief Sets the placeholder text font width. + * + * @param[in] width The font width + */ + void SetPlaceholderTextFontWidth( FontWidth width ); + + /** + * @brief Whether the font's width has been defined. + * + * @return True if the placeholder text font width is defined + */ + bool IsPlaceholderTextFontWidthDefined() const; + + /** + * @brief Retrieves the placeholder text font width. + * + * @return The placeholder text font width + */ + FontWidth GetPlaceholderTextFontWidth() const; + + /** * @brief Sets the default font slant. * * @param[in] slant The font slant. @@ -362,38 +628,69 @@ public: FontSlant GetDefaultFontSlant() const; /** - * @brief Set the default point size. + * @brief Sets the placeholder text font slant. + * + * @param[in] slant The font slant + */ + void SetPlaceholderTextFontSlant( FontSlant slant ); + + /** + * @brief Whether the font's slant has been defined. * - * @param[in] pointSize The default point size. + * @return True if the placeholder text font slant is defined */ - void SetDefaultPointSize( float pointSize ); + bool IsPlaceholderTextFontSlantDefined() const; + + /** + * @brief Retrieves the placeholder text font slant. + * + * @return The placeholder text font slant + */ + FontSlant GetPlaceholderTextFontSlant() const; + + /** + * @brief Set the default font size. + * + * @param[in] fontSize The default font size + * @param[in] type The font size type is point size or pixel size + */ + void SetDefaultFontSize( float fontSize, FontSizeType type ); /** * @brief Retrieve the default point size. * + * @param[in] type The font size type * @return The default point size. */ - float GetDefaultPointSize() const; + float GetDefaultFontSize( FontSizeType type ) const; /** - * @ brief Update the text after a font change - * @param[in] newDefaultFont The new font to change to + * @brief Sets the Placeholder text font size. + * @param[in] fontSize The placeholder text font size + * @param[in] type The font size type is point size or pixel size */ - void UpdateAfterFontChange( const std::string& newDefaultFont ); + void SetPlaceholderTextFontSize( float fontSize, FontSizeType type ); /** - * @brief Set the text color + * @brief Retrieves the Placeholder text font size. + * @param[in] type The font size type + * @return The placeholder font size + */ + float GetPlaceholderTextFontSize( FontSizeType type ) const; + + /** + * @brief Sets the text's default color. * - * @param textColor The text color + * @param color The default color. */ - void SetTextColor( const Vector4& textColor ); + void SetDefaultColor( const Vector4& color ); /** - * @brief Retrieve the text color + * @brief Retrieves the text's default color. * - * @return The text color + * @return The default color. */ - const Vector4& GetTextColor() const; + const Vector4& GetDefaultColor() const; /** * @brief Set the text color @@ -438,22 +735,6 @@ public: const Vector4& GetShadowColor() const; /** - * @brief Sets the shadow's properties string. - * - * @note The string is stored to be recovered. - * - * @param[in] shadowProperties The shadow's properties string. - */ - void SetDefaultShadowProperties( const std::string& shadowProperties ); - - /** - * @brief Retrieves the shadow's properties string. - * - * @return The shadow's properties string. - */ - const std::string& GetDefaultShadowProperties() const; - - /** * @brief Set the underline color. * * @param[in] color color of underline. @@ -496,22 +777,6 @@ public: float GetUnderlineHeight() const; /** - * @brief Sets the underline's properties string. - * - * @note The string is stored to be recovered. - * - * @param[in] underlineProperties The underline's properties string. - */ - void SetDefaultUnderlineProperties( const std::string& underlineProperties ); - - /** - * @brief Retrieves the underline's properties string. - * - * @return The underline's properties string. - */ - const std::string& GetDefaultUnderlineProperties() const; - - /** * @brief Sets the emboss's properties string. * * @note The string is stored to be recovered. @@ -735,26 +1000,27 @@ public: const std::string& GetInputOutlineProperties() const; /** - * @brief Called to enable/disable cursor blink. + * @brief Set the control's interface. * - * @note Only editable controls should calls this. - * @param[in] enabled Whether the cursor should blink or not. + * @param[in] controlInterface The control's interface. */ - void SetEnableCursorBlink( bool enable ); + void SetControlInterface( ControlInterface* controlInterface ); + +public: // Queries & retrieves. /** - * @brief Query whether cursor blink is enabled. + * @brief Return the layout engine. * - * @return Whether the cursor should blink or not. + * @return A reference to the layout engine. */ - bool GetEnableCursorBlink() const; + Layout::Engine& GetLayoutEngine(); /** - * @brief Query the current scroll position; the UI control is responsible for moving actors to this position. + * @brief Return a view of the text. * - * @return The scroll position. + * @return A reference to the view. */ - const Vector2& GetScrollPosition() const; + View& GetView(); /** * @copydoc Control::GetNaturalSize() @@ -767,119 +1033,95 @@ public: float GetHeightForWidth( float width ); /** - * @brief Triggers a relayout which updates View (if necessary). - * - * @note UI Controls are expected to minimize calls to this method e.g. call once after size negotiation. - * @param[in] size A the size of a bounding box to layout text within. - * - * @return Whether the text model or decorations were updated. + * @brief Retrieves the text's number of lines for a given width. + * @param[in] width The width of the text's area. + * @ return The number of lines. */ - UpdateTextType Relayout( const Size& size ); + int GetLineCount( float width ); /** - * @brief Process queued events which modify the model. - */ - void ProcessModifyEvents(); - - /** - * @brief Used to remove placeholder text. - */ - void ResetText(); - - /** - * @brief Used to reset the cursor position after setting a new text. + * @brief Retrieves the text's model. * - * @param[in] cursorIndex Where to place the cursor. + * @return A pointer to the text's model. */ - void ResetCursorPosition( CharacterIndex cursorIndex ); + const ModelInterface* const GetTextModel() const; /** - * @brief Used to reset the scroll position after setting a new text. + * @brief Used to get scrolled distance by user input + * + * @return Distance from last scroll offset to new scroll offset */ - void ResetScrollPosition(); + float GetScrollAmountByUserInput(); /** - * @brief Used to process an event queued from SetText() + * @brief Get latest scroll amount, control size and layout size + * + * This method is used to get information of control's scroll + * @param[out] scrollPosition The current scrolled position + * @param[out] controlHeight The size of a UI control + * @param[out] layoutHeight The size of a bounding box to layout text within. + * + * @return Whether the text scroll position is changed or not after last update. */ - void TextReplacedEvent(); + bool GetTextScrollInfo( float& scrollPosition, float& controlHeight, float& layoutHeight ); /** - * @brief Used to process an event queued from key events etc. + * @brief Used to set the hidden input option */ - void TextInsertedEvent(); + void SetHiddenInputOption( const Property::Map& options ); /** - * @brief Used to process an event queued from backspace key etc. + * @brief Used to get the hidden input option */ - void TextDeletedEvent(); + void GetHiddenInputOption( Property::Map& options ); /** - * @brief Lays-out the text. + * @brief Sets the Placeholder Properties. * - * GetNaturalSize(), GetHeightForWidth() and Relayout() calls this method. - * - * @param[in] size A the size of a bounding box to layout text within. - * @param[in] operations The layout operations which need to be done. - * @param[out] layoutSize The size of the laid-out text. + * @param[in] map The placeholder property map */ - bool DoRelayout( const Size& size, - OperationsMask operations, - Size& layoutSize ); + void SetPlaceholderProperty( const Property::Map& map ); /** - * @brief Whether to enable the multi-line layout. + * @brief Retrieves the Placeholder Property map. * - * @param[in] enable \e true enables the multi-line (by default) - */ - void SetMultiLineEnabled( bool enable ); - - /** - * @return Whether the multi-line layout is enabled. - */ - bool IsMultiLineEnabled() const; - - /** - * @copydoc Dali::Toolkit::Text::LayoutEngine::SetHorizontalAlignment() + * @param[out] map The property map */ - void SetHorizontalAlignment( LayoutEngine::HorizontalAlignment alignment ); + void GetPlaceholderProperty( Property::Map& map ); - /** - * @copydoc Dali::Toolkit::Text::LayoutEngine::GetHorizontalAlignment() - */ - LayoutEngine::HorizontalAlignment GetHorizontalAlignment() const; +public: // Relayout. /** - * @copydoc Dali::Toolkit::Text::LayoutEngine::SetVerticalAlignment() + * @brief Triggers a relayout which updates View (if necessary). + * + * @note UI Controls are expected to minimize calls to this method e.g. call once after size negotiation. + * @param[in] size A the size of a bounding box to layout text within. + * + * @return Whether the text model or decorations were updated. */ - void SetVerticalAlignment( LayoutEngine::VerticalAlignment alignment ); + UpdateTextType Relayout( const Size& size ); /** - * @copydoc Dali::Toolkit::Text::LayoutEngine::GetVerticalAlignment() + * @brief Request a relayout using the ControlInterface. */ - LayoutEngine::VerticalAlignment GetVerticalAlignment() const; + void RequestRelayout(); - /** - * @brief Calulates the vertical offset to align the text inside the bounding box. - * - * @param[in] size The size of the bounding box. - */ - void CalculateVerticalOffset( const Size& size ); +public: // Input style change signals. /** - * @brief Return the layout engine. - * - * @return A reference to the layout engine. + * @return Whether the queue of input style changed signals is empty. */ - LayoutEngine& GetLayoutEngine(); + bool IsInputStyleChangedSignalsQueueEmpty(); /** - * @brief Return a view of the text. + * @brief Process all pending input style changed signals. * - * @return A reference to the view. + * Calls the Text::ControlInterface::InputStyleChanged() method which is overriden by the + * text controls. Text controls may send signals to state the input style has changed. */ - View& GetView(); + void ProcessInputStyleChangedSignals(); - // Text-input Event Queuing +public: // Text-input Event Queuing. /** * @brief Called by editable UI controls when keyboard focus is gained. @@ -900,20 +1142,6 @@ public: bool KeyEvent( const Dali::KeyEvent& event ); /** - * @brief Called by editable UI controls when key events are received. - * - * @param[in] text The text to insert. - * @param[in] type Used to distinguish between regular key events and IMF events. - */ - void InsertText( const std::string& text, InsertType type ); - - /** - * @brief Checks if text is selected and if so removes it. - * @return true if text was removed - */ - bool RemoveSelectedText(); - - /** * @brief Called by editable UI controls when a tap gesture occurs. * @param[in] tapCount The number of taps. * @param[in] x The x position relative to the top-left of the parent control. @@ -939,17 +1167,6 @@ public: void LongPressEvent( Gesture::State state, float x, float y ); /** - * @brief Creates a selection event. - * - * It could be called from the TapEvent (double tap) or when the text selection popup's sellect all button is pressed. - * - * @param[in] x The x position relative to the top-left of the parent control. - * @param[in] y The y position relative to the top-left of the parent control. - * @param[in] selectAll Whether the whole text is selected. - */ - void SelectEvent( float x, float y, bool selectAll ); - - /** * @brief Event received from IMF manager * * @param[in] imfManager The IMF manager. @@ -959,16 +1176,12 @@ public: ImfManager::ImfCallbackData OnImfEvent( ImfManager& imfManager, const ImfManager::ImfEventData& imfEvent ); /** - * @brief Paste given string into Text model - * @param[in] stringToPaste this string will be inserted into the text model - */ - void PasteText( const std::string& stringToPaste ); - - /** * @brief Event from Clipboard notifying an Item has been selected for pasting */ void PasteClipboardItemEvent(); +protected: // Inherit from Text::Decorator::ControllerInterface. + /** * @copydoc Dali::Toolkit::Text::Decorator::ControllerInterface::GetTargetSize() */ @@ -984,19 +1197,112 @@ public: */ virtual void DecorationEvent( HandleType handle, HandleState state, float x, float y ); +protected: // Inherit from TextSelectionPopup::TextPopupButtonCallbackInterface. + /** * @copydoc Dali::Toolkit::TextSelectionPopup::TextPopupButtonCallbackInterface::TextPopupButtonTouched() */ virtual void TextPopupButtonTouched( Dali::Toolkit::TextSelectionPopup::Buttons button ); -protected: +protected: // Inherit from HiddenText. /** - * @brief A reference counted object may only be deleted by calling Unreference(). + * @brief Invoked from HiddenText when showing time of the last character was expired */ - virtual ~Controller(); + virtual void DisplayTimeExpired(); -private: +private: // Update. + + /** + * @brief Called by editable UI controls when key events are received. + * + * @param[in] text The text to insert. + * @param[in] type Used to distinguish between regular key events and IMF events. + */ + void InsertText( const std::string& text, InsertType type ); + + /** + * @brief Paste given string into Text model + * @param[in] stringToPaste this string will be inserted into the text model + */ + void PasteText( const std::string& stringToPaste ); + + /** + * @brief Remove a given number of characters + * + * When predictve text is used the pre-edit text is removed and inserted again with the new characters. + * The UpdateInputStyleType @type parameter if set to DONT_UPDATE_INPUT_STYLE avoids to update the input + * style when pre-edit text is removed. + * + * @param[in] cursorOffset Start position from the current cursor position to start deleting characters. + * @param[in] numberOfCharacters The number of characters to delete from the cursorOffset. + * @param[in] type Whether to update the input style. + * @return True if the remove was successful. + */ + bool RemoveText( int cursorOffset, + int numberOfCharacters, + UpdateInputStyleType type ); + + /** + * @brief Checks if text is selected and if so removes it. + * @return true if text was removed + */ + bool RemoveSelectedText(); + +private: // Relayout. + + /** + * @brief Lays-out the text. + * + * GetNaturalSize(), GetHeightForWidth() and Relayout() calls this method. + * + * @param[in] size A the size of a bounding box to layout text within. + * @param[in] operations The layout operations which need to be done. + * @param[out] layoutSize The size of the laid-out text. + */ + bool DoRelayout( const Size& size, + OperationsMask operations, + Size& layoutSize ); + + /** + * @brief Calulates the vertical offset to align the text inside the bounding box. + * + * @param[in] size The size of the bounding box. + */ + void CalculateVerticalOffset( const Size& size ); + +private: // Events. + + /** + * @brief Process queued events which modify the model. + */ + void ProcessModifyEvents(); + + /** + * @brief Used to process an event queued from SetText() + */ + void TextReplacedEvent(); + + /** + * @brief Used to process an event queued from key events etc. + */ + void TextInsertedEvent(); + + /** + * @brief Used to process an event queued from backspace key etc. + */ + void TextDeletedEvent(); + + /** + * @brief Creates a selection event. + * + * It could be called from the TapEvent (double tap) or when the text selection popup's sellect all button is pressed. + * + * @param[in] x The x position relative to the top-left of the parent control. + * @param[in] y The y position relative to the top-left of the parent control. + * @param[in] selectAll Whether the whole text is selected. + */ + void SelectEvent( float x, float y, bool selectAll ); /** * @brief Helper to KeyEvent() to handle the backspace case. @@ -1005,8 +1311,15 @@ private: */ bool BackspaceKeyEvent(); +private: // Helpers. + /** - * @brief Helper to clear font-specific data. + * @brief Used to remove the text included the placeholder text. + */ + void ResetText(); + + /** + * @brief Helper to show the place holder text.. */ void ShowPlaceholderText(); @@ -1021,9 +1334,34 @@ private: void ClearStyleData(); /** + * @brief Used to reset the cursor position after setting a new text. + * + * @param[in] cursorIndex Where to place the cursor. + */ + void ResetCursorPosition( CharacterIndex cursorIndex ); + + /** + * @brief Used to reset the scroll position after setting a new text. + */ + void ResetScrollPosition(); + +private: // Private contructors & copy operator. + + /** + * @brief Private constructor. + */ + Controller(); + + /** * @brief Private constructor. */ - Controller( ControlInterface& controlInterface ); + Controller( ControlInterface* controlInterface ); + + /** + * @brief Private constructor. + */ + Controller( ControlInterface* controlInterface, + EditableControlInterface* editableControlInterface ); // Undefined Controller( const Controller& handle ); @@ -1031,6 +1369,13 @@ private: // Undefined Controller& operator=( const Controller& handle ); +protected: // Destructor. + + /** + * @brief A reference counted object may only be deleted by calling Unreference(). + */ + virtual ~Controller(); + private: struct Impl; @@ -1043,4 +1388,4 @@ private: } // namespace Dali -#endif // __DALI_TOOLKIT_TEXT_CONTROLLER_H__ +#endif // DALI_TOOLKIT_TEXT_CONTROLLER_H