00001 /*************************************************************************** 00002 File : ScriptingEnv.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 abstraction layer 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 SCRIPTINGENV_H 00032 #define SCRIPTINGENV_H 00033 00034 #include <QVariant> 00035 #include <QString> 00036 #include <QStringList> 00037 #include <QObject> 00038 #include <QStringList> 00039 #include <QEvent> 00040 00041 #include "customevents.h" 00042 00043 class ApplicationWindow; 00044 class Script; 00045 00047 00052 class ScriptingEnv : public QObject 00053 { 00054 Q_OBJECT 00055 00056 public: 00057 ScriptingEnv(ApplicationWindow *parent, const char *langName); 00059 virtual bool initialize() { return true; }; 00061 bool initialized() const { return d_initialized; } 00063 virtual bool isRunning() const { return false; } 00064 00066 virtual Script *newScript(const QString&, QObject*, const QString&) { return 0; } 00067 00069 virtual QString stackTraceString() { return QString::null; } 00070 00072 virtual const QStringList mathFunctions() const { return QStringList(); } 00074 virtual const QString mathFunctionDoc(const QString&) const { return QString::null; } 00076 virtual const QStringList fileExtensions() const { return QStringList(); }; 00078 const QString fileFilter() const; 00079 00080 // virtual QSyntaxHighlighter syntaxHighlighter(QTextEdit *textEdit) const; 00081 00082 public slots: 00083 // global variables 00084 virtual bool setQObject(QObject*, const char*) { return false; } 00085 virtual bool setInt(int, const char*) { return false; } 00086 virtual bool setDouble(double, const char*) { return false; } 00087 00089 virtual void clear() {} 00091 virtual void stopExecution() {} 00093 virtual void startExecution() {} 00094 00096 void incref(); 00098 void decref(); 00099 00100 signals: 00102 void error(const QString & message, const QString & scriptName, int lineNumber); 00104 void print(const QString & output); 00105 00106 protected: 00108 bool d_initialized; 00110 ApplicationWindow *d_parent; 00111 00112 private: 00114 int d_refcount; 00115 }; 00116 00117 #endif