]>
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_printNoCopies = 1; | |
157 | m_printCollate = false; | |
158 | ||
159 | // New, 24/3/99 | |
160 | m_printerName = wxEmptyString; | |
161 | m_colour = true; | |
162 | m_duplexMode = wxDUPLEX_SIMPLEX; | |
163 | m_printQuality = wxPRINT_QUALITY_HIGH; | |
164 | ||
165 | // we intentionally don't initialize paper id and size at all, like this | |
166 | // the default system settings will be used for them | |
167 | m_paperId = wxPAPER_NONE; | |
168 | m_paperSize = wxDefaultSize; | |
169 | ||
170 | m_privData = NULL; | |
171 | m_privDataLen = 0; | |
172 | ||
173 | m_nativeData = wxPrintFactory::GetFactory()->CreatePrintNativeData(); | |
174 | } | |
175 | ||
176 | wxPrintData::wxPrintData(const wxPrintData& printData) | |
177 | : wxObject() | |
178 | { | |
179 | m_nativeData = NULL; | |
180 | m_privData = NULL; | |
181 | (*this) = printData; | |
182 | } | |
183 | ||
184 | void wxPrintData::SetPrivData( char *privData, int len ) | |
185 | { | |
186 | if (m_privData) | |
187 | { | |
188 | delete [] m_privData; | |
189 | m_privData = NULL; | |
190 | } | |
191 | m_privDataLen = len; | |
192 | if (m_privDataLen > 0) | |
193 | { | |
194 | m_privData = new char[m_privDataLen]; | |
195 | memcpy( m_privData, privData, m_privDataLen ); | |
196 | } | |
197 | } | |
198 | ||
199 | wxPrintData::~wxPrintData() | |
200 | { | |
201 | m_nativeData->m_ref--; | |
202 | if (m_nativeData->m_ref == 0) | |
203 | delete m_nativeData; | |
204 | ||
205 | if (m_privData) | |
206 | delete [] m_privData; | |
207 | } | |
208 | ||
209 | void wxPrintData::ConvertToNative() | |
210 | { | |
211 | m_nativeData->TransferFrom( *this ) ; | |
212 | } | |
213 | ||
214 | void wxPrintData::ConvertFromNative() | |
215 | { | |
216 | m_nativeData->TransferTo( *this ) ; | |
217 | } | |
218 | ||
219 | void wxPrintData::operator=(const wxPrintData& data) | |
220 | { | |
221 | m_printNoCopies = data.m_printNoCopies; | |
222 | m_printCollate = data.m_printCollate; | |
223 | m_printOrientation = data.m_printOrientation; | |
224 | m_printerName = data.m_printerName; | |
225 | m_colour = data.m_colour; | |
226 | m_duplexMode = data.m_duplexMode; | |
227 | m_printQuality = data.m_printQuality; | |
228 | m_paperId = data.m_paperId; | |
229 | m_paperSize = data.m_paperSize; | |
230 | m_bin = data.m_bin; | |
231 | m_media = data.m_media; | |
232 | m_printMode = data.m_printMode; | |
233 | m_filename = data.m_filename; | |
234 | ||
235 | // UnRef old m_nativeData | |
236 | if (m_nativeData) | |
237 | { | |
238 | m_nativeData->m_ref--; | |
239 | if (m_nativeData->m_ref == 0) | |
240 | delete m_nativeData; | |
241 | } | |
242 | // Set Ref new one | |
243 | m_nativeData = data.GetNativeData(); | |
244 | m_nativeData->m_ref++; | |
245 | ||
246 | if (m_privData) | |
247 | { | |
248 | delete [] m_privData; | |
249 | m_privData = NULL; | |
250 | } | |
251 | m_privDataLen = data.GetPrivDataLen(); | |
252 | if (m_privDataLen > 0) | |
253 | { | |
254 | m_privData = new char[m_privDataLen]; | |
255 | memcpy( m_privData, data.GetPrivData(), m_privDataLen ); | |
256 | } | |
257 | } | |
258 | ||
259 | // Is this data OK for showing the print dialog? | |
260 | bool wxPrintData::IsOk() const | |
261 | { | |
262 | m_nativeData->TransferFrom( *this ); | |
263 | ||
264 | return m_nativeData->Ok(); | |
265 | } | |
266 | ||
267 | // What should happen here? wxPostScriptPrintNativeData is not | |
268 | // defined unless all this is true on MSW. | |
269 | #if WXWIN_COMPATIBILITY_2_4 && wxUSE_PRINTING_ARCHITECTURE && (!defined(__WXMSW__) || wxUSE_POSTSCRIPT_ARCHITECTURE_IN_MSW) | |
270 | ||
271 | #include "wx/generic/prntdlgg.h" | |
272 | ||
273 | #if wxUSE_POSTSCRIPT | |
274 | #define WXUNUSED_WITHOUT_PS(name) name | |
275 | #else | |
276 | #define WXUNUSED_WITHOUT_PS(name) WXUNUSED(name) | |
277 | #endif | |
278 | ||
279 | wxString wxPrintData::GetPrinterCommand() const | |
280 | { | |
281 | #if wxUSE_POSTSCRIPT | |
282 | if (m_nativeData && wxIsKindOf(m_nativeData,wxPostScriptPrintNativeData)) | |
283 | return ((wxPostScriptPrintNativeData*)m_nativeData)->GetPrinterCommand(); | |
284 | #endif | |
285 | return wxEmptyString; | |
286 | } | |
287 | ||
288 | wxString wxPrintData::GetPrinterOptions() const | |
289 | { | |
290 | #if wxUSE_POSTSCRIPT | |
291 | if (m_nativeData && wxIsKindOf(m_nativeData,wxPostScriptPrintNativeData)) | |
292 | return ((wxPostScriptPrintNativeData*)m_nativeData)->GetPrinterOptions(); | |
293 | #endif | |
294 | return wxEmptyString; | |
295 | } | |
296 | ||
297 | wxString wxPrintData::GetPreviewCommand() const | |
298 | { | |
299 | #if wxUSE_POSTSCRIPT | |
300 | if (m_nativeData && wxIsKindOf(m_nativeData,wxPostScriptPrintNativeData)) | |
301 | return ((wxPostScriptPrintNativeData*)m_nativeData)->GetPreviewCommand(); | |
302 | #endif | |
303 | return wxEmptyString; | |
304 | } | |
305 | ||
306 | wxString wxPrintData::GetFontMetricPath() const | |
307 | { | |
308 | #if wxUSE_POSTSCRIPT | |
309 | if (m_nativeData && wxIsKindOf(m_nativeData,wxPostScriptPrintNativeData)) | |
310 | return ((wxPostScriptPrintNativeData*)m_nativeData)->GetFontMetricPath(); | |
311 | #endif | |
312 | return wxEmptyString; | |
313 | } | |
314 | ||
315 | double wxPrintData::GetPrinterScaleX() const | |
316 | { | |
317 | #if wxUSE_POSTSCRIPT | |
318 | if (m_nativeData && wxIsKindOf(m_nativeData,wxPostScriptPrintNativeData)) | |
319 | return ((wxPostScriptPrintNativeData*)m_nativeData)->GetPrinterScaleX(); | |
320 | #endif | |
321 | return 1.0; | |
322 | } | |
323 | ||
324 | double wxPrintData::GetPrinterScaleY() const | |
325 | { | |
326 | #if wxUSE_POSTSCRIPT | |
327 | if (m_nativeData && wxIsKindOf(m_nativeData,wxPostScriptPrintNativeData)) | |
328 | return ((wxPostScriptPrintNativeData*)m_nativeData)->GetPrinterScaleY(); | |
329 | #endif | |
330 | return 1.0; | |
331 | } | |
332 | ||
333 | long wxPrintData::GetPrinterTranslateX() const | |
334 | { | |
335 | #if wxUSE_POSTSCRIPT | |
336 | if (m_nativeData && wxIsKindOf(m_nativeData,wxPostScriptPrintNativeData)) | |
337 | return ((wxPostScriptPrintNativeData*)m_nativeData)->GetPrinterTranslateX(); | |
338 | #endif | |
339 | return 0; | |
340 | } | |
341 | ||
342 | long wxPrintData::GetPrinterTranslateY() const | |
343 | { | |
344 | #if wxUSE_POSTSCRIPT | |
345 | if (m_nativeData && wxIsKindOf(m_nativeData,wxPostScriptPrintNativeData)) | |
346 | return ((wxPostScriptPrintNativeData*)m_nativeData)->GetPrinterTranslateY(); | |
347 | #endif | |
348 | return 0; | |
349 | } | |
350 | ||
351 | void wxPrintData::SetPrinterCommand(const wxString& WXUNUSED_WITHOUT_PS(command)) | |
352 | { | |
353 | #if wxUSE_POSTSCRIPT | |
354 | if (m_nativeData && wxIsKindOf(m_nativeData,wxPostScriptPrintNativeData)) | |
355 | ((wxPostScriptPrintNativeData*)m_nativeData)->SetPrinterCommand( command ); | |
356 | #endif | |
357 | } | |
358 | ||
359 | void wxPrintData::SetPrinterOptions(const wxString& WXUNUSED_WITHOUT_PS(options)) | |
360 | { | |
361 | #if wxUSE_POSTSCRIPT | |
362 | if (m_nativeData && wxIsKindOf(m_nativeData,wxPostScriptPrintNativeData)) | |
363 | ((wxPostScriptPrintNativeData*)m_nativeData)->SetPrinterOptions( options ); | |
364 | #endif | |
365 | } | |
366 | ||
367 | void wxPrintData::SetPreviewCommand(const wxString& WXUNUSED_WITHOUT_PS(command)) | |
368 | { | |
369 | #if wxUSE_POSTSCRIPT | |
370 | if (m_nativeData && wxIsKindOf(m_nativeData,wxPostScriptPrintNativeData)) | |
371 | ((wxPostScriptPrintNativeData*)m_nativeData)->SetPreviewCommand( command ); | |
372 | #endif | |
373 | } | |
374 | ||
375 | void wxPrintData::SetFontMetricPath(const wxString& WXUNUSED_WITHOUT_PS(path)) | |
376 | { | |
377 | #if wxUSE_POSTSCRIPT | |
378 | if (m_nativeData && wxIsKindOf(m_nativeData,wxPostScriptPrintNativeData)) | |
379 | ((wxPostScriptPrintNativeData*)m_nativeData)->SetFontMetricPath( path ); | |
380 | #endif | |
381 | } | |
382 | ||
383 | void wxPrintData::SetPrinterScaleX(double WXUNUSED_WITHOUT_PS(x)) | |
384 | { | |
385 | #if wxUSE_POSTSCRIPT | |
386 | if (m_nativeData && wxIsKindOf(m_nativeData,wxPostScriptPrintNativeData)) | |
387 | ((wxPostScriptPrintNativeData*)m_nativeData)->SetPrinterScaleX( x ); | |
388 | #endif | |
389 | } | |
390 | ||
391 | void wxPrintData::SetPrinterScaleY(double WXUNUSED_WITHOUT_PS(y)) | |
392 | { | |
393 | #if wxUSE_POSTSCRIPT | |
394 | if (m_nativeData && wxIsKindOf(m_nativeData,wxPostScriptPrintNativeData)) | |
395 | ((wxPostScriptPrintNativeData*)m_nativeData)->SetPrinterScaleY( y ); | |
396 | #endif | |
397 | } | |
398 | ||
399 | void wxPrintData::SetPrinterScaling(double WXUNUSED_WITHOUT_PS(x), double WXUNUSED_WITHOUT_PS(y)) | |
400 | { | |
401 | #if wxUSE_POSTSCRIPT | |
402 | if (m_nativeData && wxIsKindOf(m_nativeData,wxPostScriptPrintNativeData)) | |
403 | ((wxPostScriptPrintNativeData*)m_nativeData)->SetPrinterScaling( x, y ); | |
404 | #endif | |
405 | } | |
406 | ||
407 | void wxPrintData::SetPrinterTranslateX(long WXUNUSED_WITHOUT_PS(x)) | |
408 | { | |
409 | #if wxUSE_POSTSCRIPT | |
410 | if (m_nativeData && wxIsKindOf(m_nativeData,wxPostScriptPrintNativeData)) | |
411 | ((wxPostScriptPrintNativeData*)m_nativeData)->SetPrinterTranslateX( x ); | |
412 | #endif | |
413 | } | |
414 | ||
415 | void wxPrintData::SetPrinterTranslateY(long WXUNUSED_WITHOUT_PS(y)) | |
416 | { | |
417 | #if wxUSE_POSTSCRIPT | |
418 | if (m_nativeData && wxIsKindOf(m_nativeData,wxPostScriptPrintNativeData)) | |
419 | ((wxPostScriptPrintNativeData*)m_nativeData)->SetPrinterTranslateY( y ); | |
420 | #endif | |
421 | } | |
422 | ||
423 | void wxPrintData::SetPrinterTranslation(long WXUNUSED_WITHOUT_PS(x), long WXUNUSED_WITHOUT_PS(y)) | |
424 | { | |
425 | #if wxUSE_POSTSCRIPT | |
426 | if (m_nativeData && wxIsKindOf(m_nativeData,wxPostScriptPrintNativeData)) | |
427 | ((wxPostScriptPrintNativeData*)m_nativeData)->SetPrinterTranslation( x, y ); | |
428 | #endif | |
429 | } | |
430 | #endif | |
431 | ||
432 | // ---------------------------------------------------------------------------- | |
433 | // Print dialog data | |
434 | // ---------------------------------------------------------------------------- | |
435 | ||
436 | wxPrintDialogData::wxPrintDialogData() | |
437 | { | |
438 | m_printFromPage = 0; | |
439 | m_printToPage = 0; | |
440 | m_printMinPage = 0; | |
441 | m_printMaxPage = 0; | |
442 | m_printNoCopies = 1; | |
443 | m_printAllPages = false; | |
444 | m_printCollate = false; | |
445 | m_printToFile = false; | |
446 | m_printSelection = false; | |
447 | m_printEnableSelection = false; | |
448 | m_printEnablePageNumbers = true; | |
449 | ||
450 | wxPrintFactory* factory = wxPrintFactory::GetFactory(); | |
451 | m_printEnablePrintToFile = ! factory->HasOwnPrintToFile(); | |
452 | ||
453 | m_printEnableHelp = false; | |
454 | #if WXWIN_COMPATIBILITY_2_4 | |
455 | m_printSetupDialog = false; | |
456 | #endif | |
457 | } | |
458 | ||
459 | wxPrintDialogData::wxPrintDialogData(const wxPrintDialogData& dialogData) | |
460 | : wxObject() | |
461 | { | |
462 | (*this) = dialogData; | |
463 | } | |
464 | ||
465 | wxPrintDialogData::wxPrintDialogData(const wxPrintData& printData) | |
466 | { | |
467 | m_printFromPage = 1; | |
468 | m_printToPage = 0; | |
469 | m_printMinPage = 1; | |
470 | m_printMaxPage = 9999; | |
471 | m_printNoCopies = 1; | |
472 | m_printAllPages = false; | |
473 | m_printCollate = false; | |
474 | m_printToFile = false; | |
475 | m_printSelection = false; | |
476 | m_printEnableSelection = false; | |
477 | m_printEnablePageNumbers = true; | |
478 | m_printEnablePrintToFile = true; | |
479 | m_printEnableHelp = false; | |
480 | #if WXWIN_COMPATIBILITY_2_4 | |
481 | m_printSetupDialog = false; | |
482 | #endif | |
483 | m_printData = printData; | |
484 | } | |
485 | ||
486 | wxPrintDialogData::~wxPrintDialogData() | |
487 | { | |
488 | } | |
489 | ||
490 | void wxPrintDialogData::operator=(const wxPrintDialogData& data) | |
491 | { | |
492 | m_printFromPage = data.m_printFromPage; | |
493 | m_printToPage = data.m_printToPage; | |
494 | m_printMinPage = data.m_printMinPage; | |
495 | m_printMaxPage = data.m_printMaxPage; | |
496 | m_printNoCopies = data.m_printNoCopies; | |
497 | m_printAllPages = data.m_printAllPages; | |
498 | m_printCollate = data.m_printCollate; | |
499 | m_printToFile = data.m_printToFile; | |
500 | m_printSelection = data.m_printSelection; | |
501 | m_printEnableSelection = data.m_printEnableSelection; | |
502 | m_printEnablePageNumbers = data.m_printEnablePageNumbers; | |
503 | m_printEnableHelp = data.m_printEnableHelp; | |
504 | m_printEnablePrintToFile = data.m_printEnablePrintToFile; | |
505 | #if WXWIN_COMPATIBILITY_2_4 | |
506 | m_printSetupDialog = data.m_printSetupDialog; | |
507 | #endif | |
508 | m_printData = data.m_printData; | |
509 | } | |
510 | ||
511 | void wxPrintDialogData::operator=(const wxPrintData& data) | |
512 | { | |
513 | m_printData = data; | |
514 | } | |
515 | ||
516 | // ---------------------------------------------------------------------------- | |
517 | // wxPageSetupDialogData | |
518 | // ---------------------------------------------------------------------------- | |
519 | ||
520 | wxPageSetupDialogData::wxPageSetupDialogData() | |
521 | { | |
522 | m_paperSize = wxSize(0,0); | |
523 | ||
524 | CalculatePaperSizeFromId(); | |
525 | ||
526 | m_minMarginTopLeft = | |
527 | m_minMarginBottomRight = | |
528 | m_marginTopLeft = | |
529 | m_marginBottomRight = wxPoint(0,0); | |
530 | ||
531 | // Flags | |
532 | m_defaultMinMargins = false; | |
533 | m_enableMargins = true; | |
534 | m_enableOrientation = true; | |
535 | m_enablePaper = true; | |
536 | m_enablePrinter = true; | |
537 | m_enableHelp = false; | |
538 | m_getDefaultInfo = false; | |
539 | } | |
540 | ||
541 | wxPageSetupDialogData::wxPageSetupDialogData(const wxPageSetupDialogData& dialogData) | |
542 | : wxObject() | |
543 | { | |
544 | (*this) = dialogData; | |
545 | } | |
546 | ||
547 | wxPageSetupDialogData::wxPageSetupDialogData(const wxPrintData& printData) | |
548 | { | |
549 | m_paperSize = wxSize(0,0); | |
550 | m_minMarginTopLeft = | |
551 | m_minMarginBottomRight = | |
552 | m_marginTopLeft = | |
553 | m_marginBottomRight = wxPoint(0,0); | |
554 | ||
555 | // Flags | |
556 | m_defaultMinMargins = false; | |
557 | m_enableMargins = true; | |
558 | m_enableOrientation = true; | |
559 | m_enablePaper = true; | |
560 | m_enablePrinter = true; | |
561 | m_enableHelp = false; | |
562 | m_getDefaultInfo = false; | |
563 | ||
564 | m_printData = printData; | |
565 | ||
566 | // The wxPrintData paper size overrides these values, unless the size cannot | |
567 | // be found. | |
568 | CalculatePaperSizeFromId(); | |
569 | } | |
570 | ||
571 | wxPageSetupDialogData::~wxPageSetupDialogData() | |
572 | { | |
573 | } | |
574 | ||
575 | wxPageSetupDialogData& wxPageSetupDialogData::operator=(const wxPageSetupDialogData& data) | |
576 | { | |
577 | m_paperSize = data.m_paperSize; | |
578 | m_minMarginTopLeft = data.m_minMarginTopLeft; | |
579 | m_minMarginBottomRight = data.m_minMarginBottomRight; | |
580 | m_marginTopLeft = data.m_marginTopLeft; | |
581 | m_marginBottomRight = data.m_marginBottomRight; | |
582 | m_defaultMinMargins = data.m_defaultMinMargins; | |
583 | m_enableMargins = data.m_enableMargins; | |
584 | m_enableOrientation = data.m_enableOrientation; | |
585 | m_enablePaper = data.m_enablePaper; | |
586 | m_enablePrinter = data.m_enablePrinter; | |
587 | m_getDefaultInfo = data.m_getDefaultInfo; | |
588 | m_enableHelp = data.m_enableHelp; | |
589 | ||
590 | m_printData = data.m_printData; | |
591 | ||
592 | return *this; | |
593 | } | |
594 | ||
595 | wxPageSetupDialogData& wxPageSetupDialogData::operator=(const wxPrintData& data) | |
596 | { | |
597 | m_printData = data; | |
598 | CalculatePaperSizeFromId(); | |
599 | ||
600 | return *this; | |
601 | } | |
602 | ||
603 | // If a corresponding paper type is found in the paper database, will set the m_printData | |
604 | // paper size id member as well. | |
605 | void wxPageSetupDialogData::SetPaperSize(const wxSize& sz) | |
606 | { | |
607 | m_paperSize = sz; | |
608 | ||
609 | CalculateIdFromPaperSize(); | |
610 | } | |
611 | ||
612 | // Sets the wxPrintData id, plus the paper width/height if found in the paper database. | |
613 | void wxPageSetupDialogData::SetPaperSize(wxPaperSize id) | |
614 | { | |
615 | m_printData.SetPaperId(id); | |
616 | ||
617 | CalculatePaperSizeFromId(); | |
618 | } | |
619 | ||
620 | void wxPageSetupDialogData::SetPrintData(const wxPrintData& printData) | |
621 | { | |
622 | m_printData = printData; | |
623 | CalculatePaperSizeFromId(); | |
624 | } | |
625 | ||
626 | // Use paper size defined in this object to set the wxPrintData | |
627 | // paper id | |
628 | void wxPageSetupDialogData::CalculateIdFromPaperSize() | |
629 | { | |
630 | wxASSERT_MSG( (wxThePrintPaperDatabase != (wxPrintPaperDatabase*) NULL), | |
631 | wxT("wxThePrintPaperDatabase should not be NULL. Do not create global print dialog data objects.") ); | |
632 | ||
633 | wxSize sz = GetPaperSize(); | |
634 | ||
635 | wxPaperSize id = wxThePrintPaperDatabase->GetSize(wxSize(sz.x* 10, sz.y * 10)); | |
636 | if (id != wxPAPER_NONE) | |
637 | { | |
638 | m_printData.SetPaperId(id); | |
639 | } | |
640 | } | |
641 | ||
642 | // Use paper id in wxPrintData to set this object's paper size | |
643 | void wxPageSetupDialogData::CalculatePaperSizeFromId() | |
644 | { | |
645 | wxASSERT_MSG( (wxThePrintPaperDatabase != (wxPrintPaperDatabase*) NULL), | |
646 | wxT("wxThePrintPaperDatabase should not be NULL. Do not create global print dialog data objects.") ); | |
647 | ||
648 | wxSize sz = wxThePrintPaperDatabase->GetSize(m_printData.GetPaperId()); | |
649 | ||
650 | // sz is in 10ths of a mm, while paper size is in mm | |
651 | m_paperSize.x = sz.x / 10; | |
652 | m_paperSize.y = sz.y / 10; | |
653 | } | |
654 | ||
655 | #endif // wxUSE_PRINTING_ARCHITECTURE |