Class GutterRenderer

All Implemented Interfaces:
Accessible, Buildable, ConstraintTarget, Proxy
Direct Known Subclasses:
GutterRenderer.GutterRenderer$Impl, GutterRendererPixbuf, GutterRendererText

@Generated("org.javagi.JavaGI") public abstract class GutterRenderer extends Widget implements Accessible, Buildable, ConstraintTarget

Gutter cell renderer.

A GtkSourceGutterRenderer represents a column in a Gutter. The column contains one cell for each visible line of the TextBuffer. Due to text wrapping, a cell can thus span multiple lines of the TextView. In this case, GutterRendererAlignmentMode controls the alignment of the cell.

The gutter renderer is a Widget and is measured using the normal widget measurement facilities. The width of the gutter will be determined by the measurements of the gutter renderers.

The width of a gutter renderer generally takes into account the entire text buffer. For instance, to display the line numbers, if the buffer contains 100 lines, the gutter renderer will always set its width such as three digits can be printed, even if only the first 20 lines are shown. Another strategy is to take into account only the visible lines. In this case, only two digits are necessary to display the line numbers of the first 20 lines. To take another example, the gutter renderer for Marks doesn't need to take into account the text buffer to announce its width. It only depends on the icons size displayed in the gutter column.

When the available size to render a cell is greater than the required size to render the cell contents, the cell contents can be aligned horizontally and vertically with setAlignmentMode(GutterRendererAlignmentMode).

The cells rendering occurs using Widget#snapshot. Implementations should use gtk_source_gutter_renderer_get_lines() to retrieve information about the lines to be rendered. To help with aligning content which takes into account the padding and alignment of a cell, implementations may call alignCell(int, float, float, Out, Out) for a given line number with the width and height measurement of the content they width to render.

  • Constructor Details

    • GutterRenderer

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

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

    • getType

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

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

      protected GutterRenderer 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
    • activate

      public void activate(TextIter iter, Rectangle area, int button, Set<ModifierType> state, int nPresses)
      Emits the GutterRenderer::activate signal of the renderer. This is called from Gutter and should never have to be called manually.
      Parameters:
      iter - a GtkTextIter at the start of the line where the renderer is activated
      area - a GdkRectangle of the cell area where the renderer is activated
      button - the button that was pressed
      state - a GdkModifierType
      nPresses - the number of button presses
    • activate

      public void activate(TextIter iter, Rectangle area, int button, ModifierType state, int nPresses)
      Emits the GutterRenderer::activate signal of the renderer. This is called from Gutter and should never have to be called manually.
      Parameters:
      iter - a GtkTextIter at the start of the line where the renderer is activated
      area - a GdkRectangle of the cell area where the renderer is activated
      button - the button that was pressed
      state - a GdkModifierType
      nPresses - the number of button presses
    • alignCell

      public void alignCell(int line, float width, float height, Out<Float> x, Out<Float> y)

      Locates where to render content that is width x height based on the renderers alignment and padding.

      The location will be placed into x and y and is relative to the renderer's coordinates.

      It is encouraged that renderers use this function when snappshotting to ensure consistent placement of their contents.

      Parameters:
      line - the line number for content
      width - the width of the content to draw
      height - the height of the content to draw
      x - the X position to render the content
      y - the Y position to render the content
    • getAlignmentMode

      public GutterRendererAlignmentMode getAlignmentMode()

      Get the alignment mode.

      The alignment mode describes the manner in which the renderer is aligned (see GutterRenderer:xalign and GutterRenderer:yalign).

      Returns:
      a GtkSourceGutterRendererAlignmentMode
    • getBuffer

      public @Nullable Buffer getBuffer()
      Gets the Buffer for which the gutter renderer is drawing.
      Returns:
      a GtkTextBuffer or null
    • getView

      public View getView()
      Get the view associated to the gutter renderer
      Returns:
      a GtkSourceView
    • getXalign

      public float getXalign()

      Gets the xalign property.

      This may be used to adjust where within the cell rectangle the renderer will draw.

    • getXpad

      public int getXpad()

      Gets the xpad property.

      This may be used to adjust the cell rectangle that the renderer will use to draw.

    • getYalign

      public float getYalign()

      Gets the yalign property.

      This may be used to adjust where within the cell rectangle the renderer will draw.

    • getYpad

      public int getYpad()

      Gets the ypad property.

      This may be used to adjust the cell rectangle that the renderer will use to draw.

    • queryActivatable

      public boolean queryActivatable(TextIter iter, Rectangle area)
      Get whether the renderer is activatable at the location provided. This is called from Gutter to determine whether a renderer is activatable using the mouse pointer.
      Parameters:
      iter - a GtkTextIter at the start of the line to be activated
      area - a GdkRectangle of the cell area to be activated
      Returns:
      true if the renderer can be activated, false otherwise
    • setAlignmentMode

      public void setAlignmentMode(GutterRendererAlignmentMode mode)
      Set the alignment mode. The alignment mode describes the manner in which the renderer is aligned (see GutterRenderer:xalign and GutterRenderer:yalign).
      Parameters:
      mode - a GtkSourceGutterRendererAlignmentMode
    • setXalign

      public void setXalign(float xalign)

      Adjusts the xalign property.

      This may be used to adjust where within the cell rectangle the renderer will draw.

      Parameters:
      xalign - the Y padding for the drawing cell
    • setXpad

      public void setXpad(int xpad)

      Adjusts the xpad property.

      This may be used to adjust the cell rectangle that the renderer will use to draw.

      Parameters:
      xpad - the Y padding for the drawing cell
    • setYalign

      public void setYalign(float yalign)

      Adjusts the yalign property.

      This may be used to adjust where within the cell rectangle the renderer will draw.

      Parameters:
      yalign - the Y padding for the drawing cell
    • setYpad

      public void setYpad(int ypad)

      Adjusts the ypad property.

      This may be used to adjust the cell rectangle that the renderer will use to draw.

      Parameters:
      ypad - the Y padding for the drawing cell
    • begin

      protected void begin(GutterLines lines)
    • changeBuffer

      protected void changeBuffer(@Nullable Buffer oldBuffer)
      This is called when the text buffer changes for renderer.
      Parameters:
      oldBuffer - the old GtkTextBuffer.
    • changeView

      protected void changeView(@Nullable View oldView)
      This is called when the text view changes for renderer.
      Parameters:
      oldView - the old GtkTextView.
    • end

      protected void end()
    • queryData

      protected void queryData(GutterLines lines, int line)
    • snapshotLine

      protected void snapshotLine(Snapshot snapshot, GutterLines lines, int line)
    • onActivate

      The signal is emitted when the renderer is activated.
      Parameters:
      handler - the signal handler
      Returns:
      a signal handler ID to keep track of the signal connection
      See Also:
    • emitActivate

      public void emitActivate(@Nullable TextIter iter, @Nullable Rectangle area, int button, Set<ModifierType> state, int nPresses)
      Emits the "activate" signal. See onActivate(GutterRenderer.ActivateCallback).
    • onQueryActivatable

      The signal is emitted when the renderer can possibly be activated.
      Parameters:
      handler - the signal handler
      Returns:
      a signal handler ID to keep track of the signal connection
      See Also:
    • emitQueryActivatable

      public boolean emitQueryActivatable(@Nullable TextIter iter, @Nullable Rectangle area)
      Emits the "query-activatable" signal. See onQueryActivatable(GutterRenderer.QueryActivatableCallback).
    • onQueryData

    • emitQueryData

      public void emitQueryData(@Nullable GObject object, int p0)