File indexing completed on 2024-04-28 16:26:32
0001 /***************************************************************************** 0002 * Copyright (C) 2006 by Mathias Soeken (msoeken@informatik.uni-bremen.de) * 0003 * (C) 2011 by Michel Ludwig (michel.ludwig@kdemail.net) * 0004 ******************************************************************************/ 0005 0006 /*************************************************************************** 0007 * * 0008 * This program is free software; you can redistribute it and/or modify * 0009 * it under the terms of the GNU General Public License as published by * 0010 * the Free Software Foundation; either version 2 of the License, or * 0011 * (at your option) any later version. * 0012 * * 0013 ***************************************************************************/ 0014 0015 #ifndef PREVIEWWIDGET_H 0016 #define PREVIEWWIDGET_H 0017 0018 #include <QScrollArea> 0019 0020 class QImage; 0021 class QLabel; 0022 0023 class KileInfo; 0024 0025 namespace KileTool { 0026 class Base; 0027 } 0028 0029 namespace KileWidget 0030 { 0031 0032 // declared in the .cpp file 0033 class ImageDisplayWidget; 0034 0035 /** 0036 * Widget which can display PNG images from Math LaTeX 0037 * Code 0038 * 0039 * This is used to be inserted in the bottom bar of the kile 0040 * main widget. When putting the cursor in a mathgroup, the LaTeX 0041 * source should be extracted and rendered in this widget. 0042 * 0043 * This widget uses one new Tool: DVItoPNG which converts 0044 * a dvi file to an png image, which is fitted to the size 0045 * of the formula). 0046 * 0047 * You could use this widget to implement a formula editor in Kile, 0048 * where the editor is the editor, but with this widget you can see 0049 * the result in a appropriate size just in time. 0050 * 0051 * @author Mathias Soeken <msoeken@informatik.uni-bremen.de> 0052 */ 0053 0054 class PreviewWidget : public QScrollArea 0055 { 0056 Q_OBJECT 0057 0058 public: 0059 explicit PreviewWidget(KileInfo *info, QWidget *parent = 0, const char *name = 0); 0060 ~PreviewWidget(); 0061 0062 /** 0063 * Tries to paint the current mathgroup of 0064 * the current document. 0065 * 0066 * If a document is open and the cursor is 0067 * inside a mathgroup, a PNG is generated 0068 * containing this mathgroup. 0069 * 0070 * This PNG image is then displayed on the 0071 * widget. 0072 **/ 0073 void showActivePreview(const QString &text, const QString &textfilename, int startrow, int previewtype); 0074 0075 public Q_SLOTS: 0076 void clear(); 0077 0078 private: 0079 enum { pwDvipng=0, pwDvipsConvert, pwConvert }; 0080 0081 KileInfo *m_info; 0082 ImageDisplayWidget *m_imageDisplayWidget; 0083 bool m_running; 0084 QString m_conversionTool; 0085 0086 protected: 0087 void showError(const QString &text); 0088 0089 public Q_SLOTS: 0090 /** 0091 * Notify, if the DVItoPNG tool is done. 0092 * 0093 * Because the tool runs async. we 0094 * must wait, if the process is done. 0095 * 0096 * Then we try to generate a image of the 0097 * temporary PNG filename and display it on 0098 * the widget. 0099 * 0100 * The size of the widget is also adjusted 0101 * to the size of the widget. 0102 **/ 0103 void drawImage(); 0104 void toolDestroyed(); 0105 }; 0106 0107 } 0108 0109 #endif