00001
00002
00003
00004
00005
00006
00007
00008
00009 #ifndef XPDFCORE_H
00010 #define XPDFCORE_H
00011
00012 #include <aconf.h>
00013
00014 #ifdef USE_GCC_PRAGMAS
00015 #pragma interface
00016 #endif
00017
00018 #define Object XtObject
00019 #include <Xm/XmAll.h>
00020 #undef Object
00021 #include <aconf.h>
00022 #include "gtypes.h"
00023 #include "gfile.h"
00024
00025 class GString;
00026 class GList;
00027 class PDFDoc;
00028 class LinkAction;
00029 class LinkDest;
00030 class XPixmapOutputDev;
00031
00032
00033
00034
00035
00036 #define minZoom -5
00037 #define maxZoom 5
00038 #define zoomPage 100
00039 #define zoomWidth 101
00040 #define defZoom 1
00041
00042
00043
00044
00045
00046 struct XPDFHistory {
00047 GString *fileName;
00048 int page;
00049 };
00050
00051 #define xpdfHistorySize 50
00052
00053
00054
00055
00056
00057 struct XPDFRegion {
00058 int page;
00059 double xMin, yMin, xMax, yMax;
00060 Gulong color;
00061 Gulong selectColor;
00062 };
00063
00064
00065
00066
00067
00068 typedef void (*XPDFUpdateCbk)(void *data, GString *fileName,
00069 int pageNum, int numPages, char *linkLabel);
00070
00071 typedef void (*XPDFActionCbk)(void *data, char *action);
00072
00073 typedef void (*XPDFKeyPressCbk)(void *data, char *s, KeySym key,
00074 Guint modifiers);
00075
00076 typedef void (*XPDFMouseCbk)(void *data, XEvent *event);
00077
00078 typedef GString *(*XPDFReqPasswordCbk)(void *data, GBool again);
00079
00080
00081
00082
00083
00084 class XPDFCore {
00085 public:
00086
00087
00088 XPDFCore(Widget shellA, Widget parentWidgetA,
00089 Gulong paperColorA, GBool fullScreenA, GBool reverseVideo,
00090 GBool installCmap, int rgbCubeSize);
00091
00092 ~XPDFCore();
00093
00094
00095
00096
00097 int loadFile(GString *fileName, GString *ownerPassword = NULL,
00098 GString *userPassword = NULL);
00099
00100
00101 void resizeToPage(int pg);
00102
00103
00104 void clear();
00105
00106
00107
00108
00109
00110 void displayPage(int pageA, int zoomA, int rotateA,
00111 GBool scrollToTop, GBool addToHist);
00112
00113
00114 void displayDest(LinkDest *dest, int zoomA, int rotateA,
00115 GBool addToHist);
00116
00117
00118
00119 void gotoNextPage(int inc, GBool top);
00120 void gotoPrevPage(int dec, GBool top, GBool bottom);
00121 void goForward();
00122 void goBackward();
00123 void scrollLeft(int nCols = 1);
00124 void scrollRight(int nCols = 1);
00125 void scrollUp(int nLines = 1);
00126 void scrollDown(int nLines = 1);
00127 void scrollPageUp();
00128 void scrollPageDown();
00129 void scrollTo(int x, int y);
00130
00131
00132
00133 void setSelection(int newXMin, int newYMin, int newXMax, int newYMax);
00134 void moveSelection(int mx, int my);
00135 void copySelection();
00136 GBool getSelection(int *xMin, int *yMin, int *xMax, int *yMax);
00137 GString *extractText(int xMin, int yMin, int xMax, int yMax);
00138 GString *extractText(int pageNum, int xMin, int yMin, int xMax, int yMax);
00139
00140
00141
00142 void doAction(LinkAction *action);
00143
00144
00145
00146
00147 void find(char *s);
00148
00149
00150
00151 GBool doQuestionDialog(char *title, GString *msg);
00152 void doInfoDialog(char *title, GString *msg);
00153 void doErrorDialog(char *title, GString *msg);
00154
00155
00156
00157 Widget getWidget() { return scrolledWin; }
00158 Widget getDrawAreaWidget() { return drawArea; }
00159 PDFDoc *getDoc() { return doc; }
00160 XPixmapOutputDev *getOutputDev() { return out; }
00161 int getPageNum() { return page; }
00162 int getZoom() { return zoom; }
00163 double getZoomDPI() { return dpi; }
00164 int getRotate() { return rotate; }
00165 GBool canGoBack() { return historyBLen > 1; }
00166 GBool canGoForward() { return historyFLen > 0; }
00167 int getScrollX() { return scrollX; }
00168 int getScrollY() { return scrollY; }
00169 int getDrawAreaWidth() { return drawAreaWidth; }
00170 int getDrawAreaHeight() { return drawAreaHeight; }
00171 void setBusyCursor(GBool busy);
00172 void takeFocus();
00173 void enableHyperlinks(GBool on) { hyperlinksEnabled = on; }
00174 void enableSelect(GBool on) { selectEnabled = on; }
00175 void setUpdateCbk(XPDFUpdateCbk cbk, void *data)
00176 { updateCbk = cbk; updateCbkData = data; }
00177 void setActionCbk(XPDFActionCbk cbk, void *data)
00178 { actionCbk = cbk; actionCbkData = data; }
00179 void setKeyPressCbk(XPDFKeyPressCbk cbk, void *data)
00180 { keyPressCbk = cbk; keyPressCbkData = data; }
00181 void setMouseCbk(XPDFMouseCbk cbk, void *data)
00182 { mouseCbk = cbk; mouseCbkData = data; }
00183 void setReqPasswordCbk(XPDFReqPasswordCbk cbk, void *data)
00184 { reqPasswordCbk = cbk; reqPasswordCbkData = data; }
00185
00186 private:
00187
00188
00189 void doLink(int mx, int my);
00190 void runCommand(GString *cmdFmt, GString *arg);
00191
00192
00193 static Boolean convertSelectionCbk(Widget widget, Atom *selection,
00194 Atom *target, Atom *type,
00195 XtPointer *value, unsigned long *length,
00196 int *format);
00197
00198
00199
00200 void initWindow();
00201 static void hScrollChangeCbk(Widget widget, XtPointer ptr,
00202 XtPointer callData);
00203 static void hScrollDragCbk(Widget widget, XtPointer ptr,
00204 XtPointer callData);
00205 static void vScrollChangeCbk(Widget widget, XtPointer ptr,
00206 XtPointer callData);
00207 static void vScrollDragCbk(Widget widget, XtPointer ptr,
00208 XtPointer callData);
00209 static void resizeCbk(Widget widget, XtPointer ptr, XtPointer callData);
00210 static void redrawCbk(Widget widget, XtPointer ptr, XtPointer callData);
00211 static void outputDevRedrawCbk(void *data);
00212 static void inputCbk(Widget widget, XtPointer ptr, XtPointer callData);
00213 void keyPress(char *s, KeySym key, Guint modifiers);
00214 void redrawRectangle(int x, int y, int w, int h);
00215 void updateScrollBars();
00216 void setCursor(Cursor cursor);
00217 GBool doDialog(int type, GBool hasCancel,
00218 char *title, GString *msg);
00219 static void dialogOkCbk(Widget widget, XtPointer ptr,
00220 XtPointer callData);
00221 static void dialogCancelCbk(Widget widget, XtPointer ptr,
00222 XtPointer callData);
00223
00224 Gulong paperColor;
00225 GBool fullScreen;
00226
00227 Display *display;
00228 int screenNum;
00229 Visual *visual;
00230 Colormap colormap;
00231 Widget shell;
00232 Widget parentWidget;
00233 Widget scrolledWin;
00234 Widget hScrollBar;
00235 Widget vScrollBar;
00236 Widget drawAreaFrame;
00237 Widget drawArea;
00238 Cursor busyCursor, linkCursor, selectCursor;
00239 Cursor currentCursor;
00240 GC drawAreaGC;
00241 GC selectGC;
00242 GC highlightGC;
00243
00244 int drawAreaWidth, drawAreaHeight;
00245 int scrollX, scrollY;
00246
00247 int selectXMin, selectYMin,
00248 selectXMax, selectYMax;
00249
00250 GBool dragging;
00251 GBool lastDragLeft;
00252 GBool lastDragTop;
00253 static GString *currentSelection;
00254 static XPDFCore *currentSelectionOwner;
00255
00256 GBool panning;
00257 int panMX, panMY;
00258
00259 XPDFHistory
00260 history[xpdfHistorySize];
00261 int historyCur;
00262 int historyBLen;
00263
00264 int historyFLen;
00265
00266
00267 PDFDoc *doc;
00268 int page;
00269 int zoom;
00270 double dpi;
00271 int rotate;
00272 time_t modTime;
00273
00274 LinkAction *linkAction;
00275
00276
00277 XPDFUpdateCbk updateCbk;
00278 void *updateCbkData;
00279 XPDFActionCbk actionCbk;
00280 void *actionCbkData;
00281 XPDFKeyPressCbk keyPressCbk;
00282 void *keyPressCbkData;
00283 XPDFMouseCbk mouseCbk;
00284 void *mouseCbkData;
00285 XPDFReqPasswordCbk reqPasswordCbk;
00286 void *reqPasswordCbkData;
00287
00288 GBool hyperlinksEnabled;
00289 GBool selectEnabled;
00290
00291 XPixmapOutputDev *out;
00292
00293 int dialogDone;
00294 };
00295
00296 #endif