Class DragIcon

All Implemented Interfaces:
Accessible, Buildable, ConstraintTarget, Native, Root, Proxy

@Generated("org.javagi.JavaGI") public class DragIcon extends Widget implements Accessible, Buildable, ConstraintTarget, Native, Root

A GtkRoot implementation for drag icons.

A drag icon moves with the pointer during a Drag-and-Drop operation and is destroyed when the drag ends.

To set up a drag icon and associate it with an ongoing drag operation, use getForDrag(Drag) to get the icon for a drag. You can then use it like any other widget and use setChild(Widget) to set whatever widget should be used for the drag icon.

Keep in mind that drag icons do not allow user input.

  • Constructor Details

    • DragIcon

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

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

    • getType

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

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

      protected DragIcon 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
    • getForDrag

      public static DragIcon getForDrag(Drag drag)

      Gets the GtkDragIcon in use with drag.

      If no drag icon exists yet, a new one will be created and shown.

      Parameters:
      drag - a GdkDrag
      Returns:
      the GtkDragIcon
    • createWidgetForValue

      public static @Nullable Widget createWidgetForValue(Value value)

      Creates a widget that can be used as a drag icon for the given value.

      Supported types include strings, GdkRGBA and GtkTextBuffer. If GTK does not know how to create a widget for a given value, it will return null.

      This method is used to set the default drag icon on drag-and-drop operations started by GtkDragSource, so you don't need to set a drag icon using this function there.

      Parameters:
      value - a GValue
      Returns:
      A new GtkWidget for displaying value as a drag icon.
    • setFromPaintable

      public static void setFromPaintable(Drag drag, Paintable paintable, int hotX, int hotY)

      Creates a GtkDragIcon that shows paintable, and associates it with the drag operation.

      The hotspot position on the paintable is aligned with the hotspot of the cursor.

      Parameters:
      drag - a GdkDrag
      paintable - a GdkPaintable to display
      hotX - X coordinate of the hotspot
      hotY - Y coordinate of the hotspot
    • getChild

      public @Nullable Widget getChild()
      Gets the widget currently used as drag icon.
      Returns:
      The drag icon
    • setChild

      public void setChild(@Nullable Widget child)
      Sets the widget to display as the drag icon.
      Parameters:
      child - a GtkWidget
    • builder

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