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>
|
2001-08-09 07:35:46 +00:00
|
|
|
#include <qvaluestack.h>
|
2001-11-03 14:23:24 +00:00
|
|
|
#include <qptrvector.h>
|
2000-06-09 05:31:11 +00:00
|
|
|
|
2000-11-03 14:38:50 +00:00
|
|
|
#include <kviewpart.h>
|
|
|
|
|
2001-10-18 16:40:34 +00:00
|
|
|
#include "bigEndianByteReader.h"
|
2001-03-02 21:02:45 +00:00
|
|
|
#include "fontpool.h"
|
2000-06-23 00:22:44 +00:00
|
|
|
#include "psgs.h"
|
|
|
|
#include "dvi_init.h"
|
2001-11-23 15:26:13 +00:00
|
|
|
#include "selection.h"
|
2000-06-23 00:22:44 +00:00
|
|
|
|
2001-06-04 09:44:47 +00:00
|
|
|
class fontProgressDialog;
|
2001-03-28 10:16:48 +00:00
|
|
|
class infoDialog;
|
2001-11-26 12:32:34 +00:00
|
|
|
class KAction;
|
2001-11-01 09:53:31 +00:00
|
|
|
class KEdFind;
|
2001-06-04 09:44:47 +00:00
|
|
|
class KPrinter;
|
2001-05-03 08:45:04 +00:00
|
|
|
class KShellProcess;
|
2001-06-04 09:44:47 +00:00
|
|
|
|
2000-06-23 00:22:44 +00:00
|
|
|
|
2001-04-08 09:21:27 +00:00
|
|
|
// max. number of hyperlinks per page. This should later be replaced by
|
2000-06-09 05:31:11 +00:00
|
|
|
// a dynamic allocation scheme.
|
2001-07-06 10:14:01 +00:00
|
|
|
#define MAX_HYPERLINKS 400
|
2001-04-08 09:21:27 +00:00
|
|
|
// max. number of anchors per document. This should later be replaced by
|
2000-06-11 07:04:57 +00:00
|
|
|
// a dynamic allocation scheme.
|
2001-07-06 10:14:01 +00:00
|
|
|
#define MAX_ANCHORS 1000
|
2000-06-09 05:31:11 +00:00
|
|
|
|
2000-06-23 00:22:44 +00:00
|
|
|
|
2000-06-09 05:31:11 +00:00
|
|
|
class DVI_Hyperlink {
|
|
|
|
public:
|
2001-07-06 10:14:01 +00:00
|
|
|
unsigned int baseline;
|
|
|
|
QRect box;
|
|
|
|
QString linkText;
|
2000-06-09 05:31:11 +00:00
|
|
|
};
|
|
|
|
|
1997-10-18 11:34:02 +00:00
|
|
|
|
2001-10-12 01:32:07 +00:00
|
|
|
/** Compound of registers, as defined in section 2.6.2 of the DVI
|
2001-08-09 07:35:46 +00:00
|
|
|
driver standard, Level 0, published by the TUG DVI driver
|
|
|
|
standards committee. */
|
|
|
|
|
|
|
|
struct framedata {
|
|
|
|
long dvi_h;
|
|
|
|
long dvi_v;
|
|
|
|
long w;
|
|
|
|
long x;
|
|
|
|
long y;
|
|
|
|
long z;
|
|
|
|
int pxl_v;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2001-10-18 16:40:34 +00:00
|
|
|
class dviWindow : public QWidget, bigEndianByteReader
|
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-11-29 12:17:44 +00:00
|
|
|
dviWindow( double zoom, int makepk, QWidget *parent=0, const char *name=0 );
|
2000-05-26 00:00:15 +00:00
|
|
|
~dviWindow();
|
|
|
|
|
2001-03-02 21:02:45 +00:00
|
|
|
class dvifile *dviFile;
|
2000-05-26 00:00:15 +00:00
|
|
|
|
2001-03-28 10:16:48 +00:00
|
|
|
void showInfo();
|
2001-06-04 09:44:47 +00:00
|
|
|
void exportPS(QString fname = QString::null, QString options = QString::null, KPrinter *printer = 0);
|
2001-05-03 08:45:04 +00:00
|
|
|
void exportPDF();
|
2001-10-27 11:38:16 +00:00
|
|
|
void exportText();
|
|
|
|
|
2001-11-23 15:26:13 +00:00
|
|
|
void changePageSize(void);
|
|
|
|
int totalPages(void);
|
2000-05-26 00:00:15 +00:00
|
|
|
void setShowPS( int flag );
|
2001-11-23 15:26:13 +00:00
|
|
|
int showPS(void) { return _postscript; };
|
|
|
|
int curr_page(void) { return current_page+1; };
|
2000-06-14 04:15:22 +00:00
|
|
|
void setShowHyperLinks( int flag );
|
2001-11-23 15:26:13 +00:00
|
|
|
int showHyperLinks(void) { return _showHyperLinks; };
|
2001-08-20 16:13:34 +00:00
|
|
|
void setEditorCommand( QString command ) { editorCommand = command; };
|
2000-05-26 00:00:15 +00:00
|
|
|
void setMakePK( int flag );
|
2001-11-23 15:26:13 +00:00
|
|
|
int makePK(void) { return makepk; };
|
2000-11-29 12:17:44 +00:00
|
|
|
void setMetafontMode( unsigned int );
|
2000-05-26 00:00:15 +00:00
|
|
|
void setPaper(double w, double h);
|
2000-06-23 00:22:44 +00:00
|
|
|
bool correctDVI(QString filename);
|
2000-05-26 00:00:15 +00:00
|
|
|
|
|
|
|
// for the preview
|
2000-06-23 00:22:44 +00:00
|
|
|
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 );
|
2001-04-08 09:21:27 +00:00
|
|
|
void mouseMoveEvent ( QMouseEvent * e );
|
2001-11-11 10:50:44 +00:00
|
|
|
void mouseReleaseEvent ( QMouseEvent * e );
|
2000-06-07 01:41:55 +00:00
|
|
|
void read_postamble(void);
|
2001-08-09 07:35:46 +00:00
|
|
|
void draw_part(double current_dimconv, bool is_vfmacro);
|
2000-06-09 05:31:11 +00:00
|
|
|
void set_vf_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);
|
2000-08-06 10:25:11 +00:00
|
|
|
void applicationDoSpecial(char * cp);
|
2001-08-20 16:13:34 +00:00
|
|
|
|
|
|
|
|
2000-06-09 05:31:11 +00:00
|
|
|
void special(long nbytes);
|
|
|
|
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);
|
2001-03-02 21:02:45 +00:00
|
|
|
void draw_page(void);
|
2000-06-23 00:22:44 +00:00
|
|
|
|
2001-03-02 21:02:45 +00:00
|
|
|
class fontPool *font_pool;
|
2001-05-03 08:45:04 +00:00
|
|
|
|
2001-07-09 07:41:24 +00:00
|
|
|
double xres; // horizontal resolution of the display device in dots per inch.
|
|
|
|
double paper_width; // paper width in centimeters
|
|
|
|
double paper_height; // paper height in centimeters
|
|
|
|
|
2001-11-23 15:26:13 +00:00
|
|
|
selection DVIselection;
|
|
|
|
|
2001-11-20 12:46:54 +00:00
|
|
|
/** Reference part of the URL which describes the filename. */
|
|
|
|
QString reference;
|
2001-07-09 07:41:24 +00:00
|
|
|
|
2001-11-26 12:32:34 +00:00
|
|
|
QString searchText;
|
|
|
|
KAction *findNextAction;
|
|
|
|
KAction *findPrevAction;
|
2001-07-09 07:41:24 +00:00
|
|
|
|
1997-10-18 11:34:02 +00:00
|
|
|
public slots:
|
2001-11-23 15:26:13 +00:00
|
|
|
void selectAll(void);
|
|
|
|
void copyText(void);
|
|
|
|
void showFindTextDialog(void);
|
2001-11-26 12:32:34 +00:00
|
|
|
void findText(void);
|
|
|
|
void findNextText(void);
|
|
|
|
void findPrevText(void);
|
2001-11-23 15:26:13 +00:00
|
|
|
|
2001-05-03 08:45:04 +00:00
|
|
|
void abortExternalProgramm(void);
|
2001-11-27 10:56:25 +00:00
|
|
|
bool setFile(QString fname, QString ref = QString::null, bool sourceMarker=true);
|
2001-05-21 07:15:24 +00:00
|
|
|
|
|
|
|
/** Displays the page of the first argument */
|
2001-08-28 13:02:20 +00:00
|
|
|
void gotoPage(unsigned int page);
|
2001-05-21 07:15:24 +00:00
|
|
|
|
|
|
|
/** Displays the page of the first argument, and blinks the display
|
|
|
|
at the vertical offset vflashOffset. This is used when the user
|
|
|
|
clicks on a hyperlink: the target of the jump flashes so that
|
|
|
|
the user can locate it more easily. */
|
|
|
|
void gotoPage(int page, int vflashOffset);
|
2000-11-03 14:38:50 +00:00
|
|
|
double setZoom(double zoom);
|
2000-06-11 07:04:57 +00:00
|
|
|
double zoom() { return _zoom; };
|
2001-03-02 21:02:45 +00:00
|
|
|
void drawPage();
|
2001-09-03 08:57:03 +00:00
|
|
|
|
|
|
|
/** Slots used in conjunction with external programs */
|
2001-05-03 08:45:04 +00:00
|
|
|
void dvips_output_receiver(KProcess *, char *buffer, int buflen);
|
|
|
|
void dvips_terminated(KProcess *);
|
2001-09-03 08:57:03 +00:00
|
|
|
void editorCommand_terminated(KProcess *);
|
2001-11-26 12:32:34 +00:00
|
|
|
|
2001-11-01 09:53:31 +00:00
|
|
|
|
2001-11-16 16:26:38 +00:00
|
|
|
/** This slot is usually called by the fontpool if all fonts are
|
|
|
|
loaded. The method will try to parse the reference part of the
|
|
|
|
DVI file's URL, e.g. src:<line><filename> and see if a
|
|
|
|
corresponding section of the DVI file can be found. If so, it
|
|
|
|
will emit a "requestGotoPage", otherwise it will just call
|
|
|
|
drawpage */
|
|
|
|
void all_fonts_loaded();
|
|
|
|
|
2000-06-11 07:04:57 +00:00
|
|
|
signals:
|
2001-06-05 07:25:25 +00:00
|
|
|
/** 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. */
|
2000-06-11 07:04:57 +00:00
|
|
|
void request_goto_page(int page, int y);
|
2000-06-01 10:27:41 +00:00
|
|
|
|
2001-06-05 07:25:25 +00:00
|
|
|
/** Emitted to indicate the the contents of the widget has changed
|
|
|
|
and that the tumbnail image should be updated. */
|
|
|
|
void contents_changed(void);
|
|
|
|
|
2001-06-11 13:40:16 +00:00
|
|
|
/** Passed through to the top-level kpart. */
|
|
|
|
void setStatusBarText( const QString& );
|
|
|
|
|
1997-10-18 11:34:02 +00:00
|
|
|
protected:
|
2001-11-01 09:53:31 +00:00
|
|
|
void paintEvent(QPaintEvent *ev);
|
2000-05-15 06:51:49 +00:00
|
|
|
|
1997-10-18 11:34:02 +00:00
|
|
|
private:
|
2001-11-01 09:53:31 +00:00
|
|
|
QString errorMsg;
|
|
|
|
|
2001-08-20 16:13:34 +00:00
|
|
|
/** Methods which handle certain special commands. */
|
|
|
|
void bang_special(QString cp);
|
|
|
|
void quote_special(QString cp);
|
|
|
|
void ps_special(QString cp);
|
|
|
|
void epsf_special(QString cp);
|
|
|
|
void header_special(QString cp);
|
|
|
|
void source_special(QString cp);
|
|
|
|
|
|
|
|
/** List of source-hyperlinks, for source-specials */
|
|
|
|
DVI_Hyperlink sourceHyperLinkList[MAX_HYPERLINKS];
|
|
|
|
int num_of_used_source_hyperlinks;
|
|
|
|
QString *source_href; // If not NULL, the text currently
|
|
|
|
// drawn represents a source hyperlink
|
|
|
|
// to the (relative) URL given in the
|
|
|
|
// string;
|
|
|
|
QString editorCommand;
|
|
|
|
|
|
|
|
/** List of ordinary-hyperlinks */
|
|
|
|
DVI_Hyperlink hyperLinkList[MAX_HYPERLINKS];
|
|
|
|
int num_of_used_hyperlinks;
|
|
|
|
QString *HTML_href; // If not NULL, the text currently drawn
|
|
|
|
// represents a hyperlink to the
|
|
|
|
// (relative) URL given in the string;
|
|
|
|
|
2001-10-27 11:38:16 +00:00
|
|
|
/** List of text in the window */
|
|
|
|
DVI_Hyperlink textLinkList[MAX_HYPERLINKS];
|
|
|
|
int num_of_used_textlinks;
|
|
|
|
|
|
|
|
|
2001-08-09 07:35:46 +00:00
|
|
|
/** Stack for register compounds, used for the DVI-commands PUSH/POP
|
|
|
|
as explained in section 2.5 and 2.6.2 of the DVI driver standard,
|
|
|
|
Level 0, published by the TUG DVI driver standards committee. */
|
|
|
|
QValueStack<struct framedata> stack;
|
|
|
|
|
2001-05-21 07:15:24 +00:00
|
|
|
/** Methods and counters used for the animation to mark the target of
|
|
|
|
an hyperlink. */
|
|
|
|
int timerIdent;
|
|
|
|
void timerEvent( QTimerEvent *e );
|
|
|
|
int animationCounter;
|
|
|
|
int flashOffset;
|
|
|
|
|
2001-11-10 19:56:40 +00:00
|
|
|
/** Methods and classes concerned with the find functionality and
|
|
|
|
with selecting text */
|
2001-11-01 09:53:31 +00:00
|
|
|
class KEdFind *findDialog;
|
2001-11-10 19:56:40 +00:00
|
|
|
QRect selectedRectangle;
|
|
|
|
|
|
|
|
|
2001-11-01 09:53:31 +00:00
|
|
|
|
2001-08-09 07:35:46 +00:00
|
|
|
/** These fields contain information about the geometry of the
|
|
|
|
page. */
|
2001-07-09 07:41:24 +00:00
|
|
|
unsigned int unshrunk_page_w; // basedpi * width(in inch)
|
|
|
|
unsigned int unshrunk_page_h; // basedpi * height(in inch)
|
2000-06-09 05:31:11 +00:00
|
|
|
|
2001-03-28 10:16:48 +00:00
|
|
|
infoDialog *info;
|
|
|
|
|
2001-08-09 07:35:46 +00:00
|
|
|
/** 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;
|
2000-06-09 05:31:11 +00:00
|
|
|
|
2000-06-23 00:22:44 +00:00
|
|
|
ghostscript_interface *PS_interface;
|
2000-06-09 05:31:11 +00:00
|
|
|
|
2001-09-03 08:57:03 +00:00
|
|
|
/** TRUE, if gs should be used, otherwise, only bounding boxes are
|
|
|
|
drawn. */
|
2000-06-09 05:31:11 +00:00
|
|
|
unsigned char _postscript;
|
|
|
|
|
2001-09-03 08:57:03 +00:00
|
|
|
/** TRUE, if Hyperlinks should be shown. */
|
2000-06-14 04:15:22 +00:00
|
|
|
unsigned char _showHyperLinks;
|
|
|
|
|
2001-09-03 08:57:03 +00:00
|
|
|
/** This flag is used when rendering a dvi-page. It is set to "true"
|
|
|
|
when any dvi-command other than "set" or "put" series of commands
|
|
|
|
is encountered. This is considered to mark the end of a word. */
|
2001-10-27 11:38:16 +00:00
|
|
|
bool line_boundary_encountered;
|
2001-07-06 10:14:01 +00:00
|
|
|
bool word_boundary_encountered;
|
|
|
|
|
2001-09-03 08:57:03 +00:00
|
|
|
/** List of anchors in a document */
|
2000-06-11 07:04:57 +00:00
|
|
|
QString AnchorList_String[MAX_ANCHORS];
|
2000-11-29 12:17:44 +00:00
|
|
|
unsigned int AnchorList_Page[MAX_ANCHORS];
|
|
|
|
double AnchorList_Vert[MAX_ANCHORS];
|
2000-06-11 07:04:57 +00:00
|
|
|
int numAnchors;
|
|
|
|
|
2000-06-09 05:31:11 +00:00
|
|
|
int basedpi;
|
|
|
|
int makepk;
|
|
|
|
QPixmap *pixmap;
|
2000-11-29 12:17:44 +00:00
|
|
|
unsigned int MetafontMode;
|
2000-06-09 05:31:11 +00:00
|
|
|
QString paper_type;
|
|
|
|
int ChangesPossible;
|
2001-08-28 13:02:20 +00:00
|
|
|
unsigned int current_page;
|
2001-09-03 08:57:03 +00:00
|
|
|
|
|
|
|
/** Indicates if the current page is already drawn (=1) or not
|
|
|
|
(=0). */
|
2000-07-07 02:07:26 +00:00
|
|
|
char is_current_page_drawn;
|
2000-06-09 05:31:11 +00:00
|
|
|
double _zoom;
|
2001-05-03 08:45:04 +00:00
|
|
|
|
2001-09-03 08:57:03 +00:00
|
|
|
/** Used to run and to show the progress of dvips and friends. */
|
2001-05-03 08:45:04 +00:00
|
|
|
fontProgressDialog *progress;
|
2001-06-04 09:44:47 +00:00
|
|
|
KShellProcess *proc;
|
|
|
|
KPrinter *export_printer;
|
|
|
|
QString export_fileName;
|
2001-08-28 13:02:20 +00:00
|
|
|
QString export_tmpFileName;
|
2001-09-03 08:57:03 +00:00
|
|
|
QString export_errorString;
|
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>
|
|
|
|
|
|
|
|
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 */
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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;
|
|
|
|
struct font *_virtual;
|
2000-05-20 05:08:51 +00:00
|
|
|
};
|
|
|
|
|
2000-08-18 17:53:00 +00:00
|
|
|
#undef Unsorted
|
|
|
|
|
1999-06-27 19:06:40 +00:00
|
|
|
#endif
|