Release 4.0.0-preview1-00301
[platform/core/csapi/tizenfx.git] / src / Tizen.NUI / src / public / UIComponents / PushButton.cs
1 /*
2  * Copyright(c) 2017 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
18 using System;
19 using Tizen.NUI.BaseComponents;
20
21 namespace Tizen.NUI.UIComponents
22 {
23
24     /// <summary>
25     /// The PushButton changes its appearance when it is pressed, and returns to its original when it is released.
26     /// </summary>
27     public class PushButton : Button
28     {
29         private global::System.Runtime.InteropServices.HandleRef swigCPtr;
30
31         internal PushButton(global::System.IntPtr cPtr, bool cMemoryOwn) : base(NDalicPINVOKE.PushButton_SWIGUpcast(cPtr), cMemoryOwn)
32         {
33             swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
34         }
35
36         internal static global::System.Runtime.InteropServices.HandleRef getCPtr(PushButton obj)
37         {
38             return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
39         }
40
41         /// <summary>
42         /// To dispose the PushButton instance.
43         /// </summary>
44         protected override void Dispose(DisposeTypes type)
45         {
46             if (disposed)
47             {
48                 return;
49             }
50
51             if(type == DisposeTypes.Explicit)
52             {
53                 //Called by User
54                 //Release your own managed resources here.
55                 //You should release all of your own disposable objects here.
56             }
57
58             //Release your own unmanaged resources here.
59             //You should not access any managed member here except static instance.
60             //because the execution order of Finalizes is non-deterministic.
61
62             if (swigCPtr.Handle != global::System.IntPtr.Zero)
63             {
64                 if (swigCMemOwn)
65                 {
66                     swigCMemOwn = false;
67                     NDalicPINVOKE.delete_PushButton(swigCPtr);
68                 }
69                 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
70             }
71
72             base.Dispose(type);
73         }
74
75
76         internal new class Property
77         {
78             internal static readonly int UNSELECTED_ICON = NDalicPINVOKE.PushButton_Property_UNSELECTED_ICON_get();
79             internal static readonly int SELECTED_ICON = NDalicPINVOKE.PushButton_Property_SELECTED_ICON_get();
80             internal static readonly int ICON_ALIGNMENT = NDalicPINVOKE.PushButton_Property_ICON_ALIGNMENT_get();
81             internal static readonly int LABEL_PADDING = NDalicPINVOKE.PushButton_Property_LABEL_PADDING_get();
82             internal static readonly int ICON_PADDING = NDalicPINVOKE.PushButton_Property_ICON_PADDING_get();
83         }
84
85         /// <summary>
86         /// Creates the PushButton.
87         /// </summary>
88         /// <since_tizen> 3 </since_tizen>
89         public PushButton() : this(NDalicPINVOKE.PushButton_New(), true)
90         {
91             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
92
93         }
94
95         /// <summary>
96         /// Please do not use! this will be deprecated
97         /// </summary>
98         /// <since_tizen> 3 </since_tizen>
99         [Obsolete("Please do not use! this will be deprecated")]
100         public new static PushButton DownCast(BaseHandle handle)
101         {
102             PushButton ret =  Registry.GetManagedBaseHandleFromNativePtr(handle) as PushButton;
103             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
104             return ret;
105         }
106
107         /// <summary>
108         /// Please do not use! this will be deprecated
109         /// </summary>
110         /// <since_tizen> 3 </since_tizen>
111         [Obsolete("Please do not use! this will be deprecated")]
112         public string UnselectedIcon
113         {
114             set
115             {
116                 SetProperty(PushButton.Property.UNSELECTED_ICON, new Tizen.NUI.PropertyValue(value));
117             }
118         }
119
120         /// <summary>
121         /// Please do not use! this will be deprecated
122         /// </summary>
123         /// <since_tizen> 3 </since_tizen>
124         [Obsolete("Please do not use! this will be deprecated")]
125         public string SelectedIcon
126         {
127             set
128             {
129                 SetProperty(PushButton.Property.SELECTED_ICON, new Tizen.NUI.PropertyValue(value));
130             }
131         }
132         /// <summary>
133         /// Please do not use! this will be deprecated
134         /// </summary>
135         /// <since_tizen> 3 </since_tizen>
136         [Obsolete("Please do not use! this will be deprecated")]
137         public IconAlignmentType IconAlignment
138         {
139             get
140             {
141                 string temp;
142                 if (GetProperty(PushButton.Property.ICON_ALIGNMENT).Get(out temp) == false)
143                 {
144                     NUILog.Error("IconAlignment get error!");
145                 }
146                 switch (temp)
147                 {
148                     case "LEFT":
149                         return IconAlignmentType.Left;
150                     case "RIGHT":
151                         return IconAlignmentType.Right;
152                     case "TOP":
153                         return IconAlignmentType.Top;
154                     case "BOTTOM":
155                         return IconAlignmentType.Bottom;
156                     default:
157                         return IconAlignmentType.Default;
158                 }
159             }
160             set
161             {
162                 string valueToString = "";
163                 switch (value)
164                 {
165                     case IconAlignmentType.Left:
166                         {
167                             valueToString = "LEFT";
168                             break;
169                         }
170                     case IconAlignmentType.Right:
171                         {
172                             valueToString = "RIGHT";
173                             break;
174                         }
175                     case IconAlignmentType.Top:
176                         {
177                             valueToString = "TOP";
178                             break;
179                         }
180                     case IconAlignmentType.Bottom:
181                         {
182                             valueToString = "BOTTOM";
183                             break;
184                         }
185                     default:
186                         {
187                             valueToString = "DEFAULT";
188                             break;
189                         }
190                 }
191                 SetProperty(PushButton.Property.ICON_ALIGNMENT, new Tizen.NUI.PropertyValue(valueToString));
192             }
193         }
194         /// <summary>
195         /// Please do not use! this will be deprecated
196         /// </summary>
197         /// <since_tizen> 3 </since_tizen>
198         [Obsolete("Please do not use! this will be deprecated")]
199         public new Vector4 LabelPadding
200         {
201             get
202             {
203                 Vector4 temp = new Vector4(0.0f, 0.0f, 0.0f, 0.0f);
204                 GetProperty(PushButton.Property.LABEL_PADDING).Get(temp);
205                 return temp;
206             }
207             set
208             {
209                 SetProperty(PushButton.Property.LABEL_PADDING, new Tizen.NUI.PropertyValue(value));
210             }
211         }
212
213         /// <summary>
214         /// Please do not use! this will be deprecated
215         /// </summary>
216         /// <since_tizen> 3 </since_tizen>
217         [Obsolete("Please do not use! this will be deprecated")]
218         public Vector4 IconPadding
219         {
220             get
221             {
222                 Vector4 temp = new Vector4(0.0f, 0.0f, 0.0f, 0.0f);
223                 GetProperty(PushButton.Property.ICON_PADDING).Get(temp);
224                 return temp;
225             }
226             set
227             {
228                 SetProperty(PushButton.Property.ICON_PADDING, new Tizen.NUI.PropertyValue(value));
229             }
230         }
231
232         /// <summary>
233         /// Please do not use! this will be deprecated
234         /// </summary>
235         /// <since_tizen> 3 </since_tizen>
236         [Obsolete("Please do not use! this will be deprecated")]
237         public enum IconAlignmentType
238         {
239             /// <summary>
240             /// The icon located to the left of text.
241             /// </summary>
242             Left,
243             /// <summary>
244             /// The icon located to the right of text.
245             /// </summary>
246             Right,
247             /// <summary>
248             /// The icon located to the top of text.
249             /// </summary>
250             Top,
251             /// <summary>
252             /// The icon located to the bottom of text.
253             /// </summary>
254             Bottom,
255             /// <summary>
256             /// The icon located to the right of text by default.
257             /// </summary>
258             Default = Right
259         }
260
261     }
262 }