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