[NUI] Add class SelectedChangedEventArgs to public (#2086)
[platform/core/csapi/tizenfx.git] / src / Tizen.NUI.Components / Controls / Button.cs
1 /*
2  * Copyright(c) 2020 Samsung Electronics Co., Ltd.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  */
17 using System;
18 using System.ComponentModel;
19 using Tizen.NUI.BaseComponents;
20 using Tizen.NUI.Binding;
21 using Tizen.NUI.Components.Extension;
22 using Tizen.NUI.Accessibility;
23
24 namespace Tizen.NUI.Components
25 {
26     /// <summary>
27     /// ClickedEventArgs is a class to record button click event arguments which will sent to user.
28     /// </summary>
29     /// <since_tizen> 8 </since_tizen>
30     public class ClickedEventArgs : EventArgs
31     {
32     }
33
34     /// <summary>
35     /// SelectedChangedEventArgs is a class to record item selected arguments which will sent to user.
36     /// </summary>
37     /// <since_tizen> 8 </since_tizen>
38     public class SelectedChangedEventArgs : EventArgs
39     {
40         /// <summary> Selected state </summary>
41         /// <since_tizen> 8 </since_tizen>
42         public bool IsSelected { get; set; }
43     }
44
45     /// <summary>
46     /// Button is one kind of common component, a button clearly describes what action will occur when the user selects it.
47     /// Button may contain text or an icon.
48     /// </summary>
49     /// <since_tizen> 6 </since_tizen>
50     public partial class Button : Control
51     {
52         /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
53         [EditorBrowsable(EditorBrowsableState.Never)]
54         public static readonly BindableProperty IconRelativeOrientationProperty = BindableProperty.Create(nameof(IconRelativeOrientation), typeof(IconOrientation?), typeof(Button), null, propertyChanged: (bindable, oldValue, newValue) =>
55         {
56             var instance = (Button)bindable;
57             if (newValue != null)
58             {
59                 if (instance.buttonStyle != null && instance.buttonStyle.IconRelativeOrientation != (IconOrientation?)newValue)
60                 {
61                     instance.buttonStyle.IconRelativeOrientation = (IconOrientation?)newValue;
62                     instance.UpdateUIContent();
63                 }
64             }
65         },
66         defaultValueCreator: (bindable) =>
67         {
68             var instance = (Button)bindable;
69             return instance.buttonStyle?.IconRelativeOrientation;
70         });
71         /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
72         [EditorBrowsable(EditorBrowsableState.Never)]
73         public static readonly BindableProperty IsEnabledProperty = BindableProperty.Create(nameof(IsEnabled), typeof(bool), typeof(Button), true, propertyChanged: (bindable, oldValue, newValue) =>
74         {
75             var instance = (Button)bindable;
76             if (newValue != null)
77             {
78                 if (instance.buttonStyle != null && (!instance.styleApplied || instance.buttonStyle.IsEnabled != (bool)newValue))
79                 {
80                     instance.buttonStyle.IsEnabled = (bool)newValue;
81                     instance.UpdateState();
82                 }
83             }
84         },
85         defaultValueCreator: (bindable) =>
86         {
87             var instance = (Button)bindable;
88             return instance.buttonStyle?.IsEnabled ?? true;
89         });
90         /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
91         [EditorBrowsable(EditorBrowsableState.Never)]
92         public static readonly BindableProperty IsSelectedProperty = BindableProperty.Create(nameof(IsSelected), typeof(bool), typeof(Button), true, propertyChanged: (bindable, oldValue, newValue) =>
93         {
94             var instance = (Button)bindable;
95             if (newValue != null)
96             {
97                 if (instance.buttonStyle != null && instance.IsSelectable && (!instance.styleApplied || instance.buttonStyle.IsSelected != (bool)newValue))
98                 {
99                     instance.buttonStyle.IsSelected = (bool)newValue;
100                     instance.UpdateState();
101                 }
102             }
103         },
104         defaultValueCreator: (bindable) =>
105         {
106             var instance = (Button)bindable;
107             return instance.IsSelectable && (instance.buttonStyle.IsSelected ?? false);
108         });
109         /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
110         [EditorBrowsable(EditorBrowsableState.Never)]
111         public static readonly BindableProperty IsSelectableProperty = BindableProperty.Create(nameof(IsSelectable), typeof(bool), typeof(Button), true, propertyChanged: (bindable, oldValue, newValue) =>
112         {
113             var instance = (Button)bindable;
114             if (newValue != null)
115             {
116                 if (instance.buttonStyle != null && (!instance.styleApplied || instance.buttonStyle.IsSelectable != (bool)newValue))
117                 {
118                     instance.buttonStyle.IsSelectable = (bool)newValue;
119                 }
120             }
121         },
122         defaultValueCreator: (bindable) =>
123         {
124             var instance = (Button)bindable;
125             return instance.buttonStyle?.IsSelectable ?? false;
126         });
127         /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
128         [EditorBrowsable(EditorBrowsableState.Never)]
129         public static readonly BindableProperty IconPaddingProperty = BindableProperty.Create(nameof(IconPadding), typeof(Extents), typeof(Button), null, propertyChanged: (bindable, oldValue, newValue) =>
130         {
131             var instance = (Button)bindable;
132             if (null != newValue && null != instance.buttonStyle?.IconPadding)
133             {
134                 instance.buttonStyle.IconPadding.CopyFrom((Extents)newValue);
135                 instance.UpdateUIContent();
136             }
137         },
138         defaultValueCreator: (bindable) =>
139         {
140             var instance = (Button)bindable;
141             return instance.buttonStyle?.IconPadding;
142         });
143         /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
144         [EditorBrowsable(EditorBrowsableState.Never)]
145         public static readonly BindableProperty TextPaddingProperty = BindableProperty.Create(nameof(TextPadding), typeof(Extents), typeof(Button), null, propertyChanged: (bindable, oldValue, newValue) =>
146         {
147             var instance = (Button)bindable;
148             if (null != newValue && null != instance.buttonStyle?.TextPadding)
149             {
150                 instance.buttonStyle.TextPadding.CopyFrom((Extents)newValue);
151                 instance.UpdateUIContent();
152             }
153         },
154         defaultValueCreator: (bindable) =>
155         {
156             var instance = (Button)bindable;
157             return instance.buttonStyle?.TextPadding;
158         });
159
160         static Button() { }
161
162         /// <summary>
163         /// Creates a new instance of a Button.
164         /// </summary>
165         /// <since_tizen> 6 </since_tizen>
166         public Button() : base()
167         {
168             Initialize();
169         }
170
171         /// <summary>
172         /// Creates a new instance of a Button with style.
173         /// </summary>
174         /// <param name="style">Create Button by special style defined in UX.</param>
175         /// <since_tizen> 8 </since_tizen>
176         public Button(string style) : base(style)
177         {
178             Initialize();
179         }
180
181         /// <summary>
182         /// Creates a new instance of a Button with style.
183         /// </summary>
184         /// <param name="buttonStyle">Create Button by style customized by user.</param>
185         /// <since_tizen> 8 </since_tizen>
186         public Button(ButtonStyle buttonStyle) : base(buttonStyle)
187         {
188             Initialize();
189         }
190
191         /// <summary>
192         /// An event for the button clicked signal which can be used to subscribe or unsubscribe the event handler provided by the user.<br />
193         /// </summary>
194         /// <since_tizen> 6 </since_tizen>
195         [Obsolete("Deprecated in API8; Will be removed in API10. Please use Clicked event instead.")]
196         public event EventHandler<ClickEventArgs> ClickEvent;
197
198         /// <summary>
199         /// An event for the button clicked signal which can be used to subscribe or unsubscribe the event handler provided by the user.
200         /// </summary>
201         /// <since_tizen> 8 </since_tizen>
202         public event EventHandler<ClickedEventArgs> Clicked;
203
204         /// <summary>
205         /// An event for the button state changed signal which can be used to subscribe or unsubscribe the event handler provided by the user.<br />
206         /// </summary>
207         /// <since_tizen> 6 </since_tizen>
208         [Obsolete("Deprecated in API8; Will be removed in API10. Please use View.ControlStateChangedEvent")]
209         public event EventHandler<StateChangedEventArgs> StateChangedEvent
210         {
211             add
212             {
213                 stateChangeHandler += value;
214             }
215             remove
216             {
217                 stateChangeHandler -= value;
218             }
219         }
220
221         /// <summary>
222         /// Icon orientation.
223         /// </summary>
224         /// <since_tizen> 6 </since_tizen>
225         public enum IconOrientation
226         {
227             /// <summary>
228             /// Top.
229             /// </summary>
230             /// <since_tizen> 6 </since_tizen>
231             Top,
232             /// <summary>
233             /// Bottom.
234             /// </summary>
235             /// <since_tizen> 6 </since_tizen>
236             Bottom,
237             /// <summary>
238             /// Left.
239             /// </summary>
240             /// <since_tizen> 6 </since_tizen>
241             Left,
242             /// <summary>
243             /// Right.
244             /// </summary>
245             /// <since_tizen> 6 </since_tizen>
246             Right,
247         }
248
249         /// <summary>
250         /// Button's icon part.
251         /// </summary>
252         /// <since_tizen> 8 </since_tizen>
253         public ImageView Icon
254         {
255             get
256             {
257                 if (null == buttonIcon)
258                 {
259                     buttonIcon = CreateIcon();
260                     if (null != Extension)
261                     {
262                         buttonIcon = Extension.OnCreateIcon(this, buttonIcon);
263                     }
264                     Add(buttonIcon);
265                     buttonIcon.Relayout += OnIconRelayout;
266                 }
267                 return buttonIcon;
268             }
269             internal set
270             {
271                 buttonIcon = value;
272             }
273         }
274
275         /// <summary>
276         /// Button's overlay image part.
277         /// </summary>
278         /// <since_tizen> 8 </since_tizen>
279         public ImageView OverlayImage
280         {
281             get
282             {
283                 if (null == overlayImage)
284                 {
285                     overlayImage = CreateOverlayImage();
286                     if (null != Extension)
287                     {
288                         overlayImage = Extension.OnCreateOverlayImage(this, overlayImage);
289                     }
290                     overlayImage.WidthResizePolicy = ResizePolicyType.FillToParent;
291                     overlayImage.HeightResizePolicy = ResizePolicyType.FillToParent;
292                     Add(overlayImage);
293                 }
294                 return overlayImage;
295             }
296             internal set
297             {
298                 overlayImage = value;
299             }
300         }
301
302         /// <summary>
303         /// Button's text part.
304         /// </summary>
305         /// <since_tizen> 8 </since_tizen>
306         public TextLabel TextLabel
307         {
308             get
309             {
310                 if (null == buttonText)
311                 {
312                     buttonText = CreateText();
313                     if (null != Extension)
314                     {
315                         buttonText = Extension.OnCreateText(this, buttonText);
316                     }
317                     buttonText.HorizontalAlignment = HorizontalAlignment.Center;
318                     buttonText.VerticalAlignment = VerticalAlignment.Center;
319                     Add(buttonText);
320                 }
321                 return buttonText;
322             }
323             internal set
324             {
325                 buttonText = value;
326                 AccessibilityManager.Instance.SetAccessibilityAttribute(this, AccessibilityManager.AccessibilityAttribute.Label, buttonText.Text);
327             }
328         }
329
330         /// <summary>
331         /// Return a copied Style instance of Button
332         /// </summary>
333         /// <remarks>
334         /// It returns copied Style instance and changing it does not effect to the Button.
335         /// Style setting is possible by using constructor or the function of ApplyStyle(ViewStyle viewStyle)
336         /// </remarks>
337         /// <since_tizen> 8 </since_tizen>
338         public new ButtonStyle Style
339         {
340             get
341             {
342                 var result = (ButtonStyle)ViewStyle.Clone();
343                 result.CopyPropertiesFromView(this);
344                 result.Text.CopyPropertiesFromView(TextLabel);
345                 result.Icon.CopyPropertiesFromView(Icon);
346                 result.Overlay.CopyPropertiesFromView(OverlayImage);
347                 return result;
348             }
349         }
350
351         /// <summary>
352         /// The text of Button.
353         /// </summary>
354         /// <since_tizen> 6 </since_tizen>
355         public string Text
356         {
357             get
358             {
359                 return TextLabel.Text;
360             }
361             set
362             {
363                 TextLabel.Text = value;
364             }
365         }
366
367         /// <summary>
368         /// Flag to decide Button can be selected or not.
369         /// </summary>
370         /// <since_tizen> 6 </since_tizen>
371         public bool IsSelectable
372         {
373             get
374             {
375                 return (bool)GetValue(IsSelectableProperty);
376             }
377             set
378             {
379                 SetValue(IsSelectableProperty, value);
380             }
381         }
382
383         /// <summary>
384         /// Translate text string in Button.
385         /// </summary>
386         /// <since_tizen> 6 </since_tizen>
387         public string TranslatableText
388         {
389             get
390             {
391                 return TextLabel.TranslatableText;
392             }
393             set
394             {
395                 TextLabel.TranslatableText = value;
396             }
397         }
398
399         /// <summary>
400         /// Text point size in Button.
401         /// </summary>
402         /// <since_tizen> 6 </since_tizen>
403         public float PointSize
404         {
405             get
406             {
407                 return TextLabel.PointSize;
408             }
409             set
410             {
411                 TextLabel.PointSize = value;
412             }
413         }
414
415         /// <summary>
416         /// Text font family in Button.
417         /// </summary>
418         /// <since_tizen> 6 </since_tizen>
419         public string FontFamily
420         {
421             get
422             {
423                 return TextLabel.FontFamily;
424             }
425             set
426             {
427                 TextLabel.FontFamily = value;
428             }
429         }
430
431         /// <summary>
432         /// Text color in Button.
433         /// </summary>
434         /// <since_tizen> 6 </since_tizen>
435         public Color TextColor
436         {
437             get
438             {
439                 return TextLabel.TextColor;
440             }
441             set
442             {
443                 TextLabel.TextColor = value;
444             }
445         }
446
447         /// <summary>
448         /// Text horizontal alignment in Button.
449         /// </summary>
450         /// <since_tizen> 6 </since_tizen>
451         public HorizontalAlignment TextAlignment
452         {
453             get
454             {
455                 return TextLabel.HorizontalAlignment;
456             }
457             set
458             {
459                 TextLabel.HorizontalAlignment = value;
460             }
461         }
462
463         /// <summary>
464         /// Icon image's resource url in Button.
465         /// </summary>
466         /// <since_tizen> 6 </since_tizen>
467         public string IconURL
468         {
469             get
470             {
471                 return Icon.ResourceUrl;
472             }
473             set
474             {
475                 Icon.ResourceUrl = value;
476             }
477         }
478
479         /// <summary>
480         /// Text string selector in Button.
481         /// Getter returns copied selector value if exist, null otherwise.
482         /// <exception cref="NullReferenceException">Thrown when setting null value.</exception>
483         /// </summary>
484         /// <since_tizen> 6 </since_tizen>
485         public StringSelector TextSelector
486         {
487             get => buttonText == null ? null : new StringSelector((Selector<string>)buttonText.GetValue(TextLabel.TextSelectorProperty));
488             set
489             {
490                 if (value == null || buttonText == null)
491                 {
492                     throw new NullReferenceException("Button.TextSelector is null");
493                 }
494                 else
495                 {
496                     buttonText.SetValue(TextLabel.TextSelectorProperty, value);
497                 }
498             }
499         }
500
501         /// <summary>
502         /// Translateable text string selector in Button.
503         /// Getter returns copied selector value if exist, null otherwise.
504         /// </summary>
505         /// <exception cref="NullReferenceException">Thrown when setting null value.</exception>
506         /// <since_tizen> 6 </since_tizen>
507         public StringSelector TranslatableTextSelector
508         {
509             get => buttonText == null ? null : new StringSelector((Selector<string>)buttonText.GetValue(TextLabel.TranslatableTextSelectorProperty));
510             set
511             {
512                 if (value == null || buttonText == null)
513                 {
514                     throw new NullReferenceException("Button.TranslatableTextSelector is null");
515                 }
516                 else
517                 {
518                     buttonText.SetValue(TextLabel.TranslatableTextSelectorProperty, value);
519                 }
520             }
521         }
522
523         /// <summary>
524         /// Text color selector in Button.
525         /// Getter returns copied selector value if exist, null otherwise.
526         /// </summary>
527         /// <exception cref="NullReferenceException">Thrown when setting null value.</exception>
528         /// <since_tizen> 6 </since_tizen>
529         public ColorSelector TextColorSelector
530         {
531             get => buttonText == null ? null : new ColorSelector((Selector<Color>)buttonText.GetValue(TextLabel.TextColorSelectorProperty));
532             set
533             {
534                 if (value == null || buttonText == null)
535                 {
536                     throw new NullReferenceException("Button.TextColorSelectorProperty is null");
537                 }
538                 else
539                 {
540                     buttonText.SetValue(TextLabel.TextColorSelectorProperty, value);
541                 }
542             }
543         }
544
545         /// <summary>
546         /// Text font size selector in Button.
547         /// Getter returns copied selector value if exist, null otherwise.
548         /// </summary>
549         /// <exception cref="NullReferenceException">Thrown when setting null value.</exception>
550         /// <since_tizen> 6 </since_tizen>
551         public FloatSelector PointSizeSelector
552         {
553             get => buttonText == null ? null : new FloatSelector((Selector<float?>)buttonText.GetValue(TextLabel.PointSizeSelectorProperty));
554             set
555             {
556                 if (value == null || buttonText == null)
557                 {
558                     throw new NullReferenceException("Button.PointSizeSelector is null");
559                 }
560                 else
561                 {
562                     buttonText.SetValue(TextLabel.PointSizeSelectorProperty, value);
563                 }
564             }
565         }
566
567         /// <summary>
568         /// Icon image's resource url selector in Button.
569         /// Getter returns copied selector value if exist, null otherwise.
570         /// </summary>
571         /// <exception cref="NullReferenceException">Thrown when setting null value.</exception>
572         /// <since_tizen> 6 </since_tizen>
573         public StringSelector IconURLSelector
574         {
575             get => buttonIcon == null ? null : new StringSelector((Selector<string>)buttonIcon.GetValue(ImageView.ResourceUrlSelectorProperty));
576             set
577             {
578                 if (value == null || buttonIcon == null)
579                 {
580                     throw new NullReferenceException("Button.IconURLSelector is null");
581                 }
582                 else
583                 {
584                     buttonIcon.SetValue(ImageView.ResourceUrlSelectorProperty, value);
585                 }
586             }
587         }
588
589         /// <summary>
590         /// Flag to decide selected state in Button.
591         /// </summary>
592         /// <since_tizen> 6 </since_tizen>
593         public bool IsSelected
594         {
595             get
596             {
597                 return (bool)GetValue(IsSelectedProperty);
598             }
599             set
600             {
601                 SetValue(IsSelectedProperty, value);
602             }
603         }
604
605         /// <summary>
606         /// Flag to decide enable or disable in Button.
607         /// </summary>
608         /// <since_tizen> 6 </since_tizen>
609         public bool IsEnabled
610         {
611             get
612             {
613                 return (bool)GetValue(IsEnabledProperty);
614             }
615             set
616             {
617                 SetValue(IsEnabledProperty, value);
618             }
619         }
620
621         /// <summary>
622         /// Icon relative orientation in Button, work only when show icon and text.
623         /// </summary>
624         /// <since_tizen> 8 </since_tizen>
625         public IconOrientation? IconRelativeOrientation
626         {
627             get
628             {
629                 return (IconOrientation?)GetValue(IconRelativeOrientationProperty);
630             }
631             set
632             {
633                 SetValue(IconRelativeOrientationProperty, value);
634             }
635         }
636
637         /// <summary>
638         /// Icon padding in Button, work only when show icon and text.
639         /// </summary>
640         /// <since_tizen> 6 </since_tizen>
641         public Extents IconPadding
642         {
643             get => (Extents)GetValue(IconPaddingProperty);
644             set => SetValue(IconPaddingProperty, value);
645         }
646
647         /// <summary>
648         /// Text padding in Button, work only when show icon and text.
649         /// </summary>
650         /// <since_tizen> 6 </since_tizen>
651         public Extents TextPadding
652         {
653             get => (Extents)GetValue(TextPaddingProperty);
654             set => SetValue(TextPaddingProperty, value);
655         }
656
657         private ButtonStyle buttonStyle => ViewStyle as ButtonStyle;
658
659         /// <summary>
660         /// Called after a key event is received by the view that has had its focus set.
661         /// </summary>
662         /// <param name="key">The key event.</param>
663         /// <returns>True if the key event should be consumed.</returns>
664         /// <since_tizen> 6 </since_tizen>
665         public override bool OnKey(Key key)
666         {
667             if (!IsEnabled || null == key)
668             {
669                 return false;
670             }
671
672             if (key.State == Key.StateType.Down)
673             {
674                 if (key.KeyPressedName == "Return")
675                 {
676                     isPressed = true;
677                     UpdateState();
678                 }
679             }
680             else if (key.State == Key.StateType.Up)
681             {
682                 if (key.KeyPressedName == "Return")
683                 {
684                     bool clicked = isPressed && IsEnabled;
685
686                     isPressed = false;
687
688                     if (IsSelectable)
689                     {
690                         IsSelected = !IsSelected;
691                     }
692                     else
693                     {
694                         UpdateState();
695                     }
696
697                     if (clicked)
698                     {
699                         ClickedEventArgs eventArgs = new ClickedEventArgs();
700                         OnClickedInternal(eventArgs);
701                     }
702                 }
703             }
704             return base.OnKey(key);
705         }
706
707         /// <summary>
708         /// Called when the control gain key input focus. Should be overridden by derived classes if they need to customize what happens when the focus is gained.
709         /// </summary>
710         /// <since_tizen> 8 </since_tizen>
711         public override void OnFocusGained()
712         {
713             base.OnFocusGained();
714             UpdateState();
715         }
716
717         /// <summary>
718         /// Called when the control loses key input focus. Should be overridden by derived classes if they need to customize what happens when the focus is lost.
719         /// </summary>
720         /// <since_tizen> 8 </since_tizen>
721         public override void OnFocusLost()
722         {
723             base.OnFocusLost();
724             UpdateState();
725         }
726
727         /// <summary>
728         /// Called after a touch event is received by the owning view.<br />
729         /// CustomViewBehaviour.REQUIRES_TOUCH_EVENTS must be enabled during construction. See CustomView(ViewWrapperImpl.CustomViewBehaviour behaviour).<br />
730         /// </summary>
731         /// <param name="touch">The touch event.</param>
732         /// <returns>True if the event should be consumed.</returns>
733         /// <since_tizen> 8 </since_tizen>
734         [Obsolete("Deprecated in API8; Will be removed in API10. Please use OnClicked instead.")]
735         public override bool OnTouch(Touch touch)
736         {
737             return base.OnTouch(touch);
738         }
739
740         /// <summary>
741         /// Apply style to button.
742         /// </summary>
743         /// <param name="viewStyle">The style to apply.</param>
744         /// <since_tizen> 8 </since_tizen>
745         public override void ApplyStyle(ViewStyle viewStyle)
746         {
747             styleApplied = false;
748
749             base.ApplyStyle(viewStyle);
750
751             if (null != buttonStyle)
752             {
753                 Extension = buttonStyle.CreateExtension();
754                 if (buttonStyle.Overlay != null)
755                 {
756                     OverlayImage?.ApplyStyle(buttonStyle.Overlay);
757                 }
758
759                 if (buttonStyle.Text != null)
760                 {
761                     TextLabel?.ApplyStyle(buttonStyle.Text);
762                 }
763
764                 if (buttonStyle.Icon != null)
765                 {
766                     Icon?.ApplyStyle(buttonStyle.Icon);
767                 }
768             }
769
770             styleApplied = true;
771         }
772
773         /// <summary>
774         /// ClickEventArgs is a class to record button click event arguments which will sent to user.
775         /// </summary>
776         /// <since_tizen> 6 </since_tizen>
777         [Obsolete("Deprecated in API8; Will be removed in API10. Please use ClickedEventArgs instead.")]
778         public class ClickEventArgs : EventArgs
779         {
780         }
781
782         /// <summary>
783         /// StateChangeEventArgs is a class to record button state change event arguments which will sent to user.
784         /// </summary>
785         /// <since_tizen> 6 </since_tizen>
786         [Obsolete("Deprecated in API8; Will be removed in API10. Please use View.ControlStateChangedEventArgs")]
787         public class StateChangedEventArgs : EventArgs
788         {
789             /// <summary> previous state of Button </summary>
790             /// <since_tizen> 6 </since_tizen>
791             [Obsolete("Deprecated in API8; Will be removed in API10")]
792             public ControlStates PreviousState;
793             /// <summary> current state of Button </summary>
794             /// <since_tizen> 6 </since_tizen>
795             [Obsolete("Deprecated in API8; Will be removed in API10")]
796             public ControlStates CurrentState;
797         }
798
799         /// <summary>
800         /// Get current text part to the attached ButtonExtension.
801         /// </summary>
802         /// <remarks>
803         /// It returns null if the passed extension is invalid.
804         /// </remarks>
805         /// <param name="extension">The extension instance that is currently attached to this Button.</param>
806         /// <return>The button's text part.</return>
807         [EditorBrowsable(EditorBrowsableState.Never)]
808         public TextLabel GetCurrentText(ButtonExtension extension)
809         {
810             return (extension == Extension) ? TextLabel : null;
811         }
812
813         /// <summary>
814         /// Get current icon part to the attached ButtonExtension.
815         /// </summary>
816         /// <remarks>
817         /// It returns null if the passed extension is invalid.
818         /// </remarks>
819         /// <param name="extension">The extension instance that is currently attached to this Button.</param>
820         /// <return>The button's icon part.</return>
821         [EditorBrowsable(EditorBrowsableState.Never)]
822         public ImageView GetCurrentIcon(ButtonExtension extension)
823         {
824             return (extension == Extension) ? Icon : null;
825         }
826
827         /// <summary>
828         /// Get current overlay image part to the attached ButtonExtension.
829         /// </summary>
830         /// <remarks>
831         /// It returns null if the passed extension is invalid.
832         /// </remarks>
833         /// <param name="extension">The extension instance that is currently attached to this Button.</param>
834         /// <return>The button's overlay image part.</return>
835         [EditorBrowsable(EditorBrowsableState.Never)]
836         public ImageView GetCurrentOverlayImage(ButtonExtension extension)
837         {
838             return (extension == Extension) ? OverlayImage : null;
839         }
840     }
841 }