086f1879ce0e648c37ef8c1d9b7ec130ede189c1
[platform/core/csapi/elm-sharp.git] / ElmSharp / ElmSharp / Container.cs
1 /*
2  * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
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 using System;
18 using System.Collections.Generic;
19
20 namespace ElmSharp
21 {
22     public abstract class Container : Widget
23     {
24         HashSet<EvasObject> _children = new HashSet<EvasObject>();
25
26         public Container(EvasObject parent) : base(parent)
27         {
28         }
29
30         internal void AddChild(EvasObject obj)
31         {
32             _children.Add(obj);
33             obj.Deleted += OnChildDeleted;
34         }
35
36         internal void RemoveChild(EvasObject obj)
37         {
38             _children.Remove(obj);
39         }
40
41         internal void ClearChildren()
42         {
43             _children.Clear();
44         }
45
46         void OnChildDeleted(object sender, EventArgs a)
47         {
48             _children.Remove((EvasObject)sender);
49         }
50     }
51 }