Release 4.0.0-preview1-00271
[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     /// The PushButton changes its appearance when it is pressed, and returns to its original when it 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 dispose the PushButton instance.
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 new 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         /// <since_tizen> 3 </since_tizen>
88         public PushButton() : this(NDalicPINVOKE.PushButton_New(), true)
89         {
90             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
91
92         }
93
94         [Obsolete("Please do not use! this will be deprecated")]
95         public new static PushButton DownCast(BaseHandle handle)
96         {
97             PushButton ret =  Registry.GetManagedBaseHandleFromNativePtr(handle) as PushButton;
98             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
99             return ret;
100         }
101
102         [Obsolete("Please do not use! this will be deprecated")]
103         public string UnselectedIcon
104         {
105             set
106             {
107                 SetProperty(PushButton.Property.UNSELECTED_ICON, new Tizen.NUI.PropertyValue(value));
108             }
109         }
110         [Obsolete("Please do not use! this will be deprecated")]
111         public string SelectedIcon
112         {
113             set
114             {
115                 SetProperty(PushButton.Property.SELECTED_ICON, new Tizen.NUI.PropertyValue(value));
116             }
117         }
118         [Obsolete("Please do not use! this will be deprecated")]
119         public IconAlignmentType IconAlignment
120         {
121             get
122             {
123                 string temp;
124                 if (GetProperty(PushButton.Property.ICON_ALIGNMENT).Get(out temp) == false)
125                 {
126                     NUILog.Error("IconAlignment get error!");
127                 }
128                 switch (temp)
129                 {
130                     case "LEFT":
131                         return IconAlignmentType.Left;
132                     case "RIGHT":
133                         return IconAlignmentType.Right;
134                     case "TOP":
135                         return IconAlignmentType.Top;
136                     case "BOTTOM":
137                         return IconAlignmentType.Bottom;
138                     default:
139                         return IconAlignmentType.Default;
140                 }
141             }
142             set
143             {
144                 string valueToString = "";
145                 switch (value)
146                 {
147                     case IconAlignmentType.Left:
148                         {
149                             valueToString = "LEFT";
150                             break;
151                         }
152                     case IconAlignmentType.Right:
153                         {
154                             valueToString = "RIGHT";
155                             break;
156                         }
157                     case IconAlignmentType.Top:
158                         {
159                             valueToString = "TOP";
160                             break;
161                         }
162                     case IconAlignmentType.Bottom:
163                         {
164                             valueToString = "BOTTOM";
165                             break;
166                         }
167                     default:
168                         {
169                             valueToString = "DEFAULT";
170                             break;
171                         }
172                 }
173                 SetProperty(PushButton.Property.ICON_ALIGNMENT, new Tizen.NUI.PropertyValue(valueToString));
174             }
175         }
176         [Obsolete("Please do not use! this will be deprecated")]
177         public new Vector4 LabelPadding
178         {
179             get
180             {
181                 Vector4 temp = new Vector4(0.0f, 0.0f, 0.0f, 0.0f);
182                 GetProperty(PushButton.Property.LABEL_PADDING).Get(temp);
183                 return temp;
184             }
185             set
186             {
187                 SetProperty(PushButton.Property.LABEL_PADDING, new Tizen.NUI.PropertyValue(value));
188             }
189         }
190
191         [Obsolete("Please do not use! this will be deprecated")]
192         public Vector4 IconPadding
193         {
194             get
195             {
196                 Vector4 temp = new Vector4(0.0f, 0.0f, 0.0f, 0.0f);
197                 GetProperty(PushButton.Property.ICON_PADDING).Get(temp);
198                 return temp;
199             }
200             set
201             {
202                 SetProperty(PushButton.Property.ICON_PADDING, new Tizen.NUI.PropertyValue(value));
203             }
204         }
205
206         [Obsolete("Please do not use! this will be deprecated")]
207         public enum IconAlignmentType
208         {
209             /// <summary>
210             /// The icon located to the left of text.
211             /// </summary>
212             Left,
213             /// <summary>
214             /// The icon located to the right of text.
215             /// </summary>
216             Right,
217             /// <summary>
218             /// The icon located to the top of text.
219             /// </summary>
220             Top,
221             /// <summary>
222             /// The icon located to the bottom of text.
223             /// </summary>
224             Bottom,
225             /// <summary>
226             /// The icon located to the right of text by default.
227             /// </summary>
228             Default = Right
229         }
230
231     }
232 }