umbrello 2.32.3 Umbrello UML Modeller is a Unified Modelling Language (UML) diagram program based on KDE Technology

codetextedit.h
Go to the documentation of this file.
1 /*
2 CodeTextEdit: Text edit widget with line numbers and highlighted current line.
3 Copyright 2010 Nokia Corporation and/or its subsidiary(-ies) <qt-info@nokia.com>
4 Code based on examples of the Qt Toolkit under BSD license,
5 <http://doc.qt.nokia.com/4.6/widgets-codeeditor.html>.
6 Copyright 2010 Umbrello UML Modeller Authors <umbrello-devel@kde.org>
7
8 This program is free software; you can redistribute it and/or
9 modify it under the terms of the GNU General Public License as
10 published by the Free Software Foundation; either version 2 of
11 the License or (at your option) version 3 or any later version
12 accepted by the membership of KDE e.V. (or its successor approved
13 by the membership of KDE e.V.), which shall act as a proxy
14 defined in Section 14 of version 3 of the license.
15
16 This program is distributed in the hope that it will be useful,
17 but WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 GNU General Public License for more details.
20
21 You should have received a copy of the GNU General Public License
22 along with this program. If not, see <http://www.gnu.org/licenses/>.
23 */
24
25 #ifndef CODETEXTEDIT_H
26 #define CODETEXTEDIT_H
27
28 #include <QObject>
29 #include <QPlainTextEdit>
30
31 class QPaintEvent;
32 class QResizeEvent;
33 class QSize;
34 class QWidget;
35
36 class CodeTextHighlighter;
37 class LineNumberArea;
38
39 class CodeTextEdit : public QPlainTextEdit
40 {
41 Q_OBJECT
42
43 public:
44 explicit CodeTextEdit(QWidget *parent = 0);
45
46 void lineNumberAreaPaintEvent(QPaintEvent *event);
47 int lineNumberAreaWidth();
48
49 protected:
50 void resizeEvent(QResizeEvent *event);
51
52 private slots:
53 void updateLineNumberAreaWidth(int newBlockCount);
54 void highlightCurrentLine();
55 void updateLineNumberArea(const QRect &, int);
56
57 private:
58 QWidget *m_lineNumberArea;
59 CodeTextHighlighter *m_highlighter;
60 };
61
62
63 class LineNumberArea : public QWidget
64 {
65 public:
66 explicit LineNumberArea(CodeTextEdit *editor) : QWidget(editor) {
67 m_codeEditor = editor;
68 }
69
70 QSize sizeHint() const {
71 return QSize(m_codeEditor->lineNumberAreaWidth(), 0);
72 }
73
74 protected:
75 void paintEvent(QPaintEvent *event) {
76 m_codeEditor->lineNumberAreaPaintEvent(event);
77 }
78
79 private:
80 CodeTextEdit *m_codeEditor;
81 };
82
83 #endif // CODETEXTBOX_H
LineNumberArea::LineNumberArea
LineNumberArea(CodeTextEdit *editor)
Definition: codetextedit.h:66
CodeTextEdit::lineNumberAreaPaintEvent
void lineNumberAreaPaintEvent(QPaintEvent *event)
Definition: codetextedit.cpp:131
CodeTextHighlighter
Definition: codetexthighlighter.h:35
LineNumberArea::m_codeEditor
CodeTextEdit * m_codeEditor
Definition: codetextedit.h:80
CodeTextEdit
Definition: codetextedit.h:40
LineNumberArea::paintEvent
void paintEvent(QPaintEvent *event)
Definition: codetextedit.h:75
CodeTextEdit::updateLineNumberArea
void updateLineNumberArea(const QRect &, int)
Definition: codetextedit.cpp:81
LineNumberArea
Definition: codetextedit.h:64
CodeTextEdit::resizeEvent
void resizeEvent(QResizeEvent *event)
Definition: codetextedit.cpp:98
codetextedit.h
LineNumberArea::sizeHint
QSize sizeHint() const
Definition: codetextedit.h:70
CodeTextEdit::m_highlighter
CodeTextHighlighter * m_highlighter
Definition: codetextedit.h:59
codetexthighlighter.h
CodeTextEdit::m_lineNumberArea
QWidget * m_lineNumberArea
Definition: codetextedit.h:58
CodeTextEdit::updateLineNumberAreaWidth
void updateLineNumberAreaWidth(int newBlockCount)
Definition: codetextedit.cpp:72
CodeTextEdit::CodeTextEdit
CodeTextEdit(QWidget *parent=0)
Definition: codetextedit.cpp:35
CodeTextEdit::highlightCurrentLine
void highlightCurrentLine()
Definition: codetextedit.cpp:109
int
int int y int
Definition: cxx11-lambda-functions-and-expressions.h:4
MyProject\connect
connect()
Definition: namespaces-multiple.php:5
CodeTextEdit::lineNumberAreaWidth
int lineNumberAreaWidth()
Definition: codetextedit.cpp:53