Qt Jambi Home

com.trolltech.qt.gui
Class QAbstractTextDocumentLayout

java.lang.Object
  extended by com.trolltech.qt.QSignalEmitter
      extended by com.trolltech.qt.QtJambiObject
          extended by com.trolltech.qt.core.QObject
              extended by com.trolltech.qt.gui.QAbstractTextDocumentLayout
All Implemented Interfaces:
QtJambiInterface

public abstract class QAbstractTextDocumentLayout
extends QObject

The QAbstractTextDocumentLayout class is an abstract base class used to implement custom layouts for QTextDocuments.

The standard layout provided by Qt can handle simple word processing including inline layouts, lists and tables.

Some applications (e.g. a word processor or a DTP application) might need more features than the ones provided by Qt's layout engine, in which case you can subclass QAbstractTextDocumentLayout to provide your own custom layout behavior for your text documents.


Nested Class Summary
 
Nested classes/interfaces inherited from class com.trolltech.qt.QSignalEmitter
QSignalEmitter.Signal0, QSignalEmitter.Signal1<A>, QSignalEmitter.Signal2<A,B>, QSignalEmitter.Signal3<A,B,C>, QSignalEmitter.Signal4<A,B,C,D>, QSignalEmitter.Signal5<A,B,C,D,E>, QSignalEmitter.Signal6<A,B,C,D,E,F>, QSignalEmitter.Signal7<A,B,C,D,E,F,G>, QSignalEmitter.Signal8<A,B,C,D,E,F,G,H>, QSignalEmitter.Signal9<A,B,C,D,E,F,G,H,I>
 
Field Summary
 QSignalEmitter.Signal1<QSizeF> documentSizeChanged
          This signal is emitted when the size of the document changes.
 QSignalEmitter.Signal1<java.lang.Integer> pageCountChanged
          This signal is emitted when the number of pages in the layout changes; newPages is the updated page count.
 QSignalEmitter.Signal1<QRectF> update
          This signal is emitted when the rectangle arg__1 has been updated.
 
Constructor Summary
QAbstractTextDocumentLayout(QTextDocument doc)
          Creates a new text document layout for the given doc.
 
Method Summary
 java.lang.String anchorAt(QPointF pos)
          Returns the reference of the anchor at the given pos, or an empty string if no anchor exists at that point.
abstract  QRectF blockBoundingRect(QTextBlock block)
          Returns the bounding rectangle of block.
 QTextDocument document()
          Returns the text document that this layout is operating on.
protected abstract  void documentChanged(int from, int charsRemoved, int charsAdded)
          This function is called whenever the contents of the document change.
abstract  QSizeF documentSize()
          Returns the total size of the document.
abstract  void draw(QPainter painter, QAbstractTextDocumentLayout_PaintContext context)
          Draws the layout on the given painter with the given context.
protected  void drawInlineObject(QPainter painter, QRectF rect, QTextInlineObject object, int posInDocument, QTextFormat format)
          Called to draw the inline object object on the given painter within the rectangle specified by rect using the text format specified by format.
protected  QTextCharFormat format(int pos)
          Returns the character format that is applicable at the given pos.
protected  int formatIndex(int pos)
          
abstract  QRectF frameBoundingRect(QTextFrame frame)
          Returns the bounding rectacle of frame.
static QAbstractTextDocumentLayout fromNativePointer(QNativePointer nativePointer)
          This function returns the QAbstractTextDocumentLayout instance pointed to by nativePointer
 QTextObjectInterface handlerForObject(int objectType)
          Returns a handler for objects of the given objectType.
abstract  int hitTest(QPointF point, Qt.HitTestAccuracy accuracy)
          Returns the cursor postion for the given point with the accuracy specified.
abstract  int pageCount()
          Returns the number of pages required by the layout.
 QPaintDeviceInterface paintDevice()
          Returns the paint device used to render the document's layout.
protected  void positionInlineObject(QTextInlineObject item, int posInDocument, QTextFormat format)
          Lays out the inline object item using the given text format.
 void registerHandler(int objectType, QObject component)
          Registers the given component as a handler for items of the given objectType.
protected  void resizeInlineObject(QTextInlineObject item, int posInDocument, QTextFormat format)
          Sets the size of the inline object item in accordance with the text format.
 void setPaintDevice(QPaintDeviceInterface device)
          Sets the paint device used for rendering the document's layout to the given device.
 
Methods inherited from class com.trolltech.qt.core.QObject
blockSignals, childEvent, children, connectSlotsByName, customEvent, disposeLater, dumpObjectInfo, dumpObjectTree, dynamicPropertyNames, event, eventFilter, findChild, findChild, findChild, findChildren, findChildren, findChildren, findChildren, installEventFilter, isWidgetType, killTimer, moveToThread, objectName, parent, property, removeEventFilter, setObjectName, setParent, setProperty, signalsBlocked, startTimer, thread, timerEvent
 
Methods inherited from class com.trolltech.qt.QtJambiObject
dispose, disposed, finalize, reassignNativeResources, tr, tr, tr
 
