void TextDocument::drawBackground(QPainter* painter, const QRect& bounds) { if (d.highlights.isEmpty() && d.lowlight == -1) return; const int margin = qCeil(documentMargin()); const QAbstractTextDocumentLayout* layout = documentLayout(); static QPointer<TextLowlight> lowlightFrame = 0; if (!lowlightFrame) lowlightFrame = new TextLowlight(static_cast<QWidget*>(painter->device())); static QPointer<TextHighlight> highlightFrame = 0; if (!highlightFrame) highlightFrame = new TextHighlight(static_cast<QWidget*>(painter->device())); if (d.lowlight != -1) { const QAbstractTextDocumentLayout* layout = documentLayout(); const int margin = qCeil(documentMargin()); const QTextBlock to = findBlockByNumber(d.lowlight); if (to.isValid()) { QRect br = layout->blockBoundingRect(to).toAlignedRect(); br.setTop(0); if (bounds.intersects(br)) { br.adjust(-margin - 1, 0, margin + 1, 2); painter->translate(br.topLeft()); lowlightFrame->setGeometry(br); lowlightFrame->render(painter); painter->translate(-br.topLeft()); } } } foreach (int highlight, d.highlights) { QTextBlock block = findBlockByNumber(highlight); if (block.isValid()) { QRect br = layout->blockBoundingRect(block).toAlignedRect(); if (bounds.intersects(br)) { br.adjust(-margin - 1, 0, margin + 1, 2); painter->translate(br.topLeft()); highlightFrame->setGeometry(br); highlightFrame->render(painter); painter->translate(-br.topLeft()); } } } }
int QTextDocument::qt_metacall(QMetaObject::Call _c, int _id, void **_a) { _id = QObject::qt_metacall(_c, _id, _a); if (_id < 0) return _id; if (_c == QMetaObject::InvokeMetaMethod) { if (_id < 14) qt_static_metacall(this, _c, _id, _a); _id -= 14; } #ifndef QT_NO_PROPERTIES else if (_c == QMetaObject::ReadProperty) { void *_v = _a[0]; switch (_id) { case 0: *reinterpret_cast< bool*>(_v) = isUndoRedoEnabled(); break; case 1: *reinterpret_cast< bool*>(_v) = isModified(); break; case 2: *reinterpret_cast< QSizeF*>(_v) = pageSize(); break; case 3: *reinterpret_cast< QFont*>(_v) = defaultFont(); break; case 4: *reinterpret_cast< bool*>(_v) = useDesignMetrics(); break; case 5: *reinterpret_cast< QSizeF*>(_v) = size(); break; case 6: *reinterpret_cast< qreal*>(_v) = textWidth(); break; case 7: *reinterpret_cast< int*>(_v) = blockCount(); break; case 8: *reinterpret_cast< qreal*>(_v) = indentWidth(); break; case 9: *reinterpret_cast< QString*>(_v) = defaultStyleSheet(); break; case 10: *reinterpret_cast< int*>(_v) = maximumBlockCount(); break; case 11: *reinterpret_cast< qreal*>(_v) = documentMargin(); break; } _id -= 12; } else if (_c == QMetaObject::WriteProperty) { void *_v = _a[0]; switch (_id) { case 0: setUndoRedoEnabled(*reinterpret_cast< bool*>(_v)); break; case 1: setModified(*reinterpret_cast< bool*>(_v)); break; case 2: setPageSize(*reinterpret_cast< QSizeF*>(_v)); break; case 3: setDefaultFont(*reinterpret_cast< QFont*>(_v)); break; case 4: setUseDesignMetrics(*reinterpret_cast< bool*>(_v)); break; case 6: setTextWidth(*reinterpret_cast< qreal*>(_v)); break; case 8: setIndentWidth(*reinterpret_cast< qreal*>(_v)); break; case 9: setDefaultStyleSheet(*reinterpret_cast< QString*>(_v)); break; case 10: setMaximumBlockCount(*reinterpret_cast< int*>(_v)); break; case 11: setDocumentMargin(*reinterpret_cast< qreal*>(_v)); break; } _id -= 12; } else if (_c == QMetaObject::ResetProperty) { _id -= 12; } else if (_c == QMetaObject::QueryPropertyDesignable) { _id -= 12; } else if (_c == QMetaObject::QueryPropertyScriptable) { _id -= 12; } else if (_c == QMetaObject::QueryPropertyStored) { _id -= 12; } else if (_c == QMetaObject::QueryPropertyEditable) { _id -= 12; } else if (_c == QMetaObject::QueryPropertyUser) { _id -= 12; } #endif // QT_NO_PROPERTIES return _id; }
int QTextDocument::qt_metacall(QMetaObject::Call _c, int _id, void **_a) { _id = QObject::qt_metacall(_c, _id, _a); if (_id < 0) return _id; if (_c == QMetaObject::InvokeMetaMethod) { switch (_id) { case 0: contentsChange((*reinterpret_cast< int(*)>(_a[1])),(*reinterpret_cast< int(*)>(_a[2])),(*reinterpret_cast< int(*)>(_a[3]))); break; case 1: contentsChanged(); break; case 2: undoAvailable((*reinterpret_cast< bool(*)>(_a[1]))); break; case 3: redoAvailable((*reinterpret_cast< bool(*)>(_a[1]))); break; case 4: undoCommandAdded(); break; case 5: modificationChanged((*reinterpret_cast< bool(*)>(_a[1]))); break; case 6: cursorPositionChanged((*reinterpret_cast< const QTextCursor(*)>(_a[1]))); break; case 7: blockCountChanged((*reinterpret_cast< int(*)>(_a[1]))); break; case 8: documentLayoutChanged(); break; case 9: undo(); break; case 10: redo(); break; case 11: appendUndoItem((*reinterpret_cast< QAbstractUndoItem*(*)>(_a[1]))); break; case 12: setModified((*reinterpret_cast< bool(*)>(_a[1]))); break; case 13: setModified(); break; default: ; } _id -= 14; } #ifndef QT_NO_PROPERTIES else if (_c == QMetaObject::ReadProperty) { void *_v = _a[0]; switch (_id) { case 0: *reinterpret_cast< bool*>(_v) = isUndoRedoEnabled(); break; case 1: *reinterpret_cast< bool*>(_v) = isModified(); break; case 2: *reinterpret_cast< QSizeF*>(_v) = pageSize(); break; case 3: *reinterpret_cast< QFont*>(_v) = defaultFont(); break; case 4: *reinterpret_cast< bool*>(_v) = useDesignMetrics(); break; case 5: *reinterpret_cast< QSizeF*>(_v) = size(); break; case 6: *reinterpret_cast< qreal*>(_v) = textWidth(); break; case 7: *reinterpret_cast< int*>(_v) = blockCount(); break; case 8: *reinterpret_cast< qreal*>(_v) = indentWidth(); break; case 9: *reinterpret_cast< QString*>(_v) = defaultStyleSheet(); break; case 10: *reinterpret_cast< int*>(_v) = maximumBlockCount(); break; case 11: *reinterpret_cast< qreal*>(_v) = documentMargin(); break; } _id -= 12; } else if (_c == QMetaObject::WriteProperty) { void *_v = _a[0]; switch (_id) { case 0: setUndoRedoEnabled(*reinterpret_cast< bool*>(_v)); break; case 1: setModified(*reinterpret_cast< bool*>(_v)); break; case 2: setPageSize(*reinterpret_cast< QSizeF*>(_v)); break; case 3: setDefaultFont(*reinterpret_cast< QFont*>(_v)); break; case 4: setUseDesignMetrics(*reinterpret_cast< bool*>(_v)); break; case 6: setTextWidth(*reinterpret_cast< qreal*>(_v)); break; case 8: setIndentWidth(*reinterpret_cast< qreal*>(_v)); break; case 9: setDefaultStyleSheet(*reinterpret_cast< QString*>(_v)); break; case 10: setMaximumBlockCount(*reinterpret_cast< int*>(_v)); break; case 11: setDocumentMargin(*reinterpret_cast< qreal*>(_v)); break; } _id -= 12; } else if (_c == QMetaObject::ResetProperty) { _id -= 12; } else if (_c == QMetaObject::QueryPropertyDesignable) { _id -= 12; } else if (_c == QMetaObject::QueryPropertyScriptable) { _id -= 12; } else if (_c == QMetaObject::QueryPropertyStored) { _id -= 12; } else if (_c == QMetaObject::QueryPropertyEditable) { _id -= 12; } else if (_c == QMetaObject::QueryPropertyUser) { _id -= 12; } #endif // QT_NO_PROPERTIES return _id; }