[Bluetooth][Non-ACR] Fix no data exception issue (#787)
[platform/core/csapi/tizenfx.git] / internals / src / EflSharp / EflSharp / RotarySelectorItem.cs
1 using System;
2 using System.Collections.Generic;
3 using System.Text;
4
5 namespace Efl
6 {
7     namespace Ui
8     {
9         namespace Wearable
10         {
11             public class RotaryColorPart : Efl.Object, Efl.Gfx.Color
12             {
13                 int _r, _g, _b, _a;
14
15                 public RotaryColorPart() { _r = _g = _b = _a = -1; }
16
17                 public void SetColor(int r, int g, int b, int a)
18                 {
19                     _r = r;
20                     _g = g;
21                     _b = b;
22                     _a = a;
23                 }
24
25                 public virtual void GetColor(out int r, out int g, out int b, out int a)
26                 {
27                     //Not Implemented
28                     r = _r;
29                     g = _g;
30                     b = _b;
31                     a = _a;
32                 }
33
34                 public void SetColorCode(System.String colorcode)
35                 {
36                     //Not Implemented
37                     return;
38                 }
39
40                 public System.String GetColorCode()
41                 {
42                     //Not Implemented
43                     return null;
44                 }
45
46                 public System.String GetColorClassCode(System.String color_class, Efl.Gfx.ColorClassLayer layer)
47                 {
48                     //Not Implemented
49                     return null;
50                 }
51                 public void SetColorClassCode(System.String color_class, Efl.Gfx.ColorClassLayer layer, System.String colorcode)
52                 {
53                     //This function will be removed after interface work is done
54                     return;
55                 }
56
57                 public System.String ColorCode
58                 {
59                     //This function will be removed afater interface work is done
60                     get { return null; }
61                     set { }
62                 }
63             }
64
65             public class RotarySelectorItem
66             {
67                 const string MainTextPartName = "selector,main_text";
68                 const string SubTextPartName = "selector,sub_text";
69                 const string IconPartName = "item,icon";
70                 const string BgPartName = "item,bg_image";
71                 const string SelectorIconPartName = "selector,icon";
72
73                 string _mainText;
74                 string _subText;
75                 Image _normalIconImage;
76                 Image _pressedIconImage;
77                 Image _disabledIconImage;
78                 Image _selectedIconImage;
79                 Image _normalBgImage;
80                 Image _pressedBgImage;
81                 Image _disabledBgImage;
82                 Image _selectedBgImage;
83                 Image _selectorIconImage;
84
85                 public RotaryColorPart MainTextColor;
86                 public RotaryColorPart SubTextColor;
87                 public RotaryColorPart NormalBgColor;
88                 public RotaryColorPart PressedBgColor;
89                 public RotaryColorPart DisabledBgColor;
90                 public RotaryColorPart SelectedBgColor;
91
92                 public IntPtr _handle;
93                 public IntPtr NativeHandle
94                 {
95                     set
96                     {
97                         if (_handle == value) return;
98                         _handle = value;
99
100                         if (_handle == null) return;
101
102                         
103                         SetPart(MainTextPartName, _mainText);
104                         SetPart(SubTextPartName, _subText);
105
106                         SetPart(MainTextPartName, ItemState.Normal, MainTextColor);
107                         SetPart(SubTextPartName, ItemState.Normal, SubTextColor);
108
109                         SetPart(IconPartName, ItemState.Normal, _normalIconImage);
110                         SetPart(IconPartName, ItemState.Pressed, _pressedIconImage);
111                         SetPart(IconPartName, ItemState.Disabled, _disabledIconImage);
112                         SetPart(IconPartName, ItemState.Selected, _selectedIconImage);
113                         
114                         SetPart(BgPartName, ItemState.Normal, _normalBgImage);
115                         SetPart(BgPartName, ItemState.Pressed, _pressedBgImage);
116                         SetPart(BgPartName, ItemState.Disabled, _disabledBgImage);
117                         SetPart(BgPartName, ItemState.Selected, _selectedBgImage);
118
119                         SetPart(BgPartName, ItemState.Normal, NormalBgColor);
120                         SetPart(BgPartName, ItemState.Normal, PressedBgColor);
121                         SetPart(BgPartName, ItemState.Normal, DisabledBgColor);
122                         SetPart(BgPartName, ItemState.Normal, SelectedBgColor);
123
124                         SetPart(SelectorIconPartName, ItemState.Normal, _selectorIconImage);
125                     }
126                     get
127                     {
128                         return _handle;
129                     }
130                 }
131
132                 void SetPart(string partName, ItemState state, Image img)
133                 {
134                     if (NativeHandle != null && partName != null && img != null)
135                     {
136                         Interop.Eext.eext_rotary_selector_item_part_content_set(NativeHandle, partName, (int)state, img.NativeHandle);
137                     }
138                 }
139
140                 void SetPart(string partName, string text)
141                 {
142                     if (NativeHandle != null && text != null)
143                     {
144                         Interop.Eext.eext_rotary_selector_item_part_text_set(NativeHandle, partName, text);
145                     }
146                 }
147
148                 void SetPart(string partName, ItemState state, RotaryColorPart color)
149                 {
150                     if (NativeHandle != null && partName != null && color != null)
151                     {
152                         int r, g, b, a;
153                         color.GetColor(out r, out g, out b, out a);
154
155                         if (r != -1 || g != -1 || b != -1 || a != -1)
156                           Interop.Eext.eext_rotary_selector_item_part_color_set(NativeHandle, partName, (int)state, r, g, b, a);
157                     }
158                 }
159
160                 public string MainText
161                 {
162                     get { return _mainText; }
163                     set
164                     {
165                         _mainText = value;
166                         SetPart(MainTextPartName, value);
167                     }
168                 }
169
170                 public string SubText
171                 {
172                     get { return _subText; }
173                     set
174                     {
175                         _subText = value;
176                         SetPart(SubTextPartName, value);
177                     }
178                 }
179
180                 public Image NormalIconImage
181                 {
182                     get { return _normalIconImage; }
183                     set
184                     {
185                         _normalIconImage = value;
186                         SetPart(IconPartName, ItemState.Normal, value);
187                     }
188                 }
189
190                 public Image PressedIconImage
191                 {
192                     get { return _pressedIconImage; }
193                     set
194                     {
195                         _pressedIconImage = value;
196                         SetPart(IconPartName, ItemState.Pressed, value);
197                     }
198                 }
199
200                 public Image DisabledIconImage
201                 {
202                     get { return _disabledIconImage; }
203                     set
204                     {
205                         _disabledIconImage = value;
206                         SetPart(IconPartName, ItemState.Disabled, value);
207                     }
208                 }
209
210                 public Image SelectedIconImage
211                 {
212                     get { return _selectedIconImage; }
213                     set
214                     {
215                         _selectedIconImage = value;
216                         SetPart(IconPartName, ItemState.Selected, value);
217                     }
218                 }
219
220                 public Image NormalBackgroundImage
221                 {
222                     get { return _normalBgImage; }
223                     set
224                     {
225                         _normalBgImage = value;
226                         SetPart(BgPartName, ItemState.Normal, value);
227                     }
228                 }
229
230                 public Image PressedBackgroundImage
231                 {
232                     get { return _pressedBgImage; }
233                     set
234                     {
235                         _pressedBgImage = value;
236                         SetPart(BgPartName, ItemState.Pressed, value);
237                     }
238                 }
239
240                 public Image DisabledBackgroundImage
241                 {
242                     get { return _disabledBgImage; }
243                     set
244                     {
245                         _disabledBgImage = value;
246                         SetPart(BgPartName, ItemState.Disabled, value);
247                     }
248                 }
249
250                 public Image SelectedBackgroundImage
251                 {
252                     get { return _selectedBgImage; }
253                     set
254                     {
255                         _selectedBgImage = value;
256                         SetPart(BgPartName, ItemState.Selected, value);
257                     }
258                 }
259
260                 public Image SelectorIconImage
261                 {
262                     get { return _selectorIconImage; }
263                     set
264                     {
265                         _selectorIconImage = value;
266                         SetPart(SelectorIconPartName, ItemState.Normal, value);
267                     }
268                 }
269
270                 internal enum ItemState
271                 {
272                     Normal,
273                     Pressed,
274                     Disabled,
275                     Selected
276                 }
277             }
278         }
279     }
280 }