Merge "Fix Box.MinimumHeight issue" into devel/dotnet
[platform/core/csapi/tizenfx.git] / src / ElmSharp / ElmSharp / Box.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
19 namespace ElmSharp
20 {
21     public class Box : Container
22     {
23         private Interop.Elementary.BoxLayoutCallback _layoutCallback;
24
25         public Box(EvasObject parent) : base(parent)
26         {
27         }
28
29         public bool IsHorizontal
30         {
31             get
32             {
33                 return Interop.Elementary.elm_box_horizontal_get(RealHandle);
34             }
35             set
36             {
37                 Interop.Elementary.elm_box_horizontal_set(RealHandle, value);
38             }
39         }
40
41         public void PackEnd(EvasObject content)
42         {
43             Interop.Elementary.elm_box_pack_end(RealHandle, content);
44             AddChild(content);
45         }
46
47         public void PackStart(EvasObject content)
48         {
49             Interop.Elementary.elm_box_pack_start(RealHandle, content);
50             AddChild(content);
51         }
52
53         public void PackAfter(EvasObject content, EvasObject after)
54         {
55             Interop.Elementary.elm_box_pack_after(RealHandle, content, after);
56             AddChild(content);
57         }
58
59         public void UnPack(EvasObject content)
60         {
61             Interop.Elementary.elm_box_unpack(RealHandle, content);
62             RemoveChild(content);
63         }
64
65         public void UnPackAll()
66         {
67             Interop.Elementary.elm_box_unpack_all(RealHandle);
68             ClearChildren();
69         }
70
71         public void SetLayoutCallback(Action action)
72         {
73             _layoutCallback = (obj, priv, data) =>
74             {
75                 action();
76             };
77             Interop.Elementary.elm_box_layout_set(RealHandle, _layoutCallback, IntPtr.Zero, null);
78         }
79
80         protected override IntPtr CreateHandle(EvasObject parent)
81         {
82             IntPtr handle = Interop.Elementary.elm_layout_add(parent);
83             Interop.Elementary.elm_layout_theme_set(handle, "layout", "background", "default");
84
85             RealHandle = Interop.Elementary.elm_box_add(handle);
86             Interop.Elementary.elm_object_part_content_set(handle, "elm.swallow.content", RealHandle);
87
88             return handle;
89         }
90     }
91 }