[NUI] add ControlState class to support combined and custom state (#1762)
[platform/core/csapi/tizenfx.git] / src / Tizen.NUI.Components / Controls / DropDown.DropDownItemView.cs
1 using System.ComponentModel;
2 using Tizen.NUI.BaseComponents;
3
4 namespace Tizen.NUI.Components
5 {
6     public partial class DropDown
7     {
8         /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
9         [EditorBrowsable(EditorBrowsableState.Never)]
10         internal class DropDownItemView : Control
11         {
12             private TextLabel mText = null;
13             private ImageView mIcon = null;
14             private ImageView mCheck = null;
15
16             /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
17             [EditorBrowsable(EditorBrowsableState.Never)]
18             public DropDownItemView() : base() { }
19
20             /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
21             [EditorBrowsable(EditorBrowsableState.Never)]
22             public Selector<Color> BackgroundColorSelector { get; set; }
23
24             /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
25             [EditorBrowsable(EditorBrowsableState.Never)]
26             public string Text
27             {
28                 get
29                 {
30                     return (null == mText) ? null : mText.Text;
31                 }
32                 set
33                 {
34                     CreateText();
35                     mText.Text = value;
36                 }
37             }
38
39             /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
40             [EditorBrowsable(EditorBrowsableState.Never)]
41             public string FontFamily
42             {
43                 get
44                 {
45                     return (null == mText) ? null : mText.FontFamily;
46                 }
47                 set
48                 {
49                     CreateText();
50                     mText.FontFamily = value;
51                 }
52             }
53
54             /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
55             [EditorBrowsable(EditorBrowsableState.Never)]
56             public float? PointSize
57             {
58                 get
59                 {
60                     return (null == mText) ? 0 : mText.PointSize;
61                 }
62                 set
63                 {
64                     CreateText();
65                     mText.PointSize = (float)value;
66                 }
67             }
68
69             /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
70             [EditorBrowsable(EditorBrowsableState.Never)]
71             public Color TextColor
72             {
73                 get
74                 {
75                     return (null == mText) ? null : mText.TextColor;
76                 }
77                 set
78                 {
79                     CreateText();
80                     mText.TextColor = value;
81                 }
82             }
83
84             /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
85             [EditorBrowsable(EditorBrowsableState.Never)]
86             public Position TextPosition
87             {
88                 get
89                 {
90                     return (null == mText) ? null : mText.Position;
91                 }
92                 set
93                 {
94                     CreateText();
95                     mText.Position = value;
96                 }
97             }
98
99             /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
100             [EditorBrowsable(EditorBrowsableState.Never)]
101             public string IconResourceUrl
102             {
103                 get
104                 {
105                     return (null == mIcon) ? null : mIcon.ResourceUrl;
106                 }
107                 set
108                 {
109                     CreateIcon();
110                     mIcon.ResourceUrl = value;
111                 }
112             }
113
114             /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
115             [EditorBrowsable(EditorBrowsableState.Never)]
116             public Size IconSize
117             {
118                 get
119                 {
120                     return (null == mIcon) ? null : mIcon.Size;
121                 }
122                 set
123                 {
124                     CreateIcon();
125                     mIcon.Size = value;
126                 }
127             }
128
129             /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
130             [EditorBrowsable(EditorBrowsableState.Never)]
131             public Position IconPosition
132             {
133                 get
134                 {
135                     return (null == mIcon) ? null : mIcon.Position;
136                 }
137                 set
138                 {
139                     CreateIcon();
140                     mIcon.Position = value;
141                 }
142             }
143
144             /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
145             [EditorBrowsable(EditorBrowsableState.Never)]
146             public string CheckResourceUrl
147             {
148                 get
149                 {
150                     return (null == mCheck) ? null : mCheck.ResourceUrl;
151                 }
152                 set
153                 {
154                     CreateCheckImage();
155                     mCheck.ResourceUrl = value;
156                 }
157             }
158
159             /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
160             [EditorBrowsable(EditorBrowsableState.Never)]
161             public Position CheckPosition
162             {
163                 get
164                 {
165                     return (null == mCheck) ? null : mCheck.Position;
166                 }
167                 set
168                 {
169                     CreateCheckImage();
170                     mCheck.Position = value;
171                 }
172             }
173
174             /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
175             [EditorBrowsable(EditorBrowsableState.Never)]
176             public Size CheckImageSize
177             {
178                 get
179                 {
180                     return (null == mCheck) ? null : mCheck.Size;
181                 }
182                 set
183                 {
184                     CreateCheckImage();
185                     mCheck.Size = value;
186                 }
187             }
188
189             /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
190             [EditorBrowsable(EditorBrowsableState.Never)]
191             public bool IsSelected
192             {
193                 get
194                 {
195                     return (null == mCheck) ? false : mCheck.Visibility;
196                 }
197                 set
198                 {
199                     CreateCheckImage();
200                     if (value)
201                     {
202                         ControlState = ControlState.Selected;
203                         mCheck.Show();
204                     }
205                     else
206                     {
207                         ControlState = ControlState.Normal;
208                         mCheck.Hide();
209                     }
210                 }
211             }
212
213             /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
214             [EditorBrowsable(EditorBrowsableState.Never)]
215             protected override void Dispose(DisposeTypes type)
216             {
217                 if (disposed)
218                 {
219                     return;
220                 }
221
222                 if (type == DisposeTypes.Explicit)
223                 {
224                     if (mText != null)
225                     {
226                         Remove(mText);
227                         mText.Dispose();
228                         mText = null;
229                     }
230
231                     if (mIcon != null)
232                     {
233                         Remove(mIcon);
234                         mIcon.Dispose();
235                         mIcon = null;
236                     }
237
238                     if (mCheck != null)
239                     {
240                         Remove(mCheck);
241                         mCheck.Dispose();
242                         mCheck = null;
243                     }
244                 }
245                 base.Dispose(type);
246             }
247
248             /// <summary>
249             /// Get DropDownItemView style.
250             /// </summary>
251             /// <returns>The empty.</returns>
252             /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
253             [EditorBrowsable(EditorBrowsableState.Never)]
254             protected override ViewStyle CreateViewStyle()
255             {
256                 return new DropDownItemStyle();
257             }
258
259             private void CreateIcon()
260             {
261                 if (mIcon == null)
262                 {
263                     mIcon = new ImageView()
264                     {
265                         PositionUsesPivotPoint = true,
266                         ParentOrigin = Tizen.NUI.ParentOrigin.TopLeft,
267                         PivotPoint = Tizen.NUI.PivotPoint.TopLeft,
268                     };
269                     Add(mIcon);
270                 }
271             }
272
273             private void CreateText()
274             {
275                 if (mText == null)
276                 {
277                     mText = new TextLabel()
278                     {
279                         PositionUsesPivotPoint = true,
280                         ParentOrigin = Tizen.NUI.ParentOrigin.TopLeft,
281                         PivotPoint = Tizen.NUI.PivotPoint.TopLeft,
282                         WidthResizePolicy = ResizePolicyType.UseNaturalSize,
283                         HeightResizePolicy = ResizePolicyType.FillToParent,
284                         VerticalAlignment = VerticalAlignment.Center,
285                         HorizontalAlignment = HorizontalAlignment.Begin,
286                     };
287                     Add(mText);
288                 }
289             }
290
291             private void CreateCheckImage()
292             {
293                 if (mCheck == null)
294                 {
295                     mCheck = new ImageView()
296                     {
297                         PositionUsesPivotPoint = true,
298                         ParentOrigin = Tizen.NUI.ParentOrigin.TopLeft,
299                         PivotPoint = Tizen.NUI.PivotPoint.TopLeft,
300                         Name = "checkedImage",
301                     };
302                     Add(mCheck);
303                 }
304                 mCheck.Hide();
305             }
306         }
307     }
308 }