gi-gtk-4.0.8: Gtk bindings
CopyrightWill Thompson and Iñaki García Etxebarria
LicenseLGPL-2.1
MaintainerIñaki García Etxebarria
Safe HaskellSafe-Inferred
LanguageHaskell2010

GI.Gtk.Objects.Grid

Description

GtkGrid is a container which arranges its child widgets in rows and columns.

It supports arbitrary positions and horizontal/vertical spans.

Children are added using gridAttach. They can span multiple rows or columns. It is also possible to add a child next to an existing child, using gridAttachNextTo. To remove a child from the grid, use gridRemove.

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

GtkGrid as GtkBuildable

Every child in a GtkGrid has access to a custom Buildable element, called <layout>. It can by used to specify a position in the grid and optionally spans. All properties that can be used in the <layout> element are implemented by GridLayoutChild.

It is implemented by GtkWidget using LayoutManager.

To showcase it, here is a simple example:

xml code

<object class="GtkGrid" id="my_grid">
  <child>
    <object class="GtkButton" id="button1">
      <property name="label">Button 1</property>
      <layout>
        <property name="column">0</property>
        <property name="row">0</property>
      </layout>
    </object>
  </child>
  <child>
    <object class="GtkButton" id="button2">
      <property name="label">Button 2</property>
      <layout>
        <property name="column">1</property>
        <property name="row">0</property>
      </layout>
    </object>
  </child>
  <child>
    <object class="GtkButton" id="button3">
      <property name="label">Button 3</property>
      <layout>
        <property name="column">2</property>
        <property name="row">0</property>
        <property name="row-span">2</property>
      </layout>
    </object>
  </child>
  <child>
    <object class="GtkButton" id="button4">
      <property name="label">Button 4</property>
      <layout>
        <property name="column">0</property>
        <property name="row">1</property>
        <property name="column-span">2</property>
      </layout>
    </object>
  </child>
</object>

It organizes the first two buttons side-by-side in one cell each. The third button is in the last column but spans across two rows. This is defined by the row-span property. The last button is located in the second row and spans across two columns, which is defined by the column-span property.

CSS nodes

GtkGrid uses a single CSS node with name grid.

Accessibility

GtkGrid uses the AccessibleRoleGroup role.

Synopsis

Exported types

newtype Grid Source #

Memory-managed wrapper type.

Constructors

Grid (ManagedPtr Grid) 

Instances

Instances details
Eq Grid Source # 
Instance details

Defined in GI.Gtk.Objects.Grid

Methods

(==) :: Grid -> Grid -> Bool #

(/=) :: Grid -> Grid -> Bool #

GObject Grid Source # 
Instance details

Defined in GI.Gtk.Objects.Grid

ManagedPtrNewtype Grid Source # 
Instance details

Defined in GI.Gtk.Objects.Grid

Methods

toManagedPtr :: Grid -> ManagedPtr Grid

TypedObject Grid Source # 
Instance details

Defined in GI.Gtk.Objects.Grid

Methods

glibType :: IO GType

HasParentTypes Grid Source # 
Instance details

Defined in GI.Gtk.Objects.Grid

IsGValue (Maybe Grid) Source #

Convert Grid to and from GValue. See toGValue and fromGValue.

Instance details

Defined in GI.Gtk.Objects.Grid

Methods

gvalueGType_ :: IO GType

gvalueSet_ :: Ptr GValue -> Maybe Grid -> IO ()

gvalueGet_ :: Ptr GValue -> IO (Maybe Grid)

type ParentTypes Grid Source # 
Instance details

Defined in GI.Gtk.Objects.Grid

type ParentTypes Grid = '[Widget, Object, Accessible, Buildable, ConstraintTarget, Orientable]

class (GObject o, IsDescendantOf Grid o) => IsGrid o Source #

Type class for types which can be safely cast to Grid, for instance with toGrid.

Instances

Instances details
(GObject o, IsDescendantOf Grid o) => IsGrid o Source # 
Instance details

