Class Paned

All Implemented Interfaces:
Accessible, AccessibleRange, Buildable, ConstraintTarget, Orientable, Proxy

@Generated("org.javagi.JavaGI") public class Paned extends Widget implements Accessible, AccessibleRange, Buildable, ConstraintTarget, Orientable

Arranges its children in two panes, horizontally or vertically.

An example GtkPaned

The division between the two panes is adjustable by the user by dragging a handle.

Child widgets are added to the panes of the widget with setStartChild(Widget) and setEndChild(Widget). The division between the two children is set by default from the size requests of the children, but it can be adjusted by the user.

A paned widget draws a separator between the two child widgets and a small handle that the user can drag to adjust the division. It does not draw any relief around the children or around the separator. (The space in which the separator is called the gutter.) Often, it is useful to put each child inside a Frame so that the gutter appears as a ridge. No separator is drawn if one of the children is missing.

Each child has two options that can be set, "resize" and "shrink". If "resize" is true then, when the GtkPaned is resized, that child will expand or shrink along with the paned widget. If "shrink" is true, then that child can be made smaller than its requisition by the user. Setting "shrink" to false allows the application to set a minimum size. If "resize" is false for both children, then this is treated as if "resize" is true for both children.

The application can set the position of the slider as if it were set by the user, by calling setPosition(int).

Shortcuts and Gestures

The following signals have default keybindings:

  • Gtk.Paned::accept-position
  • Gtk.Paned::cancel-position
  • Gtk.Paned::cycle-child-focus
  • Gtk.Paned::cycle-handle-focus
  • Gtk.Paned::move-handle
  • Gtk.Paned::toggle-handle-focus

CSS nodes

paned
├── <child>
├── separator[.wide]
╰── <child>

GtkPaned has a main CSS node with name paned, and a subnode for the separator with name separator. The subnode gets a .wide style class when the paned is supposed to be wide.

In horizontal orientation, the nodes are arranged based on the text direction, so in left-to-right mode, :first-child will select the leftmost child, while it will select the rightmost child in RTL layouts.

Creating a paned widget with minimum sizes.

GtkWidget *hpaned = gtk_paned_new (GTK_ORIENTATION_HORIZONTAL);
GtkWidget *frame1 = gtk_frame_new (NULL);
GtkWidget *frame2 = gtk_frame_new (NULL);

gtk_widget_set_size_request (hpaned, 200, -1);

gtk_paned_set_start_child (GTK_PANED (hpaned), frame1);
gtk_paned_set_resize_start_child (GTK_PANED (hpaned), TRUE);
gtk_paned_set_shrink_start_child (GTK_PANED (hpaned), FALSE);
gtk_widget_set_size_request (frame1, 50, -1);

