TextEdit.h

Go to the documentation of this file.
00001 /***************************************************************************
00002  *   Copyright (c) 2004 Werner Mayer <wmayer[at]users.sourceforge.net>     *
00003  *                                                                         *
00004  *   This file is part of the FreeCAD CAx development system.              *
00005  *                                                                         *
00006  *   This library is free software; you can redistribute it and/or         *
00007  *   modify it under the terms of the GNU Library General Public           *
00008  *   License as published by the Free Software Foundation; either          *
00009  *   version 2 of the License, or (at your option) any later version.      *
00010  *                                                                         *
00011  *   This library  is distributed in the hope that it will be useful,      *
00012  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00013  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
00014  *   GNU Library General Public License for more details.                  *
00015  *                                                                         *
00016  *   You should have received a copy of the GNU Library General Public     *
00017  *   License along with this library; see the file COPYING.LIB. If not,    *
00018  *   write to the Free Software Foundation, Inc., 59 Temple Place,         *
00019  *   Suite 330, Boston, MA  02111-1307, USA                                *
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 } // namespace Gui
00157 
00158 #endif // GUI_TEXTEDIT_H

Generated on Wed Nov 23 19:00:45 2011 for FreeCAD by  doxygen 1.6.1