2 * Copyright(c) 2017 Samsung Electronics Co., Ltd.
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 namespace Tizen.NUI.BaseComponents
21 /// FlexContainer implements a subset of the flexbox spec (defined by W3C):https://www.w3.org/TR/css3-flexbox/<br />
22 /// It aims at providing a more efficient way to layout, align, and distribute space among items in the container, even when their size is unknown or dynamic.<br />
23 /// FlexContainer has the ability to alter the width and the height of its children (i.e., flex items) to fill the available space in the best possible way on different screen sizes.<br />
24 /// FlexContainer can expand items to fill available free space, or shrink them to prevent overflow.<br />
26 public class FlexContainer : View
28 private global::System.Runtime.InteropServices.HandleRef swigCPtr;
30 internal FlexContainer(global::System.IntPtr cPtr, bool cMemoryOwn) : base(NDalicPINVOKE.FlexContainer_SWIGUpcast(cPtr), cMemoryOwn)
32 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
35 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(FlexContainer obj)
37 return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
41 /// To make the FlexContainer instance be disposed.
43 /// <since_tizen> 3 </since_tizen>
44 protected override void Dispose(DisposeTypes type)
51 if(type == DisposeTypes.Explicit)
54 //Release your own managed resources here.
55 //You should release all of your own disposable objects here.
58 //Release your own unmanaged resources here.
59 //You should not access any managed member here except static instance.
60 //because the execution order of Finalizes is non-deterministic.
62 if (swigCPtr.Handle != global::System.IntPtr.Zero)
67 NDalicPINVOKE.delete_FlexContainer(swigCPtr);
69 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
76 internal new class Property
78 internal static readonly int CONTENT_DIRECTION = NDalicPINVOKE.FlexContainer_Property_CONTENT_DIRECTION_get();
79 internal static readonly int FLEX_DIRECTION = NDalicPINVOKE.FlexContainer_Property_FLEX_DIRECTION_get();
80 internal static readonly int FLEX_WRAP = NDalicPINVOKE.FlexContainer_Property_FLEX_WRAP_get();
81 internal static readonly int JUSTIFY_CONTENT = NDalicPINVOKE.FlexContainer_Property_JUSTIFY_CONTENT_get();
82 internal static readonly int ALIGN_ITEMS = NDalicPINVOKE.FlexContainer_Property_ALIGN_ITEMS_get();
83 internal static readonly int ALIGN_CONTENT = NDalicPINVOKE.FlexContainer_Property_ALIGN_CONTENT_get();
88 /// Enumeration for the instance of child properties belonging to the FlexContainer class.
90 public class ChildProperty
92 internal static readonly int FLEX = NDalicPINVOKE.FlexContainer_ChildProperty_FLEX_get();
93 internal static readonly int ALIGN_SELF = NDalicPINVOKE.FlexContainer_ChildProperty_ALIGN_SELF_get();
94 internal static readonly int FLEX_MARGIN = NDalicPINVOKE.FlexContainer_ChildProperty_FLEX_MARGIN_get();
98 /// Creates a FlexContainer handle.
99 /// Calling member functions with an uninitialized handle is not allowed.
101 public FlexContainer() : this(NDalicPINVOKE.FlexContainer_New(), true)
103 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
108 /// Enumeration for the direction of the main axis in the flex container. This determines
109 /// the direction that flex items are laid out in the flex container.
111 /// <since_tizen> 3 </since_tizen>
112 public enum FlexDirectionType
115 /// The flexible items are displayed vertically as a column.
117 /// <since_tizen> 3 </since_tizen>
120 /// The flexible items are displayed vertically as a column, but in reverse order.
122 /// <since_tizen> 3 </since_tizen>
125 /// The flexible items are displayed horizontally as a row.
127 /// <since_tizen> 3 </since_tizen>
130 /// The flexible items are displayed horizontally as a row.
132 /// <since_tizen> 3 </since_tizen>
137 /// Enumeration for the primary direction in which content is ordered in the flex container
138 /// and on which sides the ?�start??and ?�end??are.
140 /// <since_tizen> 3 </since_tizen>
141 public enum ContentDirectionType
144 /// Inherits the same direction from the parent.
146 /// <since_tizen> 3 </since_tizen>
149 /// From left to right.
151 /// <since_tizen> 3 </since_tizen>
154 /// From right to left.
156 /// <since_tizen> 3 </since_tizen>
161 /// Enumeration for the alignment of the flex items when the items do not use all available
162 /// space on the main axis.
164 /// <since_tizen> 3 </since_tizen>
165 public enum Justification
168 /// Items are positioned at the beginning of the container.
170 /// <since_tizen> 3 </since_tizen>
173 /// Items are positioned at the center of the container.
175 /// <since_tizen> 3 </since_tizen>
178 /// Items are positioned at the end of the container.
180 /// <since_tizen> 3 </since_tizen>
183 /// Items are positioned with equal space between the lines.
185 /// <since_tizen> 3 </since_tizen>
188 /// Items are positioned with equal space before, between, and after the lines.
190 /// <since_tizen> 3 </since_tizen>
195 /// Enumeration for the alignment of the flex items or lines when the items or lines do not
196 /// use all the available space on the cross axis.
198 /// <since_tizen> 3 </since_tizen>
199 public enum Alignment
202 /// Inherits the same alignment from the parent (only valid for "alignSelf" property).
204 /// <since_tizen> 3 </since_tizen>
207 /// At the beginning of the container.
209 /// <since_tizen> 3 </since_tizen>
212 /// At the center of the container.
214 /// <since_tizen> 3 </since_tizen>
217 /// At the end of the container.
219 /// <since_tizen> 3 </since_tizen>
222 /// Stretch to fit the container.
224 /// <since_tizen> 3 </since_tizen>
229 /// Enumeration for the wrap type of the flex container when there is no enough room for
230 /// all the items on one flex line.
232 /// <since_tizen> 3 </since_tizen>
236 /// Flex items laid out in single line (shrunk to fit the flex container along the main axis).
238 /// <since_tizen> 3 </since_tizen>
241 /// Flex items laid out in multiple lines if needed.
243 /// <since_tizen> 3 </since_tizen>
248 /// The primary direction in which content is ordered.
250 /// <since_tizen> 3 </since_tizen>
251 public ContentDirectionType ContentDirection
256 GetProperty(FlexContainer.Property.CONTENT_DIRECTION).Get(out temp);
257 return (ContentDirectionType)temp;
261 SetProperty(FlexContainer.Property.CONTENT_DIRECTION, new Tizen.NUI.PropertyValue((int)value));
266 /// The direction of the main axis which determines the direction that flex items are laid out.
268 /// <since_tizen> 3 </since_tizen>
269 public FlexDirectionType FlexDirection
274 GetProperty(FlexContainer.Property.FLEX_DIRECTION).Get(out temp);
275 return (FlexDirectionType)temp;
279 SetProperty(FlexContainer.Property.FLEX_DIRECTION, new Tizen.NUI.PropertyValue((int)value));
284 /// Whether the flex items should wrap or not if there is no enough room for them on one flex line.
286 /// <since_tizen> 3 </since_tizen>
287 public WrapType FlexWrap
292 GetProperty(FlexContainer.Property.FLEX_WRAP).Get(out temp);
293 return (WrapType)temp;
297 SetProperty(FlexContainer.Property.FLEX_WRAP, new Tizen.NUI.PropertyValue((int)value));
302 /// The alignment of flex items when the items do not use all available space on the main axis.
304 /// <since_tizen> 3 </since_tizen>
305 public Justification JustifyContent
310 GetProperty(FlexContainer.Property.JUSTIFY_CONTENT).Get(out temp);
311 return (Justification)temp;
315 SetProperty(FlexContainer.Property.JUSTIFY_CONTENT, new Tizen.NUI.PropertyValue((int)value));
320 /// The alignment of flex items when the items do not use all available space on the cross axis.
322 /// <since_tizen> 3 </since_tizen>
323 public Alignment AlignItems
328 GetProperty(FlexContainer.Property.ALIGN_ITEMS).Get(out temp);
329 return (Alignment)temp;
333 SetProperty(FlexContainer.Property.ALIGN_ITEMS, new Tizen.NUI.PropertyValue((int)value));
338 /// Similar to "alignItems", but it aligns flex lines; so only works when there are multiple lines.
340 /// <since_tizen> 3 </since_tizen>
341 public Alignment AlignContent
346 GetProperty(FlexContainer.Property.ALIGN_CONTENT).Get(out temp);
347 return (Alignment)temp;
351 SetProperty(FlexContainer.Property.ALIGN_CONTENT, new Tizen.NUI.PropertyValue((int)value));