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