1
//========================================================================
5
// Copyright 2002-2003 Glyph & Cog, LLC
7
//========================================================================
14
#ifdef USE_GCC_PRAGMAS
18
#define Object XtObject
22
#include "gfile.h" // for time_t
23
#include "SplashTypes.h"
31
//------------------------------------------------------------------------
33
#define xMaxRGBCube 6 // max size of RGB color cube
35
//------------------------------------------------------------------------
37
//------------------------------------------------------------------------
39
typedef void (*XPDFUpdateCbk)(void *data, GString *fileName,
40
int pageNum, int numPages, char *linkLabel);
42
typedef void (*XPDFActionCbk)(void *data, char *action);
44
typedef void (*XPDFKeyPressCbk)(void *data, KeySym key, Guint modifiers,
47
typedef void (*XPDFMouseCbk)(void *data, XEvent *event);
49
//------------------------------------------------------------------------
51
//------------------------------------------------------------------------
53
class XPDFCore: public PDFCore {
56
// Create viewer core inside <parentWidgetA>.
57
XPDFCore(Widget shellA, Widget parentWidgetA,
58
SplashColorPtr paperColorA, Gulong paperPixelA,
59
Gulong mattePixelA, GBool fullScreenA, GBool reverseVideoA,
60
GBool installCmap, int rgbCubeSizeA);
64
//----- loadFile / displayPage / displayDest
66
// Load a new file. Returns pdfOk or error code.
67
virtual int loadFile(GString *fileName, GString *ownerPassword = NULL,
68
GString *userPassword = NULL);
70
// Load a new file, via a Stream instead of a file name. Returns
71
// pdfOk or error code.
72
virtual int loadFile(BaseStream *stream, GString *ownerPassword = NULL,
73
GString *userPassword = NULL);
75
// Load an already-created PDFDoc object.
76
virtual void loadDoc(PDFDoc *docA);
78
// Resize the window to fit page <pg> of the current document.
79
void resizeToPage(int pg);
81
// Update the display, given the specified parameters.
82
virtual void update(int topPageA, int scrollXA, int scrollYA,
83
double zoomA, int rotateA,
84
GBool force, GBool addToHist);
86
//----- page/position changes
88
virtual GBool gotoNextPage(int inc, GBool top);
89
virtual GBool gotoPrevPage(int dec, GBool top, GBool bottom);
90
virtual GBool goForward();
91
virtual GBool goBackward();
95
void startSelection(int wx, int wy);
96
void endSelection(int wx, int wy);
98
void startPan(int wx, int wy);
99
void endPan(int wx, int wy);
103
void doAction(LinkAction *action);
104
LinkAction *getLinkAction() { return linkAction; }
105
GString *mungeURL(GString *url);
109
virtual GBool find(char *s, GBool caseSensitive,
110
GBool next, GBool backward, GBool onePageOnly);
111
virtual GBool findU(Unicode *u, int len, GBool caseSensitive,
112
GBool next, GBool backward, GBool onePageOnly);
114
//----- simple modal dialogs
116
GBool doQuestionDialog(char *title, GString *msg);
117
void doInfoDialog(char *title, GString *msg);
118
void doErrorDialog(char *title, GString *msg);
120
//----- password dialog
122
GString *getPassword();
126
Widget getWidget() { return scrolledWin; }
127
Widget getDrawAreaWidget() { return drawArea; }
128
virtual void setBusyCursor(GBool busy);
129
Cursor getBusyCursor() { return busyCursor; }
131
void enableHyperlinks(GBool on) { hyperlinksEnabled = on; }
132
GBool getHyperlinksEnabled() { return hyperlinksEnabled; }
133
void enableSelect(GBool on) { selectEnabled = on; }
134
void setUpdateCbk(XPDFUpdateCbk cbk, void *data)
135
{ updateCbk = cbk; updateCbkData = data; }
136
void setActionCbk(XPDFActionCbk cbk, void *data)
137
{ actionCbk = cbk; actionCbkData = data; }
138
void setKeyPressCbk(XPDFKeyPressCbk cbk, void *data)
139
{ keyPressCbk = cbk; keyPressCbkData = data; }
140
void setMouseCbk(XPDFMouseCbk cbk, void *data)
141
{ mouseCbk = cbk; mouseCbkData = data; }
142
GBool getFullScreen() { return fullScreen; }
146
virtual GBool checkForNewFile();
149
void runCommand(GString *cmdFmt, GString *arg);
152
static Boolean convertSelectionCbk(Widget widget, Atom *selection,
153
Atom *target, Atom *type,
154
XtPointer *value, unsigned long *length,
158
void setupX(GBool installCmap, int rgbCubeSizeA);
160
static void hScrollChangeCbk(Widget widget, XtPointer ptr,
162
static void hScrollDragCbk(Widget widget, XtPointer ptr,
164
static void vScrollChangeCbk(Widget widget, XtPointer ptr,
166
static void vScrollDragCbk(Widget widget, XtPointer ptr,
168
static void resizeCbk(Widget widget, XtPointer ptr, XtPointer callData);
169
static void redrawCbk(Widget widget, XtPointer ptr, XtPointer callData);
170
static void inputCbk(Widget widget, XtPointer ptr, XtPointer callData);
171
virtual PDFCoreTile *newTile(int xDestA, int yDestA);
172
virtual void updateTileData(PDFCoreTile *tileA, int xSrc, int ySrc,
173
int width, int height, GBool composited);
174
virtual void redrawRect(PDFCoreTile *tileA, int xSrc, int ySrc,
175
int xDest, int yDest, int width, int height,
177
virtual void updateScrollbars();
178
void setCursor(Cursor cursor);
179
GBool doDialog(int type, GBool hasCancel,
180
char *title, GString *msg);
181
static void dialogOkCbk(Widget widget, XtPointer ptr,
183
static void dialogCancelCbk(Widget widget, XtPointer ptr,
185
void initPasswordDialog();
186
static void passwordTextVerifyCbk(Widget widget, XtPointer ptr,
188
static void passwordOkCbk(Widget widget, XtPointer ptr,
190
static void passwordCancelCbk(Widget widget, XtPointer ptr,
195
//~unimp: move fullScreen into PDFCore?
202
Guint depth; // visual depth
203
GBool trueColor; // set if using a TrueColor visual
204
int rDiv, gDiv, bDiv; // RGB right shifts (for TrueColor)
205
int rShift, gShift, bShift; // RGB left shifts (for TrueColor)
206
int rgbCubeSize; // size of color cube (for non-TrueColor)
207
Gulong // color cube (for non-TrueColor)
208
colors[xMaxRGBCube * xMaxRGBCube * xMaxRGBCube];
210
Widget shell; // top-level shell containing the widget
211
Widget parentWidget; // parent widget (not created by XPDFCore)
215
Widget drawAreaFrame;
217
Cursor busyCursor, linkCursor, selectCursor;
218
Cursor currentCursor;
219
GC drawAreaGC; // GC for blitting into drawArea
221
static GString *currentSelection; // selected text
222
static XPDFCore *currentSelectionOwner;
223
static Atom targetsAtom;
228
time_t modTime; // last modification time of PDF file
230
LinkAction *linkAction; // mouse cursor is over this link
232
XPDFUpdateCbk updateCbk;
234
XPDFActionCbk actionCbk;
236
XPDFKeyPressCbk keyPressCbk;
237
void *keyPressCbkData;
238
XPDFMouseCbk mouseCbk;
241
GBool hyperlinksEnabled;
246
Widget passwordDialog;