Release 4.0.0-preview1-00279
[platform/core/csapi/tizenfx.git] / src / Tizen.Uix.InputMethod / Tizen.Uix.InputMethod / EditorWindow.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 using Tizen;
18 using System;
19 using ElmSharp;
20 using static Interop.InputMethod;
21
22 namespace Tizen.Uix.InputMethod
23 {
24     /// <summary>
25     /// The Editor window class
26     /// </summary>
27     public class EditorWindow : Window
28     {
29         internal static IntPtr _handle = IntPtr.Zero;
30         private IntPtr _realHandle = IntPtr.Zero;
31
32         internal EditorWindow():base("Edit")
33         {
34             _realHandle = _handle;
35         }
36
37         /// <summary>
38         /// This API creates handle for editor window.
39         /// </summary>
40         protected override IntPtr CreateHandle(EvasObject parent)
41         {
42             return _handle;
43         }
44
45         /// <summary>
46         /// This API gets handle for editor window.
47         /// </summary>
48         public IntPtr GetHandle()
49         {
50             return _handle;
51         }
52
53         /// <summary>
54         /// This API updates the input panel window's size information.
55         /// </summary>
56         /// <privilege>
57         /// http://tizen.org/privilege/ime
58         /// </privilege>
59         /// <param name="portraitWidth">The width in portrait mode</param>
60         /// <param name="portraitHeight">The height in portrait mode</param>
61         /// <param name="landscapeWidth">The width in landscape mode</param>
62         /// <param name="landscapeHeight">The height in landscape mode</param>
63         /// <exception cref="InvalidOperationException">
64         /// This can occur due to the following reasons:
65         /// 1) The application does not have the privilege to call this function
66         /// 2) IME main loop isn't started yet
67         /// </exception>
68         public static void SetSize(int portraitWidth, int portraitHeight, int landscapeWidth, int landscapeHeight)
69         {
70             ErrorCode error = ImeSetSize(portraitWidth, portraitHeight, landscapeWidth, landscapeHeight);
71             if (error != ErrorCode.None)
72             {
73                 Log.Error(LogTag, "SetSize Failed with error " + error);
74                 throw InputMethodExceptionFactory.CreateException(error);
75             }
76         }
77     }
78 }