[NUI] Add ThemeManager (#2034)
[platform/core/csapi/tizenfx.git] / src / Tizen.NUI.Components / Controls / RadioButton.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.ComponentModel;
18 using Tizen.NUI.BaseComponents;
19
20 namespace Tizen.NUI.Components
21 {
22     /// <summary>
23     /// RadioButton is the Class that describe the control which can be checked, but not cleared by a user.
24     /// </summary>
25     /// <code>
26     /// RadioButton radio = new RadioButton("C_RadioButton_WhiteText");
27     /// radio.Size = new Size(200, 64, 0);
28     /// radio.Position = new Position(500, posY, 0);
29     /// radio.Text = "RadioButton";
30     /// radio.Focusable = true;
31     /// </code>
32     /// <since_tizen> 8 </since_tizen>
33     public class RadioButton : SelectButton
34     {
35         static RadioButton() { }
36
37         /// <summary>
38         /// Creates a new instance of a RadioButton.
39         /// </summary>
40         /// <since_tizen> 8 </since_tizen>
41         public RadioButton() : base() { }
42         /// <summary>
43         /// Creates a new instance of a RadioButton with style.
44         /// </summary>
45         /// <param name="style"></param>
46         /// <since_tizen> 8 </since_tizen>
47         public RadioButton(string style) : base(style) { }
48         /// <summary>
49         /// Creates a new instance of a RadioButton with style.
50         /// </summary>
51         /// <param name="buttonStyle"></param>
52         /// <since_tizen> 8 </since_tizen>
53         public RadioButton(ButtonStyle buttonStyle) : base(buttonStyle) { }
54
55         /// <summary>
56         /// Get RadioButtonGroup to which this selections belong.
57         /// </summary>
58         /// <since_tizen> 6 </since_tizen>
59         /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
60         [EditorBrowsable(EditorBrowsableState.Never)]
61         public RadioButtonGroup ItemGroup
62         {
63             get
64             {
65                 return base.ItemGroup as RadioButtonGroup;
66             }
67             internal set
68             {
69                 base.ItemGroup = value;
70             }
71         }
72
73         /// <inheritdoc/>
74         [EditorBrowsable(EditorBrowsableState.Never)]
75         public override void ApplyStyle(ViewStyle viewStyle)
76         {
77             if (viewStyle is ButtonStyle buttonStyle)
78             {
79                 if (buttonStyle.IsSelectable == null)
80                 {
81                     buttonStyle.IsSelectable = true;
82                 }
83
84                 base.ApplyStyle(buttonStyle);
85             }
86         }
87
88         /// <summary>
89         /// Set CheckState to true after selecting RadioButton.
90         /// </summary>
91         /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
92         [EditorBrowsable(EditorBrowsableState.Never)]
93         protected override void OnSelectedChanged()
94         {
95             if (!IsSelected)
96             {
97                 IsSelected = true;
98             }
99         }
100
101         /// <inheritdoc/>
102         [EditorBrowsable(EditorBrowsableState.Never)]
103         protected override ImageView CreateIcon()
104         {
105             return new ImageView
106             {
107                 PositionUsesPivotPoint = true,
108                 ParentOrigin = NUI.ParentOrigin.Center,
109                 PivotPoint = NUI.PivotPoint.Center,
110                 WidthResizePolicy = ResizePolicyType.DimensionDependency,
111                 HeightResizePolicy = ResizePolicyType.SizeRelativeToParent,
112                 SizeModeFactor = new Vector3(1, 1, 1),
113             };
114         }
115     }
116 }