home *** CD-ROM | disk | FTP | other *** search
/ Clickx 115 / Clickx 115.iso / software / tools / windows / tails-i386-0.16.iso / live / filesystem.squashfs / usr / include / scribus-ng / pageitem_latexframe.h < prev    next >
Encoding:
C/C++ Source or Header  |  2009-09-26  |  4.1 KB  |  129 lines

  1. /*
  2. For general Scribus (>=1.3.2) copyright and licensing information please refer
  3. to the COPYING file provided with the program. Following this notice may exist
  4. a copyright and/or license notice that predates the release of Scribus 1.3.2
  5. for which a new license (GPL+exception) is in place.
  6. */
  7. /***************************************************************************
  8.                         pageitem_latexframe.h  -  description
  9.                         -------------------
  10. copyright            : Scribus Team
  11. ***************************************************************************/
  12.  
  13. /***************************************************************************
  14. *                                                                         *
  15. *   This program is free software; you can redistribute it and/or modify  *
  16. *   it under the terms of the GNU General Public License as published by  *
  17. *   the Free Software Foundation; either version 2 of the License, or     *
  18. *   (at your option) any later version.                                   *
  19. *                                                                         *
  20. ***************************************************************************/
  21.  
  22. #ifndef PAGEITEM_LATEXFRAME_H
  23. #define PAGEITEM_LATEXFRAME_H
  24.  
  25. #include <QObject>
  26. #include <QWidget>
  27. #include <QString>
  28. #include <QProcess>
  29. #include <QMap>
  30.  
  31. #include "scribusapi.h"
  32. #include "pageitem.h"
  33. #include "pageitem_imageframe.h"
  34.  
  35. class QTemporaryFile;
  36. class LatexEditor;
  37. class LatexConfigParser;
  38. class QTimer;
  39.  
  40. /** @brief Displays all kinds of content generated by external programs.
  41.     Named LatexFrame because it initally only showed the output of Latex.
  42. */
  43. class SCRIBUS_API PageItem_LatexFrame : public PageItem_ImageFrame
  44. {
  45.     Q_OBJECT
  46.  
  47.     public:
  48.         PageItem_LatexFrame(ScribusDoc *pa, double x, double y, double w, double h, double w2, QString fill, QString outline);
  49.         ~PageItem_LatexFrame();
  50.         
  51.         virtual PageItem_LatexFrame * asLatexFrame() { return this; }
  52.         virtual void clearContents();
  53.         virtual ItemType realItemType() const { return PageItem::LatexFrame; }
  54.         virtual void applicableActions(QStringList& actionList);
  55.         virtual QString infoDescription();
  56.         void layout();
  57.         
  58.         /** @brief Perform undo/redo action */
  59.         void restore(UndoState *state, bool isUndo);
  60.         
  61.         
  62.         /** @brief UI-Callback that runs the editor. */
  63.         void runEditor();
  64.         /*TODO void convertToVector(); */
  65.         
  66.         /** @brief Sets the formula text and forces rerunning latex.
  67.             Emits formulaAutoUpdate() when undoable is false.
  68.             @return Returns true if the frame has to be updated, false if nothing changed.
  69.         */
  70.         bool setFormula(QString formula, bool undoable=true);
  71.         /** @brief Get current source. */
  72.         QString formula() const { return formulaText; }
  73.         
  74.         /** @brief Runs the external application and sets internal vars and loads
  75.         the image.*/
  76.         void runApplication();
  77.         
  78.         void rerunApplication(bool updateDisplay=false);
  79.         
  80.         QString configFile() const;
  81.         void setConfigFile(QString newConfig, bool relative=false);
  82.         QString application() const;
  83.         bool usePreamble() const { return m_usePreamble; }
  84.         int dpi() const { return m_dpi; }
  85.         int realDpi() const;
  86.         
  87.         const QString output() const { return appStdout; }
  88.         QProcess::ProcessState state() const { return latex->state(); }
  89.         int error() const { return err; }
  90.  
  91.         QMap<QString,QString> editorProperties;
  92.     protected:
  93.         virtual void DrawObj_Item(ScPainter *p, QRectF e, double sc);
  94.         double lastWidth, lastHeight;
  95.         
  96.         QString formulaText;
  97.  
  98.         void writeFileContents(QFile *tempfile);
  99.         void deleteImageFile();
  100.         /* Last error code */
  101.         int err;
  102.         int m_dpi;
  103.         
  104.         QString imageFile, tempFileBase;
  105.         QString appStdout;
  106.         QString configFilename;
  107.         
  108.         QProcess *latex;
  109.         LatexEditor *internalEditor;
  110.         LatexConfigParser *config;
  111.         bool imgValid;
  112.         bool m_usePreamble;
  113.         bool killed;
  114.     signals:
  115.         void formulaAutoUpdate(QString oldText, QString newText);
  116.         void latexFinished();
  117.         void stateChanged(QProcess::ProcessState state);
  118.         void applicationChanged();
  119.     protected slots:
  120.         void updateImage(int exitCode, QProcess::ExitStatus exitStatus);
  121.         void latexError(QProcess::ProcessError error);
  122.     public slots:
  123.         void killProcess();
  124.         void setDpi(int dpi);
  125.         void setUsePreamble(bool);
  126. };
  127.  
  128. #endif
  129.