Revert "[NUI] Fix ConvertIdToView (#877)" (#889)
[platform/core/csapi/tizenfx.git] / src / Tizen.NUI / src / public / Container.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.Collections.Generic;
20 using Tizen.NUI.BaseComponents;
21
22 namespace Tizen.NUI
23 {
24     /// <summary>
25     /// The Container is an abstract class to be inherited from by classes that desire to have views
26     /// added to them.
27     /// </summary>
28     /// <since_tizen> 4 </since_tizen>
29     public abstract class Container : Animatable
30     {
31         internal BaseHandle InternalParent;
32         private List<View> _childViews = new List<View>();
33
34         internal Container(global::System.IntPtr cPtr, bool cMemoryOwn) : base(cPtr, cMemoryOwn)
35         {
36             // No un-managed data hence no need to store a native ptr
37         }
38
39         /// <summary>
40         /// List of children of Container.
41         /// </summary>
42         /// <since_tizen> 4 </since_tizen>
43         public List<View> Children
44         {
45             get
46             {
47                 return _childViews;
48             }
49         }
50
51         /// <summary>
52         /// Gets the parent container.
53         /// Read only
54         /// </summary>
55         /// <pre>The child container has been initialized.</pre>
56         /// <returns>The parent container.</returns>
57         /// <since_tizen> 4 </since_tizen>
58         public Container Parent
59         {
60             get
61             {
62                 return GetParent();
63             }
64         }
65
66         /// <summary>
67         /// Gets the number of children for this container.
68         /// Read only
69         /// </summary>
70         /// <pre>The container has been initialized.</pre>
71         /// <returns>The number of children.</returns>
72         /// <since_tizen> 4 </since_tizen>
73         public uint ChildCount
74         {
75             get
76             {
77                 return GetChildCount();
78             }
79         }
80
81         /// <summary>
82         /// Adds a child view to this Container.
83         /// </summary>
84         /// <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>
85         /// <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>
86         /// <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>
87         /// <param name="view">The child view to add.</param>
88         /// <since_tizen> 4 </since_tizen>
89         public abstract void Add(View view);
90
91         /// <summary>
92         /// Removes a child view from this view. If the view was not a child of this view, this is a no-op.
93         /// </summary>
94         /// <pre>This View(the parent) has been initialized. The child view is not the same as the parent view.</pre>
95         /// <param name="view">The view to remove</param>
96         /// <since_tizen> 4 </since_tizen>
97         public abstract void Remove(View view);
98
99         /// <summary>
100         /// Retrieves the child view by the index.
101         /// </summary>
102         /// <pre>The view has been initialized.</pre>
103         /// <param name="index">The index of the child to retrieve.</param>
104         /// <returns>The view for the given index or empty handle if children are not initialized.</returns>
105         /// <since_tizen> 4 </since_tizen>
106         public abstract View GetChildAt(uint index);
107
108         /// <summary>
109         /// Gets the parent of this container.
110         /// </summary>
111         /// <pre>The child container has been initialized.</pre>
112         /// <returns>The parent container.</returns>
113         /// <since_tizen> 4 </since_tizen>
114         public abstract Container GetParent();
115
116         /// <summary>
117         /// Gets the number of children for this container.
118         /// </summary>
119         /// <pre>The container has been initialized.</pre>
120         /// <returns>The number of children.</returns>
121         /// <since_tizen> 4 </since_tizen>
122         public abstract UInt32 GetChildCount();
123
124         /// <summary>
125         /// Dispose.
126         /// </summary>
127         /// <since_tizen> 4 </since_tizen>
128         protected override void Dispose(DisposeTypes type)
129         {
130             if (disposed)
131             {
132                 return;
133             }
134
135             base.Dispose(type);
136         }
137
138     }
139 } // namespace Tizen.NUI