ff79bcc1427e8673c6af2d71e912d2cb2d36157c
[platform/core/csapi/tizenfx.git] / src / Tizen.NUI / src / internal / FontMetrics.cs
1 /*
2  * Copyright(c) 2019 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     internal class FontMetrics : Disposable
20     {
21         private global::System.Runtime.InteropServices.HandleRef swigCPtr;
22         protected bool swigCMemOwn;
23
24         internal FontMetrics(global::System.IntPtr cPtr, bool cMemoryOwn)
25         {
26             swigCMemOwn = cMemoryOwn;
27             swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
28         }
29
30         internal static global::System.Runtime.InteropServices.HandleRef getCPtr(FontMetrics obj)
31         {
32             return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
33         }
34
35         protected override void Dispose(DisposeTypes type)
36         {
37             if (disposed)
38             {
39                 return;
40             }
41
42             //Release your own unmanaged resources here.
43             //You should not access any managed member here except static instance.
44             //because the execution order of Finalizes is non-deterministic.
45
46             if (swigCPtr.Handle != global::System.IntPtr.Zero)
47             {
48                 if (swigCMemOwn)
49                 {
50                     swigCMemOwn = false;
51                     Interop.FontClient.delete_FontMetrics(swigCPtr);
52                 }
53                 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
54             }
55             base.Dispose(type);
56         }
57
58         public FontMetrics() : this(Interop.FontClient.new_FontMetrics__SWIG_0(), true)
59         {
60             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
61         }
62
63         public FontMetrics(float ascenderPixels, float descenderPixels, float heightPixels, float underlinePositionPixels, float underlinePositionThickness) : this(Interop.FontClient.new_FontMetrics__SWIG_1(ascenderPixels, descenderPixels, heightPixels, underlinePositionPixels, underlinePositionThickness), true)
64         {
65             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
66         }
67
68         public float Ascender
69         {
70             set
71             {
72                 Interop.FontClient.FontMetrics_ascender_set(swigCPtr, value);
73                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
74             }
75             get
76             {
77                 float ret = Interop.FontClient.FontMetrics_ascender_get(swigCPtr);
78                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
79                 return ret;
80             }
81         }
82
83         public float Descender
84         {
85             set
86             {
87                 Interop.FontClient.FontMetrics_descender_set(swigCPtr, value);
88                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
89             }
90             get
91             {
92                 float ret = Interop.FontClient.FontMetrics_descender_get(swigCPtr);
93                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
94                 return ret;
95             }
96         }
97
98         public float Height
99         {
100             set
101             {
102                 Interop.FontClient.FontMetrics_height_set(swigCPtr, value);
103                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
104             }
105             get
106             {
107                 float ret = Interop.FontClient.FontMetrics_height_get(swigCPtr);
108                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
109                 return ret;
110             }
111         }
112
113         public float UnderlinePosition
114         {
115             set
116             {
117                 Interop.FontClient.FontMetrics_underlinePosition_set(swigCPtr, value);
118                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
119             }
120             get
121             {
122                 float ret = Interop.FontClient.FontMetrics_underlinePosition_get(swigCPtr);
123                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
124                 return ret;
125             }
126         }
127
128         public float UnderlineThickness
129         {
130             set
131             {
132                 Interop.FontClient.FontMetrics_underlineThickness_set(swigCPtr, value);
133                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
134             }
135             get
136             {
137                 float ret = Interop.FontClient.FontMetrics_underlineThickness_get(swigCPtr);
138                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
139                 return ret;
140             }
141         }
142     }
143 }