Add ScriptUI to support XAML file (#320)
[platform/core/csapi/tizenfx.git] / src / Tizen.NUI / src / public / UIComponents / Button.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 using System;
18 using System.ComponentModel;
19 using System.Runtime.InteropServices;
20 using Tizen.NUI.BaseComponents;
21 using Tizen.NUI.Binding;
22
23 namespace Tizen.NUI.UIComponents
24 {
25     /// <summary>
26     /// The Button class is a base class for different kinds of buttons.<br />
27     /// This class provides the disabled property and the clicked signal.<br />
28     /// The clicked event handler is emitted when the button is touched, and the touch point doesn't leave the boundary of the button.<br />
29     /// When the disabled property is set to true, no signal is emitted.<br />
30     /// The 'Visual' describes not just traditional images like PNG and BMP, but also refers to whatever is used to show the button. It could be a color, gradient, or some other kind of renderer.<br />
31     /// The button's appearance can be modified by setting properties for the various visuals or images.<br />
32     /// It is not mandatory to set all the visuals. A button could be defined only by setting its background visual, or by setting its background and selected visuals.<br />
33     /// The button visual is shown over the background visual.<br />
34     /// When pressed, the unselected visuals are replaced by the selected visuals.<br />
35     /// The text label is always placed on the top of all images.<br />
36     /// When the button is disabled, the background button and the selected visuals are replaced by their disabled visuals.<br />
37     /// </summary>
38     /// <since_tizen> 3 </since_tizen>
39     [ContentProperty("LabelText")]
40     public class Button : View
41     {
42         /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
43         [EditorBrowsable(EditorBrowsableState.Never)]
44         public static readonly BindableProperty UnselectedVisualProperty = BindableProperty.Create("UnselectedVisual", typeof(PropertyMap), typeof(Button), new PropertyMap(), propertyChanged: (bindable, oldValue, newValue) =>
45         {
46             var button = (Button)bindable;
47             if (newValue != null)
48             {
49                 Tizen.NUI.Object.SetProperty(button.swigCPtr, Button.Property.UNSELECTED_VISUAL, new Tizen.NUI.PropertyValue((PropertyMap)newValue));
50             }
51         },
52         defaultValueCreator:(bindable) =>
53         {
54             var button = (Button)bindable;
55             Tizen.NUI.PropertyMap temp = new Tizen.NUI.PropertyMap();
56             Tizen.NUI.Object.GetProperty(button.swigCPtr, Button.Property.UNSELECTED_VISUAL).Get(temp);
57             return temp;
58         });
59         /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
60         [EditorBrowsable(EditorBrowsableState.Never)]
61         public static readonly BindableProperty SelectedVisualProperty = BindableProperty.Create("SelectedVisual", typeof(PropertyMap), typeof(Button), new PropertyMap(), propertyChanged: (bindable, oldValue, newValue) =>
62         {
63             var button = (Button)bindable;
64             if (newValue != null)
65             {
66                 Tizen.NUI.Object.SetProperty(button.swigCPtr, Button.Property.SELECTED_VISUAL, new Tizen.NUI.PropertyValue((PropertyMap)newValue));
67             }
68         },
69         defaultValueCreator:(bindable) =>
70         {
71             var button = (Button)bindable;
72             Tizen.NUI.PropertyMap temp = new Tizen.NUI.PropertyMap();
73             Tizen.NUI.Object.GetProperty(button.swigCPtr, Button.Property.SELECTED_VISUAL).Get(temp);
74             return temp;
75         });
76         /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
77         [EditorBrowsable(EditorBrowsableState.Never)]
78         public static readonly BindableProperty DisabledSelectedVisualProperty = BindableProperty.Create("DisabledSelectedVisual", typeof(PropertyMap), typeof(Button), new PropertyMap(), propertyChanged: (bindable, oldValue, newValue) =>
79         {
80             var button = (Button)bindable;
81             if (newValue != null)
82             {
83                 Tizen.NUI.Object.SetProperty(button.swigCPtr, Button.Property.DISABLED_SELECTED_VISUAL, new Tizen.NUI.PropertyValue((PropertyMap)newValue));
84             }
85         },
86         defaultValueCreator:(bindable) =>
87         {
88             var button = (Button)bindable;
89             Tizen.NUI.PropertyMap temp = new Tizen.NUI.PropertyMap();
90             Tizen.NUI.Object.GetProperty(button.swigCPtr, Button.Property.DISABLED_SELECTED_VISUAL).Get(temp);
91             return temp;
92         });
93         /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
94         [EditorBrowsable(EditorBrowsableState.Never)]
95         public static readonly BindableProperty DisabledUnselectedVisualProperty = BindableProperty.Create("DisabledUnselectedVisual", typeof(PropertyMap), typeof(Button), new PropertyMap(), propertyChanged: (bindable, oldValue, newValue) =>
96         {
97             var button = (Button)bindable;
98             if (newValue != null)
99             {
100                 Tizen.NUI.Object.SetProperty(button.swigCPtr, Button.Property.DISABLED_UNSELECTED_VISUAL, new Tizen.NUI.PropertyValue((PropertyMap)newValue));
101             }
102         },
103         defaultValueCreator:(bindable) =>
104         {
105             var button = (Button)bindable;
106             Tizen.NUI.PropertyMap temp = new Tizen.NUI.PropertyMap();
107             Tizen.NUI.Object.GetProperty(button.swigCPtr, Button.Property.DISABLED_UNSELECTED_VISUAL).Get(temp);
108             return temp;
109         });
110         /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
111         [EditorBrowsable(EditorBrowsableState.Never)]
112         public static readonly BindableProperty UnselectedBackgroundVisualProperty = BindableProperty.Create("UnselectedBackgroundVisual", typeof(PropertyMap), typeof(Button), new PropertyMap(), propertyChanged: (bindable, oldValue, newValue) =>
113         {
114             var button = (Button)bindable;
115             if (newValue != null)
116             {
117                 Tizen.NUI.Object.SetProperty(button.swigCPtr, Button.Property.UNSELECTED_BACKGROUND_VISUAL, new Tizen.NUI.PropertyValue((PropertyMap)newValue));
118             }
119         },
120         defaultValueCreator:(bindable) =>
121         {
122             var button = (Button)bindable;
123             Tizen.NUI.PropertyMap temp = new Tizen.NUI.PropertyMap();
124             Tizen.NUI.Object.GetProperty(button.swigCPtr, Button.Property.UNSELECTED_BACKGROUND_VISUAL).Get(temp);
125             return temp;
126         });
127         /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
128         [EditorBrowsable(EditorBrowsableState.Never)]
129         public static readonly BindableProperty SelectedBackgroundVisualProperty = BindableProperty.Create("SelectedBackgroundVisual", typeof(PropertyMap), typeof(Button), new PropertyMap(), propertyChanged: (bindable, oldValue, newValue) =>
130         {
131             var button = (Button)bindable;
132             if (newValue != null)
133             {
134                 Tizen.NUI.Object.SetProperty(button.swigCPtr, Button.Property.SELECTED_BACKGROUND_VISUAL, new Tizen.NUI.PropertyValue((PropertyMap)newValue));
135             }
136         },
137         defaultValueCreator:(bindable) =>
138         {
139             var button = (Button)bindable;
140             Tizen.NUI.PropertyMap temp = new Tizen.NUI.PropertyMap();
141             Tizen.NUI.Object.GetProperty(button.swigCPtr, Button.Property.SELECTED_BACKGROUND_VISUAL).Get(temp);
142             return temp;
143         });
144         /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
145         [EditorBrowsable(EditorBrowsableState.Never)]
146         public static readonly BindableProperty DisabledUnselectedBackgroundVisualProperty = BindableProperty.Create("DisabledUnselectedBackgroundVisual", typeof(PropertyMap), typeof(Button), new PropertyMap(), propertyChanged: (bindable, oldValue, newValue) =>
147         {
148             var button = (Button)bindable;
149             if (newValue != null)
150             {
151                 Tizen.NUI.Object.SetProperty(button.swigCPtr, Button.Property.DISABLED_UNSELECTED_BACKGROUND_VISUAL, new Tizen.NUI.PropertyValue((PropertyMap)newValue));
152             }
153         },
154         defaultValueCreator:(bindable) =>
155                 {
156                         var button = (Button)bindable;
157             Tizen.NUI.PropertyMap temp = new Tizen.NUI.PropertyMap();
158                         Tizen.NUI.Object.GetProperty(button.swigCPtr, Button.Property.DISABLED_UNSELECTED_BACKGROUND_VISUAL).Get(temp);
159                         return temp;
160                 });
161         /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
162         [EditorBrowsable(EditorBrowsableState.Never)]
163         public static readonly BindableProperty DisabledSelectedBackgroundVisualProperty = BindableProperty.Create("DisabledSelectedBackgroundVisual", typeof(PropertyMap), typeof(Button), new PropertyMap(), propertyChanged: (bindable, oldValue, newValue) =>
164         {
165             var button = (Button)bindable;
166             if (newValue != null)
167             {
168                 Tizen.NUI.Object.SetProperty(button.swigCPtr, Button.Property.DISABLED_SELECTED_BACKGROUND_VISUAL, new Tizen.NUI.PropertyValue((PropertyMap)newValue));
169             }
170         },
171         defaultValueCreator:(bindable) =>
172                 {
173                         var button = (Button)bindable;
174             Tizen.NUI.PropertyMap temp = new Tizen.NUI.PropertyMap();
175                         Tizen.NUI.Object.GetProperty(button.swigCPtr, Button.Property.DISABLED_SELECTED_BACKGROUND_VISUAL).Get(temp);
176                         return temp;
177                 });
178         /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
179         [EditorBrowsable(EditorBrowsableState.Never)]
180         public static readonly BindableProperty LabelRelativeAlignmentProperty = BindableProperty.Create("LabelRelativeAlignment", typeof(Align), typeof(Button), Align.End, propertyChanged: (bindable, oldValue, newValue) =>
181         {
182             var button = (Button)bindable;
183             string valueToString = "";
184             if (newValue != null)
185             {
186                 switch ((Align)newValue)
187                 {
188                     case Align.Begin: { valueToString = "BEGIN"; break; }
189                     case Align.End: { valueToString = "END"; break; }
190                     case Align.Top: { valueToString = "TOP"; break; }
191                     case Align.Bottom: { valueToString = "BOTTOM"; break; }
192                     default: { valueToString = "END";  break; }
193                 }
194                 Tizen.NUI.Object.SetProperty(button.swigCPtr, Button.Property.LABEL_RELATIVE_ALIGNMENT, new Tizen.NUI.PropertyValue(valueToString));
195             }
196         },
197         defaultValueCreator:(bindable) =>
198         {
199             var button = (Button)bindable;
200             string temp;
201             if (Tizen.NUI.Object.GetProperty(button.swigCPtr, Button.Property.LABEL_RELATIVE_ALIGNMENT).Get(out temp) == false)
202             {
203                 NUILog.Error("LabelRelativeAlignment get error!");
204             }
205             switch (temp)
206             {
207                 case "BEGIN":  return Align.Begin;
208                 case "END": return Align.End;
209                 case "TOP": return Align.Top;
210                 case "BOTTOM": return Align.Bottom;
211                 default: return Align.End;
212             }
213         });
214         /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
215         [EditorBrowsable(EditorBrowsableState.Never)]
216         public static readonly BindableProperty LabelPaddingProperty = BindableProperty.Create("LabelPadding", typeof(Vector4), typeof(Button), Vector4.Zero, propertyChanged: (bindable, oldValue, newValue) =>
217         {
218             var button = (Button)bindable;
219             if (newValue != null)
220             {
221                 Tizen.NUI.Object.SetProperty(button.swigCPtr, Button.Property.LABEL_PADDING, new Tizen.NUI.PropertyValue((Vector4)newValue));
222             }
223         },
224         defaultValueCreator:(bindable) =>
225                 {
226                         var button = (Button)bindable;
227             Vector4 temp = new Vector4(0.0f, 0.0f, 0.0f, 0.0f);
228                         Tizen.NUI.Object.GetProperty(button.swigCPtr, Button.Property.LABEL_PADDING).Get(temp);
229                         return temp;
230                 });
231         /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
232         [EditorBrowsable(EditorBrowsableState.Never)]
233         public static readonly BindableProperty ForegroundVisualPaddingProperty = BindableProperty.Create("ForegroundVisualPadding", typeof(Vector4), typeof(Button), Vector4.Zero, propertyChanged: (bindable, oldValue, newValue) =>
234         {
235             var button = (Button)bindable;
236             if (newValue != null)
237             {
238                 Tizen.NUI.Object.SetProperty(button.swigCPtr, Button.Property.FOREGROUND_VISUAL_PADDING, new Tizen.NUI.PropertyValue((Vector4)newValue));
239             }
240         },
241         defaultValueCreator:(bindable) =>
242                 {
243                         var button = (Button)bindable;
244             Vector4 temp = new Vector4(0.0f, 0.0f, 0.0f, 0.0f);
245                         Tizen.NUI.Object.GetProperty(button.swigCPtr, Button.Property.FOREGROUND_VISUAL_PADDING).Get(temp);
246                         return temp;
247                 });
248         /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
249         [EditorBrowsable(EditorBrowsableState.Never)]
250         public static readonly BindableProperty AutoRepeatingProperty = BindableProperty.Create("AutoRepeating", typeof(bool), typeof(Button), false, propertyChanged: (bindable, oldValue, newValue) =>
251         {
252             var button = (Button)bindable;
253             if (newValue != null)
254             {
255                 Tizen.NUI.Object.SetProperty(button.swigCPtr, Button.Property.AUTO_REPEATING, new Tizen.NUI.PropertyValue((bool)newValue));
256             }
257         },
258         defaultValueCreator:(bindable) =>
259                 {
260                         var button = (Button)bindable;
261             bool temp = false;
262                         Tizen.NUI.Object.GetProperty(button.swigCPtr, Button.Property.AUTO_REPEATING).Get(out temp);
263                         return temp;
264                 });
265         /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
266         [EditorBrowsable(EditorBrowsableState.Never)]
267         public static readonly BindableProperty InitialAutoRepeatingDelayProperty = BindableProperty.Create("InitialAutoRepeatingDelay", typeof(float), typeof(Button), default(float), propertyChanged: (bindable, oldValue, newValue) =>
268         {
269             var button = (Button)bindable;
270             if (newValue != null)
271             {
272                 Tizen.NUI.Object.SetProperty(button.swigCPtr, Button.Property.INITIAL_AUTO_REPEATING_DELAY, new Tizen.NUI.PropertyValue((float)newValue));
273             }
274         },
275         defaultValueCreator:(bindable) =>
276                 {
277                         var button = (Button)bindable;
278             float temp = 0.0f;
279                         Tizen.NUI.Object.GetProperty(button.swigCPtr, Button.Property.INITIAL_AUTO_REPEATING_DELAY).Get(out temp);
280                         return temp;
281                 });
282         /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
283         [EditorBrowsable(EditorBrowsableState.Never)]
284         public static readonly BindableProperty NextAutoRepeatingDelayProperty = BindableProperty.Create("NextAutoRepeatingDelay", typeof(float), typeof(Button), default(float), propertyChanged: (bindable, oldValue, newValue) =>
285         {
286             var button = (Button)bindable;
287             if (newValue != null)
288             {
289                 Tizen.NUI.Object.SetProperty(button.swigCPtr, Button.Property.NEXT_AUTO_REPEATING_DELAY, new Tizen.NUI.PropertyValue((float)newValue));
290             }
291         },
292         defaultValueCreator:(bindable) =>
293                 {
294                         var button = (Button)bindable;
295             float temp = 0.0f;
296                         Tizen.NUI.Object.GetProperty(button.swigCPtr, Button.Property.NEXT_AUTO_REPEATING_DELAY).Get(out temp);
297                         return temp;
298                 });
299         /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
300         [EditorBrowsable(EditorBrowsableState.Never)]
301         public static readonly BindableProperty TogglableProperty = BindableProperty.Create("Togglable", typeof(bool), typeof(Button), false, propertyChanged: (bindable, oldValue, newValue) =>
302         {
303             var button = (Button)bindable;
304             if (newValue != null)
305             {
306                 Tizen.NUI.Object.SetProperty(button.swigCPtr, Button.Property.TOGGLABLE, new Tizen.NUI.PropertyValue((bool)newValue));
307             }
308         },
309         defaultValueCreator:(bindable) =>
310                 {
311                         var button = (Button)bindable;
312                         bool temp = false;
313                         Tizen.NUI.Object.GetProperty(button.swigCPtr, Button.Property.TOGGLABLE).Get(out temp);
314                         return temp;
315                 });
316         /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
317         [EditorBrowsable(EditorBrowsableState.Never)]
318         public static readonly BindableProperty SelectedProperty = BindableProperty.Create("Selected", typeof(bool), typeof(Button), false, propertyChanged: (bindable, oldValue, newValue) =>
319         {
320             var button = (Button)bindable;
321             if (newValue != null)
322             {
323                 Tizen.NUI.Object.SetProperty(button.swigCPtr, Button.Property.SELECTED, new Tizen.NUI.PropertyValue((bool)newValue));
324             }
325         },
326         defaultValueCreator:(bindable) =>
327                 {
328                         var button = (Button)bindable;
329                         bool temp = false;
330                         Tizen.NUI.Object.GetProperty(button.swigCPtr, Button.Property.SELECTED).Get(out temp);
331                         return temp;
332                 });
333         /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
334         [EditorBrowsable(EditorBrowsableState.Never)]
335         public static readonly BindableProperty UnselectedColorProperty = BindableProperty.Create("UnselectedColor", typeof(Color), typeof(Button), Color.Transparent, propertyChanged: (bindable, oldValue, newValue) =>
336         {
337             var button = (Button)bindable;
338             if (newValue != null)
339             {
340                 Tizen.NUI.Object.SetProperty(button.swigCPtr, Button.Property.UNSELECTED_COLOR, new Tizen.NUI.PropertyValue((Color)newValue));
341             }
342         },
343         defaultValueCreator:(bindable) =>
344                 {
345                         var button = (Button)bindable;
346             Color temp = new Color(0.0f, 0.0f, 0.0f, 0.0f);
347                         Tizen.NUI.Object.GetProperty(button.swigCPtr, Button.Property.UNSELECTED_COLOR).Get(temp);
348                         return temp;
349                 });
350         /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
351         [EditorBrowsable(EditorBrowsableState.Never)]
352         public static readonly BindableProperty SelectedColorProperty = BindableProperty.Create("SelectedColor", typeof(Color), typeof(Button), Color.Transparent, propertyChanged: (bindable, oldValue, newValue) =>
353         {
354             var button = (Button)bindable;
355             if (newValue != null)
356             {
357                 Tizen.NUI.Object.SetProperty(button.swigCPtr, Button.Property.SELECTED_COLOR, new Tizen.NUI.PropertyValue((Color)newValue));
358             }
359         },
360         defaultValueCreator:(bindable) =>
361                 {
362                         var button = (Button)bindable;
363             Color temp = new Color(0.0f, 0.0f, 0.0f, 0.0f);
364                         Tizen.NUI.Object.GetProperty(button.swigCPtr, Button.Property.SELECTED_COLOR).Get(temp);
365                         return temp;
366                 });
367         /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
368         [EditorBrowsable(EditorBrowsableState.Never)]
369         public static readonly BindableProperty LabelProperty = BindableProperty.Create("Label", typeof(PropertyMap), typeof(Button), new PropertyMap(), propertyChanged: (bindable, oldValue, newValue) =>
370         {
371             var button = (Button)bindable;
372             if (newValue != null)
373             {
374                 Tizen.NUI.Object.SetProperty(button.swigCPtr, Button.Property.LABEL, new Tizen.NUI.PropertyValue((PropertyMap)newValue));
375             }
376         },
377         defaultValueCreator:(bindable) =>
378                 {
379                         var button = (Button)bindable;
380             Tizen.NUI.PropertyMap temp = new Tizen.NUI.PropertyMap();
381                         Tizen.NUI.Object.GetProperty(button.swigCPtr, Button.Property.LABEL).Get(temp);
382                         return temp;
383                 });
384         /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
385         [EditorBrowsable(EditorBrowsableState.Never)]
386         public static readonly BindableProperty LabelTextProperty = BindableProperty.Create("LabelText", typeof(string), typeof(Button), string.Empty, propertyChanged: (bindable, oldValue, newValue) =>
387         {
388             var button = (Button)bindable;
389             if (newValue != null)
390             {
391                 Tizen.NUI.Object.SetProperty(button.swigCPtr, Button.Property.LABEL, new Tizen.NUI.PropertyValue((string)newValue));
392             }
393         },
394         defaultValueCreator:(bindable) =>
395         {
396             var button = (Button)bindable;
397             Tizen.NUI.PropertyMap map = new Tizen.NUI.PropertyMap();
398             Tizen.NUI.Object.GetProperty(button.swigCPtr, Button.Property.LABEL).Get(map);
399             Tizen.NUI.PropertyValue value = map.Find( TextVisualProperty.Text, "Text");
400             string str = "";
401             value?.Get(out str);
402             return str;
403         });
404
405         private global::System.Runtime.InteropServices.HandleRef swigCPtr;
406
407         internal Button(global::System.IntPtr cPtr, bool cMemoryOwn) : base(NDalicPINVOKE.Button_SWIGUpcast(cPtr), cMemoryOwn)
408         {
409             swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
410         }
411
412         internal static global::System.Runtime.InteropServices.HandleRef getCPtr(Button obj)
413         {
414             return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
415         }
416
417         /// <summary>
418         /// To dispose the button instance.
419         /// </summary>
420         /// <since_tizen> 3 </since_tizen>
421         protected override void Dispose(DisposeTypes type)
422         {
423             if (disposed)
424             {
425                 return;
426             }
427
428             if (type == DisposeTypes.Explicit)
429             {
430                 //Called by User
431                 //Release your own managed resources here.
432                 //You should release all of your own disposable objects here.
433
434             }
435
436             //Release your own unmanaged resources here.
437             //You should not access any managed member here except static instance.
438             //because the execution order of Finalizes is non-deterministic.
439             if (this != null)
440             {
441                 DisConnectFromSignals();
442             }
443
444             if (swigCPtr.Handle != global::System.IntPtr.Zero)
445             {
446                 if (swigCMemOwn)
447                 {
448                     swigCMemOwn = false;
449                     NDalicPINVOKE.delete_Button(swigCPtr);
450                 }
451                 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
452             }
453
454             base.Dispose(type);
455         }
456
457         private void DisConnectFromSignals()
458         {
459             // Save current CPtr.
460             global::System.Runtime.InteropServices.HandleRef currentCPtr = swigCPtr;
461
462             // Use BaseHandle CPtr as current might have been deleted already in derived classes.
463             swigCPtr = GetBaseHandleCPtrHandleRef;
464
465             if (_stateChangedCallback != null)
466             {
467                 StateChangedSignal().Disconnect(_stateChangedCallback);
468             }
469
470             if (_releasedCallback != null)
471             {
472                 ReleasedSignal().Disconnect(_releasedCallback);
473             }
474
475             if (_pressedCallback != null)
476             {
477                 this.PressedSignal().Disconnect(_pressedCallback);
478             }
479
480             if (_clickedCallback != null)
481             {
482                 ClickedSignal().Disconnect(_clickedCallback);
483             }
484
485             // BaseHandle CPtr is used in Registry and there is danger of deletion if we keep using it here.
486             // Restore current CPtr.
487             swigCPtr = currentCPtr;
488         }
489
490
491         private EventHandlerWithReturnType<object, EventArgs, bool> _clickedEventHandler;
492         [UnmanagedFunctionPointer(CallingConvention.StdCall)]
493         private delegate bool ClickedCallbackType(global::System.IntPtr data);
494         private ClickedCallbackType _clickedCallback;
495
496         /// <summary>
497         /// The Clicked event will be triggered when the button is touched and the touch point doesn't leave the boundary of the button.
498         /// </summary>
499         /// <since_tizen> 3 </since_tizen>
500         public event EventHandlerWithReturnType<object, EventArgs, bool> Clicked
501         {
502             add
503             {
504                 if (_clickedEventHandler == null)
505                 {
506                     _clickedCallback = OnClicked;
507                     ClickedSignal().Connect(_clickedCallback);
508                 }
509
510                 _clickedEventHandler += value;
511             }
512
513             remove
514             {
515                 _clickedEventHandler -= value;
516
517                 if (_clickedEventHandler == null && ClickedSignal().Empty() == false)
518                 {
519                     ClickedSignal().Disconnect(_clickedCallback);
520                 }
521             }
522         }
523
524
525         private bool OnClicked(IntPtr data)
526         {
527             if (_clickedEventHandler != null)
528             {
529                 return _clickedEventHandler(this, null);
530             }
531             return false;
532         }
533
534
535
536         private EventHandlerWithReturnType<object, EventArgs, bool> _pressedEventHandler;
537         [UnmanagedFunctionPointer(CallingConvention.StdCall)]
538         private delegate bool PressedCallbackType(global::System.IntPtr data);
539         private PressedCallbackType _pressedCallback;
540
541         /// <summary>
542         /// The Pressed event will be triggered when the button is touched.
543         /// </summary>
544         /// <since_tizen> 3 </since_tizen>
545         public event EventHandlerWithReturnType<object, EventArgs, bool> Pressed
546         {
547             add
548             {
549                 if (_pressedEventHandler == null)
550                 {
551                     _pressedCallback = OnPressed;
552                     PressedSignal().Connect(_pressedCallback);
553                 }
554
555                 _pressedEventHandler += value;
556             }
557
558             remove
559             {
560                 _pressedEventHandler -= value;
561
562                 if (_pressedEventHandler == null && PressedSignal().Empty() == false)
563                 {
564                     this.PressedSignal().Disconnect(_pressedCallback);
565                 }
566             }
567         }
568
569         private bool OnPressed(IntPtr data)
570         {
571             if (_pressedEventHandler != null)
572             {
573                 return _pressedEventHandler(this, null);
574             }
575             return false;
576         }
577
578
579
580         private EventHandlerWithReturnType<object, EventArgs, bool> _releasedEventHandler;
581         [UnmanagedFunctionPointer(CallingConvention.StdCall)]
582         private delegate bool ReleasedCallbackType(global::System.IntPtr data);
583         private ReleasedCallbackType _releasedCallback;
584
585         /// <summary>
586         /// The Released event will be triggered when the button is touched and the touch point leaves the boundary of the button.
587         /// </summary>
588         /// <since_tizen> 3 </since_tizen>
589         public event EventHandlerWithReturnType<object, EventArgs, bool> Released
590         {
591             add
592             {
593                 if (_releasedEventHandler == null)
594                 {
595                     _releasedCallback = OnReleased;
596                     ReleasedSignal().Connect(_releasedCallback);
597                 }
598                 _releasedEventHandler += value;
599             }
600
601             remove
602             {
603                 _releasedEventHandler -= value;
604
605                 if (_releasedEventHandler == null && ReleasedSignal().Empty() == false)
606                 {
607                     ReleasedSignal().Disconnect(_releasedCallback);
608                 }
609
610             }
611         }
612
613         private bool OnReleased(IntPtr data)
614         {
615             if (_releasedEventHandler != null)
616             {
617                 return _releasedEventHandler(this, null);
618             }
619             return false;
620         }
621
622
623         private EventHandlerWithReturnType<object, EventArgs, bool> _stateChangedEventHandler;
624         [UnmanagedFunctionPointer(CallingConvention.StdCall)]
625         private delegate bool StateChangedCallback(global::System.IntPtr data);
626         private StateChangedCallback _stateChangedCallback;
627
628         /// <summary>
629         /// The StateChanged event will be triggered when the button's state is changed.
630         /// </summary>
631         /// <since_tizen> 3 </since_tizen>
632         public event EventHandlerWithReturnType<object, EventArgs, bool> StateChanged
633         {
634             add
635             {
636                 if (_stateChangedEventHandler == null)
637                 {
638                     _stateChangedCallback = OnStateChanged;
639                     StateChangedSignal().Connect(_stateChangedCallback);
640                 }
641
642                 _stateChangedEventHandler += value;
643             }
644
645             remove
646             {
647                 _stateChangedEventHandler -= value;
648
649                 if (_stateChangedEventHandler == null && StateChangedSignal().Empty() == false)
650                 {
651                     StateChangedSignal().Disconnect(_stateChangedCallback);
652                 }
653             }
654         }
655
656         private bool OnStateChanged(IntPtr data)
657         {
658             if (_stateChangedEventHandler != null)
659             {
660                 return _stateChangedEventHandler(this, null);
661             }
662             return false;
663         }
664
665
666         /// <summary>
667         /// Gets or sets the unselected button foreground or icon visual.
668         /// </summary>
669         /// <since_tizen> 3 </since_tizen>
670         public Tizen.NUI.PropertyMap UnselectedVisual
671         {
672             get
673             {
674                 return (PropertyMap)GetValue(UnselectedVisualProperty);
675             }
676             set
677             {
678                 SetValue(UnselectedVisualProperty, value);
679             }
680         }
681
682         /// <summary>
683         /// Gets or sets the selected button foreground or icon visual.
684         /// </summary>
685         /// <since_tizen> 3 </since_tizen>
686         public Tizen.NUI.PropertyMap SelectedVisual
687         {
688             get
689             {
690                 return (PropertyMap)GetValue(SelectedVisualProperty);
691             }
692             set
693             {
694                 SetValue(SelectedVisualProperty, value);
695             }
696         }
697
698         /// <summary>
699         /// Gets or sets the disabled selected state foreground or icon button visual.
700         /// </summary>
701         /// <since_tizen> 3 </since_tizen>
702         public Tizen.NUI.PropertyMap DisabledSelectedVisual
703         {
704             get
705             {
706                 return (PropertyMap)GetValue(DisabledSelectedVisualProperty);
707             }
708             set
709             {
710                 SetValue(DisabledSelectedVisualProperty, value);
711             }
712         }
713
714         /// <summary>
715         /// Gets or sets the disabled unselected state foreground or icon visual.
716         /// </summary>
717         /// <since_tizen> 3 </since_tizen>
718         public Tizen.NUI.PropertyMap DisabledUnselectedVisual
719         {
720             get
721             {
722                 return (PropertyMap)GetValue(DisabledUnselectedVisualProperty);
723             }
724             set
725             {
726                 SetValue(DisabledUnselectedVisualProperty, value);
727             }
728         }
729
730         /// <summary>
731         /// Gets or sets the disabled unselected state background button visual.
732         /// </summary>
733         /// <since_tizen> 3 </since_tizen>
734         public Tizen.NUI.PropertyMap UnselectedBackgroundVisual
735         {
736             get
737             {
738                 return (PropertyMap)GetValue(UnselectedBackgroundVisualProperty);
739             }
740             set
741             {
742                 SetValue(UnselectedBackgroundVisualProperty, value);
743             }
744         }
745
746         /// <summary>
747         /// Gets or sets the selected background button visual.
748         /// </summary>
749         /// <since_tizen> 3 </since_tizen>
750         public Tizen.NUI.PropertyMap SelectedBackgroundVisual
751         {
752             get
753             {
754                 return (PropertyMap)GetValue(SelectedBackgroundVisualProperty);
755             }
756             set
757             {
758                 SetValue(SelectedBackgroundVisualProperty, value);
759             }
760         }
761
762         /// <summary>
763         /// Gets or sets the disabled while unselected background button visual.
764         /// </summary>
765         /// <since_tizen> 3 </since_tizen>
766         public Tizen.NUI.PropertyMap DisabledUnselectedBackgroundVisual
767         {
768             get
769             {
770                 return (PropertyMap)GetValue(DisabledUnselectedBackgroundVisualProperty);
771             }
772             set
773             {
774                 SetValue(DisabledUnselectedBackgroundVisualProperty, value);
775             }
776         }
777
778         /// <summary>
779         /// Gets or sets the disabled while selected background button visual.
780         /// </summary>
781         /// <since_tizen> 3 </since_tizen>
782         public Tizen.NUI.PropertyMap DisabledSelectedBackgroundVisual
783         {
784             get
785             {
786                 return (PropertyMap)GetValue(DisabledSelectedBackgroundVisualProperty);
787             }
788             set
789             {
790                 SetValue(DisabledSelectedBackgroundVisualProperty, value);
791             }
792         }
793
794         /// <summary>
795         /// Gets or sets the position of the the label in relation to the foreground or icon, if both present.
796         /// </summary>
797         /// <since_tizen> 3 </since_tizen>
798         public Align LabelRelativeAlignment
799         {
800             get
801             {
802                 return (Align)GetValue(LabelRelativeAlignmentProperty);
803             }
804             set
805             {
806                 SetValue(LabelRelativeAlignmentProperty, value);
807             }
808         }
809
810         /// <summary>
811         /// Gets or sets the padding around the text.
812         /// </summary>
813         /// <since_tizen> 3 </since_tizen>
814         public Vector4 LabelPadding
815         {
816             get
817             {
818                 return (Vector4)GetValue(LabelPaddingProperty);
819             }
820             set
821             {
822                 SetValue(LabelPaddingProperty, value);
823             }
824         }
825
826         /// <summary>
827         /// Gets or sets the padding around the foreground visual.
828         /// </summary>
829         /// <since_tizen> 3 </since_tizen>
830         public Vector4 ForegroundVisualPadding
831         {
832             get
833             {
834                 return (Vector4)GetValue(ForegroundVisualPaddingProperty);
835             }
836             set
837             {
838                 SetValue(ForegroundVisualPaddingProperty, value);
839             }
840         }
841
842         internal new class Property
843         {
844             internal static readonly int UNSELECTED_VISUAL = NDalicManualPINVOKE.Button_Property_UNSELECTED_VISUAL_get();
845             internal static readonly int SELECTED_VISUAL = NDalicManualPINVOKE.Button_Property_SELECTED_VISUAL_get();
846             internal static readonly int DISABLED_SELECTED_VISUAL = NDalicManualPINVOKE.Button_Property_DISABLED_SELECTED_VISUAL_get();
847             internal static readonly int DISABLED_UNSELECTED_VISUAL = NDalicManualPINVOKE.Button_Property_DISABLED_UNSELECTED_VISUAL_get();
848             internal static readonly int UNSELECTED_BACKGROUND_VISUAL = NDalicManualPINVOKE.Button_Property_UNSELECTED_BACKGROUND_VISUAL_get();
849             internal static readonly int SELECTED_BACKGROUND_VISUAL = NDalicManualPINVOKE.Button_Property_SELECTED_BACKGROUND_VISUAL_get();
850             internal static readonly int DISABLED_UNSELECTED_BACKGROUND_VISUAL = NDalicManualPINVOKE.Button_Property_DISABLED_UNSELECTED_BACKGROUND_VISUAL_get();
851             internal static readonly int DISABLED_SELECTED_BACKGROUND_VISUAL = NDalicManualPINVOKE.Button_Property_DISABLED_SELECTED_BACKGROUND_VISUAL_get();
852             internal static readonly int LABEL_RELATIVE_ALIGNMENT = NDalicManualPINVOKE.Button_Property_LABEL_RELATIVE_ALIGNMENT_get();
853             internal static readonly int LABEL_PADDING = NDalicManualPINVOKE.Button_Property_LABEL_PADDING_get();
854             internal static readonly int FOREGROUND_VISUAL_PADDING = NDalicManualPINVOKE.Button_Property_VISUAL_PADDING_get();
855             internal static readonly int AUTO_REPEATING = NDalicPINVOKE.Button_Property_AUTO_REPEATING_get();
856             internal static readonly int INITIAL_AUTO_REPEATING_DELAY = NDalicPINVOKE.Button_Property_INITIAL_AUTO_REPEATING_DELAY_get();
857             internal static readonly int NEXT_AUTO_REPEATING_DELAY = NDalicPINVOKE.Button_Property_NEXT_AUTO_REPEATING_DELAY_get();
858             internal static readonly int TOGGLABLE = NDalicPINVOKE.Button_Property_TOGGLABLE_get();
859             internal static readonly int SELECTED = NDalicPINVOKE.Button_Property_SELECTED_get();
860             internal static readonly int UNSELECTED_COLOR = NDalicPINVOKE.Button_Property_UNSELECTED_COLOR_get();
861             internal static readonly int SELECTED_COLOR = NDalicPINVOKE.Button_Property_SELECTED_COLOR_get();
862             internal static readonly int LABEL = NDalicPINVOKE.Button_Property_LABEL_get();
863         }
864
865         /// <summary>
866         /// Creates an uninitialized button.<br />
867         /// Only the derived versions can be instantiated.<br />
868         /// </summary>
869         /// <since_tizen> 3 </since_tizen>
870         public Button() : this(NDalicPINVOKE.new_Button__SWIG_0(), true)
871         {
872             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
873         }
874
875         internal ButtonSignal PressedSignal()
876         {
877             ButtonSignal ret = new ButtonSignal(NDalicPINVOKE.Button_PressedSignal(swigCPtr), false);
878             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
879             return ret;
880         }
881
882         internal ButtonSignal ReleasedSignal()
883         {
884             ButtonSignal ret = new ButtonSignal(NDalicPINVOKE.Button_ReleasedSignal(swigCPtr), false);
885             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
886             return ret;
887         }
888
889         internal ButtonSignal ClickedSignal()
890         {
891             ButtonSignal ret = new ButtonSignal(NDalicPINVOKE.Button_ClickedSignal(swigCPtr), false);
892             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
893             return ret;
894         }
895
896         internal ButtonSignal StateChangedSignal()
897         {
898             ButtonSignal ret = new ButtonSignal(NDalicPINVOKE.Button_StateChangedSignal(swigCPtr), false);
899             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
900             return ret;
901         }
902
903         /// <summary>
904         /// If the autorepeating property is set to true, then the togglable property is set to false.
905         /// </summary>
906         /// <since_tizen> 3 </since_tizen>
907         public bool AutoRepeating
908         {
909             get
910             {
911                 return (bool)GetValue(AutoRepeatingProperty);
912             }
913             set
914             {
915                 SetValue(AutoRepeatingProperty, value);
916             }
917         }
918
919         /// <summary>
920         /// By default, this value is set to 0.15 seconds.
921         /// </summary>
922         /// <since_tizen> 3 </since_tizen>
923         public float InitialAutoRepeatingDelay
924         {
925             get
926             {
927                 return (float)GetValue(InitialAutoRepeatingDelayProperty);
928             }
929             set
930             {
931                 SetValue(InitialAutoRepeatingDelayProperty, value);
932             }
933         }
934
935         /// <summary>
936         /// By default, this value is set to 0.05 seconds.
937         /// </summary>
938         /// <since_tizen> 3 </since_tizen>
939         public float NextAutoRepeatingDelay
940         {
941             get
942             {
943                 return (float)GetValue(NextAutoRepeatingDelayProperty);
944             }
945             set
946             {
947                 SetValue(NextAutoRepeatingDelayProperty, value);
948             }
949         }
950
951         /// <summary>
952         /// If the togglable property is set to true, then the autorepeating property is set to false.
953         /// </summary>
954         /// <since_tizen> 3 </since_tizen>
955         public bool Togglable
956         {
957             get
958             {
959                 return (bool)GetValue(TogglableProperty);
960             }
961             set
962             {
963                 SetValue(TogglableProperty, value);
964             }
965         }
966
967         /// <summary>
968         /// Gets or sets the togglable button as either selected or unselected, togglable property must be set to true.
969         /// </summary>
970         /// <since_tizen> 3 </since_tizen>
971         public bool Selected
972         {
973             get
974             {
975                 return (bool)GetValue(SelectedProperty);
976             }
977             set
978             {
979                 SetValue(SelectedProperty, value);
980             }
981         }
982
983         /// <summary>
984         /// Gets or sets the unselected color.
985         /// </summary>
986         /// <since_tizen> 3 </since_tizen>
987         public Color UnselectedColor
988         {
989             get
990             {
991                 return (Color)GetValue(UnselectedColorProperty);
992             }
993             set
994             {
995                 SetValue(UnselectedColorProperty, value);
996             }
997         }
998
999         /// <summary>
1000         /// Gets or sets the selected color.
1001         /// </summary>
1002         /// <since_tizen> 3 </since_tizen>
1003         public Color SelectedColor
1004         {
1005             get
1006             {
1007                 return (Color)GetValue(SelectedColorProperty);
1008             }
1009             set
1010             {
1011                 SetValue(SelectedColorProperty, value);
1012             }
1013         }
1014
1015         /// <summary>
1016         /// Gets or sets the label.
1017         /// </summary>
1018         /// <since_tizen> 3 </since_tizen>
1019         public Tizen.NUI.PropertyMap Label
1020         {
1021             get
1022             {
1023                 return (PropertyMap)GetValue(LabelProperty);
1024             }
1025             set
1026             {
1027                 SetValue(LabelProperty, value);
1028             }
1029         }
1030
1031         /// <summary>
1032         /// Gets or sets the text of the label.
1033         /// </summary>
1034         /// <since_tizen> 3 </since_tizen>
1035         public string LabelText
1036         {
1037             get
1038             {
1039                 return (string)GetValue(LabelTextProperty);
1040             }
1041             set
1042             {
1043                 SetValue(LabelTextProperty, value);
1044             }
1045         }
1046
1047         /// <summary>
1048         /// Enumeration for describing the position, the text label can be, in relation to the control (and foreground/icon).
1049         /// </summary>
1050         /// <since_tizen> 3 </since_tizen>
1051         public enum Align
1052         {
1053             /// <summary>
1054             /// At the start of the control before the foreground or icon.
1055             /// </summary>
1056             Begin,
1057             /// <summary>
1058             /// At the end of the control after the foreground or icon.
1059             /// </summary>
1060             End,
1061             /// <summary>
1062             /// At the top of the control above the foreground or icon.
1063             /// </summary>
1064             Top,
1065             /// <summary>
1066             /// At the bottom of the control below the foreground or icon.
1067             /// </summary>
1068             Bottom
1069         }
1070
1071     }
1072
1073 }