TextEdit.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #ifndef GUI_TEXTEDIT_H
00025 #define GUI_TEXTEDIT_H
00026
00027 #include <QListWidget>
00028 #include <QPlainTextEdit>
00029 #include "View.h"
00030 #include "Window.h"
00031
00032 namespace Gui {
00033 class CompletionBox;
00034 class SyntaxHighlighter;
00035
00053 class CompletionList;
00054 class GuiExport TextEdit : public QPlainTextEdit
00055 {
00056 Q_OBJECT
00057
00058 public:
00059 TextEdit(QWidget *parent = 0);
00060 virtual ~TextEdit();
00061
00062 private Q_SLOTS:
00063 void complete();
00064
00065 protected:
00066 void keyPressEvent(QKeyEvent *);
00067
00068 private:
00069 void createListBox();
00070
00071 private:
00072 QString wordPrefix;
00073 int cursorPosition;
00074 CompletionList *listBox;
00075 };
00076
00077 class SyntaxHighlighter;
00078 class GuiExport TextEditor : public TextEdit, public WindowParameter
00079 {
00080 Q_OBJECT
00081
00082 public:
00083 TextEditor(QWidget *parent = 0);
00084 ~TextEditor();
00085 void setSyntaxHighlighter(SyntaxHighlighter*);
00086
00087 void OnChange(Base::Subject<const char*> &rCaller,const char* rcReason);
00088
00089 void lineNumberAreaPaintEvent(QPaintEvent* );
00090 int lineNumberAreaWidth();
00091
00092 private Q_SLOTS:
00093 void updateLineNumberAreaWidth(int newBlockCount);
00094 void updateLineNumberArea(const QRect &, int);
00095 void highlightCurrentLine();
00096
00097 protected:
00098 void keyPressEvent (QKeyEvent * e);
00100 void paintEvent (QPaintEvent * e);
00101 void resizeEvent(QResizeEvent* e);
00102 virtual void drawMarker(int line, int x, int y, QPainter*);
00103
00104 private:
00105 SyntaxHighlighter* highlighter;
00106 QWidget* lineNumberArea;
00107 struct TextEditorP* d;
00108
00109 friend class SyntaxHighlighter;
00110 };
00111
00112 class LineMarker : public QWidget
00113 {
00114 Q_OBJECT
00115
00116 public:
00117 LineMarker(TextEditor* editor);
00118 virtual ~LineMarker();
00119
00120 QSize sizeHint() const;
00121
00122 protected:
00123 void paintEvent (QPaintEvent *);
00124
00125 private:
00126 TextEditor *textEditor;
00127 };
00128
00134 class CompletionList : public QListWidget
00135 {
00136 Q_OBJECT
00137
00138 public:
00140 CompletionList(QPlainTextEdit* parent);
00142 ~CompletionList();
00143
00144 void findCurrentWord(const QString&);
00145
00146 protected:
00147 bool eventFilter(QObject *, QEvent *);
00148
00149 private Q_SLOTS:
00150 void completionItem(QListWidgetItem *item);
00151
00152 private:
00153 QPlainTextEdit* textEdit;
00154 };
00155
00156 }
00157
00158 #endif // GUI_TEXTEDIT_H