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.
22 /// The Box is a container that is used to arrange UI components in a linear order.
24 /// <since_tizen> preview </since_tizen>
25 [Obsolete("This has been deprecated in API12")]
26 public class Box : Container
28 private Interop.Elementary.BoxLayoutCallback _layoutCallback;
31 /// Creates and initializes a new instance of the Box class.
33 /// <param name="parent">The EvasObject to which the new Box will be attached as a child.</param>
34 /// <since_tizen> preview </since_tizen>
35 [Obsolete("This has been deprecated in API12")]
36 public Box(EvasObject parent) : base(parent)
41 /// Sets or gets the IsHorizontal value, which describe the pack direction. Vertical is default.
43 /// <since_tizen> preview </since_tizen>
44 [Obsolete("This has been deprecated in API12")]
45 public bool IsHorizontal
49 return Interop.Elementary.elm_box_horizontal_get(RealHandle);
53 Interop.Elementary.elm_box_horizontal_set(RealHandle, value);
58 /// Sets or gets whether the box has to arrange its children homogeneously.
60 /// <since_tizen> preview </since_tizen>
61 [Obsolete("This has been deprecated in API12")]
62 public bool IsHomogeneous
66 return Interop.Elementary.elm_box_homogeneous_get(RealHandle);
70 Interop.Elementary.elm_box_homogeneous_set(RealHandle, value);
75 /// Adds an object at the end of the pack list.
78 /// Packs the "content" object into the Box, placing it last in the list of children objects.
79 /// The actual position of the object will get on the screen depending on the layout used.
80 /// If no custom layout is set, it will be at the bottom or right,
81 /// depending if the Box is vertical or horizontal, respectively.
83 /// <param name="content">The oject to be packed.</param>
84 /// <since_tizen> preview </since_tizen>
85 [Obsolete("This has been deprecated in API12")]
86 public void PackEnd(EvasObject content)
88 Interop.Elementary.elm_box_pack_end(RealHandle, content);
93 /// Adds a "content" object to the beginning of the pack list.
96 /// Packs the "content" object into the box object, placing it first in the list of children objects.
97 /// The actual position of the object will get on the screen depending on the layout used.
98 /// If no custom layout is set, it will be at the top or left,
99 /// depending if the Box is vertical or horizontal, respectively.
101 /// <param name="content">The object to be packed.</param>
102 /// <since_tizen> preview </since_tizen>
103 [Obsolete("This has been deprecated in API12")]
104 public void PackStart(EvasObject content)
106 Interop.Elementary.elm_box_pack_start(RealHandle, content);
111 /// Adds a "content" object to the box after the "after" object.
114 /// This will add the "content" to the box indicated after the object indicated with "after".
115 /// If "after" is not already in the box, the results are undefined.
116 /// After means either to the right of the "after" object or below it, depending on orientation.
118 /// <param name="content">The object will be added in the box.</param>
119 /// <param name="after">The object has been added in the box.</param>
120 /// <since_tizen> preview </since_tizen>
121 [Obsolete("This has been deprecated in API12")]
122 public void PackAfter(EvasObject content, EvasObject after)
124 Interop.Elementary.elm_box_pack_after(RealHandle, content, after);
129 /// Adds a "content" object to the box before the "before" object.
132 /// This will add the "content" to the box indicated before the object indicated with "before".
133 /// If "before" is not already in the box, the results are undefined.
134 /// Before means either to the left of the "before" object or below it, depending on orientation.
136 /// <param name="content">The object will be added in the box.</param>
137 /// <param name="before">The object has been added in the box.</param>
138 /// <since_tizen> preview </since_tizen>
139 [Obsolete("This has been deprecated in API12")]
140 public void PackBefore(EvasObject content, EvasObject before)
142 Interop.Elementary.elm_box_pack_before(RealHandle, content, before);
147 /// Removes the "content" object from the box without deleting it.
149 /// <param name="content">The object to unpack.</param>
150 /// <since_tizen> preview </since_tizen>
151 [Obsolete("This has been deprecated in API12")]
152 public void UnPack(EvasObject content)
154 Interop.Elementary.elm_box_unpack(RealHandle, content);
155 RemoveChild(content);
159 /// Removes all the objects from the Box container.
161 /// <since_tizen> preview </since_tizen>
162 [Obsolete("This has been deprecated in API12")]
163 public void UnPackAll()
165 Interop.Elementary.elm_box_unpack_all(RealHandle);
170 /// Whenever any changes that requires the box in object to recalculate the size and position of its elements,
171 /// the function cb will be called to determine what the layout of the children will be.
173 /// <param name="action">The callback function used for layout.</param>
174 /// <since_tizen> preview </since_tizen>
175 [Obsolete("This has been deprecated in API12")]
176 public void SetLayoutCallback(Action action)
178 _layoutCallback = (obj, priv, data) =>
182 Interop.Elementary.elm_box_layout_set(RealHandle, _layoutCallback, IntPtr.Zero, null);
186 /// Sets the color of the exact part to the box's layout parent.
188 /// <param name="part">The name of part class, it could be 'bg', 'elm.swllow.content'.</param>
189 /// <param name="color">The color value.</param>
190 /// <since_tizen> preview </since_tizen>
191 [Obsolete("This has been deprecated in API12")]
192 public override void SetPartColor(string part, Color color)
194 Interop.Elementary.elm_object_color_class_color_set(Handle, part, color.R * color.A / 255,
195 color.G * color.A / 255,
196 color.B * color.A / 255,
201 /// Gets the color of the exact part of the box's layout parent.
203 /// <param name="part">The name of part class, it could be 'bg', 'elm.swllow.content'.</param>
204 /// <returns></returns>
205 /// <since_tizen> preview </since_tizen>
206 [Obsolete("This has been deprecated in API12")]
207 public override Color GetPartColor(string part)
210 Interop.Elementary.elm_object_color_class_color_get(Handle, part, out r, out g, out b, out a);
211 return new Color((int)(r / (a / 255.0)), (int)(g / (a / 255.0)), (int)(b / (a / 255.0)), a);
215 /// Forces the box to recalculate its children packing.
216 /// If any children were added or removed, the box will not calculate the values immediately, rather leaving it to the next main loop iteration.
217 /// While this is great as it would save lots of recalculation, whenever you need to get the position of a just added item, you must force recalculate before doing so.
219 /// <since_tizen> preview </since_tizen>
220 [Obsolete("This has been deprecated in API12")]
221 public void Recalculate()
223 Interop.Elementary.elm_box_recalculate(RealHandle);
227 /// Clears the box's of all the children.
228 /// Remove all the elements contained by the box, deleting the respective objects.
230 /// <since_tizen> preview </since_tizen>
231 [Obsolete("This has been deprecated in API12")]
234 Interop.Elementary.elm_box_clear(RealHandle);
239 /// Sets or gets the alignment of the whole bounding box of contents.
241 /// <param name="horizontal">Horizontal alignment.</param>
242 /// <param name="vertical">Vertical alignment.</param>
243 /// <since_tizen> preview </since_tizen>
244 [Obsolete("This has been deprecated in API12")]
245 public void SetBoxAlignment(double horizontal, double vertical)
247 Interop.Elementary.elm_box_align_set(RealHandle, horizontal, vertical);
251 /// Sets or gets the space (padding) between the box's elements.
253 /// <param name="horizontal">Horizontal padding.</param>
254 /// <param name="vertical">Vertical padding.</param>
255 /// <since_tizen> preview </since_tizen>
256 [Obsolete("This has been deprecated in API12")]
257 public void SetPadding(int horizontal, int vertical)
259 Interop.Elementary.elm_box_padding_set(RealHandle, horizontal, vertical);
263 /// Creates a widget handle.
265 /// <param name="parent">Parent EvasObject.</param>
266 /// <returns>Handle IntPtr.</returns>
267 /// <since_tizen> preview </since_tizen>
268 [Obsolete("This has been deprecated in API12")]
269 protected override IntPtr CreateHandle(EvasObject parent)
271 IntPtr handle = Interop.Elementary.elm_layout_add(parent.Handle);
272 Interop.Elementary.elm_layout_theme_set(handle, "layout", "background", "default");
274 RealHandle = Interop.Elementary.elm_box_add(handle);
275 Interop.Elementary.elm_object_part_content_set(handle, "elm.swallow.content", RealHandle);