Class GridLayout

All Implemented Interfaces:
Proxy

@Generated("org.javagi.JavaGI") public class GridLayout extends LayoutManager

Arranges child widgets in rows and columns.

Children have an "attach point" defined by the horizontal and vertical index of the cell they occupy; children can span multiple rows or columns. The layout properties for setting the attach points and spans are set using the GridLayoutChild associated to each child widget.

The behaviour of GtkGridLayout when several children occupy the same grid cell is undefined.

GtkGridLayout can be used like a GtkBoxLayout if all children are attached to the same row or column; however, if you only ever need a single row or column, you should consider using GtkBoxLayout.

  • Constructor Details

    • GridLayout

      public GridLayout(MemorySegment address)
      Create a GridLayout instance for the provided memory address.
      Parameters:
      address - the memory address of the native object
    • GridLayout

      public GridLayout()
      Create a new GridLayout.
  • Method Details

    • getType

      public static @Nullable Type getType()
      Get the GType of the GridLayout class.
      Returns:
      the GType
    • getMemoryLayout

      public static MemoryLayout getMemoryLayout()
      The memory layout of the native struct.
      Returns:
      the memory layout
    • asParent

      protected GridLayout asParent()
      Return this instance as if it were its parent type. Comparable to the Java super keyword, but ensures the parent typeclass is also used in native code.
      Overrides:
      asParent in class LayoutManager
      Returns:
      the instance as if it were its parent type
    • getBaselineRow

      public int getBaselineRow()
      Retrieves the row set with gtk_grid_layout_set_baseline_row().
      Returns:
      the global baseline row
    • getColumnHomogeneous

      public boolean getColumnHomogeneous()
      Checks whether all columns of this GridLayout should have the same width.
      Returns:
      true if the columns are homogeneous, and false otherwise
    • getColumnSpacing

      public int getColumnSpacing()
      Retrieves the spacing set with gtk_grid_layout_set_column_spacing().
      Returns:
      the spacing between consecutive columns
    • getRowBaselinePosition

      public BaselinePosition getRowBaselinePosition(int row)

      Returns the baseline position of row.

      If no value has been set with setRowBaselinePosition(int, BaselinePosition), the default value of BaselinePosition.CENTER is returned.

      Parameters:
      row - a row index
      Returns:
      the baseline position of row
    • getRowHomogeneous

      public boolean getRowHomogeneous()
      Checks whether all rows of this GridLayout should have the same height.
      Returns:
      true if the rows are homogeneous, and false otherwise
    • getRowSpacing

      public int getRowSpacing()
      Retrieves the spacing set with gtk_grid_layout_set_row_spacing().
      Returns:
      the spacing between consecutive rows
    • setBaselineRow

      public void setBaselineRow(int row)

      Sets which row defines the global baseline for the entire grid.

      Each row in the grid can have its own local baseline, but only one of those is global, meaning it will be the baseline in the parent of the grid.

      Parameters:
      row - the row index
    • setColumnHomogeneous

      public void setColumnHomogeneous(boolean homogeneous)
      Sets whether all columns of this GridLayout should have the same width.
      Parameters:
      homogeneous - true to make columns homogeneous
    • setColumnSpacing

      public void setColumnSpacing(int spacing)
      Sets the amount of space to insert between consecutive columns.
      Parameters:
      spacing - the amount of space between columns, in pixels
    • setRowBaselinePosition

      public void setRowBaselinePosition(int row, BaselinePosition pos)
      Sets how the baseline should be positioned on row of the grid, in case that row is assigned more space than is requested.
      Parameters:
      row - a row index
      pos - a GtkBaselinePosition
    • setRowHomogeneous

      public void setRowHomogeneous(boolean homogeneous)
      Sets whether all rows of this GridLayout should have the same height.
      Parameters:
      homogeneous - true to make rows homogeneous
    • setRowSpacing

      public void setRowSpacing(int spacing)
      Sets the amount of space to insert between consecutive rows.
      Parameters:
      spacing - the amount of space between rows, in pixels
    • builder

      public static GridLayout.Builder<? extends GridLayout.Builder> builder()
      A GridLayout.Builder object constructs a GridLayout with the specified properties. Use the various set...() methods to set properties, and finish construction with GridLayout.Builder.build().
      Returns:
      the builder object