Revert "[Tizen] Ensuring that Registry.Unregister is called from the most derived...
[platform/core/csapi/tizenfx.git] / src / Tizen.NUI / src / public / UIComponents / PushButton.cs
1 /** Copyright (c) 2017 Samsung Electronics Co., Ltd.
2 *
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 *
15 */
16
17 using System;
18 using Tizen.NUI.BaseComponents;
19
20 namespace Tizen.NUI.UIComponents
21 {
22
23     /// <summary>
24     /// A PushButton changes its appearance when is pressed and returns to its original when is released.
25     /// </summary>
26     public class PushButton : Button
27     {
28         private global::System.Runtime.InteropServices.HandleRef swigCPtr;
29
30         internal PushButton(global::System.IntPtr cPtr, bool cMemoryOwn) : base(NDalicPINVOKE.PushButton_SWIGUpcast(cPtr), cMemoryOwn)
31         {
32             swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
33         }
34
35         internal static global::System.Runtime.InteropServices.HandleRef getCPtr(PushButton obj)
36         {
37             return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
38         }
39
40         /// <summary>
41         /// To make PushButton instance be disposed.
42         /// </summary>
43         protected override void Dispose(DisposeTypes type)
44         {
45             if (disposed)
46             {
47                 return;
48             }
49
50             if(type == DisposeTypes.Explicit)
51             {
52                 //Called by User
53                 //Release your own managed resources here.
54                 //You should release all of your own disposable objects here.
55             }
56
57             //Release your own unmanaged resources here.
58             //You should not access any managed member here except static instance.
59             //because the execution order of Finalizes is non-deterministic.
60
61             if (swigCPtr.Handle != global::System.IntPtr.Zero)
62             {
63                 if (swigCMemOwn)
64                 {
65                     swigCMemOwn = false;
66                     NDalicPINVOKE.delete_PushButton(swigCPtr);
67                 }
68                 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
69             }
70
71             base.Dispose(type);
72         }
73
74
75         internal class Property
76         {
77             internal static readonly int UNSELECTED_ICON = NDalicPINVOKE.PushButton_Property_UNSELECTED_ICON_get();
78             internal static readonly int SELECTED_ICON = NDalicPINVOKE.PushButton_Property_SELECTED_ICON_get();
79             internal static readonly int ICON_ALIGNMENT = NDalicPINVOKE.PushButton_Property_ICON_ALIGNMENT_get();
80             internal static readonly int LABEL_PADDING = NDalicPINVOKE.PushButton_Property_LABEL_PADDING_get();
81             internal static readonly int ICON_PADDING = NDalicPINVOKE.PushButton_Property_ICON_PADDING_get();
82         }
83
84         /// <summary>
85         /// Creates the PushButton.
86         /// </summary>
87         public PushButton() : this(NDalicPINVOKE.PushButton_New(), true)
88         {
89             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
90
91         }
92
93         [Obsolete("Please do not use! this will be deprecated")]
94         public new static PushButton DownCast(BaseHandle handle)
95         {
96             PushButton ret = new PushButton(NDalicPINVOKE.PushButton_DownCast(BaseHandle.getCPtr(handle)), true);
97             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
98             return ret;
99         }
100
101         [Obsolete("Please do not use! this will be deprecated")]
102         public string UnselectedIcon
103         {
104             set
105             {
106                 SetProperty(PushButton.Property.UNSELECTED_ICON, new Tizen.NUI.PropertyValue(value));
107             }
108         }
109         [Obsolete("Please do not use! this will be deprecated")]
110         public string SelectedIcon
111         {
112             set
113             {
114                 SetProperty(PushButton.Property.SELECTED_ICON, new Tizen.NUI.PropertyValue(value));
115             }
116         }
117         [Obsolete("Please do not use! this will be deprecated")]
118         public IconAlignmentType IconAlignment
119         {
120             get
121             {
122                 string temp;
123                 if (GetProperty(PushButton.Property.ICON_ALIGNMENT).Get(out temp) == false)
124                 {
125                     NUILog.Error("IconAlignment get error!");
126                 }
127                 switch (temp)
128                 {
129                     case "LEFT":
130                         return IconAlignmentType.Left;
131                     case "RIGHT":
132                         return IconAlignmentType.Right;
133                     case "TOP":
134                         return IconAlignmentType.Top;
135                     case "BOTTOM":
136                         return IconAlignmentType.Bottom;
137                     default:
138                         return IconAlignmentType.Default;
139                 }
140             }
141             set
142             {
143                 string valueToString = "";
144                 switch (value)
145                 {
146                     case IconAlignmentType.Left:
147                         {
148                             valueToString = "LEFT";
149                             break;
150                         }
151                     case IconAlignmentType.Right:
152                         {
153                             valueToString = "RIGHT";
154                             break;
155                         }
156                     case IconAlignmentType.Top:
157                         {
158                             valueToString = "TOP";
159                             break;
160                         }
161                     case IconAlignmentType.Bottom:
162                         {
163                             valueToString = "BOTTOM";
164                             break;
165                         }
166                     default:
167                         {
168                             valueToString = "DEFAULT";
169                             break;
170                         }
171                 }
172                 SetProperty(PushButton.Property.ICON_ALIGNMENT, new Tizen.NUI.PropertyValue(valueToString));
173             }
174         }
175         [Obsolete("Please do not use! this will be deprecated")]
176         public Vector4 LabelPadding
177         {
178             get
179             {
180                 Vector4 temp = new Vector4(0.0f, 0.0f, 0.0f, 0.0f);
181                 GetProperty(PushButton.Property.LABEL_PADDING).Get(temp);
182                 return temp;
183             }
184             set
185             {
186                 SetProperty(PushButton.Property.LABEL_PADDING, new Tizen.NUI.PropertyValue(value));
187             }
188         }
189
190         [Obsolete("Please do not use! this will be deprecated")]
191         public Vector4 IconPadding
192         {
193             get
194             {
195                 Vector4 temp = new Vector4(0.0f, 0.0f, 0.0f, 0.0f);
196                 GetProperty(PushButton.Property.ICON_PADDING).Get(temp);
197                 return temp;
198             }
199             set
200             {
201                 SetProperty(PushButton.Property.ICON_PADDING, new Tizen.NUI.PropertyValue(value));
202             }
203         }
204
205         [Obsolete("Please do not use! this will be deprecated")]
206         public enum IconAlignmentType
207         {
208             /// <summary>
209             /// Icon located to the left of text.
210             /// </summary>
211             Left,
212             /// <summary>
213             /// Icon located to the right of text.
214             /// </summary>
215             Right,
216             /// <summary>
217             /// Icon located to the top of text.
218             /// </summary>
219             Top,
220             /// <summary>
221             /// Icon located to the bottom of text.
222             /// </summary>
223             Bottom,
224             /// <summary>
225             /// Icon located to the right of text by default.
226             /// </summary>
227             Default = Right
228         }
229
230     }
231 }