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