stec-platform
codeeditor.h
1 /*
2 *
3 * $LastChangedDate: 2014-11-03 14:00:00 -0500 (Mon, 03 Nov 2014) $
4 * $LastChangedBy: ed $
5 * $Revision: 174 $
6 * $Author: ed $
7 * $URL: svn+ssh://svn.vremsoft.com/var/share/svn/tags/platfom3.4.3/platformglib/codeeditor.h $
8 * $Id: codeeditor.h 174 2014-11-03 19:00:00Z ed $
9 * edc@vremsoft.com
10 *
11 * 19
12 *
13 * *** 2014<c> ***
14 *
15 *
16 */
17 #ifndef CODEEDITOR_H
18 #define CODEEDITOR_H
19 
20 #include <QPlainTextEdit>
21 #include <QTextEdit>
22 #include <QObject>
23 #include "platformg_global.h"
24 
25 QT_BEGIN_NAMESPACE
26 class QPaintEvent;
27 class QResizeEvent;
28 class QSize;
29 class QWidget;
30 QT_END_NAMESPACE
31 
32 class LineNumberArea;
33 
35 
40 class PLATFORMGSHARED_EXPORT CodeEditor : public QPlainTextEdit
41 {
42  Q_OBJECT
43 
44 public:
51  CodeEditor(QWidget *parent = 0);
52  virtual ~CodeEditor();
53 
58  void lineNumberAreaPaintEvent(QPaintEvent *event);
63  int lineNumberAreaWidth();
68  int getLineNumber(void);
74  int bumpTo( int lineNo);
75  QHash<int,int> bpHighlights;
76 
77 
78 
79 protected:
80  void resizeEvent(QResizeEvent *event);
81 
82 public slots:
83  void gotoLine( int lineNo);
84 
85 private slots:
86  void updateLineNumberAreaWidth(int newBlockCount);
87  void highlightCurrentLine();
88  void updateLineNumberArea(const QRect &, int);
89  void updateBreakpoints(QHash<int,int> bp)
90  {
91  bpHighlights = bp;
92  repaint();
93 
94  }
95 
96 
97 private:
98  QWidget *lineNumberArea;
99 };
100 
103 
108 class LineNumberArea : public QWidget
109 {
110 public:
115  LineNumberArea(CodeEditor *editor) : QWidget(editor)
116  {
117  codeEditor = editor;
118  }
119 
124  QSize sizeHint() const {
125  return QSize(codeEditor->lineNumberAreaWidth(), 0);
126  }
127 
128 protected:
129  void paintEvent(QPaintEvent *event)
130  {
131  codeEditor->lineNumberAreaPaintEvent(event);
132  }
133 
134 private:
135  CodeEditor *codeEditor;
136 };
137 
139 
140 #endif
[codeeditordefinition]
Definition: codeeditor.h:41
void lineNumberAreaPaintEvent(QPaintEvent *event)
lineNumberAreaPaintEvent
Definition: codeeditor.cpp:186
int lineNumberAreaWidth()
lineNumberAreaWidth
Definition: codeeditor.cpp:50
The LineNumberArea class.
Definition: codeeditor.h:109
QSize sizeHint() const
sizeHint
Definition: codeeditor.h:124
LineNumberArea(CodeEditor *editor)
LineNumberArea.
Definition: codeeditor.h:115