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