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 using System.ComponentModel;
19 using System.Diagnostics.CodeAnalysis;
20 using Tizen.NUI.Binding;
22 namespace Tizen.NUI.BaseComponents
25 /// FlexContainer implements a subset of the flexbox spec (defined by W3C):https://www.w3.org/TR/css3-flexbox/<br />
26 /// 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 />
27 /// 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 />
28 /// FlexContainer can expand items to fill available free space, or shrink them to prevent overflow.<br />
30 /// <since_tizen> 3 </since_tizen>
31 [Obsolete("This has been deprecated in API8 and will be removed in API10. Use FlexLayout instead.")]
32 public class FlexContainer : View
34 /// <summary> Property of ContentDirection </summary>
35 [EditorBrowsable(EditorBrowsableState.Never)]
36 public static BindableProperty ContentDirectionProperty = null;
37 internal static void SetInternalContentDirectionProperty(BindableObject bindable, object oldValue, object newValue)
39 var flexContainer = (FlexContainer)bindable;
42 Tizen.NUI.Object.SetProperty((System.Runtime.InteropServices.HandleRef)flexContainer.SwigCPtr, FlexContainer.Property.ContentDirection, new Tizen.NUI.PropertyValue((int)newValue));
45 internal static object GetInternalContentDirectionProperty(BindableObject bindable)
47 var flexContainer = (FlexContainer)bindable;
49 Tizen.NUI.Object.GetProperty((System.Runtime.InteropServices.HandleRef)flexContainer.SwigCPtr, FlexContainer.Property.ContentDirection).Get(out temp);
50 return (ContentDirectionType)temp;
53 /// <summary> Property of FlexDirection </summary>
54 [EditorBrowsable(EditorBrowsableState.Never)]
55 public static BindableProperty FlexDirectionProperty = null;
56 internal static void SetInternalFlexDirectionProperty(BindableObject bindable, object oldValue, object newValue)
58 var flexContainer = (FlexContainer)bindable;
61 Tizen.NUI.Object.SetProperty((System.Runtime.InteropServices.HandleRef)flexContainer.SwigCPtr, FlexContainer.Property.FlexDirection, new Tizen.NUI.PropertyValue((int)newValue));
64 internal static object GetInternalFlexDirectionProperty(BindableObject bindable)
66 var flexContainer = (FlexContainer)bindable;
68 Tizen.NUI.Object.GetProperty((System.Runtime.InteropServices.HandleRef)flexContainer.SwigCPtr, FlexContainer.Property.FlexDirection).Get(out temp);
69 return (FlexDirectionType)temp;
72 /// <summary> Property of FlexWrap </summary>
73 [EditorBrowsable(EditorBrowsableState.Never)]
74 public static BindableProperty FlexWrapProperty = null;
75 internal static void SetInternalFlexWrapProperty(BindableObject bindable, object oldValue, object newValue)
77 var flexContainer = (FlexContainer)bindable;
80 Tizen.NUI.Object.SetProperty((System.Runtime.InteropServices.HandleRef)flexContainer.SwigCPtr, FlexContainer.Property.FlexWrap, new Tizen.NUI.PropertyValue((int)newValue));
83 internal static object GetInternalFlexWrapProperty(BindableObject bindable)
85 var flexContainer = (FlexContainer)bindable;
87 Tizen.NUI.Object.GetProperty((System.Runtime.InteropServices.HandleRef)flexContainer.SwigCPtr, FlexContainer.Property.FlexWrap).Get(out temp);
88 return (WrapType)temp;
91 /// <summary> Property of JustifyContent </summary>
92 [EditorBrowsable(EditorBrowsableState.Never)]
93 public static BindableProperty JustifyContentProperty = null;
94 internal static void SetInternalJustifyContentProperty(BindableObject bindable, object oldValue, object newValue)
96 var flexContainer = (FlexContainer)bindable;
99 Tizen.NUI.Object.SetProperty((System.Runtime.InteropServices.HandleRef)flexContainer.SwigCPtr, FlexContainer.Property.JustifyContent, new Tizen.NUI.PropertyValue((int)newValue));
102 internal static object GetInternalJustifyContentProperty(BindableObject bindable)
104 var flexContainer = (FlexContainer)bindable;
106 Tizen.NUI.Object.GetProperty((System.Runtime.InteropServices.HandleRef)flexContainer.SwigCPtr, FlexContainer.Property.JustifyContent).Get(out temp);
107 return (Justification)temp;
110 /// <summary> Property of AlignItems </summary>
111 [EditorBrowsable(EditorBrowsableState.Never)]
112 public static BindableProperty AlignItemsProperty = null;
113 internal static void SetInternalAlignItemsProperty(BindableObject bindable, object oldValue, object newValue)
115 var flexContainer = (FlexContainer)bindable;
116 if (newValue != null)
118 Tizen.NUI.Object.SetProperty((System.Runtime.InteropServices.HandleRef)flexContainer.SwigCPtr, FlexContainer.Property.AlignItems, new Tizen.NUI.PropertyValue((int)newValue));
121 internal static object GetInternalAlignItemsProperty(BindableObject bindable)
123 var flexContainer = (FlexContainer)bindable;
125 Tizen.NUI.Object.GetProperty((System.Runtime.InteropServices.HandleRef)flexContainer.SwigCPtr, FlexContainer.Property.AlignItems).Get(out temp);
126 return (Alignment)temp;
129 /// <summary> Property of AlignContent </summary>
130 [EditorBrowsable(EditorBrowsableState.Never)]
131 public static BindableProperty AlignContentProperty = null;
132 internal static void SetInternalAlignContentProperty(BindableObject bindable, object oldValue, object newValue)
134 var flexContainer = (FlexContainer)bindable;
135 if (newValue != null)
137 Tizen.NUI.Object.SetProperty((System.Runtime.InteropServices.HandleRef)flexContainer.SwigCPtr, FlexContainer.Property.AlignContent, new Tizen.NUI.PropertyValue((int)newValue));
140 internal static object GetInternalAlignContentProperty(BindableObject bindable)
142 var flexContainer = (FlexContainer)bindable;
144 Tizen.NUI.Object.GetProperty((System.Runtime.InteropServices.HandleRef)flexContainer.SwigCPtr, FlexContainer.Property.AlignContent).Get(out temp);
145 return (Alignment)temp;
148 static FlexContainer()
150 if (NUIApplication.IsUsingXaml)
152 ContentDirectionProperty = BindableProperty.Create(nameof(ContentDirection), typeof(ContentDirectionType), typeof(FlexContainer), ContentDirectionType.Inherit,
153 propertyChanged: SetInternalContentDirectionProperty, defaultValueCreator: GetInternalContentDirectionProperty);
155 FlexDirectionProperty = BindableProperty.Create(nameof(FlexDirection), typeof(FlexDirectionType), typeof(FlexContainer), FlexDirectionType.Column,
156 propertyChanged: SetInternalFlexDirectionProperty, defaultValueCreator: GetInternalFlexDirectionProperty);
158 FlexWrapProperty = BindableProperty.Create(nameof(FlexWrap), typeof(WrapType), typeof(FlexContainer), WrapType.NoWrap,
159 propertyChanged: SetInternalFlexWrapProperty, defaultValueCreator: GetInternalFlexWrapProperty);
161 JustifyContentProperty = BindableProperty.Create(nameof(JustifyContent), typeof(Justification), typeof(FlexContainer), Justification.JustifyFlexStart,
162 propertyChanged: SetInternalJustifyContentProperty, defaultValueCreator: GetInternalJustifyContentProperty);
164 AlignItemsProperty = BindableProperty.Create(nameof(AlignItems), typeof(Alignment), typeof(FlexContainer), Alignment.AlignAuto,
165 propertyChanged: SetInternalAlignItemsProperty, defaultValueCreator: GetInternalAlignItemsProperty);
167 AlignContentProperty = BindableProperty.Create(nameof(AlignContent), typeof(Alignment), typeof(FlexContainer), Alignment.AlignAuto,
168 propertyChanged: SetInternalAlignContentProperty, defaultValueCreator: GetInternalAlignContentProperty);
174 /// Creates a FlexContainer handle.
175 /// Calling member functions with an uninitialized handle is not allowed.
177 /// <since_tizen> 3 </since_tizen>
178 [Obsolete("This has been deprecated in API8 and will be removed in API10. Use FlexLayout instead.")]
179 public FlexContainer() : this(Interop.FlexContainer.New(), true)
181 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
184 internal FlexContainer(global::System.IntPtr cPtr, bool cMemoryOwn) : base(cPtr, cMemoryOwn)
189 /// Enumeration for the direction of the main axis in the flex container. This determines
190 /// the direction that flex items are laid out in the flex container.
192 /// <since_tizen> 3 </since_tizen>
193 [Obsolete("This has been deprecated in API8 and will be removed in API10. Use FlexLayout instead.")]
194 public enum FlexDirectionType
197 /// The flexible items are displayed vertically as a column.
199 /// <since_tizen> 3 </since_tizen>
200 [Obsolete("This has been deprecated in API8 and will be removed in API10. Use FlexLayout instead.")]
203 /// The flexible items are displayed vertically as a column, but in reverse order.
205 /// <since_tizen> 3 </since_tizen>
206 [Obsolete("This has been deprecated in API8 and will be removed in API10. Use FlexLayout instead.")]
209 /// The flexible items are displayed horizontally as a row.
211 /// <since_tizen> 3 </since_tizen>
212 [Obsolete("This has been deprecated in API8 and will be removed in API10. Use FlexLayout instead.")]
215 /// The flexible items are displayed horizontally as a row.
217 /// <since_tizen> 3 </since_tizen>
218 [Obsolete("This has been deprecated in API8 and will be removed in API10. Use FlexLayout instead.")]
223 /// Enumeration for the primary direction in which content is ordered in the flex container
224 /// and on which sides the ?�start??and ?�end??are.
226 /// <since_tizen> 3 </since_tizen>
227 [Obsolete("This has been deprecated in API8 and will be removed in API10. Use FlexLayout instead.")]
228 public enum ContentDirectionType
231 /// Inherits the same direction from the parent.
233 /// <since_tizen> 3 </since_tizen>
234 [Obsolete("This has been deprecated in API8 and will be removed in API10. Use FlexLayout instead.")]
237 /// From left to right.
239 /// <since_tizen> 3 </since_tizen>
240 [Obsolete("This has been deprecated in API8 and will be removed in API10. Use FlexLayout instead.")]
243 /// From right to left.
245 /// <since_tizen> 3 </since_tizen>
246 [Obsolete("This has been deprecated in API8 and will be removed in API10. Use FlexLayout instead.")]
251 /// Enumeration for the alignment of the flex items when the items do not use all available
252 /// space on the main axis.
254 /// <since_tizen> 3 </since_tizen>
255 [Obsolete("This has been deprecated in API8 and will be removed in API10. Use FlexLayout instead.")]
256 public enum Justification
259 /// Items are positioned at the beginning of the container.
261 /// <since_tizen> 3 </since_tizen>
262 [Obsolete("This has been deprecated in API8 and will be removed in API10. Use FlexLayout instead.")]
265 /// Items are positioned at the center of the container.
267 /// <since_tizen> 3 </since_tizen>
268 [Obsolete("This has been deprecated in API8 and will be removed in API10. Use FlexLayout instead.")]
271 /// Items are positioned at the end of the container.
273 /// <since_tizen> 3 </since_tizen>
274 [Obsolete("This has been deprecated in API8 and will be removed in API10. Use FlexLayout instead.")]
277 /// Items are positioned with equal space between the lines.
279 /// <since_tizen> 3 </since_tizen>
280 [Obsolete("This has been deprecated in API8 and will be removed in API10. Use FlexLayout instead.")]
283 /// Items are positioned with equal space before, between, and after the lines.
285 /// <since_tizen> 3 </since_tizen>
286 [Obsolete("This has been deprecated in API8 and will be removed in API10. Use FlexLayout instead.")]
291 /// Enumeration for the alignment of the flex items or lines when the items or lines do not
292 /// use all the available space on the cross axis.
294 /// <since_tizen> 3 </since_tizen>
295 [Obsolete("This has been deprecated in API8 and will be removed in API10. Use FlexLayout instead.")]
296 public enum Alignment
299 /// Inherits the same alignment from the parent (only valid for "alignSelf" property).
301 /// <since_tizen> 3 </since_tizen>
302 [Obsolete("This has been deprecated in API8 and will be removed in API10. Use FlexLayout instead.")]
305 /// At the beginning of the container.
307 /// <since_tizen> 3 </since_tizen>
308 [Obsolete("This has been deprecated in API8 and will be removed in API10. Use FlexLayout instead.")]
311 /// At the center of the container.
313 /// <since_tizen> 3 </since_tizen>
314 [Obsolete("This has been deprecated in API8 and will be removed in API10. Use FlexLayout instead.")]
317 /// At the end of the container.
319 /// <since_tizen> 3 </since_tizen>
320 [Obsolete("This has been deprecated in API8 and will be removed in API10. Use FlexLayout instead.")]
323 /// Stretch to fit the container.
325 /// <since_tizen> 3 </since_tizen>
326 [Obsolete("This has been deprecated in API8 and will be removed in API10. Use FlexLayout instead.")]
331 /// Enumeration for the wrap type of the flex container when there is no enough room for
332 /// all the items on one flex line.
334 /// <since_tizen> 3 </since_tizen>
335 [Obsolete("This has been deprecated in API8 and will be removed in API10. Use FlexLayout instead.")]
339 /// Flex items laid out in single line (shrunk to fit the flex container along the main axis).
341 /// <since_tizen> 3 </since_tizen>
342 [Obsolete("This has been deprecated in API8 and will be removed in API10. Use FlexLayout instead.")]
345 /// Flex items laid out in multiple lines if needed.
347 /// <since_tizen> 3 </since_tizen>
348 [Obsolete("This has been deprecated in API8 and will be removed in API10. Use FlexLayout instead.")]
353 /// The primary direction in which content is ordered.
355 /// <since_tizen> 3 </since_tizen>
356 [Obsolete("This has been deprecated in API8 and will be removed in API10. Use FlexLayout instead.")]
357 public ContentDirectionType ContentDirection
361 if (NUIApplication.IsUsingXaml)
363 return (ContentDirectionType)GetValue(ContentDirectionProperty);
367 return (ContentDirectionType)GetInternalContentDirectionProperty(this);
372 if (NUIApplication.IsUsingXaml)
374 SetValue(ContentDirectionProperty, value);
378 SetInternalContentDirectionProperty(this, null, value);
380 NotifyPropertyChanged();
385 /// The direction of the main axis which determines the direction that flex items are laid out.
387 /// <since_tizen> 3 </since_tizen>
388 [Obsolete("This has been deprecated in API8 and will be removed in API10. Use FlexLayout instead.")]
389 public FlexDirectionType FlexDirection
393 if (NUIApplication.IsUsingXaml)
395 return (FlexDirectionType)GetValue(FlexDirectionProperty);
399 return (FlexDirectionType)GetInternalFlexDirectionProperty(this);
404 if (NUIApplication.IsUsingXaml)
406 SetValue(FlexDirectionProperty, value);
410 SetInternalFlexDirectionProperty(this, null, value);
412 NotifyPropertyChanged();
417 /// Whether the flex items should wrap or not if there is no enough room for them on one flex line.
419 /// <since_tizen> 3 </since_tizen>
420 [Obsolete("This has been deprecated in API8 and will be removed in API10. Use FlexLayout instead.")]
421 public WrapType FlexWrap
425 if (NUIApplication.IsUsingXaml)
427 return (WrapType)GetValue(FlexWrapProperty);
431 return (WrapType)GetInternalFlexWrapProperty(this);
436 if (NUIApplication.IsUsingXaml)
438 SetValue(FlexWrapProperty, value);
442 SetInternalFlexWrapProperty(this, null, value);
444 NotifyPropertyChanged();
449 /// The alignment of flex items when the items do not use all available space on the main axis.
451 /// <since_tizen> 3 </since_tizen>
452 [Obsolete("This has been deprecated in API8 and will be removed in API10. Use FlexLayout instead.")]
453 public Justification JustifyContent
457 if (NUIApplication.IsUsingXaml)
459 return (Justification)GetValue(JustifyContentProperty);
463 return (Justification)GetInternalJustifyContentProperty(this);
468 if (NUIApplication.IsUsingXaml)
470 SetValue(JustifyContentProperty, value);
474 SetInternalJustifyContentProperty(this, null, value);
476 NotifyPropertyChanged();
481 /// The alignment of flex items when the items do not use all available space on the cross axis.
483 /// <since_tizen> 3 </since_tizen>
484 [Obsolete("This has been deprecated in API8 and will be removed in API10. Use FlexLayout instead.")]
485 public Alignment AlignItems
489 if (NUIApplication.IsUsingXaml)
491 return (Alignment)GetValue(AlignItemsProperty);
495 return (Alignment)GetInternalAlignItemsProperty(this);
500 if (NUIApplication.IsUsingXaml)
502 SetValue(AlignItemsProperty, value);
506 SetInternalAlignItemsProperty(this, null, value);
508 NotifyPropertyChanged();
513 /// Similar to "alignItems", but it aligns flex lines; so only works when there are multiple lines.
515 /// <since_tizen> 3 </since_tizen>
516 [Obsolete("This has been deprecated in API8 and will be removed in API10. Use FlexLayout instead.")]
517 public Alignment AlignContent
521 if (NUIApplication.IsUsingXaml)
523 return (Alignment)GetValue(AlignContentProperty);
527 return (Alignment)GetInternalAlignContentProperty(this);
532 if (NUIApplication.IsUsingXaml)
534 SetValue(AlignContentProperty, value);
538 SetInternalAlignContentProperty(this, null, value);
540 NotifyPropertyChanged();
545 [EditorBrowsable(EditorBrowsableState.Never)]
546 protected override void ReleaseSwigCPtr(System.Runtime.InteropServices.HandleRef swigCPtr)
548 Interop.FlexContainer.DeleteFlexContainer(swigCPtr);
552 /// Enumeration for the instance of child properties belonging to the FlexContainer class.
554 internal class ChildProperty
556 internal static readonly int FLEX = Interop.FlexContainer.ChildPropertyFlexGet();
557 internal static readonly int AlignSelf = Interop.FlexContainer.ChildPropertyAlignSelfGet();
558 internal static readonly int FlexMargin = Interop.FlexContainer.ChildPropertyFlexMarginGet();
561 internal new class Property
563 internal static readonly int ContentDirection = Interop.FlexContainer.ContentDirectionGet();
564 internal static readonly int FlexDirection = Interop.FlexContainer.FlexDirectionGet();
565 internal static readonly int FlexWrap = Interop.FlexContainer.FlexWrapGet();
566 internal static readonly int JustifyContent = Interop.FlexContainer.JustifyContentGet();
567 internal static readonly int AlignItems = Interop.FlexContainer.AlignItemsGet();
568 internal static readonly int AlignContent = Interop.FlexContainer.AlignContentGet();