1 /***************************************************************************
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
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 ****************************************************************************/
39 #include <QPlainTextEdit>
51 //![codeeditordefinition]
53 class CodeEditor
: public QPlainTextEdit
58 CodeEditor(QWidget
*parent
= 0);
60 void lineNumberAreaPaintEvent(QPaintEvent
*event
);
61 int lineNumberAreaWidth();
64 void resizeEvent(QResizeEvent
*event
);
67 void updateLineNumberAreaWidth(int newBlockCount
);
68 void updateLineNumberArea(const QRect
&, int);
71 QWidget
*lineNumberArea
;
74 //![codeeditordefinition]
77 class LineNumberArea
: public QWidget
80 LineNumberArea(CodeEditor
*editor
) : QWidget(editor
) {
84 QSize
sizeHint() const {
85 return QSize(codeEditor
->lineNumberAreaWidth(), 0);
89 void paintEvent(QPaintEvent
*event
) {
90 codeEditor
->lineNumberAreaPaintEvent(event
);
94 CodeEditor
*codeEditor
;