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