Add a TextEditor property to limit input to maximum characters
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / devel-api / controls / text-controls / text-editor-devel.h
old mode 100644 (file)
new mode 100755 (executable)
index 50f6af5..fe8bc2e
@@ -2,7 +2,7 @@
 #define DALI_TOOLKIT_TEXT_EDITOR_DEVEL_H
 
 /*
- * Copyright (c) 2017 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2020 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.
@@ -17,6 +17,8 @@
  * limitations under the License.
  *
  */
+// EXTERNAL INCLUDES
+#include <dali/devel-api/adaptor-framework/input-method-context.h>
 
 // INTERNAL INCLUDES
 #include <dali-toolkit/public-api/controls/text-controls/text-editor.h>
@@ -34,7 +36,6 @@ namespace Property
 {
   enum Type
   {
-      RENDERING_BACKEND = Dali::Toolkit::TextEditor::Property::RENDERING_BACKEND,
       TEXT = Dali::Toolkit::TextEditor::Property::TEXT,
       TEXT_COLOR = Dali::Toolkit::TextEditor::Property::TEXT_COLOR,
       FONT_FAMILY = Dali::Toolkit::TextEditor::Property::FONT_FAMILY,
@@ -74,125 +75,88 @@ namespace Property
       INPUT_EMBOSS = Dali::Toolkit::TextEditor::Property::INPUT_EMBOSS,
       OUTLINE = Dali::Toolkit::TextEditor::Property::OUTLINE,
       INPUT_OUTLINE = Dali::Toolkit::TextEditor::Property::INPUT_OUTLINE,
+      SMOOTH_SCROLL = Dali::Toolkit::TextEditor::Property::SMOOTH_SCROLL,
+      SMOOTH_SCROLL_DURATION = Dali::Toolkit::TextEditor::Property::SMOOTH_SCROLL_DURATION,
+      ENABLE_SCROLL_BAR = Dali::Toolkit::TextEditor::Property::ENABLE_SCROLL_BAR,
+      SCROLL_BAR_SHOW_DURATION = Dali::Toolkit::TextEditor::Property::SCROLL_BAR_SHOW_DURATION,
+      SCROLL_BAR_FADE_DURATION = Dali::Toolkit::TextEditor::Property::SCROLL_BAR_FADE_DURATION,
+      PIXEL_SIZE = Dali::Toolkit::TextEditor::Property::PIXEL_SIZE,
+      LINE_COUNT = Dali::Toolkit::TextEditor::Property::LINE_COUNT,
+      ENABLE_SELECTION = Dali::Toolkit::TextEditor::Property::ENABLE_SELECTION,
+      PLACEHOLDER = Dali::Toolkit::TextEditor::Property::PLACEHOLDER,
+      LINE_WRAP_MODE = Dali::Toolkit::TextEditor::Property::LINE_WRAP_MODE,
 
       /**
-       * @brief name "smoothScroll", type bool
-       * @details Enable or disable the smooth scroll animation
-       */
-      SMOOTH_SCROLL = INPUT_OUTLINE + 1,
-
-      /**
-       * @brief name "smoothScrollDuration", type float
-       * @details Sets the duration of smooth scroll animation
-       */
-      SMOOTH_SCROLL_DURATION,
-
-      /**
-       * @brief name "enableScrollBar", type bool
-       * @details Enable or disable the scroll bar
-       */
-      ENABLE_SCROLL_BAR,
-
-      /**
-       * @brief name "scrollBarShowDuration", type float
-       * @details Sets the duration of scroll bar to show
-       */
-      SCROLL_BAR_SHOW_DURATION,
-
-      /**
-       * @brief name "scrollBarFadeDuration", type float
-       * @details Sets the duration of scroll bar to fade out
-       */
-      SCROLL_BAR_FADE_DURATION,
-
-      /**
-       * @brief The size of font in pixels.
-       *
-       * Conversion from Point size to Pixel size :
-       *  Pixel size = Point size * DPI / 72
-       * @details name "pixelSize", type float
+       * @brief The text to display when the TextEditor is empty and inactive.
+       * @details Name "placeholderText", type Property::STRING.
        */
-      PIXEL_SIZE,
+      PLACEHOLDER_TEXT,
 
       /**
-       * @brief The line count of text.
-       * @details name "lineCount", type int
-       * @note this property is read-only.
+       * @brief The placeholder-text color.
+       * @details Name "placeholderTextColor", type Property::VECTOR4.
        */
-      LINE_COUNT,
+      PLACEHOLDER_TEXT_COLOR,
 
       /**
-       * @brief The text to display when the TextEditor is empty and inactive.
-       * @details name "placeholderText", type string
+       * @brief Enables Text selection using Shift key.
+       * @details Name "enableShiftSelection", type Property::BOOLEAN.
        */
-      PLACEHOLDER_TEXT,
+      ENABLE_SHIFT_SELECTION,
 
       /**
-       * @brief The placeholder-text color.
-       * @details name "placeholderTextColor", type vector4
+       * @brief Enables the grab handles for text selection.
+       * @details Name "enableGrabHandle", type Property::BOOLEAN.
+       * @note The default value is true, which means the grab handles are enabled by default.
        */
-      PLACEHOLDER_TEXT_COLOR,
+      ENABLE_GRAB_HANDLE,
 
       /**
-       * @brief Enables Text selection, such as the cursor, handle, clipboard, and highlight color.
-       * @details name "enableSelection", type bool
+       * @brief Modifies the default text alignment to match the direction of the system language.
+       * @details Name "matchSystemLanguageDirection", type (Property::BOOLEAN), Read/Write
+       * @note The default value is false
        */
-      ENABLE_SELECTION,
+      MATCH_SYSTEM_LANGUAGE_DIRECTION,
 
       /**
-       * @brief Sets the placeholder : text, color, font family, font style, point size, and pixel size.
-       *
-       * @code
-       *   Property::Map propertyMap;
-       *   propertyMap["placeholderText"] = "Setting Placeholder Text";
-       *   propertyMap["placeholderTextFocused"] = "Setting Placeholder Text Focused";
-       *   propertyMap["placeholderColor"] = Color::RED;
-       *   propertyMap["placeholderFontFamily"] = "Arial";
-       *   propertyMap["placeholderPointSize"] = 12.0f;
-       *
-       *   Property::Map fontStyleMap;
-       *   fontStyleMap.Insert( "weight", "bold" );
-       *   fontStyleMap.Insert( "width", "condensed" );
-       *   fontStyleMap.Insert( "slant", "italic" );
-       *   propertyMap["placeholderFontStyle"] = fontStyleMap;
-       *
-       *   editor.SetProperty( DevelTextEditor::Property::PLACEHOLDER, propertyMap );
-       * @endcode
-       *
-       * @details name "placeholder", type MAP
+       * @brief The type or rendering e.g. bitmap-based.
+       * @details Name "renderingBackend", type Property::INTEGER.
        */
-      PLACEHOLDER,
+      RENDERING_BACKEND,
 
       /**
-       * @brief line wrap mode when the text lines over layout width.
-       * @details name "lineWrapMode", type string.
+       * @brief The maximum number of characters that can be inserted.
+       * @details Name "maxLength", type Property::INTEGER.
        */
-      LINE_WRAP_MODE
+      MAX_LENGTH,
   };
+
 } // namespace Property
 
