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,
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.
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.
30 public class StyleManager : BaseHandle
32 private global::System.Runtime.InteropServices.HandleRef swigCPtr;
34 internal StyleManager(global::System.IntPtr cPtr, bool cMemoryOwn) : base(NDalicPINVOKE.StyleManager_SWIGUpcast(cPtr), cMemoryOwn)
36 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
39 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(StyleManager obj)
41 return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
46 DisposeQueue.Instance.Add(this);
52 public override void Dispose()
54 if (!Stage.IsInstalled())
56 DisposeQueue.Instance.Add(this);
62 if (swigCPtr.Handle != global::System.IntPtr.Zero)
67 NDalicPINVOKE.delete_StyleManager(swigCPtr);
69 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
71 global::System.GC.SuppressFinalize(this);
77 /// Style changed event arguments
79 public class StyleChangedEventArgs : EventArgs
81 private StyleManager _styleManager;
82 private StyleChangeType _styleChange;
87 public StyleManager StyleManager
95 _styleManager = value;
100 /// StyleChange - contains Style change information (default font changed or
101 /// default font size changed or theme has changed)
103 public StyleChangeType StyleChange
111 _styleChange = value;
117 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
118 private delegate void StyleChangedCallbackDelegate(IntPtr styleManager, Tizen.NUI.StyleChangeType styleChange);
119 private EventHandler<StyleChangedEventArgs> _styleManagerStyleChangedEventHandler;
120 private StyleChangedCallbackDelegate _styleManagerStyleChangedCallbackDelegate;
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.
128 public event EventHandler<StyleChangedEventArgs> StyleChanged
132 if (_styleManagerStyleChangedEventHandler == null)
134 _styleManagerStyleChangedCallbackDelegate = (OnStyleChanged);
135 StyleChangedSignal().Connect(_styleManagerStyleChangedCallbackDelegate);
137 _styleManagerStyleChangedEventHandler += value;
141 _styleManagerStyleChangedEventHandler -= value;
142 if (_styleManagerStyleChangedEventHandler == null && _styleManagerStyleChangedCallbackDelegate != null)
144 StyleChangedSignal().Disconnect(_styleManagerStyleChangedCallbackDelegate);
149 // Callback for StyleManager StyleChangedsignal
150 private void OnStyleChanged(IntPtr styleManager, StyleChangeType styleChange)
152 StyleChangedEventArgs e = new StyleChangedEventArgs();
154 // Populate all members of "e" (StyleChangedEventArgs) with real data
155 e.StyleManager = StyleManager.GetStyleManagerFromPtr(styleManager);
156 e.StyleChange = styleChange;
158 if (_styleManagerStyleChangedEventHandler != null)
160 //here we send all data to user event handlers
161 _styleManagerStyleChangedEventHandler(this, e);
165 internal static StyleManager GetStyleManagerFromPtr(global::System.IntPtr cPtr)
167 StyleManager ret = new StyleManager(cPtr, false);
168 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
173 /// Creates a StyleManager handle.
174 /// this can be initialized with StyleManager::Get().
176 public StyleManager() : this(NDalicPINVOKE.new_StyleManager(), true)
178 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
182 /// Gets the singleton of StyleManager object.
184 /// <returns>A handle to the StyleManager control</returns>
185 public static StyleManager Get()
187 StyleManager ret = new StyleManager(NDalicPINVOKE.StyleManager_Get(), true);
188 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
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.
199 /// <param name="themeFile">A relative path is specified for style theme</param>
200 public void ApplyTheme(string themeFile)
202 NDalicPINVOKE.StyleManager_ApplyTheme(swigCPtr, themeFile);
203 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
207 /// Applies the default Toolkit theme.
209 public void ApplyDefaultTheme()
211 NDalicPINVOKE.StyleManager_ApplyDefaultTheme(swigCPtr);
212 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
216 /// Sets a constant for use when building styles.
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)
222 NDalicPINVOKE.StyleManager_SetStyleConstant(swigCPtr, key, PropertyValue.getCPtr(value));
223 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
227 /// Returns the style constant set for a specific key.
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)
234 bool ret = NDalicPINVOKE.StyleManager_GetStyleConstant(swigCPtr, key, PropertyValue.getCPtr(valueOut));
235 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
240 /// Applies the specified style to the control.
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)
247 NDalicPINVOKE.StyleManager_ApplyStyle(swigCPtr, View.getCPtr(control), jsonFileName, styleName);
248 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
251 internal StyleChangedSignal StyleChangedSignal()
253 StyleChangedSignal ret = new StyleChangedSignal(NDalicPINVOKE.StyleManager_StyleChangedSignal(swigCPtr), false);
254 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
261 /// Types of style change.
263 public enum StyleChangeType
266 DefaultFontSizeChange,