Tizen 2.1 base
[platform/upstream/hplip.git] / prnt / hpijs / capture.cpp
1 /*****************************************************************************\
2   capture.cpp : Implimentation for capturing functions
3
4   Copyright (c) 1996 - 2001, Hewlett-Packard Co.
5   All rights reserved.
6
7   Redistribution and use in source and binary forms, with or without
8   modification, are permitted provided that the following conditions
9   are met:
10   1. Redistributions of source code must retain the above copyright
11      notice, this list of conditions and the following disclaimer.
12   2. Redistributions in binary form must reproduce the above copyright
13      notice, this list of conditions and the following disclaimer in the
14      documentation and/or other materials provided with the distribution.
15   3. Neither the name of Hewlett-Packard nor the names of its
16      contributors may be used to endorse or promote products derived
17      from this software without specific prior written permission.
18
19   THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR IMPLIED
20   WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
21   MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN
22   NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23   SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
24   TO, PATENT INFRINGEMENT; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
25   OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
26   ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27   (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
28   THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 \*****************************************************************************/
30
31
32 #ifdef APDK_CAPTURE
33 #include "header.h"
34 #include "script.h"
35
36 APDK_BEGIN_NAMESPACE
37
38 //////////////////////////////////////////////////////////////
39 // Capture functions belonging to API
40
41
42 void PrintContext::Capture_PrintContext(unsigned int InputPixelsPerRow,
43                                         unsigned int OutputPixelsPerRow,
44                                         PAPER_SIZE ps,
45                                         IO_MODE IOMode)
46 {
47
48     if (! pSS->Capturing)
49         return;
50
51     Scripter *pS = pSS->pScripter;
52
53     pS->PutDebugToken(tokPrintContext);
54     pS->PutDebugInt(InputPixelsPerRow);
55     pS->PutDebugInt(OutputPixelsPerRow);
56     pS->PutDebugByte(ps);
57     pS->PutDebugByte(IOMode.bDevID);
58     pS->PutDebugByte(IOMode.bStatus);
59     if (!IOMode.bDevID)
60         return;
61
62     // need to simulate bidi, remember model and pens
63     pS->PutDebugString((const char*)pSS->strModel,strlen(pSS->strModel));
64     pS->PutDebugString((const char*)pSS->strPens,strlen(pSS->strPens));
65
66 }
67
68
69 void PrintContext::Capture_RealizeFont(const unsigned int ptr,
70                                        const unsigned int index,
71                                        const BYTE bSize,
72                                        const TEXTCOLOR eColor,
73                                        const BOOL bBold,
74                                        const BOOL bItalic,
75                                        const BOOL bUnderline)
76 {
77
78     if (! pSS->Capturing)
79         return;
80
81     Scripter *pS = pSS->pScripter;
82
83     pS->PutDebugToken(tokRealizeFont);
84     pS->PutDebugInt(ptr);
85     pS->PutDebugByte(index);
86     pS->PutDebugByte(bSize);
87     pS->PutDebugByte(eColor);
88     pS->PutDebugByte(bBold);
89     pS->PutDebugByte(bItalic);
90     pS->PutDebugByte(bUnderline);
91
92 }
93
94 void PrintContext::Capture_SetPixelsPerRow(unsigned int InputPixelsPerRow,
95                                            unsigned int OutputPixelsPerRow)
96 {
97
98     if (! pSS->Capturing)
99         return;
100
101     Scripter *pS = pSS->pScripter;
102
103     pS->PutDebugToken(tokSetPixelsPerRow);
104     pS->PutDebugInt(InputPixelsPerRow);
105     pS->PutDebugInt(OutputPixelsPerRow);
106 }
107
108 void PrintContext::Capture_SetInputResolution(unsigned int Res)
109 {
110
111     if (! pSS->Capturing)
112         return;
113
114     Scripter *pS = pSS->pScripter;
115
116     pS->PutDebugToken(tokSetRes);
117     pS->PutDebugInt(Res);
118
119 }
120
121
122 void PrintContext::Capture_SelectDevice(const PRINTER_TYPE Model)
123 {
124
125     if (! pSS->Capturing)
126         return;
127
128     Scripter *pS = pSS->pScripter;
129
130     pS->PutDebugToken(tokSelectDevice);
131     pS->PutDebugByte(Model);
132
133 }
134
135
136 void PrintContext::Capture_SelectDevice(const char* szDevIdString)
137 {
138     if (! pSS->Capturing)
139         return;
140
141     Scripter *pS = pSS->pScripter;
142
143     pS->PutDebugToken(tokSelectDevice);
144     pS->PutDebugString(szDevIdString, strlen(szDevIdString));
145 }
146
147
148 void PrintContext::Capture_SelectPrintMode(unsigned int modenum)
149 {
150
151     if (! pSS->Capturing)
152         return;
153
154     Scripter *pS = pSS->pScripter;
155
156     pS->PutDebugToken(tokSelectPrintMode);
157     pS->PutDebugByte(modenum);
158 }
159
160 void PrintContext::Capture_SetPaperSize(PAPER_SIZE ps, BOOL bFullBleed)
161 {
162
163     if (! pSS->Capturing)
164         return;
165
166     Scripter *pS = pSS->pScripter;
167
168     pS->PutDebugToken(tokSetPaperSize);
169     pS->PutDebugByte(ps);
170     pS->PutDebugByte (bFullBleed);
171 }
172
173
174
175
176 void Job::Capture_Job(PrintContext* pPC)
177 {
178
179     if (! thePrintContext->pSS->Capturing)
180         return;
181
182     Scripter *pS = thePrintContext->pSS->pScripter;
183
184     pS->PutDebugToken(tokJob);
185
186 }
187
188 void Job::Capture_SendRasters(BYTE* BlackImageData, BYTE* ColorImageData)
189 {
190
191     if (! thePrintContext->pSS->Capturing)
192         return;
193
194     Scripter *pS = thePrintContext->pSS->pScripter;
195
196     pS->PutDebugToken(tokSendRasters);
197     unsigned int len=0;
198     if (BlackImageData != NULL)
199         len= (thePrintContext->InputWidth/8) + (thePrintContext->InputWidth%8);
200         pS->PutDebugStream(BlackImageData, len);
201         len = 0;
202     if (ColorImageData != NULL)
203         len= thePrintContext->OutputWidth*3;
204     pS->PutDebugStream(ColorImageData, len);
205
206 }
207
208 #if defined(APDK_FONTS_NEEDED)
209 void Job::Capture_TextOut(const char* pTextString,
210                           unsigned int iLenString,
211                           const Font& font,
212                           unsigned int iAbsX,
213                           unsigned int iAbsY)
214 {
215     SystemServices* pSS = thePrintContext->pSS;
216
217     if (! pSS->Capturing)
218         return;
219
220     Scripter *pS = pSS->pScripter;
221
222     pS->PutDebugToken(tokTextOut);
223     pS->PutDebugInt((int)&font);
224     pS->PutDebugString(pTextString,iLenString);
225     pS->PutDebugInt(iAbsX);
226     pS->PutDebugInt(iAbsY);
227 }
228 #endif
229
230 void Job::Capture_NewPage()
231 {
232     SystemServices* pSS = thePrintContext->pSS;
233     if (! pSS->Capturing)
234         return;
235
236     Scripter *pS = pSS->pScripter;
237
238     pS->PutDebugToken(tokNewPage);
239
240 }
241
242
243 void Job::Capture_dJob()
244 {
245     SystemServices* pSS = thePrintContext->pSS;
246     if (! pSS->Capturing)
247         return;
248
249     Scripter *pS = pSS->pScripter;
250
251     pS->PutDebugToken(tokdJob);
252
253 }
254
255 #if defined(APDK_FONTS_NEEDED)
256 void Font::Capture_dFont(const unsigned int ptr)
257 {
258
259     if (internal)
260         return;
261     if (! pSS->Capturing)
262         return;
263
264     Scripter *pS = pSS->pScripter;
265
266     pS->PutDebugToken(tokdFont);
267     pS->PutDebugInt(ptr);
268 }
269 #endif
270
271 void PrintContext::Capture_dPrintContext()
272 {
273
274     if (! pSS->Capturing)
275         return;
276
277     Scripter *pS = pSS->pScripter;
278
279     pS->PutDebugToken(tokdPrintContext);
280
281 }
282
283 APDK_END_NAMESPACE
284
285 #endif