summaryrefslogtreecommitdiff
path: root/utils/themeeditor/codeeditor.h
diff options
context:
space:
mode:
Diffstat (limited to 'utils/themeeditor/codeeditor.h')
-rw-r--r--utils/themeeditor/codeeditor.h99
1 files changed, 99 insertions, 0 deletions
diff --git a/utils/themeeditor/codeeditor.h b/utils/themeeditor/codeeditor.h
new file mode 100644
index 0000000000..edbe218ec4
--- /dev/null
+++ b/utils/themeeditor/codeeditor.h
@@ -0,0 +1,99 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * This file has been copied from Nokia's Qt Examples, with minor modifications
11 * made available under the LGPL version 2.1, as the original file was licensed
12 *
13 ****************************************************************************
14 ****************************************************************************
15**
16** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
17** All rights reserved.
18** Contact: Nokia Corporation (qt-info@nokia.com)
19**
20** This file is part of the examples of the Qt Toolkit.
21**
22** GNU Lesser General Public License Usage
23** Alternatively, this file may be used under the terms of the GNU Lesser
24** General Public License version 2.1 as published by the Free Software
25** Foundation and appearing in the file LICENSE.LGPL included in the
26** packaging of this file. Please review the following information to
27** ensure the GNU Lesser General Public License version 2.1 requirements
28** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
29**
30** In addition, as a special exception, Nokia gives you certain additional
31** rights. These rights are described in the Nokia Qt LGPL Exception
32** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
33**
34****************************************************************************/
35
36#ifndef CODEEDITOR_H
37#define CODEEDITOR_H
38
39#include <QPlainTextEdit>
40#include <QObject>
41
42QT_BEGIN_NAMESPACE
43class QPaintEvent;
44class QResizeEvent;
45class QSize;
46class QWidget;
47QT_END_NAMESPACE
48
49class LineNumberArea;
50
51//![codeeditordefinition]
52
53class CodeEditor : public QPlainTextEdit
54{
55 Q_OBJECT
56
57public:
58 CodeEditor(QWidget *parent = 0);
59
60 void lineNumberAreaPaintEvent(QPaintEvent *event);
61 int lineNumberAreaWidth();
62
63protected:
64 void resizeEvent(QResizeEvent *event);
65
66private slots:
67 void updateLineNumberAreaWidth(int newBlockCount);
68 void updateLineNumberArea(const QRect &, int);
69
70private:
71 QWidget *lineNumberArea;
72};
73
74//![codeeditordefinition]
75//![extraarea]
76
77class LineNumberArea : public QWidget
78{
79public:
80 LineNumberArea(CodeEditor *editor) : QWidget(editor) {
81 codeEditor = editor;
82 }
83
84 QSize sizeHint() const {
85 return QSize(codeEditor->lineNumberAreaWidth(), 0);
86 }
87
88protected:
89 void paintEvent(QPaintEvent *event) {
90 codeEditor->lineNumberAreaPaintEvent(event);
91 }
92
93private:
94 CodeEditor *codeEditor;
95};
96
97//![extraarea]
98
99#endif