[NUI] Add FontClient related classes
[platform/core/csapi/tizenfx.git] / src / Tizen.NUI / src / internal / GlyphInfo.cs
1 /*
2  * Copyright(c) 2017 Samsung Electronics Co., Ltd.
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 namespace Tizen.NUI
18 {
19
20     internal class GlyphInfo : global::System.IDisposable
21     {
22         private global::System.Runtime.InteropServices.HandleRef swigCPtr;
23         protected bool swigCMemOwn;
24
25         internal GlyphInfo(global::System.IntPtr cPtr, bool cMemoryOwn)
26         {
27             swigCMemOwn = cMemoryOwn;
28             swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
29         }
30
31         internal static global::System.Runtime.InteropServices.HandleRef getCPtr(GlyphInfo obj)
32         {
33             return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
34         }
35
36         //A Flag to check who called Dispose(). (By User or DisposeQueue)
37         private bool isDisposeQueued = false;
38         /// <summary>
39         /// A Flat to check if it is already disposed.
40         /// </summary>
41         protected bool disposed = false;
42
43         ~GlyphInfo()
44         {
45             if (!isDisposeQueued)
46             {
47                 isDisposeQueued = true;
48                 DisposeQueue.Instance.Add(this);
49             }
50         }
51
52         public void Dispose()
53         {
54             //Throw excpetion if Dispose() is called in separate thread.
55             if (!Window.IsInstalled())
56             {
57                 throw new System.InvalidOperationException("This API called from separate thread. This API must be called from MainThread.");
58             }
59
60             if (isDisposeQueued)
61             {
62                 Dispose(DisposeTypes.Implicit);
63             }
64             else
65             {
66                 Dispose(DisposeTypes.Explicit);
67                 System.GC.SuppressFinalize(this);
68             }
69         }
70
71         protected virtual void Dispose(DisposeTypes type)
72         {
73             if (disposed)
74             {
75                 return;
76             }
77
78             if (type == DisposeTypes.Explicit)
79             {
80                 //Called by User
81                 //Release your own managed resources here.
82                 //You should release all of your own disposable objects here.
83             }
84
85             //Release your own unmanaged resources here.
86             //You should not access any managed member here except static instance.
87             //because the execution order of Finalizes is non-deterministic.
88
89             if (swigCPtr.Handle != global::System.IntPtr.Zero)
90             {
91                 if (swigCMemOwn)
92                 {
93                     swigCMemOwn = false;
94                     NDalicManualPINVOKE.delete_GlyphInfo(swigCPtr);
95                 }
96                 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
97             }
98             disposed = true;
99         }
100
101         public GlyphInfo() : this(NDalicManualPINVOKE.new_GlyphInfo__SWIG_0(), true)
102         {
103             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
104         }
105
106         public GlyphInfo(uint font, uint i) : this(NDalicManualPINVOKE.new_GlyphInfo__SWIG_1(font, i), true)
107         {
108             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
109         }
110
111         public uint FontId
112         {
113             set
114             {
115                 NDalicManualPINVOKE.GlyphInfo_fontId_set(swigCPtr, value);
116                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
117             }
118             get
119             {
120                 uint ret = NDalicManualPINVOKE.GlyphInfo_fontId_get(swigCPtr);
121                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
122                 return ret;
123             }
124         }
125
126         public uint Index
127         {
128             set
129             {
130                 NDalicManualPINVOKE.GlyphInfo_index_set(swigCPtr, value);
131                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
132             }
133             get
134             {
135                 uint ret = NDalicManualPINVOKE.GlyphInfo_index_get(swigCPtr);
136                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
137                 return ret;
138             }
139         }
140
141         public float Width
142         {
143             set
144             {
145                 NDalicManualPINVOKE.GlyphInfo_width_set(swigCPtr, value);
146                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
147             }
148             get
149             {
150                 float ret = NDalicManualPINVOKE.GlyphInfo_width_get(swigCPtr);
151                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
152                 return ret;
153             }
154         }
155
156         public float Height
157         {
158             set
159             {
160                 NDalicManualPINVOKE.GlyphInfo_height_set(swigCPtr, value);
161                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
162             }
163             get
164             {
165                 float ret = NDalicManualPINVOKE.GlyphInfo_height_get(swigCPtr);
166                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
167                 return ret;
168             }
169         }
170
171         public float XBearing
172         {
173             set
174             {
175                 NDalicManualPINVOKE.GlyphInfo_xBearing_set(swigCPtr, value);
176                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
177             }
178             get
179             {
180                 float ret = NDalicManualPINVOKE.GlyphInfo_xBearing_get(swigCPtr);
181                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
182                 return ret;
183             }
184         }
185
186         public float YBearing
187         {
188             set
189             {
190                 NDalicManualPINVOKE.GlyphInfo_yBearing_set(swigCPtr, value);
191                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
192             }
193             get
194             {
195                 float ret = NDalicManualPINVOKE.GlyphInfo_yBearing_get(swigCPtr);
196                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
197                 return ret;
198             }
199         }
200
201         public float Advance
202         {
203             set
204             {
205                 NDalicManualPINVOKE.GlyphInfo_advance_set(swigCPtr, value);
206                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
207             }
208             get
209             {
210                 float ret = NDalicManualPINVOKE.GlyphInfo_advance_get(swigCPtr);
211                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
212                 return ret;
213             }
214         }
215
216         public float ScaleFactor
217         {
218             set
219             {
220                 NDalicManualPINVOKE.GlyphInfo_scaleFactor_set(swigCPtr, value);
221                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
222             }
223             get
224             {
225                 float ret = NDalicManualPINVOKE.GlyphInfo_scaleFactor_get(swigCPtr);
226                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
227                 return ret;
228             }
229         }
230
231     }
232
233 }