Methods inherited from class com.trolltech.qt.QSignalEmitter
disconnect, disconnect, signalSender
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.trolltech.qt.QtJambiInterface
disableGarbageCollection, nativeId, nativePointer, reenableGarbageCollection, setJavaOwnership
 

Field Detail

documentSizeChanged

public final QSignalEmitter.Signal1<QSizeF> documentSizeChanged

This signal is emitted when the size of the document changes. The new size is specified by newSize.

This information is useful to widgets that display text documents since it enables them to update their scroll bars correctly.

Compatible Slot Signatures:
void mySlot(com.trolltech.qt.core.QSizeF newSize)
void mySlot()
See Also:
documentSize


pageCountChanged

public final QSignalEmitter.Signal1<java.lang.Integer> pageCountChanged

This signal is emitted when the number of pages in the layout changes; newPages is the updated page count.

Changes to the page count are due to the changes to the layout or the document content itself.

Compatible Slot Signatures:
void mySlot(int newPages)
void mySlot()
See Also:
pageCount


update

public final QSignalEmitter.Signal1<QRectF> update

This signal is emitted when the rectangle arg__1 has been updated.

Compatible Slot Signatures:
void mySlot(com.trolltech.qt.core.QRectF arg__1)
void mySlot()

Constructor Detail

QAbstractTextDocumentLayout

public QAbstractTextDocumentLayout(QTextDocument doc)

Creates a new text document layout for the given doc.

Method Detail

anchorAt

public final java.lang.String anchorAt(QPointF pos)

Returns the reference of the anchor at the given pos, or an empty string if no anchor exists at that point.


document

public final QTextDocument document()

Returns the text document that this layout is operating on.


format

protected final QTextCharFormat format(int pos)

Returns the character format that is applicable at the given pos.


formatIndex

protected final int formatIndex(int pos)


handlerForObject

public final QTextObjectInterface handlerForObject(int objectType)

Returns a handler for objects of the given objectType.


paintDevice

public final QPaintDeviceInterface paintDevice()

Returns the paint device used to render the document's layout.

See Also:
setPaintDevice

registerHandler

public final void registerHandler(int objectType,
                                  QObject component)

Registers the given component as a handler for items of the given objectType.


setPaintDevice

public final void setPaintDevice(QPaintDeviceInterface device)

Sets the paint device used for rendering the document's layout to the given device.

See Also:
paintDevice

blockBoundingRect

public abstract QRectF blockBoundingRect(QTextBlock block)

Returns the bounding rectangle of block.


documentChanged

protected abstract void documentChanged(int from,
                                        int charsRemoved,
                                        int charsAdded)

This function is called whenever the contents of the document change. A change occurs when text is inserted, removed, or a combination of the two types of operation. The change is specified by from, charsRemoved, and charsAdded corresponding to the starting character position of the change, the number of character removed from the document, and the number of characters added.

For example, when inserting the text "Hello" into an empty document, charsRemoved would be 0 and charsAdded would be 5 (the length of the string).

Replacing text is the combination of removal and insertion. For example, if the text "Hello" gets replaced by "Hi", charsRemoved would be 5 and charsAdded would be 2.


documentSize

public abstract QSizeF documentSize()

Returns the total size of the document. This is useful to display widgets since they can use to information to update their scroll bars correctly

See Also:
documentSizeChanged, QTextDocument::pageSize

draw

public abstract void draw(QPainter painter,
                          QAbstractTextDocumentLayout_PaintContext context)

Draws the layout on the given painter with the given context.


drawInlineObject

protected void drawInlineObject(QPainter painter,
                                QRectF rect,
                                QTextInlineObject object,
                                int posInDocument,
                                QTextFormat format)

Called to draw the inline object object on the given painter within the rectangle specified by rect using the text format specified by format. posInDocument specifies the position of the object within the document.

See Also:
draw

frameBoundingRect

public abstract QRectF frameBoundingRect(QTextFrame frame)

Returns the bounding rectacle of frame. Returns the bounding rectangle of frame.


hitTest

public abstract int hitTest(QPointF point,
                            Qt.HitTestAccuracy accuracy)

Returns the cursor postion for the given point with the accuracy specified. Returns -1 to indicate failure if no valid cursor position was found.


pageCount

public abstract int pageCount()

Returns the number of pages required by the layout.

See Also:
pageCountChanged

positionInlineObject

protected void positionInlineObject(QTextInlineObject item,
                                    int posInDocument,
                                    QTextFormat format)

Lays out the inline object item using the given text format. The base class implementation does nothing. posInDocument specifies the position of the object within the document.

See Also:
drawInlineObject

resizeInlineObject

protected void resizeInlineObject(QTextInlineObject item,
                                  int posInDocument,
                                  QTextFormat format)

Sets the size of the inline object item in accordance with the text format. posInDocument specifies the position of the object within the document.


fromNativePointer

public static QAbstractTextDocumentLayout fromNativePointer(QNativePointer nativePointer)
This function returns the QAbstractTextDocumentLayout instance pointed to by nativePointer

Parameters:
nativePointer - the QNativePointer of which object should be returned.

Qt Jambi Home