1.[NUI 276] c# nui visual high level class refactorying.
[platform/core/csapi/tizenfx.git] / src / Tizen.NUI / src / public / StyleManager.cs
1 //------------------------------------------------------------------------------
2 // <auto-generated />
3 //
4 // This file was automatically generated by SWIG (http://www.swig.org).
5 // Version 3.0.9
6 //
7 // Do not make changes to this file unless you know what you are doing--modify
8 // the SWIG interface file instead.
9 //------------------------------------------------------------------------------
10
11 namespace Tizen.NUI
12 {
13
14     using System;
15     using System.Runtime.InteropServices;
16
17     /// <summary>
18     /// StyleManager informs applications of system theme change, and supports application theme change at runtime.<br>
19     /// Applies various styles to Controls using the properties system.<br>
20     /// On theme change, it automatically updates all controls, then raises a event to inform the application.<br>
21     /// If the application wants to customize the theme, RequestThemeChange needs to be called.<br>
22     /// It provides the path to the  application resource root folder, from there the filename can an be specified along with any sub folders, e.g Images, Models etc.<br>
23     /// </summary>
24     public class StyleManager : BaseHandle
25     {
26         private global::System.Runtime.InteropServices.HandleRef swigCPtr;
27
28         internal StyleManager(global::System.IntPtr cPtr, bool cMemoryOwn) : base(NDalicPINVOKE.StyleManager_SWIGUpcast(cPtr), cMemoryOwn)
29         {
30             swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
31         }
32
33         internal static global::System.Runtime.InteropServices.HandleRef getCPtr(StyleManager obj)
34         {
35             return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
36         }
37
38         ~StyleManager()
39         {
40             DisposeQueue.Instance.Add(this);
41         }
42
43         /// <summary>
44         /// Dispose
45         /// </summary>
46         public override void Dispose()
47         {
48             if (!Stage.IsInstalled())
49             {
50                 DisposeQueue.Instance.Add(this);
51                 return;
52             }
53
54             lock (this)
55             {
56                 if (swigCPtr.Handle != global::System.IntPtr.Zero)
57                 {
58                     if (swigCMemOwn)
59                     {
60                         swigCMemOwn = false;
61                         NDalicPINVOKE.delete_StyleManager(swigCPtr);
62                     }
63                     swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
64                 }
65                 global::System.GC.SuppressFinalize(this);
66                 base.Dispose();
67             }
68         }
69
70         /// <summary>
71         /// Style changed event arguments
72         /// </summary>
73         public class StyleChangedEventArgs : EventArgs
74         {
75             private StyleManager _styleManager;
76             private StyleChangeType _styleChange;
77
78             /// <summary>
79             /// StyleManager.
80             /// </summary>
81             public StyleManager StyleManager
82             {
83                 get
84                 {
85                     return _styleManager;
86                 }
87                 set
88                 {
89                     _styleManager = value;
90                 }
91             }
92
93             /// <summary>
94             /// StyleChange - contains Style change information (default font changed or
95             /// default font size changed or theme has changed).<br>
96             /// </summary>
97             public StyleChangeType StyleChange
98             {
99                 get
100                 {
101                     return _styleChange;
102                 }
103                 set
104                 {
105                     _styleChange = value;
106                 }
107             }
108
109         }
110
111         [UnmanagedFunctionPointer(CallingConvention.StdCall)]
112         private delegate void StyleChangedCallbackDelegate(IntPtr styleManager, Tizen.NUI.StyleChangeType styleChange);
113         private EventHandler<StyleChangedEventArgs> _styleManagerStyleChangedEventHandler;
114         private StyleChangedCallbackDelegate _styleManagerStyleChangedCallbackDelegate;
115
116         /// <summary>
117         /// Event for StyleChanged signal which can be used to subscribe/unsubscribe the
118         /// event handler provided by the user.<br>
119         /// StyleChanged signal is is emitted after the style (e.g. theme/font change) has changed
120         /// and the controls have been informed.<br>
121         /// </summary>
122         public event EventHandler<StyleChangedEventArgs> StyleChanged
123         {
124             add
125             {
126                 if (_styleManagerStyleChangedEventHandler == null)
127                 {
128                     _styleManagerStyleChangedCallbackDelegate = (OnStyleChanged);
129                     StyleChangedSignal().Connect(_styleManagerStyleChangedCallbackDelegate);
130                 }
131                 _styleManagerStyleChangedEventHandler += value;
132             }
133             remove
134             {
135                 _styleManagerStyleChangedEventHandler -= value;
136                 if (_styleManagerStyleChangedEventHandler == null && StyleChangedSignal().Empty() == false)
137                 {
138                     StyleChangedSignal().Disconnect(_styleManagerStyleChangedCallbackDelegate);
139                 }
140             }
141         }
142
143         // Callback for StyleManager StyleChangedsignal
144         private void OnStyleChanged(IntPtr styleManager, StyleChangeType styleChange)
145         {
146             StyleChangedEventArgs e = new StyleChangedEventArgs();
147
148             // Populate all members of "e" (StyleChangedEventArgs) with real data
149             e.StyleManager = StyleManager.GetStyleManagerFromPtr(styleManager);
150             e.StyleChange = styleChange;
151
152             if (_styleManagerStyleChangedEventHandler != null)
153             {
154                 //here we send all data to user event handlers
155                 _styleManagerStyleChangedEventHandler(this, e);
156             }
157         }
158
159         internal static StyleManager GetStyleManagerFromPtr(global::System.IntPtr cPtr)
160         {
161             StyleManager ret = new StyleManager(cPtr, false);
162             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
163             return ret;
164         }
165
166         /// <summary>
167         /// Creates a StyleManager handle.<br>
168         /// this can be initialized with StyleManager::Get().<br>
169         /// </summary>
170         public StyleManager() : this(NDalicPINVOKE.new_StyleManager(), true)
171         {
172             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
173         }
174
175         /// <summary>
176         /// Gets the singleton of StyleManager object.
177         /// </summary>
178         /// <returns>A handle to the StyleManager control</returns>
179         public static StyleManager Get()
180         {
181             StyleManager ret = new StyleManager(NDalicPINVOKE.StyleManager_Get(), true);
182             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
183             return ret;
184         }
185
186         /// <summary>
187         /// Applies a new theme to the application. <br>
188         /// This will be merged on top of the default Toolkit theme.<br>
189         /// If the application theme file doesn't style all controls that the
190         /// application uses, then the default Toolkit theme will be used
191         /// instead for those controls.<br>
192         /// </summary>
193         /// <param name="themeFile">A relative path is specified for style theme</param>
194         public void ApplyTheme(string themeFile)
195         {
196             NDalicPINVOKE.StyleManager_ApplyTheme(swigCPtr, themeFile);
197             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
198         }
199
200         /// <summary>
201         /// Applies the default Toolkit theme.
202         /// </summary>
203         public void ApplyDefaultTheme()
204         {
205             NDalicPINVOKE.StyleManager_ApplyDefaultTheme(swigCPtr);
206             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
207         }
208
209         /// <summary>
210         /// Sets a constant for use when building styles.
211         /// </summary>
212         /// <param name="key">The key of the constant</param>
213         /// <param name="value">The value of the constant</param>
214         public void SetStyleConstant(string key, PropertyValue value)
215         {
216             NDalicPINVOKE.StyleManager_SetStyleConstant(swigCPtr, key, PropertyValue.getCPtr(value));
217             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
218         }
219
220         /// <summary>
221         /// Returns the style constant set for a specific key.
222         /// </summary>
223         /// <param name="key">The key of the constant</param>
224         /// <param name="valueOut">The value of the constant if it exists</param>
225         /// <returns></returns>
226         public bool GetStyleConstant(string key, PropertyValue valueOut)
227         {
228             bool ret = NDalicPINVOKE.StyleManager_GetStyleConstant(swigCPtr, key, PropertyValue.getCPtr(valueOut));
229             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
230             return ret;
231         }
232
233         /// <summary>
234         /// Applies the specified style to the control.
235         /// </summary>
236         /// <param name="control">The control to which to apply the style</param>
237         /// <param name="jsonFileName">The name of the JSON style file to apply</param>
238         /// <param name="styleName">The name of the style within the JSON file to apply</param>
239         public void ApplyStyle(View control, string jsonFileName, string styleName)
240         {
241             NDalicPINVOKE.StyleManager_ApplyStyle(swigCPtr, View.getCPtr(control), jsonFileName, styleName);
242             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
243         }
244
245         internal StyleChangedSignal StyleChangedSignal()
246         {
247             StyleChangedSignal ret = new StyleChangedSignal(NDalicPINVOKE.StyleManager_StyleChangedSignal(swigCPtr), false);
248             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
249             return ret;
250         }
251
252     }
253 }