Class PaperSize

All Implemented Interfaces:
PointerInterface

public class PaperSize extends Record
`GtkPaperSize` handles paper sizes.

It uses the standard called
[PWG 5101.1-2002 PWG: Standard for Media Standardized Names](http://www.pwg.org/standards.html)
to name the paper sizes (and to get the data for the page sizes).
In addition to standard paper sizes, `GtkPaperSize` allows to
construct custom paper sizes with arbitrary dimensions.

The `GtkPaperSize` object stores not only the dimensions (width
and height) of a paper size and its name, it also provides
default print margins.

https://docs.gtk.org/gtk4/struct.PaperSize.html

  • Constructor Details

    • PaperSize

      public PaperSize(PointerContainer pointer)
    • PaperSize

      public PaperSize(@Nullable Str name)
      Creates a new `GtkPaperSize` object by parsing a
      [PWG 5101.1-2002](ftp://ftp.pwg.org/pub/pwg/candidates/cs-pwgmsn10-20020226-5101.1.pdf)
      paper name.

      If @name is %NULL, the default paper size is returned,
      see [func@Gtk.PaperSize.get_default].
      Parameters:
      name - a paper size name
    • PaperSize

      public PaperSize(String name)
      Creates a new `GtkPaperSize` object by parsing a
      [PWG 5101.1-2002](ftp://ftp.pwg.org/pub/pwg/candidates/cs-pwgmsn10-20020226-5101.1.pdf)
      paper name.

      If @name is %NULL, the default paper size is returned,
      see [func@Gtk.PaperSize.get_default].
      Parameters:
      name - a paper size name
  • Method Details

    • getClassHandler

      public static ClassHandler getClassHandler()
    • newCustomPaperSize

      public static PaperSize newCustomPaperSize(@Nonnull Str name, @Nonnull Str display_name, double width, double height, int unit)
      Creates a new `GtkPaperSize` object with the
      given parameters.
      Parameters:
      name - the paper name
      display_name - the human-readable name
      width - the paper width, in units of @unit
      height - the paper height, in units of @unit
      unit - the unit for @width and @height. not %GTK_UNIT_NONE.
      Returns:
      a new `GtkPaperSize` object, use [method@Gtk.PaperSize.free] to free it
    • newCustomPaperSize

      public static PaperSize newCustomPaperSize(String name, String display_name, double width, double height, int unit)
      Creates a new `GtkPaperSize` object with the
      given parameters.
      Parameters:
      name - the paper name
      display_name - the human-readable name
      width - the paper width, in units of @unit
      height - the paper height, in units of @unit
      unit - the unit for @width and @height. not %GTK_UNIT_NONE.
      Returns:
      a new `GtkPaperSize` object, use [method@Gtk.PaperSize.free] to free it
    • newFromGvariantPaperSize

      public static PaperSize newFromGvariantPaperSize(@Nonnull Variant variant)
      Deserialize a paper size from a `GVariant`.

      The `GVariant must be in the format produced by
      [method@Gtk.PaperSize.to_gvariant].
      Parameters:
      variant - an a{sv} `GVariant`
      Returns:
      a new `GtkPaperSize` object
    • newFromIppPaperSize

      public static PaperSize newFromIppPaperSize(@Nonnull Str ipp_name, double width, double height)
      Creates a new `GtkPaperSize` object by using
      IPP information.

      If @ipp_name is not a recognized paper name,
      @width and @height are used to
      construct a custom `GtkPaperSize` object.
      Parameters:
      ipp_name - an IPP paper name
      width - the paper width, in points
      height - the paper height in points
      Returns:
      a new `GtkPaperSize`, use [method@Gtk.PaperSize.free] to free it
    • newFromIppPaperSize

      public static PaperSize newFromIppPaperSize(String ipp_name, double width, double height)
      Creates a new `GtkPaperSize` object by using
      IPP information.

      If @ipp_name is not a recognized paper name,
      @width and @height are used to
      construct a custom `GtkPaperSize` object.
      Parameters:
      ipp_name - an IPP paper name
      width - the paper width, in points
      height - the paper height in points
      Returns:
      a new `GtkPaperSize`, use [method@Gtk.PaperSize.free] to free it
    • newFromKeyFilePaperSize

      public static PaperSize newFromKeyFilePaperSize(@Nonnull KeyFile key_file, @Nullable Str group_name) throws AllocationError
      Reads a paper size from the group @group_name in the key file
      @key_file.
      Parameters:
      key_file - the `GKeyFile` to retrieve the papersize from
      group_name - the name of the group in the key file to read, or %NULL to read the first group
      Returns:
      a new `GtkPaperSize` object with the restored paper size
      Throws:
      AllocationError
    • newFromKeyFilePaperSize

      public static PaperSize newFromKeyFilePaperSize(@Nonnull KeyFile key_file, String group_name) throws AllocationError
      Reads a paper size from the group @group_name in the key file
      @key_file.
      Parameters:
      key_file - the `GKeyFile` to retrieve the papersize from
      group_name - the name of the group in the key file to read, or %NULL to read the first group
      Returns:
      a new `GtkPaperSize` object with the restored paper size
      Throws:
      AllocationError
    • newFromPpdPaperSize

      public static PaperSize newFromPpdPaperSize(@Nonnull Str ppd_name, @Nonnull Str ppd_display_name, double width, double height)
      Creates a new `GtkPaperSize` object by using
      PPD information.

      If @ppd_name is not a recognized PPD paper name,
      @ppd_display_name, @width and @height are used to
      construct a custom `GtkPaperSize` object.
      Parameters:
      ppd_name - a PPD paper name
      ppd_display_name - the corresponding human-readable name
      width - the paper width, in points
      height - the paper height in points
      Returns:
      a new `GtkPaperSize`, use [method@Gtk.PaperSize.free] to free it
    • newFromPpdPaperSize

      public static PaperSize newFromPpdPaperSize(String ppd_name, String ppd_display_name, double width, double height)
      Creates a new `GtkPaperSize` object by using
      PPD information.

      If @ppd_name is not a recognized PPD paper name,
      @ppd_display_name, @width and @height are used to
      construct a custom `GtkPaperSize` object.
      Parameters:
      ppd_name - a PPD paper name
      ppd_display_name - the corresponding human-readable name
      width - the paper width, in points
      height - the paper height in points
      Returns:
      a new `GtkPaperSize`, use [method@Gtk.PaperSize.free] to free it
    • copy

      public PaperSize copy()
      Copies an existing `GtkPaperSize`.
      Returns:
      a copy of @other
    • free

      public void free()
      Free the given `GtkPaperSize` object.
    • getDefaultBottomMargin

      public double getDefaultBottomMargin(int unit)
      Gets the default bottom margin for the `GtkPaperSize`.
      Parameters:
      unit - the unit for the return value, not %GTK_UNIT_NONE
      Returns:
      the default bottom margin
    • getDefaultLeftMargin

      public double getDefaultLeftMargin(int unit)
      Gets the default left margin for the `GtkPaperSize`.
      Parameters:
      unit - the unit for the return value, not %GTK_UNIT_NONE
      Returns:
      the default left margin
    • getDefaultRightMargin

      public double getDefaultRightMargin(int unit)
      Gets the default right margin for the `GtkPaperSize`.
      Parameters:
      unit - the unit for the return value, not %GTK_UNIT_NONE
      Returns:
      the default right margin
    • getDefaultTopMargin

      public double getDefaultTopMargin(int unit)
      Gets the default top margin for the `GtkPaperSize`.
      Parameters:
      unit - the unit for the return value, not %GTK_UNIT_NONE
      Returns:
      the default top margin
    • getDisplayName

      public Str getDisplayName()
      Gets the human-readable name of the `GtkPaperSize`.
      Returns:
      the human-readable name of @size
    • getHeight

      public double getHeight(int unit)
      Gets the paper height of the `GtkPaperSize`, in
      units of @unit.
      Parameters:
      unit - the unit for the return value, not %GTK_UNIT_NONE
      Returns:
      the paper height
    • getName

      public Str getName()
      Gets the name of the `GtkPaperSize`.
      Returns:
      the name of @size
    • getPpdName

      public Str getPpdName()
      Gets the PPD name of the `GtkPaperSize`, which
      may be %NULL.
      Returns:
      the PPD name of @size
    • getWidth

      public double getWidth(int unit)
      Gets the paper width of the `GtkPaperSize`, in
      units of @unit.
      Parameters:
      unit - the unit for the return value, not %GTK_UNIT_NONE
      Returns:
      the paper width
    • isCustom

      public boolean isCustom()
      Returns %TRUE if @size is not a standard paper size.
      Returns:
      whether @size is a custom paper size.
    • isEqual

      public boolean isEqual(@Nonnull PaperSize size2)
      Compares two `GtkPaperSize` objects.
      Parameters:
      size2 - another `GtkPaperSize` object
      Returns:
      %TRUE, if @size1 and @size2 represent the same paper size
    • isIpp

      public boolean isIpp()
      Returns %TRUE if @size is an IPP standard paper size.
      Returns:
      whether @size is not an IPP custom paper size.
    • setSize

      public void setSize(double width, double height, int unit)
      Changes the dimensions of a @size to @width x @height.
      Parameters:
      width - the new width in units of @unit
      height - the new height in units of @unit
      unit - the unit for @width and @height
    • toGvariant

      public Variant toGvariant()
      Serialize a paper size to an `a{sv}` variant.
      Returns:
      a new, floating, `GVariant`
    • toKeyFile

      public void toKeyFile(@Nonnull KeyFile key_file, @Nonnull Str group_name)
      This function adds the paper size from @size to @key_file.
      Parameters:
      key_file - the `GKeyFile` to save the paper size to
      group_name - the group to add the settings to in @key_file
    • toKeyFile

      public void toKeyFile(@Nonnull KeyFile key_file, String group_name)
      This function adds the paper size from @size to @key_file.
      Parameters:
      key_file - the `GKeyFile` to save the paper size to
      group_name - the group to add the settings to in @key_file
    • getDefault

      public static Str getDefault()
      Returns the name of the default paper size, which
      depends on the current locale.
      Returns:
      the name of the default paper size. The string is owned by GTK and should not be modified.
    • getPaperSizes

      public static List getPaperSizes(boolean include_custom)
      Creates a list of known paper sizes.
      Parameters:
      include_custom - whether to include custom paper sizes as defined in the page setup dialog
      Returns:
      a newly allocated list of newly allocated `GtkPaperSize` objects
    • getTypeID

      public static long getTypeID()
    • getParentTypeID

      public static long getParentTypeID()
    • getTypeSize

      public static TypeSystem.TypeSize getTypeSize()
    • getParentTypeSize

      public static TypeSystem.TypeSize getParentTypeSize()
    • getInstanceSize

      public static int getInstanceSize()