~ubuntu-branches/ubuntu/wily/luatex/wily

« back to all changes in this revision

Viewing changes to source/libs/xpdf/xpdf-3.02/xpdf/XPDFCore.h

  • Committer: Bazaar Package Importer
  • Author(s): Norbert Preining
  • Date: 2010-04-29 00:47:19 UTC
  • mfrom: (1.1.10 upstream)
  • Revision ID: james.westby@ubuntu.com-20100429004719-o42etkqe90n97b9e
Tags: 0.60.1-1
* new upstream release, adapt build-script patch
* disable patch: upstream-epstopdf_cc_no_xpdf_patching, included upstream
* disable patch: libpoppler-0.12, not needed anymore

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
//========================================================================
 
2
//
 
3
// XPDFCore.h
 
4
//
 
5
// Copyright 2002-2003 Glyph & Cog, LLC
 
6
//
 
7
//========================================================================
 
8
 
 
9
#ifndef XPDFCORE_H
 
10
#define XPDFCORE_H
 
11
 
 
12
#include <aconf.h>
 
13
 
 
14
#ifdef USE_GCC_PRAGMAS
 
15
#pragma interface
 
16
#endif
 
17
 
 
18
#define Object XtObject
 
19
#include <Xm/XmAll.h>
 
20
#undef Object
 
21
#include "gtypes.h"
 
22
#include "gfile.h" // for time_t
 
23
#include "SplashTypes.h"
 
24
#include "PDFCore.h"
 
25
 
 
26
class GString;
 
27
class BaseStream;
 
28
class PDFDoc;
 
29
class LinkAction;
 
30
 
 
31
//------------------------------------------------------------------------
 
32
 
 
33
#define xMaxRGBCube 6           // max size of RGB color cube
 
34
 
 
35
//------------------------------------------------------------------------
 
36
// callbacks
 
37
//------------------------------------------------------------------------
 
38
 
 
39
typedef void (*XPDFUpdateCbk)(void *data, GString *fileName,
 
40
                              int pageNum, int numPages, char *linkLabel);
 
41
 
 
42
typedef void (*XPDFActionCbk)(void *data, char *action);
 
43
 
 
44
typedef void (*XPDFKeyPressCbk)(void *data, KeySym key, Guint modifiers,
 
45
                                XEvent *event);
 
46
 
 
47
typedef void (*XPDFMouseCbk)(void *data, XEvent *event);
 
48
 
 
49
//------------------------------------------------------------------------
 
50
// XPDFCore
 
51
//------------------------------------------------------------------------
 
52
 
 
53
class XPDFCore: public PDFCore {
 
54
public:
 
55
 
 
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);
 
61
 
 
62
  ~XPDFCore();
 
63
 
 
64
  //----- loadFile / displayPage / displayDest
 
65
 
 
66
  // Load a new file.  Returns pdfOk or error code.
 
67
  virtual int loadFile(GString *fileName, GString *ownerPassword = NULL,
 
68
                       GString *userPassword = NULL);
 
69
 
 
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);
 
74
 
 
75
  // Load an already-created PDFDoc object.
 
76
  virtual void loadDoc(PDFDoc *docA);
 
77
 
 
78
  // Resize the window to fit page <pg> of the current document.
 
79
  void resizeToPage(int pg);
 
80
 
 
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);
 
85
 
 
86
  //----- page/position changes
 
87
 
 
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();
 
92
 
 
93
  //----- selection
 
94
 
 
95
  void startSelection(int wx, int wy);
 
96
  void endSelection(int wx, int wy);
 
97
  void copySelection();
 
98
  void startPan(int wx, int wy);
 
99
  void endPan(int wx, int wy);
 
100
 
 
101
  //----- hyperlinks
 
102
 
 
103
  void doAction(LinkAction *action);
 
104
  LinkAction *getLinkAction() { return linkAction; }
 
105
  GString *mungeURL(GString *url);
 
106
 
 
107
  //----- find
 
108
 
 
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);
 
113
 
 
114
  //----- simple modal dialogs
 
115
 
 
116
  GBool doQuestionDialog(char *title, GString *msg);
 
117
  void doInfoDialog(char *title, GString *msg);
 
118
  void doErrorDialog(char *title, GString *msg);
 
