2 * Copyright(c) 2017 Samsung Electronics Co., Ltd.
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
18 using System.ComponentModel;
19 using System.Runtime.InteropServices;
20 using Tizen.NUI.BaseComponents;
21 using Tizen.NUI.Binding;
23 namespace Tizen.NUI.UIComponents
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 />
38 /// <since_tizen> 3 </since_tizen>
39 [ContentProperty("LabelText")]
40 public class Button : View
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) =>
46 var button = (Button)bindable;
49 Tizen.NUI.Object.SetProperty(button.swigCPtr, Button.Property.UNSELECTED_VISUAL, new Tizen.NUI.PropertyValue((PropertyMap)newValue));
52 defaultValueCreator:(bindable) =>
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);
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) =>
63 var button = (Button)bindable;
66 Tizen.NUI.Object.SetProperty(button.swigCPtr, Button.Property.SELECTED_VISUAL, new Tizen.NUI.PropertyValue((PropertyMap)newValue));
69 defaultValueCreator:(bindable) =>
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);
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) =>
80 var button = (Button)bindable;
83 Tizen.NUI.Object.SetProperty(button.swigCPtr, Button.Property.DISABLED_SELECTED_VISUAL, new Tizen.NUI.PropertyValue((PropertyMap)newValue));
86 defaultValueCreator:(bindable) =>
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);
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) =>
97 var button = (Button)bindable;
100 Tizen.NUI.Object.SetProperty(button.swigCPtr, Button.Property.DISABLED_UNSELECTED_VISUAL, new Tizen.NUI.PropertyValue((PropertyMap)newValue));
103 defaultValueCreator:(bindable) =>
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);
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) =>
114 var button = (Button)bindable;
115 if (newValue != null)
117 Tizen.NUI.Object.SetProperty(button.swigCPtr, Button.Property.UNSELECTED_BACKGROUND_VISUAL, new Tizen.NUI.PropertyValue((PropertyMap)newValue));
120 defaultValueCreator:(bindable) =>
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);
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) =>
131 var button = (Button)bindable;
132 if (newValue != null)
134 Tizen.NUI.Object.SetProperty(button.swigCPtr, Button.Property.SELECTED_BACKGROUND_VISUAL, new Tizen.NUI.PropertyValue((PropertyMap)newValue));
137 defaultValueCreator:(bindable) =>
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);
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) =>
148 var button = (Button)bindable;
149 if (newValue != null)
151 Tizen.NUI.Object.SetProperty(button.swigCPtr, Button.Property.DISABLED_UNSELECTED_BACKGROUND_VISUAL, new Tizen.NUI.PropertyValue((PropertyMap)newValue));
154 defaultValueCreator:(bindable) =>
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);
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) =>
165 var button = (Button)bindable;
166 if (newValue != null)
168 Tizen.NUI.Object.SetProperty(button.swigCPtr, Button.Property.DISABLED_SELECTED_BACKGROUND_VISUAL, new Tizen.NUI.PropertyValue((PropertyMap)newValue));
171 defaultValueCreator:(bindable) =>
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);
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) =>
182 var button = (Button)bindable;
183 string valueToString = "";
184 if (newValue != null)
186 switch ((Align)newValue)
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; }
194 Tizen.NUI.Object.SetProperty(button.swigCPtr, Button.Property.LABEL_RELATIVE_ALIGNMENT, new Tizen.NUI.PropertyValue(valueToString));
197 defaultValueCreator:(bindable) =>
199 var button = (Button)bindable;
201 if (Tizen.NUI.Object.GetProperty(button.swigCPtr, Button.Property.LABEL_RELATIVE_ALIGNMENT).Get(out temp) == false)
203 NUILog.Error("LabelRelativeAlignment get error!");
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;
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) =>
218 var button = (Button)bindable;
219 if (newValue != null)
221 Tizen.NUI.Object.SetProperty(button.swigCPtr, Button.Property.LABEL_PADDING, new Tizen.NUI.PropertyValue((Vector4)newValue));
224 defaultValueCreator:(bindable) =>
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);
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) =>
235 var button = (Button)bindable;
236 if (newValue != null)
238 Tizen.NUI.Object.SetProperty(button.swigCPtr, Button.Property.FOREGROUND_VISUAL_PADDING, new Tizen.NUI.PropertyValue((Vector4)newValue));
241 defaultValueCreator:(bindable) =>
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);
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) =>
252 var button = (Button)bindable;
253 if (newValue != null)
255 Tizen.NUI.Object.SetProperty(button.swigCPtr, Button.Property.AUTO_REPEATING, new Tizen.NUI.PropertyValue((bool)newValue));
258 defaultValueCreator:(bindable) =>
260 var button = (Button)bindable;
262 Tizen.NUI.Object.GetProperty(button.swigCPtr, Button.Property.AUTO_REPEATING).Get(out temp);
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) =>
269 var button = (Button)bindable;
270 if (newValue != null)
272 Tizen.NUI.Object.SetProperty(button.swigCPtr, Button.Property.INITIAL_AUTO_REPEATING_DELAY, new Tizen.NUI.PropertyValue((float)newValue));
275 defaultValueCreator:(bindable) =>
277 var button = (Button)bindable;
279 Tizen.NUI.Object.GetProperty(button.swigCPtr, Button.Property.INITIAL_AUTO_REPEATING_DELAY).Get(out temp);
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) =>
286 var button = (Button)bindable;
287 if (newValue != null)
289 Tizen.NUI.Object.SetProperty(button.swigCPtr, Button.Property.NEXT_AUTO_REPEATING_DELAY, new Tizen.NUI.PropertyValue((float)newValue));
292 defaultValueCreator:(bindable) =>
294 var button = (Button)bindable;
296 Tizen.NUI.Object.GetProperty(button.swigCPtr, Button.Property.NEXT_AUTO_REPEATING_DELAY).Get(out temp);
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) =>
303 var button = (Button)bindable;
304 if (newValue != null)
306 Tizen.NUI.Object.SetProperty(button.swigCPtr, Button.Property.TOGGLABLE, new Tizen.NUI.PropertyValue((bool)newValue));
309 defaultValueCreator:(bindable) =>
311 var button = (Button)bindable;
313 Tizen.NUI.Object.GetProperty(button.swigCPtr, Button.Property.TOGGLABLE).Get(out temp);
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) =>
320 var button = (Button)bindable;
321 if (newValue != null)
323 Tizen.NUI.Object.SetProperty(button.swigCPtr, Button.Property.SELECTED, new Tizen.NUI.PropertyValue((bool)newValue));
326 defaultValueCreator:(bindable) =>
328 var button = (Button)bindable;
330 Tizen.NUI.Object.GetProperty(button.swigCPtr, Button.Property.SELECTED).Get(out temp);
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) =>
337 var button = (Button)bindable;
338 if (newValue != null)
340 Tizen.NUI.Object.SetProperty(button.swigCPtr, Button.Property.UNSELECTED_COLOR, new Tizen.NUI.PropertyValue((Color)newValue));
343 defaultValueCreator:(bindable) =>
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);
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) =>
354 var button = (Button)bindable;
355 if (newValue != null)
357 Tizen.NUI.Object.SetProperty(button.swigCPtr, Button.Property.SELECTED_COLOR, new Tizen.NUI.PropertyValue((Color)newValue));
360 defaultValueCreator:(bindable) =>
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);
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) =>
371 var button = (Button)bindable;
372 if (newValue != null)
374 Tizen.NUI.Object.SetProperty(button.swigCPtr, Button.Property.LABEL, new Tizen.NUI.PropertyValue((PropertyMap)newValue));
377 defaultValueCreator:(bindable) =>
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);
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) =>
388 var button = (Button)bindable;
389 if (newValue != null)
391 Tizen.NUI.Object.SetProperty(button.swigCPtr, Button.Property.LABEL, new Tizen.NUI.PropertyValue((string)newValue));
394 defaultValueCreator:(bindable) =>
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");
405 private global::System.Runtime.InteropServices.HandleRef swigCPtr;
407 internal Button(global::System.IntPtr cPtr, bool cMemoryOwn) : base(NDalicPINVOKE.Button_SWIGUpcast(cPtr), cMemoryOwn)
409 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
412 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(Button obj)
414 return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
418 /// To dispose the button instance.
420 /// <since_tizen> 3 </since_tizen>
421 protected override void Dispose(DisposeTypes type)
428 if (type == DisposeTypes.Explicit)
431 //Release your own managed resources here.
432 //You should release all of your own disposable objects here.
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.
441 DisConnectFromSignals();
444 if (swigCPtr.Handle != global::System.IntPtr.Zero)
449 NDalicPINVOKE.delete_Button(swigCPtr);
451 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
457 private void DisConnectFromSignals()
459 // Save current CPtr.
460 global::System.Runtime.InteropServices.HandleRef currentCPtr = swigCPtr;
462 // Use BaseHandle CPtr as current might have been deleted already in derived classes.
463 swigCPtr = GetBaseHandleCPtrHandleRef;
465 if (_stateChangedCallback != null)
467 StateChangedSignal().Disconnect(_stateChangedCallback);
470 if (_releasedCallback != null)
472 ReleasedSignal().Disconnect(_releasedCallback);
475 if (_pressedCallback != null)
477 this.PressedSignal().Disconnect(_pressedCallback);
480 if (_clickedCallback != null)
482 ClickedSignal().Disconnect(_clickedCallback);
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;
491 private EventHandlerWithReturnType<object, EventArgs, bool> _clickedEventHandler;
492 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
493 private delegate bool ClickedCallbackType(global::System.IntPtr data);
494 private ClickedCallbackType _clickedCallback;
497 /// The Clicked event will be triggered when the button is touched and the touch point doesn't leave the boundary of the button.
499 /// <since_tizen> 3 </since_tizen>
500 public event EventHandlerWithReturnType<object, EventArgs, bool> Clicked
504 if (_clickedEventHandler == null)
506 _clickedCallback = OnClicked;
507 ClickedSignal().Connect(_clickedCallback);
510 _clickedEventHandler += value;
515 _clickedEventHandler -= value;
517 if (_clickedEventHandler == null && ClickedSignal().Empty() == false)
519 ClickedSignal().Disconnect(_clickedCallback);
525 private bool OnClicked(IntPtr data)
527 if (_clickedEventHandler != null)
529 return _clickedEventHandler(this, null);
536 private EventHandlerWithReturnType<object, EventArgs, bool> _pressedEventHandler;
537 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
538 private delegate bool PressedCallbackType(global::System.IntPtr data);
539 private PressedCallbackType _pressedCallback;
542 /// The Pressed event will be triggered when the button is touched.
544 /// <since_tizen> 3 </since_tizen>
545 public event EventHandlerWithReturnType<object, EventArgs, bool> Pressed
549 if (_pressedEventHandler == null)
551 _pressedCallback = OnPressed;
552 PressedSignal().Connect(_pressedCallback);
555 _pressedEventHandler += value;
560 _pressedEventHandler -= value;
562 if (_pressedEventHandler == null && PressedSignal().Empty() == false)
564 this.PressedSignal().Disconnect(_pressedCallback);
569 private bool OnPressed(IntPtr data)
571 if (_pressedEventHandler != null)
573 return _pressedEventHandler(this, null);
580 private EventHandlerWithReturnType<object, EventArgs, bool> _releasedEventHandler;
581 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
582 private delegate bool ReleasedCallbackType(global::System.IntPtr data);
583 private ReleasedCallbackType _releasedCallback;
586 /// The Released event will be triggered when the button is touched and the touch point leaves the boundary of the button.
588 /// <since_tizen> 3 </since_tizen>
589 public event EventHandlerWithReturnType<object, EventArgs, bool> Released
593 if (_releasedEventHandler == null)
595 _releasedCallback = OnReleased;
596 ReleasedSignal().Connect(_releasedCallback);
598 _releasedEventHandler += value;
603 _releasedEventHandler -= value;
605 if (_releasedEventHandler == null && ReleasedSignal().Empty() == false)
607 ReleasedSignal().Disconnect(_releasedCallback);
613 private bool OnReleased(IntPtr data)
615 if (_releasedEventHandler != null)
617 return _releasedEventHandler(this, null);
623 private EventHandlerWithReturnType<object, EventArgs, bool> _stateChangedEventHandler;
624 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
625 private delegate bool StateChangedCallback(global::System.IntPtr data);
626 private StateChangedCallback _stateChangedCallback;
629 /// The StateChanged event will be triggered when the button's state is changed.
631 /// <since_tizen> 3 </since_tizen>
632 public event EventHandlerWithReturnType<object, EventArgs, bool> StateChanged
636 if (_stateChangedEventHandler == null)
638 _stateChangedCallback = OnStateChanged;
639 StateChangedSignal().Connect(_stateChangedCallback);
642 _stateChangedEventHandler += value;
647 _stateChangedEventHandler -= value;
649 if (_stateChangedEventHandler == null && StateChangedSignal().Empty() == false)
651 StateChangedSignal().Disconnect(_stateChangedCallback);
656 private bool OnStateChanged(IntPtr data)
658 if (_stateChangedEventHandler != null)
660 return _stateChangedEventHandler(this, null);
667 /// Gets or sets the unselected button foreground or icon visual.
669 /// <since_tizen> 3 </since_tizen>
670 public Tizen.NUI.PropertyMap UnselectedVisual
674 return (PropertyMap)GetValue(UnselectedVisualProperty);
678 SetValue(UnselectedVisualProperty, value);
683 /// Gets or sets the selected button foreground or icon visual.
685 /// <since_tizen> 3 </since_tizen>
686 public Tizen.NUI.PropertyMap SelectedVisual
690 return (PropertyMap)GetValue(SelectedVisualProperty);
694 SetValue(SelectedVisualProperty, value);
699 /// Gets or sets the disabled selected state foreground or icon button visual.
701 /// <since_tizen> 3 </since_tizen>
702 public Tizen.NUI.PropertyMap DisabledSelectedVisual
706 return (PropertyMap)GetValue(DisabledSelectedVisualProperty);
710 SetValue(DisabledSelectedVisualProperty, value);
715 /// Gets or sets the disabled unselected state foreground or icon visual.
717 /// <since_tizen> 3 </since_tizen>
718 public Tizen.NUI.PropertyMap DisabledUnselectedVisual
722 return (PropertyMap)GetValue(DisabledUnselectedVisualProperty);
726 SetValue(DisabledUnselectedVisualProperty, value);
731 /// Gets or sets the disabled unselected state background button visual.
733 /// <since_tizen> 3 </since_tizen>
734 public Tizen.NUI.PropertyMap UnselectedBackgroundVisual
738 return (PropertyMap)GetValue(UnselectedBackgroundVisualProperty);
742 SetValue(UnselectedBackgroundVisualProperty, value);
747 /// Gets or sets the selected background button visual.
749 /// <since_tizen> 3 </since_tizen>
750 public Tizen.NUI.PropertyMap SelectedBackgroundVisual
754 return (PropertyMap)GetValue(SelectedBackgroundVisualProperty);
758 SetValue(SelectedBackgroundVisualProperty, value);
763 /// Gets or sets the disabled while unselected background button visual.
765 /// <since_tizen> 3 </since_tizen>
766 public Tizen.NUI.PropertyMap DisabledUnselectedBackgroundVisual
770 return (PropertyMap)GetValue(DisabledUnselectedBackgroundVisualProperty);
774 SetValue(DisabledUnselectedBackgroundVisualProperty, value);
779 /// Gets or sets the disabled while selected background button visual.
781 /// <since_tizen> 3 </since_tizen>
782 public Tizen.NUI.PropertyMap DisabledSelectedBackgroundVisual
786 return (PropertyMap)GetValue(DisabledSelectedBackgroundVisualProperty);
790 SetValue(DisabledSelectedBackgroundVisualProperty, value);
795 /// Gets or sets the position of the the label in relation to the foreground or icon, if both present.
797 /// <since_tizen> 3 </since_tizen>
798 public Align LabelRelativeAlignment
802 return (Align)GetValue(LabelRelativeAlignmentProperty);
806 SetValue(LabelRelativeAlignmentProperty, value);
811 /// Gets or sets the padding around the text.
813 /// <since_tizen> 3 </since_tizen>
814 public Vector4 LabelPadding
818 return (Vector4)GetValue(LabelPaddingProperty);
822 SetValue(LabelPaddingProperty, value);
827 /// Gets or sets the padding around the foreground visual.
829 /// <since_tizen> 3 </since_tizen>
830 public Vector4 ForegroundVisualPadding
834 return (Vector4)GetValue(ForegroundVisualPaddingProperty);
838 SetValue(ForegroundVisualPaddingProperty, value);
842 internal new class Property
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();
866 /// Creates an uninitialized button.<br />
867 /// Only the derived versions can be instantiated.<br />
869 /// <since_tizen> 3 </since_tizen>
870 public Button() : this(NDalicPINVOKE.new_Button__SWIG_0(), true)
872 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
875 internal ButtonSignal PressedSignal()
877 ButtonSignal ret = new ButtonSignal(NDalicPINVOKE.Button_PressedSignal(swigCPtr), false);
878 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
882 internal ButtonSignal ReleasedSignal()
884 ButtonSignal ret = new ButtonSignal(NDalicPINVOKE.Button_ReleasedSignal(swigCPtr), false);
885 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
889 internal ButtonSignal ClickedSignal()
891 ButtonSignal ret = new ButtonSignal(NDalicPINVOKE.Button_ClickedSignal(swigCPtr), false);
892 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
896 internal ButtonSignal StateChangedSignal()
898 ButtonSignal ret = new ButtonSignal(NDalicPINVOKE.Button_StateChangedSignal(swigCPtr), false);
899 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
904 /// If the autorepeating property is set to true, then the togglable property is set to false.
906 /// <since_tizen> 3 </since_tizen>
907 public bool AutoRepeating
911 return (bool)GetValue(AutoRepeatingProperty);
915 SetValue(AutoRepeatingProperty, value);
920 /// By default, this value is set to 0.15 seconds.
922 /// <since_tizen> 3 </since_tizen>
923 public float InitialAutoRepeatingDelay
927 return (float)GetValue(InitialAutoRepeatingDelayProperty);
931 SetValue(InitialAutoRepeatingDelayProperty, value);
936 /// By default, this value is set to 0.05 seconds.
938 /// <since_tizen> 3 </since_tizen>
939 public float NextAutoRepeatingDelay
943 return (float)GetValue(NextAutoRepeatingDelayProperty);
947 SetValue(NextAutoRepeatingDelayProperty, value);
952 /// If the togglable property is set to true, then the autorepeating property is set to false.
954 /// <since_tizen> 3 </since_tizen>
955 public bool Togglable
959 return (bool)GetValue(TogglableProperty);
963 SetValue(TogglableProperty, value);
968 /// Gets or sets the togglable button as either selected or unselected, togglable property must be set to true.
970 /// <since_tizen> 3 </since_tizen>
975 return (bool)GetValue(SelectedProperty);
979 SetValue(SelectedProperty, value);
984 /// Gets or sets the unselected color.
986 /// <since_tizen> 3 </since_tizen>
987 public Color UnselectedColor
991 return (Color)GetValue(UnselectedColorProperty);
995 SetValue(UnselectedColorProperty, value);
1000 /// Gets or sets the selected color.
1002 /// <since_tizen> 3 </since_tizen>
1003 public Color SelectedColor
1007 return (Color)GetValue(SelectedColorProperty);
1011 SetValue(SelectedColorProperty, value);
1016 /// Gets or sets the label.
1018 /// <since_tizen> 3 </since_tizen>
1019 public Tizen.NUI.PropertyMap Label
1023 return (PropertyMap)GetValue(LabelProperty);
1027 SetValue(LabelProperty, value);
1032 /// Gets or sets the text of the label.
1034 /// <since_tizen> 3 </since_tizen>
1035 public string LabelText
1039 return (string)GetValue(LabelTextProperty);
1043 SetValue(LabelTextProperty, value);
1048 /// Enumeration for describing the position, the text label can be, in relation to the control (and foreground/icon).
1050 /// <since_tizen> 3 </since_tizen>
1054 /// At the start of the control before the foreground or icon.
1058 /// At the end of the control after the foreground or icon.
1062 /// At the top of the control above the foreground or icon.
1066 /// At the bottom of the control below the foreground or icon.