/** Copyright (c) 2017 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ using System; namespace Tizen.NUI.BaseComponents { /// /// TableView is a layout container for aligning child actors in a grid like layout.
/// TableView constraints the X and the Y position and the width and the height of the child actors.
/// The Z position and depth are left intact so that the 3D model actors can also be laid out /// in a grid without loosing their depth scaling.
///
public class TableView : View { private global::System.Runtime.InteropServices.HandleRef swigCPtr; internal TableView(global::System.IntPtr cPtr, bool cMemoryOwn) : base(NDalicPINVOKE.TableView_SWIGUpcast(cPtr), cMemoryOwn) { swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr); } internal static global::System.Runtime.InteropServices.HandleRef getCPtr(TableView obj) { return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr; } protected override void Dispose(DisposeTypes type) { if(disposed) { return; } if(type == DisposeTypes.Explicit) { //Called by User //Release your own managed resources here. //You should release all of your own disposable objects here. } //Release your own unmanaged resources here. //You should not access any managed member here except static instance. //because the execution order of Finalizes is non-deterministic. if (swigCPtr.Handle != global::System.IntPtr.Zero) { if (swigCMemOwn) { swigCMemOwn = false; NDalicPINVOKE.delete_TableView(swigCPtr); } swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero); } base.Dispose(type); } internal new class Property { internal static readonly int ROWS = NDalicPINVOKE.TableView_Property_ROWS_get(); internal static readonly int COLUMNS = NDalicPINVOKE.TableView_Property_COLUMNS_get(); internal static readonly int CELL_PADDING = NDalicPINVOKE.TableView_Property_CELL_PADDING_get(); internal static readonly int LAYOUT_ROWS = NDalicPINVOKE.TableView_Property_LAYOUT_ROWS_get(); internal static readonly int LAYOUT_COLUMNS = NDalicPINVOKE.TableView_Property_LAYOUT_COLUMNS_get(); } internal class ChildProperty { internal static readonly int CELL_INDEX = NDalicPINVOKE.TableView_ChildProperty_CELL_INDEX_get(); internal static readonly int ROW_SPAN = NDalicPINVOKE.TableView_ChildProperty_ROW_SPAN_get(); internal static readonly int COLUMN_SPAN = NDalicPINVOKE.TableView_ChildProperty_COLUMN_SPAN_get(); internal static readonly int CELL_HORIZONTAL_ALIGNMENT = NDalicPINVOKE.TableView_ChildProperty_CELL_HORIZONTAL_ALIGNMENT_get(); internal static readonly int CELL_VERTICAL_ALIGNMENT = NDalicPINVOKE.TableView_ChildProperty_CELL_VERTICAL_ALIGNMENT_get(); } /// /// Class to specify the layout position for the child view. /// public class CellPosition : global::System.IDisposable { private global::System.Runtime.InteropServices.HandleRef swigCPtr; protected bool swigCMemOwn; internal CellPosition(global::System.IntPtr cPtr, bool cMemoryOwn) { swigCMemOwn = cMemoryOwn; swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr); } internal static global::System.Runtime.InteropServices.HandleRef getCPtr(CellPosition obj) { return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr; } //A Flag to check who called Dispose(). (By User or DisposeQueue) private bool isDisposeQueued = false; //A Flat to check if it is already disposed. protected bool disposed = false; ~CellPosition() { if(!isDisposeQueued) { isDisposeQueued = true; DisposeQueue.Instance.Add(this); } } public void Dispose() { //Throw excpetion if Dispose() is called in separate thread. if (!Window.IsInstalled()) { throw new System.InvalidOperationException("This API called from separate thread. This API must be called from MainThread."); } if (isDisposeQueued) { Dispose(DisposeTypes.Implicit); } else { Dispose(DisposeTypes.Explicit); System.GC.SuppressFinalize(this); } } protected virtual void Dispose(DisposeTypes type) { if (disposed) { return; } if(type == DisposeTypes.Explicit) { //Called by User //Release your own managed resources here. //You should release all of your own disposable objects here. } //Release your own unmanaged resources here. //You should not access any managed member here except static instance. //because the execution order of Finalizes is non-deterministic. if (swigCPtr.Handle != global::System.IntPtr.Zero) { if (swigCMemOwn) { swigCMemOwn = false; NDalicPINVOKE.delete_TableView_CellPosition(swigCPtr); } swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero); } disposed = true; } /// /// The constructor. /// /// The row index initialized. /// The column index initialized. /// The row span initialized. /// The column span initialized. public CellPosition(uint rowIndex, uint columnIndex, uint rowSpan, uint columnSpan) : this(NDalicPINVOKE.new_TableView_CellPosition__SWIG_0(rowIndex, columnIndex, rowSpan, columnSpan), true) { if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); } /// /// The constructor to initialize values to defaults for convenience. /// /// The row index initialized. /// The column index initialized. /// The row span initialized. public CellPosition(uint rowIndex, uint columnIndex, uint rowSpan) : this(NDalicPINVOKE.new_TableView_CellPosition__SWIG_1(rowIndex, columnIndex, rowSpan), true) { if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); } /// /// The constructor to initialize values to defaults for convenience. /// /// The row index initialized. /// The column index initialized. public CellPosition(uint rowIndex, uint columnIndex) : this(NDalicPINVOKE.new_TableView_CellPosition__SWIG_2(rowIndex, columnIndex), true) { if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); } /// /// The constructor to initialize values to default for convenience. /// /// The row index initialized. public CellPosition(uint rowIndex) : this(NDalicPINVOKE.new_TableView_CellPosition__SWIG_3(rowIndex), true) { if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); } /// /// The default constructor. /// public CellPosition() : this(NDalicPINVOKE.new_TableView_CellPosition__SWIG_4(), true) { if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); } /// /// The index of a row. /// public uint rowIndex { set { NDalicPINVOKE.TableView_CellPosition_rowIndex_set(swigCPtr, value); if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); } get { uint ret = NDalicPINVOKE.TableView_CellPosition_rowIndex_get(swigCPtr); if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); return ret; } } /// /// The index of a column. /// public uint columnIndex { set { NDalicPINVOKE.TableView_CellPosition_columnIndex_set(swigCPtr, value); if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); } get { uint ret = NDalicPINVOKE.TableView_CellPosition_columnIndex_get(swigCPtr); if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); return ret; } } /// /// The span of a row. /// public uint rowSpan { set { NDalicPINVOKE.TableView_CellPosition_rowSpan_set(swigCPtr, value); if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); } get { uint ret = NDalicPINVOKE.TableView_CellPosition_rowSpan_get(swigCPtr); if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); return ret; } } /// /// The span of a column. /// public uint columnSpan { set { NDalicPINVOKE.TableView_CellPosition_columnSpan_set(swigCPtr, value); if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); } get { uint ret = NDalicPINVOKE.TableView_CellPosition_columnSpan_get(swigCPtr); if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); return ret; } } } /// /// Creates the TableView view. /// /// Initial rows for the table. /// Initial columns for the table. public TableView(uint initialRows, uint initialColumns) : this(NDalicPINVOKE.TableView_New(initialRows, initialColumns), true) { if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); } /// /// The Copy constructor. Creates another handle that points to the same real object. /// /// Handle to copy from. public TableView(TableView handle) : this(NDalicPINVOKE.new_TableView__SWIG_1(TableView.getCPtr(handle)), true) { if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); } [Obsolete("Please do not use! this will be deprecated")] public new static TableView DownCast(BaseHandle handle) { TableView ret = Registry.GetManagedBaseHandleFromNativePtr(handle) as TableView; if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); return ret; } /// /// Adds a child to the table.
/// If the row or column index is outside the table, the table gets resized bigger.
///
/// The child to add. /// The position for the child. /// True if the addition succeeded, and false if the cell is already occupied. public bool AddChild(View child, TableView.CellPosition position) { bool ret = NDalicPINVOKE.TableView_AddChild(swigCPtr, View.getCPtr(child), TableView.CellPosition.getCPtr(position)); if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); return ret; } /// /// Returns a child from the given layout position. /// /// The position in the table. /// Child that was in the cell or an uninitialized handle. public View GetChildAt(TableView.CellPosition position) { IntPtr cPtr = NDalicPINVOKE.TableView_GetChildAt(swigCPtr, TableView.CellPosition.getCPtr(position)); View ret = Registry.GetManagedBaseHandleFromNativePtr(cPtr) as View; if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); return ret; } /// /// Removes a child from the given layout position. /// /// The position for the child to remove. /// Child that was removed or an uninitialized handle. public View RemoveChildAt(TableView.CellPosition position) { IntPtr cPtr = NDalicPINVOKE.TableView_RemoveChildAt(swigCPtr, TableView.CellPosition.getCPtr(position)); View ret = Registry.GetManagedBaseHandleFromNativePtr(cPtr) as View; if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); return ret; } /// /// Finds the child's layout position. /// /// The child to search for. /// The position for the child. /// True if the child was included in this TableView. public bool FindChildPosition(View child, TableView.CellPosition position) { bool ret = NDalicPINVOKE.TableView_FindChildPosition(swigCPtr, View.getCPtr(child), TableView.CellPosition.getCPtr(position)); if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); return ret; } /// /// Inserts a new row to the given index. /// /// The rowIndex of the new row. public void InsertRow(uint rowIndex) { NDalicPINVOKE.TableView_InsertRow(swigCPtr, rowIndex); if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); } /// /// Deletes a row from the given index.
/// Removed elements are deleted.
///
/// The rowIndex of the row to delete. public void DeleteRow(uint rowIndex) { NDalicPINVOKE.TableView_DeleteRow__SWIG_0(swigCPtr, rowIndex); if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); } /// /// Inserts a new column to the given index. /// /// The columnIndex of the new column. public void InsertColumn(uint columnIndex) { NDalicPINVOKE.TableView_InsertColumn(swigCPtr, columnIndex); if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); } /// /// Deletes a column from the given index.
/// Removed elements are deleted.
///
/// The columnIndex of the column to delete. public void DeleteColumn(uint columnIndex) { NDalicPINVOKE.TableView_DeleteColumn__SWIG_0(swigCPtr, columnIndex); if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); } /// /// Resizes the TableView. /// /// The rows for the table. /// The columns for the table. public void Resize(uint rows, uint columns) { NDalicPINVOKE.TableView_Resize__SWIG_0(swigCPtr, rows, columns); if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); } /// /// Sets the horizontal and the vertical padding between cells. /// /// Width and height. public void SetCellPadding(Size2D padding) { NDalicPINVOKE.TableView_SetCellPadding(swigCPtr, Size2D.getCPtr(padding)); if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); } /// /// Gets the current padding as width and height. /// /// The current padding as width and height. public Vector2 GetCellPadding() { Vector2 ret = new Vector2(NDalicPINVOKE.TableView_GetCellPadding(swigCPtr), true); if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); return ret; } /// /// Specifies this row as fitting its height to its children. /// /// The row to set. public void SetFitHeight(uint rowIndex) { NDalicPINVOKE.TableView_SetFitHeight(swigCPtr, rowIndex); if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); } /// /// Checks if the row is a fit row. /// /// The row to check. /// True if the row is fit. public bool IsFitHeight(uint rowIndex) { bool ret = NDalicPINVOKE.TableView_IsFitHeight(swigCPtr, rowIndex); if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); return ret; } /// /// Specifies this column as fitting its width to its children. /// /// The column to set. public void SetFitWidth(uint columnIndex) { NDalicPINVOKE.TableView_SetFitWidth(swigCPtr, columnIndex); if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); } /// /// Checks if the column is a fit column. /// /// The column to check. /// True if the column is fit. public bool IsFitWidth(uint columnIndex) { bool ret = NDalicPINVOKE.TableView_IsFitWidth(swigCPtr, columnIndex); if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); return ret; } /// /// Sets a row to have a fixed height.
/// Setting a fixed height of 0 has no effect.
///
/// The rowIndex for row with a fixed height. /// The height in world coordinate units. public void SetFixedHeight(uint rowIndex, float height) { NDalicPINVOKE.TableView_SetFixedHeight(swigCPtr, rowIndex, height); if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); } /// /// Gets a row's fixed height. /// /// The row index with a fixed height. /// height The height in world coordinate units. public float GetFixedHeight(uint rowIndex) { float ret = NDalicPINVOKE.TableView_GetFixedHeight(swigCPtr, rowIndex); if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); return ret; } /// /// Sets a row to have a relative height. Relative height means percentage of /// the remainder of the table height after subtracting padding and fixed height rows.
/// Setting a relative height of 0 has no effect.
///
/// The rowIndex for row with a relative height. /// The height percentage between 0.0f and 1.0f. public void SetRelativeHeight(uint rowIndex, float heightPercentage) { NDalicPINVOKE.TableView_SetRelativeHeight(swigCPtr, rowIndex, heightPercentage); if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); } /// /// Gets a row's relative height. /// /// The row index with a relative height. /// Height in percentage units, between 0.0f and 1.0f. public float GetRelativeHeight(uint rowIndex) { float ret = NDalicPINVOKE.TableView_GetRelativeHeight(swigCPtr, rowIndex); if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); return ret; } /// /// Sets a column to have a fixed width.
/// Setting a fixed width of 0 has no effect.
///
/// The columnIndex for column with a fixed width. /// The width in world coordinate units. public void SetFixedWidth(uint columnIndex, float width) { NDalicPINVOKE.TableView_SetFixedWidth(swigCPtr, columnIndex, width); if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); } /// /// Gets a column's fixed width. /// /// The column index with a fixed width. /// Width in world coordinate units. public float GetFixedWidth(uint columnIndex) { float ret = NDalicPINVOKE.TableView_GetFixedWidth(swigCPtr, columnIndex); if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); return ret; } /// /// Sets a column to have a relative width. Relative width means percentage of /// the remainder of the table width after subtracting padding and fixed width columns.
/// Setting a relative width of 0 has no effect.
///
/// The columnIndex for column with a fixed width. /// The widthPercentage between 0.0f and 1.0f. public void SetRelativeWidth(uint columnIndex, float widthPercentage) { NDalicPINVOKE.TableView_SetRelativeWidth(swigCPtr, columnIndex, widthPercentage); if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); } /// /// Gets a column's relative width. /// /// The column index with a relative width. /// Width in percentage units, between 0.0f and 1.0f. public float GetRelativeWidth(uint columnIndex) { float ret = NDalicPINVOKE.TableView_GetRelativeWidth(swigCPtr, columnIndex); if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); return ret; } /// /// Sets the alignment on a cell.
/// Cells without calling this function have the default values of left and top respectively.
///
/// The cell to set alignment on. /// The horizontal alignment. /// The vertical alignment. public void SetCellAlignment(TableView.CellPosition position, HorizontalAlignmentType horizontal, VerticalAlignmentType vertical) { NDalicPINVOKE.TableView_SetCellAlignment(swigCPtr, TableView.CellPosition.getCPtr(position), (int)horizontal, (int)vertical); if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); } /// /// Enumeration for describing how the size of a row or column has been set. /// public enum LayoutPolicy { Fixed, Relative, Fill, Fit } /// /// The amount of rows in the table. /// public int Rows { get { int temp = 0; GetProperty(TableView.Property.ROWS).Get(out temp); return temp; } set { SetProperty(TableView.Property.ROWS, new Tizen.NUI.PropertyValue(value)); } } /// /// The amount of columns in the table. /// public int Columns { get { int temp = 0; GetProperty(TableView.Property.COLUMNS).Get(out temp); return temp; } set { SetProperty(TableView.Property.COLUMNS, new Tizen.NUI.PropertyValue(value)); } } /// /// Padding between cells. /// public Vector2 CellPadding { get { Vector2 temp = new Vector2(0.0f, 0.0f); GetProperty(TableView.Property.CELL_PADDING).Get(temp); return temp; } set { SetProperty(TableView.Property.CELL_PADDING, new Tizen.NUI.PropertyValue(value)); } } /// /// The number of layout rows. /// public PropertyMap LayoutRows { get { PropertyMap temp = new PropertyMap(); GetProperty(TableView.Property.LAYOUT_ROWS).Get(temp); return temp; } set { SetProperty(TableView.Property.LAYOUT_ROWS, new Tizen.NUI.PropertyValue(value)); } } /// /// The number of layout columns. /// public PropertyMap LayoutColumns { get { PropertyMap temp = new PropertyMap(); GetProperty(TableView.Property.LAYOUT_COLUMNS).Get(temp); return temp; } set { SetProperty(TableView.Property.LAYOUT_COLUMNS, new Tizen.NUI.PropertyValue(value)); } } } }