ReportView.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_DOCKWND_REPORTVIEW_H
00025 #define GUI_DOCKWND_REPORTVIEW_H
00026 
00027 #include <QTextEdit>
00028 #include <QSyntaxHighlighter>
00029 #include <Base/Console.h>
00030 #include "DockWindow.h"
00031 #include "Window.h"
00032 
00033 class QTabWidget;
00034 
00035 namespace Gui {
00036 class PythonConsole;
00037 namespace DockWnd {
00038 
00039 class ReportOutput;
00040 class ReportHighlighter;
00041 
00047 class ReportView : public QWidget
00048 {
00049     Q_OBJECT
00050 
00051 public:
00052     ReportView( QWidget* parent = 0);
00053     ~ReportView();
00054 
00055 protected:
00056     void changeEvent(QEvent *e);
00057 
00058 private:
00059     QTabWidget* tabWidget;
00060     ReportOutput* tabOutput; 
00061     PythonConsole* tabPython; 
00062 };
00063 
00067 class GuiExport ReportHighlighter : public QSyntaxHighlighter
00068 {
00069 public: 
00070     enum Paragraph { 
00071         Message  = 0, 
00072         Warning  = 1, 
00073         Error    = 2, 
00074         LogText  = 3  
00075     };
00076 
00077 public:
00078     ReportHighlighter(QTextEdit* );
00079     ~ReportHighlighter();
00080 
00082     void highlightBlock ( const QString & text );
00089     void setParagraphType(Paragraph);
00090 
00094     void setTextColor( const QColor& col );
00095 
00099     void setLogColor( const QColor& col );
00100 
00104     void setWarningColor( const QColor& col );
00105 
00109     void setErrorColor( const QColor& col );
00110 
00111 private:
00114     Paragraph type;
00115     QColor txtCol, logCol, warnCol, errCol;
00117 };
00118 
00124 class GuiExport ReportOutput : public QTextEdit, public WindowParameter, public Base::ConsoleObserver
00125 {
00126     Q_OBJECT
00127 
00128 public:
00129     ReportOutput(QWidget* parent=0);
00130     virtual ~ReportOutput();
00131 
00133     void OnChange(Base::Subject<const char*> &rCaller, const char * sReason);
00134 
00136     void Warning(const char * s);
00138     void Message(const char * s);
00140     void Error  (const char * s);
00142     void Log (const char * s);
00143 
00145     const char* Name(void){return "ReportOutput";}
00146 
00148     void restoreFont ();
00149 
00151     bool isError() const;
00153     bool isWarning() const;
00155     bool isLogging() const;
00156 
00157 protected:
00159     void customEvent ( QEvent* ev );
00161     void contextMenuEvent ( QContextMenuEvent* e );
00162 
00163 public Q_SLOTS:
00165     void onSaveAs();
00167     void onToggleError();
00169     void onToggleWarning();
00171     void onToggleLogging();
00173     void onToggleRedirectPythonStdout();
00175     void onToggleRedirectPythonStderr();
00177     void onToggleGoToEnd();
00178 
00179 private:
00180     class Data;
00181     Data* d;
00182     bool gotoEnd;
00183     ReportHighlighter* reportHl; 
00184     ParameterGrp::handle _prefs; 
00185 };
00186 
00187 } // namespace DockWnd
00188 } // namespace Gui
00189 
00190 #endif //GUI_DOCKWND_REPORTVIEW_H

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