CopperSpice API
1.9.2
|
An abstract base class used to implement custom layouts for QTextDocument. More...
Classes | |
class | PaintContext |
A nested class which defines the parameters used when painting a document layout More... | |
class | Selection |
A nested class which defines the parameters of a document selection More... | |
Public Signals | |
void | documentSizeChanged (const QSizeF &newSize) |
void | pageCountChanged (int newPages) |
void | update (const QRectF &rect=QRectF (0.0, 0.0, 1000000000.0, 1000000000.0)) |
void | updateBlock (const QTextBlock &block) |
Public Signals inherited from QObject | |
void | destroyed (QObject *obj=nullptr) |
void | objectNameChanged (const QString &objectName) |
Public Methods | |
QAbstractTextDocumentLayout (QTextDocument *doc) | |
QString | anchorAt (const QPointF &pos) const |
virtual QRectF | blockBoundingRect (const QTextBlock &block) const = 0 |
QTextDocument * | document () const |
virtual QSizeF | documentSize () const = 0 |
virtual void | draw (QPainter *painter, const PaintContext &context) = 0 |
virtual QRectF | frameBoundingRect (QTextFrame *frame) const = 0 |
QTextObjectInterface * | handlerForObject (int objectType) const |
virtual int | hitTest (const QPointF &point, Qt::HitTestAccuracy accuracy) const = 0 |
virtual int | pageCount () const = 0 |
QPaintDevice * | paintDevice () const |
void | registerHandler (int objectType, QObject *component) |
void | setPaintDevice (QPaintDevice *device) |
void | unregisterHandler (int objectType, QObject *component=nullptr) |
Public Methods inherited from QObject | |
QObject (QObject *parent=nullptr) | |
~QObject () | |
bool | blockSignals (bool block) |
const QList< QObject * > & | children () const |
bool | connect (const QObject *sender, const QString &signalMethod, const QString &location, const QString &slotMethod, Qt::ConnectionType type=Qt::AutoConnection) |
bool | connect (const QObject *sender, const QString &signalMethod, const QString &slotMethod, Qt::ConnectionType type=Qt::AutoConnection) |
bool | disconnect (const QObject *receiver, const QString &slotMethod=QString ()) const |
bool | disconnect (const QString &signalMethod, const QString &location, const QObject *receiver=nullptr, const QString &slotMethod=QString ()) const |
bool | disconnect (const QString &signalMethod=QString (), const QObject *receiver=nullptr, const QString &slotMethod=QString ()) const |
void | dumpObjectInfo () |
void | dumpObjectTree () |
QList< QString > | dynamicPropertyNames () const |
virtual bool | event (QEvent *event) |
virtual bool | eventFilter (QObject *watched, QEvent *event) |
template<typename T > | |
T | findChild (const QString &childName=QString ()) const |
template<class T > | |
QList< T > | findChildren (const QRegularExpression ®Exp, Qt::FindChildOptions options=Qt::FindChildrenRecursively) const |
template<class T > | |
QList< T > | findChildren (const QString &childName=QString (), Qt::FindChildOptions options=Qt::FindChildrenRecursively) const |
bool | inherits (const QString &className) const |
void | installEventFilter (QObject *filterObj) |
bool | isWidgetType () const |
bool | isWindowType () const |
void | killTimer (int id) |
const QMetaObject * | metaObject () const |
void | moveToThread (QThread *targetThread) |
QString | objectName () const |
QObject * | parent () const |
template<class T = QVariant> | |
T | property (const QString &name) const |
void | removeEventFilter (QObject *obj) |
void | setObjectName (const QString &name) |
void | setParent (QObject *parent) |
bool | setProperty (const QString &name, const QVariant &value) |
bool | signalsBlocked () const |
int | startTimer (int interval, Qt::TimerType timerType=Qt::CoarseTimer) |
QThread * | thread () const |
Protected Methods | |
virtual void | documentChanged (int pos, int charsRemoved, int charsAdded) = 0 |
virtual void | drawInlineObject (QPainter *painter, const QRectF &rect, QTextInlineObject object, int posInDocument, const QTextFormat &format) |
QTextCharFormat | format (int pos) |
virtual void | positionInlineObject (QTextInlineObject item, int posInDocument, const QTextFormat &format) |
virtual void | resizeInlineObject (QTextInlineObject item, int posInDocument, const QTextFormat &format) |
Protected Methods inherited from QObject | |
virtual void | childEvent (QChildEvent *event) |
virtual void | connectNotify (const QMetaMethod &signalMethod) const |
virtual void | customEvent (QEvent *event) |
virtual void | disconnectNotify (const QMetaMethod &signalMethod) const |
bool | isSignalConnected (const QMetaMethod &signalMethod) const |
int | receivers (const QString &signal) const |
QObject * | sender () const |
int | senderSignalIndex () const |
virtual void | timerEvent (QTimerEvent *event) |
Friends | |
class | QTextDocument |
class | QTextLayout |
class | QTextLine |
Additional Inherited Members | |
Public Slots inherited from QObject | |
void | deleteLater () |
Static Public Methods inherited from QObject | |
static bool | connect (const QObject *sender, const QMetaMethod &signalMethod, const QObject *receiver, const QMetaMethod &slotMethod, Qt::ConnectionType type=Qt::AutoConnection) |
static bool | connect (const QObject *sender, const QString &signalMethod, const QObject *receiver, const QString &slotMethod, Qt::ConnectionType type=Qt::AutoConnection, const QString &location=QString ()) |
static bool | connect (const QObject *sender, const QString &signalMethod, const QString &location, const QObject *receiver, const QString &slotMethod, Qt::ConnectionType type=Qt::AutoConnection) |
template<class Sender , class SignalClass , class... SignalArgs, class Receiver , class SlotClass , class... SlotArgs, class SlotReturn > | |
static bool | connect (const Sender *sender, void (SignalClass::*signalMethod)(SignalArgs...), const Receiver *receiver, SlotReturn (SlotClass::*slotMethod)(SlotArgs...), Qt::ConnectionType type=Qt::AutoConnection) |
template<class Sender , class SignalClass , class... SignalArgs, class Receiver , class T > | |
static bool | connect (const Sender *sender, void (SignalClass::*signalMethod)(SignalArgs...), const Receiver *receiver, T slotLambda, Qt::ConnectionType type=Qt::AutoConnection) |
static bool | disconnect (const QObject *sender, const QMetaMethod &signalMethod, const QObject *receiver, const QMetaMethod &slotMethod) |
static bool | disconnect (const QObject *sender, const QString &signalMethod, const QObject *receiver, const QString &slotMethod) |
static bool | disconnect (const QObject *sender, const QString &signalMethod, const QString &location, const QObject *receiver, const QString &slotMethod) |
static bool | disconnect (const QObject *sender, std::nullptr_t, const QObject *receiver, std::nullptr_t) |
template<class Sender , class SignalClass , class... SignalArgs, class Receiver , class SlotClass , class... SlotArgs, class SlotReturn > | |
static bool | disconnect (const Sender *sender, void (SignalClass::*signalMethod)(SignalArgs...), const Receiver *receiver, SlotReturn (SlotClass::*slotMethod)(SlotArgs...)) |
template<class Sender , class SignalClass , class... SignalArgs, class Receiver > | |
static bool | disconnect (const Sender *sender, void (SignalClass::*signalMethod)(SignalArgs...), const Receiver *receiver, std::nullptr_t slotMethod=nullptr) |
template<class Sender , class SignalClass , class... SignalArgs, class Receiver , class T > | |
static bool | disconnect (const Sender *sender, void (SignalClass::*signalMethod)(SignalArgs...), const Receiver *receiver, T slotMethod) |
static QMetaObject & | staticMetaObject () |
static QString | tr (const char *text, const char *comment=nullptr, std::optional< int > numArg=std::optional< int >()) |
Properties inherited from QObject | |
objectName | |
Related Functions inherited from QObject | |
T | qobject_cast (QObject *object) |
QObjectList | |
The QAbstractTextDocumentLayout class is an abstract base class used to implement custom layouts for QTextDocuments. The standard layout provided by CopperSpice can handle simple word processing including inline images, lists and tables.
Some applications, like a word processor or a DTP application, might need more features than the ones provided by the CopperSpice layout engine. In this case you can subclass QAbstractTextDocumentLayout to provide custom layout behavior for your text documents.
An instance of the QAbstractTextDocumentLayout subclass can be installed on a QTextDocument object with the setDocumentLayout() function. You can insert custom objects into a QTextDocument. Refer to the QTextObjectInterface class description for details.
|
explicit |
Constructs a new text document layout for the given doc.
Returns the reference of the anchor the given pos, or an empty string if no anchor exists at that point.
|
pure virtual |
Returns the bounding rectangle of block.
Implemented in QPlainTextDocumentLayout::blockBoundingRect()
QTextDocument * QAbstractTextDocumentLayout::document | ( | ) | const |
Returns the text document that this layout is operating on.
|
protectedpure virtual |
This method is called whenever the contents of the document change. A change occurs when text is inserted, removed, or a combination of these two. The change is specified by position, charsRemoved, and charsAdded corresponding to the starting character position of the change, the number of characters removed from the document, and the number of characters added.
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 a combination of removing and inserting. If the text "Hello" gets replaced by "Hi", charsRemoved would be 5 and charsAdded would be 2.
For subclasses of QAbstractTextDocumentLayout, this is the central function where a large portion of the work to lay out and position document contents is done.
For example, in a subclass that only arranges blocks of text, an implementation of this function would have to do the following:
Implemented in QPlainTextDocumentLayout::documentChanged()
|
pure virtual |
Returns the total size of the document's layout.
This information can be used by display widgets to update their scroll bars correctly.
Implemented in QPlainTextDocumentLayout::documentSize()
|
signal |
This signal is emitted when the size of the document layout changes to newSize.
Subclasses of QAbstractTextDocumentLayout should emit this signal when the document's entire layout size changes. This signal is useful for widgets that display text documents since it enables them to update their scroll bars correctly.
|
pure virtual |
Draws the layout with the given painter using the given context.
|
protectedvirtual |
This function is called to draw the inline object, object, with the given painter within the rectangle specified by rect using the specified text format.
posInDocument specifies the position of the object within the document.
The default implementation calls drawObject() on the object handlers. This function is called internally. Subclasses can reimplement this function to customize the drawing of inline objects.
|
protected |
Returns the character format that is applicable at the given pos.
|
pure virtual |
Returns the bounding rectangle of frame.
Implemented in QPlainTextDocumentLayout::frameBoundingRect()
QTextObjectInterface * QAbstractTextDocumentLayout::handlerForObject | ( | int | objectType | ) | const |
Returns a handler for objects of the given objectType.
|
pure virtual |
Returns the cursor position for the given point with the specified accuracy. Returns -1 if no valid cursor position was found.
Implemented in QPlainTextDocumentLayout::hitTest()
|
pure virtual |
Returns the number of pages contained in the layout.
Implemented in QPlainTextDocumentLayout::pageCount()
|
signal |
This signal is emitted when the number of pages in the layout changes; newPages is the updated page count.
Subclasses of QAbstractTextDocumentLayout should emit this signal when the number of pages in the layout has changed. Changes to the page count are caused by changes to the layout or the document content itself.
QPaintDevice * QAbstractTextDocumentLayout::paintDevice | ( | ) | const |
Returns the paint device used to render the document's layout.
|
protectedvirtual |
Lays out the inline object item using the given text format.
posInDocument specifies the position of the object within the document.
The default implementation does nothing. This function is called internally. Subclasses can reimplement this function to customize the position of inline objects.
void QAbstractTextDocumentLayout::registerHandler | ( | int | objectType, |
QObject * | component | ||
) |
Registers the given component as a handler for items of the given objectType.
|
protectedvirtual |
Sets the size of the inline object item corresponding to the text format.
posInDocument specifies the position of the object within the document.
The default implementation resizes the item to the size returned by the object handler's intrinsicSize() function. This function is called internally. Subclasses can reimplement this function to customize the resizing of inline objects.
void QAbstractTextDocumentLayout::setPaintDevice | ( | QPaintDevice * | device | ) |
Sets the paint device used for rendering the document's layout to the given device.
void QAbstractTextDocumentLayout::unregisterHandler | ( | int | objectType, |
QObject * | component = nullptr |
||
) |
Unregisters the given component as handler for items of the given objectType. Unregisters all handlers if the component is a nullptr.
|
signal |
This signal is emitted when the rectangle rect has been updated. Subclasses of QAbstractTextDocumentLayout should emit this signal when the layout of the contents change in order to repaint.
|
signal |
This signal is emitted when the specified block has been updated. Subclasses of QAbstractTextDocumentLayout should emit this signal when the layout of block has changed in order to repaint.