1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88
|
#pragma once
// Qt
#include <QObject> // Required for inheritance
#include <QTextObjectInterface> // Required for inheritance
class QSyntaxStyle;
/**
* @brief Class, that describes
* attribute for making text frame.
*/
class QFramedTextAttribute : public QObject,
public QTextObjectInterface
{
Q_OBJECT
Q_INTERFACES(QTextObjectInterface)
public:
enum Property
{
FramedString = 1
};
/**
* @brief Static method for getting framed text
* attribute type.
*/
static int type();
/**
* @brief Constructor.
* @param parent Pointer to parent QObject.
*/
explicit QFramedTextAttribute(QObject* parent=nullptr);
// Disable copying
QFramedTextAttribute(const QFramedTextAttribute&) = delete;
QFramedTextAttribute& operator=(const QFramedTextAttribute&) = delete;
/**
* @brief Method for getting custom element (frame)
* size. Though frame symbol has no size, this
* method returns {0, 0}
*/
QSizeF intrinsicSize(QTextDocument *doc,
int posInDocument,
const QTextFormat &format) override;
/**
* @brief Method for drawing frame.
*/
void drawObject(QPainter *painter,
const QRectF &rect,
QTextDocument *doc,
int posInDocument,
const QTextFormat &format) override;
/**
* @brief Method for creating frame in cursor
* selection.
* @param cursor Cursor.
*/
void frame(QTextCursor cursor);
/**
* @brief Method for clearing all frames
* with desired cursor.
*/
void clear(QTextCursor cursor);
/**
* @brief Method for setting syntax style
* for rendering.
*/
void setSyntaxStyle(QSyntaxStyle* style);
/**
* @brief Method for getting syntax style.
*/
QSyntaxStyle* syntaxStyle() const;
private:
QSyntaxStyle* m_style;
};
|