ScriptEdit.h

Go to the documentation of this file.
00001 /***************************************************************************
00002     File                 : ScriptEdit.h
00003     Project              : QtiPlot
00004     --------------------------------------------------------------------
00005     Copyright            : (C) 2006 by Ion Vasilief,
00006                            Tilman Hoener zu Siederdissen,
00007                            Knut Franke
00008     Email (use @ for *)  : ion_vasilief*yahoo.fr, thzs*gmx.net
00009     Description          : Scripting classes
00010 
00011  ***************************************************************************/
00012 
00013 /***************************************************************************
00014  *                                                                         *
00015  *  This program is free software; you can redistribute it and/or modify   *
00016  *  it under the terms of the GNU General Public License as published by   *
00017  *  the Free Software Foundation; either version 2 of the License, or      *
00018  *  (at your option) any later version.                                    *
00019  *                                                                         *
00020  *  This program is distributed in the hope that it will be useful,        *
00021  *  but WITHOUT ANY WARRANTY; without even the implied warranty of         *
00022  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          *
00023  *  GNU General Public License for more details.                           *
00024  *                                                                         *
00025  *   You should have received a copy of the GNU General Public License     *
00026  *   along with this program; if not, write to the Free Software           *
00027  *   Foundation, Inc., 51 Franklin Street, Fifth Floor,                    *
00028  *   Boston, MA  02110-1301  USA                                           *
00029  *                                                                         *
00030  ***************************************************************************/
00031 #ifndef SCRIPTEDIT_H
00032 #define SCRIPTEDIT_H
00033 
00034 #include "ScriptingEnv.h"
00035 #include "Script.h"
00036 
00037 #include <QMenu>
00038 #include <QTextEdit>
00039 
00040 class QAction;
00041 class QMenu;
00042 
00049 class ScriptEdit: public QTextEdit, public scripted
00050 {
00051   Q_OBJECT
00052 
00053   public:
00054     ScriptEdit(ScriptingEnv *env, QWidget *parent=0, const char *name=0);
00055     ~ScriptEdit();
00056 
00057     void customEvent(QEvent*);
00058     int lineNumber(int pos) const;
00059 
00060   public slots:
00061     void execute();
00062     void executeAll();
00063     void evaluate();
00064     void print();
00065     void exportPDF(const QString& fileName);
00066     QString exportASCII(const QString &file=QString::null);
00067     QString importASCII(const QString &file=QString::null);
00068     void insertFunction(const QString &);
00069     void insertFunction(QAction * action);
00070     void setContext(QObject *context) { myScript->setContext(context); }
00071     void scriptPrint(const QString&);
00072     void updateIndentation();
00073 
00074   protected:
00075     virtual void contextMenuEvent(QContextMenuEvent *e);
00076     virtual void keyPressEvent(QKeyEvent *e);
00077 
00078   private:
00079     Script *myScript;
00080     QAction *actionExecute, *actionExecuteAll, *actionEval, *actionPrint, *actionImport, *actionExport;
00081     QMenu *functionsMenu;
00082     QTextCursor printCursor;
00083 
00084   private slots:
00085     void insertErrorMsg(const QString &message);
00086 };
00087 
00088 #endif

Generated on Mon Oct 15 06:11:42 2007 for QtiPlot by  doxygen 1.5.3