Release 4.0.0-preview1-00271
[platform/core/csapi/tizenfx.git] / src / Tizen.NUI / src / public / VisualBase.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 */
16
17 using System;
18 using System.Runtime.InteropServices;
19
20 namespace Tizen.NUI
21 {
22
23     /// <summary>
24     /// Sets whether the actor should be focusable by keyboard navigation.<br>
25     /// Visuals reuse geometry, shader etc. across controls. They ensure that the renderer and texture sets exist only when control is on window.<br>
26     /// Each visual also responds to actor size and color change, and provides clipping at the renderer level.<br>
27     /// </summary>
28     public class VisualBase : BaseHandle
29     {
30         private global::System.Runtime.InteropServices.HandleRef swigCPtr;
31
32         internal VisualBase(global::System.IntPtr cPtr, bool cMemoryOwn) : base(NDalicPINVOKE.VisualBase_SWIGUpcast(cPtr), cMemoryOwn)
33         {
34             swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
35         }
36
37         internal static global::System.Runtime.InteropServices.HandleRef getCPtr(VisualBase obj)
38         {
39             return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
40         }
41
42         protected override void Dispose(DisposeTypes type)
43         {
44             if(disposed)
45             {
46                 return;
47             }
48
49             if(type == DisposeTypes.Explicit)
50             {
51                 //Called by User
52                 //Release your own managed resources here.
53                 //You should release all of your own disposable objects here.
54             }
55
56             //Release your own unmanaged resources here.
57             //You should not access any managed member here except static instance.
58             //because the execution order of Finalizes is non-deterministic.
59
60             if (swigCPtr.Handle != global::System.IntPtr.Zero)
61             {
62                 if (swigCMemOwn)
63                 {
64                     swigCMemOwn = false;
65                     NDalicPINVOKE.delete_VisualBase(swigCPtr);
66                 }
67                 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
68             }
69
70             base.Dispose(type);
71         }
72
73         /// <summary>
74         /// Creates an empty visual handle.
75         /// </summary>
76         /// <since_tizen> 3 </since_tizen>
77         public VisualBase() : this(NDalicPINVOKE.new_VisualBase__SWIG_0(), true)
78         {
79             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
80         }
81
82         internal VisualBase(VisualBase handle) : this(NDalicPINVOKE.new_VisualBase__SWIG_1(VisualBase.getCPtr(handle)), true)
83         {
84             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
85         }
86
87         /// <summary>
88         /// The name of the visual.
89         /// </summary>
90         /// <since_tizen> 3 </since_tizen>
91         public string Name
92         {
93             set
94             {
95                 SetName(value);
96             }
97             get
98             {
99                 return GetName();
100             }
101         }
102
103         internal void SetName(string name)
104         {
105             NDalicPINVOKE.VisualBase_SetName(swigCPtr, name);
106             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
107         }
108
109         internal string GetName()
110         {
111             string ret = NDalicPINVOKE.VisualBase_GetName(swigCPtr);
112             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
113             return ret;
114         }
115
116         /// <summary>
117         /// Sets the transform and the control size.
118         /// </summary>
119         /// <param name="transform">A property map describing the transform.</param>
120         /// <param name="controlSize">The size of the parent control for visuals that need to scale internally.</param>
121         /// <since_tizen> 3 </since_tizen>
122         public void SetTransformAndSize(PropertyMap transform, Vector2 controlSize)
123         {
124             NDalicPINVOKE.VisualBase_SetTransformAndSize(swigCPtr, PropertyMap.getCPtr(transform), Vector2.getCPtr(controlSize));
125             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
126         }
127
128         /// <summary>
129         /// Returns the height for a given width.
130         /// </summary>
131         /// <param name="width">The width to use.</param>
132         /// <returns>The height based on the width.</returns>
133         /// <since_tizen> 3 </since_tizen>
134         public float GetHeightForWidth(float width)
135         {
136             float ret = NDalicPINVOKE.VisualBase_GetHeightForWidth(swigCPtr, width);
137             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
138             return ret;
139         }
140
141         /// <summary>
142         /// Returns the width for a given height.
143         /// </summary>
144         /// <param name="height">The height to use.</param>
145         /// <returns>The width based on the height.</returns>
146         /// <since_tizen> 3 </since_tizen>
147         public float GetWidthForHeight(float height)
148         {
149             float ret = NDalicPINVOKE.VisualBase_GetWidthForHeight(swigCPtr, height);
150             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
151             return ret;
152         }
153
154         /// <summary>
155         /// Returns the natural size of the visual.<br>
156         /// Deriving classes stipulate the natural size and by default a visual has a zero natural size.<br>
157         /// A visual may not actually have a natural size until it has been placed on window and acquired all it's resources.<br>
158         /// </summary>
159         /// <param name="naturalSize">The visual's natural size.</param>
160         /// <since_tizen> 3 </since_tizen>
161         public void GetNaturalSize(Size2D naturalSize)
162         {
163             NDalicPINVOKE.VisualBase_GetNaturalSize(swigCPtr, Size2D.getCPtr(naturalSize));
164             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
165         }
166
167         /// <summary>
168         /// The depth index of this visual.
169         /// </summary>
170         /// <since_tizen> 3 </since_tizen>
171         public int DepthIndex
172         {
173             set
174             {
175                 SetDepthIndex(value);
176             }
177             get
178             {
179                 return GetDepthIndex();
180             }
181         }
182         internal void SetDepthIndex(int index)
183         {
184             NDalicPINVOKE.VisualBase_SetDepthIndex(swigCPtr, index);
185             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
186         }
187
188         internal int GetDepthIndex()
189         {
190             int ret = NDalicPINVOKE.VisualBase_GetDepthIndex(swigCPtr);
191             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
192             return ret;
193         }
194
195         /// <summary>
196         /// Creates the property map representing this visual.
197         /// </summary>
198         [Obsolete("Please be caution! this will be readonly.")]
199         public PropertyMap Creation
200         {
201             set
202             {
203                 CreatePropertyMap(value);
204             }
205             get
206             {
207                 PropertyMap map = new PropertyMap();
208                 CreatePropertyMap(map);
209                 return map;
210             }
211         }
212
213         internal void CreatePropertyMap(PropertyMap map)
214         {
215             NDalicPINVOKE.VisualBase_CreatePropertyMap(swigCPtr, PropertyMap.getCPtr(map));
216             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
217         }
218
219         internal VisualBase(SWIGTYPE_p_Dali__Toolkit__Internal__Visual__Base impl) : this(NDalicPINVOKE.new_VisualBase__SWIG_2(SWIGTYPE_p_Dali__Toolkit__Internal__Visual__Base.getCPtr(impl)), true)
220         {
221             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
222         }
223
224     }
225
226 }