-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcodeeditor.h
95 lines (78 loc) · 2.33 KB
/
codeeditor.h
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
89
90
91
92
93
94
95
#ifndef CODEEDITOR_H
#define CODEEDITOR_H
#include <QPlainTextEdit>
class LineNumberArea;
/**
* @brief The CodeEditor class defines a text editor for code (used for specification and properties)
*/
class CodeEditor : public QPlainTextEdit
{
Q_OBJECT
public:
/**
* @brief CodeEditor Constructor
* @param parent The parent of this widget
* @param spec Whether this code editor is to create a specification (else a property)
*/
explicit CodeEditor(QWidget *parent = 0, bool spec = false);
/**
* @brief lineNumberAreaPaintEvent Paints the line number area on the screen
* @param event A paint event
*/
void lineNumberAreaPaintEvent(QPaintEvent *event);
/**
* @brief lineNumberAreaWidth Computes the width needed for the line number area
* @return The width needed for the line number area
*/
int lineNumberAreaWidth();
public slots:
/**
* @brief deleteChar Allows the user to delete text
*/
void deleteChar();
protected:
/**
* @brief resizeEvent Resizes the line number area when the window is resized
* @param e The resize event
*/
void resizeEvent(QResizeEvent *event) override;
private:
QWidget *lineNumberArea;
private slots:
/**
* @brief updateLineNumberAreaWidth Updates the width of the line number area
*/
void updateLineNumberAreaWidth(int);
/**
* @brief updateLineNumberArea Updates the line number area after the scrollbar has been used
* @param rect The rectangle that covers the line number area
* @param dy The amount of pixels scrolled
*/
void updateLineNumberArea(const QRect &, int);
};
/**
* @brief The LineNumberArea class defines the area with line numbers in the code editor
*/
class LineNumberArea : public QWidget
{
public:
/**
* @brief LineNumberArea Constructor
* @param editor The code editor this line number area belongs to
*/
LineNumberArea(CodeEditor *editor);
/**
* @brief sizeHint Returns the recommended size of the widget
* @return The recommended size of the widget
*/
QSize sizeHint() const override;
protected:
/**
* @brief paintEvent Handles paint events
* @param event A paint event
*/
void paintEvent(QPaintEvent *event) override;
private:
CodeEditor *codeEditor;
};
#endif // CODEEDITOR_H