Class Adjustment

All Implemented Interfaces:
Proxy

@Generated("org.javagi.JavaGI") public class Adjustment extends InitiallyUnowned

A model for a numeric value.

The GtkAdjustment has an associated lower and upper bound. It also contains step and page increments, and a page size.

Adjustments are used within several GTK widgets, including SpinButton, Viewport, Scrollbar and Scale.

The GtkAdjustment object does not update the value itself. Instead it is left up to the owner of the GtkAdjustment to control the value.

  • Constructor Details

    • Adjustment

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

      public Adjustment(double value, double lower, double upper, double stepIncrement, double pageIncrement, double pageSize)
      Creates a new GtkAdjustment.
      Parameters:
      value - the initial value
      lower - the minimum value
      upper - the maximum value
      stepIncrement - the step increment
      pageIncrement - the page increment
      pageSize - the page size
    • Adjustment

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

    • getType

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

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

      protected Adjustment 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 InitiallyUnowned
      Returns:
      the instance as if it were its parent type
    • clampPage

      public void clampPage(double lower, double upper)

      Updates the value of the adjustment to ensure that the given range is contained in the current page.

      The current page goes from value to value + page-size. If the range is larger than the page size, then only the start of it will be in the current page.

      A Gtk.Adjustment::value-changed signal will be emitted if the value is changed.

      Parameters:
      lower - the lower value
      upper - the upper value
    • configure

      public void configure(double value, double lower, double upper, double stepIncrement, double pageIncrement, double pageSize)

      Sets all properties of the adjustment at once.

      Use this function to avoid multiple emissions of the Gtk.Adjustment::changed signal. See setLower(double) for an alternative way of compressing multiple emissions of Gtk.Adjustment::changed into one.

      Parameters:
      value - the new value
      lower - the new minimum value
      upper - the new maximum value
      stepIncrement - the new step increment
      pageIncrement - the new page increment
      pageSize - the new page size
    • getLower

      public double getLower()
      Retrieves the minimum value of the adjustment.
      Returns:
      the minimum value
    • getMinimumIncrement

      public double getMinimumIncrement()
      Gets the smaller of step increment and page increment.
      Returns:
      the minimum increment
    • getPageIncrement

      public double getPageIncrement()
      Retrieves the page increment of the adjustment.
      Returns:
      the page increment
    • getPageSize

      public double getPageSize()
      Retrieves the page size of the adjustment.
      Returns:
      the page size
    • getStepIncrement

      public double getStepIncrement()
      Retrieves the step increment of the adjustment.
      Returns:
      the step increment
    • getUpper

      public double getUpper()
      Retrieves the maximum value of the adjustment.
      Returns:
      the maximum value
    • getValue

      public double getValue()
      Gets the current value of the adjustment.
      Returns:
      the current value
    • setLower

      public void setLower(double lower)

      Sets the minimum value of the adjustment.

      When setting multiple adjustment properties via their individual setters, multiple Gtk.Adjustment::changed signals will be emitted. However, since the emission of the Gtk.Adjustment::changed signal is tied to the emission of the ::notify signals of the changed properties, it’s possible to compress the Gtk.Adjustment::changed signals into one by calling g_object_freeze_notify() and g_object_thaw_notify() around the calls to the individual setters.

      Alternatively, using a single g_object_set() for all the properties to change, or using configure(double, double, double, double, double, double) has the same effect.

      Parameters:
      lower - the new minimum value
    • setPageIncrement

      public void setPageIncrement(double pageIncrement)

      Sets the page increment of the adjustment.

      See setLower(double) about how to compress multiple emissions of the Gtk.Adjustment::changed signal when setting multiple adjustment properties.

      Parameters:
      pageIncrement - the new page increment
    • setPageSize

      public void setPageSize(double pageSize)

      Sets the page size of the adjustment.

      See setLower(double) about how to compress multiple emissions of the Gtk.Adjustment::changed signal when setting multiple adjustment properties.

      Parameters:
      pageSize - the new page size
    • setStepIncrement

      public void setStepIncrement(double stepIncrement)

      Sets the step increment of the adjustment.

      See setLower(double) about how to compress multiple emissions of the Gtk.Adjustment::changed signal when setting multiple adjustment properties.

      Parameters:
      stepIncrement - the new step increment
    • setUpper

      public void setUpper(double upper)

      Sets the maximum value of the adjustment.

      Note that values will be restricted by upper - page-size if the page-size property is nonzero.

      See setLower(double) about how to compress multiple emissions of the Gtk.Adjustment::changed signal when setting multiple adjustment properties.

      Parameters:
      upper - the new maximum value
    • setValue

      public void setValue(double value)

      Sets the GtkAdjustment value.

      The value is clamped to lie between Gtk.Adjustment:lower and Gtk.Adjustment:upper.

      Note that for adjustments which are used in a GtkScrollbar, the effective range of allowed values goes from Gtk.Adjustment:lower to Gtk.Adjustment:upper - Gtk.Adjustment:page-size.

      Parameters:
      value - the new value
    • changed

      protected void changed()
    • valueChanged

      protected void valueChanged()
    • onChanged

      Emitted when one or more of the GtkAdjustment properties have been changed.

      Note that the Gtk.Adjustment:value property is covered by the Gtk.Adjustment::value-changed signal.

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

      public void emitChanged()
      Emits the "changed" signal. See onChanged(Adjustment.ChangedCallback).
    • onValueChanged

      Emitted when the value has been changed.
      Parameters:
      handler - the signal handler
      Returns:
      a signal handler ID to keep track of the signal connection
      See Also:
    • emitValueChanged

      public void emitValueChanged()
      Emits the "value-changed" signal. See onValueChanged(Adjustment.ValueChangedCallback).
    • builder

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