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