]>
Commit | Line | Data |
---|---|---|
1 | ///////////////////////////////////////////////////////////////////////////// | |
2 | // Name: src/msw/printdlg.cpp | |
3 | // Purpose: wxPrintDialog, wxPageSetupDialog | |
4 | // Author: Julian Smart | |
5 | // Modified by: | |
6 | // Created: 04/01/98 | |
7 | // RCS-ID: $Id$ | |
8 | // Copyright: (c) Julian Smart | |
9 | // Licence: wxWindows licence | |
10 | ///////////////////////////////////////////////////////////////////////////// | |
11 | ||
12 | // =========================================================================== | |
13 | // declarations | |
14 | // =========================================================================== | |
15 | ||
16 | // --------------------------------------------------------------------------- | |
17 | // headers | |
18 | // --------------------------------------------------------------------------- | |
19 | ||
20 | // For compilers that support precompilation, includes "wx.h". | |
21 | #include "wx/wxprec.h" | |
22 | ||
23 | #ifdef __BORLANDC__ | |
24 | #pragma hdrstop | |
25 | #endif | |
26 | ||
27 | // Don't use the Windows print dialog if we're in wxUniv mode and using | |
28 | // the PostScript architecture | |
29 | #if wxUSE_PRINTING_ARCHITECTURE && (!defined(__WXUNIVERSAL__) || !wxUSE_POSTSCRIPT_ARCHITECTURE_IN_MSW) | |
30 | ||
31 | #ifndef WX_PRECOMP | |
32 | #include "wx/msw/wrapcdlg.h" | |
33 | #include "wx/app.h" | |
34 | #include "wx/dcprint.h" | |
35 | #include "wx/cmndata.h" | |
36 | #endif | |
37 | ||
38 | #include "wx/printdlg.h" | |
39 | #include "wx/msw/printdlg.h" | |
40 | #include "wx/msw/dcprint.h" | |
41 | #include "wx/paper.h" | |
42 | ||
43 | #include <stdlib.h> | |
44 | ||
45 | //---------------------------------------------------------------------------- | |
46 | // wxWindowsPrintNativeData | |
47 | //---------------------------------------------------------------------------- | |
48 | ||
49 | static wxString wxGetPrintDlgError() | |
50 | { | |
51 | DWORD err = CommDlgExtendedError(); | |
52 | wxString msg = wxT("Unknown"); | |
53 | switch (err) | |
54 | { | |
55 | case CDERR_FINDRESFAILURE: msg = wxT("CDERR_FINDRESFAILURE"); break; | |
56 | case CDERR_INITIALIZATION: msg = wxT("CDERR_INITIALIZATION"); break; | |
57 | case CDERR_LOADRESFAILURE: msg = wxT("CDERR_LOADRESFAILURE"); break; | |
58 | case CDERR_LOADSTRFAILURE: msg = wxT("CDERR_LOADSTRFAILURE"); break; | |
59 | case CDERR_LOCKRESFAILURE: msg = wxT("CDERR_LOCKRESFAILURE"); break; | |
60 | case CDERR_MEMALLOCFAILURE: msg = wxT("CDERR_MEMALLOCFAILURE"); break; | |
61 | case CDERR_MEMLOCKFAILURE: msg = wxT("CDERR_MEMLOCKFAILURE"); break; | |
62 | case CDERR_NOHINSTANCE: msg = wxT("CDERR_NOHINSTANCE"); break; | |
63 | case CDERR_NOHOOK: msg = wxT("CDERR_NOHOOK"); break; | |
64 | case CDERR_NOTEMPLATE: msg = wxT("CDERR_NOTEMPLATE"); break; | |
65 | case CDERR_STRUCTSIZE: msg = wxT("CDERR_STRUCTSIZE"); break; | |
66 | case PDERR_RETDEFFAILURE: msg = wxT("PDERR_RETDEFFAILURE"); break; | |
67 | case PDERR_PRINTERNOTFOUND: msg = wxT("PDERR_PRINTERNOTFOUND"); break; | |
68 | case PDERR_PARSEFAILURE: msg = wxT("PDERR_PARSEFAILURE"); break; | |
69 | case PDERR_NODEVICES: msg = wxT("PDERR_NODEVICES"); break; | |
70 | case PDERR_NODEFAULTPRN: msg = wxT("PDERR_NODEFAULTPRN"); break; | |
71 | case PDERR_LOADDRVFAILURE: msg = wxT("PDERR_LOADDRVFAILURE"); break; | |
72 | case PDERR_INITFAILURE: msg = wxT("PDERR_INITFAILURE"); break; | |
73 | case PDERR_GETDEVMODEFAIL: msg = wxT("PDERR_GETDEVMODEFAIL"); break; | |
74 | case PDERR_DNDMMISMATCH: msg = wxT("PDERR_DNDMMISMATCH"); break; | |
75 | case PDERR_DEFAULTDIFFERENT: msg = wxT("PDERR_DEFAULTDIFFERENT"); break; | |
76 | case PDERR_CREATEICFAILURE: msg = wxT("PDERR_CREATEICFAILURE"); break; | |
77 | default: break; | |
78 | } | |
79 | return msg; | |
80 | } | |
81 | ||
82 | static HGLOBAL | |
83 | wxCreateDevNames(const wxString& driverName, | |
84 | const wxString& printerName, | |
85 | const wxString& portName) | |
86 | { | |
87 | HGLOBAL hDev = NULL; | |
88 | // if (!driverName.empty() && !printerName.empty() && !portName.empty()) | |
89 | if (driverName.empty() && printerName.empty() && portName.empty()) | |
90 | { | |
91 | } | |
92 | else | |
93 | { | |
94 | hDev = GlobalAlloc(GPTR, 4*sizeof(WORD)+ | |
95 | ( driverName.length() + 1 + | |
96 | printerName.length() + 1 + | |
97 | portName.length()+1 ) * sizeof(wxChar) ); | |
98 | LPDEVNAMES lpDev = (LPDEVNAMES)GlobalLock(hDev); | |
99 | lpDev->wDriverOffset = sizeof(WORD) * 4 / sizeof(wxChar); | |
100 | wxStrcpy((wxChar*)lpDev + lpDev->wDriverOffset, driverName); | |
101 | ||
102 | lpDev->wDeviceOffset = (WORD)( lpDev->wDriverOffset + | |
103 | driverName.length() + 1 ); | |
104 | wxStrcpy((wxChar*)lpDev + lpDev->wDeviceOffset, printerName); | |
105 | ||
106 | lpDev->wOutputOffset = (WORD)( lpDev->wDeviceOffset + | |
107 | printerName.length() + 1 ); | |
108 | wxStrcpy((wxChar*)lpDev + lpDev->wOutputOffset, portName); | |
109 | ||
110 | lpDev->wDefault = 0; | |
111 | ||
112 | GlobalUnlock(hDev); | |
113 | } | |
114 | ||
115 | return hDev; | |
116 | } | |
117 | ||
118 | IMPLEMENT_CLASS(wxWindowsPrintNativeData, wxPrintNativeDataBase) | |
119 | ||
120 | wxWindowsPrintNativeData::wxWindowsPrintNativeData() | |
121 | { | |
122 | m_devMode = NULL; | |
123 | m_devNames = NULL; | |
124 | m_customWindowsPaperId = 0; | |
125 | } | |
126 | ||
127 | wxWindowsPrintNativeData::~wxWindowsPrintNativeData() | |
128 | { | |
129 | if ( m_devMode ) | |
130 | ::GlobalFree(static_cast<HGLOBAL>(m_devMode)); | |
131 | ||
132 | if ( m_devNames ) | |
133 | ::GlobalFree(static_cast<HGLOBAL>(m_devNames)); | |
134 | } | |
135 | ||
136 | bool wxWindowsPrintNativeData::IsOk() const | |
137 | { | |
138 | return (m_devMode != NULL) ; | |
139 | } | |
140 | ||
141 | bool wxWindowsPrintNativeData::TransferTo( wxPrintData &data ) | |
142 | { | |
143 | if ( !m_devMode ) | |
144 | return false; | |
145 | ||
146 | GlobalPtrLock lockDevMode(m_devMode); | |
147 | ||
148 | LPDEVMODE devMode = static_cast<LPDEVMODE>(lockDevMode.Get()); | |
149 | ||
150 | //// Orientation | |
151 | if (devMode->dmFields & DM_ORIENTATION) | |
152 | data.SetOrientation( devMode->dmOrientation ); | |
153 | ||
154 | //// Collation | |
155 | if (devMode->dmFields & DM_COLLATE) | |
156 | { | |
157 | if (devMode->dmCollate == DMCOLLATE_TRUE) | |
158 | data.SetCollate( true ); | |
159 | else | |
160 | data.SetCollate( false ); | |
161 | } | |
162 | ||
163 | //// Number of copies | |
164 | if (devMode->dmFields & DM_COPIES) | |
165 | data.SetNoCopies( devMode->dmCopies ); | |
166 | ||
167 | //// Bin | |
168 | if (devMode->dmFields & DM_DEFAULTSOURCE) { | |
169 | switch (devMode->dmDefaultSource) { | |
170 | case DMBIN_ONLYONE : data.SetBin(wxPRINTBIN_ONLYONE ); break; | |
171 | case DMBIN_LOWER : data.SetBin(wxPRINTBIN_LOWER ); break; | |
172 | case DMBIN_MIDDLE : data.SetBin(wxPRINTBIN_MIDDLE ); break; | |
173 | case DMBIN_MANUAL : data.SetBin(wxPRINTBIN_MANUAL ); break; | |
174 | case DMBIN_ENVELOPE : data.SetBin(wxPRINTBIN_ENVELOPE ); break; | |
175 | case DMBIN_ENVMANUAL : data.SetBin(wxPRINTBIN_ENVMANUAL ); break; | |
176 | case DMBIN_AUTO : data.SetBin(wxPRINTBIN_AUTO ); break; | |
177 | case DMBIN_TRACTOR : data.SetBin(wxPRINTBIN_TRACTOR ); break; | |
178 | case DMBIN_SMALLFMT : data.SetBin(wxPRINTBIN_SMALLFMT ); break; | |
179 | case DMBIN_LARGEFMT : data.SetBin(wxPRINTBIN_LARGEFMT ); break; | |
180 | case DMBIN_LARGECAPACITY : data.SetBin(wxPRINTBIN_LARGECAPACITY ); break; | |
181 | case DMBIN_CASSETTE : data.SetBin(wxPRINTBIN_CASSETTE ); break; | |
182 | case DMBIN_FORMSOURCE : data.SetBin(wxPRINTBIN_FORMSOURCE ); break; | |
183 | default: | |
184 | if (devMode->dmDefaultSource >= DMBIN_USER) | |
185 | data.SetBin((wxPrintBin)((devMode->dmDefaultSource)-DMBIN_USER+(int)wxPRINTBIN_USER)); | |
186 | else | |
187 | data.SetBin(wxPRINTBIN_DEFAULT); | |
188 | } | |
189 | } else { | |
190 | data.SetBin(wxPRINTBIN_DEFAULT); | |
191 | } | |
192 | if (devMode->dmFields & DM_MEDIATYPE) | |
193 | { | |
194 | wxASSERT( (int)devMode->dmMediaType != wxPRINTMEDIA_DEFAULT ); | |
195 | data.SetMedia(devMode->dmMediaType); | |
196 | } | |
197 | //// Printer name | |
198 | if (devMode->dmDeviceName[0] != 0) | |
199 | // This syntax fixes a crash when using VS 7.1 | |
200 | data.SetPrinterName( wxString(devMode->dmDeviceName, CCHDEVICENAME) ); | |
201 | ||
202 | //// Colour | |
203 | if (devMode->dmFields & DM_COLOR) | |
204 | { | |
205 | if (devMode->dmColor == DMCOLOR_COLOR) | |
206 | data.SetColour( true ); | |
207 | else | |
208 | data.SetColour( false ); | |
209 | } | |
210 | else | |
211 | data.SetColour( true ); | |
212 | ||
213 | //// Paper size | |
214 | ||
215 | // We don't know size of user defined paper and some buggy drivers | |
216 | // set both DM_PAPERSIZE and DM_PAPERWIDTH & DM_PAPERLENGTH. Since | |
217 | // dmPaperSize >= DMPAPER_USER wouldn't be in wxWin's database, this | |
218 | // code wouldn't set m_paperSize correctly. | |
219 | ||
220 | bool foundPaperSize = false; | |
221 | if ((devMode->dmFields & DM_PAPERSIZE) && (devMode->dmPaperSize < DMPAPER_USER)) | |
222 | { | |
223 | if (wxThePrintPaperDatabase) | |
224 | { | |
225 | wxPrintPaperType* paper = wxThePrintPaperDatabase->FindPaperTypeByPlatformId(devMode->dmPaperSize); | |
226 | if (paper) | |
227 | { | |
228 | data.SetPaperId( paper->GetId() ); | |
229 | data.SetPaperSize( wxSize(paper->GetWidth() / 10,paper->GetHeight() / 10) ); | |
230 | m_customWindowsPaperId = 0; | |
231 | foundPaperSize = true; | |
232 | } | |
233 | } | |
234 | else | |
235 | { | |
236 | // Shouldn't really get here | |
237 | wxFAIL_MSG(wxT("Paper database wasn't initialized in wxPrintData::ConvertFromNative.")); | |
238 | data.SetPaperId( wxPAPER_NONE ); | |
239 | data.SetPaperSize( wxSize(0,0) ); | |
240 | m_customWindowsPaperId = 0; | |
241 | ||
242 | return false; | |
243 | } | |
244 | } | |
245 | ||
246 | if (!foundPaperSize) { | |
247 | if ((devMode->dmFields & DM_PAPERWIDTH) && (devMode->dmFields & DM_PAPERLENGTH)) | |
248 | { | |
249 | // DEVMODE is in tenths of a millimeter | |
250 | data.SetPaperSize( wxSize(devMode->dmPaperWidth / 10, devMode->dmPaperLength / 10) ); | |
251 | data.SetPaperId( wxPAPER_NONE ); | |
252 | m_customWindowsPaperId = devMode->dmPaperSize; | |
253 | } | |
254 | else | |
255 | { | |
256 | // Often will reach this for non-standard paper sizes (sizes which | |
257 | // wouldn't be in wxWidget's paper database). Setting | |
258 | // m_customWindowsPaperId to devMode->dmPaperSize should be enough | |
259 | // to get this paper size working. | |
260 | data.SetPaperSize( wxSize(0,0) ); | |
261 | data.SetPaperId( wxPAPER_NONE ); | |
262 | m_customWindowsPaperId = devMode->dmPaperSize; | |
263 | } | |
264 | } | |
265 | ||
266 | //// Duplex | |
267 | ||
268 | if (devMode->dmFields & DM_DUPLEX) | |
269 | { | |
270 | switch (devMode->dmDuplex) | |
271 | { | |
272 | case DMDUP_HORIZONTAL: data.SetDuplex( wxDUPLEX_HORIZONTAL ); break; | |
273 | case DMDUP_VERTICAL: data.SetDuplex( wxDUPLEX_VERTICAL ); break; | |
274 | default: | |
275 | case DMDUP_SIMPLEX: data.SetDuplex( wxDUPLEX_SIMPLEX ); break; | |
276 | } | |
277 | } | |
278 | else | |
279 | data.SetDuplex( wxDUPLEX_SIMPLEX ); | |
280 | ||
281 | //// Quality | |
282 | ||
283 | if (devMode->dmFields & DM_PRINTQUALITY) | |
284 | { | |
285 | switch (devMode->dmPrintQuality) | |
286 | { | |
287 | case DMRES_MEDIUM: data.SetQuality( wxPRINT_QUALITY_MEDIUM ); break; | |
288 | case DMRES_LOW: data.SetQuality( wxPRINT_QUALITY_LOW ); break; | |
289 | case DMRES_DRAFT: data.SetQuality( wxPRINT_QUALITY_DRAFT ); break; | |
290 | case DMRES_HIGH: data.SetQuality( wxPRINT_QUALITY_HIGH ); break; | |
291 | default: | |
292 | { | |
293 | // TODO: if the printer fills in the resolution in DPI, how | |
294 | // will the application know if it's high, low, draft etc.?? | |
295 | // wxFAIL_MSG("Warning: DM_PRINTQUALITY was not one of the standard values."); | |
296 | data.SetQuality( devMode->dmPrintQuality ); | |
297 | break; | |
298 | ||
299 | } | |
300 | } | |
301 | } | |
302 | else | |
303 | data.SetQuality( wxPRINT_QUALITY_HIGH ); | |
304 | ||
305 | if (devMode->dmDriverExtra > 0) | |
306 | data.SetPrivData( (char *)devMode+devMode->dmSize, devMode->dmDriverExtra ); | |
307 | else | |
308 | data.SetPrivData( NULL, 0 ); | |
309 | ||
310 | if ( m_devNames ) | |
311 | { | |
312 | GlobalPtrLock lockDevNames(m_devNames); | |
313 | LPDEVNAMES lpDevNames = static_cast<LPDEVNAMES>(lockDevNames.Get()); | |
314 | ||
315 | // TODO: Unicode-ification | |
316 | ||
317 | // Get the port name | |
318 | // port is obsolete in WIN32 | |
319 | // m_printData.SetPortName((LPSTR)lpDevNames + lpDevNames->wDriverOffset); | |
320 | ||
321 | // Get the printer name | |
322 | wxString printerName = (LPTSTR)lpDevNames + lpDevNames->wDeviceOffset; | |
323 | ||
324 | // Not sure if we should check for this mismatch | |
325 | // wxASSERT_MSG( (m_printerName.empty() || (devName == m_printerName)), "Printer name obtained from DEVMODE and DEVNAMES were different!"); | |
326 | ||
327 | if (!printerName.empty()) | |
328 | data.SetPrinterName( printerName ); | |
329 | } | |
330 | ||
331 | return true; | |
332 | } | |
333 | ||
334 | bool wxWindowsPrintNativeData::TransferFrom( const wxPrintData &data ) | |
335 | { | |
336 | HGLOBAL hDevMode = static_cast<HGLOBAL>(m_devMode); | |
337 | if ( !m_devMode ) | |
338 | { | |
339 | // Use PRINTDLG as a way of creating a DEVMODE object | |
340 | PRINTDLG pd; | |
341 | ||
342 | memset(&pd, 0, sizeof(PRINTDLG)); | |
343 | #ifdef __WXWINCE__ | |
344 | pd.cbStruct = sizeof(PRINTDLG); | |
345 | #else | |
346 | pd.lStructSize = sizeof(PRINTDLG); | |
347 | #endif | |
348 | ||
349 | pd.hwndOwner = NULL; | |
350 | pd.hDevMode = NULL; // Will be created by PrintDlg | |
351 | pd.hDevNames = NULL; // Ditto | |
352 | ||
353 | pd.Flags = PD_RETURNDEFAULT; | |
354 | pd.nCopies = 1; | |
355 | ||
356 | // Fill out the DEVMODE structure | |
357 | // so we can use it as input in the 'real' PrintDlg | |
358 | if (!PrintDlg(&pd)) | |
359 | { | |
360 | if ( pd.hDevMode ) | |
361 | GlobalFree(pd.hDevMode); | |
362 | if ( pd.hDevNames ) | |
363 | GlobalFree(pd.hDevNames); | |
364 | pd.hDevMode = NULL; | |
365 | pd.hDevNames = NULL; | |
366 | ||
367 | wxLogDebug(wxT("Printing error: ") + wxGetPrintDlgError()); | |
368 | } | |
369 | else | |
370 | { | |
371 | hDevMode = pd.hDevMode; | |
372 | m_devMode = hDevMode; | |
373 | pd.hDevMode = NULL; | |
374 | ||
375 | // We'll create a new DEVNAMEs structure below. | |
376 | if ( pd.hDevNames ) | |
377 | GlobalFree(pd.hDevNames); | |
378 | pd.hDevNames = NULL; | |
379 | ||
380 | // hDevNames = pd->hDevNames; | |
381 | // m_devNames = (void*)(long) hDevNames; | |
382 | // pd->hDevnames = NULL; | |
383 | ||
384 | } | |
385 | } | |
386 | ||
387 | if ( hDevMode ) | |
388 | { | |
389 | GlobalPtrLock lockDevMode(hDevMode); | |
390 | DEVMODE * const devMode = static_cast<DEVMODE *>(lockDevMode.Get()); | |
391 | ||
392 | //// Orientation | |
393 | devMode->dmOrientation = (short)data.GetOrientation(); | |
394 | ||
395 | //// Collation | |
396 | devMode->dmCollate = (data.GetCollate() ? DMCOLLATE_TRUE : DMCOLLATE_FALSE); | |
397 | devMode->dmFields |= DM_COLLATE; | |
398 | ||
399 | //// Number of copies | |
400 | devMode->dmCopies = (short)data.GetNoCopies(); | |
401 | devMode->dmFields |= DM_COPIES; | |
402 | ||
403 | //// Printer name | |
404 | wxString name = data.GetPrinterName(); | |
405 | if (!name.empty()) | |
406 | { | |
407 | // NB: the cast is needed in the ANSI build, strangely enough | |
408 | // dmDeviceName is BYTE[] and not char[] there | |
409 | wxStrlcpy(reinterpret_cast<wxChar *>(devMode->dmDeviceName), | |
410 | name.wx_str(), | |
411 | WXSIZEOF(devMode->dmDeviceName)); | |
412 | } | |
413 | ||
414 | //// Colour | |
415 | if (data.GetColour()) | |
416 | devMode->dmColor = DMCOLOR_COLOR; | |
417 | else | |
418 | devMode->dmColor = DMCOLOR_MONOCHROME; | |
419 | devMode->dmFields |= DM_COLOR; | |
420 | ||
421 | //// Paper size | |
422 | ||
423 | // Paper id has priority over paper size. If id is specified, then size | |
424 | // is ignored (as it can be filled in even for standard paper sizes) | |
425 | ||
426 | wxPrintPaperType *paperType = NULL; | |
427 | ||
428 | const wxPaperSize paperId = data.GetPaperId(); | |
429 | if ( paperId != wxPAPER_NONE && wxThePrintPaperDatabase ) | |
430 | { | |
431 | paperType = wxThePrintPaperDatabase->FindPaperType(paperId); | |
432 | } | |
433 | ||
434 | if ( paperType ) | |
435 | { | |
436 | devMode->dmPaperSize = (short)paperType->GetPlatformId(); | |
437 | devMode->dmFields |= DM_PAPERSIZE; | |
438 | } | |
439 | else // custom (or no) paper size | |
440 | { | |
441 | const wxSize paperSize = data.GetPaperSize(); | |
442 | if ( paperSize != wxDefaultSize ) | |
443 | { | |
444 | // Fall back on specifying the paper size explicitly | |
445 | if(m_customWindowsPaperId != 0) | |
446 | devMode->dmPaperSize = m_customWindowsPaperId; | |
447 | else | |
448 | devMode->dmPaperSize = DMPAPER_USER; | |
449 | devMode->dmPaperWidth = (short)(paperSize.x * 10); | |
450 | devMode->dmPaperLength = (short)(paperSize.y * 10); | |
451 | devMode->dmFields |= DM_PAPERWIDTH; | |
452 | devMode->dmFields |= DM_PAPERLENGTH; | |
453 | } | |
454 | //else: neither paper type nor size specified, don't fill DEVMODE | |
455 | // at all so that the system defaults are used | |
456 | } | |
457 | ||
458 | //// Duplex | |
459 | short duplex; | |
460 | switch (data.GetDuplex()) | |
461 | { | |
462 | case wxDUPLEX_HORIZONTAL: | |
463 | duplex = DMDUP_HORIZONTAL; | |
464 | break; | |
465 | case wxDUPLEX_VERTICAL: | |
466 | duplex = DMDUP_VERTICAL; | |
467 | break; | |
468 | default: | |
469 | // in fact case wxDUPLEX_SIMPLEX: | |
470 | duplex = DMDUP_SIMPLEX; | |
471 | break; | |
472 | } | |
473 | devMode->dmDuplex = duplex; | |
474 | devMode->dmFields |= DM_DUPLEX; | |
475 | ||
476 | //// Quality | |
477 | ||
478 | short quality; | |
479 | switch (data.GetQuality()) | |
480 | { | |
481 | case wxPRINT_QUALITY_MEDIUM: | |
482 | quality = DMRES_MEDIUM; | |
483 | break; | |
484 | case wxPRINT_QUALITY_LOW: | |
485 | quality = DMRES_LOW; | |
486 | break; | |
487 | case wxPRINT_QUALITY_DRAFT: | |
488 | quality = DMRES_DRAFT; | |
489 | break; | |
490 | case wxPRINT_QUALITY_HIGH: | |
491 | quality = DMRES_HIGH; | |
492 | break; | |
493 | default: | |
494 | quality = (short)data.GetQuality(); | |
495 | break; | |
496 | } | |
497 | devMode->dmPrintQuality = quality; | |
498 | devMode->dmFields |= DM_PRINTQUALITY; | |
499 | ||
500 | if (data.GetPrivDataLen() > 0) | |
501 | { | |
502 | memcpy( (char *)devMode+devMode->dmSize, data.GetPrivData(), data.GetPrivDataLen() ); | |
503 | devMode->dmDriverExtra = (WXWORD)data.GetPrivDataLen(); | |
504 | } | |
505 | ||
506 | if (data.GetBin() != wxPRINTBIN_DEFAULT) | |
507 | { | |
508 | switch (data.GetBin()) | |
509 | { | |
510 | case wxPRINTBIN_ONLYONE: devMode->dmDefaultSource = DMBIN_ONLYONE; break; | |
511 | case wxPRINTBIN_LOWER: devMode->dmDefaultSource = DMBIN_LOWER; break; | |
512 | case wxPRINTBIN_MIDDLE: devMode->dmDefaultSource = DMBIN_MIDDLE; break; | |
513 | case wxPRINTBIN_MANUAL: devMode->dmDefaultSource = DMBIN_MANUAL; break; | |
514 | case wxPRINTBIN_ENVELOPE: devMode->dmDefaultSource = DMBIN_ENVELOPE; break; | |
515 | case wxPRINTBIN_ENVMANUAL: devMode->dmDefaultSource = DMBIN_ENVMANUAL; break; | |
516 | case wxPRINTBIN_AUTO: devMode->dmDefaultSource = DMBIN_AUTO; break; | |
517 | case wxPRINTBIN_TRACTOR: devMode->dmDefaultSource = DMBIN_TRACTOR; break; | |
518 | case wxPRINTBIN_SMALLFMT: devMode->dmDefaultSource = DMBIN_SMALLFMT; break; | |
519 | case wxPRINTBIN_LARGEFMT: devMode->dmDefaultSource = DMBIN_LARGEFMT; break; | |
520 | case wxPRINTBIN_LARGECAPACITY: devMode->dmDefaultSource = DMBIN_LARGECAPACITY; break; | |
521 | case wxPRINTBIN_CASSETTE: devMode->dmDefaultSource = DMBIN_CASSETTE; break; | |
522 | case wxPRINTBIN_FORMSOURCE: devMode->dmDefaultSource = DMBIN_FORMSOURCE; break; | |
523 | ||
524 | default: | |
525 | devMode->dmDefaultSource = (short)(DMBIN_USER + data.GetBin() - wxPRINTBIN_USER); // 256 + data.GetBin() - 14 = 242 + data.GetBin() | |
526 | break; | |
527 | } | |
528 | ||
529 | devMode->dmFields |= DM_DEFAULTSOURCE; | |
530 | } | |
531 | if (data.GetMedia() != wxPRINTMEDIA_DEFAULT) | |
532 | { | |
533 | devMode->dmMediaType = data.GetMedia(); | |
534 | devMode->dmFields |= DM_MEDIATYPE; | |
535 | } | |
536 | } | |
537 | ||
538 | if ( m_devNames ) | |
539 | { | |
540 | ::GlobalFree(static_cast<HGLOBAL>(m_devNames)); | |
541 | } | |
542 | ||
543 | // TODO: I hope it's OK to pass some empty strings to DEVNAMES. | |
544 | m_devNames = wxCreateDevNames(wxEmptyString, data.GetPrinterName(), wxEmptyString); | |
545 | ||
546 | return true; | |
547 | } | |
548 | ||
549 | // --------------------------------------------------------------------------- | |
550 | // wxPrintDialog | |
551 | // --------------------------------------------------------------------------- | |
552 | ||
553 | IMPLEMENT_CLASS(wxWindowsPrintDialog, wxPrintDialogBase) | |
554 | ||
555 | wxWindowsPrintDialog::wxWindowsPrintDialog(wxWindow *p, wxPrintDialogData* data) | |
556 | { | |
557 | Create(p, data); | |
558 | } | |
559 | ||
560 | wxWindowsPrintDialog::wxWindowsPrintDialog(wxWindow *p, wxPrintData* data) | |
561 | { | |
562 | wxPrintDialogData data2; | |
563 | if ( data ) | |
564 | data2 = *data; | |
565 | ||
566 | Create(p, &data2); | |
567 | } | |
568 | ||
569 | bool wxWindowsPrintDialog::Create(wxWindow *p, wxPrintDialogData* data) | |
570 | { | |
571 | m_dialogParent = p; | |
572 | m_printerDC = NULL; | |
573 | m_destroyDC = true; | |
574 | ||
575 | // MSW handle | |
576 | m_printDlg = NULL; | |
577 | ||
578 | if ( data ) | |
579 | m_printDialogData = *data; | |
580 | ||
581 | return true; | |
582 | } | |
583 | ||
584 | wxWindowsPrintDialog::~wxWindowsPrintDialog() | |
585 | { | |
586 | PRINTDLG *pd = (PRINTDLG *) m_printDlg; | |
587 | if (pd && pd->hDevMode) | |
588 | GlobalFree(pd->hDevMode); | |
589 | if ( pd ) | |
590 | delete pd; | |
591 | ||
592 | if (m_destroyDC && m_printerDC) | |
593 | delete m_printerDC; | |
594 | } | |
595 | ||
596 | int wxWindowsPrintDialog::ShowModal() | |
597 | { | |
598 | ConvertToNative( m_printDialogData ); | |
599 | ||
600 | PRINTDLG *pd = (PRINTDLG*) m_printDlg; | |
601 | ||
602 | if (m_dialogParent) | |
603 | pd->hwndOwner = (HWND) m_dialogParent->GetHWND(); | |
604 | else if (wxTheApp->GetTopWindow()) | |
605 | pd->hwndOwner = (HWND) wxTheApp->GetTopWindow()->GetHWND(); | |
606 | else | |
607 | pd->hwndOwner = 0; | |
608 | ||
609 | bool ret = (PrintDlg( pd ) != 0); | |
610 | ||
611 | pd->hwndOwner = 0; | |
612 | ||
613 | if ( ret && (pd->hDC) ) | |
614 | { | |
615 | wxPrinterDC *pdc = new wxPrinterDCFromHDC( (WXHDC) pd->hDC ); | |
616 | m_printerDC = pdc; | |
617 | ConvertFromNative( m_printDialogData ); | |
618 | return wxID_OK; | |
619 | } | |
620 | else | |
621 | { | |
622 | return wxID_CANCEL; | |
623 | } | |
624 | } | |
625 | ||
626 | wxDC *wxWindowsPrintDialog::GetPrintDC() | |
627 | { | |
628 | if (m_printerDC) | |
629 | { | |
630 | m_destroyDC = false; | |
631 | return m_printerDC; | |
632 | } | |
633 | else | |
634 | return NULL; | |
635 | } | |
636 | ||
637 | bool wxWindowsPrintDialog::ConvertToNative( wxPrintDialogData &data ) | |
638 | { | |
639 | wxWindowsPrintNativeData *native_data = | |
640 | (wxWindowsPrintNativeData *) data.GetPrintData().GetNativeData(); | |
641 | data.GetPrintData().ConvertToNative(); | |
642 | ||
643 | PRINTDLG *pd = (PRINTDLG*) m_printDlg; | |
644 | ||
645 | // Shouldn't have been defined anywhere | |
646 | if (pd) | |
647 | return false; | |
648 | ||
649 | pd = new PRINTDLG; | |
650 | memset( pd, 0, sizeof(PRINTDLG) ); | |
651 | m_printDlg = (void*) pd; | |
652 | ||
653 | pd->lStructSize = sizeof(PRINTDLG); | |
654 | pd->hwndOwner = NULL; | |
655 | pd->hDevMode = NULL; // Will be created by PrintDlg | |
656 | pd->hDevNames = NULL; // Ditto | |
657 | ||
658 | pd->Flags = PD_RETURNDEFAULT; | |
659 | pd->nCopies = 1; | |
660 | ||
661 | // Pass the devmode data to the PRINTDLG structure, since it'll | |
662 | // be needed when PrintDlg is called. | |
663 | if (pd->hDevMode) | |
664 | GlobalFree(pd->hDevMode); | |
665 | ||
666 | // Pass the devnames data to the PRINTDLG structure, since it'll | |
667 | // be needed when PrintDlg is called. | |
668 | if (pd->hDevNames) | |
669 | GlobalFree(pd->hDevNames); | |
670 | ||
671 | pd->hDevMode = static_cast<HGLOBAL>(native_data->GetDevMode()); | |
672 | native_data->SetDevMode(NULL); | |
673 | ||
674 | // Shouldn't assert; we should be able to test Ok-ness at a higher level | |
675 | //wxASSERT_MSG( (pd->hDevMode), wxT("hDevMode must be non-NULL in ConvertToNative!")); | |
676 | ||
677 | pd->hDevNames = static_cast<HGLOBAL>(native_data->GetDevNames()); | |
678 | native_data->SetDevNames(NULL); | |
679 | ||
680 | ||
681 | pd->hDC = NULL; | |
682 | pd->nFromPage = (WORD)data.GetFromPage(); | |
683 | pd->nToPage = (WORD)data.GetToPage(); | |
684 | pd->nMinPage = (WORD)data.GetMinPage(); | |
685 | pd->nMaxPage = (WORD)data.GetMaxPage(); | |
686 | pd->nCopies = (WORD)data.GetNoCopies(); | |
687 | ||
688 | pd->Flags = PD_RETURNDC; | |
689 | pd->lStructSize = sizeof( PRINTDLG ); | |
690 | ||
691 | pd->hwndOwner = NULL; | |
692 | pd->hInstance = NULL; | |
693 | pd->lCustData = 0; | |
694 | pd->lpfnPrintHook = NULL; | |
695 | pd->lpfnSetupHook = NULL; | |
696 | pd->lpPrintTemplateName = NULL; | |
697 | pd->lpSetupTemplateName = NULL; | |
698 | pd->hPrintTemplate = NULL; | |
699 | pd->hSetupTemplate = NULL; | |
700 | ||
701 | if ( data.GetAllPages() ) | |
702 | pd->Flags |= PD_ALLPAGES; | |
703 | if ( data.GetSelection() ) | |
704 | pd->Flags |= PD_SELECTION; | |
705 | if ( data.GetCollate() ) | |
706 | pd->Flags |= PD_COLLATE; | |
707 | if ( data.GetPrintToFile() ) | |
708 | pd->Flags |= PD_PRINTTOFILE; | |
709 | if ( !data.GetEnablePrintToFile() ) | |
710 | pd->Flags |= PD_DISABLEPRINTTOFILE; | |
711 | if ( !data.GetEnableSelection() ) | |
712 | pd->Flags |= PD_NOSELECTION; | |
713 | if ( !data.GetEnablePageNumbers() ) | |
714 | pd->Flags |= PD_NOPAGENUMS; | |
715 | else if ( (!data.GetAllPages()) && (!data.GetSelection()) && (data.GetFromPage() != 0) && (data.GetToPage() != 0)) | |
716 | pd->Flags |= PD_PAGENUMS; | |
717 | if ( data.GetEnableHelp() ) | |
718 | pd->Flags |= PD_SHOWHELP; | |
719 | ||
720 | return true; | |
721 | } | |
722 | ||
723 | bool wxWindowsPrintDialog::ConvertFromNative( wxPrintDialogData &data ) | |
724 | { | |
725 | PRINTDLG *pd = (PRINTDLG*) m_printDlg; | |
726 | if ( pd == NULL ) | |
727 | return false; | |
728 | ||
729 | wxWindowsPrintNativeData *native_data = | |
730 | (wxWindowsPrintNativeData *) data.GetPrintData().GetNativeData(); | |
731 | ||
732 | // Pass the devmode data back to the wxPrintData structure where it really belongs. | |
733 | if (pd->hDevMode) | |
734 | { | |
735 | if (native_data->GetDevMode()) | |
736 | { | |
737 | ::GlobalFree(static_cast<HGLOBAL>(native_data->GetDevMode())); | |
738 | } | |
739 | native_data->SetDevMode(pd->hDevMode); | |
740 | pd->hDevMode = NULL; | |
741 | } | |
742 | ||
743 | // Pass the devnames data back to the wxPrintData structure where it really belongs. | |
744 | if (pd->hDevNames) | |
745 | { | |
746 | if (native_data->GetDevNames()) | |
747 | { | |
748 | ::GlobalFree(static_cast<HGLOBAL>(native_data->GetDevNames())); | |
749 | } | |
750 | native_data->SetDevNames(pd->hDevNames); | |
751 | pd->hDevNames = NULL; | |
752 | } | |
753 | ||
754 | // Now convert the DEVMODE object, passed down from the PRINTDLG object, | |
755 | // into wxWidgets form. | |
756 | native_data->TransferTo( data.GetPrintData() ); | |
757 | ||
758 | data.SetFromPage( pd->nFromPage ); | |
759 | data.SetToPage( pd->nToPage ); | |
760 | data.SetMinPage( pd->nMinPage ); | |
761 | data.SetMaxPage( pd->nMaxPage ); | |
762 | data.SetNoCopies( pd->nCopies ); | |
763 | ||
764 | data.SetAllPages( (((pd->Flags & PD_PAGENUMS) != PD_PAGENUMS) && ((pd->Flags & PD_SELECTION) != PD_SELECTION)) ); | |
765 | data.SetSelection( ((pd->Flags & PD_SELECTION) == PD_SELECTION) ); | |
766 | data.SetCollate( ((pd->Flags & PD_COLLATE) == PD_COLLATE) ); | |
767 | data.SetPrintToFile( ((pd->Flags & PD_PRINTTOFILE) == PD_PRINTTOFILE) ); | |
768 | data.EnablePrintToFile( ((pd->Flags & PD_DISABLEPRINTTOFILE) != PD_DISABLEPRINTTOFILE) ); | |
769 | data.EnableSelection( ((pd->Flags & PD_NOSELECTION) != PD_NOSELECTION) ); | |
770 | data.EnablePageNumbers( ((pd->Flags & PD_NOPAGENUMS) != PD_NOPAGENUMS) ); | |
771 | data.EnableHelp( ((pd->Flags & PD_SHOWHELP) == PD_SHOWHELP) ); | |
772 | ||
773 | return true; | |
774 | } | |
775 | ||
776 | // --------------------------------------------------------------------------- | |
777 | // wxWidnowsPageSetupDialog | |
778 | // --------------------------------------------------------------------------- | |
779 | ||
780 | IMPLEMENT_CLASS(wxWindowsPageSetupDialog, wxPageSetupDialogBase) | |
781 | ||
782 | wxWindowsPageSetupDialog::wxWindowsPageSetupDialog() | |
783 | { | |
784 | m_dialogParent = NULL; | |
785 | m_pageDlg = NULL; | |
786 | } | |
787 | ||
788 | wxWindowsPageSetupDialog::wxWindowsPageSetupDialog(wxWindow *p, wxPageSetupDialogData *data) | |
789 | { | |
790 | Create(p, data); | |
791 | } | |
792 | ||
793 | bool wxWindowsPageSetupDialog::Create(wxWindow *p, wxPageSetupDialogData *data) | |
794 | { | |
795 | m_dialogParent = p; | |
796 | m_pageDlg = NULL; | |
797 | ||
798 | if (data) | |
799 | m_pageSetupData = (*data); | |
800 | ||
801 | return true; | |
802 | } | |
803 | ||
804 | wxWindowsPageSetupDialog::~wxWindowsPageSetupDialog() | |
805 | { | |
806 | PAGESETUPDLG *pd = (PAGESETUPDLG *)m_pageDlg; | |
807 | if ( pd && pd->hDevMode ) | |
808 | GlobalFree(pd->hDevMode); | |
809 | if ( pd && pd->hDevNames ) | |
810 | GlobalFree(pd->hDevNames); | |
811 | if ( pd ) | |
812 | delete pd; | |
813 | } | |
814 | ||
815 | int wxWindowsPageSetupDialog::ShowModal() | |
816 | { | |
817 | ConvertToNative( m_pageSetupData ); | |
818 | ||
819 | PAGESETUPDLG *pd = (PAGESETUPDLG *) m_pageDlg; | |
820 | if (m_dialogParent) | |
821 | pd->hwndOwner = (HWND) m_dialogParent->GetHWND(); | |
822 | else if (wxTheApp->GetTopWindow()) | |
823 | pd->hwndOwner = (HWND) wxTheApp->GetTopWindow()->GetHWND(); | |
824 | else | |
825 | pd->hwndOwner = 0; | |
826 | BOOL retVal = PageSetupDlg( pd ) ; | |
827 | pd->hwndOwner = 0; | |
828 | if (retVal) | |
829 | { | |
830 | ConvertFromNative( m_pageSetupData ); | |
831 | return wxID_OK; | |
832 | } | |
833 | else | |
834 | return wxID_CANCEL; | |
835 | } | |
836 | ||
837 | bool wxWindowsPageSetupDialog::ConvertToNative( wxPageSetupDialogData &data ) | |
838 | { | |
839 | wxWindowsPrintNativeData *native_data = | |
840 | (wxWindowsPrintNativeData *) data.GetPrintData().GetNativeData(); | |
841 | data.GetPrintData().ConvertToNative(); | |
842 | ||
843 | PAGESETUPDLG *pd = (PAGESETUPDLG*) m_pageDlg; | |
844 | ||
845 | // Shouldn't have been defined anywhere | |
846 | if (pd) | |
847 | return false; | |
848 | ||
849 | pd = new PAGESETUPDLG; | |
850 | pd->hDevMode = NULL; | |
851 | pd->hDevNames = NULL; | |
852 | m_pageDlg = (void *)pd; | |
853 | ||
854 | // Pass the devmode data (created in m_printData.ConvertToNative) | |
855 | // to the PRINTDLG structure, since it'll | |
856 | // be needed when PrintDlg is called. | |
857 | ||
858 | if (pd->hDevMode) | |
859 | { | |
860 | GlobalFree(pd->hDevMode); | |
861 | pd->hDevMode = NULL; | |
862 | } | |
863 | pd->hDevMode = (HGLOBAL) native_data->GetDevMode(); | |
864 | native_data->SetDevMode(NULL); | |
865 | ||
866 | // Shouldn't assert; we should be able to test Ok-ness at a higher level | |
867 | //wxASSERT_MSG( (pd->hDevMode), wxT("hDevMode must be non-NULL in ConvertToNative!")); | |
868 | ||
869 | // Pass the devnames data (created in m_printData.ConvertToNative) | |
870 | // to the PRINTDLG structure, since it'll | |
871 | // be needed when PrintDlg is called. | |
872 | ||
873 | if (pd->hDevNames) | |
874 | { | |
875 | GlobalFree(pd->hDevNames); | |
876 | pd->hDevNames = NULL; | |
877 | } | |
878 | pd->hDevNames = (HGLOBAL) native_data->GetDevNames(); | |
879 | native_data->SetDevNames(NULL); | |
880 | ||
881 | // pd->hDevMode = GlobalAlloc(GMEM_MOVEABLE, sizeof(DEVMODE)); | |
882 | ||
883 | pd->Flags = PSD_MARGINS|PSD_MINMARGINS; | |
884 | ||
885 | if ( data.GetDefaultMinMargins() ) | |
886 | pd->Flags |= PSD_DEFAULTMINMARGINS; | |
887 | if ( !data.GetEnableMargins() ) | |
888 | pd->Flags |= PSD_DISABLEMARGINS; | |
889 | if ( !data.GetEnableOrientation() ) | |
890 | pd->Flags |= PSD_DISABLEORIENTATION; | |
891 | if ( !data.GetEnablePaper() ) | |
892 | pd->Flags |= PSD_DISABLEPAPER; | |
893 | if ( !data.GetEnablePrinter() ) | |
894 | pd->Flags |= PSD_DISABLEPRINTER; | |
895 | if ( data.GetDefaultInfo() ) | |
896 | pd->Flags |= PSD_RETURNDEFAULT; | |
897 | if ( data.GetEnableHelp() ) | |
898 | pd->Flags |= PSD_SHOWHELP; | |
899 | ||
900 | // We want the units to be in hundredths of a millimetre | |
901 | pd->Flags |= PSD_INHUNDREDTHSOFMILLIMETERS; | |
902 | ||
903 | pd->lStructSize = sizeof( PAGESETUPDLG ); | |
904 | pd->hwndOwner = NULL; | |
905 | pd->hInstance = NULL; | |
906 | // PAGESETUPDLG is in hundreds of a mm | |
907 | pd->ptPaperSize.x = data.GetPaperSize().x * 100; | |
908 | pd->ptPaperSize.y = data.GetPaperSize().y * 100; | |
909 | ||
910 | pd->rtMinMargin.left = data.GetMinMarginTopLeft().x * 100; | |
911 | pd->rtMinMargin.top = data.GetMinMarginTopLeft().y * 100; | |
912 | pd->rtMinMargin.right = data.GetMinMarginBottomRight().x * 100; | |
913 | pd->rtMinMargin.bottom = data.GetMinMarginBottomRight().y * 100; | |
914 | ||
915 | pd->rtMargin.left = data.GetMarginTopLeft().x * 100; | |
916 | pd->rtMargin.top = data.GetMarginTopLeft().y * 100; | |
917 | pd->rtMargin.right = data.GetMarginBottomRight().x * 100; | |
918 | pd->rtMargin.bottom = data.GetMarginBottomRight().y * 100; | |
919 | ||
920 | pd->lCustData = 0; | |
921 | pd->lpfnPageSetupHook = NULL; | |
922 | pd->lpfnPagePaintHook = NULL; | |
923 | pd->hPageSetupTemplate = NULL; | |
924 | pd->lpPageSetupTemplateName = NULL; | |
925 | ||
926 | /* | |
927 | if ( pd->hDevMode ) | |
928 | { | |
929 | DEVMODE *devMode = (DEVMODE*) GlobalLock(pd->hDevMode); | |
930 | memset(devMode, 0, sizeof(DEVMODE)); | |
931 | devMode->dmSize = sizeof(DEVMODE); | |
932 | devMode->dmOrientation = m_orientation; | |
933 | devMode->dmFields = DM_ORIENTATION; | |
934 | GlobalUnlock(pd->hDevMode); | |
935 | } | |
936 | */ | |
937 | return true; | |
938 | } | |
939 | ||
940 | bool wxWindowsPageSetupDialog::ConvertFromNative( wxPageSetupDialogData &data ) | |
941 | { | |
942 | PAGESETUPDLG *pd = (PAGESETUPDLG *) m_pageDlg; | |
943 | if ( !pd ) | |
944 | return false; | |
945 | ||
946 | wxWindowsPrintNativeData *native_data = | |
947 | (wxWindowsPrintNativeData *) data.GetPrintData().GetNativeData(); | |
948 | ||
949 | // Pass the devmode data back to the wxPrintData structure where it really belongs. | |
950 | if (pd->hDevMode) | |
951 | { | |
952 | if (native_data->GetDevMode()) | |
953 | { | |
954 | // Make sure we don't leak memory | |
955 | GlobalFree((HGLOBAL) native_data->GetDevMode()); | |
956 | } | |
957 | native_data->SetDevMode( (void*) pd->hDevMode ); | |
958 | pd->hDevMode = NULL; | |
959 | } | |
960 | ||
961 | // Isn't this superfluous? It's called again below. | |
962 | // data.GetPrintData().ConvertFromNative(); | |
963 | ||
964 | // Pass the devnames data back to the wxPrintData structure where it really belongs. | |
965 | if (pd->hDevNames) | |
966 | { | |
967 | if (native_data->GetDevNames()) | |
968 | { | |
969 | // Make sure we don't leak memory | |
970 | GlobalFree((HGLOBAL) native_data->GetDevNames()); | |
971 | } | |
972 | native_data->SetDevNames((void*) pd->hDevNames); | |
973 | pd->hDevNames = NULL; | |
974 | } | |
975 | ||
976 | data.GetPrintData().ConvertFromNative(); | |
977 | ||
978 | pd->Flags = PSD_MARGINS|PSD_MINMARGINS; | |
979 | ||
980 | data.SetDefaultMinMargins( ((pd->Flags & PSD_DEFAULTMINMARGINS) == PSD_DEFAULTMINMARGINS) ); | |
981 | data.EnableMargins( ((pd->Flags & PSD_DISABLEMARGINS) != PSD_DISABLEMARGINS) ); | |
982 | data.EnableOrientation( ((pd->Flags & PSD_DISABLEORIENTATION) != PSD_DISABLEORIENTATION) ); | |
983 | data.EnablePaper( ((pd->Flags & PSD_DISABLEPAPER) != PSD_DISABLEPAPER) ); | |
984 | data.EnablePrinter( ((pd->Flags & PSD_DISABLEPRINTER) != PSD_DISABLEPRINTER) ); | |
985 | data.SetDefaultInfo( ((pd->Flags & PSD_RETURNDEFAULT) == PSD_RETURNDEFAULT) ); | |
986 | data.EnableHelp( ((pd->Flags & PSD_SHOWHELP) == PSD_SHOWHELP) ); | |
987 | ||
988 | // PAGESETUPDLG is in hundreds of a mm | |
989 | if (data.GetPrintData().GetOrientation() == wxLANDSCAPE) | |
990 | data.SetPaperSize( wxSize(pd->ptPaperSize.y / 100, pd->ptPaperSize.x / 100) ); | |
991 | else | |
992 | data.SetPaperSize( wxSize(pd->ptPaperSize.x / 100, pd->ptPaperSize.y / 100) ); | |
993 | ||
994 | data.SetMinMarginTopLeft( wxPoint(pd->rtMinMargin.left / 100, pd->rtMinMargin.top / 100) ); | |
995 | data.SetMinMarginBottomRight( wxPoint(pd->rtMinMargin.right / 100, pd->rtMinMargin.bottom / 100) ); | |
996 | ||
997 | data.SetMarginTopLeft( wxPoint(pd->rtMargin.left / 100, pd->rtMargin.top / 100) ); | |
998 | data.SetMarginBottomRight( wxPoint(pd->rtMargin.right / 100, pd->rtMargin.bottom / 100) ); | |
999 | ||
1000 | return true; | |
1001 | } | |
1002 | ||
1003 | #endif | |
1004 | // wxUSE_PRINTING_ARCHITECTURE |