Bringing apdf from vendor into main branch.
[AROS-Contrib.git] / apdf / xpdf / XPDFViewer.h
blob01a12e97fff5ceaf9bc5e91315b75d046b3b289f
1 //========================================================================
2 //
3 // XPDFViewer.h
4 //
5 // Copyright 2002-2003 Glyph & Cog, LLC
6 //
7 //========================================================================
9 #ifndef XPDFVIEWER_H
10 #define XPDFVIEWER_H
12 #include <aconf.h>
14 #ifdef USE_GCC_PRAGMAS
15 #pragma interface
16 #endif
18 #define Object XtObject
19 #include <Xm/XmAll.h>
20 #undef Object
21 #include "gtypes.h"
22 #include "XPDFCore.h"
24 #if (XmVERSION <= 1) && !defined(__sgi)
25 #define DISABLE_OUTLINE
26 #endif
28 #if (XmVERSION >= 2 && !defined(LESSTIF_VERSION))
29 # define USE_COMBO_BOX 1
30 #else
31 # undef USE_COMBO_BOX
32 #endif
34 class GString;
35 class GList;
36 class UnicodeMap;
37 class LinkDest;
38 class XPDFApp;
40 //------------------------------------------------------------------------
42 // NB: this must match the defn of zoomMenuBtnInfo in XPDFViewer.cc
43 #define nZoomMenuItems 10
45 //------------------------------------------------------------------------
46 // XPDFViewer
47 //------------------------------------------------------------------------
49 class XPDFViewer {
50 public:
52 XPDFViewer(XPDFApp *appA, GString *fileName,
53 int pageA, GString *destName,
54 GString *ownerPassword, GString *userPassword);
55 GBool isOk() { return ok; }
56 ~XPDFViewer();
58 void open(GString *fileName, int pageA, GString *destName);
59 void clear();
60 void reloadFile();
62 Widget getWindow() { return win; }
64 private:
66 //----- load / display
67 GBool loadFile(GString *fileName, GString *ownerPassword = NULL,
68 GString *userPassword = NULL);
69 void displayPage(int pageA, double zoomA, int rotateA,
70 GBool scrollToTop, GBool addToHist);
71 void displayDest(LinkDest *dest, double zoomA, int rotateA,
72 GBool addToHist);
73 void getPageAndDest(int pageA, GString *destName,
74 int *pageOut, LinkDest **destOut);
76 //----- actions
77 static void actionCbk(void *data, char *action);
79 //----- keyboard/mouse input
80 static void keyPressCbk(void *data, char *s, KeySym key,
81 Guint modifiers);
82 static void mouseCbk(void *data, XEvent *event);
84 //----- GUI code: main window
85 void initWindow();
86 void addToolTip(Widget widget, char *text);
87 void mapWindow();
88 void closeWindow();
89 int getZoomIdx();
90 void setZoomIdx(int idx);
91 void setZoomVal(double z);
92 static void prevPageCbk(Widget widget, XtPointer ptr,
93 XtPointer callData);
94 static void prevTenPageCbk(Widget widget, XtPointer ptr,
95 XtPointer callData);
96 static void nextPageCbk(Widget widget, XtPointer ptr,
97 XtPointer callData);
98 static void nextTenPageCbk(Widget widget, XtPointer ptr,
99 XtPointer callData);
100 static void backCbk(Widget widget, XtPointer ptr,
101 XtPointer callData);
102 static void forwardCbk(Widget widget, XtPointer ptr,
103 XtPointer callData);
104 #if USE_COMBO_BOX
105 static void zoomComboBoxCbk(Widget widget, XtPointer ptr,
106 XtPointer callData);
107 #else
108 static void zoomMenuCbk(Widget widget, XtPointer ptr,
109 XtPointer callData);
110 #endif
111 static void findCbk(Widget widget, XtPointer ptr,
112 XtPointer callData);
113 static void printCbk(Widget widget, XtPointer ptr,
114 XtPointer callData);
115 static void aboutCbk(Widget widget, XtPointer ptr,
116 XtPointer callData);
117 static void quitCbk(Widget widget, XtPointer ptr,
118 XtPointer callData);
119 static void openCbk(Widget widget, XtPointer ptr,
120 XtPointer callData);
121 static void openInNewWindowCbk(Widget widget, XtPointer ptr,
122 XtPointer callData);
123 static void reloadCbk(Widget widget, XtPointer ptr,
124 XtPointer callData);
125 static void saveAsCbk(Widget widget, XtPointer ptr,
126 XtPointer callData);
127 static void continuousModeToggleCbk(Widget widget, XtPointer ptr,
128 XtPointer callData);
129 static void rotateCCWCbk(Widget widget, XtPointer ptr,
130 XtPointer callData);
131 static void rotateCWCbk(Widget widget, XtPointer ptr,
132 XtPointer callData);
133 static void closeCbk(Widget widget, XtPointer ptr,
134 XtPointer callData);
135 static void closeMsgCbk(Widget widget, XtPointer ptr,
136 XtPointer callData);
137 static void pageNumCbk(Widget widget, XtPointer ptr,
138 XtPointer callData);
139 static void updateCbk(void *data, GString *fileName,
140 int pageNum, int numPages, char *linkString);
142 //----- GUI code: outline
143 #ifndef DISABLE_OUTLINE
144 void setupOutline();
145 void setupOutlineItems(GList *items, Widget parent, UnicodeMap *uMap);
146 static void outlineSelectCbk(Widget widget, XtPointer ptr,
147 XtPointer callData);
148 #endif
150 //----- GUI code: "about" dialog
151 void initAboutDialog();
153 //----- GUI code: "open" dialog
154 void initOpenDialog();
155 void mapOpenDialog(GBool openInNewWindowA);
156 static void openOkCbk(Widget widget, XtPointer ptr,
157 XtPointer callData);
159 //----- GUI code: "find" dialog
160 void initFindDialog();
161 static void findFindCbk(Widget widget, XtPointer ptr,
162 XtPointer callData);
163 void mapFindDialog();
164 void doFind(GBool next);
165 static void findCloseCbk(Widget widget, XtPointer ptr,
166 XtPointer callData);
168 //----- GUI code: "save as" dialog
169 void initSaveAsDialog();
170 void mapSaveAsDialog();
171 static void saveAsOkCbk(Widget widget, XtPointer ptr,
172 XtPointer callData);
174 //----- GUI code: "print" dialog
175 void initPrintDialog();
176 void setupPrintDialog();
177 static void printWithCmdBtnCbk(Widget widget, XtPointer ptr,
178 XtPointer callData);
179 static void printToFileBtnCbk(Widget widget, XtPointer ptr,
180 XtPointer callData);
181 static void printPrintCbk(Widget widget, XtPointer ptr,
182 XtPointer callData);
184 //----- Motif support
185 XmFontList createFontList(char *xlfd);
187 XPDFApp *app;
188 GBool ok;
190 Display *display;
191 int screenNum;
192 Widget win; // top-level window
193 Widget form;
194 Widget panedWin;
195 #ifndef DISABLE_OUTLINE
196 Widget outlineScroll;
197 Widget outlineTree;
198 Widget *outlineLabels;
199 int outlineLabelsLength;
200 int outlineLabelsSize;
201 #endif
202 XPDFCore *core;
203 Widget toolBar;
204 Widget backBtn;
205 Widget prevTenPageBtn;
206 Widget prevPageBtn;
207 Widget nextPageBtn;
208 Widget nextTenPageBtn;
209 Widget forwardBtn;
210 Widget pageNumText;
211 Widget pageCountLabel;
212 #if USE_COMBO_BOX
213 Widget zoomComboBox;
214 #else
215 Widget zoomMenu;
216 Widget zoomMenuBtns[nZoomMenuItems];
217 #endif
218 Widget findBtn;
219 Widget printBtn;
220 Widget aboutBtn;
221 Widget linkLabel;
222 Widget quitBtn;
223 Widget popupMenu;
225 Widget aboutDialog;
226 XmFontList aboutBigFont, aboutVersionFont, aboutFixedFont;
228 Widget openDialog;
229 GBool openInNewWindow;
231 Widget findDialog;
232 Widget findText;
233 Widget findBackwardToggle;
234 Widget findCaseSensitiveToggle;
236 Widget saveAsDialog;
238 Widget printDialog;
239 Widget printWithCmdBtn;
240 Widget printToFileBtn;
241 Widget printCmdText;
242 Widget printFileText;
243 Widget printFirstPage;
244 Widget printLastPage;
247 #endif