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