]> git.saurik.com Git - wxWidgets.git/blob - src/mac/carbon/printdlg.cpp
Patch by David Brinegar to fix menubar updating after modal dialog shown
[wxWidgets.git] / src / mac / carbon / printdlg.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: printdlg.cpp
3 // Purpose: wxPrintDialog, wxPageSetupDialog
4 // Author: Stefan Csomor
5 // Modified by:
6 // Created: 1998-01-01
7 // RCS-ID: $Id$
8 // Copyright: (c) Stefan Csomor
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
11
12 #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
13 #pragma implementation "printdlg.h"
14 #endif
15
16 #include "wx/wxprec.h"
17
18 #include "wx/object.h"
19 #include "wx/printdlg.h"
20 #include "wx/mac/printdlg.h"
21 #include "wx/dcprint.h"
22 #include "wx/msgdlg.h"
23 #include "wx/mac/private/print.h"
24
25 // Use generic page setup dialog: use your own native one if one exists.
26
27 IMPLEMENT_DYNAMIC_CLASS(wxMacPrintDialog, wxPrintDialogBase)
28
29 wxMacPrintDialog::wxMacPrintDialog()
30 {
31 m_dialogParent = NULL;
32 m_printerDC = NULL;
33 m_destroyDC = TRUE;
34 }
35
36 wxMacPrintDialog::wxMacPrintDialog(wxWindow *p, wxPrintDialogData* data)
37 {
38 Create(p, data);
39 }
40
41 wxMacPrintDialog::wxMacPrintDialog(wxWindow *p, wxPrintData* data)
42 {
43 wxPrintDialogData data2;
44 if ( data )
45 data2 = *data;
46
47 Create(p, &data2);
48 }
49
50 bool wxMacPrintDialog::Create(wxWindow *p, wxPrintDialogData* data)
51 {
52 m_dialogParent = p;
53 m_printerDC = NULL;
54 m_destroyDC = TRUE;
55
56 if ( data )
57 m_printDialogData = *data;
58
59 return TRUE;
60 }
61
62 wxMacPrintDialog::~wxMacPrintDialog()
63 {
64 if (m_destroyDC && m_printerDC) {
65 delete m_printerDC;
66 m_printerDC = NULL;
67 }
68 }
69
70 int wxMacPrintDialog::ShowModal()
71 {
72 m_printDialogData.ConvertToNative() ;
73 int result = m_printDialogData.GetPrintData().m_nativePrintData->ShowPrintDialog() ;
74 if ( result == wxID_OK )
75 m_printDialogData.ConvertFromNative() ;
76
77 return result ;
78 }
79
80 wxDC *wxMacPrintDialog::GetPrintDC()
81 {
82 return new wxPrinterDC( m_printDialogData.GetPrintData() ) ;
83 }
84
85 /*
86 * wxMacPageSetupDialog
87 */
88
89 IMPLEMENT_CLASS(wxMacPageSetupDialog, wxPageSetupDialogBase)
90
91 wxMacPageSetupDialog::wxMacPageSetupDialog(wxWindow *p, wxPageSetupDialogData *data) :
92 wxPageSetupDialogBase()
93 {
94 Create(p, data);
95 }
96
97 bool wxMacPageSetupDialog::Create(wxWindow *p, wxPageSetupDialogData *data)
98 {
99 m_dialogParent = p;
100
101 if (data)
102 m_pageSetupData = (*data);
103
104 return TRUE;
105 }
106
107 wxMacPageSetupDialog::~wxMacPageSetupDialog()
108 {
109 }
110
111 wxPageSetupData& wxMacPageSetupDialog::GetPageSetupDialogData()
112 {
113 return m_pageSetupData;
114 }
115
116 int wxMacPageSetupDialog::ShowModal()
117 {
118 m_pageSetupData.ConvertToNative();
119
120 int result = m_pageSetupData.GetPrintData().m_nativePrintData->ShowPageSetupDialog();
121
122 if (result == wxID_OK )
123 m_pageSetupData.ConvertFromNative();
124
125 return result;
126 }
127