umbrello  2.32.1
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  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 
17 class QPaintEvent;
18 class QResizeEvent;
19 class QSize;
20 class QWidget;
21 
23 class LineNumberArea;
24 
25 class CodeTextEdit : public QPlainTextEdit
26 {
27  Q_OBJECT
28 
29 public:
30  explicit CodeTextEdit(QWidget *parent = 0);
31 
32  void lineNumberAreaPaintEvent(QPaintEvent *event);
33  int lineNumberAreaWidth();
34 
35 protected:
36  void resizeEvent(QResizeEvent *event);
37 
38 private slots:
39  void updateLineNumberAreaWidth(int newBlockCount);
40  void highlightCurrentLine();
41  void updateLineNumberArea(const QRect &, int);
42 
43 private:
44  QWidget *m_lineNumberArea;
46 };
47 
48 
49 class LineNumberArea : public QWidget
50 {
51 public:
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 
60 protected:
61  void paintEvent(QPaintEvent *event) {
63  }
64 
65 private:
67 };
68 
69 #endif // CODETEXTBOX_H
document
GNU GENERAL PUBLIC LICENSE June Free Software Inc Franklin Fifth USA Everyone is permitted to copy and distribute verbatim copies of this license document
Definition: GPL-2.0-only.txt:8
LineNumberArea::LineNumberArea
LineNumberArea(CodeTextEdit *editor)
Definition: codetextedit.h:52
CodeTextEdit::lineNumberAreaPaintEvent
void lineNumberAreaPaintEvent(QPaintEvent *event)
Definition: codetextedit.cpp:117
CodeTextHighlighter
Definition: codetexthighlighter.h:20
LineNumberArea::m_codeEditor
CodeTextEdit * m_codeEditor
Definition: codetextedit.h:66
CodeTextEdit
Definition: codetextedit.h:25
LineNumberArea::paintEvent
void paintEvent(QPaintEvent *event)
Definition: codetextedit.h:61
CodeTextEdit::updateLineNumberArea
void updateLineNumberArea(const QRect &, int)
Definition: codetextedit.cpp:67
LineNumberArea
Definition: codetextedit.h:49
CodeTextEdit::resizeEvent
void resizeEvent(QResizeEvent *event)
Definition: codetextedit.cpp:84
codetextedit.h
LineNumberArea::sizeHint
QSize sizeHint() const
Definition: codetextedit.h:56
CodeTextEdit::m_highlighter
CodeTextHighlighter * m_highlighter
Definition: codetextedit.h:45
codetexthighlighter.h
CodeTextEdit::m_lineNumberArea
QWidget * m_lineNumberArea
Definition: codetextedit.h:44
CodeTextEdit::updateLineNumberAreaWidth
void updateLineNumberAreaWidth(int newBlockCount)
Definition: codetextedit.cpp:58
CodeTextEdit::CodeTextEdit
CodeTextEdit(QWidget *parent=0)
Definition: codetextedit.cpp:21
number
it is up to the author donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License If the distribution and or use of the Library is restricted in certain countries either by patents or by copyrighted the original copyright holder who places the Library under this License may add an geographical distribution limitation excluding those so that distribution is permitted only in or among countries not thus excluded In such this License incorporates the limitation as if written in the body of this License The Free Software Foundation may publish revised and or new versions of the Library General Public License from time to time Such new versions will be similar in spirit to the present but may differ in detail to address new problems or concerns Each version is given a distinguishing version number If the Library specifies a version number of this License which applies to it and any later you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation If the Library does not specify a license version number
Definition: LGPL-2.0-only.txt:368
CodeTextEdit::highlightCurrentLine
void highlightCurrentLine()
Definition: codetextedit.cpp:95
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:39