2005-12-15 21:34:10 +00:00
|
|
|
// -*- Mode: C++; c-basic-offset: 2; indent-tabs-mode: nil; c-brace-offset: 0; -*-
|
2004-12-17 20:34:29 +00:00
|
|
|
//
|
|
|
|
// ghostscript_interface
|
|
|
|
//
|
|
|
|
// Part of KDVI - A framework for multipage text/gfx viewers
|
|
|
|
//
|
|
|
|
// (C) 2004 Stefan Kebekus
|
|
|
|
// Distributed under the GPL
|
|
|
|
|
2000-08-18 17:53:00 +00:00
|
|
|
#ifndef _PSGS_H_
|
|
|
|
#define _PSGS_H_
|
|
|
|
|
2005-10-13 22:41:50 +00:00
|
|
|
#include <Q3IntDict>
|
2005-09-21 18:10:56 +00:00
|
|
|
#include <QColor>
|
|
|
|
#include <QObject>
|
|
|
|
#include <QString>
|
2004-12-17 20:34:29 +00:00
|
|
|
|
2006-01-28 13:15:59 +00:00
|
|
|
class KUrl;
|
2005-09-21 18:10:56 +00:00
|
|
|
class PageNumber;
|
2004-12-17 20:34:29 +00:00
|
|
|
class QPainter;
|
|
|
|
|
2005-09-21 18:10:56 +00:00
|
|
|
|
2000-06-24 04:43:55 +00:00
|
|
|
class pageInfo
|
|
|
|
{
|
|
|
|
public:
|
2005-10-03 20:01:17 +00:00
|
|
|
pageInfo(const QString& _PostScriptString);
|
2002-07-31 16:39:39 +00:00
|
|
|
~pageInfo();
|
2000-06-24 04:43:55 +00:00
|
|
|
|
2003-04-02 18:12:45 +00:00
|
|
|
QColor background;
|
2005-03-10 20:40:21 +00:00
|
|
|
QColor permanentBackground;
|
2000-06-24 04:43:55 +00:00
|
|
|
QString *PostScriptString;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2005-10-14 22:46:01 +00:00
|
|
|
class ghostscript_interface : public QObject
|
2000-06-24 04:43:55 +00:00
|
|
|
{
|
2001-06-11 13:40:16 +00:00
|
|
|
Q_OBJECT
|
2000-06-24 04:43:55 +00:00
|
|
|
|
|
|
|
public:
|
2004-12-12 13:44:38 +00:00
|
|
|
ghostscript_interface();
|
2000-06-24 04:43:55 +00:00
|
|
|
~ghostscript_interface();
|
|
|
|
|
|
|
|
void clear();
|
|
|
|
|
2003-04-02 18:12:45 +00:00
|
|
|
// sets the PostScript which is used on a certain page
|
2005-10-03 20:01:17 +00:00
|
|
|
void setPostScript(const PageNumber& page, const QString& PostScript);
|
2000-06-24 04:43:55 +00:00
|
|
|
|
2003-04-09 21:02:56 +00:00
|
|
|
// sets path from additional postscript files may be read
|
|
|
|
void setIncludePath(const QString &_includePath);
|
|
|
|
|
2005-10-14 22:46:01 +00:00
|
|
|
// Sets the background color for a certain page. If permanent is false then the original
|
2005-03-10 20:40:21 +00:00
|
|
|
// background color can be restored by calling restoreBackground(page).
|
2005-10-14 22:46:01 +00:00
|
|
|
// The Option permanent = false is used when we want to display a different paper
|
2005-03-10 20:40:21 +00:00
|
|
|
// color as the one specified in the dvi file.
|
2005-10-03 20:01:17 +00:00
|
|
|
void setBackgroundColor(const PageNumber& page, const QColor& background_color, bool permanent = true);
|
2005-03-10 20:40:21 +00:00
|
|
|
|
|
|
|
// Restore the background to the color which was specified by the last call to setBackgroundColor()
|
|
|
|
// With option permanent = true.
|
2005-10-03 20:01:17 +00:00
|
|
|
void restoreBackgroundColor(const PageNumber& page);
|
2003-04-02 18:12:45 +00:00
|
|
|
|
2004-12-17 20:34:29 +00:00
|
|
|
// Draws the graphics of the page into the painter, if possible. If
|
|
|
|
// the page does not contain any graphics, nothing happens
|
2005-10-03 20:01:17 +00:00
|
|
|
void graphics(const PageNumber& page, double dpi, long magnification, QPainter* paint);
|
2000-06-24 04:43:55 +00:00
|
|
|
|
2003-04-02 18:12:45 +00:00
|
|
|
// Returns the background color for a certain page. If no color was
|
|
|
|
// set, Qt::white is returned.
|
2005-10-03 20:01:17 +00:00
|
|
|
QColor getBackgroundColor(const PageNumber& page) const;
|
2003-04-02 18:12:45 +00:00
|
|
|
|
2000-06-24 04:43:55 +00:00
|
|
|
QString *PostScriptHeaderString;
|
|
|
|
|
2004-02-07 17:09:58 +00:00
|
|
|
/** This method tries to find the PostScript file 'filename' in the
|
2005-10-30 19:14:28 +00:00
|
|
|
DVI file's directory (if the base-URL indicates that the DVI file
|
|
|
|
is local), and, if that fails, uses kpsewhich to find the file. If
|
|
|
|
the file is found, the full path (including file name) is
|
|
|
|
returned. Otherwise, the method returns the first argument. TODO:
|
|
|
|
use the DVI file's baseURL, once this is implemented.
|
2004-02-07 17:09:58 +00:00
|
|
|
*/
|
2006-01-28 13:15:59 +00:00
|
|
|
static QString locateEPSfile(const QString &filename, const KUrl &base);
|
2004-02-07 17:09:58 +00:00
|
|
|
|
2000-06-24 04:43:55 +00:00
|
|
|
private:
|
2005-10-03 20:01:17 +00:00
|
|
|
void gs_generate_graphics_file(const PageNumber& page, const QString& filename, long magnification);
|
2005-10-28 21:45:29 +00:00
|
|
|
Q3IntDict<pageInfo> pageList;
|
2000-06-24 04:43:55 +00:00
|
|
|
|
2003-04-02 18:12:45 +00:00
|
|
|
double resolution; // in dots per inch
|
2000-06-24 04:43:55 +00:00
|
|
|
int pixel_page_w; // in pixels
|
|
|
|
int pixel_page_h; // in pixels
|
2001-06-11 13:40:16 +00:00
|
|
|
|
2003-04-09 21:02:56 +00:00
|
|
|
QString includePath;
|
|
|
|
|
2004-01-31 18:28:56 +00:00
|
|
|
// Output device that ghostscript is supposed tp use. Default is
|
|
|
|
// "png256". If that does not work, gs_generate_graphics_file will
|
|
|
|
// automatically try other known device drivers. If no known output
|
|
|
|
// device can be found, something is badly wrong. In that case,
|
|
|
|
// "gsDevice" is set to an empty string, and
|
|
|
|
// gs_generate_graphics_file will return immediately.
|
2005-08-07 11:29:43 +00:00
|
|
|
QList<QString>::iterator gsDevice;
|
2004-01-31 18:28:56 +00:00
|
|
|
|
2004-02-07 17:09:58 +00:00
|
|
|
// A list of known devices, set by the constructor. This includes
|
2004-01-31 18:28:56 +00:00
|
|
|
// "png256", "pnm". If a device is found to not work, its name is
|
|
|
|
// removed from the list, and another device name is tried.
|
|
|
|
QStringList knownDevices;
|
|
|
|
|
2001-06-11 13:40:16 +00:00
|
|
|
signals:
|
|
|
|
/** Passed through to the top-level kpart. */
|
|
|
|
void setStatusBarText( const QString& );
|
2000-06-24 04:43:55 +00:00
|
|
|
};
|
2000-08-18 17:53:00 +00:00
|
|
|
|
|
|
|
#endif
|