nsbaci 1.0
Loading...
Searching...
No Matches
codeeditor.h
Go to the documentation of this file.
1
9
10#ifndef CODEEDITOR_H
11#define CODEEDITOR_H
12
13#include <QPlainTextEdit>
14#include <QWidget>
15
16class LineNumberArea;
17
18class CodeEditor : public QPlainTextEdit {
19 Q_OBJECT
20
21 public:
22 explicit CodeEditor(QWidget* parent = nullptr);
23
24 void lineNumberAreaPaintEvent(QPaintEvent* event);
25 int lineNumberAreaWidth();
26
27 protected:
28 void resizeEvent(QResizeEvent* event) override;
29
30 private slots:
31 void updateLineNumberAreaWidth(int newBlockCount);
32 void highlightCurrentLine();
33 void updateLineNumberArea(const QRect& rect, int dy);
34
35 private:
36 LineNumberArea* lineNumberArea;
37};
38
39class LineNumberArea : public QWidget {
40 public:
41 explicit LineNumberArea(CodeEditor* editor)
42 : QWidget(editor), codeEditor(editor) {}
43
44 QSize sizeHint() const override {
45 return QSize(codeEditor->lineNumberAreaWidth(), 0);
46 }
47
48 protected:
49 void paintEvent(QPaintEvent* event) override {
50 codeEditor->lineNumberAreaPaintEvent(event);
51 }
52
53 private:
54 CodeEditor* codeEditor;
55};
56
57#endif // CODEEDITOR_H
Definition codeeditor.h:18
Definition codeeditor.h:39