]>
Commit | Line | Data |
---|---|---|
1 | ///////////////////////////////////////////////////////////////////////////// | |
2 | // Name: src/common/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 | |
9 | // Licence: wxWindows licence | |
10 | ///////////////////////////////////////////////////////////////////////////// | |
11 | ||
12 | // ============================================================================ | |
13 | // declarations | |
14 | // ============================================================================ | |
15 | ||
16 | // ---------------------------------------------------------------------------- | |
17 | // headers | |
18 | // ---------------------------------------------------------------------------- | |
19 | ||
20 | // For compilers that support precompilation, includes "wx.h". | |
21 | #include "wx/wxprec.h" | |
22 | ||
23 | #ifdef __BORLANDC__ | |
24 | #pragma hdrstop | |
25 | #endif | |
26 | ||
27 | #include "wx/cmndata.h" | |
28 | ||
29 | #ifndef WX_PRECOMP | |
30 | #if defined(__WXMSW__) | |
31 | #include "wx/msw/wrapcdlg.h" | |
32 | #endif // MSW | |
33 | #include <stdio.h> | |
34 | #include "wx/string.h" | |
35 | #include "wx/utils.h" | |
36 | #include "wx/app.h" | |
37 | #include "wx/log.h" | |
38 | #include "wx/gdicmn.h" | |
39 | #endif | |
40 | ||
41 | #include "wx/prntbase.h" | |
42 | #include "wx/printdlg.h" | |
43 | ||
44 | #if wxUSE_FONTDLG | |
45 | #include "wx/fontdlg.h" | |
46 | #endif // wxUSE_FONTDLG | |
47 | ||
48 | #if wxUSE_PRINTING_ARCHITECTURE | |
49 | ||
50 | #include "wx/paper.h" | |
51 | ||
52 | #if defined(__WXMAC__) | |
53 | #include "wx/mac/private/print.h" | |
54 | #endif | |
55 | ||
56 | IMPLEMENT_DYNAMIC_CLASS(wxPrintData, wxObject) | |
57 | IMPLEMENT_DYNAMIC_CLASS(wxPrintDialogData, wxObject) | |
58 | IMPLEMENT_DYNAMIC_CLASS(wxPageSetupDialogData, wxObject) | |
59 | ||
60 | #endif // wxUSE_PRINTING_ARCHITECTURE | |
61 | ||
62 | IMPLEMENT_DYNAMIC_CLASS(wxFontData, wxObject) | |
63 | IMPLEMENT_DYNAMIC_CLASS(wxColourData, wxObject) | |
64 | ||
65 | // ============================================================================ | |
66 | // implementation | |
67 | // ============================================================================ | |
68 | ||
69 | // ---------------------------------------------------------------------------- | |
70 | // wxColourData | |
71 | // ---------------------------------------------------------------------------- | |
72 | ||
73 | wxColourData::wxColourData() | |
74 | { | |
75 | m_chooseFull = false; | |
76 | m_dataColour.Set(0,0,0); | |
77 | // m_custColours are wxNullColours initially | |
78 | } | |
79 | ||
80 | wxColourData::wxColourData(const wxColourData& data) | |
81 | : wxObject() | |
82 | { | |
83 | (*this) = data; | |
84 | } | |
85 | ||
86 | wxColourData::~wxColourData() | |
87 | { | |
88 | } | |
89 | ||
90 | void wxColourData::SetCustomColour(int i, const wxColour& colour) | |
91 | { | |
92 | wxCHECK_RET( (i >= 0 && i < 16), _T("custom colour index out of range") ); | |
93 | ||
94 | m_custColours[i] = colour; | |
95 | } | |
96 | ||
97 | wxColour wxColourData::GetCustomColour(int i) | |
98 | { | |
99 | wxCHECK_MSG( (i >= 0 && i < 16), wxColour(0,0,0), | |
100 | _T("custom colour index out of range") ); | |
101 | ||
102 | return m_custColours[i]; | |
103 | } | |
104 | ||
105 | void wxColourData::operator=(const wxColourData& data) | |
106 | { | |
107 | int i; | |
108 | for (i = 0; i < 16; i++) | |
109 | m_custColours[i] = data.m_custColours[i]; | |
110 | ||
111 | m_dataColour = (wxColour&)data.m_dataColour; | |
112 | m_chooseFull = data.m_chooseFull; | |
113 | } | |
114 | ||
115 | // ---------------------------------------------------------------------------- | |
116 | // Font data | |
117 | // ---------------------------------------------------------------------------- | |
118 | ||
119 | wxFontData::wxFontData() | |
120 | { | |
121 | // Intialize colour to black. | |
122 | m_fontColour = wxNullColour; | |
123 | ||
124 | m_showHelp = false; | |
125 | m_allowSymbols = true; | |
126 | m_enableEffects = true; | |
127 | m_minSize = 0; | |
128 | m_maxSize = 0; | |
129 | ||
130 | m_encoding = wxFONTENCODING_SYSTEM; | |
131 | } | |
132 | ||
133 | wxFontData::~wxFontData() | |
134 | { | |
135 | } | |
136 | ||
137 | #if wxUSE_FONTDLG | |
138 | ||
139 | wxFontDialogBase::~wxFontDialogBase() | |
140 | { | |
141 | } | |
142 | ||
143 | #endif // wxUSE_FONTDLG | |
144 | ||
145 | #if wxUSE_PRINTING_ARCHITECTURE | |
146 | // ---------------------------------------------------------------------------- | |
147 | // Print data | |
148 | // ---------------------------------------------------------------------------- | |
149 | ||
150 | wxPrintData::wxPrintData() | |
151 | { | |
152 | m_bin = wxPRINTBIN_DEFAULT; | |
153 | m_media = wxPRINTMEDIA_DEFAULT; | |
154 | m_printMode = wxPRINT_MODE_PRINTER; | |
155 | m_printOrientation = wxPORTRAIT; | |
156 | m_printOrientationReversed = false; | |
157 | m_printNoCopies = 1; | |
158 | m_printCollate = false; | |
159 | ||
160 | // New, 24/3/99 | |
161 | m_printerName = wxEmptyString; | |
162 | m_colour = true; | |
163 | m_duplexMode = wxDUPLEX_SIMPLEX; | |
164 | m_printQuality = wxPRINT_QUALITY_HIGH; | |
165 | ||
166 | // we intentionally don't initialize paper id and size at all, like this | |
167 | // the default system settings will be used for them | |
168 | m_paperId = wxPAPER_NONE; | |
169 | m_paperSize = wxDefaultSize; | |
170 | ||
171 | m_privData = NULL; | |
172 | m_privDataLen = 0; | |
173 | ||
174 | m_nativeData = wxPrintFactory::GetFactory()->CreatePrintNativeData(); | |
175 | } | |
176 | ||
177 | wxPrintData::wxPrintData(const wxPrintData& printData) | |
178 | : wxObject() | |
179 | { | |
180 | m_nativeData = NULL; | |
181 | m_privData = NULL; | |
182 | (*this) = printData; | |
183 | } | |
184 | ||
185 | void wxPrintData::SetPrivData( char *privData, int len ) | |
186 | { | |
187 | if (m_privData) | |
188 | { | |
189 | delete [] m_privData; | |
190 | m_privData = NULL; | |
191 | } | |
192 | m_privDataLen = len; | |
193 | if (m_privDataLen > 0) | |
194 | { | |
195 | m_privData = new char[m_privDataLen]; | |
196 | memcpy( m_privData, privData, m_privDataLen ); | |
197 | } | |
198 | } | |
199 | ||
200 | wxPrintData::~wxPrintData() | |
201 | { | |
202 | m_nativeData->m_ref--; | |
203 | if (m_nativeData->m_ref == 0) | |
204 | delete m_nativeData; | |
205 | ||
206 | if (m_privData) | |
207 | delete [] m_privData; | |
208 | } | |
209 | ||
210 | void wxPrintData::ConvertToNative() | |
211 | { | |
212 | m_nativeData->TransferFrom( *this ) ; | |
213 | } | |
214 | ||
215 | void wxPrintData::ConvertFromNative() | |
216 | { | |
217 | m_nativeData->TransferTo( *this ) ; | |
218 | } | |
219 | ||
220 | void wxPrintData::operator=(const wxPrintData& data) | |
221 | { | |
222 | m_printNoCopies = data.m_printNoCopies; | |
223 | m_printCollate = data.m_printCollate; | |
224 | m_printOrientation = data.m_printOrientation; | |
225 | m_printOrientationReversed = data.m_printOrientationReversed; | |
226 | m_printerName = data.m_printerName; | |
227 | m_colour = data.m_colour; | |
228 | m_duplexMode = data.m_duplexMode; | |
229 | m_printQuality = data.m_printQuality; | |
230 | m_paperId = data.m_paperId; | |
231 | m_paperSize = data.m_paperSize; | |
232 | m_bin = data.m_bin; | |
233 | m_media = data.m_media; | |
234 | m_printMode = data.m_printMode; | |
235 | m_filename = data.m_filename; | |
236 | ||
237 | // UnRef old m_nativeData | |
238 | if (m_nativeData) | |
239 | { | |
240 | m_nativeData->m_ref--; | |
241 | if (m_nativeData->m_ref == 0) | |
242 | delete m_nativeData; | |
243 | } | |
244 | // Set Ref new one | |
245 | m_nativeData = data.GetNativeData(); | |
246 | m_nativeData->m_ref++; | |
247 | ||
248 | if (m_privData) | |
249 | { | |
250 | delete [] m_privData; | |
251 | m_privData = NULL; | |
252 | } | |
253 | m_privDataLen = data.GetPrivDataLen(); | |
254 | if (m_privDataLen > 0) | |
255 | { | |
256 | m_privData = new char[m_privDataLen]; | |
257 | memcpy( m_privData, data.GetPrivData(), m_privDataLen ); | |
258 | } | |
259 | } | |
260 | ||
261 | // Is this data OK for showing the print dialog? | |
262 | bool wxPrintData::IsOk() const | |
263 | { | |
264 | m_nativeData->TransferFrom( *this ); | |
265 | ||
266 | return m_nativeData->Ok(); | |
267 | } | |
268 | ||
269 | // What should happen here? wxPostScriptPrintNativeData is not | |
270 | // defined unless all this is true on MSW. | |
271 | #if WXWIN_COMPATIBILITY_2_4 && wxUSE_PRINTING_ARCHITECTURE && (!defined(__WXMSW__) || wxUSE_POSTSCRIPT_ARCHITECTURE_IN_MSW) | |
272 | ||
273 | #include "wx/generic/prntdlgg.h" | |
274 | ||
275 | #if wxUSE_POSTSCRIPT | |
276 | #define WXUNUSED_WITHOUT_PS(name) name | |
277 | #else | |
278 | #define WXUNUSED_WITHOUT_PS(name) WXUNUSED(name) | |
279 | #endif | |
280 | ||
281 | wxString wxPrintData::GetPrinterCommand() const | |
282 | { | |
283 | #if wxUSE_POSTSCRIPT | |
284 | if (m_nativeData && wxIsKindOf(m_nativeData,wxPostScriptPrintNativeData)) | |
285 | return ((wxPostScriptPrintNativeData*)m_nativeData)->GetPrinterCommand(); | |
286 | #endif | |
287 | return wxEmptyString; | |
288 | } | |
289 | ||
290 | wxString wxPrintData::GetPrinterOptions() const | |
291 | { | |
292 | #if wxUSE_POSTSCRIPT | |
293 | if (m_nativeData && wxIsKindOf(m_nativeData,wxPostScriptPrintNativeData)) | |
294 | return ((wxPostScriptPrintNativeData*)m_nativeData)->GetPrinterOptions(); | |
295 | #endif | |
296 | return wxEmptyString; | |
297 | } | |
298 | ||
299 | wxString wxPrintData::GetPreviewCommand() const | |
300 | { | |
301 | #if wxUSE_POSTSCRIPT | |
302 | if (m_nativeData && wxIsKindOf(m_nativeData,wxPostScriptPrintNativeData)) | |
303 | return ((wxPostScriptPrintNativeData*)m_nativeData)->GetPreviewCommand(); | |
304 | #endif | |
305 | return wxEmptyString; | |
306 | } | |
307 | ||
308 | wxString wxPrintData::GetFontMetricPath() const | |
309 | { | |
310 | #if wxUSE_POSTSCRIPT | |
311 | if (m_nativeData && wxIsKindOf(m_nativeData,wxPostScriptPrintNativeData)) | |
312 | return ((wxPostScriptPrintNativeData*)m_nativeData)->GetFontMetricPath(); | |
313 | #endif | |
314 | return wxEmptyString; | |
315 | } | |
316 | ||
317 | double wxPrintData::GetPrinterScaleX() const | |
318 | { | |
319 | #if wxUSE_POSTSCRIPT | |
320 | if (m_nativeData && wxIsKindOf(m_nativeData,wxPostScriptPrintNativeData)) | |
321 | return ((wxPostScriptPrintNativeData*)m_nativeData)->GetPrinterScaleX(); | |
322 | #endif | |
323 | return 1.0; | |
324 | } | |
325 | ||
326 | double wxPrintData::GetPrinterScaleY() const | |
327 | { | |
328 | #if wxUSE_POSTSCRIPT | |
329 | if (m_nativeData && wxIsKindOf(m_nativeData,wxPostScriptPrintNativeData)) | |
330 | return ((wxPostScriptPrintNativeData*)m_nativeData)->GetPrinterScaleY(); | |
331 | #endif | |
332 | return 1.0; | |
333 | } | |
334 | ||
335 | long wxPrintData::GetPrinterTranslateX() const | |
336 | { | |
337 | #if wxUSE_POSTSCRIPT | |
338 | if (m_nativeData && wxIsKindOf(m_nativeData,wxPostScriptPrintNativeData)) | |
339 | return ((wxPostScriptPrintNativeData*)m_nativeData)->GetPrinterTranslateX(); | |
340 | #endif | |
341 | return 0; | |
342 | } | |
343 | ||
344 | long wxPrintData::GetPrinterTranslateY() const | |
345 | { | |
346 | #if wxUSE_POSTSCRIPT | |
347 | if (m_nativeData && wxIsKindOf(m_nativeData,wxPostScriptPrintNativeData)) | |
348 | return ((wxPostScriptPrintNativeData*)m_nativeData)->GetPrinterTranslateY(); | |
349 | #endif | |
350 | return 0; | |
351 | } | |
352 | ||
353 | void wxPrintData::SetPrinterCommand(const wxString& WXUNUSED_WITHOUT_PS(command)) | |
354 | { | |
355 | #if wxUSE_POSTSCRIPT | |
356 | if (m_nativeData && wxIsKindOf(m_nativeData,wxPostScriptPrintNativeData)) | |
357 | ((wxPostScriptPrintNativeData*)m_nativeData)->SetPrinterCommand( command ); | |
358 | #endif | |
359 | } | |
360 | ||
361 | void wxPrintData::SetPrinterOptions(const wxString& WXUNUSED_WITHOUT_PS(options)) | |
362 | { | |
363 | #if wxUSE_POSTSCRIPT | |
364 | if (m_nativeData && wxIsKindOf(m_nativeData,wxPostScriptPrintNativeData)) | |
365 | ((wxPostScriptPrintNativeData*)m_nativeData)->SetPrinterOptions( options ); | |
366 | #endif | |
367 | } | |
368 | ||
369 | void wxPrintData::SetPreviewCommand(const wxString& WXUNUSED_WITHOUT_PS(command)) | |
370 | { | |
371 | #if wxUSE_POSTSCRIPT | |
372 | if (m_nativeData && wxIsKindOf(m_nativeData,wxPostScriptPrintNativeData)) | |
373 | ((wxPostScriptPrintNativeData*)m_nativeData)->SetPreviewCommand( command ); | |
374 | #endif | |
375 | } | |
376 | ||
377 | void wxPrintData::SetFontMetricPath(const wxString& WXUNUSED_WITHOUT_PS(path)) | |
378 | { | |
379 | #if wxUSE_POSTSCRIPT | |
380 | if (m_nativeData && wxIsKindOf(m_nativeData,wxPostScriptPrintNativeData)) | |
381 | ((wxPostScriptPrintNativeData*)m_nativeData)->SetFontMetricPath( path ); | |
382 | #endif | |
383 | } | |
384 | ||
385 | void wxPrintData::SetPrinterScaleX(double WXUNUSED_WITHOUT_PS(x)) | |
386 | { | |
387 | #if wxUSE_POSTSCRIPT | |
388 | if (m_nativeData && wxIsKindOf(m_nativeData,wxPostScriptPrintNativeData)) | |
389 | ((wxPostScriptPrintNativeData*)m_nativeData)->SetPrinterScaleX( x ); | |
390 | #endif | |
391 | } | |
392 | ||
393 | void wxPrintData::SetPrinterScaleY(double WXUNUSED_WITHOUT_PS(y)) | |
394 | { | |
395 | #if wxUSE_POSTSCRIPT | |
396 | if (m_nativeData && wxIsKindOf(m_nativeData,wxPostScriptPrintNativeData)) | |
397 | ((wxPostScriptPrintNativeData*)m_nativeData)->SetPrinterScaleY( y ); | |
398 | #endif | |
399 | } | |
400 | ||
401 | void wxPrintData::SetPrinterScaling(double WXUNUSED_WITHOUT_PS(x), double WXUNUSED_WITHOUT_PS(y)) | |
402 | { | |
403 | #if wxUSE_POSTSCRIPT | |
404 | if (m_nativeData && wxIsKindOf(m_nativeData,wxPostScriptPrintNativeData)) | |
405 | ((wxPostScriptPrintNativeData*)m_nativeData)->SetPrinterScaling( x, y ); | |
406 | #endif | |
407 | } | |
408 | ||
409 | void wxPrintData::SetPrinterTranslateX(long WXUNUSED_WITHOUT_PS(x)) | |
410 | { | |
411 | #if wxUSE_POSTSCRIPT | |
412 | if (m_nativeData && wxIsKindOf(m_nativeData,wxPostScriptPrintNativeData)) | |
413 | ((wxPostScriptPrintNativeData*)m_nativeData)->SetPrinterTranslateX( x ); | |
414 | #endif | |
415 | } | |
416 | ||
417 | void wxPrintData::SetPrinterTranslateY(long WXUNUSED_WITHOUT_PS(y)) | |
418 | { | |
419 | #if wxUSE_POSTSCRIPT | |
420 | if (m_nativeData && wxIsKindOf(m_nativeData,wxPostScriptPrintNativeData)) | |
421 | ((wxPostScriptPrintNativeData*)m_nativeData)->SetPrinterTranslateY( y ); | |
422 | #endif | |
423 | } | |
424 | ||
425 | void wxPrintData::SetPrinterTranslation(long WXUNUSED_WITHOUT_PS(x), long WXUNUSED_WITHOUT_PS(y)) | |
426 | { | |
427 | #if wxUSE_POSTSCRIPT | |
428 | if (m_nativeData && wxIsKindOf(m_nativeData,wxPostScriptPrintNativeData)) | |
429 | ((wxPostScriptPrintNativeData*)m_nativeData)->SetPrinterTranslation( x, y ); | |
430 | #endif | |
431 | } | |
432 | #endif | |
433 | ||
434 | // ---------------------------------------------------------------------------- | |
435 | // Print dialog data | |
436 | // ---------------------------------------------------------------------------- | |
437 | ||
438 | wxPrintDialogData::wxPrintDialogData() | |
439 | { | |
440 | m_printFromPage = 0; | |
441 | m_printToPage = 0; | |
442 | m_printMinPage = 0; | |
443 | m_printMaxPage = 0; | |
444 | m_printNoCopies = 1; | |
445 | m_printAllPages = false; | |
446 | m_printCollate = false; | |
447 | m_printToFile = false; | |
448 | m_printSelection = false; | |
449 | m_printEnableSelection = false; | |
450 | m_printEnablePageNumbers = true; | |
451 | ||
452 | wxPrintFactory* factory = wxPrintFactory::GetFactory(); | |
453 | m_printEnablePrintToFile = ! factory->HasOwnPrintToFile(); | |
454 | ||
455 | m_printEnableHelp = false; | |
456 | #if WXWIN_COMPATIBILITY_2_4 | |
457 | m_printSetupDialog = false; | |
458 | #endif | |
459 | } | |
460 | ||
461 | wxPrintDialogData::wxPrintDialogData(const wxPrintDialogData& dialogData) | |
462 | : wxObject() | |
463 | { | |
464 | (*this) = dialogData; | |
465 | } | |
466 | ||
467 | wxPrintDialogData::wxPrintDialogData(const wxPrintData& printData) | |
468 | { | |
469 | m_printFromPage = 1; | |
470 | m_printToPage = 0; | |
471 | m_printMinPage = 1; | |
472 | m_printMaxPage = 9999; | |
473 | m_printNoCopies = 1; | |
474 | m_printAllPages = false; | |
475 | m_printCollate = false; | |
476 | m_printToFile = false; | |
477 | m_printSelection = false; | |
478 | m_printEnableSelection = false; | |
479 | m_printEnablePageNumbers = true; | |
480 | m_printEnablePrintToFile = true; | |
481 | m_printEnableHelp = false; | |
482 | #if WXWIN_COMPATIBILITY_2_4 | |
483 | m_printSetupDialog = false; | |
484 | #endif | |
485 | m_printData = printData; | |
486 | } | |
487 | ||
488 | wxPrintDialogData::~wxPrintDialogData() | |
489 | { | |
490 | } | |
491 | ||
492 | void wxPrintDialogData::operator=(const wxPrintDialogData& data) | |
493 | { | |
494 | m_printFromPage = data.m_printFromPage; | |
495 | m_printToPage = data.m_printToPage; | |
496 | m_printMinPage = data.m_printMinPage; | |
497 | m_printMaxPage = data.m_printMaxPage; | |
498 | m_printNoCopies = data.m_printNoCopies; | |
499 | m_printAllPages = data.m_printAllPages; | |
500 | m_printCollate = data.m_printCollate; | |
501 | m_printToFile = data.m_printToFile; | |
502 | m_printSelection = data.m_printSelection; | |
503 | m_printEnableSelection = data.m_printEnableSelection; | |
504 | m_printEnablePageNumbers = data.m_printEnablePageNumbers; | |
505 | m_printEnableHelp = data.m_printEnableHelp; | |
506 | m_printEnablePrintToFile = data.m_printEnablePrintToFile; | |
507 | #if WXWIN_COMPATIBILITY_2_4 | |
508 | m_printSetupDialog = data.m_printSetupDialog; | |
509 | #endif | |
510 | m_printData = data.m_printData; | |
511 | } | |
512 | ||
513 | void wxPrintDialogData::operator=(const wxPrintData& data) | |
514 | { | |
515 | m_printData = data; | |
516 | } | |
517 | ||
518 | // ---------------------------------------------------------------------------- | |
519 | // wxPageSetupDialogData | |
520 | // ---------------------------------------------------------------------------- | |
521 | ||
522 | wxPageSetupDialogData::wxPageSetupDialogData() | |
523 | { | |
524 | m_paperSize = wxSize(0,0); | |
525 | ||
526 | CalculatePaperSizeFromId(); | |
527 | ||
528 | m_minMarginTopLeft = | |
529 | m_minMarginBottomRight = | |
530 | m_marginTopLeft = | |
531 | m_marginBottomRight = wxPoint(0,0); | |
532 | ||
533 | // Flags | |
534 | m_defaultMinMargins = false; | |
535 | m_enableMargins = true; | |
536 | m_enableOrientation = true; | |
537 | m_enablePaper = true; | |
538 | m_enablePrinter = true; | |
539 | m_enableHelp = false; | |
540 | m_getDefaultInfo = false; | |
541 | } | |
542 | ||
543 | wxPageSetupDialogData::wxPageSetupDialogData(const wxPageSetupDialogData& dialogData) | |
544 | : wxObject() | |
545 | { | |
546 | (*this) = dialogData; | |
547 | } | |
548 | ||
549 | wxPageSetupDialogData::wxPageSetupDialogData(const wxPrintData& printData) | |
550 | { | |
551 | m_paperSize = wxSize(0,0); | |
552 | m_minMarginTopLeft = | |
553 | m_minMarginBottomRight = | |
554 | m_marginTopLeft = | |
555 | m_marginBottomRight = wxPoint(0,0); | |
556 | ||
557 | // Flags | |
558 | m_defaultMinMargins = false; | |
559 | m_enableMargins = true; | |
560 | m_enableOrientation = true; | |
561 | m_enablePaper = true; | |
562 | m_enablePrinter = true; | |
563 | m_enableHelp = false; | |
564 | m_getDefaultInfo = false; | |
565 | ||
566 | m_printData = printData; | |
567 | ||
568 | // The wxPrintData paper size overrides these values, unless the size cannot | |
569 | // be found. | |
570 | CalculatePaperSizeFromId(); | |
571 | } | |
572 | ||
573 | wxPageSetupDialogData::~wxPageSetupDialogData() | |
574 | { | |
575 | } | |
576 | ||
577 | wxPageSetupDialogData& wxPageSetupDialogData::operator=(const wxPageSetupDialogData& data) | |
578 | { | |
579 | m_paperSize = data.m_paperSize; | |
580 | m_minMarginTopLeft = data.m_minMarginTopLeft; | |
581 | m_minMarginBottomRight = data.m_minMarginBottomRight; | |
582 | m_marginTopLeft = data.m_marginTopLeft; | |
583 | m_marginBottomRight = data.m_marginBottomRight; | |
584 | m_defaultMinMargins = data.m_defaultMinMargins; | |
585 | m_enableMargins = data.m_enableMargins; | |
586 | m_enableOrientation = data.m_enableOrientation; | |
587 | m_enablePaper = data.m_enablePaper; | |
588 | m_enablePrinter = data.m_enablePrinter; | |
589 | m_getDefaultInfo = data.m_getDefaultInfo; | |
590 | m_enableHelp = data.m_enableHelp; | |
591 | ||
592 | m_printData = data.m_printData; | |
593 | ||
594 | return *this; | |
595 | } | |
596 | ||
597 | wxPageSetupDialogData& wxPageSetupDialogData::operator=(const wxPrintData& data) | |
598 | { | |
599 | m_printData = data; | |
600 | CalculatePaperSizeFromId(); | |
601 | ||
602 | return *this; | |
603 | } | |
604 | ||
605 | // If a corresponding paper type is found in the paper database, will set the m_printData | |
606 | // paper size id member as well. | |
607 | void wxPageSetupDialogData::SetPaperSize(const wxSize& sz) | |
608 | { | |
609 | m_paperSize = sz; | |
610 | ||
611 | CalculateIdFromPaperSize(); | |
612 | } | |
613 | ||
614 | // Sets the wxPrintData id, plus the paper width/height if found in the paper database. | |
615 | void wxPageSetupDialogData::SetPaperSize(wxPaperSize id) | |
616 | { | |
617 | m_printData.SetPaperId(id); | |
618 | ||
619 | CalculatePaperSizeFromId(); | |
620 | } | |
621 | ||
622 | void wxPageSetupDialogData::SetPrintData(const wxPrintData& printData) | |
623 | { | |
624 | m_printData = printData; | |
625 | CalculatePaperSizeFromId(); | |
626 | } | |
627 | ||
628 | // Use paper size defined in this object to set the wxPrintData | |
629 | // paper id | |
630 | void wxPageSetupDialogData::CalculateIdFromPaperSize() | |
631 | { | |
632 | wxASSERT_MSG( (wxThePrintPaperDatabase != (wxPrintPaperDatabase*) NULL), | |
633 | wxT("wxThePrintPaperDatabase should not be NULL. Do not create global print dialog data objects.") ); | |
634 | ||
635 | wxSize sz = GetPaperSize(); | |
636 | ||
637 | wxPaperSize id = wxThePrintPaperDatabase->GetSize(wxSize(sz.x* 10, sz.y * 10)); | |
638 | if (id != wxPAPER_NONE) | |
639 | { | |
640 | m_printData.SetPaperId(id); | |
641 | } | |
642 | } | |
643 | ||
644 | // Use paper id in wxPrintData to set this object's paper size | |
645 | void wxPageSetupDialogData::CalculatePaperSizeFromId() | |
646 | { | |
647 | wxASSERT_MSG( (wxThePrintPaperDatabase != (wxPrintPaperDatabase*) NULL), | |
648 | wxT("wxThePrintPaperDatabase should not be NULL. Do not create global print dialog data objects.") ); | |
649 | ||
650 | wxSize sz = wxThePrintPaperDatabase->GetSize(m_printData.GetPaperId()); | |
651 | ||
652 | // sz is in 10ths of a mm, while paper size is in mm | |
653 | m_paperSize.x = sz.x / 10; | |
654 | m_paperSize.y = sz.y / 10; | |
655 | } | |
656 | ||
657 | #endif // wxUSE_PRINTING_ARCHITECTURE |