]>
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 |
8bbe427f | 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 | |
449110cd | 54 | #if defined(__WXWINCE__) && !wxUSE_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 | |
25889d3c | 393 | #ifndef __WIN16__ |
7bcb11d3 JS |
394 | devMode->dmCollate = (m_printCollate ? DMCOLLATE_TRUE : DMCOLLATE_FALSE); |
395 | devMode->dmFields |= DM_COLLATE; | |
25889d3c | 396 | #endif |
8826f46f | 397 | |
7bcb11d3 | 398 | //// Number of copies |
8826f46f | 399 | |
7bcb11d3 JS |
400 | devMode->dmCopies = m_printNoCopies; |
401 | devMode->dmFields |= DM_COPIES; | |
8826f46f | 402 | |
7bcb11d3 | 403 | //// Printer name |
8826f46f | 404 | |
223d09f6 | 405 | if (m_printerName != wxT("")) |
7bcb11d3 | 406 | { |
161f4f73 VZ |
407 | //int len = wxMin(31, m_printerName.Len()); |
408 | wxStrncpy((wxChar*)devMode->dmDeviceName,m_printerName.c_str(),31); | |
409 | devMode->dmDeviceName[31] = wxT('\0'); | |
7bcb11d3 | 410 | } |
8826f46f | 411 | |
7bcb11d3 | 412 | //// Colour |
8826f46f | 413 | |
7bcb11d3 JS |
414 | if (m_colour) |
415 | devMode->dmColor = DMCOLOR_COLOR; | |
416 | else | |
417 | devMode->dmColor = DMCOLOR_MONOCHROME; | |
8826f46f | 418 | |
7bcb11d3 | 419 | devMode->dmFields |= DM_COLOR; |
8826f46f | 420 | |
7bcb11d3 | 421 | //// Paper size |
8826f46f | 422 | |
7bcb11d3 JS |
423 | if (m_paperId == wxPAPER_NONE) |
424 | { | |
161f4f73 | 425 | // DEVMODE is in tenths of a milimeter |
7bcb11d3 JS |
426 | devMode->dmPaperWidth = m_paperSize.x * 10; |
427 | devMode->dmPaperLength = m_paperSize.y * 10; | |
f9862abd | 428 | devMode->dmPaperSize = DMPAPER_USER; |
7bcb11d3 JS |
429 | devMode->dmFields |= DM_PAPERWIDTH; |
430 | devMode->dmFields |= DM_PAPERLENGTH; | |
431 | } | |
432 | else | |
433 | { | |
434 | if (wxThePrintPaperDatabase) | |
435 | { | |
436 | wxPrintPaperType* paper = wxThePrintPaperDatabase->FindPaperType(m_paperId); | |
437 | if (paper) | |
438 | { | |
439 | devMode->dmPaperSize = paper->GetPlatformId(); | |
440 | devMode->dmFields |= DM_PAPERSIZE; | |
441 | } | |
442 | } | |
443 | } | |
8826f46f | 444 | |
7bcb11d3 | 445 | //// Duplex |
8826f46f | 446 | |
7bcb11d3 JS |
447 | int duplex; |
448 | switch (m_duplexMode) | |
449 | { | |
450 | case wxDUPLEX_HORIZONTAL: { | |
451 | duplex = DMDUP_HORIZONTAL; break; | |
452 | } | |
453 | case wxDUPLEX_VERTICAL: { | |
454 | duplex = DMDUP_VERTICAL; break; | |
455 | } | |
456 | default: | |
457 | case wxDUPLEX_SIMPLEX: { | |
458 | duplex = DMDUP_SIMPLEX; break; | |
459 | } | |
460 | } | |
461 | devMode->dmDuplex = duplex; | |
462 | devMode->dmFields |= DM_DUPLEX; | |
8826f46f | 463 | |
7bcb11d3 | 464 | //// Quality |
8826f46f | 465 | |
7bcb11d3 JS |
466 | int quality; |
467 | switch (m_printQuality) | |
468 | { | |
469 | case wxPRINT_QUALITY_MEDIUM: { | |
470 | quality = DMRES_MEDIUM; break; | |
471 | } | |
472 | case wxPRINT_QUALITY_LOW: { | |
473 | quality = DMRES_LOW; break; | |
474 | } | |
475 | case wxPRINT_QUALITY_DRAFT: { | |
476 | quality = DMRES_DRAFT; break; | |
477 | } | |
478 | case wxPRINT_QUALITY_HIGH: { | |
479 | quality = DMRES_HIGH; break; | |
480 | } | |
481 | default: { | |
482 | quality = m_printQuality; break; | |
483 | } | |
484 | } | |
485 | devMode->dmPrintQuality = quality; | |
486 | devMode->dmFields |= DM_PRINTQUALITY; | |
8826f46f | 487 | |
7bcb11d3 | 488 | GlobalUnlock(hDevMode); |
c801d85f | 489 | } |
eaeb6a3c JS |
490 | |
491 | if ( hDevNames ) | |
492 | { | |
493 | GlobalFree(hDevNames); | |
494 | } | |
495 | ||
496 | // TODO: I hope it's OK to pass some empty strings to DEVNAMES. | |
161f4f73 | 497 | m_devNames = (void*) (long) wxCreateDevNames(wxT(""), m_printerName, wxT("")); |
7bcb11d3 JS |
498 | } |
499 | ||
500 | void wxPrintData::ConvertFromNative() | |
501 | { | |
48c12cb1 | 502 | HGLOBAL hDevMode = (HGLOBAL)(DWORD) m_devMode; |
eaeb6a3c | 503 | HGLOBAL hDevNames = (HGLOBAL)(DWORD) m_devNames; |
7bcb11d3 JS |
504 | |
505 | if (!hDevMode) | |
506 | return; | |
507 | ||
508 | if ( hDevMode ) | |
509 | { | |
8f177c8e | 510 | LPDEVMODE devMode = (LPDEVMODE)GlobalLock(hDevMode); |
8826f46f | 511 | |
7bcb11d3 | 512 | //// Orientation |
8826f46f | 513 | |
7bcb11d3 JS |
514 | if (devMode->dmFields & DM_ORIENTATION) |
515 | m_printOrientation = devMode->dmOrientation; | |
8826f46f | 516 | |
7bcb11d3 | 517 | //// Collation |
8826f46f | 518 | |
25889d3c | 519 | #ifndef __WIN16__ |
7bcb11d3 JS |
520 | if (devMode->dmFields & DM_COLLATE) |
521 | { | |
522 | if (devMode->dmCollate == DMCOLLATE_TRUE) | |
523 | m_printCollate = TRUE; | |
524 | else | |
525 | m_printCollate = FALSE; | |
526 | } | |
25889d3c | 527 | #endif |
8826f46f | 528 | |
7bcb11d3 | 529 | //// Number of copies |
8826f46f | 530 | |
7bcb11d3 JS |
531 | if (devMode->dmFields & DM_COPIES) |
532 | { | |
533 | m_printNoCopies = devMode->dmCopies; | |
534 | } | |
8826f46f | 535 | |
7bcb11d3 | 536 | //// Printer name |
8826f46f | 537 | |
7bcb11d3 JS |
538 | if (devMode->dmDeviceName[0] != 0) |
539 | { | |
2b5f62a0 | 540 | m_printerName = devMode->dmDeviceName; |
7bcb11d3 | 541 | } |
8826f46f | 542 | |
7bcb11d3 | 543 | //// Colour |
8826f46f | 544 | |
7bcb11d3 JS |
545 | if (devMode->dmFields & DM_COLOR) |
546 | { | |
547 | if (devMode->dmColor == DMCOLOR_COLOR) | |
548 | m_colour = TRUE; | |
549 | else | |
550 | m_colour = FALSE; | |
551 | } | |
552 | else | |
553 | m_colour = TRUE; | |
8826f46f | 554 | |
7bcb11d3 | 555 | //// Paper size |
8826f46f | 556 | |
8084a109 VS |
557 | // We don't know size of user defined paper and some buggy drivers |
558 | // set both DM_PAPERSIZE and DM_PAPERWIDTH & DM_PAPERLENGTH. Since | |
559 | // dmPaperSize >= DMPAPER_USER wouldn't be in wxWin's database, this | |
560 | // code wouldn't set m_paperSize correctly. | |
561 | if ((devMode->dmFields & DM_PAPERSIZE) && (devMode->dmPaperSize < DMPAPER_USER)) | |
7bcb11d3 JS |
562 | { |
563 | if (wxThePrintPaperDatabase) | |
564 | { | |
565 | wxPrintPaperType* paper = wxThePrintPaperDatabase->FindPaperTypeByPlatformId(devMode->dmPaperSize); | |
566 | if (paper) | |
567 | { | |
568 | m_paperId = paper->GetId(); | |
161f4f73 VZ |
569 | m_paperSize.x = paper->GetWidth() / 10; |
570 | m_paperSize.y = paper->GetHeight() / 10; | |
7bcb11d3 JS |
571 | } |
572 | else | |
573 | { | |
574 | // Shouldn't really get here | |
223d09f6 | 575 | wxFAIL_MSG(wxT("Couldn't find paper size in paper database.")); |
8826f46f | 576 | |
7bcb11d3 JS |
577 | m_paperId = wxPAPER_NONE; |
578 | m_paperSize.x = 0; | |
579 | m_paperSize.y = 0; | |
580 | } | |
581 | } | |
582 | else | |
583 | { | |
584 | // Shouldn't really get here | |
223d09f6 | 585 | wxFAIL_MSG(wxT("Paper database wasn't initialized in wxPrintData::ConvertFromNative.")); |
8826f46f | 586 | |
7bcb11d3 JS |
587 | m_paperId = wxPAPER_NONE; |
588 | m_paperSize.x = 0; | |
589 | m_paperSize.y = 0; | |
590 | } | |
591 | } | |
592 | else if ((devMode->dmFields & DM_PAPERWIDTH) && (devMode->dmFields & DM_PAPERLENGTH)) | |
593 | { | |
161f4f73 | 594 | // DEVMODE is in tenths of a milimeter |
7bcb11d3 JS |
595 | m_paperSize.x = devMode->dmPaperWidth / 10; |
596 | m_paperSize.y = devMode->dmPaperLength / 10; | |
597 | m_paperId = wxPAPER_NONE; | |
598 | } | |
599 | else | |
600 | { | |
601 | // Shouldn't really get here | |
223d09f6 | 602 | wxFAIL_MSG(wxT("Couldn't find paper size from DEVMODE.")); |
8826f46f | 603 | |
7bcb11d3 JS |
604 | m_paperSize.x = 0; |
605 | m_paperSize.y = 0; | |
606 | m_paperId = wxPAPER_NONE; | |
607 | } | |
8826f46f | 608 | |
7bcb11d3 | 609 | //// Duplex |
8826f46f | 610 | |
7bcb11d3 JS |
611 | if (devMode->dmFields & DM_DUPLEX) |
612 | { | |
613 | switch (devMode->dmDuplex) | |
614 | { | |
615 | case DMDUP_HORIZONTAL: { | |
616 | m_duplexMode = wxDUPLEX_HORIZONTAL; break; | |
617 | } | |
618 | case DMDUP_VERTICAL: { | |
619 | m_duplexMode = wxDUPLEX_VERTICAL; break; | |
620 | } | |
621 | default: | |
622 | case DMDUP_SIMPLEX: { | |
623 | m_duplexMode = wxDUPLEX_SIMPLEX; break; | |
624 | } | |
625 | } | |
626 | } | |
627 | else | |
628 | m_duplexMode = wxDUPLEX_SIMPLEX; | |
8826f46f | 629 | |
7bcb11d3 | 630 | //// Quality |
8826f46f | 631 | |
7bcb11d3 JS |
632 | if (devMode->dmFields & DM_PRINTQUALITY) |
633 | { | |
634 | switch (devMode->dmPrintQuality) | |
635 | { | |
636 | case DMRES_MEDIUM: { | |
637 | m_printQuality = wxPRINT_QUALITY_MEDIUM; break; | |
638 | } | |
639 | case DMRES_LOW: { | |
640 | m_printQuality = wxPRINT_QUALITY_LOW; break; | |
641 | } | |
642 | case DMRES_DRAFT: { | |
643 | m_printQuality = wxPRINT_QUALITY_DRAFT; break; | |
644 | } | |
645 | case DMRES_HIGH: { | |
646 | m_printQuality = wxPRINT_QUALITY_HIGH; break; | |
647 | } | |
648 | default: | |
649 | { | |
650 | // TODO: if the printer fills in the resolution in DPI, how | |
651 | // will the application know if it's high, low, draft etc.?? | |
652 | // wxFAIL_MSG("Warning: DM_PRINTQUALITY was not one of the standard values."); | |
653 | m_printQuality = devMode->dmPrintQuality; break; | |
8826f46f | 654 | |
7bcb11d3 JS |
655 | } |
656 | } | |
657 | } | |
658 | else | |
659 | m_printQuality = wxPRINT_QUALITY_HIGH; | |
8826f46f | 660 | |
7bcb11d3 JS |
661 | GlobalUnlock(hDevMode); |
662 | } | |
eaeb6a3c JS |
663 | |
664 | if (hDevNames) | |
665 | { | |
666 | LPDEVNAMES lpDevNames = (LPDEVNAMES)GlobalLock(hDevNames); | |
667 | if (lpDevNames) | |
668 | { | |
669 | // TODO: Unicode-ification | |
670 | ||
671 | // Get the port name | |
672 | // port is obsolete in WIN32 | |
673 | // m_printData.SetPortName((LPSTR)lpDevNames + lpDevNames->wDriverOffset); | |
674 | ||
675 | // Get the printer name | |
161f4f73 | 676 | wxString printerName = (LPTSTR)lpDevNames + lpDevNames->wDeviceOffset; |
eaeb6a3c JS |
677 | |
678 | // Not sure if we should check for this mismatch | |
679 | // wxASSERT_MSG( (m_printerName == "" || (devName == m_printerName)), "Printer name obtained from DEVMODE and DEVNAMES were different!"); | |
680 | ||
f6bcfd97 | 681 | if (printerName != wxT("")) |
eaeb6a3c JS |
682 | m_printerName = printerName; |
683 | ||
684 | GlobalUnlock(hDevNames); | |
685 | } | |
686 | } | |
7bcb11d3 | 687 | } |
c801d85f | 688 | |
7bcb11d3 JS |
689 | #endif |
690 | ||
51abe921 | 691 | #ifdef __WXMAC__ |
cfb00da4 | 692 | |
51abe921 SC |
693 | void wxPrintData::ConvertToNative() |
694 | { | |
746d7582 | 695 | m_nativePrintData->TransferFrom( this ) ; |
51abe921 SC |
696 | } |
697 | ||
698 | void wxPrintData::ConvertFromNative() | |
699 | { | |
746d7582 | 700 | m_nativePrintData->TransferTo( this ) ; |
51abe921 | 701 | } |
cfb00da4 | 702 | |
51abe921 SC |
703 | #endif |
704 | ||
7bcb11d3 JS |
705 | void wxPrintData::operator=(const wxPrintData& data) |
706 | { | |
7d610b90 | 707 | #ifdef __WXMAC__ |
746d7582 | 708 | m_nativePrintData->CopyFrom( data.m_nativePrintData ) ; |
7d610b90 | 709 | #endif |
7bcb11d3 JS |
710 | m_printNoCopies = data.m_printNoCopies; |
711 | m_printCollate = data.m_printCollate; | |
712 | m_printOrientation = data.m_printOrientation; | |
713 | m_printerName = data.m_printerName; | |
714 | m_colour = data.m_colour; | |
715 | m_duplexMode = data.m_duplexMode; | |
716 | m_printQuality = data.m_printQuality; | |
717 | m_paperId = data.m_paperId; | |
718 | m_paperSize = data.m_paperSize; | |
244e5e34 VZ |
719 | #ifdef wxUSE_STREAMS |
720 | m_outputstream = data.m_outputstream; | |
721 | #endif | |
7bcb11d3 JS |
722 | |
723 | // PostScript-specific data | |
724 | m_printerCommand = data.m_printerCommand; | |
725 | m_previewCommand = data.m_previewCommand; | |
726 | m_printerOptions = data.m_printerOptions; | |
727 | m_filename = data.m_filename; | |
728 | m_afmPath = data.m_afmPath; | |
729 | m_printerScaleX = data.m_printerScaleX; | |
730 | m_printerScaleY = data.m_printerScaleY; | |
731 | m_printerTranslateX = data.m_printerTranslateX; | |
732 | m_printerTranslateY = data.m_printerTranslateY; | |
733 | m_printMode = data.m_printMode; | |
734 | } | |
735 | ||
58cf0491 JS |
736 | // Is this data OK for showing the print dialog? |
737 | bool wxPrintData::Ok() const | |
738 | { | |
739 | #ifdef __WXMSW__ | |
740 | ((wxPrintData*)this)->ConvertToNative(); | |
741 | return (m_devMode != NULL) ; | |
742 | #else | |
743 | return TRUE; | |
dbc65e27 | 744 | #endif |
58cf0491 | 745 | } |
8826f46f VZ |
746 | |
747 | // ---------------------------------------------------------------------------- | |
748 | // Print dialog data | |
749 | // ---------------------------------------------------------------------------- | |
7bcb11d3 JS |
750 | |
751 | wxPrintDialogData::wxPrintDialogData() | |
752 | { | |
753 | #ifdef __WXMSW__ | |
754 | m_printDlgData = NULL; | |
755 | #endif | |
756 | m_printFromPage = 0; | |
757 | m_printToPage = 0; | |
758 | m_printMinPage = 0; | |
759 | m_printMaxPage = 0; | |
760 | m_printNoCopies = 1; | |
761 | m_printAllPages = FALSE; | |
762 | m_printCollate = FALSE; | |
763 | m_printToFile = FALSE; | |
5360828d | 764 | m_printSelection = FALSE; |
7bcb11d3 JS |
765 | m_printEnableSelection = FALSE; |
766 | m_printEnablePageNumbers = TRUE; | |
767 | m_printEnablePrintToFile = TRUE; | |
768 | m_printEnableHelp = FALSE; | |
769 | m_printSetupDialog = FALSE; | |
770 | } | |
771 | ||
772 | wxPrintDialogData::wxPrintDialogData(const wxPrintDialogData& dialogData) | |
5e472c1f | 773 | : wxObject() |
7bcb11d3 | 774 | { |
7c74e7fe SC |
775 | #ifdef __WXMSW__ |
776 | m_printDlgData = NULL; | |
7c74e7fe | 777 | #endif |
7bcb11d3 JS |
778 | (*this) = dialogData; |
779 | } | |
780 | ||
781 | wxPrintDialogData::wxPrintDialogData(const wxPrintData& printData) | |
782 | { | |
783 | #ifdef __WXMSW__ | |
784 | m_printDlgData = NULL; | |
785 | #endif | |
d2b354f9 | 786 | m_printFromPage = 1; |
7bcb11d3 | 787 | m_printToPage = 0; |
d2b354f9 JS |
788 | m_printMinPage = 1; |
789 | m_printMaxPage = 9999; | |
7bcb11d3 JS |
790 | m_printNoCopies = 1; |
791 | m_printAllPages = FALSE; | |
792 | m_printCollate = FALSE; | |
793 | m_printToFile = FALSE; | |
5360828d | 794 | m_printSelection = FALSE; |
7bcb11d3 JS |
795 | m_printEnableSelection = FALSE; |
796 | m_printEnablePageNumbers = TRUE; | |
797 | m_printEnablePrintToFile = TRUE; | |
798 | m_printEnableHelp = FALSE; | |
799 | m_printSetupDialog = FALSE; | |
800 | ||
801 | m_printData = printData; | |
802 | } | |
803 | ||
804 | wxPrintDialogData::~wxPrintDialogData() | |
805 | { | |
806 | #ifdef __WXMSW__ | |
807 | PRINTDLG *pd = (PRINTDLG *) m_printDlgData; | |
808 | if ( pd && pd->hDevMode ) | |
809 | GlobalFree(pd->hDevMode); | |
810 | if ( pd ) | |
811 | delete pd; | |
812 | #endif | |
813 | } | |
814 | ||
815 | #ifdef __WXMSW__ | |
816 | void wxPrintDialogData::ConvertToNative() | |
817 | { | |
818 | m_printData.ConvertToNative(); | |
819 | ||
820 | PRINTDLG *pd = (PRINTDLG*) m_printDlgData; | |
821 | ||
822 | if (!pd) | |
823 | { | |
824 | pd = new PRINTDLG; | |
161f4f73 | 825 | memset( pd, 0, sizeof(PRINTDLG) ); |
7bcb11d3 JS |
826 | m_printDlgData = (void*) pd; |
827 | ||
828 | // GNU-WIN32 has the wrong size PRINTDLG - can't work out why. | |
829 | #ifdef __GNUWIN32__ | |
161f4f73 | 830 | pd->lStructSize = 66; |
7bcb11d3 | 831 | #else |
7bcb11d3 | 832 | pd->lStructSize = sizeof(PRINTDLG); |
25889d3c | 833 | #endif |
7bcb11d3 JS |
834 | pd->hwndOwner = (HWND)NULL; |
835 | pd->hDevMode = NULL; // Will be created by PrintDlg | |
836 | pd->hDevNames = NULL; // Ditto | |
837 | ||
838 | pd->Flags = PD_RETURNDEFAULT; | |
839 | pd->nCopies = 1; | |
840 | } | |
841 | ||
842 | // Pass the devmode data to the PRINTDLG structure, since it'll | |
843 | // be needed when PrintDlg is called. | |
844 | if (pd->hDevMode) | |
845 | { | |
846 | GlobalFree(pd->hDevMode); | |
847 | } | |
848 | ||
eaeb6a3c JS |
849 | // Pass the devnames data to the PRINTDLG structure, since it'll |
850 | // be needed when PrintDlg is called. | |
851 | if (pd->hDevNames) | |
852 | { | |
853 | GlobalFree(pd->hDevNames); | |
854 | } | |
855 | ||
48c12cb1 | 856 | pd->hDevMode = (HGLOBAL)(DWORD) m_printData.GetNativeData(); |
7bcb11d3 JS |
857 | |
858 | m_printData.SetNativeData((void*) NULL); | |
859 | ||
58cf0491 JS |
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!")); | |
7bcb11d3 | 862 | |
eaeb6a3c JS |
863 | pd->hDevNames = (HGLOBAL)(DWORD) m_printData.GetNativeDataDevNames(); |
864 | ||
865 | m_printData.SetNativeDataDevNames((void*) NULL); | |
866 | ||
7bcb11d3 | 867 | pd->hDC = (HDC) NULL; |
33ac7e6f KB |
868 | pd->nFromPage = (WORD)m_printFromPage; |
869 | pd->nToPage = (WORD)m_printToPage; | |
870 | pd->nMinPage = (WORD)m_printMinPage; | |
871 | pd->nMaxPage = (WORD)m_printMaxPage; | |
872 | pd->nCopies = (WORD)m_printNoCopies; | |
8826f46f | 873 | |
161f4f73 | 874 | pd->Flags = PD_RETURNDC; |
7bcb11d3 JS |
875 | |
876 | #ifdef __GNUWIN32__ | |
161f4f73 | 877 | pd->lStructSize = 66; |
7bcb11d3 JS |
878 | #else |
879 | pd->lStructSize = sizeof( PRINTDLG ); | |
880 | #endif | |
881 | ||
8b9518ee | 882 | pd->hwndOwner=(HWND)NULL; |
eaeb6a3c | 883 | // pd->hDevNames=(HANDLE)NULL; |
c801d85f KB |
884 | pd->hInstance=(HINSTANCE)NULL; |
885 | pd->lCustData = (LPARAM) NULL; | |
886 | pd->lpfnPrintHook = NULL; | |
887 | pd->lpfnSetupHook = NULL; | |
888 | pd->lpPrintTemplateName = NULL; | |
889 | pd->lpSetupTemplateName = NULL; | |
890 | pd->hPrintTemplate = (HGLOBAL) NULL; | |
891 | pd->hSetupTemplate = (HGLOBAL) NULL; | |
8826f46f | 892 | |
7bcb11d3 | 893 | if ( m_printAllPages ) |
c801d85f | 894 | pd->Flags |= PD_ALLPAGES; |
8084a109 | 895 | if ( m_printSelection ) |
5360828d | 896 | pd->Flags |= PD_SELECTION; |
7bcb11d3 | 897 | if ( m_printCollate ) |
c801d85f | 898 | pd->Flags |= PD_COLLATE; |
7bcb11d3 | 899 | if ( m_printToFile ) |
c801d85f | 900 | pd->Flags |= PD_PRINTTOFILE; |
7bcb11d3 | 901 | if ( !m_printEnablePrintToFile ) |
c801d85f | 902 | pd->Flags |= PD_DISABLEPRINTTOFILE; |
7bcb11d3 JS |
903 | if ( !m_printEnableSelection ) |
904 | pd->Flags |= PD_NOSELECTION; | |
905 | if ( !m_printEnablePageNumbers ) | |
906 | pd->Flags |= PD_NOPAGENUMS; | |
d2b354f9 | 907 | else if ( (!m_printAllPages) && (!m_printSelection) && (m_printFromPage != 0) && (m_printToPage != 0)) |
40474984 | 908 | pd->Flags |= PD_PAGENUMS; |
7bcb11d3 JS |
909 | if ( m_printEnableHelp ) |
910 | pd->Flags |= PD_SHOWHELP; | |
911 | if ( m_printSetupDialog ) | |
912 | pd->Flags |= PD_PRINTSETUP; | |
c801d85f KB |
913 | } |
914 | ||
7bcb11d3 | 915 | void wxPrintDialogData::ConvertFromNative() |
c801d85f | 916 | { |
7bcb11d3 | 917 | PRINTDLG *pd = (PRINTDLG*) m_printDlgData; |
c801d85f KB |
918 | if ( pd == NULL ) |
919 | return; | |
920 | ||
7bcb11d3 JS |
921 | // Pass the devmode data back to the wxPrintData structure where it really belongs. |
922 | if (pd->hDevMode) | |
c801d85f | 923 | { |
7bcb11d3 JS |
924 | if (m_printData.GetNativeData()) |
925 | { | |
926 | // Make sure we don't leak memory | |
48c12cb1 | 927 | GlobalFree((HGLOBAL)(DWORD) m_printData.GetNativeData()); |
7bcb11d3 | 928 | } |
aeb50f86 | 929 | m_printData.SetNativeData((void*)(long) pd->hDevMode); |
7bcb11d3 | 930 | pd->hDevMode = NULL; |
c801d85f | 931 | } |
c801d85f | 932 | |
eaeb6a3c JS |
933 | // Pass the devnames data back to the wxPrintData structure where it really belongs. |
934 | if (pd->hDevNames) | |
935 | { | |
936 | if (m_printData.GetNativeDataDevNames()) | |
937 | { | |
938 | // Make sure we don't leak memory | |
939 | GlobalFree((HGLOBAL)(DWORD) m_printData.GetNativeDataDevNames()); | |
940 | } | |
941 | m_printData.SetNativeDataDevNames((void*)(long) pd->hDevNames); | |
942 | pd->hDevNames = NULL; | |
943 | } | |
944 | ||
7bcb11d3 JS |
945 | // Now convert the DEVMODE object, passed down from the PRINTDLG object, |
946 | // into wxWindows form. | |
947 | m_printData.ConvertFromNative(); | |
948 | ||
161f4f73 VZ |
949 | m_printFromPage = pd->nFromPage; |
950 | m_printToPage = pd->nToPage; | |
951 | m_printMinPage = pd->nMinPage; | |
952 | m_printMaxPage = pd->nMaxPage; | |
953 | m_printNoCopies = pd->nCopies; | |
8826f46f | 954 | |
40474984 | 955 | m_printAllPages = (((pd->Flags & PD_PAGENUMS) != PD_PAGENUMS) && ((pd->Flags & PD_SELECTION) != PD_SELECTION)); |
5360828d | 956 | m_printSelection = ((pd->Flags & PD_SELECTION) == PD_SELECTION); |
7bcb11d3 JS |
957 | m_printCollate = ((pd->Flags & PD_COLLATE) == PD_COLLATE); |
958 | m_printToFile = ((pd->Flags & PD_PRINTTOFILE) == PD_PRINTTOFILE); | |
959 | m_printEnablePrintToFile = ((pd->Flags & PD_DISABLEPRINTTOFILE) != PD_DISABLEPRINTTOFILE); | |
960 | m_printEnableSelection = ((pd->Flags & PD_NOSELECTION) != PD_NOSELECTION); | |
961 | m_printEnablePageNumbers = ((pd->Flags & PD_NOPAGENUMS) != PD_NOPAGENUMS); | |
962 | m_printEnableHelp = ((pd->Flags & PD_SHOWHELP) == PD_SHOWHELP); | |
963 | m_printSetupDialog = ((pd->Flags & PD_PRINTSETUP) == PD_PRINTSETUP); | |
964 | ||
965 | /* port is obsolete in WIN32 | |
966 | // Get the port name | |
967 | if (pd->hDevNames) | |
968 | { | |
969 | LPDEVNAMES lpDevNames = (LPDEVNAMES)GlobalLock(pd->hDevNames); | |
970 | if (lpDevNames) { | |
971 | m_printData.SetPortName((LPSTR)lpDevNames + lpDevNames->wDriverOffset); | |
972 | wxString devName = (LPSTR)lpDevNames + lpDevNames->wDeviceOffset; | |
973 | GlobalUnlock(pd->hDevNames); | |
8826f46f | 974 | |
7bcb11d3 JS |
975 | // wxASSERT_MSG( (m_printerName == "" || (devName == m_printerName)), "Printer name obtained from DEVMODE and DEVNAMES were different!"); |
976 | } | |
977 | } | |
978 | */ | |
c801d85f KB |
979 | } |
980 | ||
7bcb11d3 | 981 | void wxPrintDialogData::SetOwnerWindow(wxWindow* win) |
c801d85f | 982 | { |
7bcb11d3 | 983 | if ( m_printDlgData == NULL ) |
c801d85f | 984 | ConvertToNative(); |
8826f46f | 985 | |
7bcb11d3 | 986 | if ( m_printDlgData != NULL && win != NULL) |
c801d85f | 987 | { |
161f4f73 | 988 | PRINTDLG *pd = (PRINTDLG *) m_printDlgData; |
7bcb11d3 | 989 | pd->hwndOwner=(HWND) win->GetHWND(); |
c801d85f KB |
990 | } |
991 | } | |
8826f46f | 992 | #endif // MSW |
c801d85f | 993 | |
51abe921 | 994 | #ifdef __WXMAC__ |
cfb00da4 | 995 | |
51abe921 SC |
996 | void wxPrintDialogData::ConvertToNative() |
997 | { | |
cfb00da4 | 998 | m_printData.ConvertToNative(); |
746d7582 | 999 | m_printData.m_nativePrintData->TransferFrom( this ) ; |
51abe921 SC |
1000 | } |
1001 | ||
1002 | void wxPrintDialogData::ConvertFromNative() | |
1003 | { | |
cfb00da4 | 1004 | m_printData.ConvertFromNative(); |
746d7582 | 1005 | m_printData.m_nativePrintData->TransferTo( this ) ; |
51abe921 | 1006 | } |
cfb00da4 | 1007 | |
51abe921 SC |
1008 | #endif |
1009 | ||
1010 | ||
7bcb11d3 | 1011 | void wxPrintDialogData::operator=(const wxPrintDialogData& data) |
c801d85f | 1012 | { |
7bcb11d3 JS |
1013 | m_printFromPage = data.m_printFromPage; |
1014 | m_printToPage = data.m_printToPage; | |
1015 | m_printMinPage = data.m_printMinPage; | |
1016 | m_printMaxPage = data.m_printMaxPage; | |
1017 | m_printNoCopies = data.m_printNoCopies; | |
1018 | m_printAllPages = data.m_printAllPages; | |
1019 | m_printCollate = data.m_printCollate; | |
1020 | m_printToFile = data.m_printToFile; | |
5360828d | 1021 | m_printSelection = data.m_printSelection; |
7bcb11d3 JS |
1022 | m_printEnableSelection = data.m_printEnableSelection; |
1023 | m_printEnablePageNumbers = data.m_printEnablePageNumbers; | |
1024 | m_printEnableHelp = data.m_printEnableHelp; | |
1025 | m_printEnablePrintToFile = data.m_printEnablePrintToFile; | |
1026 | m_printSetupDialog = data.m_printSetupDialog; | |
1027 | ||
1028 | m_printData = data.m_printData; | |
1029 | } | |
1030 | ||
1031 | void wxPrintDialogData::operator=(const wxPrintData& data) | |
1032 | { | |
1033 | m_printData = data; | |
c801d85f KB |
1034 | } |
1035 | ||
8826f46f VZ |
1036 | // ---------------------------------------------------------------------------- |
1037 | // wxPageSetupDialogData | |
1038 | // ---------------------------------------------------------------------------- | |
c801d85f | 1039 | |
7bcb11d3 | 1040 | wxPageSetupDialogData::wxPageSetupDialogData() |
c801d85f KB |
1041 | { |
1042 | #if defined(__WIN95__) | |
7bcb11d3 | 1043 | m_pageSetupData = NULL; |
c801d85f | 1044 | #endif |
7bcb11d3 JS |
1045 | m_paperSize = wxSize(0, 0); |
1046 | ||
1047 | CalculatePaperSizeFromId(); | |
1048 | ||
1049 | m_minMarginTopLeft = wxPoint(0, 0); | |
1050 | m_minMarginBottomRight = wxPoint(0, 0); | |
1051 | m_marginTopLeft = wxPoint(0, 0); | |
1052 | m_marginBottomRight = wxPoint(0, 0); | |
1053 | ||
1054 | // Flags | |
1055 | m_defaultMinMargins = FALSE; | |
1056 | m_enableMargins = TRUE; | |
1057 | m_enableOrientation = TRUE; | |
1058 | m_enablePaper = TRUE; | |
1059 | m_enablePrinter = TRUE; | |
1060 | m_enableHelp = FALSE; | |
1061 | m_getDefaultInfo = FALSE; | |
1062 | } | |
c801d85f | 1063 | |
7bcb11d3 | 1064 | wxPageSetupDialogData::wxPageSetupDialogData(const wxPageSetupDialogData& dialogData) |
5e472c1f | 1065 | : wxObject() |
7bcb11d3 | 1066 | { |
7c74e7fe SC |
1067 | #if defined(__WIN95__) |
1068 | m_pageSetupData = NULL; | |
7c74e7fe | 1069 | #endif |
7bcb11d3 JS |
1070 | (*this) = dialogData; |
1071 | } | |
1072 | ||
1073 | wxPageSetupDialogData::wxPageSetupDialogData(const wxPrintData& printData) | |
1074 | { | |
1075 | #if defined(__WIN95__) | |
1076 | m_pageSetupData = NULL; | |
1077 | #endif | |
1078 | m_paperSize = wxSize(0, 0); | |
1079 | m_minMarginTopLeft = wxPoint(0, 0); | |
1080 | m_minMarginBottomRight = wxPoint(0, 0); | |
1081 | m_marginTopLeft = wxPoint(0, 0); | |
1082 | m_marginBottomRight = wxPoint(0, 0); | |
1083 | ||
1084 | // Flags | |
1085 | m_defaultMinMargins = FALSE; | |
1086 | m_enableMargins = TRUE; | |
1087 | m_enableOrientation = TRUE; | |
1088 | m_enablePaper = TRUE; | |
1089 | m_enablePrinter = TRUE; | |
1090 | m_enableHelp = FALSE; | |
1091 | m_getDefaultInfo = FALSE; | |
1092 | ||
1093 | m_printData = printData; | |
1094 | ||
1095 | // The wxPrintData paper size overrides these values, unless the size cannot | |
1096 | // be found. | |
1097 | CalculatePaperSizeFromId(); | |
c801d85f KB |
1098 | } |
1099 | ||
7bcb11d3 | 1100 | wxPageSetupDialogData::~wxPageSetupDialogData() |
c801d85f | 1101 | { |
34138703 | 1102 | #if defined(__WIN95__) && defined(__WXMSW__) |
c801d85f KB |
1103 | PAGESETUPDLG *pd = (PAGESETUPDLG *)m_pageSetupData; |
1104 | if ( pd && pd->hDevMode ) | |
1105 | GlobalFree(pd->hDevMode); | |
eaeb6a3c JS |
1106 | if ( pd && pd->hDevNames ) |
1107 | GlobalFree(pd->hDevNames); | |
c801d85f KB |
1108 | if ( pd ) |
1109 | delete pd; | |
1110 | #endif | |
1111 | } | |
1112 | ||
5e472c1f | 1113 | wxPageSetupDialogData& wxPageSetupDialogData::operator=(const wxPageSetupDialogData& data) |
c801d85f | 1114 | { |
7bcb11d3 JS |
1115 | m_paperSize = data.m_paperSize; |
1116 | m_minMarginTopLeft = data.m_minMarginTopLeft; | |
1117 | m_minMarginBottomRight = data.m_minMarginBottomRight; | |
1118 | m_marginTopLeft = data.m_marginTopLeft; | |
1119 | m_marginBottomRight = data.m_marginBottomRight; | |
1120 | m_defaultMinMargins = data.m_defaultMinMargins; | |
1121 | m_enableMargins = data.m_enableMargins; | |
1122 | m_enableOrientation = data.m_enableOrientation; | |
1123 | m_enablePaper = data.m_enablePaper; | |
1124 | m_enablePrinter = data.m_enablePrinter; | |
1125 | m_getDefaultInfo = data.m_getDefaultInfo;; | |
1126 | m_enableHelp = data.m_enableHelp; | |
1127 | ||
1128 | m_printData = data.m_printData; | |
5e472c1f GD |
1129 | |
1130 | return *this; | |
7bcb11d3 | 1131 | } |
c801d85f | 1132 | |
5e472c1f | 1133 | wxPageSetupDialogData& wxPageSetupDialogData::operator=(const wxPrintData& data) |
7bcb11d3 JS |
1134 | { |
1135 | m_printData = data; | |
5e472c1f GD |
1136 | |
1137 | return *this; | |
c801d85f KB |
1138 | } |
1139 | ||
8826f46f | 1140 | #if defined(__WIN95__) |
7bcb11d3 | 1141 | void wxPageSetupDialogData::ConvertToNative() |
c801d85f | 1142 | { |
7bcb11d3 JS |
1143 | m_printData.ConvertToNative(); |
1144 | ||
c801d85f | 1145 | PAGESETUPDLG *pd = (PAGESETUPDLG*) m_pageSetupData; |
7bcb11d3 | 1146 | |
c801d85f KB |
1147 | if ( m_pageSetupData == NULL ) |
1148 | { | |
7bcb11d3 JS |
1149 | pd = new PAGESETUPDLG; |
1150 | pd->hDevMode = NULL; | |
eaeb6a3c | 1151 | pd->hDevNames = NULL; |
7bcb11d3 | 1152 | m_pageSetupData = (void *)pd; |
c801d85f | 1153 | } |
8bbe427f | 1154 | |
7bcb11d3 JS |
1155 | // Pass the devmode data (created in m_printData.ConvertToNative) |
1156 | // to the PRINTDLG structure, since it'll | |
1157 | // be needed when PrintDlg is called. | |
1158 | ||
1159 | if (pd->hDevMode) | |
1160 | { | |
1161 | GlobalFree(pd->hDevMode); | |
1162 | pd->hDevMode = NULL; | |
1163 | } | |
1164 | ||
7bcb11d3 JS |
1165 | pd->hDevMode = (HGLOBAL) m_printData.GetNativeData(); |
1166 | ||
1167 | m_printData.SetNativeData((void*) NULL); | |
1168 | ||
58cf0491 JS |
1169 | // Shouldn't assert; we should be able to test Ok-ness at a higher level |
1170 | //wxASSERT_MSG( (pd->hDevMode), wxT("hDevMode must be non-NULL in ConvertToNative!")); | |
7bcb11d3 | 1171 | |
eaeb6a3c JS |
1172 | // Pass the devnames data (created in m_printData.ConvertToNative) |
1173 | // to the PRINTDLG structure, since it'll | |
1174 | // be needed when PrintDlg is called. | |
1175 | ||
1176 | if (pd->hDevNames) | |
1177 | { | |
1178 | GlobalFree(pd->hDevNames); | |
1179 | pd->hDevNames = NULL; | |
1180 | } | |
1181 | ||
1182 | pd->hDevNames = (HGLOBAL) m_printData.GetNativeDataDevNames(); | |
1183 | ||
1184 | m_printData.SetNativeDataDevNames((void*) NULL); | |
1185 | ||
7bcb11d3 | 1186 | // pd->hDevMode = GlobalAlloc(GMEM_MOVEABLE, sizeof(DEVMODE)); |
c801d85f | 1187 | |
7bcb11d3 | 1188 | pd->Flags = PSD_MARGINS|PSD_MINMARGINS; |
8826f46f | 1189 | |
c801d85f KB |
1190 | if ( m_defaultMinMargins ) |
1191 | pd->Flags |= PSD_DEFAULTMINMARGINS; | |
1192 | if ( !m_enableMargins ) | |
1193 | pd->Flags |= PSD_DISABLEMARGINS; | |
1194 | if ( !m_enableOrientation ) | |
1195 | pd->Flags |= PSD_DISABLEORIENTATION; | |
1196 | if ( !m_enablePaper ) | |
1197 | pd->Flags |= PSD_DISABLEPAPER; | |
1198 | if ( !m_enablePrinter ) | |
1199 | pd->Flags |= PSD_DISABLEPRINTER; | |
1200 | if ( m_getDefaultInfo ) | |
1201 | pd->Flags |= PSD_RETURNDEFAULT; | |
1202 | if ( m_enableHelp ) | |
1203 | pd->Flags |= PSD_SHOWHELP; | |
1204 | ||
7bcb11d3 JS |
1205 | // We want the units to be in hundredths of a millimetre |
1206 | pd->Flags |= PSD_INHUNDREDTHSOFMILLIMETERS; | |
1207 | ||
c801d85f | 1208 | pd->lStructSize = sizeof( PAGESETUPDLG ); |
c4e7c2aa | 1209 | pd->hwndOwner=(HWND)NULL; |
eaeb6a3c | 1210 | // pd->hDevNames=(HWND)NULL; |
c801d85f | 1211 | pd->hInstance=(HINSTANCE)NULL; |
161f4f73 | 1212 | // PAGESETUPDLG is in hundreds of a mm |
7bcb11d3 JS |
1213 | pd->ptPaperSize.x = m_paperSize.x * 100; |
1214 | pd->ptPaperSize.y = m_paperSize.y * 100; | |
8826f46f | 1215 | |
7bcb11d3 JS |
1216 | pd->rtMinMargin.left = m_minMarginTopLeft.x * 100; |
1217 | pd->rtMinMargin.top = m_minMarginTopLeft.y * 100; | |
1218 | pd->rtMinMargin.right = m_minMarginBottomRight.x * 100; | |
1219 | pd->rtMinMargin.bottom = m_minMarginBottomRight.y * 100; | |
8826f46f | 1220 | |
7bcb11d3 JS |
1221 | pd->rtMargin.left = m_marginTopLeft.x * 100; |
1222 | pd->rtMargin.top = m_marginTopLeft.y * 100; | |
1223 | pd->rtMargin.right = m_marginBottomRight.x * 100; | |
1224 | pd->rtMargin.bottom = m_marginBottomRight.y * 100; | |
8826f46f | 1225 | |
c801d85f KB |
1226 | pd->lCustData = 0; |
1227 | pd->lpfnPageSetupHook = NULL; | |
1228 | pd->lpfnPagePaintHook = NULL; | |
1229 | pd->hPageSetupTemplate = NULL; | |
1230 | pd->lpPageSetupTemplateName = NULL; | |
1231 | ||
8826f46f | 1232 | /* |
c801d85f KB |
1233 | if ( pd->hDevMode ) |
1234 | { | |
1235 | DEVMODE *devMode = (DEVMODE*) GlobalLock(pd->hDevMode); | |
1236 | memset(devMode, 0, sizeof(DEVMODE)); | |
1237 | devMode->dmSize = sizeof(DEVMODE); | |
1238 | devMode->dmOrientation = m_orientation; | |
1239 | devMode->dmFields = DM_ORIENTATION; | |
1240 | GlobalUnlock(pd->hDevMode); | |
1241 | } | |
7bcb11d3 | 1242 | */ |
c801d85f KB |
1243 | } |
1244 | ||
7bcb11d3 | 1245 | void wxPageSetupDialogData::ConvertFromNative() |
c801d85f | 1246 | { |
161f4f73 | 1247 | PAGESETUPDLG *pd = (PAGESETUPDLG *) m_pageSetupData; |
c801d85f KB |
1248 | if ( !pd ) |
1249 | return; | |
8826f46f | 1250 | |
7bcb11d3 JS |
1251 | // Pass the devmode data back to the wxPrintData structure where it really belongs. |
1252 | if (pd->hDevMode) | |
1253 | { | |
1254 | if (m_printData.GetNativeData()) | |
1255 | { | |
1256 | // Make sure we don't leak memory | |
1257 | GlobalFree((HGLOBAL) m_printData.GetNativeData()); | |
1258 | } | |
1259 | m_printData.SetNativeData((void*) pd->hDevMode); | |
1260 | pd->hDevMode = NULL; | |
1261 | } | |
c801d85f | 1262 | |
7bcb11d3 | 1263 | m_printData.ConvertFromNative(); |
c801d85f | 1264 | |
eaeb6a3c JS |
1265 | // Pass the devnames data back to the wxPrintData structure where it really belongs. |
1266 | if (pd->hDevNames) | |
1267 | { | |
1268 | if (m_printData.GetNativeDataDevNames()) | |
1269 | { | |
1270 | // Make sure we don't leak memory | |
1271 | GlobalFree((HGLOBAL) m_printData.GetNativeDataDevNames()); | |
1272 | } | |
1273 | m_printData.SetNativeDataDevNames((void*) pd->hDevNames); | |
1274 | pd->hDevNames = NULL; | |
1275 | } | |
1276 | ||
1277 | m_printData.ConvertFromNative(); | |
1278 | ||
7bcb11d3 | 1279 | pd->Flags = PSD_MARGINS|PSD_MINMARGINS; |
8826f46f | 1280 | |
c801d85f KB |
1281 | m_defaultMinMargins = ((pd->Flags & PSD_DEFAULTMINMARGINS) == PSD_DEFAULTMINMARGINS); |
1282 | m_enableMargins = ((pd->Flags & PSD_DISABLEMARGINS) != PSD_DISABLEMARGINS); | |
1283 | m_enableOrientation = ((pd->Flags & PSD_DISABLEORIENTATION) != PSD_DISABLEORIENTATION); | |
1284 | m_enablePaper = ((pd->Flags & PSD_DISABLEPAPER) != PSD_DISABLEPAPER); | |
1285 | m_enablePrinter = ((pd->Flags & PSD_DISABLEPRINTER) != PSD_DISABLEPRINTER); | |
1286 | m_getDefaultInfo = ((pd->Flags & PSD_RETURNDEFAULT) == PSD_RETURNDEFAULT); | |
1287 | m_enableHelp = ((pd->Flags & PSD_SHOWHELP) == PSD_SHOWHELP); | |
8826f46f | 1288 | |
161f4f73 | 1289 | // PAGESETUPDLG is in hundreds of a mm |
7bcb11d3 JS |
1290 | m_paperSize.x = pd->ptPaperSize.x / 100; |
1291 | m_paperSize.y = pd->ptPaperSize.y / 100; | |
8826f46f | 1292 | |
7bcb11d3 JS |
1293 | m_minMarginTopLeft.x = pd->rtMinMargin.left / 100; |
1294 | m_minMarginTopLeft.y = pd->rtMinMargin.top / 100; | |
1295 | m_minMarginBottomRight.x = pd->rtMinMargin.right / 100; | |
1296 | m_minMarginBottomRight.y = pd->rtMinMargin.bottom / 100; | |
8826f46f | 1297 | |
161f4f73 VZ |
1298 | m_marginTopLeft.x = pd->rtMargin.left / 100; |
1299 | m_marginTopLeft.y = pd->rtMargin.top / 100; | |
1300 | m_marginBottomRight.x = pd->rtMargin.right / 100; | |
1301 | m_marginBottomRight.y = pd->rtMargin.bottom / 100; | |
7bcb11d3 | 1302 | } |
c801d85f | 1303 | |
7bcb11d3 JS |
1304 | void wxPageSetupDialogData::SetOwnerWindow(wxWindow* win) |
1305 | { | |
1306 | if ( m_pageSetupData == NULL ) | |
1307 | ConvertToNative(); | |
8826f46f | 1308 | |
7bcb11d3 JS |
1309 | if ( m_pageSetupData != NULL && win != NULL) |
1310 | { | |
161f4f73 | 1311 | PAGESETUPDLG *pd = (PAGESETUPDLG *) m_pageSetupData; |
7bcb11d3 JS |
1312 | pd->hwndOwner=(HWND) win->GetHWND(); |
1313 | } | |
1314 | } | |
8826f46f | 1315 | #endif // Win95 |
c801d85f | 1316 | |
51abe921 | 1317 | #ifdef __WXMAC__ |
7c74e7fe | 1318 | void wxPageSetupDialogData::ConvertToNative() |
51abe921 | 1319 | { |
161f4f73 | 1320 | m_printData.ConvertToNative(); |
746d7582 | 1321 | m_printData.m_nativePrintData->TransferFrom( this ) ; |
51abe921 SC |
1322 | } |
1323 | ||
7c74e7fe | 1324 | void wxPageSetupDialogData::ConvertFromNative() |
51abe921 | 1325 | { |
161f4f73 | 1326 | m_printData.ConvertFromNative (); |
cfb00da4 SC |
1327 | m_paperSize = m_printData.GetPaperSize() ; |
1328 | CalculateIdFromPaperSize(); | |
746d7582 | 1329 | m_printData.m_nativePrintData->TransferTo( this ) ; |
161f4f73 | 1330 | // adjust minimal values |
161f4f73 VZ |
1331 | |
1332 | if ( m_marginTopLeft.x < m_minMarginTopLeft.x ) | |
1333 | m_marginTopLeft.x = m_minMarginTopLeft.x; | |
1334 | ||
1335 | if ( m_marginBottomRight.x < m_minMarginBottomRight.x ) | |
1336 | m_marginBottomRight.x = m_minMarginBottomRight.x; | |
1337 | ||
1338 | if ( m_marginTopLeft.y < m_minMarginTopLeft.y ) | |
1339 | m_marginTopLeft.y = m_minMarginTopLeft.y; | |
1340 | ||
1341 | if ( m_marginBottomRight.y < m_minMarginBottomRight.y ) | |
1342 | m_marginBottomRight.y = m_minMarginBottomRight.y; | |
51abe921 SC |
1343 | } |
1344 | #endif | |
1345 | ||
1346 | ||
7bcb11d3 JS |
1347 | // If a corresponding paper type is found in the paper database, will set the m_printData |
1348 | // paper size id member as well. | |
1349 | void wxPageSetupDialogData::SetPaperSize(const wxSize& sz) | |
1350 | { | |
1351 | m_paperSize = sz; | |
c801d85f | 1352 | |
7bcb11d3 JS |
1353 | CalculateIdFromPaperSize(); |
1354 | } | |
c801d85f | 1355 | |
7bcb11d3 JS |
1356 | // Sets the wxPrintData id, plus the paper width/height if found in the paper database. |
1357 | void wxPageSetupDialogData::SetPaperSize(wxPaperSize id) | |
1358 | { | |
1359 | m_printData.SetPaperId(id); | |
1360 | ||
1361 | CalculatePaperSizeFromId(); | |
c801d85f KB |
1362 | } |
1363 | ||
7bcb11d3 JS |
1364 | // Use paper size defined in this object to set the wxPrintData |
1365 | // paper id | |
1366 | void wxPageSetupDialogData::CalculateIdFromPaperSize() | |
c801d85f | 1367 | { |
8826f46f | 1368 | wxASSERT_MSG( (wxThePrintPaperDatabase != (wxPrintPaperDatabase*) NULL), |
fbdcff4a | 1369 | wxT("wxThePrintPaperDatabase should not be NULL. Do not create global print dialog data objects.") ); |
c801d85f | 1370 | |
7bcb11d3 JS |
1371 | wxSize sz = GetPaperSize(); |
1372 | ||
1373 | wxPaperSize id = wxThePrintPaperDatabase->GetSize(wxSize(sz.x* 10, sz.y * 10)); | |
1374 | if (id != wxPAPER_NONE) | |
c801d85f | 1375 | { |
7bcb11d3 | 1376 | m_printData.SetPaperId(id); |
c801d85f KB |
1377 | } |
1378 | } | |
8826f46f | 1379 | |
7bcb11d3 JS |
1380 | // Use paper id in wxPrintData to set this object's paper size |
1381 | void wxPageSetupDialogData::CalculatePaperSizeFromId() | |
1382 | { | |
8826f46f | 1383 | wxASSERT_MSG( (wxThePrintPaperDatabase != (wxPrintPaperDatabase*) NULL), |
fbdcff4a | 1384 | wxT("wxThePrintPaperDatabase should not be NULL. Do not create global print dialog data objects.") ); |
7bcb11d3 JS |
1385 | |
1386 | wxSize sz = wxThePrintPaperDatabase->GetSize(m_printData.GetPaperId()); | |
c801d85f | 1387 | |
01cf2f95 VZ |
1388 | // sz is in 10ths of a mm, while paper size is in mm |
1389 | m_paperSize.x = sz.x / 10; | |
1390 | m_paperSize.y = sz.y / 10; | |
7bcb11d3 | 1391 | } |
8826f46f | 1392 | |
88ac883a | 1393 | #endif // wxUSE_PRINTING_ARCHITECTURE |