Release 4.0.0-preview1-00051
[platform/core/csapi/tizenfx.git] / src / Tizen.Uix.InputMethod / Tizen.Uix.InputMethod / InputMethodContext.cs
1 /*
2 * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
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
18 using System;
19 using static Interop.InputMethod;
20
21 namespace Tizen.Uix.InputMethod
22 {
23     /// <summary>
24     /// Enumeration for Input Panel Layout
25     /// </summary>
26     public enum InputPanelLayout
27     {
28         /// <summary>
29         /// Normal
30         /// </summary>
31         LayoutNormal,
32         /// <summary>
33         /// Number
34         /// </summary>
35         LayoutNumber,
36         /// <summary>
37         /// Email
38         /// </summary>
39         LayoutEMail,
40         /// <summary>
41         /// URL
42         /// </summary>
43         LayoutURL,
44         /// <summary>
45         /// Phone Number
46         /// </summary>
47         LayoutPhoneNumber,
48         /// <summary>
49         /// IP
50         /// </summary>
51         LayoutIP,
52         /// <summary>
53         /// Month
54         /// </summary>
55         LayoutMonth,
56         /// <summary>
57         /// Number Only
58         /// </summary>
59         LayoutNumberOnly,
60         /// <summary>
61         /// Invalid
62         /// </summary>
63         LayoutInvalid,
64         /// <summary>
65         /// HEX
66         /// </summary>
67         LayoutHEX,
68         /// <summary>
69         /// Terminal
70         /// </summary>
71         LayoutTerminal,
72         /// <summary>
73         /// Password
74         /// </summary>
75         LayoutPassword,
76         /// <summary>
77         /// Date Time
78         /// </summary>
79         LayoutDateTime,
80         /// <summary>
81         /// Emoticon
82         /// </summary>
83         LayoutEmoticon,
84         /// <summary>
85         /// Voice
86         /// </summary>
87         LayoutVoice,
88         /// <summary>
89         /// Undefined
90         /// </summary>
91         Undefined
92     };
93
94     /// <summary>
95     /// Enumeration for Layout Variation
96     /// </summary>
97     public enum LayoutVariation
98     {
99         /// <summary>
100         /// The plain normal layout
101         /// </summary>
102         NormalNormal = 0,
103         /// <summary>
104         /// Filename layout; symbols such as '/', '\*', '\', '|', '&lt;', '&gt;', '?', '&quot;' and ':' should be disabled
105         /// </summary>
106         NormalFileName,
107         /// <summary>
108         /// The name of a person
109         /// </summary>
110         NormalPersonName,
111         /// <summary>
112         /// The plain normal number layout
113         /// </summary>
114         NumberOnlyNormal = 0,
115         /// <summary>
116         /// The number layout to allow a negative sign
117         /// </summary>
118         NumberOnlySigned,
119         /// <summary>
120         /// The number layout to allow decimal point to provide fractional value
121         /// </summary>
122         NumberOnlyDecimal,
123         /// <summary>
124         /// The number layout to allow decimal point and negative sign
125         /// </summary>
126         NumberOnlySignedAndDecimal,
127         /// <summary>
128         /// The normal password layout
129         /// </summary>
130         PasswordNormal = 0,
131         /// <summary>
132         /// The password layout to allow only number
133         /// </summary>
134         PasswordNumberOnly,
135         /// <summary>
136         /// Undefined
137         /// </summary>
138         Undefined
139     };
140
141     /// <summary>
142     /// Enumeration for AutoCapital Type
143     /// </summary>
144     public enum AutoCapitalization
145     {
146         /// <summary>
147         /// None
148         /// </summary>
149         None,
150         /// <summary>
151         /// Word
152         /// </summary>
153         Word,
154         /// <summary>
155         /// Sentence
156         /// </summary>
157         Sentence,
158         /// <summary>
159         /// All Character
160         /// </summary>
161         AllCharacter,
162         /// <summary>
163         /// Undefined
164         /// </summary>
165         Undefined
166     };
167
168     /// <summary>
169     /// Enumeration for InputPanel ReturnKey Type
170     /// </summary>
171     public enum InputPanelReturnKey
172     {
173         /// <summary>
174         /// Default
175         /// </summary>
176         Default,
177         /// <summary>
178         /// Done
179         /// </summary>
180         Done,
181         /// <summary>
182         /// Go
183         /// </summary>
184         Go,
185         /// <summary>
186         /// Join
187         /// </summary>
188         Join,
189         /// <summary>
190         /// Login
191         /// </summary>
192         Login,
193         /// <summary>
194         /// Next
195         /// </summary>
196         Next,
197         /// <summary>
198         /// Search
199         /// </summary>
200         Search,
201         /// <summary>
202         /// Send
203         /// </summary>
204         Send,
205         /// <summary>
206         /// SignIn
207         /// </summary>
208         SignIn,
209         /// <summary>
210         /// Undefined
211         /// </summary>
212         Undefined
213     };
214
215     /// <summary>
216     /// Enumeration for InputHints
217     /// </summary>
218     public enum InputHints
219     {
220         /// <summary>
221         /// None
222         /// </summary>
223         None,
224         /// <summary>
225         /// AutoComplete
226         /// </summary>
227         AutoComplete,
228         /// <summary>
229         /// SensitiveData
230         /// </summary>
231         SensitiveData,
232         /// <summary>
233         /// Multiline
234         /// </summary>
235         Multiline,
236         /// <summary>
237         /// Undefined
238         /// </summary>
239         Undefined
240     };
241
242     /// <summary>
243     /// Enumeration for BiDi Direction
244     /// </summary>
245     public enum BiDirection
246     {
247         /// <summary>
248         /// Neutral
249         /// </summary>
250         Neutral,
251         /// <summary>
252         /// LTR
253         /// </summary>
254         LTR,
255         /// <summary>
256         /// RTL
257         /// </summary>
258         RTL,
259         /// <summary>
260         /// Undefined
261         /// </summary>
262         Undefined
263     };
264
265     /// <summary>
266     /// Enumeration for InputPanel Language
267     /// </summary>
268     public enum InputPanelLanguage
269     {
270         /// <summary>
271         /// Automatic
272         /// </summary>
273         Automatic,
274         /// <summary>
275         /// Alphabet
276         /// </summary>
277         Alphabet,
278         /// <summary>
279         /// Undefined
280         /// </summary>
281         Undefined
282     };
283
284     /// <summary>
285     /// This class represents the context of InputMethodEditor
286     /// </summary>
287     public class InputMethodContext
288     {
289         private IntPtr _handle;
290         internal InputMethodContext(IntPtr handle)
291         {
292             _handle = handle;
293         }
294
295         /// <summary>
296         /// Gets the layout information.
297         /// </summary>
298         public InputPanelLayout Layout
299         {
300             get
301             {
302                 InputPanelLayout layout;
303                 ErrorCode error = ImeContextGetLayout(_handle, out layout);
304                 if (error != ErrorCode.None)
305                 {
306                     Log.Error(LogTag, "GetLayout Failed with error " + error);
307                     return InputPanelLayout.Undefined;
308                 }
309                 return layout;
310             }
311         }
312
313         /// <summary>
314         /// Gets the layout variation information.
315         /// </summary>
316         public LayoutVariation LayoutVariation
317         {
318             get
319             {
320                 LayoutVariation layoutVariation;
321                 ErrorCode error = ImeContextGetLayoutVariation(_handle, out layoutVariation);
322                 if (error != ErrorCode.None)
323                 {
324                     Log.Error(LogTag, "GetLayoutVariation Failed with error " + error);
325                     return LayoutVariation.Undefined;
326                 }
327                 return layoutVariation;
328             }
329         }
330
331         /// <summary>
332         /// Gets the cursor position information.
333         /// </summary>
334         public int CursorPositionition
335         {
336             get
337             {
338                 int cursorPosition;
339                 ErrorCode error = ImeContextGetCursorPositionition(_handle, out cursorPosition);
340                 if (error != ErrorCode.None)
341                 {
342                     Log.Error(LogTag, "GetCursorPositionition Failed with error " + error);
343                     return -1;
344                 }
345                 return cursorPosition;
346             }
347         }
348
349         /// <summary>
350         /// Gets the autocapital type information.
351         /// </summary>
352         public AutoCapitalization AutoCapitalization
353         {
354             get
355             {
356                 AutoCapitalization autoCapitalType;
357                 ErrorCode error = ImeContextGetAutocapitalType(_handle, out autoCapitalType);
358                 if (error != ErrorCode.None)
359                 {
360                     Log.Error(LogTag, "GetAutoCapitalization Failed with error " + error);
361                     return AutoCapitalization.Undefined;
362                 }
363                 return autoCapitalType;
364             }
365         }
366
367         /// <summary>
368         /// Gets the Return key label type information.
369         /// </summary>
370         public InputPanelReturnKey ReturnKey
371         {
372             get
373             {
374                 InputPanelReturnKey returnKeyType;
375                 ErrorCode error = ImeContextGetReturnKey(_handle, out returnKeyType);
376                 if (error != ErrorCode.None)
377                 {
378                     Log.Error(LogTag, "GetReturnKey Failed with error " + error);
379                     return InputPanelReturnKey.Undefined;
380                 }
381                 return returnKeyType;
382             }
383         }
384
385         /// <summary>
386         /// Gets the Return key state information.
387         /// </summary>
388         public bool ReturnKeyState
389         {
390             get
391             {
392                 bool returnKeyState;
393                 ErrorCode error = ImeContextGetReturnKeyState(_handle, out returnKeyState);
394                 if (error != ErrorCode.None)
395                 {
396                     Log.Error(LogTag, "GetReturnKeyState Failed with error " + error);
397                     return false;
398                 }
399                 return returnKeyState;
400             }
401         }
402
403         /// <summary>
404         /// Gets the prediction mode information.
405         /// </summary>
406         public bool PredictionMode
407         {
408             get
409             {
410                 bool predictionMode;
411                 ErrorCode error = ImeContextGetPredictionMode(_handle, out predictionMode);
412                 if (error != ErrorCode.None)
413                 {
414                     Log.Error(LogTag, "GetPredictionMode Failed with error " + error);
415                     return false;
416                 }
417                 return predictionMode;
418             }
419         }
420
421         /// <summary>
422         /// Gets the password mode information.
423         /// </summary>
424         public bool PasswordMode
425         {
426             get
427             {
428                 bool passwordMode;
429                 ErrorCode error = ImeContextGetPasswordMode(_handle, out passwordMode);
430                 if (error != ErrorCode.None)
431                 {
432                     Log.Error(LogTag, "GetPasswordMode Failed with error " + error);
433                     return false;
434                 }
435                 return passwordMode;
436             }
437         }
438
439         /// <summary>
440         /// Gets the input hint information.
441         /// </summary>
442         public InputHints InputHint
443         {
444             get
445             {
446                 InputHints inputHint;
447                 ErrorCode error = ImeContextGetInputHint(_handle, out inputHint);
448                 if (error != ErrorCode.None)
449                 {
450                     Log.Error(LogTag, "GetInputHint Failed with error " + error);
451                     return InputHints.Undefined;
452                 }
453                 return inputHint;
454             }
455         }
456
457         /// <summary>
458         /// Gets the text bidirectional information.
459         /// </summary>
460         public BiDirection BiDirection
461         {
462             get
463             {
464                 BiDirection biDiDirection;
465                 ErrorCode error = ImeContextGetBidiDirection(_handle, out biDiDirection);
466                 if (error != ErrorCode.None)
467                 {
468                     Log.Error(LogTag, "GetBiDirection Failed with error " + error);
469                     return BiDirection.Undefined;
470                 }
471                 return biDiDirection;
472             }
473         }
474
475         /// <summary>
476         /// Gets the preferred language information.
477         /// </summary>
478         public InputPanelLanguage Language
479         {
480             get
481             {
482                 InputPanelLanguage langauge;
483                 ErrorCode error = ImeContextGetLanguage(_handle, out langauge);
484                 if (error != ErrorCode.None)
485                 {
486                     Log.Error(LogTag, "GetLanguage Failed with error " + error);
487                     return InputPanelLanguage.Undefined;
488                 }
489                 return langauge;
490             }
491         }
492     }
493 }