1997-10-18 11:34:02 +00:00
|
|
|
//
|
|
|
|
// Class: dviWindow
|
|
|
|
//
|
|
|
|
// Widget for displaying TeX DVI files.
|
|
|
|
//
|
|
|
|
|
1999-06-27 19:06:40 +00:00
|
|
|
#ifndef _dviwin_h_
|
|
|
|
#define _dviwin_h_
|
|
|
|
|
2000-05-15 06:51:49 +00:00
|
|
|
|
2000-06-09 05:31:11 +00:00
|
|
|
#include <stdio.h>
|
|
|
|
|
1997-12-12 13:32:43 +00:00
|
|
|
#include "../config.h"
|
1997-10-18 11:34:02 +00:00
|
|
|
#include <qpainter.h>
|
|
|
|
#include <qevent.h>
|
2000-05-15 06:51:49 +00:00
|
|
|
#include <qwidget.h>
|
2000-05-26 00:00:15 +00:00
|
|
|
#include <qintdict.h>
|
2000-06-09 05:31:11 +00:00
|
|
|
#include <qvector.h>
|
|
|
|
|
|
|
|
// max. number of hyperlinks per page. This should late be replaced by
|
|
|
|
// a dynamic allocation scheme.
|
|
|
|
#define MAX_HYPERLINKS 200
|
2000-06-11 07:04:57 +00:00
|
|
|
// max. number of anchors per document. This should late be replaced by
|
|
|
|
// a dynamic allocation scheme.
|
|
|
|
#define MAX_ANCHORS 300
|
2000-06-09 05:31:11 +00:00
|
|
|
|
|
|
|
class DVI_Hyperlink {
|
|
|
|
public:
|
|
|
|
QRect box;
|
|
|
|
QString linkText;
|
|
|
|
};
|
|
|
|
|
1997-10-18 11:34:02 +00:00
|
|
|
|
2000-05-15 06:51:49 +00:00
|
|
|
class dviWindow : public QWidget
|
1997-10-18 11:34:02 +00:00
|
|
|
{
|
2000-05-26 00:00:15 +00:00
|
|
|
Q_OBJECT
|
1997-10-18 11:34:02 +00:00
|
|
|
|
|
|
|
public:
|
2000-05-26 00:00:15 +00:00
|
|
|
dviWindow( int basedpi, double zoom, const char *mfmode, int makepk,
|
|
|
|
QWidget *parent=0, const char *name=0 );
|
|
|
|
~dviWindow();
|
|
|
|
|
|
|
|
int totalPages();
|
|
|
|
|
|
|
|
void setShowPS( int flag );
|
|
|
|
int showPS();
|
|
|
|
void setAntiAlias( int flag );
|
|
|
|
int antiAlias();
|
|
|
|
void setMakePK( int flag );
|
|
|
|
int makePK();
|
|
|
|
void setResolution( int basedpi );
|
|
|
|
int resolution();
|
|
|
|
void setMetafontMode( const char * );
|
|
|
|
const char * metafontMode();
|
|
|
|
void setPaper(double w, double h);
|
|
|
|
void setFontPath( const char * );
|
|
|
|
const char * fontPath();
|
|
|
|
|
|
|
|
// for the preview
|
|
|
|
QPixmap *pix() { return pixmap; };
|
2000-06-07 01:41:55 +00:00
|
|
|
|
|
|
|
// These should not be public... only for the moment
|
2000-06-09 05:31:11 +00:00
|
|
|
void mousePressEvent ( QMouseEvent * e );
|
2000-06-07 01:41:55 +00:00
|
|
|
void read_postamble(void);
|
|
|
|
char init_dvi_file(void);
|
|
|
|
char check_dvi_file(void);
|
|
|
|
void draw_part(struct frame *minframe, double current_dimconv);
|
|
|
|
void draw_page(void);
|
2000-06-09 05:31:11 +00:00
|
|
|
void set_vf_char(unsigned int cmd, unsigned int ch);
|
|
|
|
void load_n_set_char(unsigned int cmd, unsigned int ch);
|
|
|
|
void set_char(unsigned int cmd, unsigned int ch);
|
|
|
|
void set_empty_char(unsigned int cmd, unsigned int ch);
|
|
|
|
void set_no_char(unsigned int cmd, unsigned int ch);
|
|
|
|
void renderPostScript(QString *PostScript);
|
|
|
|
void applicationDoSpecial(char *cp);
|
|
|
|
void special(long nbytes);
|
|
|
|
void bang_special(QString cp);
|
|
|
|
void quote_special(QString cp);
|
|
|
|
void epsf_special(QString cp);
|
|
|
|
void header_special(QString cp);
|
|
|
|
void html_href_special(QString cp);
|
|
|
|
void html_anchor_end(void);
|
2000-06-11 07:04:57 +00:00
|
|
|
void html_anchor_special(QString cp);
|
|
|
|
void drawPage();
|
|
|
|
bool correctDVI();
|
2000-06-07 01:41:55 +00:00
|
|
|
|
1997-10-18 11:34:02 +00:00
|
|
|
public slots:
|
2000-06-07 01:41:55 +00:00
|
|
|
void setFile(const char *fname);
|
|
|
|
void gotoPage(int page);
|
2000-06-11 07:04:57 +00:00
|
|
|
void setZoom(double zoom);
|
|
|
|
double zoom() { return _zoom; };
|
2000-05-15 14:53:59 +00:00
|
|
|
|
2000-06-11 07:04:57 +00:00
|
|
|
signals:
|
|
|
|
/// Emitted to indicate that a hyperlink has been clicked on, and
|
|
|
|
//that the widget requests that the controlling program goes to the
|
|
|
|
//page and the coordinates specified.
|
|
|
|
void request_goto_page(int page, int y);
|
2000-06-01 10:27:41 +00:00
|
|
|
|
1997-10-18 11:34:02 +00:00
|
|
|
protected:
|
2000-05-26 00:00:15 +00:00
|
|
|
void paintEvent(QPaintEvent *ev);
|
2000-05-15 06:51:49 +00:00
|
|
|
|
1997-10-18 11:34:02 +00:00
|
|
|
|
|
|
|
private:
|
2000-06-09 05:31:11 +00:00
|
|
|
|
|
|
|
// These fields contain information about the geometry of the page.
|
|
|
|
unsigned int unshrunk_paper_w; // basedpi * width(in inch)
|
|
|
|
unsigned int unshrunk_paper_h; // basedpi * height(in inch)
|
|
|
|
unsigned int unshrunk_page_w;
|
|
|
|
unsigned int unshrunk_page_h;
|
|
|
|
|
|
|
|
// If PostScriptOutPutFile is non-zero, then no rendering takes
|
|
|
|
// place. Instead, the PostScript code which is generated by the
|
|
|
|
// \special-commands is written to the PostScriptString
|
|
|
|
QString *PostScriptOutPutString;
|
|
|
|
|
|
|
|
// Contains headers for PostScript, which must be send whenever
|
|
|
|
// ghostview is started
|
|
|
|
QString PostScriptHeaderString;
|
|
|
|
|
|
|
|
// TRUE, if gs should be used, otherwise, only bounding boxes are
|
|
|
|
// drawn.
|
|
|
|
unsigned char _postscript;
|
|
|
|
|
|
|
|
// For each page, this vector contains the PostScript needed to
|
|
|
|
// render that page. All entries point to valid QString which migt,
|
|
|
|
// however, be empty.
|
|
|
|
QVector<QString> *PostScriptDirectory;
|
|
|
|
|
|
|
|
// If not NULL, the text currently drawn represents a hyperlink
|
|
|
|
// to the (relative) URL given in the string;
|
|
|
|
QString *HTML_href;
|
|
|
|
|
|
|
|
DVI_Hyperlink hyperLinkList[MAX_HYPERLINKS];
|
|
|
|
int num_of_used_hyperlinks;
|
|
|
|
|
2000-06-11 07:04:57 +00:00
|
|
|
// List of anchors in a document
|
|
|
|
QString AnchorList_String[MAX_ANCHORS];
|
|
|
|
unsigned int AnchorList_Page[MAX_ANCHORS];
|
|
|
|
double AnchorList_Vert[MAX_ANCHORS];
|
|
|
|
int numAnchors;
|
|
|
|
|
2000-06-09 05:31:11 +00:00
|
|
|
void initDVI();
|
|
|
|
void changePageSize();
|
|
|
|
QString filename;
|
|
|
|
int basedpi;
|
|
|
|
int makepk;
|
|
|
|
QPixmap *pixmap;
|
|
|
|
QString MetafontMode;
|
|
|
|
QString FontPath;
|
|
|
|
QString paper_type;
|
|
|
|
int ChangesPossible;
|
|
|
|
double _zoom;
|
1997-10-18 11:34:02 +00:00
|
|
|
};
|
1999-06-27 19:06:40 +00:00
|
|
|
|
2000-05-20 05:08:51 +00:00
|
|
|
|
|
|
|
#include <X11/Xlib.h>
|
|
|
|
//#include <X11/Intrinsic.h>
|
|
|
|
|
|
|
|
struct WindowRec {
|
|
|
|
Window win;
|
|
|
|
double shrinkfactor;
|
|
|
|
int base_x;
|
|
|
|
int base_y;
|
|
|
|
unsigned int width;
|
|
|
|
unsigned int height;
|
|
|
|
int min_x; /* for pending expose events */
|
|
|
|
int max_x; /* for pending expose events */
|
|
|
|
int min_y; /* for pending expose events */
|
|
|
|
int max_y; /* for pending expose events */
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
struct framedata {
|
|
|
|
long dvi_h;
|
|
|
|
long dvi_v;
|
|
|
|
long w;
|
|
|
|
long x;
|
|
|
|
long y;
|
|
|
|
long z;
|
|
|
|
int pxl_v;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
struct frame {
|
|
|
|
struct framedata data;
|
|
|
|
struct frame *next, *prev;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
2000-06-09 05:31:11 +00:00
|
|
|
typedef void (dviWindow::*set_char_proc)(unsigned int, unsigned int);
|
2000-05-20 05:08:51 +00:00
|
|
|
|
|
|
|
#include "font.h"
|
|
|
|
|
2000-05-26 00:00:15 +00:00
|
|
|
/* this information is saved when using virtual fonts */
|
|
|
|
struct drawinf {
|
|
|
|
struct framedata data;
|
|
|
|
struct font *fontp;
|
|
|
|
set_char_proc set_char_p;
|
|
|
|
|
|
|
|
QIntDict<struct font> fonttable;
|
|
|
|
unsigned char *pos;
|
|
|
|
unsigned char *end;
|
|
|
|
struct font *_virtual;
|
|
|
|
int dir;
|
2000-05-20 05:08:51 +00:00
|
|
|
};
|
|
|
|
|
1999-06-27 19:06:40 +00:00
|
|
|
#endif
|