1 //========================================================================
2 //
3 // DisplayState.h
4 //
5 // Copyright 2014 Glyph & Cog, LLC
6 //
7 //========================================================================
8 
9 #ifndef DISPLAYSTATE_H
10 #define DISPLAYSTATE_H
11 
12 #include <aconf.h>
13 
14 #ifdef USE_GCC_PRAGMAS
15 #pragma interface
16 #endif
17 
18 #include "gtypes.h"
19 #include "SplashTypes.h"
20 
21 class GString;
22 class GList;
23 class PDFDoc;
24 class TileMap;
25 class TileCache;
26 class TileCompositor;
27 
28 //------------------------------------------------------------------------
29 // zoom level
30 //------------------------------------------------------------------------
31 
32 // positive zoom levels are percentage of 72 dpi
33 // (e.g., 50 means 36dpi, 100 means 72dpi, 150 means 108 dpi)
34 
35 #define zoomPage   -1
36 #define zoomWidth  -2
37 #define zoomHeight -3
38 
39 //------------------------------------------------------------------------
40 // display mode
41 //------------------------------------------------------------------------
42 
43 enum DisplayMode {
44   displaySingle,
45   displayContinuous,
46   displaySideBySideSingle,
47   displaySideBySideContinuous,
48   displayHorizontalContinuous
49 };
50 
51 //------------------------------------------------------------------------
52 // SelectRect
53 //------------------------------------------------------------------------
54 
55 class SelectRect {
56 public:
57 
SelectRect(int pageA,double x0A,double y0A,double x1A,double y1A)58   SelectRect(int pageA, double x0A, double y0A, double x1A, double y1A):
59     page(pageA), x0(x0A), y0(y0A), x1(x1A), y1(y1A) {}
60   int operator==(SelectRect r)
61     { return page == r.page && x0 == r.x0 && y0 == r.y0 &&
62                                x1 == r.x1 && y1 == r.y1; }
63   int operator!=(SelectRect r)
64     { return page != r.page || x0 != r.x0 || y0 != r.y0 ||
65                                x1 != r.x1 || y1 != r.y1; }
66 
67   int page;
68   double x0, y0, x1, y1;	// user coords
69 };
70 
71 
72 //------------------------------------------------------------------------
73 // DisplayState
74 //------------------------------------------------------------------------
75 
76 class DisplayState {
77 public:
78 
79   DisplayState(int maxTileWidthA, int maxTileHeightA,
80 	       int tileCacheSizeA, int nWorkerThreadsA,
81 	       SplashColorMode colorModeA, int bitmapRowPadA);
82   ~DisplayState();
83 
setTileMap(TileMap * tileMapA)84   void setTileMap(TileMap *tileMapA)
85     { tileMap = tileMapA; }
setTileCache(TileCache * tileCacheA)86   void setTileCache(TileCache *tileCacheA)
87     { tileCache = tileCacheA; }
setTileCompositor(TileCompositor * tileCompositorA)88   void setTileCompositor(TileCompositor *tileCompositorA)
89     { tileCompositor = tileCompositorA; }
90 
91   void setPaperColor(SplashColorPtr paperColorA);
92   void setMatteColor(SplashColorPtr matteColorA);
93   void setSelectColor(SplashColorPtr selectColorA);
94   void setReverseVideo(GBool reverseVideoA);
95   void setDoc(PDFDoc *docA);
96   void setWindowSize(int winWA, int winHA);
97   void setDisplayMode(DisplayMode displayModeA);
98   void setZoom(double zoomA);
99   void setRotate(int rotateA);
100   void setScrollPosition(int scrollPageA, int scrollXA, int scrollYA);
101   void setSelection(int selectPage, double selectX0, double selectY0,
102 		    double selectX1, double selectY1);
103   void setSelection(GList *selectRectsA);
104   void clearSelection();
105   void forceRedraw();
106 
getMaxTileWidth()107   int getMaxTileWidth() { return maxTileWidth; }
getMaxTileHeight()108   int getMaxTileHeight() { return maxTileHeight; }
getTileCacheSize()109   int getTileCacheSize() { return tileCacheSize; }
getNWorkerThreads()110   int getNWorkerThreads() { return nWorkerThreads; }
getColorMode()111   SplashColorMode getColorMode() { return colorMode; }
getBitmapRowPad()112   int getBitmapRowPad() { return bitmapRowPad; }
getPaperColor()113   SplashColorPtr getPaperColor() { return paperColor; }
getMatteColor()114   SplashColorPtr getMatteColor() { return matteColor; }
getSelectColor()115   SplashColorPtr getSelectColor() { return selectColor; }
getReverseVideo()116   GBool getReverseVideo() { return reverseVideo; }
getDoc()117   PDFDoc *getDoc() { return doc; }
getWinW()118   int getWinW() { return winW; }
getWinH()119   int getWinH() { return winH; }
getDisplayMode()120   DisplayMode getDisplayMode() { return displayMode; }
displayModeIsContinuous()121   GBool displayModeIsContinuous()
122     { return displayMode == displayContinuous ||
123 	     displayMode == displaySideBySideContinuous ||
124 	     displayMode == displayHorizontalContinuous; }
displayModeIsSideBySide()125   GBool displayModeIsSideBySide()
126     { return displayMode == displaySideBySideSingle ||
127 	     displayMode == displaySideBySideContinuous; }
getZoom()128   double getZoom() { return zoom; }
getRotate()129   int getRotate() { return rotate; }
getScrollPage()130   int getScrollPage() { return scrollPage; }
getScrollX()131   int getScrollX() { return scrollX; }
getScrollY()132   int getScrollY() { return scrollY; }
hasSelection()133   GBool hasSelection() { return selectRects != NULL; }
getSelectRects()134   GList *getSelectRects() { return selectRects; }
135   int getNumSelectRects();
136   SelectRect *getSelectRect(int idx);
137   void optionalContentChanged();
138 
139 private:
140 
141   int maxTileWidth, maxTileHeight;
142   int tileCacheSize;
143   int nWorkerThreads;
144 
145   SplashColorMode colorMode;
146   int bitmapRowPad;
147 
148   TileMap *tileMap;
149   TileCache *tileCache;
150   TileCompositor *tileCompositor;
151 
152   SplashColor paperColor;
153   SplashColor matteColor;
154   SplashColor selectColor;
155   GBool reverseVideo;
156 
157   PDFDoc *doc;
158 
159   int winW, winH;		// window (draw area) size
160   DisplayMode displayMode;
161   double zoom;			// zoom level (see zoom* defines, above)
162   int rotate;			// rotation (0, 90, 180, or 270)
163   int scrollPage;		// scroll page - only used in
164 				//   non-continuous modes
165   int scrollX, scrollY;
166 
167   GList *selectRects;		// selection rectangles [SelectRect]
168 				//   (NULL if there is no selection)
169 
170 
171 };
172 
173 #endif
174