119
 
 
120
  //----- password dialog
 
121
 
 
122
  GString *getPassword();
 
123
 
 
124
  //----- misc access
 
125
 
 
126
  Widget getWidget() { return scrolledWin; }
 
127
  Widget getDrawAreaWidget() { return drawArea; }
 
128
  virtual void setBusyCursor(GBool busy);
 
129
  Cursor getBusyCursor() { return busyCursor; }
 
130
  void takeFocus();
 
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; }
 
143
 
 
144
private:
 
145
 
 
146
  virtual GBool checkForNewFile();
 
147
 
 
148
  //----- hyperlinks
 
149
  void runCommand(GString *cmdFmt, GString *arg);
 
150
 
 
151
  //----- selection
 
152
  static Boolean convertSelectionCbk(Widget widget, Atom *selection,
 
153
                                     Atom *target, Atom *type,
 
154
                                     XtPointer *value, unsigned long *length,
 
155
                                     int *format);
 
156
 
 
157
  //----- GUI code
 
158
  void setupX(GBool installCmap, int rgbCubeSizeA);
 
159
  void initWindow();
 
160
  static void hScrollChangeCbk(Widget widget, XtPointer ptr,
 
161
                               XtPointer callData);
 
162
  static void hScrollDragCbk(Widget widget, XtPointer ptr,
 
163
                             XtPointer callData);
 
164
  static void vScrollChangeCbk(Widget widget, XtPointer ptr,
 
165
                               XtPointer callData);
 
166
  static void vScrollDragCbk(Widget widget, XtPointer ptr,
 
167
                             XtPointer callData);
 
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,
 
176
                          GBool composited);
 
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,
 
182
                          XtPointer callData);
 
183
  static void dialogCancelCbk(Widget widget, XtPointer ptr,
 
184
                              XtPointer callData);
 
185
  void initPasswordDialog();
 
186
  static void passwordTextVerifyCbk(Widget widget, XtPointer ptr,
 
187
                                    XtPointer callData);
 
188
  static void passwordOkCbk(Widget widget, XtPointer ptr,
 
189
                            XtPointer callData);
 
190
  static void passwordCancelCbk(Widget widget, XtPointer ptr,
 
191
                                XtPointer callData);
 
192
 
 
193
  Gulong paperPixel;
 
194
  Gulong mattePixel;
 
195
  //~unimp: move fullScreen into PDFCore?
 
196
  GBool fullScreen;
 
197
 
 
198
  Display *display;
 
199
  int screenNum;
 
200
  Visual *visual;
 
201
  Colormap colormap;
 
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];
 
209
 
 
210
  Widget shell;                 // top-level shell containing the widget
 
211
  Widget parentWidget;          // parent widget (not created by XPDFCore)
 
212
  Widget scrolledWin;
 
213
  Widget hScrollBar;
 
214
  Widget vScrollBar;
 
215
  Widget drawAreaFrame;
 
216
  Widget drawArea;
 
217
  Cursor busyCursor, linkCursor, selectCursor;
 
218
  Cursor currentCursor;
 
219
  GC drawAreaGC;                // GC for blitting into drawArea
 
220
 
 
221
  static GString *currentSelection;  // selected text
 
222
  static XPDFCore *currentSelectionOwner;
 
223
  static Atom targetsAtom;
 
224
 
 
225
  GBool panning;
 
226
  int panMX, panMY;
 
227
 
 
228
  time_t modTime;               // last modification time of PDF file
 
229
 
 
230
  LinkAction *linkAction;       // mouse cursor is over this link
 
231
 
 
232
  XPDFUpdateCbk updateCbk;
 
233
  void *updateCbkData;
 
234
  XPDFActionCbk actionCbk;
 
235
  void *actionCbkData;
 
236
  XPDFKeyPressCbk keyPressCbk;
 
237
  void *keyPressCbkData;
 
238
  XPDFMouseCbk mouseCbk;
 
239
  void *mouseCbkData;
 
240
 
 
241
  GBool hyperlinksEnabled;
 
242
  GBool selectEnabled;
 
243
 
 
244
  int dialogDone;
 
245
 
 
246
  Widget passwordDialog;
 
247
  Widget passwordText;
 
248
  GString *password;
 
249
};
 
250
 
 
251
#endif