Merge "Add tag and document to Tizen.NUI."
[platform/core/csapi/tizenfx.git] / src / Tizen.NUI / src / public / Container.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 Tizen.NUI.BaseComponents;
19
20 namespace Tizen.NUI
21 {
22     /// <summary>
23     ///
24     /// The Container is an abstract class to be inherited from by classes that desire to have views
25     /// added to them.
26     ///
27     /// </summary>
28     public abstract class Container : Animatable
29     {
30
31         internal Container(global::System.IntPtr cPtr, bool cMemoryOwn) : base(cPtr, cMemoryOwn)
32         {
33             // No un-managed data hence no need to store a native ptr
34         }
35
36         protected override void Dispose(DisposeTypes type)
37         {
38             if (disposed)
39             {
40                 return;
41             }
42
43             base.Dispose(type);
44         }
45
46
47         /// <summary>
48         /// Adds a child view to this Container.
49         /// </summary>
50         /// <pre>This Container (the parent) has been initialized. The child view has been initialized. The child view is not the same as the parent view.</pre>
51         /// <post>The child will be referenced by its parent. This means that the child will be kept alive, even if the handle passed into this method is reset or destroyed.</post>
52         /// <remarks>If the child already has a parent, it will be removed from the old parent and reparented to this view. This may change child's position, color, scale, etc. as it now inherits them from this view.</remarks>
53         /// <param name="view">The child view to add.</param>
54         /// <since_tizen> 4 </since_tizen>
55         public abstract void Add( View view );
56
57         /// <summary>
58         /// Removes a child view from this view. If the view was not a child of this view, this is a no-op.
59         /// </summary>
60         /// <pre>This View(the parent) has been initialized. The child view is not the same as the parent view.</pre>
61         /// <param name="view">The view to remove</param>
62         /// <since_tizen> 4 </since_tizen>
63         public abstract void Remove( View view );
64
65         /// <summary>
66         /// Retrieves the child view by the index.
67         /// </summary>
68         /// <pre>The view has been initialized.</pre>
69         /// <param name="index">The index of the child to retrieve.</param>
70         /// <returns>The view for the given index or empty handle if children are not initialized.</returns>
71         /// <since_tizen> 4 </since_tizen>
72         public abstract View GetChildAt( uint index );
73
74         /// <summary>
75         /// Gets the parent of this container.
76         /// </summary>
77         /// <pre>The child container has been initialized.</pre>
78         /// <returns>The parent container.</returns>
79         protected abstract Container GetParent();
80
81         /// <summary>
82         /// Gets the number of children for this container.
83         /// </summary>
84         /// <pre>The container has been initialized.</pre>
85         /// <returns>The number of children.</returns>
86         protected abstract UInt32 GetChildCount();
87
88         /// <summary>
89         /// Gets the parent container.
90         /// Read only
91         /// </summary>
92         /// <pre>The child container has been initialized.</pre>
93         /// <returns>The parent container.</returns>
94         /// <since_tizen> 4 </since_tizen>
95         public Container Parent
96         {
97             get
98             {
99                 return GetParent();
100             }
101         }
102
103         /// <summary>
104         /// Gets the number of children for this container.
105         /// Read only
106         /// </summary>
107         /// <pre>The container has been initialized.</pre>
108         /// <returns>The number of children.</returns>
109         /// <since_tizen> 4 </since_tizen>
110         public uint ChildCount
111         {
112             get
113             {
114                 return GetChildCount();
115             }
116         }
117     }
118 } // namespace Tizen.NUI