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