]>
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$ | |
8 | // Copyright: (c) Julian Smart and Markus Holzem | |
8bbe427f | 9 | // Licence: wxWindows licence |
c801d85f KB |
10 | ///////////////////////////////////////////////////////////////////////////// |
11 | ||
8826f46f VZ |
12 | // ============================================================================ |
13 | // declarations | |
14 | // ============================================================================ | |
15 | ||
16 | // ---------------------------------------------------------------------------- | |
17 | // headers | |
18 | // ---------------------------------------------------------------------------- | |
19 | ||
c801d85f | 20 | #ifdef __GNUG__ |
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" | |
8826f46f | 40 | |
7bcb11d3 JS |
41 | #include "wx/paper.h" |
42 | ||
43 | // For compatibility | |
44 | #if (defined(__WXMOTIF__) || defined(__WXGTK__)) && wxUSE_POSTSCRIPT | |
8826f46f | 45 | #define wxCOMPATIBILITY_WITH_PRINTSETUPDATA 1 |
7bcb11d3 | 46 | #endif |
c801d85f | 47 | |
8826f46f VZ |
48 | #if wxCOMPATIBILITY_WITH_PRINTSETUPDATA |
49 | #include "wx/generic/dcpsg.h" | |
c801d85f | 50 | #endif |
7be1f0d9 | 51 | |
8826f46f VZ |
52 | #ifdef __WXMSW__ |
53 | #include <windows.h> | |
7be1f0d9 | 54 | |
8826f46f VZ |
55 | #if !defined(__WIN32__) |
56 | #include <print.h> | |
57 | #include <commdlg.h> | |
58 | #endif // Win16 | |
59 | ||
60 | #if defined(__WATCOMC__) || defined(__SC__) || defined(__SALFORDC__) | |
61 | #include <windowsx.h> | |
62 | #include <commdlg.h> | |
63 | #endif | |
64 | #endif // MSW | |
c801d85f KB |
65 | |
66 | #if !USE_SHARED_LIBRARY | |
8826f46f VZ |
67 | IMPLEMENT_DYNAMIC_CLASS(wxPrintData, wxObject) |
68 | IMPLEMENT_DYNAMIC_CLASS(wxPrintDialogData, wxObject) | |
69 | IMPLEMENT_DYNAMIC_CLASS(wxPageSetupDialogData, wxObject) | |
70 | IMPLEMENT_DYNAMIC_CLASS(wxFontData, wxObject) | |
71 | IMPLEMENT_DYNAMIC_CLASS(wxColourData, wxObject) | |
c801d85f KB |
72 | #endif |
73 | ||
8826f46f VZ |
74 | // ============================================================================ |
75 | // implementation | |
76 | // ============================================================================ | |
77 | ||
78 | // ---------------------------------------------------------------------------- | |
79 | // wxColourData | |
80 | // ---------------------------------------------------------------------------- | |
c801d85f | 81 | |
8bbe427f | 82 | wxColourData::wxColourData() |
c801d85f | 83 | { |
7bcb11d3 JS |
84 | int i; |
85 | for (i = 0; i < 16; i++) | |
86 | custColours[i].Set(255, 255, 255); | |
8826f46f | 87 | |
7bcb11d3 JS |
88 | chooseFull = FALSE; |
89 | dataColour.Set(0,0,0); | |
90 | } | |
c801d85f | 91 | |
7bcb11d3 JS |
92 | wxColourData::wxColourData(const wxColourData& data) |
93 | { | |
94 | (*this) = data; | |
8bbe427f | 95 | } |
c801d85f | 96 | |
8bbe427f | 97 | wxColourData::~wxColourData() |
c801d85f KB |
98 | { |
99 | } | |
100 | ||
101 | void wxColourData::SetCustomColour(int i, wxColour& colour) | |
102 | { | |
7bcb11d3 JS |
103 | if (i > 15 || i < 0) |
104 | return; | |
8826f46f | 105 | |
7bcb11d3 | 106 | custColours[i] = colour; |
c801d85f KB |
107 | } |
108 | ||
109 | wxColour wxColourData::GetCustomColour(int i) | |
110 | { | |
7bcb11d3 JS |
111 | if (i > 15 || i < 0) |
112 | return wxColour(0,0,0); | |
8826f46f | 113 | |
7bcb11d3 | 114 | return custColours[i]; |
c801d85f KB |
115 | } |
116 | ||
117 | void wxColourData::operator=(const wxColourData& data) | |
118 | { | |
7bcb11d3 JS |
119 | int i; |
120 | for (i = 0; i < 16; i++) | |
121 | custColours[i] = data.custColours[i]; | |
8826f46f | 122 | |
7bcb11d3 JS |
123 | dataColour = (wxColour&)data.dataColour; |
124 | chooseFull = data.chooseFull; | |
c801d85f KB |
125 | } |
126 | ||
8826f46f VZ |
127 | // ---------------------------------------------------------------------------- |
128 | // Font data | |
129 | // ---------------------------------------------------------------------------- | |
c801d85f | 130 | |
8bbe427f | 131 | wxFontData::wxFontData() |
c801d85f | 132 | { |
7bcb11d3 JS |
133 | // Intialize colour to black. |
134 | fontColour.Set(0, 0, 0); | |
8826f46f | 135 | |
7bcb11d3 JS |
136 | showHelp = FALSE; |
137 | allowSymbols = TRUE; | |
138 | enableEffects = TRUE; | |
139 | minSize = 0; | |
140 | maxSize = 0; | |
141 | } | |
c801d85f | 142 | |
7bcb11d3 JS |
143 | wxFontData::wxFontData(const wxFontData& data) |
144 | { | |
145 | (*this) = data; | |
c801d85f KB |
146 | } |
147 | ||
8bbe427f | 148 | wxFontData::~wxFontData() |
c801d85f KB |
149 | { |
150 | } | |
151 | ||
152 | void wxFontData::operator=(const wxFontData& data) | |
153 | { | |
7bcb11d3 JS |
154 | fontColour = data.fontColour; |
155 | showHelp = data.showHelp; | |
156 | allowSymbols = data.allowSymbols; | |
157 | enableEffects = data.enableEffects; | |
158 | initialFont = data.initialFont; | |
159 | chosenFont = data.chosenFont; | |
160 | minSize = data.minSize; | |
161 | maxSize = data.maxSize; | |
c801d85f KB |
162 | } |
163 | ||
8826f46f VZ |
164 | // ---------------------------------------------------------------------------- |
165 | // Print data | |
166 | // ---------------------------------------------------------------------------- | |
c801d85f | 167 | |
8bbe427f | 168 | wxPrintData::wxPrintData() |
c801d85f | 169 | { |
2049ba38 | 170 | #ifdef __WXMSW__ |
7bcb11d3 | 171 | m_devMode = NULL; |
c801d85f | 172 | #endif |
7bcb11d3 JS |
173 | m_printOrientation = wxPORTRAIT; |
174 | m_printNoCopies = 1; | |
175 | m_printCollate = FALSE; | |
8826f46f | 176 | |
7bcb11d3 JS |
177 | // New, 24/3/99 |
178 | m_printerName = ""; | |
179 | m_colour = TRUE; | |
180 | m_duplexMode = wxDUPLEX_SIMPLEX; | |
181 | m_printQuality = wxPRINT_QUALITY_HIGH; | |
182 | m_paperId = wxPAPER_A4; | |
183 | m_paperSize = wxSize(210, 297); | |
184 | ||
185 | // PostScript-specific data | |
186 | m_printerCommand = ""; | |
187 | m_previewCommand = ""; | |
188 | m_printerOptions = ""; | |
189 | m_filename = ""; | |
190 | m_afmPath = ""; | |
191 | m_printerScaleX = 1.0; | |
192 | m_printerScaleY = 1.0; | |
193 | m_printerTranslateX = 0; | |
194 | m_printerTranslateY = 0; | |
195 | m_printMode = wxPRINT_MODE_FILE; | |
196 | } | |
197 | ||
198 | wxPrintData::wxPrintData(const wxPrintData& printData) | |
199 | { | |
200 | (*this) = printData; | |
c801d85f KB |
201 | } |
202 | ||
8bbe427f | 203 | wxPrintData::~wxPrintData() |
c801d85f | 204 | { |
2049ba38 | 205 | #ifdef __WXMSW__ |
348675e1 | 206 | HGLOBAL hDevMode = (HGLOBAL) m_devMode; |
7bcb11d3 JS |
207 | if (hDevMode ) |
208 | GlobalFree(hDevMode); | |
c801d85f KB |
209 | #endif |
210 | } | |
211 | ||
2049ba38 | 212 | #ifdef __WXMSW__ |
7bcb11d3 | 213 | |
8bbe427f | 214 | void wxPrintData::ConvertToNative() |
c801d85f | 215 | { |
7bcb11d3 JS |
216 | HGLOBAL hDevMode = (HGLOBAL) m_devMode; |
217 | if (!hDevMode) | |
c801d85f | 218 | { |
7bcb11d3 JS |
219 | // Use PRINTDLG as a way of creating a DEVMODE object |
220 | PRINTDLG *pd = new PRINTDLG; | |
8826f46f | 221 | |
c801d85f | 222 | // GNU-WIN32 has the wrong size PRINTDLG - can't work out why. |
7bcb11d3 | 223 | #ifdef __GNUWIN32__ |
c801d85f | 224 | pd->lStructSize = 66 ; |
7bcb11d3 JS |
225 | memset(pd, 0, sizeof(PRINTDLG)); |
226 | #else | |
227 | pd->lStructSize = sizeof(PRINTDLG); | |
228 | memset(pd, 0, sizeof(PRINTDLG)); | |
229 | #endif | |
230 | ||
c801d85f KB |
231 | pd->hwndOwner = (HWND)NULL; |
232 | pd->hDevMode = NULL; // Will be created by PrintDlg | |
233 | pd->hDevNames = NULL; // Ditto | |
8826f46f | 234 | |
c801d85f KB |
235 | pd->Flags = PD_RETURNDEFAULT; |
236 | pd->nCopies = 1; | |
8826f46f | 237 | |
c801d85f KB |
238 | // Fill out the DEVMODE structure |
239 | // so we can use it as input in the 'real' PrintDlg | |
240 | if (!PrintDlg(pd)) | |
241 | { | |
242 | if ( pd->hDevMode ) | |
243 | GlobalFree(pd->hDevMode); | |
244 | if ( pd->hDevNames ) | |
245 | GlobalFree(pd->hDevNames); | |
246 | pd->hDevMode = NULL; | |
247 | pd->hDevNames = NULL; | |
248 | } | |
249 | else | |
250 | { | |
251 | if ( pd->hDevNames ) | |
252 | GlobalFree(pd->hDevNames); | |
253 | pd->hDevNames = NULL; | |
7bcb11d3 JS |
254 | |
255 | hDevMode = pd->hDevMode; | |
256 | m_devMode = (void*) hDevMode; | |
257 | pd->hDevMode = NULL; | |
c801d85f | 258 | } |
c801d85f | 259 | |
7bcb11d3 JS |
260 | delete pd; |
261 | } | |
8826f46f | 262 | |
7bcb11d3 | 263 | if ( hDevMode ) |
c801d85f | 264 | { |
7bcb11d3 | 265 | DEVMODE *devMode = (DEVMODE*) GlobalLock(hDevMode); |
8826f46f | 266 | |
7bcb11d3 | 267 | //// Orientation |
8826f46f | 268 | |
7bcb11d3 | 269 | devMode->dmOrientation = m_printOrientation; |
c801d85f | 270 | devMode->dmFields = DM_ORIENTATION; |
8826f46f | 271 | |
7bcb11d3 | 272 | //// Collation |
8826f46f | 273 | |
7bcb11d3 JS |
274 | devMode->dmCollate = (m_printCollate ? DMCOLLATE_TRUE : DMCOLLATE_FALSE); |
275 | devMode->dmFields |= DM_COLLATE; | |
8826f46f | 276 | |
7bcb11d3 | 277 | //// Number of copies |
8826f46f | 278 | |
7bcb11d3 JS |
279 | devMode->dmCopies = m_printNoCopies; |
280 | devMode->dmFields |= DM_COPIES; | |
8826f46f | 281 | |
7bcb11d3 | 282 | //// Printer name |
8826f46f | 283 | |
7bcb11d3 JS |
284 | if (m_printerName != "") |
285 | { | |
286 | // TODO: make this Unicode compatible | |
287 | int len = wxMin(31, m_printerName.Len()); | |
288 | int i; | |
289 | for (i = 0; i < len; i++) | |
290 | devMode->dmDeviceName[i] = m_printerName.GetChar(i); | |
291 | devMode->dmDeviceName[i] = 0; | |
292 | } | |
8826f46f | 293 | |
7bcb11d3 | 294 | //// Colour |
8826f46f | 295 | |
7bcb11d3 JS |
296 | if (m_colour) |
297 | devMode->dmColor = DMCOLOR_COLOR; | |
298 | else | |
299 | devMode->dmColor = DMCOLOR_MONOCHROME; | |
8826f46f | 300 | |
7bcb11d3 | 301 | devMode->dmFields |= DM_COLOR; |
8826f46f | 302 | |
7bcb11d3 | 303 | //// Paper size |
8826f46f | 304 | |
7bcb11d3 JS |
305 | if (m_paperId == wxPAPER_NONE) |
306 | { | |
307 | devMode->dmPaperWidth = m_paperSize.x * 10; | |
308 | devMode->dmPaperLength = m_paperSize.y * 10; | |
309 | devMode->dmFields |= DM_PAPERWIDTH; | |
310 | devMode->dmFields |= DM_PAPERLENGTH; | |
311 | } | |
312 | else | |
313 | { | |
314 | if (wxThePrintPaperDatabase) | |
315 | { | |
316 | wxPrintPaperType* paper = wxThePrintPaperDatabase->FindPaperType(m_paperId); | |
317 | if (paper) | |
318 | { | |
319 | devMode->dmPaperSize = paper->GetPlatformId(); | |
320 | devMode->dmFields |= DM_PAPERSIZE; | |
321 | } | |
322 | } | |
323 | } | |
8826f46f | 324 | |
7bcb11d3 | 325 | //// Duplex |
8826f46f | 326 | |
7bcb11d3 JS |
327 | int duplex; |
328 | switch (m_duplexMode) | |
329 | { | |
330 | case wxDUPLEX_HORIZONTAL: { | |
331 | duplex = DMDUP_HORIZONTAL; break; | |
332 | } | |
333 | case wxDUPLEX_VERTICAL: { | |
334 | duplex = DMDUP_VERTICAL; break; | |
335 | } | |
336 | default: | |
337 | case wxDUPLEX_SIMPLEX: { | |
338 | duplex = DMDUP_SIMPLEX; break; | |
339 | } | |
340 | } | |
341 | devMode->dmDuplex = duplex; | |
342 | devMode->dmFields |= DM_DUPLEX; | |
8826f46f | 343 | |
7bcb11d3 | 344 | //// Quality |
8826f46f | 345 | |
7bcb11d3 JS |
346 | int quality; |
347 | switch (m_printQuality) | |
348 | { | |
349 | case wxPRINT_QUALITY_MEDIUM: { | |
350 | quality = DMRES_MEDIUM; break; | |
351 | } | |
352 | case wxPRINT_QUALITY_LOW: { | |
353 | quality = DMRES_LOW; break; | |
354 | } | |
355 | case wxPRINT_QUALITY_DRAFT: { | |
356 | quality = DMRES_DRAFT; break; | |
357 | } | |
358 | case wxPRINT_QUALITY_HIGH: { | |
359 | quality = DMRES_HIGH; break; | |
360 | } | |
361 | default: { | |
362 | quality = m_printQuality; break; | |
363 | } | |
364 | } | |
365 | devMode->dmPrintQuality = quality; | |
366 | devMode->dmFields |= DM_PRINTQUALITY; | |
8826f46f | 367 | |
7bcb11d3 | 368 | GlobalUnlock(hDevMode); |
c801d85f | 369 | } |
7bcb11d3 JS |
370 | } |
371 | ||
372 | void wxPrintData::ConvertFromNative() | |
373 | { | |
374 | HGLOBAL hDevMode = (HGLOBAL) m_devMode; | |
375 | ||
376 | if (!hDevMode) | |
377 | return; | |
378 | ||
379 | if ( hDevMode ) | |
380 | { | |
381 | DEVMODE *devMode = (DEVMODE*) GlobalLock(hDevMode); | |
8826f46f | 382 | |
7bcb11d3 | 383 | //// Orientation |
8826f46f | 384 | |
7bcb11d3 JS |
385 | if (devMode->dmFields & DM_ORIENTATION) |
386 | m_printOrientation = devMode->dmOrientation; | |
8826f46f | 387 | |
7bcb11d3 | 388 | //// Collation |
8826f46f | 389 | |
7bcb11d3 JS |
390 | if (devMode->dmFields & DM_COLLATE) |
391 | { | |
392 | if (devMode->dmCollate == DMCOLLATE_TRUE) | |
393 | m_printCollate = TRUE; | |
394 | else | |
395 | m_printCollate = FALSE; | |
396 | } | |
8826f46f | 397 | |
7bcb11d3 | 398 | //// Number of copies |
8826f46f | 399 | |
7bcb11d3 JS |
400 | if (devMode->dmFields & DM_COPIES) |
401 | { | |
402 | m_printNoCopies = devMode->dmCopies; | |
403 | } | |
8826f46f | 404 | |
7bcb11d3 | 405 | //// Printer name |
8826f46f | 406 | |
7bcb11d3 JS |
407 | if (devMode->dmDeviceName[0] != 0) |
408 | { | |
409 | // TODO: make this Unicode compatible | |
410 | char buf[32]; | |
411 | int i = 0; | |
412 | while (devMode->dmDeviceName[i] != 0) | |
413 | { | |
414 | buf[i] = devMode->dmDeviceName[i]; | |
415 | i ++; | |
416 | } | |
417 | buf[i] = 0; | |
8826f46f | 418 | |
7bcb11d3 JS |
419 | m_printerName = buf; |
420 | } | |
8826f46f | 421 | |
7bcb11d3 | 422 | //// Colour |
8826f46f | 423 | |
7bcb11d3 JS |
424 | if (devMode->dmFields & DM_COLOR) |
425 | { | |
426 | if (devMode->dmColor == DMCOLOR_COLOR) | |
427 | m_colour = TRUE; | |
428 | else | |
429 | m_colour = FALSE; | |
430 | } | |
431 | else | |
432 | m_colour = TRUE; | |
8826f46f | 433 | |
7bcb11d3 | 434 | //// Paper size |
8826f46f | 435 | |
7bcb11d3 JS |
436 | if (devMode->dmFields & DM_PAPERSIZE) |
437 | { | |
438 | if (wxThePrintPaperDatabase) | |
439 | { | |
440 | wxPrintPaperType* paper = wxThePrintPaperDatabase->FindPaperTypeByPlatformId(devMode->dmPaperSize); | |
441 | if (paper) | |
442 | { | |
443 | m_paperId = paper->GetId(); | |
444 | m_paperSize.x = paper->GetWidth() / 10 ; | |
445 | m_paperSize.y = paper->GetHeight() / 10 ; | |
446 | } | |
447 | else | |
448 | { | |
449 | // Shouldn't really get here | |
450 | wxFAIL_MSG("Couldn't find paper size in paper database."); | |
8826f46f | 451 | |
7bcb11d3 JS |
452 | m_paperId = wxPAPER_NONE; |
453 | m_paperSize.x = 0; | |
454 | m_paperSize.y = 0; | |
455 | } | |
456 | } | |
457 | else | |
458 | { | |
459 | // Shouldn't really get here | |
460 | wxFAIL_MSG("Paper database wasn't initialized in wxPrintData::ConvertFromNative."); | |
8826f46f | 461 | |
7bcb11d3 JS |
462 | m_paperId = wxPAPER_NONE; |
463 | m_paperSize.x = 0; | |
464 | m_paperSize.y = 0; | |
465 | } | |
466 | } | |
467 | else if ((devMode->dmFields & DM_PAPERWIDTH) && (devMode->dmFields & DM_PAPERLENGTH)) | |
468 | { | |
469 | m_paperSize.x = devMode->dmPaperWidth / 10; | |
470 | m_paperSize.y = devMode->dmPaperLength / 10; | |
471 | m_paperId = wxPAPER_NONE; | |
472 | } | |
473 | else | |
474 | { | |
475 | // Shouldn't really get here | |
476 | wxFAIL_MSG("Couldn't find paper size from DEVMODE."); | |
8826f46f | 477 | |
7bcb11d3 JS |
478 | m_paperSize.x = 0; |
479 | m_paperSize.y = 0; | |
480 | m_paperId = wxPAPER_NONE; | |
481 | } | |
8826f46f VZ |
482 | |
483 | ||
7bcb11d3 | 484 | //// Duplex |
8826f46f | 485 | |
7bcb11d3 JS |
486 | if (devMode->dmFields & DM_DUPLEX) |
487 | { | |
488 | switch (devMode->dmDuplex) | |
489 | { | |
490 | case DMDUP_HORIZONTAL: { | |
491 | m_duplexMode = wxDUPLEX_HORIZONTAL; break; | |
492 | } | |
493 | case DMDUP_VERTICAL: { | |
494 | m_duplexMode = wxDUPLEX_VERTICAL; break; | |
495 | } | |
496 | default: | |
497 | case DMDUP_SIMPLEX: { | |
498 | m_duplexMode = wxDUPLEX_SIMPLEX; break; | |
499 | } | |
500 | } | |
501 | } | |
502 | else | |
503 | m_duplexMode = wxDUPLEX_SIMPLEX; | |
8826f46f | 504 | |
7bcb11d3 | 505 | //// Quality |
8826f46f | 506 | |
7bcb11d3 JS |
507 | if (devMode->dmFields & DM_PRINTQUALITY) |
508 | { | |
509 | switch (devMode->dmPrintQuality) | |
510 | { | |
511 | case DMRES_MEDIUM: { | |
512 | m_printQuality = wxPRINT_QUALITY_MEDIUM; break; | |
513 | } | |
514 | case DMRES_LOW: { | |
515 | m_printQuality = wxPRINT_QUALITY_LOW; break; | |
516 | } | |
517 | case DMRES_DRAFT: { | |
518 | m_printQuality = wxPRINT_QUALITY_DRAFT; break; | |
519 | } | |
520 | case DMRES_HIGH: { | |
521 | m_printQuality = wxPRINT_QUALITY_HIGH; break; | |
522 | } | |
523 | default: | |
524 | { | |
525 | // TODO: if the printer fills in the resolution in DPI, how | |
526 | // will the application know if it's high, low, draft etc.?? | |
527 | // wxFAIL_MSG("Warning: DM_PRINTQUALITY was not one of the standard values."); | |
528 | m_printQuality = devMode->dmPrintQuality; break; | |
8826f46f | 529 | |
7bcb11d3 JS |
530 | } |
531 | } | |
532 | } | |
533 | else | |
534 | m_printQuality = wxPRINT_QUALITY_HIGH; | |
8826f46f | 535 | |
7bcb11d3 JS |
536 | GlobalUnlock(hDevMode); |
537 | } | |
538 | } | |
c801d85f | 539 | |
7bcb11d3 JS |
540 | #endif |
541 | ||
542 | void wxPrintData::operator=(const wxPrintData& data) | |
543 | { | |
544 | m_printNoCopies = data.m_printNoCopies; | |
545 | m_printCollate = data.m_printCollate; | |
546 | m_printOrientation = data.m_printOrientation; | |
547 | m_printerName = data.m_printerName; | |
548 | m_colour = data.m_colour; | |
549 | m_duplexMode = data.m_duplexMode; | |
550 | m_printQuality = data.m_printQuality; | |
551 | m_paperId = data.m_paperId; | |
552 | m_paperSize = data.m_paperSize; | |
553 | ||
554 | // PostScript-specific data | |
555 | m_printerCommand = data.m_printerCommand; | |
556 | m_previewCommand = data.m_previewCommand; | |
557 | m_printerOptions = data.m_printerOptions; | |
558 | m_filename = data.m_filename; | |
559 | m_afmPath = data.m_afmPath; | |
560 | m_printerScaleX = data.m_printerScaleX; | |
561 | m_printerScaleY = data.m_printerScaleY; | |
562 | m_printerTranslateX = data.m_printerTranslateX; | |
563 | m_printerTranslateY = data.m_printerTranslateY; | |
564 | m_printMode = data.m_printMode; | |
565 | } | |
566 | ||
567 | // For compatibility | |
8826f46f | 568 | #if wxCOMPATIBILITY_WITH_PRINTSETUPDATA |
7bcb11d3 JS |
569 | void wxPrintData::operator=(const wxPrintSetupData& setupData) |
570 | { | |
571 | SetPrinterCommand(setupData.GetPrinterCommand()); | |
572 | SetPreviewCommand(setupData.GetPrintPreviewCommand()); | |
573 | SetPrinterOptions(setupData.GetPrinterOptions()); | |
574 | ||
575 | long xt, yt; | |
576 | setupData.GetPrinterTranslation(& xt, & yt); | |
577 | SetPrinterTranslation(xt, yt); | |
578 | ||
579 | double xs, ys; | |
580 | setupData.GetPrinterScaling(& xs, & ys); | |
581 | SetPrinterScaling(xs, ys); | |
582 | ||
583 | SetOrientation(setupData.GetPrinterOrientation()); | |
584 | SetPrintMode((wxPrintMode) setupData.GetPrinterMode()); | |
585 | SetFontMetricPath(setupData.GetAFMPath()); | |
586 | if (setupData.GetPaperName() != "") | |
587 | SetPaperId(wxThePrintPaperDatabase->ConvertNameToId(setupData.GetPaperName())); | |
588 | SetColour(setupData.GetColour()); | |
589 | SetFilename(setupData.GetPrinterFile()); | |
590 | } | |
8826f46f | 591 | #endif // wxCOMPATIBILITY_WITH_PRINTSETUPDATA |
7bcb11d3 | 592 | |
8826f46f VZ |
593 | |
594 | // ---------------------------------------------------------------------------- | |
595 | // Print dialog data | |
596 | // ---------------------------------------------------------------------------- | |
7bcb11d3 JS |
597 | |
598 | wxPrintDialogData::wxPrintDialogData() | |
599 | { | |
600 | #ifdef __WXMSW__ | |
601 | m_printDlgData = NULL; | |
602 | #endif | |
603 | m_printFromPage = 0; | |
604 | m_printToPage = 0; | |
605 | m_printMinPage = 0; | |
606 | m_printMaxPage = 0; | |
607 | m_printNoCopies = 1; | |
608 | m_printAllPages = FALSE; | |
609 | m_printCollate = FALSE; | |
610 | m_printToFile = FALSE; | |
611 | m_printEnableSelection = FALSE; | |
612 | m_printEnablePageNumbers = TRUE; | |
613 | m_printEnablePrintToFile = TRUE; | |
614 | m_printEnableHelp = FALSE; | |
615 | m_printSetupDialog = FALSE; | |
616 | } | |
617 | ||
618 | wxPrintDialogData::wxPrintDialogData(const wxPrintDialogData& dialogData) | |
619 | { | |
620 | (*this) = dialogData; | |
621 | } | |
622 | ||
623 | wxPrintDialogData::wxPrintDialogData(const wxPrintData& printData) | |
624 | { | |
625 | #ifdef __WXMSW__ | |
626 | m_printDlgData = NULL; | |
627 | #endif | |
628 | m_printFromPage = 0; | |
629 | m_printToPage = 0; | |
630 | m_printMinPage = 0; | |
631 | m_printMaxPage = 0; | |
632 | m_printNoCopies = 1; | |
633 | m_printAllPages = FALSE; | |
634 | m_printCollate = FALSE; | |
635 | m_printToFile = FALSE; | |
636 | m_printEnableSelection = FALSE; | |
637 | m_printEnablePageNumbers = TRUE; | |
638 | m_printEnablePrintToFile = TRUE; | |
639 | m_printEnableHelp = FALSE; | |
640 | m_printSetupDialog = FALSE; | |
641 | ||
642 | m_printData = printData; | |
643 | } | |
644 | ||
645 | wxPrintDialogData::~wxPrintDialogData() | |
646 | { | |
647 | #ifdef __WXMSW__ | |
648 | PRINTDLG *pd = (PRINTDLG *) m_printDlgData; | |
649 | if ( pd && pd->hDevMode ) | |
650 | GlobalFree(pd->hDevMode); | |
651 | if ( pd ) | |
652 | delete pd; | |
653 | #endif | |
654 | } | |
655 | ||
656 | #ifdef __WXMSW__ | |
657 | void wxPrintDialogData::ConvertToNative() | |
658 | { | |
659 | m_printData.ConvertToNative(); | |
660 | ||
661 | PRINTDLG *pd = (PRINTDLG*) m_printDlgData; | |
662 | ||
663 | if (!pd) | |
664 | { | |
665 | pd = new PRINTDLG; | |
666 | m_printDlgData = (void*) pd; | |
667 | ||
668 | // GNU-WIN32 has the wrong size PRINTDLG - can't work out why. | |
669 | #ifdef __GNUWIN32__ | |
670 | pd->lStructSize = 66 ; | |
671 | #else | |
672 | #endif | |
673 | pd->lStructSize = sizeof(PRINTDLG); | |
674 | pd->hwndOwner = (HWND)NULL; | |
675 | pd->hDevMode = NULL; // Will be created by PrintDlg | |
676 | pd->hDevNames = NULL; // Ditto | |
677 | ||
678 | pd->Flags = PD_RETURNDEFAULT; | |
679 | pd->nCopies = 1; | |
680 | } | |
681 | ||
682 | // Pass the devmode data to the PRINTDLG structure, since it'll | |
683 | // be needed when PrintDlg is called. | |
684 | if (pd->hDevMode) | |
685 | { | |
686 | GlobalFree(pd->hDevMode); | |
687 | } | |
688 | ||
689 | pd->hDevMode = (HGLOBAL) m_printData.GetNativeData(); | |
690 | ||
691 | m_printData.SetNativeData((void*) NULL); | |
692 | ||
693 | wxASSERT_MSG( (pd->hDevMode), "hDevMode must be non-NULL in ConvertToNative!"); | |
694 | ||
695 | pd->hDC = (HDC) NULL; | |
696 | pd->nFromPage = (UINT)m_printFromPage; | |
697 | pd->nToPage = (UINT)m_printToPage; | |
698 | pd->nMinPage = (UINT)m_printMinPage; | |
699 | pd->nMaxPage = (UINT)m_printMaxPage; | |
700 | pd->nCopies = (UINT)m_printNoCopies; | |
8826f46f | 701 | |
c801d85f | 702 | pd->Flags = PD_RETURNDC ; |
7bcb11d3 JS |
703 | |
704 | #ifdef __GNUWIN32__ | |
c801d85f | 705 | pd->lStructSize = 66 ; |
7bcb11d3 JS |
706 | #else |
707 | pd->lStructSize = sizeof( PRINTDLG ); | |
708 | #endif | |
709 | ||
8b9518ee | 710 | pd->hwndOwner=(HWND)NULL; |
c801d85f KB |
711 | pd->hDevNames=(HANDLE)NULL; |
712 | pd->hInstance=(HINSTANCE)NULL; | |
713 | pd->lCustData = (LPARAM) NULL; | |
714 | pd->lpfnPrintHook = NULL; | |
715 | pd->lpfnSetupHook = NULL; | |
716 | pd->lpPrintTemplateName = NULL; | |
717 | pd->lpSetupTemplateName = NULL; | |
718 | pd->hPrintTemplate = (HGLOBAL) NULL; | |
719 | pd->hSetupTemplate = (HGLOBAL) NULL; | |
8826f46f | 720 | |
7bcb11d3 | 721 | if ( m_printAllPages ) |
c801d85f | 722 | pd->Flags |= PD_ALLPAGES; |
7bcb11d3 | 723 | if ( m_printCollate ) |
c801d85f | 724 | pd->Flags |= PD_COLLATE; |
7bcb11d3 | 725 | if ( m_printToFile ) |
c801d85f | 726 | pd->Flags |= PD_PRINTTOFILE; |
7bcb11d3 | 727 | if ( !m_printEnablePrintToFile ) |
c801d85f | 728 | pd->Flags |= PD_DISABLEPRINTTOFILE; |
7bcb11d3 JS |
729 | if ( !m_printEnableSelection ) |
730 | pd->Flags |= PD_NOSELECTION; | |
731 | if ( !m_printEnablePageNumbers ) | |
732 | pd->Flags |= PD_NOPAGENUMS; | |
733 | if ( m_printEnableHelp ) | |
734 | pd->Flags |= PD_SHOWHELP; | |
735 | if ( m_printSetupDialog ) | |
736 | pd->Flags |= PD_PRINTSETUP; | |
c801d85f KB |
737 | } |
738 | ||
7bcb11d3 | 739 | void wxPrintDialogData::ConvertFromNative() |
c801d85f | 740 | { |
7bcb11d3 | 741 | PRINTDLG *pd = (PRINTDLG*) m_printDlgData; |
c801d85f KB |
742 | if ( pd == NULL ) |
743 | return; | |
744 | ||
7bcb11d3 JS |
745 | // Pass the devmode data back to the wxPrintData structure where it really belongs. |
746 | if (pd->hDevMode) | |
c801d85f | 747 | { |
7bcb11d3 JS |
748 | if (m_printData.GetNativeData()) |
749 | { | |
750 | // Make sure we don't leak memory | |
751 | GlobalFree((HGLOBAL) m_printData.GetNativeData()); | |
752 | } | |
753 | m_printData.SetNativeData((void*) pd->hDevMode); | |
754 | pd->hDevMode = NULL; | |
c801d85f | 755 | } |
c801d85f | 756 | |
7bcb11d3 JS |
757 | // Now convert the DEVMODE object, passed down from the PRINTDLG object, |
758 | // into wxWindows form. | |
759 | m_printData.ConvertFromNative(); | |
760 | ||
761 | m_printFromPage = pd->nFromPage ; | |
762 | m_printToPage = pd->nToPage ; | |
763 | m_printMinPage = pd->nMinPage ; | |
764 | m_printMaxPage = pd->nMaxPage ; | |
765 | m_printNoCopies = pd->nCopies ; | |
8826f46f | 766 | |
7bcb11d3 JS |
767 | m_printAllPages = ((pd->Flags & PD_ALLPAGES) == PD_ALLPAGES); |
768 | m_printCollate = ((pd->Flags & PD_COLLATE) == PD_COLLATE); | |
769 | m_printToFile = ((pd->Flags & PD_PRINTTOFILE) == PD_PRINTTOFILE); | |
770 | m_printEnablePrintToFile = ((pd->Flags & PD_DISABLEPRINTTOFILE) != PD_DISABLEPRINTTOFILE); | |
771 | m_printEnableSelection = ((pd->Flags & PD_NOSELECTION) != PD_NOSELECTION); | |
772 | m_printEnablePageNumbers = ((pd->Flags & PD_NOPAGENUMS) != PD_NOPAGENUMS); | |
773 | m_printEnableHelp = ((pd->Flags & PD_SHOWHELP) == PD_SHOWHELP); | |
774 | m_printSetupDialog = ((pd->Flags & PD_PRINTSETUP) == PD_PRINTSETUP); | |
775 | ||
776 | /* port is obsolete in WIN32 | |
777 | // Get the port name | |
778 | if (pd->hDevNames) | |
779 | { | |
780 | LPDEVNAMES lpDevNames = (LPDEVNAMES)GlobalLock(pd->hDevNames); | |
781 | if (lpDevNames) { | |
782 | m_printData.SetPortName((LPSTR)lpDevNames + lpDevNames->wDriverOffset); | |
783 | wxString devName = (LPSTR)lpDevNames + lpDevNames->wDeviceOffset; | |
784 | GlobalUnlock(pd->hDevNames); | |
8826f46f | 785 | |
7bcb11d3 JS |
786 | // wxASSERT_MSG( (m_printerName == "" || (devName == m_printerName)), "Printer name obtained from DEVMODE and DEVNAMES were different!"); |
787 | } | |
788 | } | |
789 | */ | |
c801d85f KB |
790 | } |
791 | ||
7bcb11d3 | 792 | void wxPrintDialogData::SetOwnerWindow(wxWindow* win) |
c801d85f | 793 | { |
7bcb11d3 | 794 | if ( m_printDlgData == NULL ) |
c801d85f | 795 | ConvertToNative(); |
8826f46f | 796 | |
7bcb11d3 | 797 | if ( m_printDlgData != NULL && win != NULL) |
c801d85f | 798 | { |
7bcb11d3 JS |
799 | PRINTDLG *pd = (PRINTDLG *) m_printDlgData ; |
800 | pd->hwndOwner=(HWND) win->GetHWND(); | |
c801d85f KB |
801 | } |
802 | } | |
8826f46f | 803 | #endif // MSW |
c801d85f | 804 | |
7bcb11d3 | 805 | void wxPrintDialogData::operator=(const wxPrintDialogData& data) |
c801d85f | 806 | { |
7bcb11d3 JS |
807 | m_printFromPage = data.m_printFromPage; |
808 | m_printToPage = data.m_printToPage; | |
809 | m_printMinPage = data.m_printMinPage; | |
810 | m_printMaxPage = data.m_printMaxPage; | |
811 | m_printNoCopies = data.m_printNoCopies; | |
812 | m_printAllPages = data.m_printAllPages; | |
813 | m_printCollate = data.m_printCollate; | |
814 | m_printToFile = data.m_printToFile; | |
815 | m_printEnableSelection = data.m_printEnableSelection; | |
816 | m_printEnablePageNumbers = data.m_printEnablePageNumbers; | |
817 | m_printEnableHelp = data.m_printEnableHelp; | |
818 | m_printEnablePrintToFile = data.m_printEnablePrintToFile; | |
819 | m_printSetupDialog = data.m_printSetupDialog; | |
820 | ||
821 | m_printData = data.m_printData; | |
822 | } | |
823 | ||
824 | void wxPrintDialogData::operator=(const wxPrintData& data) | |
825 | { | |
826 | m_printData = data; | |
c801d85f KB |
827 | } |
828 | ||
8826f46f VZ |
829 | // ---------------------------------------------------------------------------- |
830 | // wxPageSetupDialogData | |
831 | // ---------------------------------------------------------------------------- | |
c801d85f | 832 | |
7bcb11d3 | 833 | wxPageSetupDialogData::wxPageSetupDialogData() |
c801d85f KB |
834 | { |
835 | #if defined(__WIN95__) | |
7bcb11d3 | 836 | m_pageSetupData = NULL; |
c801d85f | 837 | #endif |
7bcb11d3 JS |
838 | m_paperSize = wxSize(0, 0); |
839 | ||
840 | CalculatePaperSizeFromId(); | |
841 | ||
842 | m_minMarginTopLeft = wxPoint(0, 0); | |
843 | m_minMarginBottomRight = wxPoint(0, 0); | |
844 | m_marginTopLeft = wxPoint(0, 0); | |
845 | m_marginBottomRight = wxPoint(0, 0); | |
846 | ||
847 | // Flags | |
848 | m_defaultMinMargins = FALSE; | |
849 | m_enableMargins = TRUE; | |
850 | m_enableOrientation = TRUE; | |
851 | m_enablePaper = TRUE; | |
852 | m_enablePrinter = TRUE; | |
853 | m_enableHelp = FALSE; | |
854 | m_getDefaultInfo = FALSE; | |
855 | } | |
c801d85f | 856 | |
7bcb11d3 JS |
857 | wxPageSetupDialogData::wxPageSetupDialogData(const wxPageSetupDialogData& dialogData) |
858 | { | |
859 | (*this) = dialogData; | |
860 | } | |
861 | ||
862 | wxPageSetupDialogData::wxPageSetupDialogData(const wxPrintData& printData) | |
863 | { | |
864 | #if defined(__WIN95__) | |
865 | m_pageSetupData = NULL; | |
866 | #endif | |
867 | m_paperSize = wxSize(0, 0); | |
868 | m_minMarginTopLeft = wxPoint(0, 0); | |
869 | m_minMarginBottomRight = wxPoint(0, 0); | |
870 | m_marginTopLeft = wxPoint(0, 0); | |
871 | m_marginBottomRight = wxPoint(0, 0); | |
872 | ||
873 | // Flags | |
874 | m_defaultMinMargins = FALSE; | |
875 | m_enableMargins = TRUE; | |
876 | m_enableOrientation = TRUE; | |
877 | m_enablePaper = TRUE; | |
878 | m_enablePrinter = TRUE; | |
879 | m_enableHelp = FALSE; | |
880 | m_getDefaultInfo = FALSE; | |
881 | ||
882 | m_printData = printData; | |
883 | ||
884 | // The wxPrintData paper size overrides these values, unless the size cannot | |
885 | // be found. | |
886 | CalculatePaperSizeFromId(); | |
c801d85f KB |
887 | } |
888 | ||
7bcb11d3 | 889 | wxPageSetupDialogData::~wxPageSetupDialogData() |
c801d85f | 890 | { |
34138703 | 891 | #if defined(__WIN95__) && defined(__WXMSW__) |
c801d85f KB |
892 | PAGESETUPDLG *pd = (PAGESETUPDLG *)m_pageSetupData; |
893 | if ( pd && pd->hDevMode ) | |
894 | GlobalFree(pd->hDevMode); | |
895 | if ( pd ) | |
896 | delete pd; | |
897 | #endif | |
898 | } | |
899 | ||
7bcb11d3 | 900 | void wxPageSetupDialogData::operator=(const wxPageSetupDialogData& data) |
c801d85f | 901 | { |
7bcb11d3 JS |
902 | m_paperSize = data.m_paperSize; |
903 | m_minMarginTopLeft = data.m_minMarginTopLeft; | |
904 | m_minMarginBottomRight = data.m_minMarginBottomRight; | |
905 | m_marginTopLeft = data.m_marginTopLeft; | |
906 | m_marginBottomRight = data.m_marginBottomRight; | |
907 | m_defaultMinMargins = data.m_defaultMinMargins; | |
908 | m_enableMargins = data.m_enableMargins; | |
909 | m_enableOrientation = data.m_enableOrientation; | |
910 | m_enablePaper = data.m_enablePaper; | |
911 | m_enablePrinter = data.m_enablePrinter; | |
912 | m_getDefaultInfo = data.m_getDefaultInfo;; | |
913 | m_enableHelp = data.m_enableHelp; | |
914 | ||
915 | m_printData = data.m_printData; | |
916 | } | |
c801d85f | 917 | |
7bcb11d3 JS |
918 | void wxPageSetupDialogData::operator=(const wxPrintData& data) |
919 | { | |
920 | m_printData = data; | |
c801d85f KB |
921 | } |
922 | ||
8826f46f | 923 | #if defined(__WIN95__) |
7bcb11d3 | 924 | void wxPageSetupDialogData::ConvertToNative() |
c801d85f | 925 | { |
7bcb11d3 JS |
926 | m_printData.ConvertToNative(); |
927 | ||
c801d85f | 928 | PAGESETUPDLG *pd = (PAGESETUPDLG*) m_pageSetupData; |
7bcb11d3 | 929 | |
c801d85f KB |
930 | if ( m_pageSetupData == NULL ) |
931 | { | |
7bcb11d3 JS |
932 | pd = new PAGESETUPDLG; |
933 | pd->hDevMode = NULL; | |
934 | m_pageSetupData = (void *)pd; | |
c801d85f | 935 | } |
8bbe427f | 936 | |
7bcb11d3 JS |
937 | // Pass the devmode data (created in m_printData.ConvertToNative) |
938 | // to the PRINTDLG structure, since it'll | |
939 | // be needed when PrintDlg is called. | |
940 | ||
941 | if (pd->hDevMode) | |
942 | { | |
943 | GlobalFree(pd->hDevMode); | |
944 | pd->hDevMode = NULL; | |
945 | } | |
946 | ||
947 | ||
948 | pd->hDevMode = (HGLOBAL) m_printData.GetNativeData(); | |
949 | ||
950 | m_printData.SetNativeData((void*) NULL); | |
951 | ||
952 | wxASSERT_MSG( (pd->hDevMode), "hDevMode must be non-NULL in ConvertToNative!"); | |
953 | ||
954 | // pd->hDevMode = GlobalAlloc(GMEM_MOVEABLE, sizeof(DEVMODE)); | |
c801d85f | 955 | |
7bcb11d3 | 956 | pd->Flags = PSD_MARGINS|PSD_MINMARGINS; |
8826f46f | 957 | |
c801d85f KB |
958 | if ( m_defaultMinMargins ) |
959 | pd->Flags |= PSD_DEFAULTMINMARGINS; | |
960 | if ( !m_enableMargins ) | |
961 | pd->Flags |= PSD_DISABLEMARGINS; | |
962 | if ( !m_enableOrientation ) | |
963 | pd->Flags |= PSD_DISABLEORIENTATION; | |
964 | if ( !m_enablePaper ) | |
965 | pd->Flags |= PSD_DISABLEPAPER; | |
966 | if ( !m_enablePrinter ) | |
967 | pd->Flags |= PSD_DISABLEPRINTER; | |
968 | if ( m_getDefaultInfo ) | |
969 | pd->Flags |= PSD_RETURNDEFAULT; | |
970 | if ( m_enableHelp ) | |
971 | pd->Flags |= PSD_SHOWHELP; | |
972 | ||
7bcb11d3 JS |
973 | // We want the units to be in hundredths of a millimetre |
974 | pd->Flags |= PSD_INHUNDREDTHSOFMILLIMETERS; | |
975 | ||
c801d85f | 976 | pd->lStructSize = sizeof( PAGESETUPDLG ); |
c4e7c2aa | 977 | pd->hwndOwner=(HWND)NULL; |
c801d85f KB |
978 | pd->hDevNames=(HWND)NULL; |
979 | pd->hInstance=(HINSTANCE)NULL; | |
8826f46f | 980 | |
7bcb11d3 JS |
981 | pd->ptPaperSize.x = m_paperSize.x * 100; |
982 | pd->ptPaperSize.y = m_paperSize.y * 100; | |
8826f46f | 983 | |
7bcb11d3 JS |
984 | pd->rtMinMargin.left = m_minMarginTopLeft.x * 100; |
985 | pd->rtMinMargin.top = m_minMarginTopLeft.y * 100; | |
986 | pd->rtMinMargin.right = m_minMarginBottomRight.x * 100; | |
987 | pd->rtMinMargin.bottom = m_minMarginBottomRight.y * 100; | |
8826f46f | 988 | |
7bcb11d3 JS |
989 | pd->rtMargin.left = m_marginTopLeft.x * 100; |
990 | pd->rtMargin.top = m_marginTopLeft.y * 100; | |
991 | pd->rtMargin.right = m_marginBottomRight.x * 100; | |
992 | pd->rtMargin.bottom = m_marginBottomRight.y * 100; | |
8826f46f | 993 | |
c801d85f KB |
994 | pd->lCustData = 0; |
995 | pd->lpfnPageSetupHook = NULL; | |
996 | pd->lpfnPagePaintHook = NULL; | |
997 | pd->hPageSetupTemplate = NULL; | |
998 | pd->lpPageSetupTemplateName = NULL; | |
999 | ||
8826f46f | 1000 | /* |
c801d85f KB |
1001 | if ( pd->hDevMode ) |
1002 | { | |
1003 | DEVMODE *devMode = (DEVMODE*) GlobalLock(pd->hDevMode); | |
1004 | memset(devMode, 0, sizeof(DEVMODE)); | |
1005 | devMode->dmSize = sizeof(DEVMODE); | |
1006 | devMode->dmOrientation = m_orientation; | |
1007 | devMode->dmFields = DM_ORIENTATION; | |
1008 | GlobalUnlock(pd->hDevMode); | |
1009 | } | |
7bcb11d3 | 1010 | */ |
c801d85f KB |
1011 | } |
1012 | ||
7bcb11d3 | 1013 | void wxPageSetupDialogData::ConvertFromNative() |
c801d85f KB |
1014 | { |
1015 | PAGESETUPDLG *pd = (PAGESETUPDLG *) m_pageSetupData ; | |
1016 | if ( !pd ) | |
1017 | return; | |
8826f46f | 1018 | |
7bcb11d3 JS |
1019 | // Pass the devmode data back to the wxPrintData structure where it really belongs. |
1020 | if (pd->hDevMode) | |
1021 | { | |
1022 | if (m_printData.GetNativeData()) | |
1023 | { | |
1024 | // Make sure we don't leak memory | |
1025 | GlobalFree((HGLOBAL) m_printData.GetNativeData()); | |
1026 | } | |
1027 | m_printData.SetNativeData((void*) pd->hDevMode); | |
1028 | pd->hDevMode = NULL; | |
1029 | } | |
c801d85f | 1030 | |
7bcb11d3 | 1031 | m_printData.ConvertFromNative(); |
c801d85f | 1032 | |
7bcb11d3 | 1033 | pd->Flags = PSD_MARGINS|PSD_MINMARGINS; |
8826f46f | 1034 | |
c801d85f KB |
1035 | m_defaultMinMargins = ((pd->Flags & PSD_DEFAULTMINMARGINS) == PSD_DEFAULTMINMARGINS); |
1036 | m_enableMargins = ((pd->Flags & PSD_DISABLEMARGINS) != PSD_DISABLEMARGINS); | |
1037 | m_enableOrientation = ((pd->Flags & PSD_DISABLEORIENTATION) != PSD_DISABLEORIENTATION); | |
1038 | m_enablePaper = ((pd->Flags & PSD_DISABLEPAPER) != PSD_DISABLEPAPER); | |
1039 | m_enablePrinter = ((pd->Flags & PSD_DISABLEPRINTER) != PSD_DISABLEPRINTER); | |
1040 | m_getDefaultInfo = ((pd->Flags & PSD_RETURNDEFAULT) == PSD_RETURNDEFAULT); | |
1041 | m_enableHelp = ((pd->Flags & PSD_SHOWHELP) == PSD_SHOWHELP); | |
8826f46f | 1042 | |
7bcb11d3 JS |
1043 | m_paperSize.x = pd->ptPaperSize.x / 100; |
1044 | m_paperSize.y = pd->ptPaperSize.y / 100; | |
8826f46f | 1045 | |
7bcb11d3 JS |
1046 | m_minMarginTopLeft.x = pd->rtMinMargin.left / 100; |
1047 | m_minMarginTopLeft.y = pd->rtMinMargin.top / 100; | |
1048 | m_minMarginBottomRight.x = pd->rtMinMargin.right / 100; | |
1049 | m_minMarginBottomRight.y = pd->rtMinMargin.bottom / 100; | |
8826f46f | 1050 | |
7bcb11d3 JS |
1051 | m_marginTopLeft.x = pd->rtMargin.left / 100 ; |
1052 | m_marginTopLeft.y = pd->rtMargin.top / 100 ; | |
1053 | m_marginBottomRight.x = pd->rtMargin.right / 100 ; | |
1054 | m_marginBottomRight.y = pd->rtMargin.bottom / 100 ; | |
1055 | } | |
c801d85f | 1056 | |
7bcb11d3 JS |
1057 | void wxPageSetupDialogData::SetOwnerWindow(wxWindow* win) |
1058 | { | |
1059 | if ( m_pageSetupData == NULL ) | |
1060 | ConvertToNative(); | |
8826f46f | 1061 | |
7bcb11d3 JS |
1062 | if ( m_pageSetupData != NULL && win != NULL) |
1063 | { | |
1064 | PAGESETUPDLG *pd = (PAGESETUPDLG *) m_pageSetupData ; | |
1065 | pd->hwndOwner=(HWND) win->GetHWND(); | |
1066 | } | |
1067 | } | |
8826f46f | 1068 | #endif // Win95 |
c801d85f | 1069 | |
7bcb11d3 JS |
1070 | // If a corresponding paper type is found in the paper database, will set the m_printData |
1071 | // paper size id member as well. | |
1072 | void wxPageSetupDialogData::SetPaperSize(const wxSize& sz) | |
1073 | { | |
1074 | m_paperSize = sz; | |
c801d85f | 1075 | |
7bcb11d3 JS |
1076 | CalculateIdFromPaperSize(); |
1077 | } | |
c801d85f | 1078 | |
7bcb11d3 JS |
1079 | // Sets the wxPrintData id, plus the paper width/height if found in the paper database. |
1080 | void wxPageSetupDialogData::SetPaperSize(wxPaperSize id) | |
1081 | { | |
1082 | m_printData.SetPaperId(id); | |
1083 | ||
1084 | CalculatePaperSizeFromId(); | |
c801d85f KB |
1085 | } |
1086 | ||
7bcb11d3 JS |
1087 | // Use paper size defined in this object to set the wxPrintData |
1088 | // paper id | |
1089 | void wxPageSetupDialogData::CalculateIdFromPaperSize() | |
c801d85f | 1090 | { |
8826f46f VZ |
1091 | wxASSERT_MSG( (wxThePrintPaperDatabase != (wxPrintPaperDatabase*) NULL), |
1092 | "wxThePrintPaperDatabase should not be NULL. " | |
1093 | "Do not create global print dialog data objects." ); | |
c801d85f | 1094 | |
7bcb11d3 JS |
1095 | wxSize sz = GetPaperSize(); |
1096 | ||
1097 | wxPaperSize id = wxThePrintPaperDatabase->GetSize(wxSize(sz.x* 10, sz.y * 10)); | |
1098 | if (id != wxPAPER_NONE) | |
c801d85f | 1099 | { |
7bcb11d3 | 1100 | m_printData.SetPaperId(id); |
c801d85f KB |
1101 | } |
1102 | } | |
8826f46f | 1103 | |
7bcb11d3 JS |
1104 | // Use paper id in wxPrintData to set this object's paper size |
1105 | void wxPageSetupDialogData::CalculatePaperSizeFromId() | |
1106 | { | |
8826f46f VZ |
1107 | wxASSERT_MSG( (wxThePrintPaperDatabase != (wxPrintPaperDatabase*) NULL), |
1108 | "wxThePrintPaperDatabase should not be NULL. " | |
1109 | "Do not create global print dialog data objects." ); | |
7bcb11d3 JS |
1110 | |
1111 | wxSize sz = wxThePrintPaperDatabase->GetSize(m_printData.GetPaperId()); | |
c801d85f | 1112 | |
7bcb11d3 JS |
1113 | if (sz.x != 0) |
1114 | { | |
1115 | // sz is in 10ths of a mm, so multiply by 10. | |
1116 | m_paperSize.x = sz.x * 10; | |
1117 | m_paperSize.y = sz.y * 10; | |
1118 | } | |
1119 | } | |
8826f46f | 1120 |