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