Back to index

scribus-ng  1.3.4.dfsg+svn20071115
pconsole.h
Go to the documentation of this file.
00001 /*
00002 For general Scribus (>=1.3.2) copyright and licensing information please refer
00003 to the COPYING file provided with the program. Following this notice may exist
00004 a copyright and/or license notice that predates the release of Scribus 1.3.2
00005 for which a new license (GPL+exception) is in place.
00006 */
00007 /*
00008 This program is free software; you can redistribute it and/or modify
00009 it under the terms of the GNU General Public License as published by
00010 the Free Software Foundation; either version 2 of the License, or
00011 (at your option) any later version.
00012 */
00013 
00014 #ifndef PCONSOLE_H
00015 #define PCONSOLE_H
00016 
00017 #include <qvariant.h>
00018 #include <qlayout.h>
00019 #include <qtooltip.h>
00020 #include <qwhatsthis.h>
00021 #include <qsyntaxhighlighter.h>
00022 
00023 class QVBoxLayout;
00024 class QHBoxLayout;
00025 class QGridLayout;
00026 class QSpacerItem;
00027 class QListView;
00028 class QListViewItem;
00029 class QTextEdit;
00030 class QMenuBar;
00031 class QStatusBar;
00032 
00033 
00039 class PythonConsole : public QWidget
00040 {
00041        Q_OBJECT
00042 
00043        public:
00044               PythonConsole( QWidget* parent = 0);
00045               ~PythonConsole();
00046               
00047               void setFonts();
00048 
00051               QString command() { return m_command; };
00053               QString filename;
00054 
00056               QTextEdit* commandEdit;
00058               QTextEdit* outputEdit;
00059 
00061               void closeEvent(QCloseEvent *);
00062 
00063        public slots:
00065               virtual void slot_runScript();
00066               virtual void slot_runScriptAsConsole();
00067               virtual void slot_open();
00068               virtual void slot_save();
00069               virtual void slot_saveAs();
00070               virtual void slot_saveOutput();
00071               virtual void slot_quit();
00076               virtual void commandEdit_cursorPositionChanged(int para, int pos);
00077 
00078        signals:
00080               void paletteShown(bool);
00082               void runCommand();
00083 
00084        protected:
00086               void parsePythonString();
00087               QGridLayout* gridLayout;
00088               QVBoxLayout* editorsLayout;
00089               QMenuBar* menuBar;
00090               QStatusBar* statusBar;
00092               QString m_command;
00093 
00094        protected slots:
00095               virtual void languageChange();
00096 
00097 };
00098 
00102 class SyntaxColors
00103 {
00104        public:
00105               SyntaxColors();
00106               ~SyntaxColors();
00107               QColor errorColor;
00108               QColor commentColor;
00109               QColor keywordColor;
00110               QColor signColor;
00111               QColor numberColor;
00112               QColor stringColor;
00113               QColor textColor;
00114        private:
00117               QString qcolor2named(QColor color);
00118 };
00119 
00128 class SyntaxHighlighter : public QSyntaxHighlighter
00129 {
00130        public:
00131               SyntaxHighlighter(QTextEdit *textEdit);
00132 
00137               int highlightParagraph(const QString &text, int endStateOfLastPara);
00138 
00139        private:
00141               QStringList keywords;
00142               SyntaxColors colors;
00143 
00144 };
00145 
00146 #endif