[NUI] Integration from dalihub (DALi 1.4.34) (#999)
[platform/core/csapi/tizenfx.git] / src / Tizen.NUI / src / public / UIComponents / ToggleButton.cs
1 /*
2  * Copyright(c) 2018 Samsung Electronics Co., Ltd.
3  *
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
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  *
16  */
17 using System;
18 using System.ComponentModel;
19 using Tizen.NUI.Binding;
20
21 namespace Tizen.NUI
22 {
23     /// <summary>
24     /// A ToggleButton allows the user to change a setting between two or more states.
25     /// </summary>
26     /// <since_tizen> 3 </since_tizen>
27     public class ToggleButton : Tizen.NUI.UIComponents.Button
28     {
29         /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
30         [EditorBrowsable(EditorBrowsableState.Never)]
31         public static readonly BindableProperty StateVisualsProperty = BindableProperty.Create("StateVisuals", typeof(PropertyArray), typeof(ToggleButton), new PropertyArray(), propertyChanged: (bindable, oldValue, newValue) =>
32         {
33             var toggleButton = (ToggleButton)bindable;
34             if (newValue != null)
35             {
36                 Tizen.NUI.Object.SetProperty(toggleButton.swigCPtr, ToggleButton.Property.STATE_VISUALS, new Tizen.NUI.PropertyValue((PropertyArray)newValue));
37             }
38         },
39         defaultValueCreator: (bindable) =>
40         {
41             var toggleButton = (ToggleButton)bindable;
42             Tizen.NUI.PropertyArray temp = new Tizen.NUI.PropertyArray();
43             Tizen.NUI.Object.GetProperty(toggleButton.swigCPtr, ToggleButton.Property.STATE_VISUALS).Get(temp);
44             return temp;
45         });
46
47         /// Only for XAML property binding. This will be changed as Inhouse API by ACR later.
48         public static readonly BindableProperty TooltipsProperty = BindableProperty.Create("Tooltips", typeof(PropertyArray), typeof(ToggleButton), new PropertyArray(), propertyChanged: (bindable, oldValue, newValue) =>
49         {
50             var toggleButton = (ToggleButton)bindable;
51             if (newValue != null)
52             {
53                 Tizen.NUI.Object.SetProperty(toggleButton.swigCPtr, ToggleButton.Property.TOOLTIPS, new Tizen.NUI.PropertyValue((PropertyArray)newValue));
54             }
55         },
56         defaultValueCreator: (bindable) =>
57         {
58             var toggleButton = (ToggleButton)bindable;
59             Tizen.NUI.PropertyArray temp = new Tizen.NUI.PropertyArray();
60             Tizen.NUI.Object.GetProperty(toggleButton.swigCPtr, ToggleButton.Property.TOOLTIPS).Get(temp);
61             return temp;
62         });
63
64         /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
65         [EditorBrowsable(EditorBrowsableState.Never)]
66         public static readonly BindableProperty CurrentStateIndexProperty = BindableProperty.Create("CurrentStateIndex", typeof(int), typeof(ToggleButton), default(int), propertyChanged: (bindable, oldValue, newValue) =>
67         {
68             var toggleButton = (ToggleButton)bindable;
69             if (newValue != null)
70             {
71                 Tizen.NUI.Object.SetProperty(toggleButton.swigCPtr, ToggleButton.Property.CURRENT_STATE_INDEX, new Tizen.NUI.PropertyValue((int)newValue));
72             }
73         },
74         defaultValueCreator: (bindable) =>
75         {
76             var toggleButton = (ToggleButton)bindable;
77             int temp = 0;
78             Tizen.NUI.Object.GetProperty(toggleButton.swigCPtr, ToggleButton.Property.CURRENT_STATE_INDEX).Get(out temp);
79             return temp;
80         });
81
82         private global::System.Runtime.InteropServices.HandleRef swigCPtr;
83
84         /// <summary>
85         /// Create an instance for toggleButton.
86         /// </summary>
87         /// <since_tizen> 3 </since_tizen>
88         public ToggleButton() : this(Interop.ToggleButton.ToggleButton_New(), true)
89         {
90             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
91         }
92
93         internal ToggleButton(global::System.IntPtr cPtr, bool cMemoryOwn) : base(Interop.ToggleButton.ToggleButton_SWIGUpcast(cPtr), cMemoryOwn)
94         {
95             swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
96         }
97
98         /// <summary>
99         /// Gets and Sets the state visual array of toggle button.
100         /// </summary>
101         /// <since_tizen> 3 </since_tizen>
102         public Tizen.NUI.PropertyArray StateVisuals
103         {
104             get
105             {
106                 return (PropertyArray)GetValue(StateVisualsProperty);
107             }
108             set
109             {
110                 SetValue(StateVisualsProperty, value);
111             }
112         }
113
114         /// <summary>
115         /// Gets and Sets the tooltips of toggle button.
116         /// </summary>
117         /// <since_tizen> 3 </since_tizen>
118         public Tizen.NUI.PropertyArray Tooltips
119         {
120             get
121             {
122                 return (PropertyArray)GetValue(TooltipsProperty);
123             }
124             set
125             {
126                 SetValue(TooltipsProperty, value);
127             }
128         }
129
130         /// <summary>
131         /// Gets and Sets the current state index of toggle button.
132         /// </summary>
133         /// <since_tizen> 3 </since_tizen>
134         public int CurrentStateIndex
135         {
136             get
137             {
138                 return (int)GetValue(CurrentStateIndexProperty);
139             }
140             set
141             {
142                 SetValue(CurrentStateIndexProperty, value);
143             }
144         }
145
146         internal static global::System.Runtime.InteropServices.HandleRef getCPtr(ToggleButton obj)
147         {
148             return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
149         }
150
151         /// <summary>
152         /// Dispose
153         /// </summary>
154         /// <param name="type">The dispose type</param>
155         /// <since_tizen> 3 </since_tizen>
156         protected override void Dispose(DisposeTypes type)
157         {
158             if (disposed)
159             {
160                 return;
161             }
162
163             //Release your own unmanaged resources here.
164             //You should not access any managed member here except static instance.
165             //because the execution order of Finalizes is non-deterministic.
166
167             if (swigCPtr.Handle != global::System.IntPtr.Zero)
168             {
169                 if (swigCMemOwn)
170                 {
171                     swigCMemOwn = false;
172                     Interop.ToggleButton.delete_ToggleButton(swigCPtr);
173                 }
174                 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
175             }
176
177             base.Dispose(type);
178         }
179
180         /// <summary>
181         /// This should be internal, please do not use.
182         /// </summary>
183         /// <since_tizen> 3 </since_tizen>
184         [EditorBrowsable(EditorBrowsableState.Never)]
185         [Obsolete("Deprecated in API6; Will be removed in API9.")]
186         public new class Property
187         {
188             /// <summary>
189             /// This should be internal, please do not use.
190             /// </summary>
191             /// <since_tizen> 3 </since_tizen>
192             [EditorBrowsable(EditorBrowsableState.Never)]
193             [Obsolete("Deprecated in API6; Will be removed in API9.")]
194             public static readonly int STATE_VISUALS = Interop.ToggleButton.ToggleButton_Property_STATE_VISUALS_get();
195             /// <summary>
196             /// This should be internal, please do not use.
197             /// </summary>
198             /// <since_tizen> 3 </since_tizen>
199             [EditorBrowsable(EditorBrowsableState.Never)]
200             [Obsolete("Deprecated in API6; Will be removed in API9.")]
201             public static readonly int TOOLTIPS = Interop.ToggleButton.ToggleButton_Property_TOOLTIPS_get();
202             /// <summary>
203             /// This should be internal, please do not use.
204             /// </summary>
205             /// <since_tizen> 3 </since_tizen>
206             [EditorBrowsable(EditorBrowsableState.Never)]
207             [Obsolete("Deprecated in API6; Will be removed in API9.")]
208             public static readonly int CURRENT_STATE_INDEX = Interop.ToggleButton.ToggleButton_Property_CURRENT_STATE_INDEX_get();
209         }
210     }
211 }