]>
Commit | Line | Data |
---|---|---|
c801d85f KB |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: cmndata.cpp | |
3 | // Purpose: Common GDI data | |
4 | // Author: Julian Smart | |
5 | // Modified by: | |
6 | // Created: 01/02/97 | |
7 | // RCS-ID: $Id$ | |
55d99c7a | 8 | // Copyright: (c) Julian Smart |
65571936 | 9 | // Licence: wxWindows licence |
c801d85f KB |
10 | ///////////////////////////////////////////////////////////////////////////// |
11 | ||
8826f46f VZ |
12 | // ============================================================================ |
13 | // declarations | |
14 | // ============================================================================ | |
15 | ||
16 | // ---------------------------------------------------------------------------- | |
17 | // headers | |
18 | // ---------------------------------------------------------------------------- | |
19 | ||
14f355c2 | 20 | #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) |
8826f46f | 21 | #pragma implementation "cmndata.h" |
c801d85f KB |
22 | #endif |
23 | ||
24 | // For compilers that support precompilation, includes "wx.h". | |
25 | #include "wx/wxprec.h" | |
26 | ||
27 | #ifdef __BORLANDC__ | |
8826f46f | 28 | #pragma hdrstop |
c801d85f KB |
29 | #endif |
30 | ||
31 | #ifndef WX_PRECOMP | |
8826f46f VZ |
32 | #include <stdio.h> |
33 | #include "wx/string.h" | |
34 | #include "wx/utils.h" | |
35 | #include "wx/app.h" | |
c801d85f KB |
36 | #endif |
37 | ||
38 | #include "wx/gdicmn.h" | |
39 | #include "wx/cmndata.h" | |
6776a0b2 | 40 | #include "wx/log.h" |
8826f46f | 41 | |
dbc65e27 VZ |
42 | #if wxUSE_FONTDLG |
43 | #include "wx/fontdlg.h" | |
44 | #endif // wxUSE_FONTDLG | |
45 | ||
88ac883a VZ |
46 | #if wxUSE_PRINTING_ARCHITECTURE |
47 | #include "wx/paper.h" | |
88ac883a | 48 | #endif // wxUSE_PRINTING_ARCHITECTURE |
7be1f0d9 | 49 | |
8826f46f | 50 | #ifdef __WXMSW__ |
1c193821 | 51 | #include <windowsx.h> |
3096bd2f | 52 | #include "wx/msw/private.h" |
7be1f0d9 | 53 | |
f2aa588b | 54 | #ifndef __SMARTPHONE__ |
8826f46f | 55 | #include <commdlg.h> |
1c193821 | 56 | #endif |
8826f46f | 57 | |
2bdf7154 | 58 | #if defined(__WATCOMC__) || defined(__SYMANTEC__) || defined(__SALFORDC__) |
8826f46f VZ |
59 | #include <windowsx.h> |
60 | #include <commdlg.h> | |
61 | #endif | |
62 | #endif // MSW | |
c801d85f | 63 | |
746d7582 SC |
64 | #ifdef __WXMAC__ |
65 | #include "wx/mac/private/print.h" | |
66 | #endif | |
67 | ||
88ac883a VZ |
68 | #if wxUSE_PRINTING_ARCHITECTURE |
69 | IMPLEMENT_DYNAMIC_CLASS(wxPrintData, wxObject) | |
70 | IMPLEMENT_DYNAMIC_CLASS(wxPrintDialogData, wxObject) | |
71 | IMPLEMENT_DYNAMIC_CLASS(wxPageSetupDialogData, wxObject) | |
72 | #endif // wxUSE_PRINTING_ARCHITECTURE | |
cd0b1709 | 73 | |
8826f46f VZ |
74 | IMPLEMENT_DYNAMIC_CLASS(wxFontData, wxObject) |
75 | IMPLEMENT_DYNAMIC_CLASS(wxColourData, wxObject) | |
c801d85f | 76 | |
83e72d5f GT |
77 | #ifndef DMPAPER_USER |
78 | #define DMPAPER_USER 256 | |
79 | #endif | |
80 | ||
8826f46f VZ |
81 | // ============================================================================ |
82 | // implementation | |
83 | // ============================================================================ | |
84 | ||
85 | // ---------------------------------------------------------------------------- | |
86 | // wxColourData | |
87 | // ---------------------------------------------------------------------------- | |
c801d85f | 88 | |
8bbe427f | 89 | wxColourData::wxColourData() |
c801d85f | 90 | { |
7bcb11d3 JS |
91 | int i; |
92 | for (i = 0; i < 16; i++) | |
ae500232 | 93 | m_custColours[i].Set(255, 255, 255); |
8826f46f | 94 | |
ae500232 JS |
95 | m_chooseFull = FALSE; |
96 | m_dataColour.Set(0,0,0); | |
7bcb11d3 | 97 | } |
c801d85f | 98 | |
7bcb11d3 | 99 | wxColourData::wxColourData(const wxColourData& data) |
5e472c1f | 100 | : wxObject() |
7bcb11d3 JS |
101 | { |
102 | (*this) = data; | |
8bbe427f | 103 | } |
c801d85f | 104 | |
8bbe427f | 105 | wxColourData::~wxColourData() |
c801d85f KB |
106 | { |
107 | } | |
108 | ||
cebf2fec | 109 | void wxColourData::SetCustomColour(int i, const wxColour& colour) |
c801d85f | 110 | { |
7bcb11d3 JS |
111 | if (i > 15 || i < 0) |
112 | return; | |
8826f46f | 113 | |
ae500232 | 114 | m_custColours[i] = colour; |
c801d85f KB |
115 | } |
116 | ||
117 | wxColour wxColourData::GetCustomColour(int i) | |
118 | { | |
7bcb11d3 JS |
119 | if (i > 15 || i < 0) |
120 | return wxColour(0,0,0); | |
8826f46f | 121 | |
ae500232 | 122 | return m_custColours[i]; |
c801d85f KB |
123 | } |
124 | ||
125 | void wxColourData::operator=(const wxColourData& data) | |
126 | { | |
7bcb11d3 JS |
127 | int i; |
128 | for (i = 0; i < 16; i++) | |
ae500232 | 129 | m_custColours[i] = data.m_custColours[i]; |
8826f46f | 130 | |
ae500232 JS |
131 | m_dataColour = (wxColour&)data.m_dataColour; |
132 | m_chooseFull = data.m_chooseFull; | |
c801d85f KB |
133 | } |
134 | ||
8826f46f VZ |
135 | // ---------------------------------------------------------------------------- |
136 | // Font data | |
137 | // ---------------------------------------------------------------------------- | |
c801d85f | 138 | |
8bbe427f | 139 | wxFontData::wxFontData() |
c801d85f | 140 | { |
7bcb11d3 | 141 | // Intialize colour to black. |
ae500232 | 142 | m_fontColour = wxNullColour; |
8826f46f | 143 | |
ae500232 JS |
144 | m_showHelp = FALSE; |
145 | m_allowSymbols = TRUE; | |
146 | m_enableEffects = TRUE; | |
147 | m_minSize = 0; | |
148 | m_maxSize = 0; | |
c801d85f | 149 | |
7beba2fc | 150 | m_encoding = wxFONTENCODING_SYSTEM; |
c801d85f KB |
151 | } |
152 | ||
8bbe427f | 153 | wxFontData::~wxFontData() |
c801d85f KB |
154 | { |
155 | } | |
156 | ||
dbc65e27 VZ |
157 | #if wxUSE_FONTDLG |
158 | ||
159 | wxFontDialogBase::~wxFontDialogBase() | |
160 | { | |
161 | } | |
162 | ||
163 | #endif // wxUSE_FONTDLG | |
164 | ||
88ac883a | 165 | #if wxUSE_PRINTING_ARCHITECTURE |
8826f46f VZ |
166 | // ---------------------------------------------------------------------------- |
167 | // Print data | |
168 | // ---------------------------------------------------------------------------- | |
c801d85f | 169 | |
8bbe427f | 170 | wxPrintData::wxPrintData() |
c801d85f | 171 | { |
2049ba38 | 172 | #ifdef __WXMSW__ |
eaeb6a3c JS |
173 | m_devMode = (void*) NULL; |
174 | m_devNames = (void*) NULL; | |
51abe921 | 175 | #elif defined( __WXMAC__ ) |
746d7582 | 176 | m_nativePrintData = wxNativePrintData::Create() ; |
c801d85f | 177 | #endif |
7bcb11d3 JS |
178 | m_printOrientation = wxPORTRAIT; |
179 | m_printNoCopies = 1; | |
180 | m_printCollate = FALSE; | |
8826f46f | 181 | |
7bcb11d3 | 182 | // New, 24/3/99 |
2b5f62a0 | 183 | m_printerName = wxT(""); |
7bcb11d3 JS |
184 | m_colour = TRUE; |
185 | m_duplexMode = wxDUPLEX_SIMPLEX; | |
186 | m_printQuality = wxPRINT_QUALITY_HIGH; | |
187 | m_paperId = wxPAPER_A4; | |
188 | m_paperSize = wxSize(210, 297); | |
189 | ||
190 | // PostScript-specific data | |
eba33006 RR |
191 | m_previewCommand = wxT(""); |
192 | m_filename = wxT(""); | |
193 | #ifdef __VMS__ | |
194 | m_printerCommand = wxT("print"); | |
195 | m_printerOptions = wxT("/nonotify/queue=psqueue"); | |
196 | m_afmPath = wxT("sys$ps_font_metrics:"); | |
197 | #endif | |
198 | ||
199 | #ifdef __WXMSW__ | |
200 | m_printerCommand = wxT("print"); | |
201 | m_printerOptions = wxT(""); | |
202 | m_afmPath = wxT("c:\\windows\\system\\"); | |
203 | #endif | |
204 | ||
205 | #if !defined(__VMS__) && !defined(__WXMSW__) | |
206 | m_printerCommand = wxT("lpr"); | |
207 | m_printerOptions = wxT(""); | |
208 | m_afmPath = wxT(""); | |
209 | #endif | |
210 | ||
7bcb11d3 JS |
211 | m_printerScaleX = 1.0; |
212 | m_printerScaleY = 1.0; | |
213 | m_printerTranslateX = 0; | |
214 | m_printerTranslateY = 0; | |
215 | m_printMode = wxPRINT_MODE_FILE; | |
244e5e34 VZ |
216 | |
217 | #ifdef wxUSE_STREAMS | |
218 | m_outputstream = NULL; | |
219 | #endif | |
7bcb11d3 JS |
220 | } |
221 | ||
222 | wxPrintData::wxPrintData(const wxPrintData& printData) | |
5e472c1f | 223 | : wxObject() |
7bcb11d3 | 224 | { |
58abfef6 | 225 | #ifdef __WXMSW__ |
eaeb6a3c JS |
226 | m_devMode = (void*) NULL; |
227 | m_devNames = (void*) NULL; | |
7c74e7fe | 228 | #elif defined( __WXMAC__ ) |
746d7582 | 229 | m_nativePrintData = wxNativePrintData::Create() ; |
58abfef6 | 230 | #endif |
7bcb11d3 | 231 | (*this) = printData; |
c801d85f KB |
232 | } |
233 | ||
8bbe427f | 234 | wxPrintData::~wxPrintData() |
c801d85f | 235 | { |
2049ba38 | 236 | #ifdef __WXMSW__ |
48c12cb1 | 237 | HGLOBAL hDevMode = (HGLOBAL)(DWORD) m_devMode; |
eaeb6a3c | 238 | if ( hDevMode ) |
7bcb11d3 | 239 | GlobalFree(hDevMode); |
eaeb6a3c JS |
240 | HGLOBAL hDevNames = (HGLOBAL)(DWORD) m_devNames; |
241 | if ( hDevNames ) | |
242 | GlobalFree(hDevNames); | |
51abe921 | 243 | #elif defined(__WXMAC__) |
746d7582 | 244 | delete m_nativePrintData ; |
c801d85f KB |
245 | #endif |
246 | } | |
247 | ||
25889d3c | 248 | #if defined(__WXMSW__) // && defined(__WIN32__) |
7bcb11d3 | 249 | |
e47c4d48 | 250 | #if defined(__WXDEBUG__) && defined(__WIN32__) |
6aa55ce7 JS |
251 | static wxString wxGetPrintDlgError() |
252 | { | |
253 | DWORD err = CommDlgExtendedError(); | |
223d09f6 | 254 | wxString msg = wxT("Unknown"); |
6aa55ce7 JS |
255 | switch (err) |
256 | { | |
223d09f6 KB |
257 | case CDERR_FINDRESFAILURE: msg = wxT("CDERR_FINDRESFAILURE"); break; |
258 | case CDERR_INITIALIZATION: msg = wxT("CDERR_INITIALIZATION"); break; | |
259 | case CDERR_LOADRESFAILURE: msg = wxT("CDERR_LOADRESFAILURE"); break; | |
260 | case CDERR_LOADSTRFAILURE: msg = wxT("CDERR_LOADSTRFAILURE"); break; | |
261 | case CDERR_LOCKRESFAILURE: msg = wxT("CDERR_LOCKRESFAILURE"); break; | |
262 | case CDERR_MEMALLOCFAILURE: msg = wxT("CDERR_MEMALLOCFAILURE"); break; | |
263 | case CDERR_MEMLOCKFAILURE: msg = wxT("CDERR_MEMLOCKFAILURE"); break; | |
264 | case CDERR_NOHINSTANCE: msg = wxT("CDERR_NOHINSTANCE"); break; | |
265 | case CDERR_NOHOOK: msg = wxT("CDERR_NOHOOK"); break; | |
266 | case CDERR_NOTEMPLATE: msg = wxT("CDERR_NOTEMPLATE"); break; | |
267 | case CDERR_STRUCTSIZE: msg = wxT("CDERR_STRUCTSIZE"); break; | |
268 | case PDERR_RETDEFFAILURE: msg = wxT("PDERR_RETDEFFAILURE"); break; | |
269 | case PDERR_PRINTERNOTFOUND: msg = wxT("PDERR_PRINTERNOTFOUND"); break; | |
270 | case PDERR_PARSEFAILURE: msg = wxT("PDERR_PARSEFAILURE"); break; | |
271 | case PDERR_NODEVICES: msg = wxT("PDERR_NODEVICES"); break; | |
272 | case PDERR_NODEFAULTPRN: msg = wxT("PDERR_NODEFAULTPRN"); break; | |
273 | case PDERR_LOADDRVFAILURE: msg = wxT("PDERR_LOADDRVFAILURE"); break; | |
274 | case PDERR_INITFAILURE: msg = wxT("PDERR_INITFAILURE"); break; | |
275 | case PDERR_GETDEVMODEFAIL: msg = wxT("PDERR_GETDEVMODEFAIL"); break; | |
276 | case PDERR_DNDMMISMATCH: msg = wxT("PDERR_DNDMMISMATCH"); break; | |
277 | case PDERR_DEFAULTDIFFERENT: msg = wxT("PDERR_DEFAULTDIFFERENT"); break; | |
278 | case PDERR_CREATEICFAILURE: msg = wxT("PDERR_CREATEICFAILURE"); break; | |
6aa55ce7 JS |
279 | default: break; |
280 | } | |
281 | return msg; | |
282 | } | |
25889d3c | 283 | #endif |
6aa55ce7 | 284 | |
eaeb6a3c JS |
285 | static HGLOBAL wxCreateDevNames(const wxString& driverName, const wxString& printerName, const wxString& portName) |
286 | { | |
161f4f73 VZ |
287 | HGLOBAL hDev = NULL; |
288 | // if (!driverName.IsEmpty() && !printerName.IsEmpty() && !portName.IsEmpty()) | |
eaeb6a3c JS |
289 | if (driverName.IsEmpty() && printerName.IsEmpty() && portName.IsEmpty()) |
290 | { | |
291 | } | |
292 | else | |
161f4f73 VZ |
293 | { |
294 | hDev = GlobalAlloc(GPTR, 4*sizeof(WORD)+ | |
295 | ( driverName.Length() + 1 + | |
296 | printerName.Length() + 1 + | |
297 | portName.Length()+1 ) * sizeof(wxChar) ); | |
298 | LPDEVNAMES lpDev = (LPDEVNAMES)GlobalLock(hDev); | |
299 | lpDev->wDriverOffset = sizeof(WORD)*4; | |
300 | wxStrcpy((wxChar*)((char*)lpDev + lpDev->wDriverOffset ), driverName); | |
eaeb6a3c | 301 | |
161f4f73 VZ |
302 | lpDev->wDeviceOffset = (WORD)( lpDev->wDriverOffset + |
303 | sizeof(wxChar) * ( driverName.Length() + 1 ) ); | |
304 | wxStrcpy((wxChar*)((char*)lpDev + lpDev->wDeviceOffset ), printerName); | |
eaeb6a3c | 305 | |
161f4f73 VZ |
306 | lpDev->wOutputOffset = (WORD)( lpDev->wDeviceOffset + |
307 | sizeof(wxChar) * ( printerName.Length() + 1 ) ); | |
308 | wxStrcpy((wxChar*)((char*) lpDev + lpDev->wOutputOffset ), portName); | |
eaeb6a3c | 309 | |
161f4f73 | 310 | lpDev->wDefault = 0; |
eaeb6a3c JS |
311 | |
312 | GlobalUnlock(hDev); | |
161f4f73 VZ |
313 | } |
314 | ||
315 | return hDev; | |
eaeb6a3c JS |
316 | } |
317 | ||
8bbe427f | 318 | void wxPrintData::ConvertToNative() |
c801d85f | 319 | { |
48c12cb1 | 320 | HGLOBAL hDevMode = (HGLOBAL)(DWORD) m_devMode; |
eaeb6a3c | 321 | HGLOBAL hDevNames = (HGLOBAL)(DWORD) m_devNames; |
7bcb11d3 | 322 | if (!hDevMode) |
c801d85f | 323 | { |
7bcb11d3 | 324 | // Use PRINTDLG as a way of creating a DEVMODE object |
161f4f73 | 325 | PRINTDLG pd; |
8826f46f | 326 | |
c801d85f | 327 | // GNU-WIN32 has the wrong size PRINTDLG - can't work out why. |
7bcb11d3 | 328 | #ifdef __GNUWIN32__ |
161f4f73 VZ |
329 | memset(&pd, 0, 66); |
330 | pd.lStructSize = 66; | |
7bcb11d3 | 331 | #else |
161f4f73 | 332 | memset(&pd, 0, sizeof(PRINTDLG)); |
1c193821 JS |
333 | #ifdef __WXWINCE__ |
334 | pd.cbStruct = sizeof(PRINTDLG); | |
335 | #else | |
161f4f73 | 336 | pd.lStructSize = sizeof(PRINTDLG); |
1c193821 | 337 | #endif |
7bcb11d3 JS |
338 | #endif |
339 | ||
161f4f73 VZ |
340 | pd.hwndOwner = (HWND)NULL; |
341 | pd.hDevMode = NULL; // Will be created by PrintDlg | |
342 | pd.hDevNames = NULL; // Ditto | |
343 | //pd.hInstance = (HINSTANCE) wxGetInstance(); | |
8826f46f | 344 | |
161f4f73 VZ |
345 | pd.Flags = PD_RETURNDEFAULT; |
346 | pd.nCopies = 1; | |
8826f46f | 347 | |
c801d85f KB |
348 | // Fill out the DEVMODE structure |
349 | // so we can use it as input in the 'real' PrintDlg | |
161f4f73 | 350 | if (!PrintDlg(&pd)) |
c801d85f | 351 | { |
161f4f73 VZ |
352 | if ( pd.hDevMode ) |
353 | GlobalFree(pd.hDevMode); | |
354 | if ( pd.hDevNames ) | |
355 | GlobalFree(pd.hDevNames); | |
356 | pd.hDevMode = NULL; | |
357 | pd.hDevNames = NULL; | |
58a33cb4 JS |
358 | |
359 | #if defined(__WXDEBUG__) && defined(__WIN32__) | |
223d09f6 | 360 | wxString str(wxT("Printing error: ")); |
6aa55ce7 JS |
361 | str += wxGetPrintDlgError(); |
362 | wxLogDebug(str); | |
363 | #endif | |
c801d85f KB |
364 | } |
365 | else | |
366 | { | |
161f4f73 | 367 | hDevMode = pd.hDevMode; |
eaeb6a3c | 368 | m_devMode = (void*)(long) hDevMode; |
161f4f73 | 369 | pd.hDevMode = NULL; |
eaeb6a3c JS |
370 | |
371 | // We'll create a new DEVNAMEs structure below. | |
161f4f73 VZ |
372 | if ( pd.hDevNames ) |
373 | GlobalFree(pd.hDevNames); | |
374 | pd.hDevNames = NULL; | |
7bcb11d3 | 375 | |
eaeb6a3c JS |
376 | // hDevNames = pd->hDevNames; |
377 | // m_devNames = (void*)(long) hDevNames; | |
378 | // pd->hDevnames = NULL; | |
379 | ||
c801d85f | 380 | } |
7bcb11d3 | 381 | } |
8826f46f | 382 | |
7bcb11d3 | 383 | if ( hDevMode ) |
c801d85f | 384 | { |
8f177c8e | 385 | LPDEVMODE devMode = (LPDEVMODE) GlobalLock(hDevMode); |
8826f46f | 386 | |
7bcb11d3 | 387 | //// Orientation |
8826f46f | 388 | |
7bcb11d3 | 389 | devMode->dmOrientation = m_printOrientation; |
8826f46f | 390 | |
7bcb11d3 | 391 | //// Collation |
8826f46f | 392 | |
7bcb11d3 JS |
393 | devMode->dmCollate = (m_printCollate ? DMCOLLATE_TRUE : DMCOLLATE_FALSE); |
394 | devMode->dmFields |= DM_COLLATE; | |
8826f46f | 395 | |
7bcb11d3 | 396 | //// Number of copies |
8826f46f | 397 | |
7bcb11d3 JS |
398 | devMode->dmCopies = m_printNoCopies; |
399 | devMode->dmFields |= DM_COPIES; | |
8826f46f | 400 | |
7bcb11d3 | 401 | //// Printer name |
8826f46f | 402 | |
223d09f6 | 403 | if (m_printerName != wxT("")) |
7bcb11d3 | 404 | { |
161f4f73 VZ |
405 | //int len = wxMin(31, m_printerName.Len()); |
406 | wxStrncpy((wxChar*)devMode->dmDeviceName,m_printerName.c_str(),31); | |
407 | devMode->dmDeviceName[31] = wxT('\0'); | |
7bcb11d3 | 408 | } |
8826f46f | 409 | |
7bcb11d3 | 410 | //// Colour |
8826f46f | 411 | |
7bcb11d3 JS |
412 | if (m_colour) |
413 | devMode->dmColor = DMCOLOR_COLOR; | |
414 | else | |
415 | devMode->dmColor = DMCOLOR_MONOCHROME; | |
8826f46f | 416 | |
7bcb11d3 | 417 | devMode->dmFields |= DM_COLOR; |
8826f46f | 418 | |
7bcb11d3 | 419 | //// Paper size |
8826f46f | 420 | |
7bcb11d3 JS |
421 | if (m_paperId == wxPAPER_NONE) |
422 | { | |
161f4f73 | 423 | // DEVMODE is in tenths of a milimeter |
7bcb11d3 JS |
424 | devMode->dmPaperWidth = m_paperSize.x * 10; |
425 | devMode->dmPaperLength = m_paperSize.y * 10; | |
f9862abd | 426 | devMode->dmPaperSize = DMPAPER_USER; |
7bcb11d3 JS |
427 | devMode->dmFields |= DM_PAPERWIDTH; |
428 | devMode->dmFields |= DM_PAPERLENGTH; | |
429 | } | |
430 | else | |
431 | { | |
432 | if (wxThePrintPaperDatabase) | |
433 | { | |
434 | wxPrintPaperType* paper = wxThePrintPaperDatabase->FindPaperType(m_paperId); | |
435 | if (paper) | |
436 | { | |
437 | devMode->dmPaperSize = paper->GetPlatformId(); | |
438 | devMode->dmFields |= DM_PAPERSIZE; | |
439 | } | |
440 | } | |
441 | } | |
8826f46f | 442 | |
7bcb11d3 | 443 | //// Duplex |
8826f46f | 444 | |
7bcb11d3 JS |
445 | int duplex; |
446 | switch (m_duplexMode) | |
447 | { | |
448 | case wxDUPLEX_HORIZONTAL: { | |
449 | duplex = DMDUP_HORIZONTAL; break; | |
450 | } | |
451 | case wxDUPLEX_VERTICAL: { | |
452 | duplex = DMDUP_VERTICAL; break; | |
453 | } | |
454 | default: | |
455 | case wxDUPLEX_SIMPLEX: { | |
456 | duplex = DMDUP_SIMPLEX; break; | |
457 | } | |
458 | } | |
459 | devMode->dmDuplex = duplex; | |
460 | devMode->dmFields |= DM_DUPLEX; | |
8826f46f | 461 | |
7bcb11d3 | 462 | //// Quality |
8826f46f | 463 | |
7bcb11d3 JS |
464 | int quality; |
465 | switch (m_printQuality) | |
466 | { | |
467 | case wxPRINT_QUALITY_MEDIUM: { | |
468 | quality = DMRES_MEDIUM; break; | |
469 | } | |
470 | case wxPRINT_QUALITY_LOW: { | |
471 | quality = DMRES_LOW; break; | |
472 | } | |
473 | case wxPRINT_QUALITY_DRAFT: { | |
474 | quality = DMRES_DRAFT; break; | |
475 | } | |
476 | case wxPRINT_QUALITY_HIGH: { | |
477 | quality = DMRES_HIGH; break; | |
478 | } | |
479 | default: { | |
480 | quality = m_printQuality; break; | |
481 | } | |
482 | } | |
483 | devMode->dmPrintQuality = quality; | |
484 | devMode->dmFields |= DM_PRINTQUALITY; | |
8826f46f | 485 | |
7bcb11d3 | 486 | GlobalUnlock(hDevMode); |
c801d85f | 487 | } |
eaeb6a3c JS |
488 | |
489 | if ( hDevNames ) | |
490 | { | |
491 | GlobalFree(hDevNames); | |
492 | } | |
493 | ||
494 | // TODO: I hope it's OK to pass some empty strings to DEVNAMES. | |
161f4f73 | 495 | m_devNames = (void*) (long) wxCreateDevNames(wxT(""), m_printerName, wxT("")); |
7bcb11d3 JS |
496 | } |
497 | ||
498 | void wxPrintData::ConvertFromNative() | |
499 | { | |
48c12cb1 | 500 | HGLOBAL hDevMode = (HGLOBAL)(DWORD) m_devMode; |
eaeb6a3c | 501 | HGLOBAL hDevNames = (HGLOBAL)(DWORD) m_devNames; |
7bcb11d3 JS |
502 | |
503 | if (!hDevMode) | |
504 | return; | |
505 | ||
506 | if ( hDevMode ) | |
507 | { | |
8f177c8e | 508 | LPDEVMODE devMode = (LPDEVMODE)GlobalLock(hDevMode); |
8826f46f | 509 | |
7bcb11d3 | 510 | //// Orientation |
8826f46f | 511 | |
7bcb11d3 JS |
512 | if (devMode->dmFields & DM_ORIENTATION) |
513 | m_printOrientation = devMode->dmOrientation; | |
8826f46f | 514 | |
7bcb11d3 | 515 | //// Collation |
8826f46f | 516 | |
7bcb11d3 JS |
517 | if (devMode->dmFields & DM_COLLATE) |
518 | { | |
519 | if (devMode->dmCollate == DMCOLLATE_TRUE) | |
520 | m_printCollate = TRUE; | |
521 | else | |
522 | m_printCollate = FALSE; | |
523 | } | |
8826f46f | 524 | |
7bcb11d3 | 525 | //// Number of copies |
8826f46f | 526 | |
7bcb11d3 JS |
527 | if (devMode->dmFields & DM_COPIES) |
528 | { | |
529 | m_printNoCopies = devMode->dmCopies; | |
530 | } | |
8826f46f | 531 | |
7bcb11d3 | 532 | //// Printer name |
8826f46f | 533 | |
7bcb11d3 JS |
534 | if (devMode->dmDeviceName[0] != 0) |
535 | { | |
2b5f62a0 | 536 | m_printerName = devMode->dmDeviceName; |
7bcb11d3 | 537 | } |
8826f46f | 538 | |
7bcb11d3 | 539 | //// Colour |
8826f46f | 540 | |
7bcb11d3 JS |
541 | if (devMode->dmFields & DM_COLOR) |
542 | { | |
543 | if (devMode->dmColor == DMCOLOR_COLOR) | |
544 | m_colour = TRUE; | |
545 | else | |
546 | m_colour = FALSE; | |
547 | } | |
548 | else | |
549 | m_colour = TRUE; | |
8826f46f | 550 | |
7bcb11d3 | 551 | //// Paper size |
8826f46f | 552 | |
8084a109 VS |
553 | // We don't know size of user defined paper and some buggy drivers |
554 | // set both DM_PAPERSIZE and DM_PAPERWIDTH & DM_PAPERLENGTH. Since | |
555 | // dmPaperSize >= DMPAPER_USER wouldn't be in wxWin's database, this | |
556 | // code wouldn't set m_paperSize correctly. | |
557 | if ((devMode->dmFields & DM_PAPERSIZE) && (devMode->dmPaperSize < DMPAPER_USER)) | |
7bcb11d3 JS |
558 | { |
559 | if (wxThePrintPaperDatabase) | |
560 | { | |
561 | wxPrintPaperType* paper = wxThePrintPaperDatabase->FindPaperTypeByPlatformId(devMode->dmPaperSize); | |
562 | if (paper) | |
563 | { | |
564 | m_paperId = paper->GetId(); | |
161f4f73 VZ |
565 | m_paperSize.x = paper->GetWidth() / 10; |
566 | m_paperSize.y = paper->GetHeight() / 10; | |
7bcb11d3 JS |
567 | } |
568 | else | |
569 | { | |
570 | // Shouldn't really get here | |
223d09f6 | 571 | wxFAIL_MSG(wxT("Couldn't find paper size in paper database.")); |
8826f46f | 572 | |
7bcb11d3 JS |
573 | m_paperId = wxPAPER_NONE; |
574 | m_paperSize.x = 0; | |
575 | m_paperSize.y = 0; | |
576 | } | |
577 | } | |
578 | else | |
579 | { | |
580 | // Shouldn't really get here | |
223d09f6 | 581 | wxFAIL_MSG(wxT("Paper database wasn't initialized in wxPrintData::ConvertFromNative.")); |
8826f46f | 582 | |
7bcb11d3 JS |
583 | m_paperId = wxPAPER_NONE; |
584 | m_paperSize.x = 0; | |
585 | m_paperSize.y = 0; | |
586 | } | |
587 | } | |
588 | else if ((devMode->dmFields & DM_PAPERWIDTH) && (devMode->dmFields & DM_PAPERLENGTH)) | |
589 | { | |
161f4f73 | 590 | // DEVMODE is in tenths of a milimeter |
7bcb11d3 JS |
591 | m_paperSize.x = devMode->dmPaperWidth / 10; |
592 | m_paperSize.y = devMode->dmPaperLength / 10; | |
593 | m_paperId = wxPAPER_NONE; | |
594 | } | |
595 | else | |
596 | { | |
597 | // Shouldn't really get here | |
223d09f6 | 598 | wxFAIL_MSG(wxT("Couldn't find paper size from DEVMODE.")); |
8826f46f | 599 | |
7bcb11d3 JS |
600 | m_paperSize.x = 0; |
601 | m_paperSize.y = 0; | |
602 | m_paperId = wxPAPER_NONE; | |
603 | } | |
8826f46f | 604 | |
7bcb11d3 | 605 | //// Duplex |
8826f46f | 606 | |
7bcb11d3 JS |
607 | if (devMode->dmFields & DM_DUPLEX) |
608 | { | |
609 | switch (devMode->dmDuplex) | |
610 | { | |
611 | case DMDUP_HORIZONTAL: { | |
612 | m_duplexMode = wxDUPLEX_HORIZONTAL; break; | |
613 | } | |
614 | case DMDUP_VERTICAL: { | |
615 | m_duplexMode = wxDUPLEX_VERTICAL; break; | |
616 | } | |
617 | default: | |
618 | case DMDUP_SIMPLEX: { | |
619 | m_duplexMode = wxDUPLEX_SIMPLEX; break; | |
620 | } | |
621 | } | |
622 | } | |
623 | else | |
624 | m_duplexMode = wxDUPLEX_SIMPLEX; | |
8826f46f | 625 | |
7bcb11d3 | 626 | //// Quality |
8826f46f | 627 | |
7bcb11d3 JS |
628 | if (devMode->dmFields & DM_PRINTQUALITY) |
629 | { | |
630 | switch (devMode->dmPrintQuality) | |
631 | { | |
632 | case DMRES_MEDIUM: { | |
633 | m_printQuality = wxPRINT_QUALITY_MEDIUM; break; | |
634 | } | |
635 | case DMRES_LOW: { | |
636 | m_printQuality = wxPRINT_QUALITY_LOW; break; | |
637 | } | |
638 | case DMRES_DRAFT: { | |
639 | m_printQuality = wxPRINT_QUALITY_DRAFT; break; | |
640 | } | |
641 | case DMRES_HIGH: { | |
642 | m_printQuality = wxPRINT_QUALITY_HIGH; break; | |
643 | } | |
644 | default: | |
645 | { | |
646 | // TODO: if the printer fills in the resolution in DPI, how | |
647 | // will the application know if it's high, low, draft etc.?? | |
648 | // wxFAIL_MSG("Warning: DM_PRINTQUALITY was not one of the standard values."); | |
649 | m_printQuality = devMode->dmPrintQuality; break; | |
8826f46f | 650 | |
7bcb11d3 JS |
651 | } |
652 | } | |
653 | } | |
654 | else | |
655 | m_printQuality = wxPRINT_QUALITY_HIGH; | |
8826f46f | 656 | |
7bcb11d3 JS |
657 | GlobalUnlock(hDevMode); |
658 | } | |
eaeb6a3c JS |
659 | |
660 | if (hDevNames) | |
661 | { | |
662 | LPDEVNAMES lpDevNames = (LPDEVNAMES)GlobalLock(hDevNames); | |
663 | if (lpDevNames) | |
664 | { | |
665 | // TODO: Unicode-ification | |
666 | ||
667 | // Get the port name | |
668 | // port is obsolete in WIN32 | |
669 | // m_printData.SetPortName((LPSTR)lpDevNames + lpDevNames->wDriverOffset); | |
670 | ||
671 | // Get the printer name | |
161f4f73 | 672 | wxString printerName = (LPTSTR)lpDevNames + lpDevNames->wDeviceOffset; |
eaeb6a3c JS |
673 | |
674 | // Not sure if we should check for this mismatch | |
675 | // wxASSERT_MSG( (m_printerName == "" || (devName == m_printerName)), "Printer name obtained from DEVMODE and DEVNAMES were different!"); | |
676 | ||
f6bcfd97 | 677 | if (printerName != wxT("")) |
eaeb6a3c JS |
678 | m_printerName = printerName; |
679 | ||
680 | GlobalUnlock(hDevNames); | |
681 | } | |
682 | } | |
7bcb11d3 | 683 | } |
c801d85f | 684 | |
7bcb11d3 JS |
685 | #endif |
686 | ||
51abe921 | 687 | #ifdef __WXMAC__ |
cfb00da4 | 688 | |
51abe921 SC |
689 | void wxPrintData::ConvertToNative() |
690 | { | |
746d7582 | 691 | m_nativePrintData->TransferFrom( this ) ; |
51abe921 SC |
692 | } |
693 | ||
694 | void wxPrintData::ConvertFromNative() | |
695 | { | |
746d7582 | 696 | m_nativePrintData->TransferTo( this ) ; |
51abe921 | 697 | } |
cfb00da4 | 698 | |
51abe921 SC |
699 | #endif |
700 | ||
7bcb11d3 JS |
701 | void wxPrintData::operator=(const wxPrintData& data) |
702 | { | |
7d610b90 | 703 | #ifdef __WXMAC__ |
746d7582 | 704 | m_nativePrintData->CopyFrom( data.m_nativePrintData ) ; |
7d610b90 | 705 | #endif |
7bcb11d3 JS |
706 | m_printNoCopies = data.m_printNoCopies; |
707 | m_printCollate = data.m_printCollate; | |
708 | m_printOrientation = data.m_printOrientation; | |
709 | m_printerName = data.m_printerName; | |
710 | m_colour = data.m_colour; | |
711 | m_duplexMode = data.m_duplexMode; | |
712 | m_printQuality = data.m_printQuality; | |
713 | m_paperId = data.m_paperId; | |
714 | m_paperSize = data.m_paperSize; | |
244e5e34 VZ |
715 | #ifdef wxUSE_STREAMS |
716 | m_outputstream = data.m_outputstream; | |
717 | #endif | |
7bcb11d3 JS |
718 | |
719 | // PostScript-specific data | |
720 | m_printerCommand = data.m_printerCommand; | |
721 | m_previewCommand = data.m_previewCommand; | |
722 | m_printerOptions = data.m_printerOptions; | |
723 | m_filename = data.m_filename; | |
724 | m_afmPath = data.m_afmPath; | |
725 | m_printerScaleX = data.m_printerScaleX; | |
726 | m_printerScaleY = data.m_printerScaleY; | |
727 | m_printerTranslateX = data.m_printerTranslateX; | |
728 | m_printerTranslateY = data.m_printerTranslateY; | |
729 | m_printMode = data.m_printMode; | |
730 | } | |
731 | ||
58cf0491 JS |
732 | // Is this data OK for showing the print dialog? |
733 | bool wxPrintData::Ok() const | |
734 | { | |
735 | #ifdef __WXMSW__ | |
736 | ((wxPrintData*)this)->ConvertToNative(); | |
737 | return (m_devMode != NULL) ; | |
738 | #else | |
739 | return TRUE; | |
dbc65e27 | 740 | #endif |
58cf0491 | 741 | } |
8826f46f VZ |
742 | |
743 | // ---------------------------------------------------------------------------- | |
744 | // Print dialog data | |
745 | // ---------------------------------------------------------------------------- | |
7bcb11d3 JS |
746 | |
747 | wxPrintDialogData::wxPrintDialogData() | |
748 | { | |
749 | #ifdef __WXMSW__ | |
750 | m_printDlgData = NULL; | |
751 | #endif | |
752 | m_printFromPage = 0; | |
753 | m_printToPage = 0; | |
754 | m_printMinPage = 0; | |
755 | m_printMaxPage = 0; | |
756 | m_printNoCopies = 1; | |
757 | m_printAllPages = FALSE; | |
758 | m_printCollate = FALSE; | |
759 | m_printToFile = FALSE; | |
5360828d | 760 | m_printSelection = FALSE; |
7bcb11d3 JS |
761 | m_printEnableSelection = FALSE; |
762 | m_printEnablePageNumbers = TRUE; | |
763 | m_printEnablePrintToFile = TRUE; | |
764 | m_printEnableHelp = FALSE; | |
765 | m_printSetupDialog = FALSE; | |
766 | } | |
767 | ||
768 | wxPrintDialogData::wxPrintDialogData(const wxPrintDialogData& dialogData) | |
5e472c1f | 769 | : wxObject() |
7bcb11d3 | 770 | { |
7c74e7fe SC |
771 | #ifdef __WXMSW__ |
772 | m_printDlgData = NULL; | |
7c74e7fe | 773 | #endif |
7bcb11d3 JS |
774 | (*this) = dialogData; |
775 | } | |
776 | ||
777 | wxPrintDialogData::wxPrintDialogData(const wxPrintData& printData) | |
778 | { | |
779 | #ifdef __WXMSW__ | |
780 | m_printDlgData = NULL; | |
781 | #endif | |
d2b354f9 | 782 | m_printFromPage = 1; |
7bcb11d3 | 783 | m_printToPage = 0; |
d2b354f9 JS |
784 | m_printMinPage = 1; |
785 | m_printMaxPage = 9999; | |
7bcb11d3 JS |
786 | m_printNoCopies = 1; |
787 | m_printAllPages = FALSE; | |
788 | m_printCollate = FALSE; | |
789 | m_printToFile = FALSE; | |
5360828d | 790 | m_printSelection = FALSE; |
7bcb11d3 JS |
791 | m_printEnableSelection = FALSE; |
792 | m_printEnablePageNumbers = TRUE; | |
793 | m_printEnablePrintToFile = TRUE; | |
794 | m_printEnableHelp = FALSE; | |
795 | m_printSetupDialog = FALSE; | |
796 | ||
797 | m_printData = printData; | |
798 | } | |
799 | ||
800 | wxPrintDialogData::~wxPrintDialogData() | |
801 | { | |
802 | #ifdef __WXMSW__ | |
803 | PRINTDLG *pd = (PRINTDLG *) m_printDlgData; | |
804 | if ( pd && pd->hDevMode ) | |
805 | GlobalFree(pd->hDevMode); | |
806 | if ( pd ) | |
807 | delete pd; | |
808 | #endif | |
809 | } | |
810 | ||
811 | #ifdef __WXMSW__ | |
812 | void wxPrintDialogData::ConvertToNative() | |
813 | { | |
814 | m_printData.ConvertToNative(); | |
815 | ||
816 | PRINTDLG *pd = (PRINTDLG*) m_printDlgData; | |
817 | ||
818 | if (!pd) | |
819 | { | |
820 | pd = new PRINTDLG; | |
161f4f73 | 821 | memset( pd, 0, sizeof(PRINTDLG) ); |
7bcb11d3 JS |
822 | m_printDlgData = (void*) pd; |
823 | ||
824 | // GNU-WIN32 has the wrong size PRINTDLG - can't work out why. | |
825 | #ifdef __GNUWIN32__ | |
161f4f73 | 826 | pd->lStructSize = 66; |
7bcb11d3 | 827 | #else |
7bcb11d3 | 828 | pd->lStructSize = sizeof(PRINTDLG); |
25889d3c | 829 | #endif |
7bcb11d3 JS |
830 | pd->hwndOwner = (HWND)NULL; |
831 | pd->hDevMode = NULL; // Will be created by PrintDlg | |
832 | pd->hDevNames = NULL; // Ditto | |
833 | ||
834 | pd->Flags = PD_RETURNDEFAULT; | |
835 | pd->nCopies = 1; | |
836 | } | |
837 | ||
838 | // Pass the devmode data to the PRINTDLG structure, since it'll | |
839 | // be needed when PrintDlg is called. | |
840 | if (pd->hDevMode) | |
841 | { | |
842 | GlobalFree(pd->hDevMode); | |
843 | } | |
844 | ||
eaeb6a3c JS |
845 | // Pass the devnames data to the PRINTDLG structure, since it'll |
846 | // be needed when PrintDlg is called. | |
847 | if (pd->hDevNames) | |
848 | { | |
849 | GlobalFree(pd->hDevNames); | |
850 | } | |
851 | ||
48c12cb1 | 852 | pd->hDevMode = (HGLOBAL)(DWORD) m_printData.GetNativeData(); |
7bcb11d3 JS |
853 | |
854 | m_printData.SetNativeData((void*) NULL); | |
855 | ||
58cf0491 JS |
856 | // Shouldn't assert; we should be able to test Ok-ness at a higher level |
857 | //wxASSERT_MSG( (pd->hDevMode), wxT("hDevMode must be non-NULL in ConvertToNative!")); | |
7bcb11d3 | 858 | |
eaeb6a3c JS |
859 | pd->hDevNames = (HGLOBAL)(DWORD) m_printData.GetNativeDataDevNames(); |
860 | ||
861 | m_printData.SetNativeDataDevNames((void*) NULL); | |
862 | ||
7bcb11d3 | 863 | pd->hDC = (HDC) NULL; |
33ac7e6f KB |
864 | pd->nFromPage = (WORD)m_printFromPage; |
865 | pd->nToPage = (WORD)m_printToPage; | |
866 | pd->nMinPage = (WORD)m_printMinPage; | |
867 | pd->nMaxPage = (WORD)m_printMaxPage; | |
868 | pd->nCopies = (WORD)m_printNoCopies; | |
8826f46f | 869 | |
161f4f73 | 870 | pd->Flags = PD_RETURNDC; |
7bcb11d3 JS |
871 | |
872 | #ifdef __GNUWIN32__ | |
161f4f73 | 873 | pd->lStructSize = 66; |
7bcb11d3 JS |
874 | #else |
875 | pd->lStructSize = sizeof( PRINTDLG ); | |
876 | #endif | |
877 | ||
8b9518ee | 878 | pd->hwndOwner=(HWND)NULL; |
eaeb6a3c | 879 | // pd->hDevNames=(HANDLE)NULL; |
c801d85f KB |
880 | pd->hInstance=(HINSTANCE)NULL; |
881 | pd->lCustData = (LPARAM) NULL; | |
882 | pd->lpfnPrintHook = NULL; | |
883 | pd->lpfnSetupHook = NULL; | |
884 | pd->lpPrintTemplateName = NULL; | |
885 | pd->lpSetupTemplateName = NULL; | |
886 | pd->hPrintTemplate = (HGLOBAL) NULL; | |
887 | pd->hSetupTemplate = (HGLOBAL) NULL; | |
8826f46f | 888 | |
7bcb11d3 | 889 | if ( m_printAllPages ) |
c801d85f | 890 | pd->Flags |= PD_ALLPAGES; |
8084a109 | 891 | if ( m_printSelection ) |
5360828d | 892 | pd->Flags |= PD_SELECTION; |
7bcb11d3 | 893 | if ( m_printCollate ) |
c801d85f | 894 | pd->Flags |= PD_COLLATE; |
7bcb11d3 | 895 | if ( m_printToFile ) |
c801d85f | 896 | pd->Flags |= PD_PRINTTOFILE; |
7bcb11d3 | 897 | if ( !m_printEnablePrintToFile ) |
c801d85f | 898 | pd->Flags |= PD_DISABLEPRINTTOFILE; |
7bcb11d3 JS |
899 | if ( !m_printEnableSelection ) |
900 | pd->Flags |= PD_NOSELECTION; | |
901 | if ( !m_printEnablePageNumbers ) | |
902 | pd->Flags |= PD_NOPAGENUMS; | |
d2b354f9 | 903 | else if ( (!m_printAllPages) && (!m_printSelection) && (m_printFromPage != 0) && (m_printToPage != 0)) |
40474984 | 904 | pd->Flags |= PD_PAGENUMS; |
7bcb11d3 JS |
905 | if ( m_printEnableHelp ) |
906 | pd->Flags |= PD_SHOWHELP; | |
907 | if ( m_printSetupDialog ) | |
908 | pd->Flags |= PD_PRINTSETUP; | |
c801d85f KB |
909 | } |
910 | ||
7bcb11d3 | 911 | void wxPrintDialogData::ConvertFromNative() |
c801d85f | 912 | { |
7bcb11d3 | 913 | PRINTDLG *pd = (PRINTDLG*) m_printDlgData; |
c801d85f KB |
914 | if ( pd == NULL ) |
915 | return; | |
916 | ||
7bcb11d3 JS |
917 | // Pass the devmode data back to the wxPrintData structure where it really belongs. |
918 | if (pd->hDevMode) | |
c801d85f | 919 | { |
7bcb11d3 JS |
920 | if (m_printData.GetNativeData()) |
921 | { | |
922 | // Make sure we don't leak memory | |
48c12cb1 | 923 | GlobalFree((HGLOBAL)(DWORD) m_printData.GetNativeData()); |
7bcb11d3 | 924 | } |
aeb50f86 | 925 | m_printData.SetNativeData((void*)(long) pd->hDevMode); |
7bcb11d3 | 926 | pd->hDevMode = NULL; |
c801d85f | 927 | } |
c801d85f | 928 | |
eaeb6a3c JS |
929 | // Pass the devnames data back to the wxPrintData structure where it really belongs. |
930 | if (pd->hDevNames) | |
931 | { | |
932 | if (m_printData.GetNativeDataDevNames()) | |
933 | { | |
934 | // Make sure we don't leak memory | |
935 | GlobalFree((HGLOBAL)(DWORD) m_printData.GetNativeDataDevNames()); | |
936 | } | |
937 | m_printData.SetNativeDataDevNames((void*)(long) pd->hDevNames); | |
938 | pd->hDevNames = NULL; | |
939 | } | |
940 | ||
7bcb11d3 | 941 | // Now convert the DEVMODE object, passed down from the PRINTDLG object, |
77ffb593 | 942 | // into wxWidgets form. |
7bcb11d3 JS |
943 | m_printData.ConvertFromNative(); |
944 | ||
161f4f73 VZ |
945 | m_printFromPage = pd->nFromPage; |
946 | m_printToPage = pd->nToPage; | |
947 | m_printMinPage = pd->nMinPage; | |
948 | m_printMaxPage = pd->nMaxPage; | |
949 | m_printNoCopies = pd->nCopies; | |
8826f46f | 950 | |
40474984 | 951 | m_printAllPages = (((pd->Flags & PD_PAGENUMS) != PD_PAGENUMS) && ((pd->Flags & PD_SELECTION) != PD_SELECTION)); |
5360828d | 952 | m_printSelection = ((pd->Flags & PD_SELECTION) == PD_SELECTION); |
7bcb11d3 JS |
953 | m_printCollate = ((pd->Flags & PD_COLLATE) == PD_COLLATE); |
954 | m_printToFile = ((pd->Flags & PD_PRINTTOFILE) == PD_PRINTTOFILE); | |
955 | m_printEnablePrintToFile = ((pd->Flags & PD_DISABLEPRINTTOFILE) != PD_DISABLEPRINTTOFILE); | |
956 | m_printEnableSelection = ((pd->Flags & PD_NOSELECTION) != PD_NOSELECTION); | |
957 | m_printEnablePageNumbers = ((pd->Flags & PD_NOPAGENUMS) != PD_NOPAGENUMS); | |
958 | m_printEnableHelp = ((pd->Flags & PD_SHOWHELP) == PD_SHOWHELP); | |
959 | m_printSetupDialog = ((pd->Flags & PD_PRINTSETUP) == PD_PRINTSETUP); | |
960 | ||
961 | /* port is obsolete in WIN32 | |
962 | // Get the port name | |
963 | if (pd->hDevNames) | |
964 | { | |
965 | LPDEVNAMES lpDevNames = (LPDEVNAMES)GlobalLock(pd->hDevNames); | |
966 | if (lpDevNames) { | |
967 | m_printData.SetPortName((LPSTR)lpDevNames + lpDevNames->wDriverOffset); | |
968 | wxString devName = (LPSTR)lpDevNames + lpDevNames->wDeviceOffset; | |
969 | GlobalUnlock(pd->hDevNames); | |
8826f46f | 970 | |
7bcb11d3 JS |
971 | // wxASSERT_MSG( (m_printerName == "" || (devName == m_printerName)), "Printer name obtained from DEVMODE and DEVNAMES were different!"); |
972 | } | |
973 | } | |
974 | */ | |
c801d85f KB |
975 | } |
976 | ||
7bcb11d3 | 977 | void wxPrintDialogData::SetOwnerWindow(wxWindow* win) |
c801d85f | 978 | { |
7bcb11d3 | 979 | if ( m_printDlgData == NULL ) |
c801d85f | 980 | ConvertToNative(); |
8826f46f | 981 | |
7bcb11d3 | 982 | if ( m_printDlgData != NULL && win != NULL) |
c801d85f | 983 | { |
161f4f73 | 984 | PRINTDLG *pd = (PRINTDLG *) m_printDlgData; |
7bcb11d3 | 985 | pd->hwndOwner=(HWND) win->GetHWND(); |
c801d85f KB |
986 | } |
987 | } | |
8826f46f | 988 | #endif // MSW |
c801d85f | 989 | |
51abe921 | 990 | #ifdef __WXMAC__ |
cfb00da4 | 991 | |
51abe921 SC |
992 | void wxPrintDialogData::ConvertToNative() |
993 | { | |
cfb00da4 | 994 | m_printData.ConvertToNative(); |
746d7582 | 995 | m_printData.m_nativePrintData->TransferFrom( this ) ; |
51abe921 SC |
996 | } |
997 | ||
998 | void wxPrintDialogData::ConvertFromNative() | |
999 | { | |
cfb00da4 | 1000 | m_printData.ConvertFromNative(); |
746d7582 | 1001 | m_printData.m_nativePrintData->TransferTo( this ) ; |
51abe921 | 1002 | } |
cfb00da4 | 1003 | |
51abe921 SC |
1004 | #endif |
1005 | ||
1006 | ||
7bcb11d3 | 1007 | void wxPrintDialogData::operator=(const wxPrintDialogData& data) |
c801d85f | 1008 | { |
7bcb11d3 JS |
1009 | m_printFromPage = data.m_printFromPage; |
1010 | m_printToPage = data.m_printToPage; | |
1011 | m_printMinPage = data.m_printMinPage; | |
1012 | m_printMaxPage = data.m_printMaxPage; | |
1013 | m_printNoCopies = data.m_printNoCopies; | |
1014 | m_printAllPages = data.m_printAllPages; | |
1015 | m_printCollate = data.m_printCollate; | |
1016 | m_printToFile = data.m_printToFile; | |
5360828d | 1017 | m_printSelection = data.m_printSelection; |
7bcb11d3 JS |
1018 | m_printEnableSelection = data.m_printEnableSelection; |
1019 | m_printEnablePageNumbers = data.m_printEnablePageNumbers; | |
1020 | m_printEnableHelp = data.m_printEnableHelp; | |
1021 | m_printEnablePrintToFile = data.m_printEnablePrintToFile; | |
1022 | m_printSetupDialog = data.m_printSetupDialog; | |
1023 | ||
1024 | m_printData = data.m_printData; | |
1025 | } | |
1026 | ||
1027 | void wxPrintDialogData::operator=(const wxPrintData& data) | |
1028 | { | |
1029 | m_printData = data; | |
c801d85f KB |
1030 | } |
1031 | ||
8826f46f VZ |
1032 | // ---------------------------------------------------------------------------- |
1033 | // wxPageSetupDialogData | |
1034 | // ---------------------------------------------------------------------------- | |
c801d85f | 1035 | |
7bcb11d3 | 1036 | wxPageSetupDialogData::wxPageSetupDialogData() |
c801d85f KB |
1037 | { |
1038 | #if defined(__WIN95__) | |
7bcb11d3 | 1039 | m_pageSetupData = NULL; |
c801d85f | 1040 | #endif |
7bcb11d3 JS |
1041 | m_paperSize = wxSize(0, 0); |
1042 | ||
1043 | CalculatePaperSizeFromId(); | |
1044 | ||
1045 | m_minMarginTopLeft = wxPoint(0, 0); | |
1046 | m_minMarginBottomRight = wxPoint(0, 0); | |
1047 | m_marginTopLeft = wxPoint(0, 0); | |
1048 | m_marginBottomRight = wxPoint(0, 0); | |
1049 | ||
1050 | // Flags | |
1051 | m_defaultMinMargins = FALSE; | |
1052 | m_enableMargins = TRUE; | |
1053 | m_enableOrientation = TRUE; | |
1054 | m_enablePaper = TRUE; | |
1055 | m_enablePrinter = TRUE; | |
1056 | m_enableHelp = FALSE; | |
1057 | m_getDefaultInfo = FALSE; | |
1058 | } | |
c801d85f | 1059 | |
7bcb11d3 | 1060 | wxPageSetupDialogData::wxPageSetupDialogData(const wxPageSetupDialogData& dialogData) |
5e472c1f | 1061 | : wxObject() |
7bcb11d3 | 1062 | { |
7c74e7fe SC |
1063 | #if defined(__WIN95__) |
1064 | m_pageSetupData = NULL; | |
7c74e7fe | 1065 | #endif |
7bcb11d3 JS |
1066 | (*this) = dialogData; |
1067 | } | |
1068 | ||
1069 | wxPageSetupDialogData::wxPageSetupDialogData(const wxPrintData& printData) | |
1070 | { | |
1071 | #if defined(__WIN95__) | |
1072 | m_pageSetupData = NULL; | |
1073 | #endif | |
1074 | m_paperSize = wxSize(0, 0); | |
1075 | m_minMarginTopLeft = wxPoint(0, 0); | |
1076 | m_minMarginBottomRight = wxPoint(0, 0); | |
1077 | m_marginTopLeft = wxPoint(0, 0); | |
1078 | m_marginBottomRight = wxPoint(0, 0); | |
1079 | ||
1080 | // Flags | |
1081 | m_defaultMinMargins = FALSE; | |
1082 | m_enableMargins = TRUE; | |
1083 | m_enableOrientation = TRUE; | |
1084 | m_enablePaper = TRUE; | |
1085 | m_enablePrinter = TRUE; | |
1086 | m_enableHelp = FALSE; | |
1087 | m_getDefaultInfo = FALSE; | |
1088 | ||
1089 | m_printData = printData; | |
1090 | ||
1091 | // The wxPrintData paper size overrides these values, unless the size cannot | |
1092 | // be found. | |
1093 | CalculatePaperSizeFromId(); | |
c801d85f KB |
1094 | } |
1095 | ||
7bcb11d3 | 1096 | wxPageSetupDialogData::~wxPageSetupDialogData() |
c801d85f | 1097 | { |
34138703 | 1098 | #if defined(__WIN95__) && defined(__WXMSW__) |
c801d85f KB |
1099 | PAGESETUPDLG *pd = (PAGESETUPDLG *)m_pageSetupData; |
1100 | if ( pd && pd->hDevMode ) | |
1101 | GlobalFree(pd->hDevMode); | |
eaeb6a3c JS |
1102 | if ( pd && pd->hDevNames ) |
1103 | GlobalFree(pd->hDevNames); | |
c801d85f KB |
1104 | if ( pd ) |
1105 | delete pd; | |
1106 | #endif | |
1107 | } | |
1108 | ||
5e472c1f | 1109 | wxPageSetupDialogData& wxPageSetupDialogData::operator=(const wxPageSetupDialogData& data) |
c801d85f | 1110 | { |
7bcb11d3 JS |
1111 | m_paperSize = data.m_paperSize; |
1112 | m_minMarginTopLeft = data.m_minMarginTopLeft; | |
1113 | m_minMarginBottomRight = data.m_minMarginBottomRight; | |
1114 | m_marginTopLeft = data.m_marginTopLeft; | |
1115 | m_marginBottomRight = data.m_marginBottomRight; | |
1116 | m_defaultMinMargins = data.m_defaultMinMargins; | |
1117 | m_enableMargins = data.m_enableMargins; | |
1118 | m_enableOrientation = data.m_enableOrientation; | |
1119 | m_enablePaper = data.m_enablePaper; | |
1120 | m_enablePrinter = data.m_enablePrinter; | |
1121 | m_getDefaultInfo = data.m_getDefaultInfo;; | |
1122 | m_enableHelp = data.m_enableHelp; | |
1123 | ||
1124 | m_printData = data.m_printData; | |
5e472c1f GD |
1125 | |
1126 | return *this; | |
7bcb11d3 | 1127 | } |
c801d85f | 1128 | |
5e472c1f | 1129 | wxPageSetupDialogData& wxPageSetupDialogData::operator=(const wxPrintData& data) |
7bcb11d3 JS |
1130 | { |
1131 | m_printData = data; | |
5e472c1f GD |
1132 | |
1133 | return *this; | |
c801d85f KB |
1134 | } |
1135 | ||
8826f46f | 1136 | #if defined(__WIN95__) |
7bcb11d3 | 1137 | void wxPageSetupDialogData::ConvertToNative() |
c801d85f | 1138 | { |
7bcb11d3 JS |
1139 | m_printData.ConvertToNative(); |
1140 | ||
c801d85f | 1141 | PAGESETUPDLG *pd = (PAGESETUPDLG*) m_pageSetupData; |
7bcb11d3 | 1142 | |
c801d85f KB |
1143 | if ( m_pageSetupData == NULL ) |
1144 | { | |
7bcb11d3 JS |
1145 | pd = new PAGESETUPDLG; |
1146 | pd->hDevMode = NULL; | |
eaeb6a3c | 1147 | pd->hDevNames = NULL; |
7bcb11d3 | 1148 | m_pageSetupData = (void *)pd; |
c801d85f | 1149 | } |
8bbe427f | 1150 | |
7bcb11d3 JS |
1151 | // Pass the devmode data (created in m_printData.ConvertToNative) |
1152 | // to the PRINTDLG structure, since it'll | |
1153 | // be needed when PrintDlg is called. | |
1154 | ||
1155 | if (pd->hDevMode) | |
1156 | { | |
1157 | GlobalFree(pd->hDevMode); | |
1158 | pd->hDevMode = NULL; | |
1159 | } | |
1160 | ||
7bcb11d3 JS |
1161 | pd->hDevMode = (HGLOBAL) m_printData.GetNativeData(); |
1162 | ||
1163 | m_printData.SetNativeData((void*) NULL); | |
1164 | ||
58cf0491 JS |
1165 | // Shouldn't assert; we should be able to test Ok-ness at a higher level |
1166 | //wxASSERT_MSG( (pd->hDevMode), wxT("hDevMode must be non-NULL in ConvertToNative!")); | |
7bcb11d3 | 1167 | |
eaeb6a3c JS |
1168 | // Pass the devnames data (created in m_printData.ConvertToNative) |
1169 | // to the PRINTDLG structure, since it'll | |
1170 | // be needed when PrintDlg is called. | |
1171 | ||
1172 | if (pd->hDevNames) | |
1173 | { | |
1174 | GlobalFree(pd->hDevNames); | |
1175 | pd->hDevNames = NULL; | |
1176 | } | |
1177 | ||
1178 | pd->hDevNames = (HGLOBAL) m_printData.GetNativeDataDevNames(); | |
1179 | ||
1180 | m_printData.SetNativeDataDevNames((void*) NULL); | |
1181 | ||
7bcb11d3 | 1182 | // pd->hDevMode = GlobalAlloc(GMEM_MOVEABLE, sizeof(DEVMODE)); |
c801d85f | 1183 | |
7bcb11d3 | 1184 | pd->Flags = PSD_MARGINS|PSD_MINMARGINS; |
8826f46f | 1185 | |
c801d85f KB |
1186 | if ( m_defaultMinMargins ) |
1187 | pd->Flags |= PSD_DEFAULTMINMARGINS; | |
1188 | if ( !m_enableMargins ) | |
1189 | pd->Flags |= PSD_DISABLEMARGINS; | |
1190 | if ( !m_enableOrientation ) | |
1191 | pd->Flags |= PSD_DISABLEORIENTATION; | |
1192 | if ( !m_enablePaper ) | |
1193 | pd->Flags |= PSD_DISABLEPAPER; | |
1194 | if ( !m_enablePrinter ) | |
1195 | pd->Flags |= PSD_DISABLEPRINTER; | |
1196 | if ( m_getDefaultInfo ) | |
1197 | pd->Flags |= PSD_RETURNDEFAULT; | |
1198 | if ( m_enableHelp ) | |
1199 | pd->Flags |= PSD_SHOWHELP; | |
1200 | ||
7bcb11d3 JS |
1201 | // We want the units to be in hundredths of a millimetre |
1202 | pd->Flags |= PSD_INHUNDREDTHSOFMILLIMETERS; | |
1203 | ||
c801d85f | 1204 | pd->lStructSize = sizeof( PAGESETUPDLG ); |
c4e7c2aa | 1205 | pd->hwndOwner=(HWND)NULL; |
eaeb6a3c | 1206 | // pd->hDevNames=(HWND)NULL; |
c801d85f | 1207 | pd->hInstance=(HINSTANCE)NULL; |
161f4f73 | 1208 | // PAGESETUPDLG is in hundreds of a mm |
7bcb11d3 JS |
1209 | pd->ptPaperSize.x = m_paperSize.x * 100; |
1210 | pd->ptPaperSize.y = m_paperSize.y * 100; | |
8826f46f | 1211 | |
7bcb11d3 JS |
1212 | pd->rtMinMargin.left = m_minMarginTopLeft.x * 100; |
1213 | pd->rtMinMargin.top = m_minMarginTopLeft.y * 100; | |
1214 | pd->rtMinMargin.right = m_minMarginBottomRight.x * 100; | |
1215 | pd->rtMinMargin.bottom = m_minMarginBottomRight.y * 100; | |
8826f46f | 1216 | |
7bcb11d3 JS |
1217 | pd->rtMargin.left = m_marginTopLeft.x * 100; |
1218 | pd->rtMargin.top = m_marginTopLeft.y * 100; | |
1219 | pd->rtMargin.right = m_marginBottomRight.x * 100; | |
1220 | pd->rtMargin.bottom = m_marginBottomRight.y * 100; | |
8826f46f | 1221 | |
c801d85f KB |
1222 | pd->lCustData = 0; |
1223 | pd->lpfnPageSetupHook = NULL; | |
1224 | pd->lpfnPagePaintHook = NULL; | |
1225 | pd->hPageSetupTemplate = NULL; | |
1226 | pd->lpPageSetupTemplateName = NULL; | |
1227 | ||
8826f46f | 1228 | /* |
c801d85f KB |
1229 | if ( pd->hDevMode ) |
1230 | { | |
1231 | DEVMODE *devMode = (DEVMODE*) GlobalLock(pd->hDevMode); | |
1232 | memset(devMode, 0, sizeof(DEVMODE)); | |
1233 | devMode->dmSize = sizeof(DEVMODE); | |
1234 | devMode->dmOrientation = m_orientation; | |
1235 | devMode->dmFields = DM_ORIENTATION; | |
1236 | GlobalUnlock(pd->hDevMode); | |
1237 | } | |
7bcb11d3 | 1238 | */ |
c801d85f KB |
1239 | } |
1240 | ||
7bcb11d3 | 1241 | void wxPageSetupDialogData::ConvertFromNative() |
c801d85f | 1242 | { |
161f4f73 | 1243 | PAGESETUPDLG *pd = (PAGESETUPDLG *) m_pageSetupData; |
c801d85f KB |
1244 | if ( !pd ) |
1245 | return; | |
8826f46f | 1246 | |
7bcb11d3 JS |
1247 | // Pass the devmode data back to the wxPrintData structure where it really belongs. |
1248 | if (pd->hDevMode) | |
1249 | { | |
1250 | if (m_printData.GetNativeData()) | |
1251 | { | |
1252 | // Make sure we don't leak memory | |
1253 | GlobalFree((HGLOBAL) m_printData.GetNativeData()); | |
1254 | } | |
1255 | m_printData.SetNativeData((void*) pd->hDevMode); | |
1256 | pd->hDevMode = NULL; | |
1257 | } | |
c801d85f | 1258 | |
7bcb11d3 | 1259 | m_printData.ConvertFromNative(); |
c801d85f | 1260 | |
eaeb6a3c JS |
1261 | // Pass the devnames data back to the wxPrintData structure where it really belongs. |
1262 | if (pd->hDevNames) | |
1263 | { | |
1264 | if (m_printData.GetNativeDataDevNames()) | |
1265 | { | |
1266 | // Make sure we don't leak memory | |
1267 | GlobalFree((HGLOBAL) m_printData.GetNativeDataDevNames()); | |
1268 | } | |
1269 | m_printData.SetNativeDataDevNames((void*) pd->hDevNames); | |
1270 | pd->hDevNames = NULL; | |
1271 | } | |
1272 | ||
1273 | m_printData.ConvertFromNative(); | |
1274 | ||
7bcb11d3 | 1275 | pd->Flags = PSD_MARGINS|PSD_MINMARGINS; |
8826f46f | 1276 | |
c801d85f KB |
1277 | m_defaultMinMargins = ((pd->Flags & PSD_DEFAULTMINMARGINS) == PSD_DEFAULTMINMARGINS); |
1278 | m_enableMargins = ((pd->Flags & PSD_DISABLEMARGINS) != PSD_DISABLEMARGINS); | |
1279 | m_enableOrientation = ((pd->Flags & PSD_DISABLEORIENTATION) != PSD_DISABLEORIENTATION); | |
1280 | m_enablePaper = ((pd->Flags & PSD_DISABLEPAPER) != PSD_DISABLEPAPER); | |
1281 | m_enablePrinter = ((pd->Flags & PSD_DISABLEPRINTER) != PSD_DISABLEPRINTER); | |
1282 | m_getDefaultInfo = ((pd->Flags & PSD_RETURNDEFAULT) == PSD_RETURNDEFAULT); | |
1283 | m_enableHelp = ((pd->Flags & PSD_SHOWHELP) == PSD_SHOWHELP); | |
8826f46f | 1284 | |
161f4f73 | 1285 | // PAGESETUPDLG is in hundreds of a mm |
7bcb11d3 JS |
1286 | m_paperSize.x = pd->ptPaperSize.x / 100; |
1287 | m_paperSize.y = pd->ptPaperSize.y / 100; | |
8826f46f | 1288 | |
7bcb11d3 JS |
1289 | m_minMarginTopLeft.x = pd->rtMinMargin.left / 100; |
1290 | m_minMarginTopLeft.y = pd->rtMinMargin.top / 100; | |
1291 | m_minMarginBottomRight.x = pd->rtMinMargin.right / 100; | |
1292 | m_minMarginBottomRight.y = pd->rtMinMargin.bottom / 100; | |
8826f46f | 1293 | |
161f4f73 VZ |
1294 | m_marginTopLeft.x = pd->rtMargin.left / 100; |
1295 | m_marginTopLeft.y = pd->rtMargin.top / 100; | |
1296 | m_marginBottomRight.x = pd->rtMargin.right / 100; | |
1297 | m_marginBottomRight.y = pd->rtMargin.bottom / 100; | |
7bcb11d3 | 1298 | } |
c801d85f | 1299 | |
7bcb11d3 JS |
1300 | void wxPageSetupDialogData::SetOwnerWindow(wxWindow* win) |
1301 | { | |
1302 | if ( m_pageSetupData == NULL ) | |
1303 | ConvertToNative(); | |
8826f46f | 1304 | |
7bcb11d3 JS |
1305 | if ( m_pageSetupData != NULL && win != NULL) |
1306 | { | |
161f4f73 | 1307 | PAGESETUPDLG *pd = (PAGESETUPDLG *) m_pageSetupData; |
7bcb11d3 JS |
1308 | pd->hwndOwner=(HWND) win->GetHWND(); |
1309 | } | |
1310 | } | |
8826f46f | 1311 | #endif // Win95 |
c801d85f | 1312 | |
51abe921 | 1313 | #ifdef __WXMAC__ |
7c74e7fe | 1314 | void wxPageSetupDialogData::ConvertToNative() |
51abe921 | 1315 | { |
161f4f73 | 1316 | m_printData.ConvertToNative(); |
746d7582 | 1317 | m_printData.m_nativePrintData->TransferFrom( this ) ; |
51abe921 SC |
1318 | } |
1319 | ||
7c74e7fe | 1320 | void wxPageSetupDialogData::ConvertFromNative() |
51abe921 | 1321 | { |
161f4f73 | 1322 | m_printData.ConvertFromNative (); |
cfb00da4 SC |
1323 | m_paperSize = m_printData.GetPaperSize() ; |
1324 | CalculateIdFromPaperSize(); | |
746d7582 | 1325 | m_printData.m_nativePrintData->TransferTo( this ) ; |
161f4f73 | 1326 | // adjust minimal values |
161f4f73 VZ |
1327 | |
1328 | if ( m_marginTopLeft.x < m_minMarginTopLeft.x ) | |
1329 | m_marginTopLeft.x = m_minMarginTopLeft.x; | |
1330 | ||
1331 | if ( m_marginBottomRight.x < m_minMarginBottomRight.x ) | |
1332 | m_marginBottomRight.x = m_minMarginBottomRight.x; | |
1333 | ||
1334 | if ( m_marginTopLeft.y < m_minMarginTopLeft.y ) | |
1335 | m_marginTopLeft.y = m_minMarginTopLeft.y; | |
1336 | ||
1337 | if ( m_marginBottomRight.y < m_minMarginBottomRight.y ) | |
1338 | m_marginBottomRight.y = m_minMarginBottomRight.y; | |
51abe921 SC |
1339 | } |
1340 | #endif | |
1341 | ||
1342 | ||
7bcb11d3 JS |
1343 | // If a corresponding paper type is found in the paper database, will set the m_printData |
1344 | // paper size id member as well. | |
1345 | void wxPageSetupDialogData::SetPaperSize(const wxSize& sz) | |
1346 | { | |
1347 | m_paperSize = sz; | |
c801d85f | 1348 | |
7bcb11d3 JS |
1349 | CalculateIdFromPaperSize(); |
1350 | } | |
c801d85f | 1351 | |
7bcb11d3 JS |
1352 | // Sets the wxPrintData id, plus the paper width/height if found in the paper database. |
1353 | void wxPageSetupDialogData::SetPaperSize(wxPaperSize id) | |
1354 | { | |
1355 | m_printData.SetPaperId(id); | |
1356 | ||
1357 | CalculatePaperSizeFromId(); | |
c801d85f KB |
1358 | } |
1359 | ||
7bcb11d3 JS |
1360 | // Use paper size defined in this object to set the wxPrintData |
1361 | // paper id | |
1362 | void wxPageSetupDialogData::CalculateIdFromPaperSize() | |
c801d85f | 1363 | { |
8826f46f | 1364 | wxASSERT_MSG( (wxThePrintPaperDatabase != (wxPrintPaperDatabase*) NULL), |
fbdcff4a | 1365 | wxT("wxThePrintPaperDatabase should not be NULL. Do not create global print dialog data objects.") ); |
c801d85f | 1366 | |
7bcb11d3 JS |
1367 | wxSize sz = GetPaperSize(); |
1368 | ||
1369 | wxPaperSize id = wxThePrintPaperDatabase->GetSize(wxSize(sz.x* 10, sz.y * 10)); | |
1370 | if (id != wxPAPER_NONE) | |
c801d85f | 1371 | { |
7bcb11d3 | 1372 | m_printData.SetPaperId(id); |
c801d85f KB |
1373 | } |
1374 | } | |
8826f46f | 1375 | |
7bcb11d3 JS |
1376 | // Use paper id in wxPrintData to set this object's paper size |
1377 | void wxPageSetupDialogData::CalculatePaperSizeFromId() | |
1378 | { | |
8826f46f | 1379 | wxASSERT_MSG( (wxThePrintPaperDatabase != (wxPrintPaperDatabase*) NULL), |
fbdcff4a | 1380 | wxT("wxThePrintPaperDatabase should not be NULL. Do not create global print dialog data objects.") ); |
7bcb11d3 JS |
1381 | |
1382 | wxSize sz = wxThePrintPaperDatabase->GetSize(m_printData.GetPaperId()); | |
c801d85f | 1383 | |
01cf2f95 VZ |
1384 | // sz is in 10ths of a mm, while paper size is in mm |
1385 | m_paperSize.x = sz.x / 10; | |
1386 | m_paperSize.y = sz.y / 10; | |
7bcb11d3 | 1387 | } |
8826f46f | 1388 | |
88ac883a | 1389 | #endif // wxUSE_PRINTING_ARCHITECTURE |