Revert "[NUI] Fix ConvertIdToView (#877)" (#889)
[platform/core/csapi/tizenfx.git] / src / Tizen.NUI.Xaml / 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.ComponentModel;
18 using Tizen.NUI;
19 using Tizen.NUI.XamlBinding;
20
21 namespace Tizen.NUI.Xaml.UIComponents
22 {
23
24     /// <summary>
25     /// A ToggleButton allows the user to change a setting between two or more states.
26     /// </summary>
27     /// <since_tizen> 6 </since_tizen>
28     /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
29     [EditorBrowsable(EditorBrowsableState.Never)]
30     public class ToggleButton : Button
31     {
32         private Tizen.NUI.ToggleButton _toggleButton;
33         internal Tizen.NUI.ToggleButton toggleButton
34         {
35             get
36             {
37                 if (null == _toggleButton)
38                 {
39                     _toggleButton = handleInstance as Tizen.NUI.ToggleButton;
40                 }
41
42                 return _toggleButton;
43             }
44         }
45
46         /// <summary>
47         /// Create an instance for toggleButton.
48         /// </summary>
49         /// <since_tizen> 6 </since_tizen>
50         /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
51         [EditorBrowsable(EditorBrowsableState.Never)]
52         public ToggleButton() : this(new Tizen.NUI.ToggleButton())
53         {
54         }
55
56         internal ToggleButton(Tizen.NUI.ToggleButton nuiInstance) : base(nuiInstance)
57         {
58             SetNUIInstance(nuiInstance);
59         }
60
61         /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
62         [EditorBrowsable(EditorBrowsableState.Never)]
63         public static readonly BindableProperty StateVisualsProperty = BindableProperty.Create("StateVisuals", typeof(PropertyArray), typeof(ToggleButton), null, propertyChanged: (bindable, oldValue, newValue) =>
64         {
65             var toggleButton = ((ToggleButton)bindable).toggleButton;
66             toggleButton.StateVisuals = (PropertyArray)newValue;
67         },
68         defaultValueCreator: (bindable) =>
69         {
70             var toggleButton = ((ToggleButton)bindable).toggleButton;
71             return toggleButton.StateVisuals;
72         });
73         /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
74         [EditorBrowsable(EditorBrowsableState.Never)]
75         public static readonly BindableProperty TooltipsProperty = BindableProperty.Create("Tooltips", typeof(PropertyArray), typeof(ToggleButton), null, propertyChanged: (bindable, oldValue, newValue) =>
76         {
77             var toggleButton = ((ToggleButton)bindable).toggleButton;
78             toggleButton.Tooltips = (PropertyArray)newValue;
79         },
80         defaultValueCreator: (bindable) =>
81         {
82             var toggleButton = ((ToggleButton)bindable).toggleButton;
83             return toggleButton.Tooltips;
84         });
85         /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
86         [EditorBrowsable(EditorBrowsableState.Never)]
87         public static readonly BindableProperty CurrentStateIndexProperty = BindableProperty.Create("CurrentStateIndex", typeof(int), typeof(ToggleButton), default(int), propertyChanged: (bindable, oldValue, newValue) =>
88         {
89             var toggleButton = ((ToggleButton)bindable).toggleButton;
90             toggleButton.CurrentStateIndex = (int)newValue;
91         },
92         defaultValueCreator: (bindable) =>
93         {
94             var toggleButton = ((ToggleButton)bindable).toggleButton;
95             return toggleButton.CurrentStateIndex;
96         });
97
98         /// <summary>
99         /// Gets and Sets the state visual array of toggle button.
100         /// </summary>
101         /// <since_tizen> 6 </since_tizen>
102         /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
103         [EditorBrowsable(EditorBrowsableState.Never)]
104         public PropertyArray StateVisuals
105         {
106             get
107             {
108                 return (PropertyArray)GetValue(StateVisualsProperty);
109             }
110             set
111             {
112                 SetValue(StateVisualsProperty, value);
113             }
114         }
115
116         /// <summary>
117         /// Gets and Sets the tooltips of toggle button.
118         /// </summary>
119         /// <since_tizen> 6 </since_tizen>
120         /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
121         [EditorBrowsable(EditorBrowsableState.Never)]
122         public PropertyArray Tooltips
123         {
124             get
125             {
126                 return (PropertyArray)GetValue(TooltipsProperty);
127             }
128             set
129             {
130                 SetValue(TooltipsProperty, value);
131             }
132         }
133
134         /// <summary>
135         /// Gets and Sets the current state index of toggle button.
136         /// </summary>
137         /// <since_tizen> 6 </since_tizen>
138         /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
139         [EditorBrowsable(EditorBrowsableState.Never)]
140         public int CurrentStateIndex
141         {
142             get
143             {
144                 return (int)GetValue(CurrentStateIndexProperty);
145             }
146             set
147             {
148                 SetValue(CurrentStateIndexProperty, value);
149             }
150         }
151     }
152 }