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 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 Tizen.NUI.Object.SetProperty(button.swigCPtr, Button.Property.UNSELECTED_COLOR, new Tizen.NUI.PropertyValue((Color)newValue));
342 defaultValueCreator:(bindable) =>
344 var button = (Button)bindable;
345 Color temp = new Color(0.0f, 0.0f, 0.0f, 0.0f);
346 Tizen.NUI.Object.GetProperty(button.swigCPtr, Button.Property.UNSELECTED_COLOR).Get(temp);
349 /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
350 [EditorBrowsable(EditorBrowsableState.Never)]
351 public static readonly BindableProperty SelectedColorProperty = BindableProperty.Create("SelectedColor", typeof(Color), typeof(Button), Color.Transparent, propertyChanged: (bindable, oldValue, newValue) =>
353 var button = (Button)bindable;
354 if (newValue != null)
356 Tizen.NUI.Object.SetProperty(button.swigCPtr, Button.Property.SELECTED_COLOR, new Tizen.NUI.PropertyValue((Color)newValue));
359 defaultValueCreator:(bindable) =>
361 var button = (Button)bindable;
362 Color temp = new Color(0.0f, 0.0f, 0.0f, 0.0f);
363 Tizen.NUI.Object.GetProperty(button.swigCPtr, Button.Property.SELECTED_COLOR).Get(temp);
366 /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
367 [EditorBrowsable(EditorBrowsableState.Never)]
368 public static readonly BindableProperty LabelProperty = BindableProperty.Create("Label", typeof(PropertyMap), typeof(Button), new PropertyMap(), propertyChanged: (bindable, oldValue, newValue) =>
370 var button = (Button)bindable;
371 if (newValue != null)
373 Tizen.NUI.Object.SetProperty(button.swigCPtr, Button.Property.LABEL, new Tizen.NUI.PropertyValue((PropertyMap)newValue));
376 defaultValueCreator:(bindable) =>
378 var button = (Button)bindable;
379 Tizen.NUI.PropertyMap temp = new Tizen.NUI.PropertyMap();
380 Tizen.NUI.Object.GetProperty(button.swigCPtr, Button.Property.LABEL).Get(temp);
383 /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
384 [EditorBrowsable(EditorBrowsableState.Never)]
385 public static readonly BindableProperty LabelTextProperty = BindableProperty.Create("LabelText", typeof(string), typeof(Button), string.Empty, propertyChanged: (bindable, oldValue, newValue) =>
387 var button = (Button)bindable;
388 if (newValue != null)
390 Tizen.NUI.Object.SetProperty(button.swigCPtr, Button.Property.LABEL, new Tizen.NUI.PropertyValue((string)newValue));
393 defaultValueCreator:(bindable) =>
395 var button = (Button)bindable;
396 Tizen.NUI.PropertyMap map = new Tizen.NUI.PropertyMap();
397 Tizen.NUI.Object.GetProperty(button.swigCPtr, Button.Property.LABEL).Get(map);
398 Tizen.NUI.PropertyValue value = map.Find( TextVisualProperty.Text, "Text");
404 private global::System.Runtime.InteropServices.HandleRef swigCPtr;
405 private EventHandlerWithReturnType<object, EventArgs, bool> _clickedEventHandler;
406 private ClickedCallbackType _clickedCallback;
407 private EventHandlerWithReturnType<object, EventArgs, bool> _pressedEventHandler;
408 private PressedCallbackType _pressedCallback;
409 private EventHandlerWithReturnType<object, EventArgs, bool> _releasedEventHandler;
410 private ReleasedCallbackType _releasedCallback;
411 private EventHandlerWithReturnType<object, EventArgs, bool> _stateChangedEventHandler;
412 private StateChangedCallback _stateChangedCallback;
415 /// Creates an uninitialized button.<br />
416 /// Only the derived versions can be instantiated.<br />
418 /// <since_tizen> 3 </since_tizen>
419 public Button() : this(Interop.Button.new_Button__SWIG_0(), true)
421 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
424 internal Button(global::System.IntPtr cPtr, bool cMemoryOwn) : base(Interop.Button.Button_SWIGUpcast(cPtr), cMemoryOwn)
426 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
429 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
430 private delegate bool ClickedCallbackType(global::System.IntPtr data);
431 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
432 private delegate bool PressedCallbackType(global::System.IntPtr data);
433 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
434 private delegate bool ReleasedCallbackType(global::System.IntPtr data);
435 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
436 private delegate bool StateChangedCallback(global::System.IntPtr data);
439 /// The Clicked event will be triggered when the button is touched and the touch point doesn't leave the boundary of the button.
441 /// <since_tizen> 3 </since_tizen>
442 public event EventHandlerWithReturnType<object, EventArgs, bool> Clicked
446 if (_clickedEventHandler == null)
448 _clickedCallback = OnClicked;
449 ClickedSignal().Connect(_clickedCallback);
452 _clickedEventHandler += value;
457 _clickedEventHandler -= value;
459 if (_clickedEventHandler == null && ClickedSignal().Empty() == false)
461 ClickedSignal().Disconnect(_clickedCallback);
467 /// The Pressed event will be triggered when the button is touched.
469 /// <since_tizen> 3 </since_tizen>
470 public event EventHandlerWithReturnType<object, EventArgs, bool> Pressed
474 if (_pressedEventHandler == null)
476 _pressedCallback = OnPressed;
477 PressedSignal().Connect(_pressedCallback);
480 _pressedEventHandler += value;
485 _pressedEventHandler -= value;
487 if (_pressedEventHandler == null && PressedSignal().Empty() == false)
489 this.PressedSignal().Disconnect(_pressedCallback);
495 /// The Released event will be triggered when the button is touched and the touch point leaves the boundary of the button.
497 /// <since_tizen> 3 </since_tizen>
498 public event EventHandlerWithReturnType<object, EventArgs, bool> Released
502 if (_releasedEventHandler == null)
504 _releasedCallback = OnReleased;
505 ReleasedSignal().Connect(_releasedCallback);
507 _releasedEventHandler += value;
512 _releasedEventHandler -= value;
514 if (_releasedEventHandler == null && ReleasedSignal().Empty() == false)
516 ReleasedSignal().Disconnect(_releasedCallback);
523 /// The StateChanged event will be triggered when the button's state is changed.
525 /// <since_tizen> 3 </since_tizen>
526 public event EventHandlerWithReturnType<object, EventArgs, bool> StateChanged
530 if (_stateChangedEventHandler == null)
532 _stateChangedCallback = OnStateChanged;
533 StateChangedSignal().Connect(_stateChangedCallback);
536 _stateChangedEventHandler += value;
541 _stateChangedEventHandler -= value;
543 if (_stateChangedEventHandler == null && StateChangedSignal().Empty() == false)
545 StateChangedSignal().Disconnect(_stateChangedCallback);
551 /// Enumeration for describing the position, the text label can be, in relation to the control (and foreground/icon).
553 /// <since_tizen> 3 </since_tizen>
557 /// At the start of the control before the foreground or icon.
561 /// At the end of the control after the foreground or icon.
565 /// At the top of the control above the foreground or icon.
569 /// At the bottom of the control below the foreground or icon.
575 /// Gets or sets the unselected button foreground or icon visual.
577 /// <since_tizen> 3 </since_tizen>
578 public Tizen.NUI.PropertyMap UnselectedVisual
582 return (PropertyMap)GetValue(UnselectedVisualProperty);
586 SetValue(UnselectedVisualProperty, value);
591 /// Gets or sets the selected button foreground or icon visual.
593 /// <since_tizen> 3 </since_tizen>
594 public Tizen.NUI.PropertyMap SelectedVisual
598 return (PropertyMap)GetValue(SelectedVisualProperty);
602 SetValue(SelectedVisualProperty, value);
607 /// Gets or sets the disabled selected state foreground or icon button visual.
609 /// <since_tizen> 3 </since_tizen>
610 public Tizen.NUI.PropertyMap DisabledSelectedVisual
614 return (PropertyMap)GetValue(DisabledSelectedVisualProperty);
618 SetValue(DisabledSelectedVisualProperty, value);
623 /// Gets or sets the disabled unselected state foreground or icon visual.
625 /// <since_tizen> 3 </since_tizen>
626 public Tizen.NUI.PropertyMap DisabledUnselectedVisual
630 return (PropertyMap)GetValue(DisabledUnselectedVisualProperty);
634 SetValue(DisabledUnselectedVisualProperty, value);
639 /// Gets or sets the disabled unselected state background button visual.
641 /// <since_tizen> 3 </since_tizen>
642 public Tizen.NUI.PropertyMap UnselectedBackgroundVisual
646 return (PropertyMap)GetValue(UnselectedBackgroundVisualProperty);
650 SetValue(UnselectedBackgroundVisualProperty, value);
655 /// Gets or sets the selected background button visual.
657 /// <since_tizen> 3 </since_tizen>
658 public Tizen.NUI.PropertyMap SelectedBackgroundVisual
662 return (PropertyMap)GetValue(SelectedBackgroundVisualProperty);
666 SetValue(SelectedBackgroundVisualProperty, value);
671 /// Gets or sets the disabled while unselected background button visual.
673 /// <since_tizen> 3 </since_tizen>
674 public Tizen.NUI.PropertyMap DisabledUnselectedBackgroundVisual
678 return (PropertyMap)GetValue(DisabledUnselectedBackgroundVisualProperty);
682 SetValue(DisabledUnselectedBackgroundVisualProperty, value);
687 /// Gets or sets the disabled while selected background button visual.
689 /// <since_tizen> 3 </since_tizen>
690 public Tizen.NUI.PropertyMap DisabledSelectedBackgroundVisual
694 return (PropertyMap)GetValue(DisabledSelectedBackgroundVisualProperty);
698 SetValue(DisabledSelectedBackgroundVisualProperty, value);
703 /// Gets or sets the position of the the label in relation to the foreground or icon, if both present.
705 /// <since_tizen> 3 </since_tizen>
706 public Align LabelRelativeAlignment
710 return (Align)GetValue(LabelRelativeAlignmentProperty);
714 SetValue(LabelRelativeAlignmentProperty, value);
719 /// Gets or sets the padding around the text.
721 /// <since_tizen> 3 </since_tizen>
722 public Vector4 LabelPadding
726 return (Vector4)GetValue(LabelPaddingProperty);
730 SetValue(LabelPaddingProperty, value);
735 /// Gets or sets the padding around the foreground visual.
737 /// <since_tizen> 3 </since_tizen>
738 public Vector4 ForegroundVisualPadding
742 return (Vector4)GetValue(ForegroundVisualPaddingProperty);
746 SetValue(ForegroundVisualPaddingProperty, value);
751 /// If the autorepeating property is set to true, then the togglable property is set to false.
753 /// <since_tizen> 3 </since_tizen>
754 public bool AutoRepeating
758 return (bool)GetValue(AutoRepeatingProperty);
762 SetValue(AutoRepeatingProperty, value);
767 /// By default, this value is set to 0.15 seconds.
769 /// <since_tizen> 3 </since_tizen>
770 public float InitialAutoRepeatingDelay
774 return (float)GetValue(InitialAutoRepeatingDelayProperty);
778 SetValue(InitialAutoRepeatingDelayProperty, value);
783 /// By default, this value is set to 0.05 seconds.
785 /// <since_tizen> 3 </since_tizen>
786 public float NextAutoRepeatingDelay
790 return (float)GetValue(NextAutoRepeatingDelayProperty);
794 SetValue(NextAutoRepeatingDelayProperty, value);
799 /// If the togglable property is set to true, then the autorepeating property is set to false.
801 /// <since_tizen> 3 </since_tizen>
802 public bool Togglable
806 return (bool)GetValue(TogglableProperty);
810 SetValue(TogglableProperty, value);
815 /// Gets or sets the togglable button as either selected or unselected, togglable property must be set to true.
817 /// <since_tizen> 3 </since_tizen>
822 return (bool)GetValue(SelectedProperty);
826 SetValue(SelectedProperty, value);
831 /// Gets or sets the unselected color.
833 /// <since_tizen> 3 </since_tizen>
834 public Color UnselectedColor
838 return (Color)GetValue(UnselectedColorProperty);
842 SetValue(UnselectedColorProperty, value);
847 /// Gets or sets the selected color.
849 /// <since_tizen> 3 </since_tizen>
850 public Color SelectedColor
854 return (Color)GetValue(SelectedColorProperty);
858 SetValue(SelectedColorProperty, value);
863 /// Gets or sets the label.
865 /// <since_tizen> 3 </since_tizen>
866 public Tizen.NUI.PropertyMap Label
870 return (PropertyMap)GetValue(LabelProperty);
874 SetValue(LabelProperty, value);
879 /// Gets or sets the text of the label.
881 /// <since_tizen> 3 </since_tizen>
882 public string LabelText
886 return (string)GetValue(LabelTextProperty);
890 SetValue(LabelTextProperty, value);
894 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(Button obj)
896 return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
899 internal ButtonSignal PressedSignal()
901 ButtonSignal ret = new ButtonSignal(Interop.Button.Button_PressedSignal(swigCPtr), false);
902 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
906 internal ButtonSignal ReleasedSignal()
908 ButtonSignal ret = new ButtonSignal(Interop.Button.Button_ReleasedSignal(swigCPtr), false);
909 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
913 internal ButtonSignal ClickedSignal()
915 ButtonSignal ret = new ButtonSignal(Interop.Button.Button_ClickedSignal(swigCPtr), false);
916 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
920 internal ButtonSignal StateChangedSignal()
922 ButtonSignal ret = new ButtonSignal(Interop.Button.Button_StateChangedSignal(swigCPtr), false);
923 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
928 /// To dispose the button instance.
930 /// <since_tizen> 3 </since_tizen>
931 protected override void Dispose(DisposeTypes type)
938 if (type == DisposeTypes.Explicit)
941 //Release your own managed resources here.
942 //You should release all of your own disposable objects here.
946 //Release your own unmanaged resources here.
947 //You should not access any managed member here except static instance.
948 //because the execution order of Finalizes is non-deterministic.
951 DisConnectFromSignals();
954 if (swigCPtr.Handle != global::System.IntPtr.Zero)
959 Interop.Button.delete_Button(swigCPtr);
961 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
967 private void DisConnectFromSignals()
969 // Save current CPtr.
970 global::System.Runtime.InteropServices.HandleRef currentCPtr = swigCPtr;
972 // Use BaseHandle CPtr as current might have been deleted already in derived classes.
973 swigCPtr = GetBaseHandleCPtrHandleRef;
975 if (_stateChangedCallback != null)
977 StateChangedSignal().Disconnect(_stateChangedCallback);
980 if (_releasedCallback != null)
982 ReleasedSignal().Disconnect(_releasedCallback);
985 if (_pressedCallback != null)
987 this.PressedSignal().Disconnect(_pressedCallback);
990 if (_clickedCallback != null)
992 ClickedSignal().Disconnect(_clickedCallback);
995 // BaseHandle CPtr is used in Registry and there is danger of deletion if we keep using it here.
996 // Restore current CPtr.
997 swigCPtr = currentCPtr;
1000 private bool OnClicked(IntPtr data)
1002 if (_clickedEventHandler != null)
1004 return _clickedEventHandler(this, null);
1009 private bool OnPressed(IntPtr data)
1011 if (_pressedEventHandler != null)
1013 return _pressedEventHandler(this, null);
1018 private bool OnReleased(IntPtr data)
1020 if (_releasedEventHandler != null)
1022 return _releasedEventHandler(this, null);
1027 private bool OnStateChanged(IntPtr data)
1029 if (_stateChangedEventHandler != null)
1031 return _stateChangedEventHandler(this, null);
1036 internal new class Property
1038 internal static readonly int UNSELECTED_VISUAL = Interop.Button.Button_Property_UNSELECTED_VISUAL_get();
1039 internal static readonly int SELECTED_VISUAL = Interop.Button.Button_Property_SELECTED_VISUAL_get();
1040 internal static readonly int DISABLED_SELECTED_VISUAL = Interop.Button.Button_Property_DISABLED_SELECTED_VISUAL_get();
1041 internal static readonly int DISABLED_UNSELECTED_VISUAL = Interop.Button.Button_Property_DISABLED_UNSELECTED_VISUAL_get();
1042 internal static readonly int UNSELECTED_BACKGROUND_VISUAL = Interop.Button.Button_Property_UNSELECTED_BACKGROUND_VISUAL_get();
1043 internal static readonly int SELECTED_BACKGROUND_VISUAL = Interop.Button.Button_Property_SELECTED_BACKGROUND_VISUAL_get();
1044 internal static readonly int DISABLED_UNSELECTED_BACKGROUND_VISUAL = Interop.Button.Button_Property_DISABLED_UNSELECTED_BACKGROUND_VISUAL_get();
1045 internal static readonly int DISABLED_SELECTED_BACKGROUND_VISUAL = Interop.Button.Button_Property_DISABLED_SELECTED_BACKGROUND_VISUAL_get();
1046 internal static readonly int LABEL_RELATIVE_ALIGNMENT = Interop.Button.Button_Property_LABEL_RELATIVE_ALIGNMENT_get();
1047 internal static readonly int LABEL_PADDING = Interop.Button.Button_Property_LABEL_PADDING_get();
1048 internal static readonly int FOREGROUND_VISUAL_PADDING = Interop.Button.Button_Property_VISUAL_PADDING_get();
1049 internal static readonly int AUTO_REPEATING = Interop.Button.Button_Property_AUTO_REPEATING_get();
1050 internal static readonly int INITIAL_AUTO_REPEATING_DELAY = Interop.Button.Button_Property_INITIAL_AUTO_REPEATING_DELAY_get();
1051 internal static readonly int NEXT_AUTO_REPEATING_DELAY = Interop.Button.Button_Property_NEXT_AUTO_REPEATING_DELAY_get();
1052 internal static readonly int TOGGLABLE = Interop.Button.Button_Property_TOGGLABLE_get();
1053 internal static readonly int SELECTED = Interop.Button.Button_Property_SELECTED_get();
1054 internal static readonly int UNSELECTED_COLOR = Interop.Button.Button_Property_UNSELECTED_COLOR_get();
1055 internal static readonly int SELECTED_COLOR = Interop.Button.Button_Property_SELECTED_COLOR_get();
1056 internal static readonly int LABEL = Interop.Button.Button_Property_LABEL_get();