2 * Copyright (c) 2016 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
18 %define STYLEMANAGER_EVENTHANDLER_TYPEMAP_EVENTARG(NameSpace, ClassName)
19 %typemap(csimports) NameSpace::ClassName %{
21 using System.Runtime.InteropServices;
25 %define STYLEMANAGER_EVENTHANDLER_TYPEMAP_HELPER(NameSpace, ClassName)
26 %typemap(cscode) NameSpace::ClassName %{
30 * @brief Event arguments that passed via StyleChanged signal
33 public class StyleChangedEventArgs : EventArgs
35 private StyleManager _styleManager;
36 private Dali.StyleChangeType _styleChange;
39 * @brief StyleManager - is the StyleManager that informs applications of system theme change,
40 * and supports application theme change at runtime.
43 public StyleManager StyleManager
51 _styleManager = value;
56 * @brief StyleChange - contains Style change information (default font changed or
57 * default font size changed or theme has changed)
60 public Dali.StyleChangeType StyleChange
74 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
75 private delegate void StyleChangedCallbackDelegate(IntPtr styleManager, Dali.StyleChangeType styleChange);
76 private DaliEventHandler<object,StyleChangedEventArgs> _styleManagerStyleChangedEventHandler;
77 private StyleChangedCallbackDelegate _styleManagerStyleChangedCallbackDelegate;
80 * @brief Event for StyleChanged signal which can be used to subscribe/unsubscribe the
81 * event handler (in the type of StyleChangedEventHandler-DaliEventHandler<object,StyleChangedEventArgs>)
82 * provided by the user. StyleChanged signal is is emitted after the style (e.g. theme/font change) has changed
83 * and the controls have been informed.
85 public event DaliEventHandler<object,StyleChangedEventArgs> StyleChanged
91 // Restricted to only one listener
92 if (_styleManagerStyleChangedEventHandler == null)
94 _styleManagerStyleChangedEventHandler += value;
96 _styleManagerStyleChangedCallbackDelegate = new StyleChangedCallbackDelegate(OnStyleChanged);
97 this.StyleChangedSignal().Connect(_styleManagerStyleChangedCallbackDelegate);
106 if (_styleManagerStyleChangedEventHandler != null)
108 this.StyleChangedSignal().Disconnect(_styleManagerStyleChangedCallbackDelegate);
111 _styleManagerStyleChangedEventHandler -= value;
116 // Callback for StyleManager StyleChangedsignal
117 private void OnStyleChanged(IntPtr styleManager, Dali.StyleChangeType styleChange)
119 StyleChangedEventArgs e = new StyleChangedEventArgs();
121 // Populate all members of "e" (StyleChangedEventArgs) with real data
122 e.StyleManager = StyleManager.GetStyleManagerFromPtr( styleManager );
123 e.StyleChange = styleChange;
125 if (_styleManagerStyleChangedEventHandler != null)
127 //here we send all data to user event handlers
128 _styleManagerStyleChangedEventHandler(this, e);
132 public static ClassName Get ## ClassName ## FromPtr(global::System.IntPtr cPtr) {
133 ClassName ret = new ClassName(cPtr, false);
134 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
143 %define DALI_STYLEMANAGER_EVENTHANDLER_PARAM( NameSpace, ClassName)
145 STYLEMANAGER_EVENTHANDLER_TYPEMAP_EVENTARG( NameSpace, ClassName);
146 STYLEMANAGER_EVENTHANDLER_TYPEMAP_HELPER( NameSpace, ClassName);
152 DALI_STYLEMANAGER_EVENTHANDLER_PARAM( Dali::Toolkit, StyleManager);