1
/*******************************************
2
* Original source : GNUPLOT - win/wprinter.c
4
*******************************************
6
* Copyright (C) 1992 Maurice Castro, Russell Lang
8
* Permission to use, copy, and distribute this software and its
9
* documentation for any purpose with or without fee is hereby granted,
10
* provided that the above copyright notice appear in all copies and
11
* that both that copyright notice and this permission notice appear
12
* in supporting documentation.
14
* Permission to modify the software is granted, but not the right to
15
* distribute the modified code. Modifications are to be distributed
16
* as patches to released version.
18
* This software is provided "as is" without express or implied warranty.
24
* Modifications for Scilab
25
* Jean-Philipe Chancelier
26
* Bugs and mail : Scilab@inria.fr
43
#include "wresource.h"
46
LPPRINT prlist = NULL;
47
/** list of selected printers **/
49
/********************************************
50
* A Dialog Box for choosing the size for graphics
52
********************************************/
55
PrintSizeDlgProc (HWND hdlg, UINT wmsg, WPARAM wparam, LPARAM lparam)
61
parent = GetParent (hdlg);
62
lpr = (LPPRINT) GetWindowLong (parent, 4);
66
wsprintf (buf, "%d", lpr->pdef.x);
67
SetDlgItemText (hdlg, PSIZE_DEFX, buf);
68
wsprintf (buf, "%d", lpr->pdef.y);
69
SetDlgItemText (hdlg, PSIZE_DEFY, buf);
70
wsprintf (buf, "%d", lpr->poff.x);
71
SetDlgItemText (hdlg, PSIZE_OFFX, buf);
72
wsprintf (buf, "%d", lpr->poff.y);
73
SetDlgItemText (hdlg, PSIZE_OFFY, buf);
74
wsprintf (buf, "%d", lpr->psize.x);
75
SetDlgItemText (hdlg, PSIZE_X, buf);
76
wsprintf (buf, "%d", lpr->psize.y);
77
SetDlgItemText (hdlg, PSIZE_Y, buf);
78
CheckDlgButton (hdlg, PSIZE_DEF, TRUE);
79
EnableWindow (GetDlgItem (hdlg, PSIZE_X), FALSE);
80
EnableWindow (GetDlgItem (hdlg, PSIZE_Y), FALSE);
86
EnableWindow (GetDlgItem (hdlg, PSIZE_X), FALSE);
87
EnableWindow (GetDlgItem (hdlg, PSIZE_Y), FALSE);
90
EnableWindow (GetDlgItem (hdlg, PSIZE_X), TRUE);
91
EnableWindow (GetDlgItem (hdlg, PSIZE_Y), TRUE);
94
if (SendDlgItemMessage (hdlg, PSIZE_OTHER, BM_GETCHECK, 0, 0L))
96
SendDlgItemMessage (hdlg, PSIZE_X, WM_GETTEXT, 7, (LPARAM) ((LPSTR) buf));
97
GetLInt (buf, &lpr->psize.x);
98
SendDlgItemMessage (hdlg, PSIZE_Y, WM_GETTEXT, 7, (LPARAM) ((LPSTR) buf));
99
GetLInt (buf, &lpr->psize.y);
103
lpr->psize.x = lpr->pdef.x;
104
lpr->psize.y = lpr->pdef.y;
106
SendDlgItemMessage (hdlg, PSIZE_OFFX, WM_GETTEXT, 7, (LPARAM) ((LPSTR) buf));
107
GetLInt (buf, &lpr->poff.x);
108
SendDlgItemMessage (hdlg, PSIZE_OFFY, WM_GETTEXT, 7, (LPARAM) ((LPSTR) buf));
109
GetLInt (buf, &lpr->poff.y);
111
if (lpr->psize.x <= 0)
112
lpr->psize.x = lpr->pdef.x;
113
if (lpr->psize.y <= 0)
114
lpr->psize.y = lpr->pdef.y;
116
EndDialog (hdlg, IDOK);
119
EndDialog (hdlg, IDCANCEL);
128
/* GetWindowLong(hwnd, 4) must be available for use */
131
PrintSize (HDC printer, HWND hwnd, LPRECT lprect)
134
DLGPROC lpfnPrintSizeDlgProc;
137
SetWindowLong (hwnd, 4, (LONG) ((LPPRINT) & pr));
140
pr.psize.x = GetDeviceCaps (printer, HORZSIZE);
141
pr.psize.y = GetDeviceCaps (printer, VERTSIZE);
143
GetClientRect (hwnd, lprect);
144
pr.pdef.x = MulDiv (lprect->right - lprect->left, 254, 10 * GetDeviceCaps (hdc, LOGPIXELSX));
145
pr.pdef.y = MulDiv (lprect->bottom - lprect->top, 254, 10 * GetDeviceCaps (hdc, LOGPIXELSX));
146
ReleaseDC (hwnd, hdc);
147
lpfnPrintSizeDlgProc = (DLGPROC) MyGetProcAddress ("PrintSizeDlgProc",
149
if (DialogBox (hdllInstance, "PrintSizeDlgBox", hwnd, lpfnPrintSizeDlgProc)
152
lprect->left = MulDiv (pr.poff.x * 10, GetDeviceCaps (printer, LOGPIXELSX), 254);
153
lprect->top = MulDiv (pr.poff.y * 10, GetDeviceCaps (printer, LOGPIXELSY), 254);
154
lprect->right = lprect->left + MulDiv (pr.psize.x * 10, GetDeviceCaps (printer, LOGPIXELSX), 254);
155
lprect->bottom = lprect->top + MulDiv (pr.psize.y * 10, GetDeviceCaps (printer, LOGPIXELSY), 254);
158
SetWindowLong (hwnd, 4, (LONG) (0L));
162
/******************************
163
* Deals with a list of printers
164
******************************/
167
PrintRegister (LPPRINT lpr)
180
while (this && (this->hdcPrn != hdc))
188
PrintUnregister (LPPRINT lpr)
191
prev = (LPPRINT) NULL;
193
while (this && (this != lpr))
198
if (this && (this == lpr))
202
prev->next = this->next;
208
/******************************
210
******************************/
212
/* GetWindowLong(GetParent(hDlg), 4) must be available for use */
215
PrintDlgProc (HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
219
parent = GetParent (hDlg);
220
lpr = (LPPRINT) GetWindowLong (parent, 4);
224
lpr->hDlgPrint = hDlg;
225
SetWindowText (hDlg, (LPSTR) lParam);
226
EnableMenuItem (GetSystemMenu (hDlg, FALSE), SC_CLOSE, MF_GRAYED);
229
lpr->bUserAbort = TRUE;
231
EnableWindow (GetParent (hDlg), TRUE);
232
EndDialog (hDlg, FALSE);
240
PrintAbortProc (HDC hdcPrn, int code)
244
lpr = PrintFind (hdcPrn);
245
while (!lpr->bUserAbort && PeekMessage (&msg, 0, 0, 0, PM_REMOVE))
247
if (!lpr->hDlgPrint || !IsDialogMessage (lpr->hDlgPrint, &msg))
249
TranslateMessage (&msg);
250
DispatchMessage (&msg);
253
return (!lpr->bUserAbort);