org.gnome.gtk

## Class Table

- Object
- - org.freedesktop.bindings.Pointer
  - - org.freedesktop.bindings.Proxy
    - - org.gnome.glib.Object
      - - org.gnome.gtk.Widget
        - - org.gnome.gtk.Container
          - - org.gnome.gtk.Table

-     public class Table
      extends Container

  A Container which arranges child Widgets in particular rows and columns.

  Table is not a spreadsheet Widget! For that you would need to have (say) a sea of Entry Widgets that were all hooked up to behave the same (notably to pass focus between them appropriately) and which were individually constrained to each be the same size (at least by default), etc. By contrast, Table is for laying out Widgets in a grid but where each child can happily request the size it needs.

  To be honest, this Widget is a pain in the ass to use because you have to manually keep track of which `row,column` edges a Widget is to be constrained by. In most cases you can achieve the same alignment effects with far greater flexibility by using HBoxes nested in VBoxes and controlling the size allocations via `SizeGroup`s.

  Since:
    4.0.6
  Author:
    Andrew Cowie, Stefan Prelle

- - ### Nested Class Summary

    - ### Nested classes/interfaces inherited from class org.gnome.gtk.Widget

      `Widget.ButtonPressEvent, Widget.ButtonReleaseEvent, Widget.Destroy, Widget.Draw, Widget.EnterNotifyEvent, Widget.FocusInEvent, Widget.FocusOutEvent, Widget.Hide, Widget.KeyPressEvent, Widget.KeyReleaseEvent, Widget.LeaveNotifyEvent, Widget.MapEvent, Widget.MotionNotifyEvent, Widget.PopupMenu, Widget.QueryTooltip, Widget.ScrollEvent, Widget.SizeAllocate, Widget.UnmapEvent, Widget.VisibilityNotifyEvent`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `Table(int rows, int columns, boolean homogeneous)` Create a new Table.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `attach(Widget child, int leftAttach, int rightAttach, int topAttach, int bottomAttach)` Add a child Widget to this Table.
    `void` | `attach(Widget child, int leftAttach, int rightAttach, int topAttach, int bottomAttach, AttachOptions xoptions, AttachOptions yoptions, int xpadding, int ypadding)` Like `attach()` but has finer layout control for the Widget being added, mostly achieved using the `AttachOptions`.
    `void` | `resize(int rows, int columns)` Change the number of rows and columns in the Table.
    `void` | `setColumnSpacing(int spacing)` Set the (extra) spacing between all columns.
    `void` | `setColumnSpacing(int column, int spacing)` Set the (extra) spacing to be between `column` and the one adjacent to it.
    `void` | `setRowSpacing(int spacing)` Set the (extra) spacing between all rows.
    `void` | `setRowSpacing(int row, int spacing)` Set the (extra) spacing to be between `row` and the one following it.

    - ### Methods inherited from class org.gnome.gtk.Container

      `add, getChildren, remove, setBorderWidth`

    - ### Methods inherited from class org.gnome.gtk.Widget

      `activate, addEvents, connect, connect, connect, connect, connect, connect, connect, connect, connect, connect, connect, connect, connect, connect, connect, connect, connect, connect, connect, destroy, getAllocatedHeight, getAllocatedWidth, getAllocation, getCanDefault, getCanFocus, getHasFocus, getName, getParent, getPreferredHeightForWidthMinimum, getPreferredHeightForWidthNatural, getPreferredHeightMinimum, getPreferredHeightNatural, getPreferredWidthForHeightMinimum, getPreferredWidthForHeightNatural, getPreferredWidthMinimum, getPreferredWidthNatural, getRequestMode, getRequisition, getSensitive, getStyleContext, getToplevel, getWindow, grabAdd, grabDefault, grabFocus, grabRemove, hide, isSensitive, overrideBackground, overrideColor, overrideFont, queueDraw, queueDrawArea, realize, setAlignHorizontal, setAlignVertical, setCanDefault, setCanFocus, setEvents, setExpandHorizontal, setExpandVertical, setName, setSensitive, setSizeRequest, setTooltipMarkup, setTooltipText, show, showAll`

    - ### Methods inherited from class org.freedesktop.bindings.Pointer

      `toString`

    - ### Methods inherited from class Object

      `equals, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- - ### Constructor Detail

    - #### Table

          public Table(int rows,
               int columns,
               boolean homogeneous)

      Create a new Table. The Container will be configured to lay out `n` rows of `n` columns of child Widgets.
      Parameters:
        `homogeneous` - If `true`, all cells are sized to that requested by the largest Widget in the Table.
      Since:
        4.0.6

  - ### Method Detail

    - #### attach

          public void attach(Widget child,
                    int leftAttach,
                    int rightAttach,
                    int topAttach,
                    int bottomAttach)

      Add a child Widget to this Table. This is a convenience method where the more esoteric parameters of the full `attach()` are given appropriate default values.

      Each of the parameters refer to the column or row to which the Widget being added will be anchored. To put a Widget at the fourth column from the left, second row down, you would do:

           table.attach(child, 3, 4, 1, 2);

      As alluded to in the class description, this is quite finicky and worse is error prone.
      Since:
        4.0.6

    - #### attach

          public void attach(Widget child,
                    int leftAttach,
                    int rightAttach,
                    int topAttach,
                    int bottomAttach,
                    AttachOptions xoptions,
                    AttachOptions yoptions,
                    int xpadding,
                    int ypadding)

      Like `attach()` but has finer layout control for the Widget being added, mostly achieved using the `AttachOptions`.

      To define that a Widget shall grow on the x-axis, but keep the size on the y-axis you would do:

           table.attach(child, 3, 4, 1, 2, AttachOptions.EXPAND, AttachOptions.SHRINK, 0, 0);

      A common problem is that you have Widgets of different sizes (e.g. labels in a column). If a widget is smaller than the required space additional padding is added to the sides, so finally the smaller Widget is centered compared to the larger Widget. To avoid this you a) need to encapsulate the Widget in an `Alignment` Container and b) need to attach it here using `AttachOptions.FILL`, so that instead of additional space being added to the sides, the `Alignment` Container may decide how to distribute it.

      The following example left-aligns the child Widget within its cell, while it is vertically centered:

           final Alignment aligned;

           aligned = new Alignment(Alignment.LEFT, Alignment.CENTER, 1.0f, 1.0f, child);
           table.attach(aligned, 3, 4, 1, 2, AttachOptions.FILL, AttachOptions.FILL, 0, 0);

      Since:
        4.0.9

    - #### resize

          public void resize(int rows,
                    int columns)

      Change the number of rows and columns in the Table.
      Since:
        4.0.6

    - #### setColumnSpacing

          public void setColumnSpacing(int spacing)

      Set the (extra) spacing between all columns. Overwrites previous settings or those made by the two argument form of `setColumnSpacing()`.
      Since:
        4.0.8

    - #### setColumnSpacing

          public void setColumnSpacing(int column,
                              int spacing)

      Set the (extra) spacing to be between `column` and the one adjacent to it.
      Since:
        4.0.6

    - #### setRowSpacing

          public void setRowSpacing(int spacing)

      Set the (extra) spacing between all rows. Overwrites previous settings or those made by `setRowSpacing(int,int)`.
      Since:
        4.0.8

    - #### setRowSpacing

          public void setRowSpacing(int row,
                           int spacing)

      Set the (extra) spacing to be between `row` and the one following it.
      Since:
        4.0.6