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