summaryrefslogtreecommitdiff
path: root/Build/source/libs/xpdf/xpdf-src/xpdf/DisplayState.h
blob: 12c8170f0b3a939e891e817a36fcdfd058192b44 (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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
//========================================================================
//
// DisplayState.h
//
// Copyright 2014 Glyph & Cog, LLC
//
//========================================================================

#ifndef DISPLAYSTATE_H
#define DISPLAYSTATE_H

#include <aconf.h>

#ifdef USE_GCC_PRAGMAS
#pragma interface
#endif

#include "gtypes.h"
#include "SplashTypes.h"

class GString;
class GList;
class PDFDoc;
class TileMap;
class TileCache;
class TileCompositor;

//------------------------------------------------------------------------
// zoom level
//------------------------------------------------------------------------

// positive zoom levels are percentage of 72 dpi
// (e.g., 50 means 36dpi, 100 means 72dpi, 150 means 108 dpi)

#define zoomPage   -1
#define zoomWidth  -2
#define zoomHeight -3

//------------------------------------------------------------------------
// display mode
//------------------------------------------------------------------------

enum DisplayMode {
  displaySingle,
  displayContinuous,
  displaySideBySideSingle,
  displaySideBySideContinuous,
  displayHorizontalContinuous
};

//------------------------------------------------------------------------
// SelectRect
//------------------------------------------------------------------------

class SelectRect {
public:

  SelectRect(int pageA, double x0A, double y0A, double x1A, double y1A):
    page(pageA), x0(x0A), y0(y0A), x1(x1A), y1(y1A) {}
  int operator==(SelectRect r)
    { return page == r.page && x0 == r.x0 && y0 == r.y0 &&
                               x1 == r.x1 && y1 == r.y1; }
  int operator!=(SelectRect r)
    { return page != r.page || x0 != r.x0 || y0 != r.y0 ||
                               x1 != r.x1 || y1 != r.y1; }

  int page;
  double x0, y0, x1, y1;	// user coords
};


//------------------------------------------------------------------------
// DisplayState
//------------------------------------------------------------------------

class DisplayState {
public:

  DisplayState(int maxTileWidthA, int maxTileHeightA,
	       int tileCacheSizeA, int nWorkerThreadsA,
	       SplashColorMode colorModeA, int bitmapRowPadA);
  ~DisplayState();

  void setTileMap(TileMap *tileMapA)
    { tileMap = tileMapA; }
  void setTileCache(TileCache *tileCacheA)
    { tileCache = tileCacheA; }
  void setTileCompositor(TileCompositor *tileCompositorA)
    { tileCompositor = tileCompositorA; }

  void setPaperColor(SplashColorPtr paperColorA);
  void setMatteColor(SplashColorPtr matteColorA);
  void setSelectColor(SplashColorPtr selectColorA);
  void setReverseVideo(GBool reverseVideoA);
  void setDoc(PDFDoc *docA);
  void setWindowSize(int winWA, int winHA);
  void setDisplayMode(DisplayMode displayModeA);
  void setZoom(double zoomA);
  void setRotate(int rotateA);
  void setScrollPosition(int scrollPageA, int scrollXA, int scrollYA);
  void setSelection(int selectPage, double selectX0, double selectY0,
		    double selectX1, double selectY1);
  void setSelection(GList *selectRectsA);
  void clearSelection();
  void forceRedraw();

  int getMaxTileWidth() { return maxTileWidth; }
  int getMaxTileHeight() { return maxTileHeight; }
  int getTileCacheSize() { return tileCacheSize; }
  int getNWorkerThreads() { return nWorkerThreads; }
  SplashColorMode getColorMode() { return colorMode; }
  int getBitmapRowPad() { return bitmapRowPad; }
  SplashColorPtr getPaperColor() { return paperColor; }
  SplashColorPtr getMatteColor() { return matteColor; }
  SplashColorPtr getSelectColor() { return selectColor; }
  GBool getReverseVideo() { return reverseVideo; }
  PDFDoc *getDoc() { return doc; }
  int getWinW() { return winW; }
  int getWinH() { return winH; }
  DisplayMode getDisplayMode() { return displayMode; }
  GBool displayModeIsContinuous()
    { return displayMode == displayContinuous ||
	     displayMode == displaySideBySideContinuous ||
	     displayMode == displayHorizontalContinuous; }
  GBool displayModeIsSideBySide()
    { return displayMode == displaySideBySideSingle ||
	     displayMode == displaySideBySideContinuous; }
  double getZoom() { return zoom; }
  int getRotate() { return rotate; }
  int getScrollPage() { return scrollPage; }
  int getScrollX() { return scrollX; }
  int getScrollY() { return scrollY; }
  GBool hasSelection() { return selectRects != NULL; }
  GList *getSelectRects() { return selectRects; }
  int getNumSelectRects();
  SelectRect *getSelectRect(int idx);
  void optionalContentChanged();

private:

  int maxTileWidth, maxTileHeight;
  int tileCacheSize;
  int nWorkerThreads;

  SplashColorMode colorMode;
  int bitmapRowPad;

  TileMap *tileMap;
  TileCache *tileCache;
  TileCompositor *tileCompositor;

  SplashColor paperColor;
  SplashColor matteColor;
  SplashColor selectColor;
  GBool reverseVideo;

  PDFDoc *doc;

  int winW, winH;		// window (draw area) size
  DisplayMode displayMode;
  double zoom;			// zoom level (see zoom* defines, above)
  int rotate;			// rotation (0, 90, 180, or 270)
  int scrollPage;		// scroll page - only used in
				//   non-continuous modes
  int scrollX, scrollY;

  GList *selectRects;		// selection rectangles [SelectRect]
				//   (NULL if there is no selection)


};

#endif