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