summaryrefslogtreecommitdiff
path: root/noncore/unsupported/qpdf/QOutputDev.h
blob: 29580624b90fa05b55779b44285e555adb0b8a21 (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

//========================================================================
//
// XOutputDev.h
//
// Copyright 1996 Derek B. Noonburg
//
//========================================================================

#ifndef QOUTPUTDEV_H
#define QOUTPUTDEV_H

#ifdef __GNUC__
#pragma interface
#endif

#include "aconf.h"
#include <stddef.h>

#include <qscrollview.h>

class Object;

#include "config.h"
#include "CharTypes.h"
#include "GlobalParams.h"
#include "OutputDev.h"

class GString;
class GList;
struct GfxRGB;
class GfxFont;
class GfxSubpath;
class TextPage;
class XOutputFontCache;
class Link;
class Catalog;
class DisplayFontParam;
class UnicodeMap;
class CharCodeToUnicode;


class QPainter;
class QPixmap;
class QPointArray;


typedef fouble fp_t;

//------------------------------------------------------------------------
// Constants
//------------------------------------------------------------------------


//------------------------------------------------------------------------
// Misc types
//------------------------------------------------------------------------


//------------------------------------------------------------------------
// XOutputDev
//------------------------------------------------------------------------

class QOutputDev : public QScrollView, public OutputDev {
public:

	// Constructor.
	QOutputDev( QWidget *parent = 0, const char *name = 0, int flags = 0 );

	// Destructor.
	virtual ~QOutputDev();

	//---- get info about output device

	// Does this device use upside-down coordinates?
	// (Upside-down means (0,0) is the top left corner of the page.)
	virtual GBool upsideDown() { return gTrue; }

	// Does this device use drawChar() or drawString()?
	virtual GBool useDrawChar() { return gTrue; }

	//----- initialization and control

	// Start a page.
	virtual void startPage(int pageNum, GfxState *state);

	// End a page.
	virtual void endPage();

	//----- link borders
	virtual void drawLink(Link *link, Catalog *catalog);

	//----- save/restore graphics state
	virtual void saveState(GfxState *state);
	virtual void restoreState(GfxState *state);

	//----- update graphics state
	virtual void updateAll(GfxState *state);
	virtual void updateCTM(GfxState *state, fp_t m11, fp_t m12,
			 fp_t m21, fp_t m22, fp_t m31, fp_t m32);
	virtual void updateLineDash(GfxState *state);
	virtual void updateFlatness(GfxState *state);
	virtual void updateLineJoin(GfxState *state);
	virtual void updateLineCap(GfxState *state);
	virtual void updateMiterLimit(GfxState *state);
	virtual void updateLineWidth(GfxState *state);
	virtual void updateFillColor(GfxState *state);
	virtual void updateStrokeColor(GfxState *state);

	//----- update text state
	virtual void updateFont(GfxState *state);

	//----- path painting
	virtual void stroke(GfxState *state);
	virtual void fill(GfxState *state);
	virtual void eoFill(GfxState *state);

	//----- path clipping
	virtual void clip(GfxState *state);
	virtual void eoClip(GfxState *state);

	//----- text drawing
	virtual void beginString(GfxState *state, GString *s);
	virtual void endString(GfxState *state);
	virtual void drawChar(GfxState *state, fp_t x, fp_t y,
	                      fp_t dx, fp_t dy,
	                      fp_t originX, fp_t originY,
	                      CharCode code, Unicode *u, int uLen);

	//----- image drawing
	virtual void drawImageMask(GfxState *state, Object *ref, Stream *str,
	                          int width, int height, GBool invert,
	                          GBool inlineImg);
	virtual void drawImage(GfxState *state, Object *ref, Stream *str,
	                       int width, int height, GfxImageColorMap *colorMap,
	                       int *maskColors, GBool inlineImg);

	// Find a string.  If <top> is true, starts looking at <l>,<t>;
	// otherwise starts looking at top of page.  If <bottom> is true,
	// stops looking at <l+w-1>,<t+h-1>; otherwise stops looking at bottom
	// of page.  If found, sets the text bounding rectange and returns
	// true; otherwise returns false.
	GBool findText ( Unicode *s, int len, GBool top, GBool bottom, int *xMin, int *yMin, int *xMax, int *yMax );
	
	//----- special QT access

	bool findText ( const QString &str, int &l, int &t, int &w, int &h, bool top = 0, bool bottom = 0 );
	bool findText ( const QString &str, QRect &r, bool top = 0, bool bottom = 0 );

	// Get the text which is inside the specified rectangle.
	QString getText ( int left, int top, int width, int height );
	QString getText ( const QRect &r );

protected:
	virtual void drawContents ( QPainter *p, int, int, int, int );

private:
	QPixmap *m_pixmap;   		// pixmap to draw into
	QPainter *m_painter;

	TextPage *m_text;		// text from the current page

private:	
	QFont matchFont ( GfxFont *, fp_t m11, fp_t m12, fp_t m21, fp_t m22 );

	void updateLineAttrs ( GfxState *state, GBool updateDash );
	void doFill ( GfxState *state, bool winding );
	void doClip ( GfxState *state, bool winding );
	int convertPath ( GfxState *state, QPointArray &points, QArray<int> &lengths );
	int convertSubpath ( GfxState *state, GfxSubpath *subpath, QPointArray &points );
};

#endif