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