umbrello: umbrello/dialogs/codetextedit.h Source File

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

- Main Page
- Related Pages
- Topics
- Namespaces
- Classes
- Files

- File List
- File Members

codetextedit.h
Go to the documentation of this file.
1/*
2 CodeTextEdit: Text edit widget with line numbers and highlighted current line.
3 SPDX-FileCopyrightText: 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 SPDX-FileCopyrightText: 2010 Umbrello UML Modeller Authors <umbrello-devel@kde.org>
7
8 SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
9*/
10
11#ifndef CODETEXTEDIT_H
12#define CODETEXTEDIT_H
13
14#include <QObject>
15#include <QPlainTextEdit>
16
17class QPaintEvent;
18class QResizeEvent;
19class QSize;
20class QWidget;
21
22class CodeTextHighlighter;
23class LineNumberArea;
24
25 class CodeTextEdit : public QPlainTextEdit
26{
27 Q_OBJECT
28
29public:
30 explicit CodeTextEdit(QWidget *parent = 0);
31
32 void lineNumberAreaPaintEvent(QPaintEvent *event);
33 int lineNumberAreaWidth();
34
35protected:
36 void resizeEvent(QResizeEvent *event);
37
38private slots:
39 void updateLineNumberAreaWidth(int newBlockCount);
40 void highlightCurrentLine();
41 void updateLineNumberArea(const QRect &, int);
42
43private:
44 QWidget *m_lineNumberArea;
45 CodeTextHighlighter *m_highlighter;
46};
47
48
49 class LineNumberArea : public QWidget
50{
51public:
52 explicit LineNumberArea(CodeTextEdit *editor) : QWidget(editor) {
53 m_codeEditor = editor;
54 }
55
56 QSize sizeHint() const {
57 return QSize(m_codeEditor->lineNumberAreaWidth(), 0);
58 }
59
60protected:
61 void paintEvent(QPaintEvent *event) {
62 m_codeEditor->lineNumberAreaPaintEvent(event);
63 }
64
65private:
66 CodeTextEdit *m_codeEditor;
67};
68
69#endif // CODETEXTBOX_H
CodeTextEdit
Definition codetextedit.h:26
CodeTextEdit::lineNumberAreaPaintEvent
void lineNumberAreaPaintEvent(QPaintEvent *event)
Definition codetextedit.cpp:117
CodeTextEdit::CodeTextEdit
CodeTextEdit(QWidget *parent=0)
Definition codetextedit.cpp:21
CodeTextEdit::highlightCurrentLine
void highlightCurrentLine()
Definition codetextedit.cpp:95
CodeTextEdit::m_highlighter
CodeTextHighlighter * m_highlighter
Definition codetextedit.h:45
CodeTextEdit::updateLineNumberArea
void updateLineNumberArea(const QRect &, int)
Definition codetextedit.cpp:67
CodeTextEdit::resizeEvent
void resizeEvent(QResizeEvent *event)
Definition codetextedit.cpp:84
CodeTextEdit::m_lineNumberArea
QWidget * m_lineNumberArea
Definition codetextedit.h:44
CodeTextEdit::lineNumberAreaWidth
int lineNumberAreaWidth()
Definition codetextedit.cpp:39
CodeTextEdit::updateLineNumberAreaWidth
void updateLineNumberAreaWidth(int newBlockCount)
Definition codetextedit.cpp:58
CodeTextHighlighter
Definition codetexthighlighter.h:21
LineNumberArea
Definition codetextedit.h:50
LineNumberArea::sizeHint
QSize sizeHint() const
Definition codetextedit.h:56
LineNumberArea::m_codeEditor
CodeTextEdit * m_codeEditor
Definition codetextedit.h:66
LineNumberArea::paintEvent
void paintEvent(QPaintEvent *event)
Definition codetextedit.h:61
LineNumberArea::LineNumberArea
LineNumberArea(CodeTextEdit *editor)
Definition codetextedit.h:52