gtk_paned_set_end_child (GTK_PANED (hpaned), frame2);
gtk_paned_set_resize_end_child (GTK_PANED (hpaned), FALSE);
gtk_paned_set_shrink_end_child (GTK_PANED (hpaned), FALSE);
gtk_widget_set_size_request (frame2, 50, -1);
  • Constructor Details

    • Paned

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

      public Paned(Orientation orientation)
      Creates a new GtkPaned widget.
      Parameters:
      orientation - the paned’s orientation.
    • Paned

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

    • getType

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

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

      protected Paned 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 Widget
      Returns:
      the instance as if it were its parent type
    • getEndChild

      public @Nullable Widget getEndChild()
      Retrieves the end child of the given GtkPaned.
      Returns:
      the end child widget
    • getPosition

      public int getPosition()
      Obtains the position of the divider between the two panes.
      Returns:
      the position of the divider, in pixels
    • getResizeEndChild

      public boolean getResizeEndChild()
      Returns whether the Gtk.Paned:end-child can be resized.
      Returns:
      true if the end child is resizable
    • getResizeStartChild

      public boolean getResizeStartChild()
      Returns whether the Gtk.Paned:start-child can be resized.
      Returns:
      true if the start child is resizable
    • getShrinkEndChild

      public boolean getShrinkEndChild()
      Returns whether the Gtk.Paned:end-child can shrink.
      Returns:
      true if the end child is shrinkable
    • getShrinkStartChild

      public boolean getShrinkStartChild()
      Returns whether the Gtk.Paned:start-child can shrink.
      Returns:
      true if the start child is shrinkable
    • getStartChild

      public @Nullable Widget getStartChild()
      Retrieves the start child of the given GtkPaned.
      Returns:
      the start child widget
    • getWideHandle

      public boolean getWideHandle()
      Gets whether the separator should be wide.
      Returns:
      true if the paned should have a wide handle
    • setEndChild

      public void setEndChild(@Nullable Widget child)

      Sets the end child of this Paned to child.

      If child is NULL, the existing child will be removed.

      Parameters:
      child - the widget to add
    • setPosition

      public void setPosition(int position)
      Sets the position of the divider between the two panes.
      Parameters:
      position - pixel position of divider, a negative value means that the position is unset
    • setResizeEndChild

      public void setResizeEndChild(boolean resize)
      Sets whether the Gtk.Paned:end-child can be resized.
      Parameters:
      resize - true to let the end child be resized
    • setResizeStartChild

      public void setResizeStartChild(boolean resize)
      Sets whether the Gtk.Paned:start-child can be resized.
      Parameters:
      resize - true to let the start child be resized
    • setShrinkEndChild

      public void setShrinkEndChild(boolean resize)
      Sets whether the Gtk.Paned:end-child can shrink.
      Parameters:
      resize - true to let the end child be shrunk
    • setShrinkStartChild

      public void setShrinkStartChild(boolean resize)
      Sets whether the Gtk.Paned:start-child can shrink.
      Parameters:
      resize - true to let the start child be shrunk
    • setStartChild

      public void setStartChild(@Nullable Widget child)

      Sets the start child of this Paned to child.

      If child is NULL, the existing child will be removed.

      Parameters:
      child - the widget to add
    • setWideHandle

      public void setWideHandle(boolean wide)
      Sets whether the separator should be wide.
      Parameters:
      wide - the new value for the Gtk.Paned:wide-handle property
    • onAcceptPosition

      Emitted to accept the current position of the handle when moving it using key bindings.

      This is a keybinding signal.

      The default binding for this signal is Return or Space.

      Parameters:
      handler - the signal handler
      Returns:
      a signal handler ID to keep track of the signal connection
      See Also:
    • emitAcceptPosition

      public boolean emitAcceptPosition()
      Emits the "accept-position" signal. See onAcceptPosition(Paned.AcceptPositionCallback).
    • onCancelPosition

      Emitted to cancel moving the position of the handle using key bindings.

      The position of the handle will be reset to the value prior to moving it.

      This is a keybinding signal.

      The default binding for this signal is Escape.

      Parameters:
      handler - the signal handler
      Returns:
      a signal handler ID to keep track of the signal connection
      See Also:
    • emitCancelPosition

      public boolean emitCancelPosition()
      Emits the "cancel-position" signal. See onCancelPosition(Paned.CancelPositionCallback).
    • onCycleChildFocus

      Emitted to cycle the focus between the children of the paned.

      This is a keybinding signal.

      The default binding is F6.

      Parameters:
      handler - the signal handler
      Returns:
      a signal handler ID to keep track of the signal connection
      See Also:
    • emitCycleChildFocus

      public boolean emitCycleChildFocus(boolean reversed)
      Emits the "cycle-child-focus" signal. See onCycleChildFocus(Paned.CycleChildFocusCallback).
    • onCycleHandleFocus

      Emitted to cycle whether the paned should grab focus to allow the user to change position of the handle by using key bindings.

      This is a keybinding signal.

      The default binding for this signal is F8.

      Parameters:
      handler - the signal handler
      Returns:
      a signal handler ID to keep track of the signal connection
      See Also:
    • emitCycleHandleFocus

      public boolean emitCycleHandleFocus(boolean reversed)
      Emits the "cycle-handle-focus" signal. See onCycleHandleFocus(Paned.CycleHandleFocusCallback).
    • onMoveHandle

      Emitted to move the handle with key bindings.

      This is a keybinding signal.

      The default bindings for this signal are Ctrl+, , Ctrl+, , Ctrl+, , Ctrl+, , PgUp, PgDn, Home, End.

      Parameters:
      handler - the signal handler
      Returns:
      a signal handler ID to keep track of the signal connection
      See Also:
    • emitMoveHandle

      public boolean emitMoveHandle(ScrollType scrollType)
      Emits the "move-handle" signal. See onMoveHandle(Paned.MoveHandleCallback).
    • onToggleHandleFocus

      Emitted to accept the current position of the handle and then move focus to the next widget in the focus chain.

      This is a keybinding signal.

      The default binding is Tab.

      Parameters:
      handler - the signal handler
      Returns:
      a signal handler ID to keep track of the signal connection
      See Also:
    • emitToggleHandleFocus

      public boolean emitToggleHandleFocus()
      Emits the "toggle-handle-focus" signal. See onToggleHandleFocus(Paned.ToggleHandleFocusCallback).
    • builder

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