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;
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>
24 public class StyleManager : BaseHandle
26 private global::System.Runtime.InteropServices.HandleRef swigCPtr;
28 internal StyleManager(global::System.IntPtr cPtr, bool cMemoryOwn) : base(NDalicPINVOKE.StyleManager_SWIGUpcast(cPtr), cMemoryOwn)
30 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
33 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(StyleManager obj)
35 return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
40 DisposeQueue.Instance.Add(this);
46 public override void Dispose()
48 if (!Stage.IsInstalled())
50 DisposeQueue.Instance.Add(this);
56 if (swigCPtr.Handle != global::System.IntPtr.Zero)
61 NDalicPINVOKE.delete_StyleManager(swigCPtr);
63 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
65 global::System.GC.SuppressFinalize(this);
71 /// Style changed event arguments
73 public class StyleChangedEventArgs : EventArgs
75 private StyleManager _styleManager;
76 private StyleChangeType _styleChange;
81 public StyleManager StyleManager
89 _styleManager = value;
94 /// StyleChange - contains Style change information (default font changed or
95 /// default font size changed or theme has changed).<br>
97 public StyleChangeType StyleChange
105 _styleChange = value;
111 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
112 private delegate void StyleChangedCallbackDelegate(IntPtr styleManager, Tizen.NUI.StyleChangeType styleChange);
113 private EventHandler<StyleChangedEventArgs> _styleManagerStyleChangedEventHandler;
114 private StyleChangedCallbackDelegate _styleManagerStyleChangedCallbackDelegate;
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>
122 public event EventHandler<StyleChangedEventArgs> StyleChanged
126 if (_styleManagerStyleChangedEventHandler == null)
128 _styleManagerStyleChangedCallbackDelegate = (OnStyleChanged);
129 StyleChangedSignal().Connect(_styleManagerStyleChangedCallbackDelegate);
131 _styleManagerStyleChangedEventHandler += value;
135 _styleManagerStyleChangedEventHandler -= value;
136 if (_styleManagerStyleChangedEventHandler == null && StyleChangedSignal().Empty() == false)
138 StyleChangedSignal().Disconnect(_styleManagerStyleChangedCallbackDelegate);
143 // Callback for StyleManager StyleChangedsignal
144 private void OnStyleChanged(IntPtr styleManager, StyleChangeType styleChange)
146 StyleChangedEventArgs e = new StyleChangedEventArgs();
148 // Populate all members of "e" (StyleChangedEventArgs) with real data
149 e.StyleManager = StyleManager.GetStyleManagerFromPtr(styleManager);
150 e.StyleChange = styleChange;
152 if (_styleManagerStyleChangedEventHandler != null)
154 //here we send all data to user event handlers
155 _styleManagerStyleChangedEventHandler(this, e);
159 internal static StyleManager GetStyleManagerFromPtr(global::System.IntPtr cPtr)
161 StyleManager ret = new StyleManager(cPtr, false);
162 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
167 /// Creates a StyleManager handle.<br>
168 /// this can be initialized with StyleManager::Get().<br>
170 public StyleManager() : this(NDalicPINVOKE.new_StyleManager(), true)
172 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
176 /// Gets the singleton of StyleManager object.
178 /// <returns>A handle to the StyleManager control</returns>
179 public static StyleManager Get()
181 StyleManager ret = new StyleManager(NDalicPINVOKE.StyleManager_Get(), true);
182 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
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>
193 /// <param name="themeFile">A relative path is specified for style theme</param>
194 public void ApplyTheme(string themeFile)
196 NDalicPINVOKE.StyleManager_ApplyTheme(swigCPtr, themeFile);
197 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
201 /// Applies the default Toolkit theme.
203 public void ApplyDefaultTheme()
205 NDalicPINVOKE.StyleManager_ApplyDefaultTheme(swigCPtr);
206 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
210 /// Sets a constant for use when building styles.
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)
216 NDalicPINVOKE.StyleManager_SetStyleConstant(swigCPtr, key, PropertyValue.getCPtr(value));
217 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
221 /// Returns the style constant set for a specific key.
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)
228 bool ret = NDalicPINVOKE.StyleManager_GetStyleConstant(swigCPtr, key, PropertyValue.getCPtr(valueOut));
229 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
234 /// Applies the specified style to the control.
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)
241 NDalicPINVOKE.StyleManager_ApplyStyle(swigCPtr, View.getCPtr(control), jsonFileName, styleName);
242 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
245 internal StyleChangedSignal StyleChangedSignal()
247 StyleChangedSignal ret = new StyleChangedSignal(NDalicPINVOKE.StyleManager_StyleChangedSignal(swigCPtr), false);
248 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
255 /// Types of style change. Enumeration for StyleChange type.
257 public enum StyleChangeType
260 /// Denotes that the default font has changed.
264 /// Denotes that the default font size has changed.
266 DefaultFontSizeChange,
268 /// Denotes that the theme has changed.