1 //========================================================================
5 // Copyright 2002-2003 Glyph & Cog, LLC
7 //========================================================================
14 #ifdef USE_GCC_PRAGMAS
19 #include "gfile.h" // for time_t
20 #include "SplashTypes.h"
28 //------------------------------------------------------------------------
30 #define xMaxRGBCube 6 // max size of RGB color cube
32 //------------------------------------------------------------------------
34 //------------------------------------------------------------------------
36 class XPDFCore
: public PDFCore
{
39 // Create viewer core inside <parentWidgetA>.
40 XPDFCore(//Widget shellA, Widget parentWidgetA,
41 SplashColorPtr paperColorA
, Gulong paperPixelA
,
42 Gulong mattePixelA
, GBool fullScreenA
, GBool reverseVideoA
,
43 GBool installCmap
, int rgbCubeSizeA
);
47 //----- loadFile / displayPage / displayDest
49 // Load a new file. Returns pdfOk or error code.
50 virtual int loadFile(GString
*fileName
, GString
*ownerPassword
= NULL
,
51 GString
*userPassword
= NULL
);
53 // Load a new file, via a Stream instead of a file name. Returns
54 // pdfOk or error code.
55 virtual int loadFile(BaseStream
*stream
, GString
*ownerPassword
= NULL
,
56 GString
*userPassword
= NULL
);
58 // Load an already-created PDFDoc xObject.
59 virtual void loadDoc(PDFDoc
*docA
);
61 // Resize the window to fit page <pg> of the current document.
62 void resizeToPage(int pg
);
64 // Update the display, given the specified parameters.
65 virtual void update(int topPageA
, int scrollXA
, int scrollYA
,
66 double zoomA
, int rotateA
,
67 GBool force
, GBool addToHist
);
69 //----- page/position changes
71 virtual GBool
gotoNextPage(int inc
, GBool top
);
72 virtual GBool
gotoPrevPage(int dec
, GBool top
, GBool bottom
);
73 virtual GBool
goForward();
74 virtual GBool
goBackward();
78 void startSelection(int wx
, int wy
);
79 void endSelection(int wx
, int wy
);
81 void startPan(int wx
, int wy
);
82 void endPan(int wx
, int wy
);
86 void doAction(LinkAction
*action
);
87 LinkAction
*getLinkAction() { return linkAction
; }
88 GString
*mungeURL(GString
*url
);
92 virtual GBool
find(char *s
, GBool caseSensitive
,
93 GBool next
, GBool backward
, GBool onePageOnly
);
94 virtual GBool
findU(Unicode
*u
, int len
, GBool caseSensitive
,
95 GBool next
, GBool backward
, GBool onePageOnly
);
97 //----- simple modal dialogs
99 GBool
doQuestionDialog(char *title
, GString
*msg
);
100 void doInfoDialog(char *title
, GString
*msg
);
101 void doErrorDialog(char *title
, GString
*msg
);
103 //----- password dialog
105 GString
*getPassword();
109 //Widget getWidget() { return scrolledWin; }
110 //Widget getDrawAreaWidget() { return drawArea; }
111 virtual void setBusyCursor(GBool busy
);
112 //Cursor getBusyCursor() { return busyCursor; }
114 void enableHyperlinks(GBool on
) { hyperlinksEnabled
= on
; }
115 GBool
getHyperlinksEnabled() { return hyperlinksEnabled
; }
116 void enableSelect(GBool on
) { selectEnabled
= on
; }
117 GBool
getFullScreen() { return fullScreen
; }
121 virtual GBool
checkForNewFile();
124 void runCommand(GString
*cmdFmt
, GString
*arg
);
127 /* static Boolean convertSelectionCbk(Widget widget, Atom *selection,
128 Atom *target, Atom *type,
129 XtPointer *value, unsigned long *length,
133 void setupX(GBool installCmap
, int rgbCubeSizeA
);
136 virtual PDFCoreTile
*newTile(int xDestA
, int yDestA
);
137 virtual void updateTileData(PDFCoreTile
*tileA
, int xSrc
, int ySrc
,
138 int width
, int height
, GBool composited
);
139 virtual void redrawRect(PDFCoreTile
*tileA
, int xSrc
, int ySrc
,
140 int xDest
, int yDest
, int width
, int height
,
142 virtual void updateScrollbars();
143 //void setCursor(Cursor cursor);
144 GBool
doDialog(int type
, GBool hasCancel
,
145 char *title
, GString
*msg
);
146 /*static void dialogOkCbk(Widget widget, XtPointer ptr,
148 static void dialogCancelCbk(Widget widget, XtPointer ptr,
149 XtPointer callData);*/
150 void initPasswordDialog();
151 /*static void passwordTextVerifyCbk(Widget widget, XtPointer ptr,
153 static void passwordOkCbk(Widget widget, XtPointer ptr,
155 static void passwordCancelCbk(Widget widget, XtPointer ptr,
160 //~unimp: move fullScreen into PDFCore?
167 Guint depth
; // visual depth
168 GBool trueColor
; // set if using a TrueColor visual
169 int rDiv
, gDiv
, bDiv
; // RGB right shifts (for TrueColor)
170 int rShift
, gShift
, bShift
; // RGB left shifts (for TrueColor)
171 int rgbCubeSize
; // size of color cube (for non-TrueColor)
172 Gulong
// color cube (for non-TrueColor)
173 colors
[xMaxRGBCube
* xMaxRGBCube
* xMaxRGBCube
];
175 /*Widget shell; // top-level shell containing the widget
176 Widget parentWidget; // parent widget (not created by XPDFCore)
180 Widget drawAreaFrame;
182 //Cursor busyCursor, linkCursor, selectCursor;
183 //Cursor currentCursor;
184 //GC drawAreaGC; // GC for blitting into drawArea
186 static GString
*currentSelection
; // selected text
187 static XPDFCore
*currentSelectionOwner
;
188 //static Atom targetsAtom;
193 time_t modTime
; // last modification time of PDF file
195 LinkAction
*linkAction
; // mouse cursor is over this link
197 /*XPDFUpdateCbk updateCbk;
199 XPDFActionCbk actionCbk;
201 XPDFKeyPressCbk keyPressCbk;
202 void *keyPressCbkData;
203 XPDFMouseCbk mouseCbk;
204 void *mouseCbkData;*/
206 GBool hyperlinksEnabled
;
211 /*Widget passwordDialog;
212 Widget passwordText;*/