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
ConstructorDescriptionCallsPaperSize(java.lang.String)
with name =null
Creates a newGtkPaperSize
object 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 PaperSize
Creates a newGtkPaperSize
object with the given parameters.void
free()
Free the givenGtkPaperSize
object.static PaperSize
fromGvariant
(Variant variant) Deserialize a paper size from aGVariant
.static PaperSize
Creates a newGtkPaperSize
object by using IPP information.static PaperSize
fromKeyFile
(KeyFile keyFile, @Nullable String groupName) Reads a paper size from the groupgroupName
in the key filekeyFile
.static PaperSize
Creates a newGtkPaperSize
object by using PPD information.static String
Returns the name of the default paper size, which depends on the current locale.double
getDefaultBottomMargin
(Unit unit) Gets the default bottom margin for theGtkPaperSize
.double
getDefaultLeftMargin
(Unit unit) Gets the default left margin for theGtkPaperSize
.double
getDefaultRightMargin
(Unit unit) Gets the default right margin for theGtkPaperSize
.double
getDefaultTopMargin
(Unit unit) Gets the default top margin for theGtkPaperSize
.Gets the human-readable name of theGtkPaperSize
.double
Gets 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 Type
getType()
Get the GType of the PaperSize classdouble
Gets the paper width of theGtkPaperSize
, in units ofunit
.boolean
isCustom()
Returnstrue
if this PaperSize is not a standard paper size.boolean
Compares twoGtkPaperSize
objects.boolean
isIpp()
Returnstrue
if this PaperSize is an IPP standard paper size.void
Changes the dimensions of a this PaperSize towidth
xheight
.Serialize a paper size to ana{sv}
variant.void
This function adds the paper size from this PaperSize tokeyFile
.Methods inherited from class io.github.jwharm.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 newGtkPaperSize
object by parsing a PWG 5101.1-2002 paper name.If
name
isnull
, the default paper size is returned, seegetDefault()
.- Parameters:
name
- a paper size name
-
PaperSize
public PaperSize()CallsPaperSize(java.lang.String)
with name =null
-
-
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
GtkPaperSize
object
-
fromIpp
Creates a newGtkPaperSize
object by using IPP information.If
ippName
is not a recognized paper name,width
andheight
are used to construct a customGtkPaperSize
object.- 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 @Nullable String groupName) throws GErrorException Reads a paper size from the groupgroupName
in the key filekeyFile
.- Parameters:
keyFile
- theGKeyFile
to retrieve the papersize fromgroupName
- the name of the group in the key file to read, ornull
to read the first group- Returns:
- a new
GtkPaperSize
object with the restored paper size - Throws:
GErrorException
- seeGError
-
fromPpd
Creates a newGtkPaperSize
object by using PPD information.If
ppdName
is not a recognized PPD paper name,ppdDisplayName
,width
andheight
are used to construct a customGtkPaperSize
object.- 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 givenGtkPaperSize
object. -
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()Returnstrue
if this PaperSize is not a standard paper size.- Returns:
- whether this PaperSize is a custom paper size.
-
isEqual
Compares twoGtkPaperSize
objects.- Parameters:
size2
- anotherGtkPaperSize
object- Returns:
true
, if this PaperSize andsize2
represent the same paper size
-
isIpp
public boolean isIpp()Returnstrue
if 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 towidth
xheight
.- Parameters:
width
- the new width in units ofunit
height
- the new height in units ofunit
unit
- the unit forwidth
andheight
-
toGvariant
Serialize a paper size to ana{sv}
variant.- Returns:
- a new, floating,
GVariant
-
toKeyFile
-