public class TextPrint extends java.lang.Object implements Print
TextPrints are never greedy with layout space, even with center- or right-alignment. (Greedy prints take up all the available space on the page.) Therefore, when center- or right-alignment is required, it is necessary to wrap the text in a Print which will enforce the same alignment. Usually this is a center:default:grow or right:default:grow column in a GridPrint.
Modifier and Type | Field and Description |
---|---|
static int |
DEFAULT_ALIGN
The default alignment for TextPrint.
|
static org.eclipse.swt.graphics.FontData |
DEFAULT_FONT_DATA
The default font data for a TextPrint.
|
static java.lang.String |
DEFAULT_TEXT
The default text for a TextPrint.
|
(package private) TextStyle |
style |
(package private) java.lang.String |
text |
(package private) boolean |
wordSplitting |
Constructor and Description |
---|
TextPrint()
Constructs a TextPrint with the default properties.
|
TextPrint(java.lang.String text)
Constructs a TextPrint with the given text.
|
TextPrint(java.lang.String text,
org.eclipse.swt.graphics.FontData fontData)
Constructs a TextPrint with the given text and font data.
|
TextPrint(java.lang.String text,
org.eclipse.swt.graphics.FontData fontData,
int align)
Constructs a TextPrint with the given text, font data, and alignment.
|
TextPrint(java.lang.String text,
int align)
Constructs a TextPrint with the give text and alignment.
|
TextPrint(java.lang.String text,
TextStyle style)
Constructs a TextPrint with the given text and style.
|
Modifier and Type | Method and Description |
---|---|
boolean |
equals(java.lang.Object obj) |
int |
getAlignment()
Returns the horizontal text alignment.
|
org.eclipse.swt.graphics.RGB |
getBackground()
Returns the background color.
|
org.eclipse.swt.graphics.FontData |
getFontData()
Returns the font that will be used to print the text.
|
org.eclipse.swt.graphics.RGB |
getForeground()
Returns the foreground color.
|
boolean |
getStrikeout()
Returns the strikout flag.
|
TextStyle |
getStyle()
Returns the text style.
|
java.lang.String |
getText()
Returns the text that will be printed.
|
boolean |
getUnderline()
Returns the underline flag.
|
boolean |
getWordSplitting()
Returns whether word splitting is enabled.
|
int |
hashCode() |
PrintIterator |
iterator(org.eclipse.swt.graphics.Device device,
org.eclipse.swt.graphics.GC gc)
Returns a PrintIterator for laying out the contents of this Print.
|
void |
setAlignment(int alignment)
Sets the horizontal text alignment.
|
void |
setBackground(org.eclipse.swt.graphics.RGB background)
Sets the background color to the argument.
|
void |
setFontData(org.eclipse.swt.graphics.FontData fontData)
Sets the font that will be used to print the text.
|
void |
setForeground(org.eclipse.swt.graphics.RGB foreground)
Sets the foreground color to the argument.
|
void |
setStrikeout(boolean strikeout)
Sets the strikeout flag to the argument.
|
void |
setStyle(TextStyle style)
Sets the text style to the argument.
|
void |
setText(java.lang.String text)
Sets the text that will be printed.
|
void |
setUnderline(boolean underline)
Sets the underline flag to the argument.
|
void |
setWordSplitting(boolean wordBreaking)
Sets whether word splitting is enabled.
|
public static final java.lang.String DEFAULT_TEXT
public static final org.eclipse.swt.graphics.FontData DEFAULT_FONT_DATA
public static final int DEFAULT_ALIGN
java.lang.String text
TextStyle style
boolean wordSplitting
public TextPrint()
public TextPrint(java.lang.String text)
text
- the text to print.public TextPrint(java.lang.String text, org.eclipse.swt.graphics.FontData fontData)
text
- the text to print.fontData
- the font that will be used to print the text.public TextPrint(java.lang.String text, int align)
text
- the text to print.align
- the horizontal text alignment. Must be one of SWT.LEFT
, SWT.CENTER
or SWT.RIGHT
.public TextPrint(java.lang.String text, org.eclipse.swt.graphics.FontData fontData, int align)
text
- the text to print.fontData
- the font that will be used to print the text.align
- the horizontal text alignment. Must be one of SWT.LEFT
, SWT.CENTER
or SWT.RIGHT
.public TextPrint(java.lang.String text, TextStyle style)
text
- the text to print.style
- the style to apply to the text.public int hashCode()
hashCode
in class java.lang.Object
public boolean equals(java.lang.Object obj)
equals
in class java.lang.Object
public java.lang.String getText()
public void setText(java.lang.String text)
text
- the text to print.public TextStyle getStyle()
public void setStyle(TextStyle style)
style
- the new text style.public org.eclipse.swt.graphics.FontData getFontData()
public void setFontData(org.eclipse.swt.graphics.FontData fontData)
fontData
- the font that will be used to print the text.public int getAlignment()
SWT.LEFT
, SWT.CENTER
or SWT.RIGHT
.public void setAlignment(int alignment)
alignment
- the horizontal text alignment. Must be one of SWT.LEFT
, SWT.CENTER
or SWT.RIGHT
.public org.eclipse.swt.graphics.RGB getForeground()
public void setForeground(org.eclipse.swt.graphics.RGB foreground)
foreground
- the new foreground color. A null value causes the foreground
color to be inherited.public org.eclipse.swt.graphics.RGB getBackground()
public void setBackground(org.eclipse.swt.graphics.RGB background)
background
- the new background color. A null value causes the background
to be transparent.public boolean getUnderline()
public void setUnderline(boolean underline)
underline
- the underline flag.public boolean getStrikeout()
public void setStrikeout(boolean strikeout)
strikeout
- the strikeout flag.public boolean getWordSplitting()
public void setWordSplitting(boolean wordBreaking)
wordBreaking
- whether to allow word splitting.public PrintIterator iterator(org.eclipse.swt.graphics.Device device, org.eclipse.swt.graphics.GC gc)
Print