org.gnu.pango
Class Layout

java.lang.Object
  |
  +--org.gnu.glib.GObject
        |
        +--org.gnu.pango.Layout

public class Layout
extends GObject

While complete access to the layout capabilities of Pango is provided using the detailed interfaces for itemization and shaping, using that functionality directly involves writing a fairly large amount of code. The objects and functions in this structure provide a high-level driver for formatting entire paragraphs of text at once.

The PangoLayout structure represents and entire paragraph of text. It is initialized with a PangoContext, UTF-8 string and set of attributes for that string. Once that is done, the set of formatted lines can be extracted from the object, the layout can be rendered, and conversion between logical character positions within the layout's text, and the physical position of the resulting glyphs can be made.


Constructor Summary
Layout(Context context)
          Construct a new Layout with the given Context.
Layout(int handle)
          Construct a new Layout with a handle that has been returned from a native call.
 
Method Summary
 Alignment getAlignment()
          Gets the alignment for the layout (how partial lines are positioned within the horizontal space available.)
 AttrList getAttributes()
          Gets the attribute list for the layout, if any
 int getIndent()
          Gets the amount by which the first line should be shorter than the rest of the lines.
 boolean getJustified()
          Gets whether or not each complete line should be stretched to fill the entire width of the layout.
 LayoutLine getLine(int line)
          Retrieves a particular line from a PangoLayout.
 int getLineCount()
          Retrieve the count of lines for the layout
 boolean getSingleParagraphMode()
          Obtains the value set by setSingleParagraphMode(boolean).
 int getSpacing()
          Gets the amount of spacing between the lines of the layout.
 java.lang.String getText()
          Gets the text in the layout.
 int getWidth()
          Gets the width to which the lines of the PangoLayout should be wrapped.
 WrapMode getWrapMode()
          Get the wrap mode for the layout.
 void setAlignment(Alignment alignment)
          Sets the alignment for the layout (how partial lines are positioned within the horizontal space available.)
 void setAttributes(AttrList attributes)
          Sets the text attributes for a layout object
 void setFontDescription(FontDescription desc)
          Set the default font description for the layout.
 void setIndent(int indent)
          Sets the amount by which the first line should be shorter than the rest of the lines.
 void setJustification(boolean justify)
          Sets whether or not each complete line should be stretched to fill the entire width of the layout.
 void setMarkup(java.lang.String markup)
          Same as setMarkup(String, char), but the markup text isn't scanned for accelerators.
 void setMarkup(java.lang.String markup, char accelMarker)
          Sets the layout text and attribute list from marked-up text (see markup format).
 void setSingleParagraphMode(boolean setting)
          If setting is TRUE, do not treat newlines and similar characters as paragraph separators; instead, keep all text in a single paragraph, and display a glyph for paragraph separator characters.
 void setSpacing(int spacing)
          Sets the amount of spacing between the lines of the layout.
 void setTabs(TabArray tabs)
          Sets the tabs to use for layout, overriding the default tabs (by default, tabs are every 8 spaces).
 void setText(java.lang.String text)
          Set the text of the layout.
 void setWidth(int width)
          Sets the width to which the lines of the PangoLayout should be wrapped.
 void setWrapStyle(WrapMode wrap)
          Sets the wrap style; the wrap style only has an effect if a width is set on the layout with setWidth(int)To turn off wrapping, set the width to -1.
 
Methods inherited from class org.gnu.glib.GObject
addEventHandler, addEventHandler, addEventHandler, addEventHandler, addEventHandler, addEventHandler, equals, getData, getHandle, removeEventHandler, setData
 
Methods inherited from class java.lang.Object
getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Layout

public Layout(Context context)
Construct a new Layout with the given Context.


Layout

public Layout(int handle)
Construct a new Layout with a handle that has been returned from a native call.

Parameters:
handle - The handle to the native resource.
Method Detail

setText

public void setText(java.lang.String text)
Set the text of the layout.


getText

public java.lang.String getText()
Gets the text in the layout.


setMarkup

public void setMarkup(java.lang.String markup,
                      char accelMarker)
Sets the layout text and attribute list from marked-up text (see markup format). Replaces the current text and attribute list.

If accelMarker is nonzero, the given character will mark the character following it as an accelerator. For example, the accel marker might be an ampersand or underscore. All characters marked as an accelerator will receive a Underline.LOW attribute. Two accelMarker characters following each other produce a single literal accelMarker character.

Parameters:
markup - some marked-up text
accelMarker - : marker for accelerators in the text

setMarkup

public void setMarkup(java.lang.String markup)
Same as setMarkup(String, char), but the markup text isn't scanned for accelerators.


setAttributes

public void setAttributes(AttrList attributes)
Sets the text attributes for a layout object


getAttributes

public AttrList getAttributes()
Gets the attribute list for the layout, if any


setFontDescription

public void setFontDescription(FontDescription desc)
Set the default font description for the layout. If no font description is set on the layout, the font description from the layout's context is used.


setWidth

public void setWidth(int width)
Sets the width to which the lines of the PangoLayout should be wrapped.


getWidth

public int getWidth()
Gets the width to which the lines of the PangoLayout should be wrapped.


setWrapStyle

public void setWrapStyle(WrapMode wrap)
Sets the wrap style; the wrap style only has an effect if a width is set on the layout with setWidth(int)To turn off wrapping, set the width to -1.


getWrapMode

public WrapMode getWrapMode()
Get the wrap mode for the layout.


setIndent

public void setIndent(int indent)
Sets the amount by which the first line should be shorter than the rest of the lines. This may be negative, in which case the subsequent lines will be shorter than the first line. (However, in either case, the entire width of the layout will be given by the value


getIndent

public int getIndent()
Gets the amount by which the first line should be shorter than the rest of the lines.


getSpacing

public int getSpacing()
Gets the amount of spacing between the lines of the layout.

Returns:
the spacing (in thousandths of a device unit)

setSpacing

public void setSpacing(int spacing)
Sets the amount of spacing between the lines of the layout.


setJustification

public void setJustification(boolean justify)
Sets whether or not each complete line should be stretched to fill the entire width of the layout. This stretching is typically done by adding whitespace, but for some scripts (such as Arabic), the justification is done by extending the characters.


getJustified

public boolean getJustified()
Gets whether or not each complete line should be stretched to fill the entire width of the layout.


setAlignment

public void setAlignment(Alignment alignment)
Sets the alignment for the layout (how partial lines are positioned within the horizontal space available.)


getAlignment

public Alignment getAlignment()
Gets the alignment for the layout (how partial lines are positioned within the horizontal space available.)


setTabs

public void setTabs(TabArray tabs)
Sets the tabs to use for layout, overriding the default tabs (by default, tabs are every 8 spaces).


setSingleParagraphMode

public void setSingleParagraphMode(boolean setting)
If setting is TRUE, do not treat newlines and similar characters as paragraph separators; instead, keep all text in a single paragraph, and display a glyph for paragraph separator characters. Used when you want to allow editing of newlines on a single text line.


getSingleParagraphMode

public boolean getSingleParagraphMode()
Obtains the value set by setSingleParagraphMode(boolean).


getLineCount

public int getLineCount()
Retrieve the count of lines for the layout


getLine

public LayoutLine getLine(int line)
Retrieves a particular line from a PangoLayout.

Parameters:
line - the index of a line, which must be between 0 and pango_layout_get_line_count(layout) - 1, inclusive.
Returns:
the requested PangoLayoutLine.

Please send any bug reports, comments, or suggestions for the API or documentation to java-gnome-developer@lists.sf.net