| 1 | #pragma once |
| 2 | |
| 3 | // Qt |
| 4 | #include <QWidget> // Required for inheritance |
| 5 | |
| 6 | class QCodeEditor; |
| 7 | class QSyntaxStyle; |
| 8 | |
| 9 | /** |
| 10 | * @brief Class, that describes line number area widget. |
| 11 | */ |
| 12 | class QLineNumberArea : public QWidget |
| 13 | { |
| 14 | Q_OBJECT |
| 15 | |
| 16 | public: |
| 17 | |
| 18 | /** |
| 19 | * @brief Constructor. |
| 20 | * @param parent Pointer to parent QTextEdit widget. |
| 21 | */ |
| 22 | explicit QLineNumberArea(QCodeEditor* parent=nullptr); |
| 23 | |
| 24 | // Disable copying |
| 25 | QLineNumberArea(const QLineNumberArea&) = delete; |
| 26 | QLineNumberArea& operator=(const QLineNumberArea&) = delete; |
| 27 | |
| 28 | /** |
| 29 | * @brief Overridden method for getting line number area |
| 30 | * size. |
| 31 | */ |
| 32 | QSize sizeHint() const override; |
| 33 | |
| 34 | /** |
| 35 | * @brief Method for setting syntax style object. |
| 36 | * @param style Pointer to syntax style. |
| 37 | */ |
| 38 | void setSyntaxStyle(QSyntaxStyle* style); |
| 39 | |
| 40 | /** |
| 41 | * @brief Method for getting syntax style. |
| 42 | * @return Pointer to syntax style. |
| 43 | */ |
| 44 | QSyntaxStyle* syntaxStyle() const; |
| 45 | |
| 46 | protected: |
| 47 | void paintEvent(QPaintEvent* event) override; |
| 48 | |
| 49 | private: |
| 50 | |
| 51 | QSyntaxStyle* m_syntaxStyle; |
| 52 | |
| 53 | QCodeEditor* m_codeEditParent; |
| 54 | |
| 55 | }; |
| 56 |