[NUI] Resolve many problems relative with BaseHandle
[platform/core/csapi/tizenfx.git] / src / Tizen.NUI / src / public / Common / StyleManager.cs
index ef0dd82..85dcd4c 100755 (executable)
@@ -30,7 +30,7 @@ namespace Tizen.NUI
     /// It provides the path to the application resource root folder, from there the filename can be specified along with any subfolders, for example, Images, Models, etc.<br />
     /// </summary>
     /// <since_tizen> 3 </since_tizen>
-    [Obsolete("Deprecated in API9, Will be removed in API11. Please use ThemeManager instead.")]
+    [Obsolete("Deprecated in API9, will be removed in API11. Use ThemeManager instead.")]
     public class StyleManager : BaseHandle
     {
         private static readonly StyleManager instance = StyleManager.Get();
@@ -42,13 +42,13 @@ namespace Tizen.NUI
         /// This can be initialized with StyleManager::Get().<br />
         /// </summary>
         /// <since_tizen> 3 </since_tizen>
-        [Obsolete("Deprecated in API9, Will be removed in API11. Please use ThemeManager instead.")]
-        public StyleManager() : this(Interop.StyleManager.NewStyleManager(), true)
+        [Obsolete("Deprecated in API9, will be removed in API11. Use ThemeManager instead.")]
+        public StyleManager() : this(Interop.StyleManager.NewStyleManager(), true, false)
         {
             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
         }
 
-        [UnmanagedFunctionPointer(CallingConvention.StdCall)]
+        [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
         private delegate void StyleChangedCallbackDelegate(IntPtr styleManager, Tizen.NUI.StyleChangeType styleChange);
 
         /// <summary>
@@ -58,7 +58,7 @@ namespace Tizen.NUI
         /// and the controls have been informed.<br />
         /// </summary>
         /// <since_tizen> 3 </since_tizen>
-        [Obsolete("Deprecated in API9, Will be removed in API11. Please use ThemeManager instead.")]
+        [Obsolete("Deprecated in API9, will be removed in API11. Use ThemeManager instead.")]
         public event EventHandler<StyleChangedEventArgs> StyleChanged
         {
             add
@@ -84,7 +84,7 @@ namespace Tizen.NUI
         /// Gets the singleton of the StyleManager object.
         /// </summary>
         /// <since_tizen> 5 </since_tizen>
-        [Obsolete("Deprecated in API9, Will be removed in API11. Please use ThemeManager instead.")]
+        [Obsolete("Deprecated in API9, will be removed in API11. Use ThemeManager instead.")]
         public static StyleManager Instance
         {
             get
@@ -98,10 +98,25 @@ namespace Tizen.NUI
         /// </summary>
         /// <returns>A handle to the StyleManager control.</returns>
         /// <since_tizen> 3 </since_tizen>
-        [Obsolete("Deprecated in API9, Will be removed in API11. Please use ThemeManager instead.")]
+        [Obsolete("Deprecated in API9, will be removed in API11. Use ThemeManager instead.")]
         public static StyleManager Get()
         {
-            StyleManager ret = new StyleManager(Interop.StyleManager.Get(), true);
+            global::System.IntPtr cPtr = Interop.StyleManager.Get();
+
+            StyleManager ret = Registry.GetManagedBaseHandleFromNativePtr(cPtr) as StyleManager;
+            if (ret != null)
+            {
+                object dummyObect = new object();
+
+                HandleRef CPtr = new HandleRef(dummyObect, cPtr);
+                Interop.BaseHandle.DeleteBaseHandle(CPtr);
+                CPtr = new HandleRef(null, global::System.IntPtr.Zero);
+            }
+            else
+            {
+                ret = new StyleManager(cPtr, true);
+            }
+
             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
             return ret;
         }
@@ -115,7 +130,7 @@ namespace Tizen.NUI
         /// </summary>
         /// <param name="themeFile">A relative path is specified for style theme.</param>
         /// <since_tizen> 3 </since_tizen>
-        [Obsolete("Deprecated in API9, Will be removed in API11. Please use ThemeManager instead.")]
+        [Obsolete("Deprecated in API9, will be removed in API11. Use ThemeManager instead.")]
         public void ApplyTheme(string themeFile)
         {
             Interop.StyleManager.ApplyTheme(SwigCPtr, themeFile);
@@ -126,7 +141,7 @@ namespace Tizen.NUI
         /// Applies the default Toolkit theme.
         /// </summary>
         /// <since_tizen> 3 </since_tizen>
-        [Obsolete("Deprecated in API9, Will be removed in API11. Please use ThemeManager instead.")]
+        [Obsolete("Deprecated in API9, will be removed in API11. Use ThemeManager instead.")]
         public void ApplyDefaultTheme()
         {
             Interop.StyleManager.ApplyDefaultTheme(SwigCPtr);
@@ -139,7 +154,7 @@ namespace Tizen.NUI
         /// <param name="key">The key of the constant.</param>
         /// <param name="value">The value of the constant.</param>
         /// <since_tizen> 3 </since_tizen>
-        [Obsolete("Deprecated in API9, Will be removed in API11. Please use ThemeManager instead.")]
+        [Obsolete("Deprecated in API9, will be removed in API11. Use ThemeManager instead.")]
         public void AddConstant(string key, PropertyValue value)
         {
             Interop.StyleManager.SetStyleConstant(SwigCPtr, key, PropertyValue.getCPtr(value));
@@ -153,7 +168,7 @@ namespace Tizen.NUI
         /// <param name="valueOut">The value of the constant if it exists.</param>
         /// <returns></returns>
         /// <since_tizen> 3 </since_tizen>
-        [Obsolete("Deprecated in API9, Will be removed in API11. Please use ThemeManager instead.")]
+        [Obsolete("Deprecated in API9, will be removed in API11. Use ThemeManager instead.")]
         public bool GetConstant(string key, PropertyValue valueOut)
         {
             bool ret = Interop.StyleManager.GetStyleConstant(SwigCPtr, key, PropertyValue.getCPtr(valueOut));
@@ -168,19 +183,55 @@ namespace Tizen.NUI
         /// <param name="jsonFileName">The name of the JSON style file to apply.</param>
         /// <param name="styleName">The name of the style within the JSON file to apply.</param>
         /// <since_tizen> 3 </since_tizen>
-        [Obsolete("Deprecated in API9, Will be removed in API11. Please use ThemeManager instead.")]
+        [Obsolete("Deprecated in API9, will be removed in API11. Use ThemeManager instead.")]
         public void ApplyStyle(View control, string jsonFileName, string styleName)
         {
             Interop.StyleManager.ApplyStyle(SwigCPtr, View.getCPtr(control), jsonFileName, styleName);
             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
         }
 
-        internal static global::System.Runtime.InteropServices.HandleRef getCPtr(StyleManager obj)
+        /// <summary>
+        /// The Type of BrokenImage
+        /// </summary>
+        internal enum BrokenImageType
         {
-            return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.SwigCPtr;
+            Small = 0,
+            Normal = 1,
+            Large = 2
         }
 
-        internal StyleManager(global::System.IntPtr cPtr, bool cMemoryOwn) : base(cPtr, cMemoryOwn)
+        /// <summary>
+        /// Sets the broken image url.
+        /// The broken image is the image to show when image loading is failed.
+        /// When the broken image and type are set in the Application,
+        /// the proper brokenImage is set automatically considering the size of view and the size of the brokenImage.
+        /// This Api is used from theme manager.
+        /// </summary>
+        /// <param name="type"> The type for brokenImage </param>
+        /// <param name="url"> The url for brokenImage </param>
+        internal void SetBrokenImageUrl(BrokenImageType type, string url)
+        {
+            Interop.StyleManager.SetBrokenImageUrl(SwigCPtr, (uint)type, url);
+            if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
+        }
+
+        /// <summary>
+        /// Gets the broken image url
+        /// </summary>
+        /// <param name="type"> The type for brokenImage</param>
+        /// <returns> the url for brokenImage </returns>
+        internal string GetBrokenImageUrl(BrokenImageType type)
+        {
+            string ret = Interop.StyleManager.GetBrokenImageUrl(SwigCPtr, (uint)type);
+            if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
+            return ret;
+        }
+
+        internal StyleManager(global::System.IntPtr cPtr, bool cMemoryOwn) : this(cPtr, cMemoryOwn, cMemoryOwn)
+        {
+        }
+
+        internal StyleManager(global::System.IntPtr cPtr, bool cMemoryOwn, bool cRegister) : base(cPtr, cMemoryOwn, cRegister)
         {
         }
 
@@ -210,7 +261,7 @@ namespace Tizen.NUI
         /// Style changed event arguments.
         /// </summary>
         /// <since_tizen> 3 </since_tizen>
-        [Obsolete("Deprecated in API9, Will be removed in API11. Please use ThemeManager instead.")]
+        [Obsolete("Deprecated in API9, will be removed in API11. Use ThemeManager instead.")]
         public class StyleChangedEventArgs : EventArgs
         {
             private StyleManager styleManager;
@@ -220,7 +271,7 @@ namespace Tizen.NUI
             /// StyleManager.
             /// </summary>
             /// <since_tizen> 3 </since_tizen>
-            [Obsolete("Deprecated in API9, Will be removed in API11. Please use ThemeManager instead.")]
+            [Obsolete("Deprecated in API9, will be removed in API11. Use ThemeManager instead.")]
             public StyleManager StyleManager
             {
                 get
@@ -238,7 +289,7 @@ namespace Tizen.NUI
             /// default font size changed or theme has changed).<br />
             /// </summary>
             /// <since_tizen> 3 </since_tizen>
-            [Obsolete("Deprecated in API9, Will be removed in API11. Please use ThemeManager instead.")]
+            [Obsolete("Deprecated in API9, will be removed in API11. Use ThemeManager instead.")]
             public StyleChangeType StyleChange
             {
                 get
@@ -251,5 +302,17 @@ namespace Tizen.NUI
                 }
             }
         }
+
+        internal static void SetBrokenImage(BrokenImageType type, string url)
+        {
+            Interop.StyleManager.SetBrokenImageUrl(Instance.SwigCPtr, (uint)type, url);
+            if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
+        }
+        internal static string GetBrokenImageURL(BrokenImageType type)
+        {
+            string ret = Interop.StyleManager.GetBrokenImageUrl(Instance.SwigCPtr, (uint)type);
+            if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
+            return ret;
+        }
     }
 }