Defined in GI.Gtk.Objects.Grid

toGrid :: (MonadIO m, IsGrid o) => o -> m Grid Source #

Cast to Grid, for types for which this is known to be safe. For general casts, use castTo.

Methods

Click to display all available methods, including inherited ones

Expand

Methods

actionSetEnabled, activate, activateAction, activateDefault, addController, addCssClass, addMnemonicLabel, addTickCallback, allocate, attach, attachNextTo, bindProperty, bindPropertyFull, childFocus, computeBounds, computeExpand, computePoint, computeTransform, contains, createPangoContext, createPangoLayout, disposeTemplate, dragCheckThreshold, errorBell, forceFloating, freezeNotify, getv, grabFocus, hasCssClass, hasDefault, hasFocus, hasVisibleFocus, hide, inDestruction, initTemplate, insertActionGroup, insertAfter, insertBefore, insertColumn, insertNextTo, insertRow, isAncestor, isDrawable, isFloating, isFocus, isSensitive, isVisible, keynavFailed, listMnemonicLabels, map, measure, mnemonicActivate, notify, notifyByPspec, observeChildren, observeControllers, pick, queryChild, queueAllocate, queueDraw, queueResize, realize, ref, refSink, remove, removeColumn, removeController, removeCssClass, removeMnemonicLabel, removeRow, removeTickCallback, resetProperty, resetRelation, resetState, runDispose, shouldLayout, show, sizeAllocate, snapshotChild, stealData, stealQdata, thawNotify, translateCoordinates, triggerTooltipQuery, unmap, unparent, unrealize, unref, unsetStateFlags, updateNextAccessibleSibling, updateProperty, updateRelation, updateState, watchClosure.

Getters

getAccessibleParent, getAccessibleRole, getAllocatedBaseline, getAllocatedHeight, getAllocatedWidth, getAllocation, getAncestor, getAtContext, getBaselineRow, getBounds, getBuildableId, getCanFocus, getCanTarget, getChildAt, getChildVisible, getClipboard, getColor, getColumnHomogeneous, getColumnSpacing, getCssClasses, getCssName, getCursor, getData, getDirection, getDisplay, getFirstAccessibleChild, getFirstChild, getFocusChild, getFocusOnClick, getFocusable, getFontMap, getFontOptions, getFrameClock, getHalign, getHasTooltip, getHeight, getHexpand, getHexpandSet, getLastChild, getLayoutManager, getMapped, getMarginBottom, getMarginEnd, getMarginStart, getMarginTop, getName, getNative, getNextAccessibleSibling, getNextSibling, getOpacity, getOrientation, getOverflow, getPangoContext, getParent, getPlatformState, getPreferredSize, getPrevSibling, getPrimaryClipboard, getProperty, getQdata, getRealized, getReceivesDefault, getRequestMode, getRoot, getRowBaselinePosition, getRowHomogeneous, getRowSpacing, getScaleFactor, getSensitive, getSettings, getSize, getSizeRequest, getStateFlags, getStyleContext, getTemplateChild, getTooltipMarkup, getTooltipText, getValign, getVexpand, getVexpandSet, getVisible, getWidth.

Setters

setAccessibleParent, setBaselineRow, setCanFocus, setCanTarget, setChildVisible, setColumnHomogeneous, setColumnSpacing, setCssClasses, setCursor, setCursorFromName, setData, setDataFull, setDirection, setFocusChild, setFocusOnClick, setFocusable, setFontMap, setFontOptions, setHalign, setHasTooltip, setHexpand, setHexpandSet, setLayoutManager, setMarginBottom, setMarginEnd, setMarginStart, setMarginTop, setName, setOpacity, setOrientation, setOverflow, setParent, setProperty, setReceivesDefault, setRowBaselinePosition, setRowHomogeneous, setRowSpacing, setSensitive, setSizeRequest, setStateFlags, setTooltipMarkup, setTooltipText, setValign, setVexpand, setVexpandSet, setVisible.

