2 * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
18 using System.Collections.Generic;
23 /// It inherits <see cref="Widget"/>.
24 /// The Container is a abstract class.
25 /// Other class inherits it to Elementary is about displaying
26 /// its widgets in a nice layout.
28 public abstract class Container : Widget
30 HashSet<EvasObject> _children = new HashSet<EvasObject>();
33 /// Creates and initializes a new instance of class which inherit from Container.
35 /// <param name="parent">The parent is a given object which will be attached by Container
36 /// as a child.It's <see cref="EvasObject"/> type.</param>
37 public Container(EvasObject parent) : base(parent)
42 /// Sets the background color of a given Container.
44 public override Color BackgroundColor
50 SetPartColor("bg", Color.Transparent);
54 SetPartColor("bg", value);
56 _backgroundColor = value;
61 /// Gets the collection of child EvasObject of the Container.
63 protected IEnumerable<EvasObject> Children => _children;
66 /// Add an EvasObject object as a child of Container.
68 /// <param name="obj">The EvasObject object to be added</param>
69 protected void AddChild(EvasObject obj)
72 obj.Deleted += OnChildDeleted;
76 /// Remove an EvasObject object as a child of Container.
78 /// <param name="obj">The EvasObject object to be removed</param>
79 protected void RemoveChild(EvasObject obj)
81 _children.Remove(obj);
85 /// Clear all children of the Container.
87 protected void ClearChildren()
93 /// The Container Callback that is invoked when a child is removed.
95 /// <param name="sender">The called Container</param>
96 /// <param name="a"><see cref="EventArgs"/></param>
97 void OnChildDeleted(object sender, EventArgs a)
99 _children.Remove((EvasObject)sender);