EditorView.h

Go to the documentation of this file.
00001 /***************************************************************************
00002  *   Copyright (c) 2007 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_EDITORVIEW_H
00025 #define GUI_EDITORVIEW_H
00026 
00027 #include "MDIView.h"
00028 #include "Window.h"
00029 
00030 QT_BEGIN_NAMESPACE
00031 class QPlainTextEdit;
00032 class QPrinter;
00033 QT_END_NAMESPACE
00034 
00035 namespace Gui {
00036 
00037 class EditorViewP;
00038 
00044 class GuiExport EditorView : public MDIView, public WindowParameter
00045 {
00046     Q_OBJECT
00047 
00048 public:
00049     EditorView(QPlainTextEdit* editor, QWidget* parent);
00050     ~EditorView();
00051 
00052     QPlainTextEdit* getEditor() const;
00053     //todo: remove
00054     virtual void drawMarker(int line, int x, int y, QPainter*);
00055     void OnChange(Base::Subject<const char*> &rCaller,const char* rcReason);
00056 
00057     const char *getName(void) const {return "EditorView";}
00058     void onUpdate(void){};
00059 
00060     bool onMsg(const char* pMsg,const char** ppReturn);
00061     bool onHasMsg(const char* pMsg) const;
00062 
00063     bool canClose(void);
00064 
00067     bool open   (const QString &f);
00068     bool saveAs ();
00069     void cut    ();
00070     void copy   ();
00071     void paste  ();
00072     void undo   ();
00073     void redo   ();
00074     void print  ();
00075     void printPdf();
00076     void printPreview();
00078 
00079     QStringList undoActions() const;
00080     QStringList redoActions() const;
00081     QString fileName() const;
00082 
00083 protected:
00084     void focusInEvent(QFocusEvent* e);
00085 
00086 private Q_SLOTS:
00087     void checkTimestamp();
00088     void contentsChange(int position, int charsRemoved, int charsAdded);
00089     void undoAvailable(bool);
00090     void redoAvailable(bool);
00091     void print(QPrinter*);
00092 
00093 private:
00094     void setCurrentFileName(const QString &fileName);
00095     bool saveFile();
00096 
00097 private:
00098     EditorViewP* d;
00099 };
00100 
00101 class PythonDebugger;
00102 class GuiExport PythonEditorView : public EditorView
00103 {
00104     Q_OBJECT
00105 
00106 public:
00107     PythonEditorView(QPlainTextEdit* editor, QWidget* parent);
00108     ~PythonEditorView();
00109 
00110     //todo: remove
00111     void drawMarker(int line, int x, int y, QPainter*);
00112     bool onMsg(const char* pMsg,const char** ppReturn);
00113     bool onHasMsg(const char* pMsg) const;
00114 
00115     //todo: move to PythonEditor
00116 public Q_SLOTS:
00117     void executeScript();
00118     void startDebug();
00119     void toggleBreakpoint();
00120     void showDebugMarker(int line);
00121     void hideDebugMarker();
00122 
00123     //todo: move to PythonEditor
00124 private:
00125     int m_debugLine;
00126     QRect debugRect;
00127     QPixmap breakpoint;
00128     QPixmap debugMarker;
00129     PythonDebugger* _dbg;
00130 };
00131 
00132 } // namespace Gui
00133 
00134 #endif // GUI_EDITORVIEW_H

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