Theme Editor: Fixed bug in parser handling empty lines and made ParseTreeModel handle...
[kugel-rb.git] / utils / themeeditor / codeeditor.h
blob5df5b423d5ed45719ef502d059393f3eb9921a90
1 /***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
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
13 ****************************************************************************
14 ****************************************************************************
16 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
17 ** All rights reserved.
18 ** Contact: Nokia Corporation (qt-info@nokia.com)
20 ** This file is part of the examples of the Qt Toolkit.
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.
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.
34 ****************************************************************************/
36 #ifndef CODEEDITOR_H
37 #define CODEEDITOR_H
39 #include <QPlainTextEdit>
40 #include <QObject>
42 QT_BEGIN_NAMESPACE
43 class QPaintEvent;
44 class QResizeEvent;
45 class QSize;
46 class QWidget;
47 QT_END_NAMESPACE
49 class LineNumberArea;
51 //![codeeditordefinition]
53 class CodeEditor : public QPlainTextEdit
55 Q_OBJECT
57 public:
58 CodeEditor(QWidget *parent = 0);
60 void lineNumberAreaPaintEvent(QPaintEvent *event);
61 int lineNumberAreaWidth();
62 void addError(int line){ errors.append(line); }
63 void clearErrors(){ errors.clear(); }
64 void setErrorColor(QColor color){ errorColor = color; }
66 protected:
67 void resizeEvent(QResizeEvent *event);
69 private slots:
70 void updateLineNumberAreaWidth(int newBlockCount);
71 void updateLineNumberArea(const QRect &, int);
73 private:
74 QWidget *lineNumberArea;
75 QList<int> errors;
76 QColor errorColor;
79 //![codeeditordefinition]
80 //![extraarea]
82 class LineNumberArea : public QWidget
84 public:
85 LineNumberArea(CodeEditor *editor) : QWidget(editor) {
86 codeEditor = editor;
89 QSize sizeHint() const {
90 return QSize(codeEditor->lineNumberAreaWidth(), 0);
93 protected:
94 void paintEvent(QPaintEvent *event) {
95 codeEditor->lineNumberAreaPaintEvent(event);
98 private:
99 CodeEditor *codeEditor;
102 //![extraarea]
104 #endif