-
Notifications
You must be signed in to change notification settings - Fork 16
/
XPDFViewer.h
360 lines (319 loc) · 12.8 KB
/
XPDFViewer.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
//========================================================================
//
// XPDFViewer.h
//
// Copyright 2002-2003 Glyph & Cog, LLC
//
//========================================================================
#ifndef XPDFVIEWER_H
#define XPDFVIEWER_H
#include <poppler-config.h>
#ifdef USE_GCC_PRAGMAS
#pragma interface
#endif
#define Object XtObject
#include <Xm/XmAll.h>
#undef Object
#include "XPDFCore.h"
#if (XmVERSION <= 1) && !defined(__sgi)
#define DISABLE_OUTLINE
#endif
#if (XmVERSION >= 2 && !defined(LESSTIF_VERSION))
# define USE_COMBO_BOX 1
#else
# undef USE_COMBO_BOX
#endif
class GooString;
class GooList;
class UnicodeMap;
class LinkDest;
class XPDFApp;
class XPDFViewer;
//------------------------------------------------------------------------
struct XPDFViewerCmd {
char *name;
int nArgs;
bool requiresDoc;
bool requiresEvent;
void (XPDFViewer::*func)(GooString *args[], int nArgs, XEvent *event);
};
//------------------------------------------------------------------------
//------------------------------------------------------------------------
// XPDFViewer
//------------------------------------------------------------------------
class XPDFViewer {
public:
XPDFViewer(XPDFApp *appA, GooString *fileName,
int pageA, GooString *destName, bool fullScreen,
GooString *ownerPassword, GooString *userPassword);
XPDFViewer(XPDFApp *appA, PDFDoc *doc, int pageA,
GooString *destName, bool fullScreen);
bool isOk() { return ok; }
~XPDFViewer();
void open(GooString *fileName, int pageA, GooString *destName);
void clear();
void reloadFile();
void execCmd(GooString *cmd, XEvent *event);
Widget getWindow() { return win; }
private:
//----- load / display
bool loadFile(GooString *fileName, GooString *ownerPassword = NULL,
GooString *userPassword = NULL);
void displayPage(int pageA, double zoomA, int rotateA,
bool scrollToTop, bool addToHist);
void displayDest(LinkDest *dest, double zoomA, int rotateA,
bool addToHist);
void getPageAndDest(int pageA, GooString *destName,
int *pageOut, LinkDest **destOut);
//----- hyperlinks / actions
void doLink(int wx, int wy, bool onlyIfNoSelection, bool newWin);
static void actionCbk(void *data, char *action);
//----- keyboard/mouse input
static void keyPressCbk(void *data, KeySym key, unsigned modifiers,
XEvent *event);
static void mouseCbk(void *data, XEvent *event);
int getModifiers(unsigned modifiers);
int getContext(unsigned modifiers);
//----- command functions
void cmdAbout(GooString *args[], int nArgs, XEvent *event);
void cmdCloseOutline(GooString *args[], int nArgs, XEvent *event);
void cmdCloseWindow(GooString *args[], int nArgs, XEvent *event);
void cmdContinuousMode(GooString *args[], int nArgs, XEvent *event);
void cmdEndPan(GooString *args[], int nArgs, XEvent *event);
void cmdEndSelection(GooString *args[], int nArgs, XEvent *event);
void cmdFind(GooString *args[], int nArgs, XEvent *event);
void cmdFindNext(GooString *args[], int nArgs, XEvent *event);
void cmdFocusToDocWin(GooString *args[], int nArgs, XEvent *event);
void cmdFocusToPageNum(GooString *args[], int nArgs, XEvent *event);
void cmdFollowLink(GooString *args[], int nArgs, XEvent *event);
void cmdFollowLinkInNewWin(GooString *args[], int nArgs, XEvent *event);
void cmdFollowLinkInNewWinNoSel(GooString *args[], int nArgs, XEvent *event);
void cmdFollowLinkNoSel(GooString *args[], int nArgs, XEvent *event);
void cmdFullScreenMode(GooString *args[], int nArgs, XEvent *event);
void cmdGoBackward(GooString *args[], int nArgs, XEvent *event);
void cmdGoForward(GooString *args[], int nArgs, XEvent *event);
void cmdGotoDest(GooString *args[], int nArgs, XEvent *event);
void cmdGotoLastPage(GooString *args[], int nArgs, XEvent *event);
void cmdGotoLastPageNoScroll(GooString *args[], int nArgs, XEvent *event);
void cmdGotoPage(GooString *args[], int nArgs, XEvent *event);
void cmdGotoPageNoScroll(GooString *args[], int nArgs, XEvent *event);
void cmdNextPage(GooString *args[], int nArgs, XEvent *event);
void cmdNextPageNoScroll(GooString *args[], int nArgs, XEvent *event);
void cmdOpen(GooString *args[], int nArgs, XEvent *event);
void cmdOpenFile(GooString *args[], int nArgs, XEvent *event);
void cmdOpenFileAtDest(GooString *args[], int nArgs, XEvent *event);
void cmdOpenFileAtDestInNewWin(GooString *args[], int nArgs, XEvent *event);
void cmdOpenFileAtPage(GooString *args[], int nArgs, XEvent *event);
void cmdOpenFileAtPageInNewWin(GooString *args[], int nArgs, XEvent *event);
void cmdOpenFileInNewWin(GooString *args[], int nArgs, XEvent *event);
void cmdOpenInNewWin(GooString *args[], int nArgs, XEvent *event);
void cmdOpenOutline(GooString *args[], int nArgs, XEvent *event);
void cmdPageDown(GooString *args[], int nArgs, XEvent *event);
void cmdPageUp(GooString *args[], int nArgs, XEvent *event);
void cmdPostPopupMenu(GooString *args[], int nArgs, XEvent *event);
void cmdPrevPage(GooString *args[], int nArgs, XEvent *event);
void cmdPrevPageNoScroll(GooString *args[], int nArgs, XEvent *event);
void cmdPrint(GooString *args[], int nArgs, XEvent *event);
void cmdQuit(GooString *args[], int nArgs, XEvent *event);
void cmdRaise(GooString *args[], int nArgs, XEvent *event);
void cmdRedraw(GooString *args[], int nArgs, XEvent *event);
void cmdReload(GooString *args[], int nArgs, XEvent *event);
void cmdRun(GooString *args[], int nArgs, XEvent *event);
void cmdScrollDown(GooString *args[], int nArgs, XEvent *event);
void cmdScrollDownNextPage(GooString *args[], int nArgs, XEvent *event);
void cmdScrollLeft(GooString *args[], int nArgs, XEvent *event);
void cmdScrollOutlineDown(GooString *args[], int nArgs, XEvent *event);
void cmdScrollOutlineUp(GooString *args[], int nArgs, XEvent *event);
void cmdScrollRight(GooString *args[], int nArgs, XEvent *event);
void cmdScrollToBottomEdge(GooString *args[], int nArgs, XEvent *event);
void cmdScrollToBottomRight(GooString *args[], int nArgs, XEvent *event);
void cmdScrollToLeftEdge(GooString *args[], int nArgs, XEvent *event);
void cmdScrollToRightEdge(GooString *args[], int nArgs, XEvent *event);
void cmdScrollToTopEdge(GooString *args[], int nArgs, XEvent *event);
void cmdScrollToTopLeft(GooString *args[], int nArgs, XEvent *event);
void cmdScrollUp(GooString *args[], int nArgs, XEvent *event);
void cmdScrollUpPrevPage(GooString *args[], int nArgs, XEvent *event);
void cmdSinglePageMode(GooString *args[], int nArgs, XEvent *event);
void cmdStartPan(GooString *args[], int nArgs, XEvent *event);
void cmdStartSelection(GooString *args[], int nArgs, XEvent *event);
void cmdToggleContinuousMode(GooString *args[], int nArgs, XEvent *event);
void cmdToggleFullScreenMode(GooString *args[], int nArgs, XEvent *event);
void cmdToggleOutline(GooString *args[], int nArgs, XEvent *event);
void cmdWindowMode(GooString *args[], int nArgs, XEvent *event);
void cmdZoomFitPage(GooString *args[], int nArgs, XEvent *event);
void cmdZoomFitWidth(GooString *args[], int nArgs, XEvent *event);
void cmdZoomIn(GooString *args[], int nArgs, XEvent *event);
void cmdZoomOut(GooString *args[], int nArgs, XEvent *event);
void cmdZoomPercent(GooString *args[], int nArgs, XEvent *event);
void cmdZoomToSelection(GooString *args[], int nArgs, XEvent *event);
//----- GUI code: main window
void initWindow(bool fullScreen);
void initToolbar(Widget parent);
#ifndef DISABLE_OUTLINE
void initPanedWin(Widget parent);
#endif
void initCore(Widget parent, bool fullScreen);
void initPopupMenu();
void addToolTip(Widget widget, char *text);
void mapWindow();
void closeWindow();
int getZoomIdx();
void setZoomIdx(int idx);
void setZoomVal(double z);
static void prevPageCbk(Widget widget, XtPointer ptr,
XtPointer callData);
static void prevTenPageCbk(Widget widget, XtPointer ptr,
XtPointer callData);
static void nextPageCbk(Widget widget, XtPointer ptr,
XtPointer callData);
static void nextTenPageCbk(Widget widget, XtPointer ptr,
XtPointer callData);
static void backCbk(Widget widget, XtPointer ptr,
XtPointer callData);
static void forwardCbk(Widget widget, XtPointer ptr,
XtPointer callData);
#if USE_COMBO_BOX
static void zoomComboBoxCbk(Widget widget, XtPointer ptr,
XtPointer callData);
#else
static void zoomMenuCbk(Widget widget, XtPointer ptr,
XtPointer callData);
#endif
static void findCbk(Widget widget, XtPointer ptr,
XtPointer callData);
static void printCbk(Widget widget, XtPointer ptr,
XtPointer callData);
static void aboutCbk(Widget widget, XtPointer ptr,
XtPointer callData);
static void quitCbk(Widget widget, XtPointer ptr,
XtPointer callData);
static void openCbk(Widget widget, XtPointer ptr,
XtPointer callData);
static void openInNewWindowCbk(Widget widget, XtPointer ptr,
XtPointer callData);
static void reloadCbk(Widget widget, XtPointer ptr,
XtPointer callData);
static void saveAsCbk(Widget widget, XtPointer ptr,
XtPointer callData);
static void continuousModeToggleCbk(Widget widget, XtPointer ptr,
XtPointer callData);
static void fullScreenToggleCbk(Widget widget, XtPointer ptr,
XtPointer callData);
static void rotateCCWCbk(Widget widget, XtPointer ptr,
XtPointer callData);
static void rotateCWCbk(Widget widget, XtPointer ptr,
XtPointer callData);
static void zoomToSelectionCbk(Widget widget, XtPointer ptr,
XtPointer callData);
static void closeCbk(Widget widget, XtPointer ptr,
XtPointer callData);
static void closeMsgCbk(Widget widget, XtPointer ptr,
XtPointer callData);
static void pageNumCbk(Widget widget, XtPointer ptr,
XtPointer callData);
static void updateCbk(void *data, GooString *fileName,
int pageNum, int numPages, char *linkString);
//----- GUI code: outline
#ifndef DISABLE_OUTLINE
void setupOutline();
void setupOutlineItems(GooList *items, Widget parent, UnicodeMap *uMap);
static void outlineSelectCbk(Widget widget, XtPointer ptr,
XtPointer callData);
#endif
//----- GUI code: "about" dialog
void initAboutDialog();
//----- GUI code: "open" dialog
void initOpenDialog();
void mapOpenDialog(bool openInNewWindowA);
static void openOkCbk(Widget widget, XtPointer ptr,
XtPointer callData);
//----- GUI code: "find" dialog
void initFindDialog();
static void findFindCbk(Widget widget, XtPointer ptr,
XtPointer callData);
void mapFindDialog();
void doFind(bool next);
static void findCloseCbk(Widget widget, XtPointer ptr,
XtPointer callData);
//----- GUI code: "save as" dialog
void initSaveAsDialog();
void mapSaveAsDialog();
static void saveAsOkCbk(Widget widget, XtPointer ptr,
XtPointer callData);
//----- GUI code: "print" dialog
void initPrintDialog();
void setupPrintDialog();
static void printWithCmdBtnCbk(Widget widget, XtPointer ptr,
XtPointer callData);
static void printToFileBtnCbk(Widget widget, XtPointer ptr,
XtPointer callData);
static void printAllPagesBtnCbk(Widget widget, XtPointer ptr,
XtPointer callData);
static void printEvenPagesBtnCbk(Widget widget, XtPointer ptr,
XtPointer callData);
static void printOddPagesBtnCbk(Widget widget, XtPointer ptr,
XtPointer callData);
static void printBackOrderBtnCbk(Widget widget, XtPointer ptr,
XtPointer callData);
static void printPrintCbk(Widget widget, XtPointer ptr,
XtPointer callData);
//----- Motif support
XmFontList createFontList(char *xlfd);
static XPDFViewerCmd cmdTab[];
XPDFApp *app;
bool ok;
Display *display;
int screenNum;
Widget win; // top-level window
Widget form;
Widget panedWin;
#ifndef DISABLE_OUTLINE
Widget outlineScroll;
Widget outlineTree;
Widget *outlineLabels;
int outlineLabelsLength;
int outlineLabelsSize;
Dimension outlinePaneWidth;
#endif
XPDFCore *core;
Widget toolBar;
Widget backBtn;
Widget prevTenPageBtn;
Widget prevPageBtn;
Widget nextPageBtn;
Widget nextTenPageBtn;
Widget forwardBtn;
Widget pageNumText;
Widget pageCountLabel;
#if USE_COMBO_BOX
Widget zoomComboBox;
#else
Widget zoomMenu;
Widget *zoomMenuBtns;
#endif
Widget zoomWidget;
Widget findBtn;
Widget printBtn;
Widget aboutBtn;
Widget linkLabel;
Widget quitBtn;
Widget popupMenu;
Widget aboutDialog;
XmFontList aboutBigFont, aboutVersionFont, aboutFixedFont;
Widget openDialog;
bool openInNewWindow;
Widget findDialog;
Widget findText;
Widget findBackwardToggle;
Widget findCaseSensitiveToggle;
Widget saveAsDialog;
Widget printDialog;
Widget printWithCmdBtn;
Widget printToFileBtn;
Widget printCmdText;
Widget printFileText;
Widget printFirstPage;
Widget printLastPage;
Widget printAllPages, printEvenPages, printOddPages, printBackOrder;
};
#endif