]> www.fi.muni.cz Git - evince.git/blob - pdf/GDKSplashOutputDev.cc
Hungarian translation added by "Last-Translator: \n".
[evince.git] / pdf / GDKSplashOutputDev.cc
1 //========================================================================
2 //
3 // GDKSplashOutputDev.cc
4 //
5 // Copyright 2003 Glyph & Cog, LLC
6 // Copyright 2004 Red Hat, Inc. (GDK port)
7 //
8 //========================================================================
9
10 #ifdef USE_GCC_PRAGMAS
11 #pragma implementation
12 #endif
13
14 #include <goo/gmem.h>
15 #include <splash/SplashTypes.h>
16 #include <splash/SplashBitmap.h>
17 #include <Object.h>
18 #include <GfxState.h>
19 #include <TextOutputDev.h>
20 #include <GDKSplashOutputDev.h>
21
22 //------------------------------------------------------------------------
23 // Constants and macros
24 //------------------------------------------------------------------------
25
26 #define xoutRound(x) ((int)(x + 0.5))
27
28 //------------------------------------------------------------------------
29 // GDKSplashOutputDev
30 //------------------------------------------------------------------------
31
32 static SplashColor makeSplashColor(int r, int g, int b)
33 {
34   SplashColor c;
35   c.rgb8 = splashMakeRGB8 (r, g, b);
36   return c;
37 }
38
39 GDKSplashOutputDev::GDKSplashOutputDev(GdkScreen *screen,
40                                        void (*redrawCbkA)(void *data),
41                                        void *redrawCbkDataA):
42   SplashOutputDev(splashModeRGB8Packed, gFalse, makeSplashColor (255,255,255)),
43   incrementalUpdate (1)
44 {
45   redrawCbk = redrawCbkA;
46   redrawCbkData = redrawCbkDataA;
47
48   // create text object
49   text = new TextPage(gFalse);
50 }
51
52 GDKSplashOutputDev::~GDKSplashOutputDev() {
53   delete text;
54 }
55
56 void GDKSplashOutputDev::drawChar(GfxState *state, double x, double y,
57                                   double dx, double dy,
58                                   double originX, double originY,
59                                   CharCode code, Unicode *u, int uLen) {
60   text->addChar(state, x, y, dx, dy, code, u, uLen);
61   SplashOutputDev::drawChar(state, x, y, dx, dy, originX, originY,
62                             code, u, uLen);
63 }
64
65 GBool GDKSplashOutputDev::beginType3Char(GfxState *state, double x, double y,
66                                        double dx, double dy,
67                                        CharCode code, Unicode *u, int uLen) {
68   text->addChar(state, x, y, dx, dy, code, u, uLen);
69   return SplashOutputDev::beginType3Char(state, x, y, dx, dy, code, u, uLen);
70 }
71
72 void GDKSplashOutputDev::clear() {
73   startDoc(NULL);
74   startPage(0, NULL);
75 }
76
77 void GDKSplashOutputDev::startPage(int pageNum, GfxState *state) {
78   SplashOutputDev::startPage(pageNum, state);
79   text->startPage(state);
80 }
81
82 void GDKSplashOutputDev::endPage() {
83   SplashOutputDev::endPage();
84   if (!incrementalUpdate) {
85     (*redrawCbk)(redrawCbkData);
86   }
87   text->coalesce(gTrue);
88 }
89
90 void GDKSplashOutputDev::dump() {
91   if (incrementalUpdate && redrawCbk) {
92     (*redrawCbk)(redrawCbkData);
93   }
94 }
95
96 void GDKSplashOutputDev::updateFont(GfxState *state) {
97   SplashOutputDev::updateFont(state);
98   text->updateFont(state);
99 }
100
101 void GDKSplashOutputDev::redraw(int srcX, int srcY,
102                                 GdkDrawable *drawable,
103                                 int destX, int destY,
104                                 int width, int height) {
105   GdkGC *gc;
106   int gdk_rowstride;
107
108   gdk_rowstride = getBitmap()->getRowSize();
109   gc = gdk_gc_new (drawable);
110   
111   gdk_draw_rgb_image (drawable, gc,
112                       destX, destY,
113                       width, height,
114                       GDK_RGB_DITHER_NORMAL,
115                       getBitmap()->getDataPtr().rgb8p + srcY * gdk_rowstride + srcX * 3,
116                       gdk_rowstride);
117
118   g_object_unref (gc);
119 }
120
121 void GDKSplashOutputDev::drawToPixbuf(GdkPixbuf *pixbuf, int pageNum) {
122         
123 }
124
125 GBool GDKSplashOutputDev::findText(Unicode *s, int len,
126                                    GBool startAtTop, GBool stopAtBottom,
127                                    GBool startAtLast, GBool stopAtLast,
128                                    int *xMin, int *yMin,
129                                    int *xMax, int *yMax) {
130   double xMin1, yMin1, xMax1, yMax1;
131   
132   xMin1 = (double)*xMin;
133   yMin1 = (double)*yMin;
134   xMax1 = (double)*xMax;
135   yMax1 = (double)*yMax;
136   if (text->findText(s, len, startAtTop, stopAtBottom,
137                      startAtLast, stopAtLast,
138                      &xMin1, &yMin1, &xMax1, &yMax1)) {
139     *xMin = xoutRound(xMin1);
140     *xMax = xoutRound(xMax1);
141     *yMin = xoutRound(yMin1);
142     *yMax = xoutRound(yMax1);
143     return gTrue;
144   }
145   return gFalse;
146 }
147
148 GooString *GDKSplashOutputDev::getText(int xMin, int yMin, int xMax, int yMax) {
149   return text->getText((double)xMin, (double)yMin,
150                        (double)xMax, (double)yMax);
151 }