summaryrefslogtreecommitdiff
path: root/utils/wpseditor/gui/src/numberedtextview.h
diff options
context:
space:
mode:
Diffstat (limited to 'utils/wpseditor/gui/src/numberedtextview.h')
-rw-r--r--utils/wpseditor/gui/src/numberedtextview.h87
1 files changed, 87 insertions, 0 deletions
diff --git a/utils/wpseditor/gui/src/numberedtextview.h b/utils/wpseditor/gui/src/numberedtextview.h
new file mode 100644
index 0000000000..2a0d1de068
--- /dev/null
+++ b/utils/wpseditor/gui/src/numberedtextview.h
@@ -0,0 +1,87 @@
1/* This file is part of the KDE libraries
2 Copyright (C) 2005, 2006 KJSEmbed Authors
3 See included AUTHORS file.
4
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version.
9
10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details.
14
15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to
17 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 Boston, MA 02110-1301, USA.
19
20 --------------------------------------------------------------------------------------
21 Imported into the WPS editor and simplified by Dominik Wenger
22
23*/
24
25
26#ifndef NUMBERED_TEXT_VIEW_H
27#define NUMBERED_TEXT_VIEW_H
28
29#include <QFrame>
30#include <QPixmap>
31#include <QTextCursor>
32
33class QTextEdit;
34class QHBoxLayout;
35
36// Shows the Line numbers
37class NumberBar : public QWidget
38{
39 Q_OBJECT
40
41public:
42 NumberBar( QWidget *parent );
43 ~NumberBar();
44
45 void markLine( int lineno );
46
47 void setTextEdit( QTextEdit *edit );
48 void paintEvent( QPaintEvent *ev );
49
50private:
51 QTextEdit *edit;
52 QPixmap markerIcon;
53 int markedLine;
54 QRect markedRect;
55};
56
57// Shows a QTextEdit with Line numbers
58class NumberedTextView : public QFrame
59{
60 Q_OBJECT
61
62public:
63 NumberedTextView( QWidget *parent = 0 );
64 ~NumberedTextView();
65
66 /** Returns the QTextEdit of the main view. */
67 QTextEdit *textEdit() const { return view; }
68
69 /* marks the line with a icon */
70 void markLine( int lineno );
71
72 void scrolltoLine( int lineno );
73
74private slots:
75 void textChanged( int pos, int removed, int added );
76
77private:
78 QTextEdit *view;
79 NumberBar *numbers;
80 QHBoxLayout *box;
81 QTextCursor highlight;
82 int markedLine;
83};
84
85
86#endif // NUMBERED_TEXT_VIEW_H
87