Class PaperSize
- All Implemented Interfaces:
Proxy
GtkPaperSize handles paper sizes.
It uses the standard called
PWG 5101.1-2002 PWG: Standard for Media Standardized Names
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.
-
Constructor Summary
ConstructorsConstructorDescriptionCreates a newGtkPaperSizeobject by parsing a PWG 5101.1-2002 paper name.PaperSize(MemorySegment address) Create a PaperSize proxy instance for the provided memory address. -
Method Summary
Modifier and TypeMethodDescriptioncopy()Copies an existingGtkPaperSize.static PaperSizeCreates a newGtkPaperSizeobject with the given parameters.voidfree()Free the givenGtkPaperSizeobject.static PaperSizefromGvariant(Variant variant) Deserialize a paper size from aGVariant.static PaperSizeCreates a newGtkPaperSizeobject by using IPP information.static PaperSizefromKeyFile(KeyFile keyFile, @Nullable String groupName) Reads a paper size from the groupgroupNamein the key filekeyFile.static PaperSizeCreates a newGtkPaperSizeobject by using PPD information.static StringReturns the name of the default paper size, which depends on the current locale.doublegetDefaultBottomMargin(Unit unit) Gets the default bottom margin for theGtkPaperSize.doublegetDefaultLeftMargin(Unit unit) Gets the default left margin for theGtkPaperSize.doublegetDefaultRightMargin(Unit unit) Gets the default right margin for theGtkPaperSize.doublegetDefaultTopMargin(Unit unit) Gets the default top margin for theGtkPaperSize.Gets the human-readable name of theGtkPaperSize.doubleGets the paper height of theGtkPaperSize, in units ofunit.getName()Gets the name of theGtkPaperSize.getPaperSizes(boolean includeCustom) Creates a list of known paper sizes.Gets the PPD name of theGtkPaperSize, which may benull.static @Nullable TypegetType()Get the GType of the PaperSize classdoubleGets the paper width of theGtkPaperSize, in units ofunit.booleanisCustom()Returnstrueif this PaperSize is not a standard paper size.booleanCompares twoGtkPaperSizeobjects.booleanisIpp()Returnstrueif this PaperSize is an IPP standard paper size.voidChanges the dimensions of a this PaperSize towidthxheight.Serialize a paper size to ana{sv}variant.voidThis function adds the paper size from this PaperSize tokeyFile.Methods inherited from class org.javagi.base.ProxyInstance
equals, handle, hashCode
-
Constructor Details
-
PaperSize
Create a PaperSize proxy instance for the provided memory address.- Parameters:
address- the memory address of the native object
-
PaperSize
Creates a newGtkPaperSizeobject by parsing a PWG 5101.1-2002 paper name.If
nameisnull, the default paper size is returned, seegetDefault().- Parameters:
name- a paper size name
-
-
Method Details
-
getType
-
custom
-
fromGvariant
Deserialize a paper size from aGVariant.The `GVariant must be in the format produced by
toGvariant().- Parameters:
variant- an a{sv}GVariant- Returns:
- a new
GtkPaperSizeobject
-
fromIpp
Creates a newGtkPaperSizeobject by using IPP information.If
ippNameis not a recognized paper name,widthandheightare used to construct a customGtkPaperSizeobject.- Parameters:
ippName- an IPP paper namewidth- the paper width, in pointsheight- the paper height in points- Returns:
- a new
GtkPaperSize, usefree()to free it
-
fromKeyFile
public static PaperSize fromKeyFile(KeyFile keyFile, @Nullable String groupName) throws GErrorException Reads a paper size from the groupgroupNamein the key filekeyFile.- Parameters:
keyFile- theGKeyFileto retrieve the papersize fromgroupName- the name of the group in the key file to read, ornullto read the first group- Returns:
- a new
GtkPaperSizeobject with the restored paper size - Throws:
GErrorException- seeGError
-
fromPpd
Creates a newGtkPaperSizeobject by using PPD information.If
ppdNameis not a recognized PPD paper name,ppdDisplayName,widthandheightare used to construct a customGtkPaperSizeobject.- Parameters:
ppdName- a PPD paper nameppdDisplayName- the corresponding human-readable namewidth- the paper width, in pointsheight- the paper height in points- Returns:
- a new
GtkPaperSize, usefree()to free it
-
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
-
copy
-
free
public void free()Free the givenGtkPaperSizeobject. -
getDefaultBottomMargin
-
getDefaultLeftMargin
-
getDefaultRightMargin
-
getDefaultTopMargin
-
getDisplayName
Gets the human-readable name of theGtkPaperSize.- Returns:
- the human-readable name of this PaperSize
-
getHeight
-
getName
-
getPpdName
Gets the PPD name of theGtkPaperSize, which may benull.- Returns:
- the PPD name of this PaperSize
-
getWidth
-
isCustom
public boolean isCustom()Returnstrueif this PaperSize is not a standard paper size.- Returns:
- whether this PaperSize is a custom paper size.
-
isEqual
Compares twoGtkPaperSizeobjects.- Parameters:
size2- anotherGtkPaperSizeobject- Returns:
true, if this PaperSize andsize2represent the same paper size
-
isIpp
public boolean isIpp()Returnstrueif this PaperSize is an IPP standard paper size.- Returns:
- whether this PaperSize is not an IPP custom paper size.
-
setSize
Changes the dimensions of a this PaperSize towidthxheight.- Parameters:
width- the new width in units ofunitheight- the new height in units ofunitunit- the unit forwidthandheight
-
toGvariant
Serialize a paper size to ana{sv}variant.- Returns:
- a new, floating,
GVariant
-
toKeyFile
-