2 * Copyright(c) 2019 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 public class Button : View
41 /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
42 [EditorBrowsable(EditorBrowsableState.Never)]
43 public static readonly BindableProperty UnselectedVisualProperty = BindableProperty.Create("UnselectedVisual", typeof(PropertyMap), typeof(Button), new PropertyMap(), propertyChanged: (bindable, oldValue, newValue) =>
45 var button = (Button)bindable;
48 Tizen.NUI.Object.SetProperty(button.swigCPtr, Button.Property.UNSELECTED_VISUAL, new Tizen.NUI.PropertyValue((PropertyMap)newValue));
51 defaultValueCreator:(bindable) =>
53 var button = (Button)bindable;
54 Tizen.NUI.PropertyMap temp = new Tizen.NUI.PropertyMap();
55 Tizen.NUI.Object.GetProperty(button.swigCPtr, Button.Property.UNSELECTED_VISUAL).Get(temp);
58 /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
59 [EditorBrowsable(EditorBrowsableState.Never)]
60 public static readonly BindableProperty SelectedVisualProperty = BindableProperty.Create("SelectedVisual", typeof(PropertyMap), typeof(Button), new PropertyMap(), propertyChanged: (bindable, oldValue, newValue) =>
62 var button = (Button)bindable;
65 Tizen.NUI.Object.SetProperty(button.swigCPtr, Button.Property.SELECTED_VISUAL, new Tizen.NUI.PropertyValue((PropertyMap)newValue));
68 defaultValueCreator:(bindable) =>
70 var button = (Button)bindable;
71 Tizen.NUI.PropertyMap temp = new Tizen.NUI.PropertyMap();
72 Tizen.NUI.Object.GetProperty(button.swigCPtr, Button.Property.SELECTED_VISUAL).Get(temp);
75 /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
76 [EditorBrowsable(EditorBrowsableState.Never)]
77 public static readonly BindableProperty DisabledSelectedVisualProperty = BindableProperty.Create("DisabledSelectedVisual", typeof(PropertyMap), typeof(Button), new PropertyMap(), propertyChanged: (bindable, oldValue, newValue) =>
79 var button = (Button)bindable;
82 Tizen.NUI.Object.SetProperty(button.swigCPtr, Button.Property.DISABLED_SELECTED_VISUAL, new Tizen.NUI.PropertyValue((PropertyMap)newValue));
85 defaultValueCreator:(bindable) =>
87 var button = (Button)bindable;
88 Tizen.NUI.PropertyMap temp = new Tizen.NUI.PropertyMap();
89 Tizen.NUI.Object.GetProperty(button.swigCPtr, Button.Property.DISABLED_SELECTED_VISUAL).Get(temp);
92 /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
93 [EditorBrowsable(EditorBrowsableState.Never)]
94 public static readonly BindableProperty DisabledUnselectedVisualProperty = BindableProperty.Create("DisabledUnselectedVisual", typeof(PropertyMap), typeof(Button), new PropertyMap(), propertyChanged: (bindable, oldValue, newValue) =>
96 var button = (Button)bindable;
99 Tizen.NUI.Object.SetProperty(button.swigCPtr, Button.Property.DISABLED_UNSELECTED_VISUAL, new Tizen.NUI.PropertyValue((PropertyMap)newValue));
102 defaultValueCreator:(bindable) =>
104 var button = (Button)bindable;
105 Tizen.NUI.PropertyMap temp = new Tizen.NUI.PropertyMap();
106 Tizen.NUI.Object.GetProperty(button.swigCPtr, Button.Property.DISABLED_UNSELECTED_VISUAL).Get(temp);
109 /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
110 [EditorBrowsable(EditorBrowsableState.Never)]
111 public static readonly BindableProperty UnselectedBackgroundVisualProperty = BindableProperty.Create("UnselectedBackgroundVisual", typeof(PropertyMap), typeof(Button), new PropertyMap(), propertyChanged: (bindable, oldValue, newValue) =>
113 var button = (Button)bindable;
114 if (newValue != null)
116 Tizen.NUI.Object.SetProperty(button.swigCPtr, Button.Property.UNSELECTED_BACKGROUND_VISUAL, new Tizen.NUI.PropertyValue((PropertyMap)newValue));
119 defaultValueCreator:(bindable) =>
121 var button = (Button)bindable;
122 Tizen.NUI.PropertyMap temp = new Tizen.NUI.PropertyMap();
123 Tizen.NUI.Object.GetProperty(button.swigCPtr, Button.Property.UNSELECTED_BACKGROUND_VISUAL).Get(temp);
126 /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
127 [EditorBrowsable(EditorBrowsableState.Never)]
128 public static readonly BindableProperty SelectedBackgroundVisualProperty = BindableProperty.Create("SelectedBackgroundVisual", typeof(PropertyMap), typeof(Button), new PropertyMap(), propertyChanged: (bindable, oldValue, newValue) =>
130 var button = (Button)bindable;
131 if (newValue != null)
133 Tizen.NUI.Object.SetProperty(button.swigCPtr, Button.Property.SELECTED_BACKGROUND_VISUAL, new Tizen.NUI.PropertyValue((PropertyMap)newValue));
136 defaultValueCreator:(bindable) =>
138 var button = (Button)bindable;
139 Tizen.NUI.PropertyMap temp = new Tizen.NUI.PropertyMap();
140 Tizen.NUI.Object.GetProperty(button.swigCPtr, Button.Property.SELECTED_BACKGROUND_VISUAL).Get(temp);
143 /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
144 [EditorBrowsable(EditorBrowsableState.Never)]
145 public static readonly BindableProperty DisabledUnselectedBackgroundVisualProperty = BindableProperty.Create("DisabledUnselectedBackgroundVisual", typeof(PropertyMap), typeof(Button), new PropertyMap(), propertyChanged: (bindable, oldValue, newValue) =>
147 var button = (Button)bindable;
148 if (newValue != null)
150 Tizen.NUI.Object.SetProperty(button.swigCPtr, Button.Property.DISABLED_UNSELECTED_BACKGROUND_VISUAL, new Tizen.NUI.PropertyValue((PropertyMap)newValue));
153 defaultValueCreator:(bindable) =>
155 var button = (Button)bindable;
156 Tizen.NUI.PropertyMap temp = new Tizen.NUI.PropertyMap();
157 Tizen.NUI.Object.GetProperty(button.swigCPtr, Button.Property.DISABLED_UNSELECTED_BACKGROUND_VISUAL).Get(temp);
160 /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
161 [EditorBrowsable(EditorBrowsableState.Never)]
162 public static readonly BindableProperty DisabledSelectedBackgroundVisualProperty = BindableProperty.Create("DisabledSelectedBackgroundVisual", typeof(PropertyMap), typeof(Button), new PropertyMap(), propertyChanged: (bindable, oldValue, newValue) =>
164 var button = (Button)bindable;
165 if (newValue != null)
167 Tizen.NUI.Object.SetProperty(button.swigCPtr, Button.Property.DISABLED_SELECTED_BACKGROUND_VISUAL, new Tizen.NUI.PropertyValue((PropertyMap)newValue));
170 defaultValueCreator:(bindable) =>
172 var button = (Button)bindable;
173 Tizen.NUI.PropertyMap temp = new Tizen.NUI.PropertyMap();
174 Tizen.NUI.Object.GetProperty(button.swigCPtr, Button.Property.DISABLED_SELECTED_BACKGROUND_VISUAL).Get(temp);
177 /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
178 [EditorBrowsable(EditorBrowsableState.Never)]
179 public static readonly BindableProperty LabelRelativeAlignmentProperty = BindableProperty.Create("LabelRelativeAlignment", typeof(Align), typeof(Button), Align.End, propertyChanged: (bindable, oldValue, newValue) =>
181 var button = (Button)bindable;
182 string valueToString = "";
183 if (newValue != null)
185 switch ((Align)newValue)
187 case Align.Begin: { valueToString = "BEGIN"; break; }
188 case Align.End: { valueToString = "END"; break; }
189 case Align.Top: { valueToString = "TOP"; break; }
190 case Align.Bottom: { valueToString = "BOTTOM"; break; }
191 default: { valueToString = "END"; break; }
193 Tizen.NUI.Object.SetProperty(button.swigCPtr, Button.Property.LABEL_RELATIVE_ALIGNMENT, new Tizen.NUI.PropertyValue(valueToString));
196 defaultValueCreator:(bindable) =>
198 var button = (Button)bindable;
200 if (Tizen.NUI.Object.GetProperty(button.swigCPtr, Button.Property.LABEL_RELATIVE_ALIGNMENT).Get(out temp) == false)
202 NUILog.Error("LabelRelativeAlignment get error!");
206 case "BEGIN": return Align.Begin;
207 case "END": return Align.End;
208 case "TOP": return Align.Top;
209 case "BOTTOM": return Align.Bottom;
210 default: return Align.End;
213 /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
214 [EditorBrowsable(EditorBrowsableState.Never)]
215 public static readonly BindableProperty LabelPaddingProperty = BindableProperty.Create("LabelPadding", typeof(Vector4), typeof(Button), Vector4.Zero, propertyChanged: (bindable, oldValue, newValue) =>
217 var button = (Button)bindable;
218 if (newValue != null)
220 Tizen.NUI.Object.SetProperty(button.swigCPtr, Button.Property.LABEL_PADDING, new Tizen.NUI.PropertyValue((Vector4)newValue));
223 defaultValueCreator:(bindable) =>
225 var button = (Button)bindable;
226 Vector4 temp = new Vector4(0.0f, 0.0f, 0.0f, 0.0f);
227 Tizen.NUI.Object.GetProperty(button.swigCPtr, Button.Property.LABEL_PADDING).Get(temp);
230 /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
231 [EditorBrowsable(EditorBrowsableState.Never)]
232 public static readonly BindableProperty ForegroundVisualPaddingProperty = BindableProperty.Create("ForegroundVisualPadding", typeof(Vector4), typeof(Button), Vector4.Zero, propertyChanged: (bindable, oldValue, newValue) =>
234 var button = (Button)bindable;
235 if (newValue != null)
237 Tizen.NUI.Object.SetProperty(button.swigCPtr, Button.Property.FOREGROUND_VISUAL_PADDING, new Tizen.NUI.PropertyValue((Vector4)newValue));
240 defaultValueCreator:(bindable) =>
242 var button = (Button)bindable;
243 Vector4 temp = new Vector4(0.0f, 0.0f, 0.0f, 0.0f);
244 Tizen.NUI.Object.GetProperty(button.swigCPtr, Button.Property.FOREGROUND_VISUAL_PADDING).Get(temp);
247 /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
248 [EditorBrowsable(EditorBrowsableState.Never)]
249 public static readonly BindableProperty AutoRepeatingProperty = BindableProperty.Create("AutoRepeating", typeof(bool), typeof(Button), false, propertyChanged: (bindable, oldValue, newValue) =>
251 var button = (Button)bindable;
252 if (newValue != null)
254 Tizen.NUI.Object.SetProperty(button.swigCPtr, Button.Property.AUTO_REPEATING, new Tizen.NUI.PropertyValue((bool)newValue));
257 defaultValueCreator:(bindable) =>
259 var button = (Button)bindable;
261 Tizen.NUI.Object.GetProperty(button.swigCPtr, Button.Property.AUTO_REPEATING).Get(out temp);
264 /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
265 [EditorBrowsable(EditorBrowsableState.Never)]
266 public static readonly BindableProperty InitialAutoRepeatingDelayProperty = BindableProperty.Create("InitialAutoRepeatingDelay", typeof(float), typeof(Button), default(float), propertyChanged: (bindable, oldValue, newValue) =>
268 var button = (Button)bindable;
269 if (newValue != null)
271 Tizen.NUI.Object.SetProperty(button.swigCPtr, Button.Property.INITIAL_AUTO_REPEATING_DELAY, new Tizen.NUI.PropertyValue((float)newValue));
274 defaultValueCreator:(bindable) =>
276 var button = (Button)bindable;
278 Tizen.NUI.Object.GetProperty(button.swigCPtr, Button.Property.INITIAL_AUTO_REPEATING_DELAY).Get(out temp);
281 /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
282 [EditorBrowsable(EditorBrowsableState.Never)]
283 public static readonly BindableProperty NextAutoRepeatingDelayProperty = BindableProperty.Create("NextAutoRepeatingDelay", typeof(float), typeof(Button), default(float), propertyChanged: (bindable, oldValue, newValue) =>
285 var button = (Button)bindable;
286 if (newValue != null)
288 Tizen.NUI.Object.SetProperty(button.swigCPtr, Button.Property.NEXT_AUTO_REPEATING_DELAY, new Tizen.NUI.PropertyValue((float)newValue));
291 defaultValueCreator:(bindable) =>
293 var button = (Button)bindable;
295 Tizen.NUI.Object.GetProperty(button.swigCPtr, Button.Property.NEXT_AUTO_REPEATING_DELAY).Get(out temp);
298 /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
299 [EditorBrowsable(EditorBrowsableState.Never)]
300 public static readonly BindableProperty TogglableProperty = BindableProperty.Create("Togglable", typeof(bool), typeof(Button), false, propertyChanged: (bindable, oldValue, newValue) =>
302 var button = (Button)bindable;
303 if (newValue != null)
305 Tizen.NUI.Object.SetProperty(button.swigCPtr, Button.Property.TOGGLABLE, new Tizen.NUI.PropertyValue((bool)newValue));
308 defaultValueCreator:(bindable) =>
310 var button = (Button)bindable;
312 Tizen.NUI.Object.GetProperty(button.swigCPtr, Button.Property.TOGGLABLE).Get(out temp);
315 /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
316 [EditorBrowsable(EditorBrowsableState.Never)]
317 public static readonly BindableProperty SelectedProperty = BindableProperty.Create("Selected", typeof(bool), typeof(Button), false, propertyChanged: (bindable, oldValue, newValue) =>
319 var button = (Button)bindable;
320 if (newValue != null)
322 Tizen.NUI.Object.SetProperty(button.swigCPtr, Button.Property.SELECTED, new Tizen.NUI.PropertyValue((bool)newValue));
325 defaultValueCreator:(bindable) =>
327 var button = (Button)bindable;
329 Tizen.NUI.Object.GetProperty(button.swigCPtr, Button.Property.SELECTED).Get(out temp);
332 /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
333 [EditorBrowsable(EditorBrowsableState.Never)]
334 public static readonly BindableProperty UnselectedColorProperty = BindableProperty.Create("UnselectedColor", typeof(Color), typeof(Button), Color.Transparent, propertyChanged: (bindable, oldValue, newValue) =>
336 var button = (Button)bindable;
337 if (newValue != null)
339 PropertyMap background = new PropertyMap();
340 background.Add( Visual.Property.Type, new PropertyValue((int)Visual.Type.Color) )
341 .Add( ColorVisualProperty.MixColor, new PropertyValue((Color)newValue) );
342 Tizen.NUI.Object.SetProperty(button.swigCPtr, Button.Property.UNSELECTED_BACKGROUND_VISUAL, new Tizen.NUI.PropertyValue(background));
345 defaultValueCreator:(bindable) =>
347 var button = (Button)bindable;
348 Color temp = new Color(0.0f, 0.0f, 0.0f, 0.0f);
349 Tizen.NUI.PropertyMap map = new Tizen.NUI.PropertyMap();
350 Tizen.NUI.Object.GetProperty(button.swigCPtr, Button.Property.UNSELECTED_BACKGROUND_VISUAL).Get(map);
351 Tizen.NUI.PropertyValue value = map.Find( Visual.Property.MixColor);
355 /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
356 [EditorBrowsable(EditorBrowsableState.Never)]
357 public static readonly BindableProperty SelectedColorProperty = BindableProperty.Create("SelectedColor", typeof(Color), typeof(Button), Color.Transparent, propertyChanged: (bindable, oldValue, newValue) =>
359 var button = (Button)bindable;
360 if (newValue != null)
362 PropertyMap background = new PropertyMap();
363 background.Add( Visual.Property.Type, new PropertyValue((int)Visual.Type.Color) )
364 .Add( ColorVisualProperty.MixColor, new PropertyValue((Color)newValue) );
365 Tizen.NUI.Object.SetProperty(button.swigCPtr, Button.Property.SELECTED_BACKGROUND_VISUAL, new Tizen.NUI.PropertyValue(background));
368 defaultValueCreator:(bindable) =>
370 var button = (Button)bindable;
371 Color temp = new Color(0.0f, 0.0f, 0.0f, 0.0f);
372 Tizen.NUI.PropertyMap map = new Tizen.NUI.PropertyMap();
373 Tizen.NUI.Object.GetProperty(button.swigCPtr, Button.Property.SELECTED_BACKGROUND_VISUAL).Get(map);
374 Tizen.NUI.PropertyValue value = map.Find( Visual.Property.MixColor);
378 /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
379 [EditorBrowsable(EditorBrowsableState.Never)]
380 public static readonly BindableProperty LabelProperty = BindableProperty.Create("Label", typeof(PropertyMap), typeof(Button), new PropertyMap(), propertyChanged: (bindable, oldValue, newValue) =>
382 var button = (Button)bindable;
383 if (newValue != null)
385 Tizen.NUI.Object.SetProperty(button.swigCPtr, Button.Property.LABEL, new Tizen.NUI.PropertyValue((PropertyMap)newValue));
388 defaultValueCreator:(bindable) =>
390 var button = (Button)bindable;
391 Tizen.NUI.PropertyMap temp = new Tizen.NUI.PropertyMap();
392 Tizen.NUI.Object.GetProperty(button.swigCPtr, Button.Property.LABEL).Get(temp);
395 /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
396 [EditorBrowsable(EditorBrowsableState.Never)]
397 public static readonly BindableProperty LabelTextProperty = BindableProperty.Create("LabelText", typeof(string), typeof(Button), string.Empty, propertyChanged: (bindable, oldValue, newValue) =>
399 var button = (Button)bindable;
400 if (newValue != null)
402 Tizen.NUI.Object.SetProperty(button.swigCPtr, Button.Property.LABEL, new Tizen.NUI.PropertyValue((string)newValue));
405 defaultValueCreator:(bindable) =>
407 var button = (Button)bindable;
408 Tizen.NUI.PropertyMap map = new Tizen.NUI.PropertyMap();
409 Tizen.NUI.Object.GetProperty(button.swigCPtr, Button.Property.LABEL).Get(map);
410 Tizen.NUI.PropertyValue value = map.Find( TextVisualProperty.Text, "Text");
416 private global::System.Runtime.InteropServices.HandleRef swigCPtr;
417 private EventHandlerWithReturnType<object, EventArgs, bool> _clickedEventHandler;
418 private ClickedCallbackType _clickedCallback;
419 private EventHandlerWithReturnType<object, EventArgs, bool> _pressedEventHandler;
420 private PressedCallbackType _pressedCallback;
421 private EventHandlerWithReturnType<object, EventArgs, bool> _releasedEventHandler;
422 private ReleasedCallbackType _releasedCallback;
423 private EventHandlerWithReturnType<object, EventArgs, bool> _stateChangedEventHandler;
424 private StateChangedCallback _stateChangedCallback;
427 /// Creates an uninitialized button.<br />
428 /// Only the derived versions can be instantiated.<br />
430 /// <since_tizen> 3 </since_tizen>
431 public Button() : this(Interop.Button.new_Button__SWIG_0(), true)
433 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
436 internal Button(global::System.IntPtr cPtr, bool cMemoryOwn) : base(Interop.Button.Button_SWIGUpcast(cPtr), cMemoryOwn)
438 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
441 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
442 private delegate bool ClickedCallbackType(global::System.IntPtr data);
443 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
444 private delegate bool PressedCallbackType(global::System.IntPtr data);
445 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
446 private delegate bool ReleasedCallbackType(global::System.IntPtr data);
447 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
448 private delegate bool StateChangedCallback(global::System.IntPtr data);
451 /// The Clicked event will be triggered when the button is touched and the touch point doesn't leave the boundary of the button.
453 /// <since_tizen> 3 </since_tizen>
454 public event EventHandlerWithReturnType<object, EventArgs, bool> Clicked
458 if (_clickedEventHandler == null)
460 _clickedCallback = OnClicked;
461 ClickedSignal().Connect(_clickedCallback);
464 _clickedEventHandler += value;
469 _clickedEventHandler -= value;
471 if (_clickedEventHandler == null && ClickedSignal().Empty() == false)
473 ClickedSignal().Disconnect(_clickedCallback);
479 /// The Pressed event will be triggered when the button is touched.
481 /// <since_tizen> 3 </since_tizen>
482 public event EventHandlerWithReturnType<object, EventArgs, bool> Pressed
486 if (_pressedEventHandler == null)
488 _pressedCallback = OnPressed;
489 PressedSignal().Connect(_pressedCallback);
492 _pressedEventHandler += value;
497 _pressedEventHandler -= value;
499 if (_pressedEventHandler == null && PressedSignal().Empty() == false)
501 this.PressedSignal().Disconnect(_pressedCallback);
507 /// The Released event will be triggered when the button is touched and the touch point leaves the boundary of the button.
509 /// <since_tizen> 3 </since_tizen>
510 public event EventHandlerWithReturnType<object, EventArgs, bool> Released
514 if (_releasedEventHandler == null)
516 _releasedCallback = OnReleased;
517 ReleasedSignal().Connect(_releasedCallback);
519 _releasedEventHandler += value;
524 _releasedEventHandler -= value;
526 if (_releasedEventHandler == null && ReleasedSignal().Empty() == false)
528 ReleasedSignal().Disconnect(_releasedCallback);
535 /// The StateChanged event will be triggered when the button's state is changed.
537 /// <since_tizen> 3 </since_tizen>
538 public event EventHandlerWithReturnType<object, EventArgs, bool> StateChanged
542 if (_stateChangedEventHandler == null)
544 _stateChangedCallback = OnStateChanged;
545 StateChangedSignal().Connect(_stateChangedCallback);
548 _stateChangedEventHandler += value;
553 _stateChangedEventHandler -= value;
555 if (_stateChangedEventHandler == null && StateChangedSignal().Empty() == false)
557 StateChangedSignal().Disconnect(_stateChangedCallback);
563 /// Enumeration for describing the position, the text label can be, in relation to the control (and foreground/icon).
565 /// <since_tizen> 3 </since_tizen>
569 /// At the start of the control before the foreground or icon.
573 /// At the end of the control after the foreground or icon.
577 /// At the top of the control above the foreground or icon.
581 /// At the bottom of the control below the foreground or icon.
587 /// Gets or sets the unselected button foreground or icon visual.
589 /// <since_tizen> 3 </since_tizen>
590 public Tizen.NUI.PropertyMap UnselectedVisual
594 return (PropertyMap)GetValue(UnselectedVisualProperty);
598 SetValue(UnselectedVisualProperty, value);
603 /// Gets or sets the selected button foreground or icon visual.
605 /// <since_tizen> 3 </since_tizen>
606 public Tizen.NUI.PropertyMap SelectedVisual
610 return (PropertyMap)GetValue(SelectedVisualProperty);
614 SetValue(SelectedVisualProperty, value);
619 /// Gets or sets the disabled selected state foreground or icon button visual.
621 /// <since_tizen> 3 </since_tizen>
622 public Tizen.NUI.PropertyMap DisabledSelectedVisual
626 return (PropertyMap)GetValue(DisabledSelectedVisualProperty);
630 SetValue(DisabledSelectedVisualProperty, value);
635 /// Gets or sets the disabled unselected state foreground or icon visual.
637 /// <since_tizen> 3 </since_tizen>
638 public Tizen.NUI.PropertyMap DisabledUnselectedVisual
642 return (PropertyMap)GetValue(DisabledUnselectedVisualProperty);
646 SetValue(DisabledUnselectedVisualProperty, value);
651 /// Gets or sets the disabled unselected state background button visual.
653 /// <since_tizen> 3 </since_tizen>
654 public Tizen.NUI.PropertyMap UnselectedBackgroundVisual
658 return (PropertyMap)GetValue(UnselectedBackgroundVisualProperty);
662 SetValue(UnselectedBackgroundVisualProperty, value);
667 /// Gets or sets the selected background button visual.
669 /// <since_tizen> 3 </since_tizen>
670 public Tizen.NUI.PropertyMap SelectedBackgroundVisual
674 return (PropertyMap)GetValue(SelectedBackgroundVisualProperty);
678 SetValue(SelectedBackgroundVisualProperty, value);
683 /// Gets or sets the disabled while unselected background button visual.
685 /// <since_tizen> 3 </since_tizen>
686 public Tizen.NUI.PropertyMap DisabledUnselectedBackgroundVisual
690 return (PropertyMap)GetValue(DisabledUnselectedBackgroundVisualProperty);
694 SetValue(DisabledUnselectedBackgroundVisualProperty, value);
699 /// Gets or sets the disabled while selected background button visual.
701 /// <since_tizen> 3 </since_tizen>
702 public Tizen.NUI.PropertyMap DisabledSelectedBackgroundVisual
706 return (PropertyMap)GetValue(DisabledSelectedBackgroundVisualProperty);
710 SetValue(DisabledSelectedBackgroundVisualProperty, value);
715 /// Gets or sets the position of the the label in relation to the foreground or icon, if both present.
717 /// <since_tizen> 3 </since_tizen>
718 public Align LabelRelativeAlignment
722 return (Align)GetValue(LabelRelativeAlignmentProperty);
726 SetValue(LabelRelativeAlignmentProperty, value);
731 /// Gets or sets the padding around the text.
733 /// <since_tizen> 3 </since_tizen>
734 public Vector4 LabelPadding
738 return (Vector4)GetValue(LabelPaddingProperty);
742 SetValue(LabelPaddingProperty, value);
747 /// Gets or sets the padding around the foreground visual.
749 /// <since_tizen> 3 </since_tizen>
750 public Vector4 ForegroundVisualPadding
754 return (Vector4)GetValue(ForegroundVisualPaddingProperty);
758 SetValue(ForegroundVisualPaddingProperty, value);
763 /// If the autorepeating property is set to true, then the togglable property is set to false.
765 /// <since_tizen> 3 </since_tizen>
766 public bool AutoRepeating
770 return (bool)GetValue(AutoRepeatingProperty);
774 SetValue(AutoRepeatingProperty, value);
779 /// By default, this value is set to 0.15 seconds.
781 /// <since_tizen> 3 </since_tizen>
782 public float InitialAutoRepeatingDelay
786 return (float)GetValue(InitialAutoRepeatingDelayProperty);
790 SetValue(InitialAutoRepeatingDelayProperty, value);
795 /// By default, this value is set to 0.05 seconds.
797 /// <since_tizen> 3 </since_tizen>
798 public float NextAutoRepeatingDelay
802 return (float)GetValue(NextAutoRepeatingDelayProperty);
806 SetValue(NextAutoRepeatingDelayProperty, value);
811 /// If the togglable property is set to true, then the autorepeating property is set to false.
813 /// <since_tizen> 3 </since_tizen>
814 public bool Togglable
818 return (bool)GetValue(TogglableProperty);
822 SetValue(TogglableProperty, value);
827 /// Gets or sets the togglable button as either selected or unselected, togglable property must be set to true.
829 /// <since_tizen> 3 </since_tizen>
834 return (bool)GetValue(SelectedProperty);
838 SetValue(SelectedProperty, value);
843 /// Gets or sets the unselected color.
845 /// <since_tizen> 3 </since_tizen>
846 public Color UnselectedColor
850 return (Color)GetValue(UnselectedColorProperty);
854 SetValue(UnselectedColorProperty, value);
859 /// Gets or sets the selected color.
861 /// <since_tizen> 3 </since_tizen>
862 public Color SelectedColor
866 return (Color)GetValue(SelectedColorProperty);
870 SetValue(SelectedColorProperty, value);
875 /// Gets or sets the label.
877 /// <since_tizen> 3 </since_tizen>
878 public Tizen.NUI.PropertyMap Label
882 return (PropertyMap)GetValue(LabelProperty);
886 SetValue(LabelProperty, value);
891 /// Gets or sets the text of the label.
893 /// <since_tizen> 3 </since_tizen>
894 public string LabelText
898 return (string)GetValue(LabelTextProperty);
902 SetValue(LabelTextProperty, value);
906 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(Button obj)
908 return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
911 internal ButtonSignal PressedSignal()
913 ButtonSignal ret = new ButtonSignal(Interop.Button.Button_PressedSignal(swigCPtr), false);
914 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
918 internal ButtonSignal ReleasedSignal()
920 ButtonSignal ret = new ButtonSignal(Interop.Button.Button_ReleasedSignal(swigCPtr), false);
921 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
925 internal ButtonSignal ClickedSignal()
927 ButtonSignal ret = new ButtonSignal(Interop.Button.Button_ClickedSignal(swigCPtr), false);
928 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
932 internal ButtonSignal StateChangedSignal()
934 ButtonSignal ret = new ButtonSignal(Interop.Button.Button_StateChangedSignal(swigCPtr), false);
935 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
940 /// To dispose the button instance.
942 /// <since_tizen> 3 </since_tizen>
943 protected override void Dispose(DisposeTypes type)
950 //Release your own unmanaged resources here.
951 //You should not access any managed member here except static instance.
952 //because the execution order of Finalizes is non-deterministic.
955 DisConnectFromSignals();
958 if (swigCPtr.Handle != global::System.IntPtr.Zero)
963 Interop.Button.delete_Button(swigCPtr);
965 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
971 private void DisConnectFromSignals()
973 // Save current CPtr.
974 global::System.Runtime.InteropServices.HandleRef currentCPtr = swigCPtr;
976 // Use BaseHandle CPtr as current might have been deleted already in derived classes.
977 swigCPtr = GetBaseHandleCPtrHandleRef;
979 if (_stateChangedCallback != null)
981 StateChangedSignal().Disconnect(_stateChangedCallback);
984 if (_releasedCallback != null)
986 ReleasedSignal().Disconnect(_releasedCallback);
989 if (_pressedCallback != null)
991 this.PressedSignal().Disconnect(_pressedCallback);
994 if (_clickedCallback != null)
996 ClickedSignal().Disconnect(_clickedCallback);
999 // BaseHandle CPtr is used in Registry and there is danger of deletion if we keep using it here.
1000 // Restore current CPtr.
1001 swigCPtr = currentCPtr;
1004 private bool OnClicked(IntPtr data)
1006 if (_clickedEventHandler != null)
1008 return _clickedEventHandler(this, null);
1013 private bool OnPressed(IntPtr data)
1015 if (_pressedEventHandler != null)
1017 return _pressedEventHandler(this, null);
1022 private bool OnReleased(IntPtr data)
1024 if (_releasedEventHandler != null)
1026 return _releasedEventHandler(this, null);
1031 private bool OnStateChanged(IntPtr data)
1033 if (_stateChangedEventHandler != null)
1035 return _stateChangedEventHandler(this, null);
1040 internal new class Property
1042 internal static readonly int UNSELECTED_VISUAL = Interop.Button.Button_Property_UNSELECTED_VISUAL_get();
1043 internal static readonly int SELECTED_VISUAL = Interop.Button.Button_Property_SELECTED_VISUAL_get();
1044 internal static readonly int DISABLED_SELECTED_VISUAL = Interop.Button.Button_Property_DISABLED_SELECTED_VISUAL_get();
1045 internal static readonly int DISABLED_UNSELECTED_VISUAL = Interop.Button.Button_Property_DISABLED_UNSELECTED_VISUAL_get();
1046 internal static readonly int UNSELECTED_BACKGROUND_VISUAL = Interop.Button.Button_Property_UNSELECTED_BACKGROUND_VISUAL_get();
1047 internal static readonly int SELECTED_BACKGROUND_VISUAL = Interop.Button.Button_Property_SELECTED_BACKGROUND_VISUAL_get();
1048 internal static readonly int DISABLED_UNSELECTED_BACKGROUND_VISUAL = Interop.Button.Button_Property_DISABLED_UNSELECTED_BACKGROUND_VISUAL_get();
1049 internal static readonly int DISABLED_SELECTED_BACKGROUND_VISUAL = Interop.Button.Button_Property_DISABLED_SELECTED_BACKGROUND_VISUAL_get();
1050 internal static readonly int LABEL_RELATIVE_ALIGNMENT = Interop.Button.Button_Property_LABEL_RELATIVE_ALIGNMENT_get();
1051 internal static readonly int LABEL_PADDING = Interop.Button.Button_Property_LABEL_PADDING_get();
1052 internal static readonly int FOREGROUND_VISUAL_PADDING = Interop.Button.Button_Property_VISUAL_PADDING_get();
1053 internal static readonly int AUTO_REPEATING = Interop.Button.Button_Property_AUTO_REPEATING_get();
1054 internal static readonly int INITIAL_AUTO_REPEATING_DELAY = Interop.Button.Button_Property_INITIAL_AUTO_REPEATING_DELAY_get();
1055 internal static readonly int NEXT_AUTO_REPEATING_DELAY = Interop.Button.Button_Property_NEXT_AUTO_REPEATING_DELAY_get();
1056 internal static readonly int TOGGLABLE = Interop.Button.Button_Property_TOGGLABLE_get();
1057 internal static readonly int SELECTED = Interop.Button.Button_Property_SELECTED_get();
1058 internal static readonly int LABEL = Interop.Button.Button_Property_LABEL_get();