-namespace Scroll
-{
-  enum Type
-  {
-    STARTED,   ///< Scrolling is started.
-    FINISHED   ///< Scrolling is finished.
-  };
-} // namespace Scroll
+/**
+ * @brief Return the input method context of TextEditor.
+ *
+ * @param[in] textEditor The instance of TextEditor.
+ * @return InputMethodContext instance.
+ */
+DALI_TOOLKIT_API InputMethodContext GetInputMethodContext( TextEditor textEditor );
 
-typedef Signal< void ( TextEditor, Scroll::Type ) > ScrollStateChangedSignalType;
+/**
+ * @brief Max Characters Exceed signal type.
+  */
+using MaxLengthReachedSignalType = Signal< void ( TextEditor ) >;
 
 /**
- * @brief This signal is emitted when TextEditor scrolling is started or finished.
+ * @brief This signal is emitted when inserted text exceeds the maximum character limit.
  *
  * A callback of the following type may be connected:
  * @code
- *   void YourCallbackName( ScrollState::Type type );
+ *   void YourCallbackName( TextEditor textEditor );
  * @endcode
- * type: Whether the scrolling is started or finished.
+ * @param[in] textEditor The instance of TextEditor.
  * @return The signal to connect to
  */
-DALI_IMPORT_API ScrollStateChangedSignalType& ScrollStateChangedSignal( TextEditor textEditor );
+DALI_TOOLKIT_API MaxLengthReachedSignalType& MaxLengthReachedSignal( TextEditor textEditor );
 
 } // namespace DevelTextEditor