attach

gridAttach Source #

Arguments

:: (HasCallStack, MonadIO m, IsGrid a, IsWidget b) 
=> a

grid: a GtkGrid

-> b

child: the widget to add

-> Int32

column: the column number to attach the left side of child to

-> Int32

row: the row number to attach the top side of child to

-> Int32

width: the number of columns that child will span

-> Int32

height: the number of rows that child will span

-> m () 

Adds a widget to the grid.

The position of child is determined by column and row. The number of “cells” that child will occupy is determined by width and height.

attachNextTo

gridAttachNextTo Source #

Arguments

:: (HasCallStack, MonadIO m, IsGrid a, IsWidget b, IsWidget c) 
=> a

grid: a GtkGrid

-> b

child: the widget to add

-> Maybe c

sibling: the child of grid that child will be placed next to, or Nothing to place child at the beginning or end

-> PositionType

side: the side of sibling that child is positioned next to

-> Int32

width: the number of columns that child will span

-> Int32

height: the number of rows that child will span

-> m () 

Adds a widget to the grid.

The widget is placed next to sibling, on the side determined by side. When sibling is Nothing, the widget is placed in row (for left or right placement) or column 0 (for top or bottom placement), at the end indicated by side.

Attaching widgets labeled [1], [2], [3] with @sibling == %NULL and @side == %GTK_POS_LEFT yields a layout of [3][2][1].

getBaselineRow

gridGetBaselineRow Source #

Arguments

:: (HasCallStack, MonadIO m, IsGrid a) 
=> a

grid: a GtkGrid

-> m Int32

Returns: the row index defining the global baseline

Returns which row defines the global baseline of grid.

getChildAt

gridGetChildAt Source #

Arguments

:: (HasCallStack, MonadIO m, IsGrid a) 
=> a

grid: a GtkGrid

-> Int32

column: the left edge of the cell

-> Int32

row: the top edge of the cell

-> m (Maybe Widget)

Returns: the child at the given position

Gets the child of grid whose area covers the grid cell at column, row.

getColumnHomogeneous

gridGetColumnHomogeneous Source #

Arguments

:: (HasCallStack, MonadIO m, IsGrid a) 
=> a

grid: a GtkGrid

-> m Bool

Returns: whether all columns of grid have the same width.

Returns whether all columns of grid have the same width.

getColumnSpacing

gridGetColumnSpacing Source #

Arguments

:: (HasCallStack, MonadIO m, IsGrid a) 
=> a

grid: a GtkGrid

-> m Word32

Returns: the column spacing of grid

Returns the amount of space between the columns of grid.

getRowBaselinePosition

gridGetRowBaselinePosition Source #

Arguments

:: (HasCallStack, MonadIO m, IsGrid a) 
=> a

grid: a GtkGrid

-> Int32

row: a row index

-> m BaselinePosition

Returns: the baseline position of row

Returns the baseline position of row.

See gridSetRowBaselinePosition.

getRowHomogeneous

gridGetRowHomogeneous Source #

Arguments

:: (HasCallStack, MonadIO m, IsGrid a) 
=> a

grid: a GtkGrid

-> m Bool

Returns: whether all rows of grid have the same height.

Returns whether all rows of grid have the same height.

getRowSpacing

gridGetRowSpacing Source #

Arguments

:: (HasCallStack, MonadIO m, IsGrid a) 
=> a

grid: a GtkGrid

-> m Word32

Returns: the row spacing of grid

Returns the amount of space between the rows of grid.

insertColumn

gridInsertColumn Source #

Arguments

:: (HasCallStack, MonadIO m, IsGrid a) 
=> a

grid: a GtkGrid

-> Int32

position: the position to insert the column at

-> m () 

Inserts a column at the specified position.

Children which are attached at or to the right of this position are moved one column to the right. Children which span across this position are grown to span the new column.

insertNextTo

gridInsertNextTo Source #

