[NUI] remove input method dependency from View.ControlState (#1585)
[platform/core/csapi/tizenfx.git] / src / Tizen.NUI / src / public / InputMethod.cs
1 // Copyright (c) 2017 Samsung Electronics Co., Ltd.
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 //
15
16 namespace Tizen.NUI
17 {
18
19     /// <summary>
20     /// A class encapsulating the input method map.
21     /// </summary>
22     /// <since_tizen> 3 </since_tizen>
23     public class InputMethod
24     {
25         private PanelLayoutType? _panelLayout = null;
26         private ActionButtonTitleType? _actionButton = null;
27         private AutoCapitalType? _autoCapital = null;
28         private int? _variation = null;
29
30         /// <summary>
31         /// The default constructor.
32         /// </summary>
33         /// <since_tizen> 3 </since_tizen>
34         public InputMethod()
35         {
36         }
37
38         /// <summary>
39         /// SetType that can be changed in the system input method.
40         /// </summary>
41         /// <since_tizen> 3 </since_tizen>
42         public enum CategoryType
43         {
44             /// <summary>
45             /// Set the keyboard layout.
46             /// </summary>
47             PanelLayout,
48             /// <summary>
49             /// Set the action button title.
50             /// </summary>
51             ActionButtonTitle,
52             /// <summary>
53             /// Set the auto capitalise of input.
54             /// </summary>
55             AutoCapitalise,
56             /// <summary>
57             /// Set the variation.
58             /// </summary>
59             Variation
60         }
61
62         /// <summary>
63         /// Autocapitalization Types.
64         /// </summary>
65         /// <since_tizen> 3 </since_tizen>
66         public enum AutoCapitalType
67         {
68             /// <summary>
69             /// No auto-capitalization when typing.
70             /// </summary>
71             None,
72             /// <summary>
73             /// Autocapitalize each word typed.
74             /// </summary>
75             Word,
76             /// <summary>
77             /// Autocapitalize the start of each sentence.
78             /// </summary>
79             Sentence,
80             /// <summary>
81             /// Autocapitalize all letters.
82             /// </summary>
83             Allcharacter
84         }
85
86         /// <summary>
87         /// Input panel (virtual keyboard) layout types..
88         /// </summary>
89         /// <since_tizen> 3 </since_tizen>
90         public enum PanelLayoutType
91         {
92             /// <summary>
93             /// Default layout.
94             /// </summary>
95             Normal,
96             /// <summary>
97             /// Number layout.
98             /// </summary>
99             Number,
100             /// <summary>
101             /// Email layout.
102             /// </summary>
103             Email,
104             /// <summary>
105             /// URL layout.
106             /// </summary>
107             URL,
108             /// <summary>
109             /// Phone number layout.
110             /// </summary>
111             PhoneNumber,
112             /// <summary>
113             /// IP layout.
114             /// </summary>
115             IP,
116             /// <summary>
117             /// Month layout.
118             /// </summary>
119             Month,
120             /// <summary>
121             /// Number layout.
122             /// </summary>
123             NumberOnly,
124             /// <summary>
125             /// Hexadecimal layout.
126             /// </summary>
127             HEX,
128             /// <summary>
129             /// Command-line terminal layout including Esc, Alt, Ctrl key, and so on (no auto-correct, no auto-capitalization).
130             /// </summary>
131             Terminal,
132             /// <summary>
133             /// Like normal, but no auto-correct, no auto-capitalization etc.
134             /// </summary>
135             Password,
136             /// <summary>
137             /// Date and time layout.
138             /// </summary>
139             Datetime,
140             /// <summary>
141             /// Emoticon layout.
142             /// </summary>
143             Emoticon
144         }
145
146         /// <summary>
147         /// Specifies what the Input Method "action" button functionality is set to.
148         /// </summary>
149         /// <since_tizen> 3 </since_tizen>
150         public enum ActionButtonTitleType
151         {
152             /// <summary>
153             /// Default action.
154             /// </summary>
155             Default,
156             /// <summary>
157             /// Done.
158             /// </summary>
159             Done,
160             /// <summary>
161             /// Go action.
162             /// </summary>
163             Go,
164             /// <summary>
165             /// Join action.
166             /// </summary>
167             Join,
168             /// <summary>
169             /// Login action.
170             /// </summary>
171             Login,
172             /// <summary>
173             /// Next action.
174             /// </summary>
175             Next,
176             /// <summary>
177             /// Previous action.
178             /// </summary>
179             Previous,
180             /// <summary>
181             /// Search action.
182             /// </summary>
183             Search,
184             /// <summary>
185             /// Send action.
186             /// </summary>
187             Send,
188             /// <summary>
189             /// Sign in action.
190             /// </summary>
191             SignIn,
192             /// <summary>
193             /// Unspecified action.
194             /// </summary>
195             Unspecified,
196             /// <summary>
197             /// Nothing to do.
198             /// </summary>
199             None
200         }
201
202         /// <summary>
203         /// Available variation for the normal layout.
204         /// </summary>
205         /// <since_tizen> 3 </since_tizen>
206         public enum NormalLayoutType
207         {
208             /// <summary>
209             /// The plain normal layout.
210             /// </summary>
211             Normal,
212             /// <summary>
213             /// Filename layout. sysbols such as '/' should be disabled.
214             /// </summary>
215             WithFilename,
216             /// <summary>
217             /// The name of a person.
218             /// </summary>
219             WithPersonName
220         }
221
222         /// <summary>
223         /// Available variation for the number only layout.
224         /// </summary>
225         /// <since_tizen> 3 </since_tizen>
226         public enum NumberOnlyLayoutType
227         {
228             /// <summary>
229             /// The plain normal number layout.
230             /// </summary>
231             Normal,
232             /// <summary>
233             /// The number layout to allow a positive or negative sign at the start.
234             /// </summary>
235             WithSigned,
236             /// <summary>
237             /// The number layout to allow decimal point to provide fractional value.
238             /// </summary>
239             WithDecimal,
240             /// <summary>
241             /// The number layout to allow decimal point and negative sign.
242             /// </summary>
243             WithSignedAndDecimal
244         }
245
246         /// <summary>
247         /// Available variation for the password layout.
248         /// </summary>
249         /// <since_tizen> 3 </since_tizen>
250         public enum PasswordLayoutType
251         {
252             /// <summary>
253             /// The normal password layout.
254             /// </summary>
255             Normal,
256             /// <summary>
257             /// The password layout to allow only number.
258             /// </summary>
259             WithNumberOnly
260         }
261
262         /// <summary>
263         /// Gets or sets the panel layout.
264         /// </summary>
265         /// <since_tizen> 3 </since_tizen>
266         public PanelLayoutType PanelLayout
267         {
268             get
269             {
270                 return _panelLayout ?? PanelLayoutType.Normal;
271             }
272             set
273             {
274                 _panelLayout = value;
275             }
276         }
277
278         /// <summary>
279         /// Gets or sets the action button.
280         /// </summary>
281         /// <since_tizen> 3 </since_tizen>
282         public ActionButtonTitleType ActionButton
283         {
284             get
285             {
286                 return _actionButton ?? ActionButtonTitleType.Default;
287             }
288             set
289             {
290                 _actionButton = value;
291             }
292         }
293
294         /// <summary>
295         /// Gets or sets the auto capital.
296         /// </summary>
297         /// <since_tizen> 3 </since_tizen>
298         public AutoCapitalType AutoCapital
299         {
300             get
301             {
302                 return _autoCapital ?? AutoCapitalType.None;
303             }
304             set
305             {
306                 _autoCapital = value;
307             }
308         }
309
310         /// <summary>
311         /// Gets or sets the variation.
312         /// </summary>
313         /// <since_tizen> 3 </since_tizen>
314         public int Variation
315         {
316             get
317             {
318                 return _variation ?? 0;
319             }
320             set
321             {
322                 _variation = value;
323             }
324         }
325
326         /// <summary>
327         /// Gets or sets the variation for normal layout.
328         /// </summary>
329         /// <since_tizen> 3 </since_tizen>
330         public NormalLayoutType NormalVariation
331         {
332             get
333             {
334                 return (NormalLayoutType) (_variation ?? 0);
335             }
336             set
337             {
338                 _variation = (int)value;
339             }
340         }
341
342         /// <summary>
343         /// Gets or sets the variation for the number only layout.
344         /// </summary>
345         /// <since_tizen> 3 </since_tizen>
346         public NumberOnlyLayoutType NumberOnlyVariation
347         {
348             get
349             {
350                 return (NumberOnlyLayoutType) (_variation ?? 0);
351             }
352             set
353             {
354                 _variation = (int)value;
355             }
356         }
357
358         /// <summary>
359         /// Gets or sets the variation for the password layout.
360         /// </summary>
361         /// <since_tizen> 3 </since_tizen>
362         public PasswordLayoutType PasswordVariation
363         {
364             get
365             {
366                 return (PasswordLayoutType) (_variation ?? 0);
367             }
368             set
369             {
370                 _variation = (int)value;
371             }
372         }
373
374         /// <summary>
375         /// Gets the input method map.
376         /// </summary>
377         /// <since_tizen> 3 </since_tizen>
378         public PropertyMap OutputMap
379         {
380             get
381             {
382                 return ComposingInputMethodMap();
383             }
384         }
385
386         private PropertyMap ComposingInputMethodMap()
387         {
388             PropertyMap _outputMap = new PropertyMap();
389             if (_panelLayout != null) { _outputMap.Add("PANEL_LAYOUT", new PropertyValue((int)_panelLayout)); }
390             if (_actionButton != null) { _outputMap.Add("BUTTON_ACTION", new PropertyValue((int)_actionButton)); }
391             if (_autoCapital != null) { _outputMap.Add("AUTO_CAPITALIZE", new PropertyValue((int)_autoCapital)); }
392             if (_variation != null) { _outputMap.Add("VARIATION", new PropertyValue((int)_variation)); }
393             return _outputMap;
394         }
395     }
396 }