1 //------------------------------------------------------------------------------
4 // This file was automatically generated by SWIG (http://www.swig.org).
7 // Do not make changes to this file unless you know what you are doing--modify
8 // the SWIG interface file instead.
9 //------------------------------------------------------------------------------
15 using System.Runtime.InteropServices;
16 using Tizen.NUI.BaseComponents;
19 /// StyleManager informs applications of system theme change, and supports application theme change at runtime.<br>
20 /// Applies various styles to Controls using the properties system.<br>
21 /// On theme change, it automatically updates all controls, then raises a event to inform the application.<br>
22 /// If the application wants to customize the theme, RequestThemeChange needs to be called.<br>
23 /// 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>
25 public class StyleManager : BaseHandle
27 private global::System.Runtime.InteropServices.HandleRef swigCPtr;
29 internal StyleManager(global::System.IntPtr cPtr, bool cMemoryOwn) : base(NDalicPINVOKE.StyleManager_SWIGUpcast(cPtr), cMemoryOwn)
31 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
34 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(StyleManager obj)
36 return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
42 protected override void Dispose(DisposeTypes type)
49 if(type == DisposeTypes.Explicit)
52 //Release your own managed resources here.
53 //You should release all of your own disposable objects here.
56 //Release your own unmanaged resources here.
57 //You should not access any managed member here except static instance.
58 //because the execution order of Finalizes is non-deterministic.
60 if (swigCPtr.Handle != global::System.IntPtr.Zero)
65 NDalicPINVOKE.delete_StyleManager(swigCPtr);
67 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
74 /// Style changed event arguments
76 public class StyleChangedEventArgs : EventArgs
78 private StyleManager _styleManager;
79 private StyleChangeType _styleChange;
84 public StyleManager StyleManager
92 _styleManager = value;
97 /// StyleChange - contains Style change information (default font changed or
98 /// default font size changed or theme has changed).<br>
100 public StyleChangeType StyleChange
108 _styleChange = value;
114 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
115 private delegate void StyleChangedCallbackDelegate(IntPtr styleManager, Tizen.NUI.StyleChangeType styleChange);
116 private EventHandler<StyleChangedEventArgs> _styleManagerStyleChangedEventHandler;
117 private StyleChangedCallbackDelegate _styleManagerStyleChangedCallbackDelegate;
120 /// Event for StyleChanged signal which can be used to subscribe/unsubscribe the
121 /// event handler provided by the user.<br>
122 /// StyleChanged signal is is emitted after the style (e.g. theme/font change) has changed
123 /// and the controls have been informed.<br>
125 public event EventHandler<StyleChangedEventArgs> StyleChanged
129 if (_styleManagerStyleChangedEventHandler == null)
131 _styleManagerStyleChangedCallbackDelegate = (OnStyleChanged);
132 StyleChangedSignal().Connect(_styleManagerStyleChangedCallbackDelegate);
134 _styleManagerStyleChangedEventHandler += value;
138 _styleManagerStyleChangedEventHandler -= value;
139 if (_styleManagerStyleChangedEventHandler == null && StyleChangedSignal().Empty() == false)
141 StyleChangedSignal().Disconnect(_styleManagerStyleChangedCallbackDelegate);
146 // Callback for StyleManager StyleChangedsignal
147 private void OnStyleChanged(IntPtr styleManager, StyleChangeType styleChange)
149 StyleChangedEventArgs e = new StyleChangedEventArgs();
151 // Populate all members of "e" (StyleChangedEventArgs) with real data
152 e.StyleManager = StyleManager.GetStyleManagerFromPtr(styleManager);
153 e.StyleChange = styleChange;
155 if (_styleManagerStyleChangedEventHandler != null)
157 //here we send all data to user event handlers
158 _styleManagerStyleChangedEventHandler(this, e);
162 internal static StyleManager GetStyleManagerFromPtr(global::System.IntPtr cPtr)
164 StyleManager ret = new StyleManager(cPtr, false);
165 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
170 /// Creates a StyleManager handle.<br>
171 /// this can be initialized with StyleManager::Get().<br>
173 public StyleManager() : this(NDalicPINVOKE.new_StyleManager(), true)
175 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
179 /// Gets the singleton of StyleManager object.
181 /// <returns>A handle to the StyleManager control</returns>
182 public static StyleManager Get()
184 StyleManager ret = new StyleManager(NDalicPINVOKE.StyleManager_Get(), true);
185 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
190 /// Applies a new theme to the application. <br>
191 /// This will be merged on top of the default Toolkit theme.<br>
192 /// If the application theme file doesn't style all controls that the
193 /// application uses, then the default Toolkit theme will be used
194 /// instead for those controls.<br>
196 /// <param name="themeFile">A relative path is specified for style theme</param>
197 public void ApplyTheme(string themeFile)
199 NDalicPINVOKE.StyleManager_ApplyTheme(swigCPtr, themeFile);
200 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
204 /// Applies the default Toolkit theme.
206 public void ApplyDefaultTheme()
208 NDalicPINVOKE.StyleManager_ApplyDefaultTheme(swigCPtr);
209 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
213 /// Sets a constant for use when building styles.
215 /// <param name="key">The key of the constant</param>
216 /// <param name="value">The value of the constant</param>
217 public void SetStyleConstant(string key, PropertyValue value)
219 NDalicPINVOKE.StyleManager_SetStyleConstant(swigCPtr, key, PropertyValue.getCPtr(value));
220 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
224 /// Returns the style constant set for a specific key.
226 /// <param name="key">The key of the constant</param>
227 /// <param name="valueOut">The value of the constant if it exists</param>
228 /// <returns></returns>
229 public bool GetStyleConstant(string key, PropertyValue valueOut)
231 bool ret = NDalicPINVOKE.StyleManager_GetStyleConstant(swigCPtr, key, PropertyValue.getCPtr(valueOut));
232 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
237 /// Applies the specified style to the control.
239 /// <param name="control">The control to which to apply the style</param>
240 /// <param name="jsonFileName">The name of the JSON style file to apply</param>
241 /// <param name="styleName">The name of the style within the JSON file to apply</param>
242 public void ApplyStyle(View control, string jsonFileName, string styleName)
244 NDalicPINVOKE.StyleManager_ApplyStyle(swigCPtr, View.getCPtr(control), jsonFileName, styleName);
245 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
248 internal StyleChangedSignal StyleChangedSignal()
250 StyleChangedSignal ret = new StyleChangedSignal(NDalicPINVOKE.StyleManager_StyleChangedSignal(swigCPtr), false);
251 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();