[NUI] Sync with dalihub (#969)
[platform/core/csapi/tizenfx.git] / src / Tizen.NUI.CommonUI / Controls / SelectButton.cs
1 /*
2  * Copyright(c) 2019 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 Tizen.NUI.BaseComponents;
19 using System.ComponentModel;
20
21 namespace Tizen.NUI.CommonUI
22 {
23     /// <summary>
24     /// SelectButton is base class of CheckBox and RadioButton.
25     /// It can be used as selector and add into group for single-choice or multiple-choice .
26     /// User can handle Navigation by adding/inserting/deleting NavigationItem.
27     /// </summary>
28     /// <since_tizen> 6 </since_tizen>
29     /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
30     [EditorBrowsable(EditorBrowsableState.Never)]
31     public class SelectButton : Button
32     {
33         /// <summary>
34         /// Item group which is used to manager all SelectButton in it.
35         /// </summary>
36         /// <since_tizen> 6 </since_tizen>
37         /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
38         [EditorBrowsable(EditorBrowsableState.Never)]
39         protected SelectGroup itemGroup = null;
40
41         private ImageView checkShadowImage;
42         private ImageView checkBackgroundImage;
43         private ImageView checkImage;
44
45         private SelectButtonAttributes selectButtonAttributes;
46
47         /// <summary>
48         /// Creates a new instance of a SelectButton.
49         /// </summary>
50         /// <since_tizen> 6 </since_tizen>
51         /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
52         [EditorBrowsable(EditorBrowsableState.Never)]
53         public SelectButton() : base()
54         {
55             Initialize();
56         }
57         /// <summary>
58         /// Creates a new instance of a SelectButton with style.
59         /// </summary>
60         /// <param name="style">Create SelectButton by special style defined in UX.</param>
61         /// <since_tizen> 6 </since_tizen>
62         /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
63         [EditorBrowsable(EditorBrowsableState.Never)]
64         public SelectButton(string style) : base(style)
65         {
66             Initialize();
67         }
68
69         /// <summary>
70         /// Creates a new instance of a SelectButton with attributes.
71         /// </summary>
72         /// <param name="attributes">Create SelectButton by attributes customized by user.</param>
73         /// <since_tizen> 6 </since_tizen>
74         /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
75         [EditorBrowsable(EditorBrowsableState.Never)]
76         public SelectButton(SelectButtonAttributes attributes) : base(attributes)
77         {
78             Initialize();
79         }
80
81         /// <summary>
82         /// An event for the item selected signal which can be used to subscribe or unsubscribe the event handler provided by the user.<br />
83         /// </summary>
84         /// <since_tizen> 6 </since_tizen>
85         /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
86         [EditorBrowsable(EditorBrowsableState.Never)]
87         public event EventHandler<SelectEventArgs> SelectedEvent;
88
89         /// <summary>
90         /// Index of selection in selection group. If selection is not in the group, return -1;
91         /// </summary>
92         /// <since_tizen> 6 </since_tizen>
93         /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
94         [EditorBrowsable(EditorBrowsableState.Never)]
95         public int Index
96         {
97             get
98             {
99                 if (itemGroup != null)
100                 {
101                     return itemGroup.GetIndex(this);
102                 }
103
104                 return -1;
105             }
106         }
107
108         /// <summary>
109         /// Check image's resource url in SelectButton.
110         /// </summary>
111         /// <since_tizen> 6 </since_tizen>
112         /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
113         [EditorBrowsable(EditorBrowsableState.Never)]
114         public string CheckImageURL
115         {
116             get
117             {
118                 return selectButtonAttributes?.CheckImageAttributes?.ResourceURL?.All;
119             }
120             set
121             {
122                 if (value != null)
123                 {
124                     CreateCheckImageAttributes();
125                     if (selectButtonAttributes.CheckImageAttributes.ResourceURL == null)
126                     {
127                         selectButtonAttributes.CheckImageAttributes.ResourceURL = new StringSelector();
128                     }
129                     selectButtonAttributes.CheckImageAttributes.ResourceURL.All = value;
130                     RelayoutRequest();
131                 }
132             }
133         }
134
135         /// <summary>
136         /// Check image's resource url selector in SelectButton.
137         /// </summary>
138         /// <since_tizen> 6 </since_tizen>
139         /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
140         [EditorBrowsable(EditorBrowsableState.Never)]
141         public StringSelector CheckImageURLSelector
142         {
143             get
144             {
145                 return selectButtonAttributes?.CheckImageAttributes?.ResourceURL;
146             }
147             set
148             {
149                 if (value != null)
150                 {
151                     CreateCheckImageAttributes();
152                     selectButtonAttributes.CheckImageAttributes.ResourceURL = value.Clone() as StringSelector;
153                     RelayoutRequest();
154                 }
155             }
156         }
157
158         /// <summary>
159         /// Check image's opacity in SelectButton.
160         /// </summary>
161         /// <since_tizen> 6 </since_tizen>
162         /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
163         [EditorBrowsable(EditorBrowsableState.Never)]
164         public float CheckImageOpacity
165         {
166             get
167             {
168                 return selectButtonAttributes?.CheckImageAttributes?.Opacity?.All ?? 0;
169             }
170             set
171             {
172                 CreateCheckImageAttributes();
173                 if (selectButtonAttributes.CheckImageAttributes.Opacity == null)
174                 {
175                     selectButtonAttributes.CheckImageAttributes.Opacity = new FloatSelector();
176                 }
177                 selectButtonAttributes.CheckImageAttributes.Opacity.All = value;
178                 RelayoutRequest();
179             }
180         }
181
182         /// <summary>
183         /// Check image's opacity selector in SelectButton.
184         /// </summary>
185         /// <since_tizen> 6 </since_tizen>
186         /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
187         [EditorBrowsable(EditorBrowsableState.Never)]
188         public FloatSelector CheckImageOpacitySelector
189         {
190             get
191             {
192                 return selectButtonAttributes?.CheckImageAttributes?.Opacity;
193             }
194             set
195             {
196                 if (value != null)
197                 {
198                     CreateCheckImageAttributes();
199                     selectButtonAttributes.CheckImageAttributes.Opacity = value.Clone() as FloatSelector;
200                     RelayoutRequest();
201                 }
202             }
203         }
204
205         /// <summary>
206         /// Check image's size in SelectButton.
207         /// </summary>
208         /// <since_tizen> 6 </since_tizen>
209         /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
210         [EditorBrowsable(EditorBrowsableState.Never)]
211         public Size2D CheckImageSize2D
212         {
213             get
214             {
215                 return selectButtonAttributes?.CheckImageAttributes?.Size2D ?? new Size2D(0, 0);
216             }
217             set
218             {
219                 CreateCheckImageAttributes();
220                 selectButtonAttributes.CheckImageAttributes.Size2D = value;
221                 RelayoutRequest();
222             }
223         }
224
225         /// <summary>
226         /// Background image's resource url in SelectButton.
227         /// </summary>
228         /// <since_tizen> 6 </since_tizen>
229         /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
230         [EditorBrowsable(EditorBrowsableState.Never)]
231         public string CheckBackgroundImageURL
232         {
233             get
234             {
235                 return selectButtonAttributes?.CheckBackgroundImageAttributes?.ResourceURL?.All;
236             }
237             set
238             {
239                 if (value != null)
240                 {
241                     CreateCheckBackgroundImageAttributes();
242                     if (selectButtonAttributes.CheckBackgroundImageAttributes.ResourceURL == null)
243                     {
244                         selectButtonAttributes.CheckBackgroundImageAttributes.ResourceURL = new StringSelector();
245                     }
246                     selectButtonAttributes.CheckBackgroundImageAttributes.ResourceURL.All = value;
247                     RelayoutRequest();
248                 }
249             }
250         }
251
252         /// <summary>
253         /// Background image's resource url selector in SelectButton.
254         /// </summary>
255         /// <since_tizen> 6 </since_tizen>
256         /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
257         [EditorBrowsable(EditorBrowsableState.Never)]
258         public StringSelector CheckBackgroundImageURLSelector
259         {
260             get
261             {
262                 return selectButtonAttributes?.CheckBackgroundImageAttributes?.ResourceURL;
263             }
264             set
265             {
266                 if (value != null)
267                 {
268                     CreateCheckBackgroundImageAttributes();
269                     selectButtonAttributes.CheckBackgroundImageAttributes.ResourceURL = value.Clone() as StringSelector;
270                     RelayoutRequest();
271                 }
272             }
273         }
274
275         /// <summary>
276         /// Background image's opacity in SelectButton.
277         /// </summary>
278         /// <since_tizen> 6 </since_tizen>
279         /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
280         [EditorBrowsable(EditorBrowsableState.Never)]
281         public float CheckBackgroundImageOpacity
282         {
283             get
284             {
285                 return selectButtonAttributes?.CheckBackgroundImageAttributes?.Opacity?.All ?? 0;
286             }
287             set
288             {
289                 CreateCheckBackgroundImageAttributes();
290                 if (selectButtonAttributes.CheckBackgroundImageAttributes.Opacity == null)
291                 {
292                     selectButtonAttributes.CheckBackgroundImageAttributes.Opacity = new FloatSelector();
293                 }
294                 selectButtonAttributes.CheckBackgroundImageAttributes.Opacity.All = value;
295                 RelayoutRequest();
296             }
297         }
298
299         /// <summary>
300         /// Background image's opacity selector in SelectButton.
301         /// </summary>
302         /// <since_tizen> 6 </since_tizen>
303         /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
304         [EditorBrowsable(EditorBrowsableState.Never)]
305         public FloatSelector CheckBackgroundImageOpacitySelector
306         {
307             get
308             {
309                 return selectButtonAttributes?.CheckBackgroundImageAttributes?.Opacity;
310             }
311             set
312             {
313                 if (value != null)
314                 {
315                     CreateCheckBackgroundImageAttributes();
316                     selectButtonAttributes.CheckBackgroundImageAttributes.Opacity = value.Clone() as FloatSelector;
317                     RelayoutRequest();
318                 }
319             }
320         }
321
322         /// <summary>
323         /// Shadow image's resource url in SelectButton.
324         /// </summary>
325         /// <since_tizen> 6 </since_tizen>
326         /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
327         [EditorBrowsable(EditorBrowsableState.Never)]
328         public string CheckShadowImageURL
329         {
330             get
331             {
332                 return selectButtonAttributes?.CheckShadowImageAttributes?.ResourceURL?.All;
333             }
334             set
335             {
336                 if (value != null)
337                 {
338                     CreateCheckShadowImageAttributes();
339                     if (selectButtonAttributes.CheckShadowImageAttributes.ResourceURL == null)
340                     {
341                         selectButtonAttributes.CheckShadowImageAttributes.ResourceURL = new StringSelector();
342                     }
343                     selectButtonAttributes.CheckShadowImageAttributes.ResourceURL.All = value;
344                     RelayoutRequest();
345                 }
346             }
347         }
348
349         /// <summary>
350         /// Shadow image's resource url selector in SelectButton.
351         /// </summary>
352         /// <since_tizen> 6 </since_tizen>
353         /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
354         [EditorBrowsable(EditorBrowsableState.Never)]
355         public StringSelector CheckShadowImageURLSelector
356         {
357             get
358             {
359                 return selectButtonAttributes?.CheckShadowImageAttributes?.ResourceURL;
360             }
361             set
362             {
363                 if (value != null)
364                 {
365                     CreateCheckShadowImageAttributes();
366                     selectButtonAttributes.CheckShadowImageAttributes.ResourceURL = value.Clone() as StringSelector;
367                     RelayoutRequest();
368                 }
369             }
370         }
371
372         /// <summary>
373         /// Shadow image's opacity in SelectButton.
374         /// </summary>
375         /// <since_tizen> 6 </since_tizen>
376         /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
377         [EditorBrowsable(EditorBrowsableState.Never)]
378         public float CheckShadowImageOpacity
379         {
380             get
381             {
382                 return selectButtonAttributes?.CheckShadowImageAttributes?.Opacity?.All ?? 0;
383             }
384             set
385             {
386                 CreateCheckShadowImageAttributes();
387                 if (selectButtonAttributes.CheckShadowImageAttributes.Opacity == null)
388                 {
389                     selectButtonAttributes.CheckShadowImageAttributes.Opacity = new FloatSelector();
390                 }
391                 selectButtonAttributes.CheckShadowImageAttributes.Opacity.All = value;
392                 RelayoutRequest();
393             }
394         }
395
396         /// <summary>
397         /// Shadow image's opacity selector in SelectButton.
398         /// </summary>
399         /// <since_tizen> 6 </since_tizen>
400         /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
401         [EditorBrowsable(EditorBrowsableState.Never)]
402         public FloatSelector CheckShadowImageOpacitySelector
403         {
404             get
405             {
406                 return selectButtonAttributes?.CheckShadowImageAttributes?.Opacity;
407             }
408             set
409             {
410                 if (value != null)
411                 {
412                     CreateCheckShadowImageAttributes();
413                     selectButtonAttributes.CheckShadowImageAttributes.Opacity = value.Clone() as FloatSelector;
414                     RelayoutRequest();
415                 }
416             }
417         }
418
419         /// <summary>
420         /// CheckImage left padding in SelectButton.
421         /// </summary>
422         /// <since_tizen> 6 </since_tizen>
423         /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
424         [EditorBrowsable(EditorBrowsableState.Never)]
425         public int CheckImagePaddingLeft
426         {
427             get
428             {
429                 return selectButtonAttributes?.CheckImageAttributes?.PaddingLeft ?? 0;
430             }
431             set
432             {
433                 CreateCheckImageAttributes();
434                 CreateCheckBackgroundImageAttributes();
435                 CreateCheckShadowImageAttributes();
436                 selectButtonAttributes.CheckImageAttributes.PaddingLeft = value;
437                 selectButtonAttributes.CheckBackgroundImageAttributes.PaddingLeft = value;
438                 selectButtonAttributes.CheckShadowImageAttributes.PaddingLeft = value;
439                 RelayoutRequest();
440             }
441         }
442
443         /// <summary>
444         /// CheckImage right padding in SelectButton.
445         /// </summary>
446         /// <since_tizen> 6 </since_tizen>
447         /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
448         [EditorBrowsable(EditorBrowsableState.Never)]
449         public int CheckImagePaddingRight
450         {
451             get
452             {
453                 return selectButtonAttributes?.CheckImageAttributes?.PaddingRight ?? 0;
454             }
455             set
456             {
457                 CreateCheckImageAttributes();
458                 CreateCheckBackgroundImageAttributes();
459                 CreateCheckShadowImageAttributes();
460                 selectButtonAttributes.CheckImageAttributes.PaddingRight = value;
461                 selectButtonAttributes.CheckBackgroundImageAttributes.PaddingRight = value;
462                 selectButtonAttributes.CheckShadowImageAttributes.PaddingRight = value;
463                 RelayoutRequest();
464             }
465         }
466
467         /// <summary>
468         /// CheckImage top padding in SelectButton.
469         /// </summary>
470         /// <since_tizen> 6 </since_tizen>
471         /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
472         [EditorBrowsable(EditorBrowsableState.Never)]
473         public int CheckImagePaddingTop
474         {
475             get
476             {
477                 return selectButtonAttributes?.CheckImageAttributes?.PaddingTop ?? 0;
478             }
479             set
480             {
481                 CreateCheckImageAttributes();
482                 CreateCheckBackgroundImageAttributes();
483                 CreateCheckShadowImageAttributes();
484                 selectButtonAttributes.CheckImageAttributes.PaddingTop = value;
485                 selectButtonAttributes.CheckBackgroundImageAttributes.PaddingTop = value;
486                 selectButtonAttributes.CheckShadowImageAttributes.PaddingTop = value;
487                 RelayoutRequest();
488             }
489         }
490
491         /// <summary>
492         /// CheckImage bottom padding in SelectButton.
493         /// </summary>
494         /// <since_tizen> 6 </since_tizen>
495         /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
496         [EditorBrowsable(EditorBrowsableState.Never)]
497         public int CheckImagePaddingBottom
498         {
499             get
500             {
501                 return selectButtonAttributes?.CheckImageAttributes?.PaddingBottom ?? 0;
502             }
503             set
504             {
505                 CreateCheckImageAttributes();
506                 CreateCheckBackgroundImageAttributes();
507                 CreateCheckShadowImageAttributes();
508                 selectButtonAttributes.CheckImageAttributes.PaddingBottom = value;
509                 selectButtonAttributes.CheckBackgroundImageAttributes.PaddingBottom = value;
510                 selectButtonAttributes.CheckShadowImageAttributes.PaddingBottom = value;
511                 RelayoutRequest();
512             }
513         }
514
515         /// <summary>
516         /// Theme change callback when theme is changed, this callback will be trigger.
517         /// </summary>
518         /// <since_tizen> 6 </since_tizen>
519         /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
520         [EditorBrowsable(EditorBrowsableState.Never)]
521         protected override void OnThemeChangedEvent(object sender, StyleManager.ThemeChangeEventArgs e)
522         {
523             SelectButtonAttributes tempAttributes = StyleManager.Instance.GetAttributes(style) as SelectButtonAttributes;
524             if (tempAttributes != null)
525             {
526                 attributes = selectButtonAttributes = tempAttributes;
527                 RelayoutRequest();
528             }
529         }
530
531         /// <summary>
532         /// Dispose SelectButton and all children on it.
533         /// </summary>
534         /// <param name="type">Dispose type.</param>
535         /// <since_tizen> 6 </since_tizen>
536         /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
537         [EditorBrowsable(EditorBrowsableState.Never)]
538         protected override void Dispose(DisposeTypes type)
539         {
540             if (disposed)
541             {
542                 return;
543             }
544
545             if (type == DisposeTypes.Explicit)
546             {
547                 if (checkShadowImage != null)
548                 {
549                     Remove(checkShadowImage);
550                     checkShadowImage.Dispose();
551                     checkShadowImage = null;
552                 }
553                 if (checkBackgroundImage != null)
554                 {
555                     Remove(checkBackgroundImage);
556                     checkBackgroundImage.Dispose();
557                     checkBackgroundImage = null;
558                 }
559                 if (checkImage != null)
560                 {
561                     Remove(checkImage);
562                     checkImage.Dispose();
563                     checkImage = null;
564                 }
565             }
566
567             base.Dispose(type);
568         }
569
570         /// <summary>
571         /// Update SelectButton by attributes.
572         /// </summary>
573         /// <since_tizen> 6 </since_tizen>
574         /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
575         [EditorBrowsable(EditorBrowsableState.Never)]
576         protected override void OnUpdate()
577         {
578             if (selectButtonAttributes.CheckImageAttributes != null)
579             {
580                 if (checkImage == null)
581                 {
582                     checkImage = new ImageView();
583                     checkImage.Name = "CheckImage";
584                     Add(checkImage);
585                 }
586                 ApplyAttributes(checkImage, selectButtonAttributes.CheckImageAttributes);  
587             }
588             else
589             {
590                 if (checkImage != null)
591                 {
592                     Remove(checkImage);
593                     checkImage.Dispose();
594                     checkImage = null;
595                 }
596             }
597
598             if (selectButtonAttributes.CheckShadowImageAttributes != null)
599             {
600                 if (checkShadowImage == null)
601                 {
602                     checkShadowImage = new ImageView();
603                     checkShadowImage.Name = "CheckShadowImage";
604                     Add(checkShadowImage);
605                 }
606                 ApplyAttributes(checkShadowImage, selectButtonAttributes.CheckShadowImageAttributes);
607             }
608             else
609             {
610                 if (checkShadowImage != null)
611                 {
612                     Remove(checkShadowImage);
613                     checkShadowImage.Dispose();
614                     checkShadowImage = null;
615                 }
616             }
617
618             if (selectButtonAttributes.CheckBackgroundImageAttributes != null)
619             {
620                 if (checkBackgroundImage == null)
621                 {
622                     checkBackgroundImage = new ImageView();
623                     checkBackgroundImage.Name = "CheckBackgroundImage";
624                     Add(checkBackgroundImage);
625                 }
626                 ApplyAttributes(checkBackgroundImage, selectButtonAttributes.CheckBackgroundImageAttributes);
627             }
628             else
629             {
630                 if (checkBackgroundImage != null)
631                 {
632                     Remove(checkBackgroundImage);
633                     checkBackgroundImage.Dispose();
634                     checkBackgroundImage = null;
635                 }
636             }
637
638             UpdateTextAttributes();
639             base.OnUpdate();
640
641             checkShadowImage?.RaiseToTop();
642             checkBackgroundImage?.RaiseToTop();
643             checkImage?.RaiseToTop();
644         }
645
646         /// <summary>
647         /// Called after a key event is received by the view that has had its focus set.
648         /// </summary>
649         /// <param name="key">The key event.</param>
650         /// <returns>True if the key event should be consumed.</returns>
651         /// <since_tizen> 6 </since_tizen>
652         /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
653         [EditorBrowsable(EditorBrowsableState.Never)]
654         public override bool OnKey(Key key)
655         {
656             if (IsEnabled == false)
657             {
658                 return false;
659             }
660             bool ret = base.OnKey(key);
661             if (key.State == Key.StateType.Up)
662             {
663                 if (key.KeyPressedName == "Return")
664                 {
665                     OnSelect();
666                 }
667             }
668
669             return ret;
670         }
671
672         /// <summary>
673         /// Called after a touch event is received by the owning view.<br />
674         /// CustomViewBehaviour.REQUIRES_TOUCH_EVENTS must be enabled during construction. See CustomView(ViewWrapperImpl.CustomViewBehaviour behaviour).<br />
675         /// </summary>
676         /// <param name="touch">The touch event.</param>
677         /// <returns>True if the event should be consumed.</returns>
678         /// <since_tizen> 6 </since_tizen>
679         /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
680         [EditorBrowsable(EditorBrowsableState.Never)]
681         public override bool OnTouch(Touch touch)
682         {
683             if (IsEnabled == false)
684             {
685                 return false;
686             }
687             PointStateType state = touch.GetState(0);
688             bool ret = base.OnTouch(touch);
689             switch (state)
690             {
691                 case PointStateType.Up:
692                     OnSelect();
693                     break;
694                 default:
695                     break;
696             }
697             return ret;
698         }
699
700         /// <summary>
701         /// Get SelectButton attribues.
702         /// </summary>
703         /// <since_tizen> 6 </since_tizen>
704         /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
705         [EditorBrowsable(EditorBrowsableState.Never)]
706         protected override Attributes GetAttributes()
707         {
708             return new SelectButtonAttributes();
709         }
710
711         /// <summary>
712         /// Overrides this method if want to handle behavior after pressing return key by user.
713         /// </summary>
714         /// <since_tizen> 6 </since_tizen>
715         /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
716         [EditorBrowsable(EditorBrowsableState.Never)]
717         protected virtual void OnSelected()
718         {
719         }
720
721         private void Initialize()
722         {
723             selectButtonAttributes = attributes as SelectButtonAttributes;
724             if (selectButtonAttributes == null)
725             {
726                 throw new Exception("SelectButton attribute parse error.");
727             }
728
729             selectButtonAttributes.IsSelectable = true;
730             LayoutDirectionChanged += SelectButtonLayoutDirectionChanged;
731         }
732
733         private void UpdateTextAttributes()
734         {
735             if (selectButtonAttributes.TextAttributes != null)
736             {
737                 selectButtonAttributes.TextAttributes.PositionUsesPivotPoint = true;
738                 selectButtonAttributes.TextAttributes.ParentOrigin = Tizen.NUI.ParentOrigin.TopLeft;
739                 selectButtonAttributes.TextAttributes.PivotPoint = Tizen.NUI.PivotPoint.TopLeft;
740                 selectButtonAttributes.TextAttributes.WidthResizePolicy = ResizePolicyType.Fixed;
741                 selectButtonAttributes.TextAttributes.HeightResizePolicy = ResizePolicyType.Fixed;
742
743                 int iconWidth = CheckImageSize2D.Width;
744
745                 int textPaddingLeft = selectButtonAttributes.TextAttributes.PaddingLeft;
746                 int textPaddingRight = selectButtonAttributes.TextAttributes.PaddingRight;
747
748                 if(selectButtonAttributes.TextAttributes.Size2D == null)
749                 {
750                     selectButtonAttributes.TextAttributes.Size2D = new Size2D(Size2D.Width - iconWidth - CheckImagePaddingLeft - CheckImagePaddingRight - textPaddingLeft - textPaddingRight, Size2D.Height);
751                 }
752                 
753                 if(selectButtonAttributes.TextAttributes.Position2D == null)
754                 {
755                     selectButtonAttributes.TextAttributes.Position2D = new Position2D(CheckImagePaddingLeft + iconWidth + CheckImagePaddingRight + textPaddingLeft, 0);
756                 }
757                 
758                 selectButtonAttributes.TextAttributes.VerticalAlignment = VerticalAlignment.Center;
759             }
760         }
761
762         private void SelectButtonLayoutDirectionChanged(object sender, LayoutDirectionChangedEventArgs e)
763         {
764             if (selectButtonAttributes == null || selectButtonAttributes.TextAttributes == null)
765             {
766                 return;
767             }
768
769             UpdateTextAttributes();
770
771             int iconWidth = CheckImageSize2D.Width;
772
773             int textPaddingLeft = selectButtonAttributes.TextAttributes.PaddingLeft;
774             int textPaddingRight = selectButtonAttributes.TextAttributes.PaddingRight;
775
776             if (LayoutDirection == ViewLayoutDirectionType.RTL)
777             {
778                 selectButtonAttributes.TextAttributes.HorizontalAlignment = HorizontalAlignment.End;
779                 selectButtonAttributes.TextAttributes.Position2D.X = textPaddingRight;
780                 checkShadowImage.Position2D.X = checkBackgroundImage.Position2D.X = checkImage.Position2D.X = selectButtonAttributes.TextAttributes.Size2D.Width + textPaddingLeft + textPaddingRight + IconPaddingRight;
781
782             }
783             else if (LayoutDirection == ViewLayoutDirectionType.LTR)
784             {
785                 selectButtonAttributes.TextAttributes.HorizontalAlignment = HorizontalAlignment.Begin;
786                 selectButtonAttributes.TextAttributes.Position2D.X = IconPaddingLeft + iconWidth + IconPaddingRight + textPaddingLeft;
787                 checkShadowImage.Position2D.X = checkBackgroundImage.Position2D.X = checkImage.Position2D.X = IconPaddingLeft;
788             }
789
790         }
791
792         private void OnSelect()
793         {    
794             OnSelected();
795
796             if (SelectedEvent != null)
797             {
798                 SelectEventArgs eventArgs = new SelectEventArgs();
799                 eventArgs.IsSelected = IsSelected;
800                 SelectedEvent(this, eventArgs);
801             }
802         }
803
804         private void CreateCheckImageAttributes()
805         {
806             if (selectButtonAttributes.CheckImageAttributes == null)
807             {
808                 selectButtonAttributes.CheckImageAttributes = new ImageAttributes()
809                 {
810                     PositionUsesPivotPoint = true,
811                     ParentOrigin = Tizen.NUI.ParentOrigin.TopLeft,
812                     PivotPoint =  Tizen.NUI.PivotPoint.TopLeft,
813                 };
814             }
815         }
816
817         private void CreateCheckBackgroundImageAttributes()
818         {
819             if (selectButtonAttributes.CheckBackgroundImageAttributes == null)
820             {
821                 selectButtonAttributes.CheckBackgroundImageAttributes = new ImageAttributes()
822                 {
823                     PositionUsesPivotPoint = true,
824                     ParentOrigin = Tizen.NUI.ParentOrigin.TopLeft,
825                     PivotPoint = Tizen.NUI.PivotPoint.TopLeft,
826                 };
827             }
828         }
829
830         private void CreateCheckShadowImageAttributes()
831         {
832             if (selectButtonAttributes.CheckShadowImageAttributes == null)
833             {
834                 selectButtonAttributes.CheckShadowImageAttributes = new ImageAttributes()
835                 {
836                     PositionUsesPivotPoint = true,
837                     ParentOrigin = Tizen.NUI.ParentOrigin.TopLeft,
838                     PivotPoint =  Tizen.NUI.PivotPoint.TopLeft,
839                 };
840             }
841         }
842
843         /// <summary>
844         /// SelectEventArgs is a class to record item selected arguments which will sent to user.
845         /// </summary>
846         /// <since_tizen> 6 </since_tizen>
847         /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
848         [EditorBrowsable(EditorBrowsableState.Never)]
849         public class SelectEventArgs : EventArgs
850         {
851             /// <summary> Select state of SelectButton </summary>
852             /// <since_tizen> 6 </since_tizen>
853             /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
854             [EditorBrowsable(EditorBrowsableState.Never)]
855             public bool IsSelected;
856         }
857     }
858 }