Arguments

:: (HasCallStack, MonadIO m, IsGrid a, IsWidget b) 
=> a

grid: a GtkGrid

-> b

sibling: the child of grid that the new row or column will be placed next to

-> PositionType

side: the side of sibling that child is positioned next to

-> m () 

Inserts a row or column at the specified position.

The new row or column is placed next to sibling, on the side determined by side. If side is PositionTypeTop or PositionTypeBottom, a row is inserted. If side is PositionTypeLeft of PositionTypeRight, a column is inserted.

insertRow

gridInsertRow Source #

Arguments

:: (HasCallStack, MonadIO m, IsGrid a) 
=> a

grid: a GtkGrid

-> Int32

position: the position to insert the row at

-> m () 

Inserts a row at the specified position.

Children which are attached at or below this position are moved one row down. Children which span across this position are grown to span the new row.

new

gridNew Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> m Grid

Returns: the new GtkGrid

Creates a new grid widget.

queryChild

gridQueryChild Source #

Arguments

:: (HasCallStack, MonadIO m, IsGrid a, IsWidget b) 
=> a

grid: a GtkGrid

-> b

child: a GtkWidget child of grid

-> m (Int32, Int32, Int32, Int32) 

Queries the attach points and spans of child inside the given GtkGrid.

remove

gridRemove Source #

Arguments

:: (HasCallStack, MonadIO m, IsGrid a, IsWidget b) 
=> a

grid: a GtkGrid

-> b

child: the child widget to remove

-> m () 

Removes a child from grid.

The child must have been added with gridAttach or gridAttachNextTo.

removeColumn

gridRemoveColumn Source #

Arguments

:: (HasCallStack, MonadIO m, IsGrid a) 
=> a

grid: a GtkGrid

-> Int32

position: the position of the column to remove

-> m () 

Removes a column from the grid.

Children that are placed in this column are removed, spanning children that overlap this column have their width reduced by one, and children after the column are moved to the left.

removeRow

gridRemoveRow Source #

Arguments

:: (HasCallStack, MonadIO m, IsGrid a) 
=> a

grid: a GtkGrid

-> Int32

position: the position of the row to remove

-> m () 

Removes a row from the grid.

Children that are placed in this row are removed, spanning children that overlap this row have their height reduced by one, and children below the row are moved up.

setBaselineRow

gridSetBaselineRow Source #

Arguments

:: (HasCallStack, MonadIO m, IsGrid a) 
=> a

grid: a GtkGrid

-> Int32

row: the row index

-> m () 

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.

setColumnHomogeneous

gridSetColumnHomogeneous Source #

Arguments

:: (HasCallStack, MonadIO m, IsGrid a) 
=> a

grid: a GtkGrid

-> Bool

homogeneous: True to make columns homogeneous

-> m () 

Sets whether all columns of grid will have the same width.

setColumnSpacing

gridSetColumnSpacing Source #

Arguments

:: (HasCallStack, MonadIO m, IsGrid a) 
=> a

grid: a GtkGrid

-> Word32

spacing: the amount of space to insert between columns

-> m () 

Sets the amount of space between columns of grid.

setRowBaselinePosition

gridSetRowBaselinePosition Source #

Arguments

:: (HasCallStack, MonadIO m, IsGrid a) 
=> a

grid: a GtkGrid

-> Int32

row: a row index

-> BaselinePosition

pos: a GtkBaselinePosition

-> m () 

Sets how the baseline should be positioned on row of the grid, in case that row is assigned more space than is requested.

The default baseline position is BaselinePositionCenter.

setRowHomogeneous

gridSetRowHomogeneous Source #

Arguments

:: (HasCallStack, MonadIO m, IsGrid a) 
=> a

grid: a GtkGrid

-> Bool

homogeneous: True to make rows homogeneous

-> m () 

Sets whether all rows of grid will have the same height.

setRowSpacing

gridSetRowSpacing Source #

Arguments

