aboutsummaryrefslogtreecommitdiff
path: root/xpdf-qt/XpdfApp.h
blob: 3ac2d2fb8aea8dc747edf7ff79dcd881f2731a53 (plain)
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
//========================================================================
//
// XpdfApp.h
//
// Copyright 2015 Glyph & Cog, LLC
//
//========================================================================

#ifndef XPDFAPP_H
#define XPDFAPP_H

#include <aconf.h>

#include <QApplication>
#include <QColor>
#include <QDateTime>
#include "gtypes.h"

class GList;
class XpdfViewer;

//------------------------------------------------------------------------

struct XpdfSavedPageNumber {
  XpdfSavedPageNumber(): pageNumber(1) {}
  XpdfSavedPageNumber(const QString &fileNameA, int pageNumberA)
    : fileName(fileNameA), pageNumber(pageNumberA) {}
  QString fileName;
  int pageNumber;
};

#define maxSavedPageNumbers 100

//------------------------------------------------------------------------
// XpdfApp
//------------------------------------------------------------------------

class XpdfApp: public QApplication {
  Q_OBJECT

public:

  XpdfApp(int &argc, char **argv);
  virtual ~XpdfApp();

  int getNumViewers();

  XpdfViewer *newWindow(GBool fullScreen = gFalse,
			const char *remoteServerName = NULL);

  GBool openInNewWindow(QString fileName, int page = 1,
			QString dest = QString(),
			int rotate = 0,
			QString password = QString(),
			GBool fullScreen = gFalse,
			const char *remoteServerName = NULL);

  void closeWindowOrQuit(XpdfViewer *viewer);

  // Called just before closing one or more PDF files.
  void startUpdatePagesFile();
  void updatePagesFile(const QString &fileName, int pageNumber);
  void finishUpdatePagesFile();

  // Return the saved page number for [fileName].
  int getSavedPageNumber(const QString &fileName);

  void quit();

  //--- for use by XpdfViewer

  int getErrorEventType() { return errorEventType; }
  const QColor &getPaperColor() { return paperColor; }
  const QColor &getMatteColor() { return matteColor; }
  const QColor &getFullScreenMatteColor() { return fsMatteColor; }
  const QColor &getSelectionColor() { return selectionColor; }
  GBool getReverseVideo() { return reverseVideo; }

private:

  void readPagesFile();
  void writePagesFile();

  int errorEventType;
  QColor paperColor;
  QColor matteColor;
  QColor fsMatteColor;
  QColor selectionColor;
  GBool reverseVideo;

  GList *viewers;		// [XpdfViewer]

  QString savedPagesFileName;
  QDateTime savedPagesFileTimestamp;
  XpdfSavedPageNumber savedPageNumbers[maxSavedPageNumbers];
  GBool savedPagesFileChanged;
};

#endif