146
146
print_hook (HWND hdlg, UINT uiMsg, WPARAM wParam, LPARAM lParam)
150
while ((cdown++ < SP_FOREIGN_MAX_ITER) && gdk_events_pending ()) {
151
gtk_main_iteration_do (FALSE);
153
gtk_main_iteration_do (FALSE);
150
while ((cdown++ < SP_FOREIGN_MAX_ITER) && gdk_events_pending ()) {
151
gtk_main_iteration_do (FALSE);
153
gtk_main_iteration_do (FALSE);
159
159
PrintWin32::setup (Inkscape::Extension::Print *mod)
164
NULL, /* hwndOwner */
166
NULL, /* hDevNames */
168
PD_NOPAGENUMS | PD_NOSELECTION | PD_RETURNDC | PD_USEDEVMODECOPIESANDCOLLATE, /* Flags */
169
1, 1, 1, 1, /* nFromPage, nToPage, nMinPage, nMaxPage */
171
NULL, /* hInstance */
173
NULL, NULL, NULL, NULL, NULL, NULL
178
pd.Flags |= PD_ENABLEPRINTHOOK;
179
pd.lpfnPrintHook = print_hook;
180
timer = SetTimer (NULL, 0, 40, my_timer);
182
res = PrintDlg (&pd);
184
KillTimer (NULL, timer);
185
SPWin32Modal = FALSE;
187
if (!res) return FALSE;
164
NULL, /* hwndOwner */
166
NULL, /* hDevNames */
168
PD_NOPAGENUMS | PD_NOSELECTION | PD_RETURNDC | PD_USEDEVMODECOPIESANDCOLLATE, /* Flags */
169
1, 1, 1, 1, /* nFromPage, nToPage, nMinPage, nMaxPage */
171
NULL, /* hInstance */
173
NULL, NULL, NULL, NULL, NULL, NULL
178
pd.Flags |= PD_ENABLEPRINTHOOK;
179
pd.lpfnPrintHook = print_hook;
180
timer = SetTimer (NULL, 0, 40, my_timer);
182
res = PrintDlg (&pd);
184
KillTimer (NULL, timer);
185
SPWin32Modal = FALSE;
187
if (!res) return FALSE;
192
caps = GetDeviceCaps (_hDC, RASTERCAPS);
193
if (caps & RC_BANDING) {
194
printf ("needs banding\n");
196
if (caps & RC_BITBLT) {
197
printf ("does bitblt\n");
199
if (caps & RC_DIBTODEV) {
200
printf ("does dibtodev\n");
202
if (caps & RC_STRETCHDIB) {
203
printf ("does stretchdib\n");
192
caps = GetDeviceCaps (_hDC, RASTERCAPS);
193
if (caps & RC_BANDING) {
194
printf ("needs banding\n");
196
if (caps & RC_BITBLT) {
197
printf ("does bitblt\n");
199
if (caps & RC_DIBTODEV) {
200
printf ("does dibtodev\n");
202
if (caps & RC_STRETCHDIB) {
203
printf ("does stretchdib\n");
208
devmodep = (DEVMODE *)pd.hDevMode;
209
if (devmodep->dmFields & DM_ORIENTATION) {
210
_landscape = (devmodep->dmOrientation == DMORIENT_LANDSCAPE);
208
devmodep = (DEVMODE *)pd.hDevMode;
209
if (devmodep->dmFields & DM_ORIENTATION) {
210
_landscape = (devmodep->dmOrientation == DMORIENT_LANDSCAPE);
218
218
PrintWin32::begin (Inkscape::Extension::Print *mod, SPDocument *doc)
222
NULL, /* lpszDocName */
223
NULL, /* lpszOutput */
224
NULL, /* lpszDatatype */
225
0 /* DI_APPBANDING */ /* fwType */
229
_PageWidth = sp_document_width (doc);
230
_PageHeight = sp_document_height (doc);
232
di.lpszDocName = SP_DOCUMENT_NAME (doc);
236
res = StartDoc (_hDC, &di);
237
res = StartPage (_hDC);
239
SPWin32Modal = FALSE;
222
NULL, /* lpszDocName */
223
NULL, /* lpszOutput */
224
NULL, /* lpszDatatype */
225
0 /* DI_APPBANDING */ /* fwType */
229
_PageWidth = sp_document_width (doc);
230
_PageHeight = sp_document_height (doc);
232
di.lpszDocName = SP_DOCUMENT_NAME (doc);
236
res = StartDoc (_hDC, &di);
237
res = StartPage (_hDC);
239
SPWin32Modal = FALSE;
245
245
PrintWin32::finish (Inkscape::Extension::Print *mod)
248
int pPhysicalWidth, pPhysicalHeight;
249
int pPhysicalOffsetX, pPhysicalOffsetY;
250
int pPrintableWidth, pPrintableHeight;
251
float scalex, scaley;
257
BITMAPINFO bmInfo = {
259
sizeof (BITMAPINFOHEADER), // bV4Size
264
BI_RGB, // biCompression
266
2835, // biXPelsPerMeter
267
2835, // biYPelsPerMeter
271
{ { 0, 0, 0, 0 } } // bmiColors
278
// Number of pixels per logical inch
279
dpiX = (int) GetDeviceCaps (_hDC, LOGPIXELSX);
280
dpiY = (int) GetDeviceCaps (_hDC, LOGPIXELSY);
281
// Size in pixels of the printable area
282
pPhysicalWidth = GetDeviceCaps (_hDC, PHYSICALWIDTH);
283
pPhysicalHeight = GetDeviceCaps (_hDC, PHYSICALHEIGHT);
284
// Top left corner of prontable area
285
pPhysicalOffsetX = GetDeviceCaps (_hDC, PHYSICALOFFSETX);
286
pPhysicalOffsetY = GetDeviceCaps (_hDC, PHYSICALOFFSETY);
287
// Size in pixels of the printable area
288
pPrintableWidth = GetDeviceCaps (_hDC, HORZRES);
289
pPrintableHeight = GetDeviceCaps (_hDC, VERTRES);
291
// Scaling from document to device
292
scalex = dpiX / 72.0;
293
scaley = dpiY / 72.0;
295
// We simply map document 0,0 to physical page 0,0
296
affine.c[0] = scalex / 1.25;
299
affine.c[3] = scaley / 1.25;
303
nr_arena_item_set_transform (mod->root, &affine);
305
// Calculate printable area in device coordinates
306
x0 = pPhysicalOffsetX;
307
y0 = pPhysicalOffsetY;
308
x1 = x0 + pPrintableWidth;
309
y1 = y0 + pPrintableHeight;
310
x1 = MIN (x1, (int) (_PageWidth * scalex));
311
y1 = MIN (y1, (int) (_PageHeight * scaley));
316
px = g_new (unsigned char, 4 * 64 * width);
319
/* Printing goes here */
320
for (row = 0; row < height; row += 64) {
328
if ((row + num_rows) > height) num_rows = height - row;
330
/* Set area of interest */
333
bbox.x1 = bbox.x0 + width;
334
bbox.y1 = bbox.y0 + num_rows;
335
/* Update to renderable state */
336
nr_matrix_set_identity (&gc.transform);
337
nr_arena_item_invoke_update (mod->root, &bbox, &gc, NR_ARENA_ITEM_STATE_ALL, NR_ARENA_ITEM_STATE_NONE);
339
nr_pixblock_setup_extern (&pb, NR_PIXBLOCK_MODE_R8G8B8A8N, bbox.x0, bbox.y0, bbox.x1, bbox.y1, px, 4 * (bbox.x1 - bbox.x0), FALSE, FALSE);
341
/* Blitter goes here */
342
bmInfo.bmiHeader.biWidth = bbox.x1 - bbox.x0;
343
bmInfo.bmiHeader.biHeight = -(bbox.y1 - bbox.y0);
345
memset (px, 0xff, 4 * num_rows * width);
347
nr_arena_item_invoke_render (NULL, mod->root, &bbox, &pb, 0);
349
/* Swap red and blue channels; we use RGBA, whereas
350
* the Win32 GDI uses BGRx.
352
for ( i = 0 ; i < num_rows * width ; i++ ) {
353
unsigned char temp=px[i*4];
358
SetStretchBltMode(_hDC, COLORONCOLOR);
359
res = StretchDIBits (_hDC,
360
bbox.x0 - x0, bbox.y0 - y0, bbox.x1 - bbox.x0, bbox.y1 - bbox.y0,
361
0, 0, bbox.x1 - bbox.x0, bbox.y1 - bbox.y0,
248
int pPhysicalWidth, pPhysicalHeight;
249
int pPhysicalOffsetX, pPhysicalOffsetY;
250
int pPrintableWidth, pPrintableHeight;
251
float scalex, scaley;
256
BITMAPINFO bmInfo = {
258
sizeof (BITMAPINFOHEADER), // bV4Size
263
BI_RGB, // biCompression
265
2835, // biXPelsPerMeter
266
2835, // biYPelsPerMeter
270
{ { 0, 0, 0, 0 } } // bmiColors
277
// Number of pixels per logical inch
278
dpiX = (int) GetDeviceCaps (_hDC, LOGPIXELSX);
279
dpiY = (int) GetDeviceCaps (_hDC, LOGPIXELSY);
280
// Size in pixels of the printable area
281
pPhysicalWidth = GetDeviceCaps (_hDC, PHYSICALWIDTH);
282
pPhysicalHeight = GetDeviceCaps (_hDC, PHYSICALHEIGHT);
283
// Top left corner of prontable area
284
pPhysicalOffsetX = GetDeviceCaps (_hDC, PHYSICALOFFSETX);
285
pPhysicalOffsetY = GetDeviceCaps (_hDC, PHYSICALOFFSETY);
286
// Size in pixels of the printable area
287
pPrintableWidth = GetDeviceCaps (_hDC, HORZRES);
288
pPrintableHeight = GetDeviceCaps (_hDC, VERTRES);
290
// Scaling from document to device
291
scalex = dpiX / 72.0;
292
scaley = dpiY / 72.0;
294
// We simply map document 0,0 to physical page 0,0
295
Geom::Matrix affine = Geom::Scale(scalex / 1.25, scaley / 1.25);
297
nr_arena_item_set_transform (mod->root, affine);
299
// Calculate printable area in device coordinates
300
x0 = pPhysicalOffsetX;
301
y0 = pPhysicalOffsetY;
302
x1 = x0 + pPrintableWidth;
303
y1 = y0 + pPrintableHeight;
304
x1 = MIN (x1, (int) (_PageWidth * scalex));
305
y1 = MIN (y1, (int) (_PageHeight * scaley));
310
px = g_new (unsigned char, 4 * 64 * width);
313
/* Printing goes here */
314
for (row = 0; row < height; row += 64) {
322
if ((row + num_rows) > height) num_rows = height - row;
324
/* Set area of interest */
327
bbox.x1 = bbox.x0 + width;
328
bbox.y1 = bbox.y0 + num_rows;
329
/* Update to renderable state */
330
gc.transform.setIdentity();
331
nr_arena_item_invoke_update (mod->root, &bbox, &gc, NR_ARENA_ITEM_STATE_ALL, NR_ARENA_ITEM_STATE_NONE);
333
nr_pixblock_setup_extern (&pb, NR_PIXBLOCK_MODE_R8G8B8A8N, bbox.x0, bbox.y0, bbox.x1, bbox.y1, px, 4 * (bbox.x1 - bbox.x0), FALSE, FALSE);
335
/* Blitter goes here */
336
bmInfo.bmiHeader.biWidth = bbox.x1 - bbox.x0;
337
bmInfo.bmiHeader.biHeight = -(bbox.y1 - bbox.y0);
339
memset (px, 0xff, 4 * num_rows * width);
341
nr_arena_item_invoke_render (NULL, mod->root, &bbox, &pb, 0);
343
/* Swap red and blue channels; we use RGBA, whereas
344
* the Win32 GDI uses BGRx.
346
for ( i = 0 ; i < num_rows * width ; i++ ) {
347
unsigned char temp=px[i*4];
352
SetStretchBltMode(_hDC, COLORONCOLOR);
353
res = StretchDIBits (_hDC,
354
bbox.x0 - x0, bbox.y0 - y0, bbox.x1 - bbox.x0, bbox.y1 - bbox.y0,
355
0, 0, bbox.x1 - bbox.x0, bbox.y1 - bbox.y0,
367
/* Blitter ends here */
369
nr_pixblock_release (&pb);
374
res = EndPage (_hDC);
377
SPWin32Modal = FALSE;
361
/* Blitter ends here */
363
nr_pixblock_release (&pb);
368
res = EndPage (_hDC);
371
SPWin32Modal = FALSE;
382
376
/* File dialogs */
385
379
PrintWin32::get_open_filename (unsigned char *dir, unsigned char *filter, unsigned char *title)
387
char fnbuf[4096] = {0};
389
sizeof (OPENFILENAME),
390
NULL, /* hwndOwner */
391
NULL, /* hInstance */
392
(const CHAR *)filter, /* lpstrFilter */
393
NULL, /* lpstrCustomFilter */
394
0, /* nMaxCustFilter */
395
1, /* nFilterIndex */
396
fnbuf, /* lpstrFile */
397
sizeof (fnbuf), /* nMaxFile */
398
NULL, /* lpstrFileTitle */
399
0, /* nMaxFileTitle */
400
(const CHAR *)dir, /* lpstrInitialDir */
401
(const CHAR *)title, /* lpstrTitle */
402
OFN_FILEMUSTEXIST | OFN_PATHMUSTEXIST | OFN_HIDEREADONLY, /* Flags */
404
0, /* nFileExtension */
405
NULL, /* lpstrDefExt */
408
NULL /* lpTemplateName */
414
timer = SetTimer (NULL, 0, 40, my_timer);
416
retval = GetOpenFileName (&ofn);
418
KillTimer (NULL, timer);
419
SPWin32Modal = FALSE;
423
errcode = CommDlgExtendedError();
381
char fnbuf[4096] = {0};
383
sizeof (OPENFILENAME),
384
NULL, /* hwndOwner */
385
NULL, /* hInstance */
386
(const CHAR *)filter, /* lpstrFilter */
387
NULL, /* lpstrCustomFilter */
388
0, /* nMaxCustFilter */
389
1, /* nFilterIndex */
390
fnbuf, /* lpstrFile */
391
sizeof (fnbuf), /* nMaxFile */
392
NULL, /* lpstrFileTitle */
393
0, /* nMaxFileTitle */
394
(const CHAR *)dir, /* lpstrInitialDir */
395
(const CHAR *)title, /* lpstrTitle */
396
OFN_FILEMUSTEXIST | OFN_PATHMUSTEXIST | OFN_HIDEREADONLY, /* Flags */
398
0, /* nFileExtension */
399
NULL, /* lpstrDefExt */
402
NULL /* lpTemplateName */
408
timer = SetTimer (NULL, 0, 40, my_timer);
410
retval = GetOpenFileName (&ofn);
412
KillTimer (NULL, timer);
413
SPWin32Modal = FALSE;
417
errcode = CommDlgExtendedError();
426
return g_strdup (fnbuf);
420
return g_strdup (fnbuf);
430
424
PrintWin32::get_write_filename (unsigned char *dir, unsigned char *filter, unsigned char *title)
436
430
PrintWin32::get_save_filename (unsigned char *dir, unsigned int *spns)
438
char fnbuf[4096] = {0};
440
sizeof (OPENFILENAME),
441
NULL, /* hwndOwner */
442
NULL, /* hInstance */
443
"Inkscape SVG (*.svg)\0*\0Plain SVG (*.svg)\0*\0", /* lpstrFilter */
444
NULL, /* lpstrCustomFilter */
445
0, /* nMaxCustFilter */
446
1, /* nFilterIndex */
447
fnbuf, /* lpstrFile */
448
sizeof (fnbuf), /* nMaxFile */
449
NULL, /* lpstrFileTitle */
450
0, /* nMaxFileTitle */
451
(const CHAR *)dir, /* lpstrInitialDir */
452
"Save document to file", /* lpstrTitle */
453
OFN_HIDEREADONLY, /* Flags */
455
0, /* nFileExtension */
456
NULL, /* lpstrDefExt */
459
NULL /* lpTemplateName */
465
timer = SetTimer (NULL, 0, 40, my_timer);
467
retval = GetSaveFileName (&ofn);
469
KillTimer (NULL, timer);
470
SPWin32Modal = FALSE;
474
errcode = CommDlgExtendedError();
432
char fnbuf[4096] = {0};
434
sizeof (OPENFILENAME),
435
NULL, /* hwndOwner */
436
NULL, /* hInstance */
437
"Inkscape SVG (*.svg)\0*\0Plain SVG (*.svg)\0*\0", /* lpstrFilter */
438
NULL, /* lpstrCustomFilter */
439
0, /* nMaxCustFilter */
440
1, /* nFilterIndex */
441
fnbuf, /* lpstrFile */
442
sizeof (fnbuf), /* nMaxFile */
443
NULL, /* lpstrFileTitle */
444
0, /* nMaxFileTitle */
445
(const CHAR *)dir, /* lpstrInitialDir */
446
"Save document to file", /* lpstrTitle */
447
OFN_HIDEREADONLY, /* Flags */
449
0, /* nFileExtension */
450
NULL, /* lpstrDefExt */
453
NULL /* lpTemplateName */
459
timer = SetTimer (NULL, 0, 40, my_timer);
461
retval = GetSaveFileName (&ofn);
463
KillTimer (NULL, timer);
464
SPWin32Modal = FALSE;
468
errcode = CommDlgExtendedError();
477
*spns = (ofn.nFilterIndex != 2);
478
return g_strdup (fnbuf);
471
*spns = (ofn.nFilterIndex != 2);
472
return g_strdup (fnbuf);
481
475
#include "clear-n_.h"