:: (HasCallStack, MonadIO m, IsGrid a) 
=> a

grid: a GtkGrid

-> Word32

spacing: the amount of space to insert between rows

-> m () 

Sets the amount of space between rows of grid.

Properties

baselineRow

The row to align to the baseline when valign is AlignBaseline.

constructGridBaselineRow :: (IsGrid o, MonadIO m) => Int32 -> m (GValueConstruct o) Source #

Construct a GValueConstruct with valid value for the “baseline-row” property. This is rarely needed directly, but it is used by new.

getGridBaselineRow :: (MonadIO m, IsGrid o) => o -> m Int32 Source #

Get the value of the “baseline-row” property. When overloading is enabled, this is equivalent to

get grid #baselineRow

setGridBaselineRow :: (MonadIO m, IsGrid o) => o -> Int32 -> m () Source #

Set the value of the “baseline-row” property. When overloading is enabled, this is equivalent to

set grid [ #baselineRow := value ]

columnHomogeneous

If True, the columns are all the same width.

constructGridColumnHomogeneous :: (IsGrid o, MonadIO m) => Bool -> m (GValueConstruct o) Source #

Construct a GValueConstruct with valid value for the “column-homogeneous” property. This is rarely needed directly, but it is used by new.

getGridColumnHomogeneous :: (MonadIO m, IsGrid o) => o -> m Bool Source #

Get the value of the “column-homogeneous” property. When overloading is enabled, this is equivalent to

get grid #columnHomogeneous

setGridColumnHomogeneous :: (MonadIO m, IsGrid o) => o -> Bool -> m () Source #

Set the value of the “column-homogeneous” property. When overloading is enabled, this is equivalent to

set grid [ #columnHomogeneous := value ]

columnSpacing

The amount of space between two consecutive columns.

constructGridColumnSpacing :: (IsGrid o, MonadIO m) => Int32 -> m (GValueConstruct o) Source #

Construct a GValueConstruct with valid value for the “column-spacing” property. This is rarely needed directly, but it is used by new.

getGridColumnSpacing :: (MonadIO m, IsGrid o) => o -> m Int32 Source #

Get the value of the “column-spacing” property. When overloading is enabled, this is equivalent to

get grid #columnSpacing

setGridColumnSpacing :: (MonadIO m, IsGrid o) => o -> Int32 -> m () Source #

Set the value of the “column-spacing” property. When overloading is enabled, this is equivalent to

set grid [ #columnSpacing := value ]

rowHomogeneous

If True, the rows are all the same height.

constructGridRowHomogeneous :: (IsGrid o, MonadIO m) => Bool -> m (GValueConstruct o) Source #

Construct a GValueConstruct with valid value for the “row-homogeneous” property. This is rarely needed directly, but it is used by new.

getGridRowHomogeneous :: (MonadIO m, IsGrid o) => o -> m Bool Source #

Get the value of the “row-homogeneous” property. When overloading is enabled, this is equivalent to

get grid #rowHomogeneous

setGridRowHomogeneous :: (MonadIO m, IsGrid o) => o -> Bool -> m () Source #

Set the value of the “row-homogeneous” property. When overloading is enabled, this is equivalent to

set grid [ #rowHomogeneous := value ]

rowSpacing

The amount of space between two consecutive rows.

constructGridRowSpacing :: (IsGrid o, MonadIO m) => Int32 -> m (GValueConstruct o) Source #

Construct a GValueConstruct with valid value for the “row-spacing” property. This is rarely needed directly, but it is used by new.

getGridRowSpacing :: (MonadIO m, IsGrid o) => o -> m Int32 Source #

Get the value of the “row-spacing” property. When overloading is enabled, this is equivalent to

get grid #rowSpacing

setGridRowSpacing :: (MonadIO m, IsGrid o) => o -> Int32 -> m () Source #

Set the value of the “row-spacing” property. When overloading is enabled, this is equivalent to

set grid [ #rowSpacing := value ]