[ACR-564] deprecate unused API
[platform/core/csapi/tizenfx.git] / src / ElmSharp / ElmSharp / ItemObject.cs
index f009396..bd98ecb 100644 (file)
@@ -20,8 +20,10 @@ using System.Collections.Generic;
 namespace ElmSharp
 {
     /// <summary>
-    /// The ItemObject is used to manage item object
+    /// The ItemObject is used to manage the item object.
     /// </summary>
+    /// <since_tizen> preview </since_tizen>
+    [Obsolete("This has been deprecated in API12")]
     public class ItemObject
     {
         private static Dictionary<int, ItemObject> s_IdToItemTable = new Dictionary<int, ItemObject>();
@@ -35,14 +37,40 @@ namespace ElmSharp
         EvasObject _trackObject = null;
 
         /// <summary>
-        /// Creates and initializes a new instance of ItemObject class.
+        /// Gets the parent object for ItemObject.
+        /// </summary>
+        /// <since_tizen> preview </since_tizen>
+        [Obsolete("This has been deprecated in API12")]
+        public EvasObject Parent { get; internal set; }
+
+        /// <summary>
+        /// Creates and initializes a new instance of the ItemObject class.
         /// </summary>
         /// <param name="handle">IntPtr</param>
+        /// <since_tizen> preview </since_tizen>
+        [Obsolete("This has been deprecated in API12")]
         protected ItemObject(IntPtr handle)
         {
             _deleteCallback = DeleteCallbackHandler;
             Id = GetNextId();
             s_IdToItemTable[Id] = this;
+            Parent = null;
+            Handle = handle;
+        }
+
+        /// <summary>
+        /// Creates and initializes a new instance of the ItemObject class with parent object.
+        /// </summary>
+        /// <param name="handle">IntPtr</param>
+        /// <param name="parent">Parent EvasObject</param>
+        /// <since_tizen> preview </since_tizen>
+        [Obsolete("This has been deprecated in API12")]
+        protected ItemObject(IntPtr handle, EvasObject parent)
+        {
+            _deleteCallback = DeleteCallbackHandler;
+            Id = GetNextId();
+            s_IdToItemTable[Id] = this;
+            Parent = parent;
             Handle = handle;
         }
 
@@ -56,13 +84,17 @@ namespace ElmSharp
         //}
 
         /// <summary>
-        /// Gets the id of item object
+        /// Gets the ID of the item object.
         /// </summary>
+        /// <since_tizen> preview </since_tizen>
+        [Obsolete("This has been deprecated in API12")]
         public int Id { get; private set; }
 
         /// <summary>
-        /// Sets or gets whether the item object is enabled
+        /// Sets or gets whether the item object is enabled.
         /// </summary>
+        /// <since_tizen> preview </since_tizen>
+        [Obsolete("This has been deprecated in API12")]
         public bool IsEnabled
         {
             get { return !Interop.Elementary.elm_object_item_disabled_get(Handle); }
@@ -70,18 +102,39 @@ namespace ElmSharp
         }
 
         /// <summary>
-        /// Gets track object of the item.
+        /// Gets the track object of the item.
         /// </summary>
+        /// <since_tizen> preview </since_tizen>
+        [Obsolete("This has been deprecated in API12")]
         public EvasObject TrackObject
         {
             get
             {
-                if (_trackObject == null)
+                if (_trackObject == null || Interop.Elementary.elm_object_item_track_get(Handle) == 0)
+                {
                     _trackObject = new ItemEvasObject(Handle);
+                }
                 return _trackObject;
             }
         }
 
+        /// <summary>
+        /// Sets or gets the style of the item.
+        /// </summary>
+        /// <since_tizen> preview </since_tizen>
+        [Obsolete("This has been deprecated in API12")]
+        public virtual string Style
+        {
+            get
+            {
+                return Interop.Elementary.elm_object_item_style_get(Handle);
+            }
+            set
+            {
+                Interop.Elementary.elm_object_item_style_set(Handle, value);
+            }
+        }
+
         internal IntPtr Handle
         {
             get
@@ -100,17 +153,25 @@ namespace ElmSharp
                 _handle = value;
                 SetDeleteCallback();
                 s_HandleToItemTable[Handle] = this;
+                if (_handle != IntPtr.Zero)
+                {
+                    Elementary.SendItemObjectRealized(this);
+                }
             }
         }
 
         /// <summary>
-        /// Deleted will be triggered when the item object is deleted
+        /// Deleted will be triggered when the item object is deleted.
         /// </summary>
+        /// <since_tizen> preview </since_tizen>
+        [Obsolete("This has been deprecated in API12")]
         public event EventHandler Deleted;
 
         /// <summary>
-        /// Delete the item object
+        /// Deletes the item object.
         /// </summary>
+        /// <since_tizen> preview </since_tizen>
+        [Obsolete("This has been deprecated in API12")]
         public void Delete()
         {
             Interop.Elementary.elm_object_item_del(Handle);
@@ -118,21 +179,25 @@ namespace ElmSharp
         }
 
         /// <summary>
-        /// Set a content of an object item and delete old content
+        /// Sets a content of an object item and deletes the old content.
         /// </summary>
-        /// <param name="part">The content part name (null for the default content)</param>
-        /// <param name="content">The content of the object item</param>
+        /// <param name="part">The content part name (null for the default content).</param>
+        /// <param name="content">The content of the object item.</param>
+        /// <since_tizen> preview </since_tizen>
+        [Obsolete("This has been deprecated in API12")]
         public void SetPartContent(string part, EvasObject content)
         {
             SetPartContent(part, content, false);
         }
 
-        /// <summary>
-        /// Set a content of an object item
+        /// <summary>.
+        /// Sets a content of the object item.
         /// </summary>
         /// <param name="part">The content part name (null for the default content)</param>
-        /// <param name="content">The content of the object item</param>
-        /// <param name="preserveOldContent">judge whether delete old content</param>
+        /// <param name="content">The content of the object item.</param>
+        /// <param name="preserveOldContent">Judge whether to delete the old content.</param>
+        /// <since_tizen> preview </since_tizen>
+        [Obsolete("This has been deprecated in API12")]
         public void SetPartContent(string part, EvasObject content, bool preserveOldContent)
         {
             IntPtr oldContent = Interop.Elementary.elm_object_item_part_content_unset(Handle, part);
@@ -145,30 +210,36 @@ namespace ElmSharp
         }
 
         /// <summary>
-        /// Set a label of an object item
+        /// Sets the label of the object item.
         /// </summary>
-        /// <param name="part">The text part name (null for the default label)</param>
-        /// <param name="text">Text of the label</param>
+        /// <param name="part">The text part name (null for the default label).</param>
+        /// <param name="text">Text of the label.</param>
+        /// <since_tizen> preview </since_tizen>
+        [Obsolete("This has been deprecated in API12")]
         public void SetPartText(string part, string text)
         {
             Interop.Elementary.elm_object_item_part_text_set(Handle, part, text);
         }
 
         /// <summary>
-        /// Gets a label of an object item
+        /// Gets the label of the object item.
         /// </summary>
-        /// <param name="part">The text part name (null for the default label)</param>
+        /// <param name="part">The text part name (null for the default label).</param>
         /// <returns></returns>
+        /// <since_tizen> preview </since_tizen>
+        [Obsolete("This has been deprecated in API12")]
         public string GetPartText(string part)
         {
             return Interop.Elementary.elm_object_item_part_text_get(Handle, part);
         }
 
         /// <summary>
-        /// Sets color of an object item
+        /// Sets the color of the object item.
         /// </summary>
-        /// <param name="part">The text part name (null for the default label)</param>
-        /// <param name="color">the color</param>
+        /// <param name="part">The text part name (null for the default label).</param>
+        /// <param name="color">The color.</param>
+        /// <since_tizen> preview </since_tizen>
+        [Obsolete("This has been deprecated in API12")]
         public void SetPartColor(string part, Color color)
         {
             Interop.Elementary.elm_object_item_color_class_color_set(Handle, part, color.R * color.A / 255,
@@ -178,10 +249,12 @@ namespace ElmSharp
         }
 
         /// <summary>
-        /// Gets color of an object item
+        /// Gets the color of the object item.
         /// </summary>
-        /// <param name="part">The text part name (null for the default label)</param>
-        /// <returns>the color of object item</returns>
+        /// <param name="part">The text part name (null for the default label).</param>
+        /// <returns>The color of an object item.</returns>
+        /// <since_tizen> preview </since_tizen>
+        [Obsolete("This has been deprecated in API12")]
         public Color GetPartColor(string part)
         {
             int r, g, b, a;
@@ -190,20 +263,24 @@ namespace ElmSharp
         }
 
         /// <summary>
-        /// Deletes color of an object item
+        /// Deletes the color of the object item.
         /// </summary>
-        /// <param name="part">The text part name</param>
+        /// <param name="part">The text part name.</param>
+        /// <since_tizen> preview </since_tizen>
+        [Obsolete("This has been deprecated in API12")]
         public void DeletePartColor(string part)
         {
             Interop.Elementary.elm_object_item_color_class_del(Handle, part);
         }
 
         /// <summary>
-        /// Add a function for a signal emitted by object item edje.
+        /// Adds a function for a signal emitted by the object item edje.
         /// </summary>
         /// <param name="emission">The signal's name.</param>
         /// <param name="source">The signal's source.</param>
         /// <param name="func">The function to be executed when the signal is emitted.</param>
+        /// <since_tizen> preview </since_tizen>
+        [Obsolete("This has been deprecated in API12")]
         public void AddSignalHandler(string emission, string source, Func<string, string, bool> func)
         {
             if (emission != null && source != null && func != null)
@@ -221,11 +298,13 @@ namespace ElmSharp
         }
 
         /// <summary>
-        /// Remove a signal-triggered function from a object item edje object.
+        /// Removes a signal-triggered function from the object item edje object.
         /// </summary>
         /// <param name="emission">The signal's name.</param>
         /// <param name="source">The signal's source.</param>
         /// <param name="func">The function to be executed when the signal is emitted.</param>
+        /// <since_tizen> preview </since_tizen>
+        [Obsolete("This has been deprecated in API12")]
         public void RemoveSignalHandler(string emission, string source, Func<string, string, bool> func)
         {
             if (emission != null && source != null && func != null)
@@ -248,15 +327,19 @@ namespace ElmSharp
         /// </summary>
         /// <param name="emission">The signal's name.</param>
         /// <param name="source">The signal's source.</param>
+        /// <since_tizen> preview </since_tizen>
+        [Obsolete("This has been deprecated in API12")]
         public void EmitSignal(string emission, string source)
         {
             Interop.Elementary.elm_object_item_signal_emit(Handle, emission, source);
         }
 
         /// <summary>
-        /// Gets the handle of object item
+        /// Gets the handle of the object item.
         /// </summary>
         /// <param name="obj">ItemObject</param>
+        /// <since_tizen> preview </since_tizen>
+        [Obsolete("This has been deprecated in API12")]
         public static implicit operator IntPtr(ItemObject obj)
         {
             if (obj == null)
@@ -265,8 +348,10 @@ namespace ElmSharp
         }
 
         /// <summary>
-        /// OnInvalidate of object item
+        /// OnInvalidate of the object item.
         /// </summary>
+        /// <since_tizen> preview </since_tizen>
+        [Obsolete("This has been deprecated in API12")]
         protected virtual void OnInvalidate() { }
 
         internal static ItemObject GetItemById(int id)
@@ -286,6 +371,7 @@ namespace ElmSharp
         void DeleteCallbackHandler(IntPtr data, IntPtr obj, IntPtr info)
         {
             Deleted?.Invoke(this, EventArgs.Empty);
+            Parent = null;
             OnInvalidate();
             if (s_IdToItemTable.ContainsKey(Id))
             {
@@ -315,7 +401,7 @@ namespace ElmSharp
             return s_globalId++;
         }
 
-        class SignalData
+        class SignalData : IEquatable<SignalData>
         {
             public string Emission { get; set; }
             public string Source { get; set; }
@@ -328,14 +414,18 @@ namespace ElmSharp
                 Func = func;
             }
 
-            public override bool Equals(object obj)
+            public override bool Equals(object other)
             {
-                SignalData s = obj as SignalData;
-                if (s == null)
+                return Equals(other as SignalData);
+            }
+
+            public bool Equals(SignalData other)
+            {
+                if (other == null)
                 {
                     return false;
                 }
-                return (Emission == s.Emission) && (Source == s.Source) && (Func == s.Func);
+                return (Emission == other.Emission) && (Source == other.Source) && (Func == other.Func);
             }
 
             public override int GetHashCode()
@@ -349,17 +439,20 @@ namespace ElmSharp
 
         class ItemEvasObject : EvasObject
         {
-            IntPtr _parent = IntPtr.Zero;
+            IntPtr _trackHandle = IntPtr.Zero;
 
-            public ItemEvasObject(IntPtr parent) : base()
+            public ItemEvasObject(IntPtr parent)
             {
-                _parent = parent;
-                Realize(null);
+                _trackHandle = Interop.Elementary.elm_object_item_track(parent);
+                if (_trackHandle != IntPtr.Zero)
+                {
+                    Realize(null);
+                }
             }
 
             protected override IntPtr CreateHandle(EvasObject parent)
             {
-                return Interop.Elementary.elm_object_item_track(_parent);
+                return _trackHandle;
             }
         }
     }