]>
Commit | Line | Data |
---|---|---|
2bda0e17 KB |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: printdlg.cpp | |
3 | // Purpose: wxPrintDialog, wxPageSetupDialog | |
4 | // Author: Julian Smart | |
5 | // Modified by: | |
6 | // Created: 04/01/98 | |
7 | // RCS-ID: $Id$ | |
6c9a19aa | 8 | // Copyright: (c) Julian Smart |
65571936 | 9 | // Licence: wxWindows licence |
2bda0e17 KB |
10 | ///////////////////////////////////////////////////////////////////////////// |
11 | ||
103aec29 VZ |
12 | // =========================================================================== |
13 | // declarations | |
14 | // =========================================================================== | |
15 | ||
16 | // --------------------------------------------------------------------------- | |
17 | // headers | |
18 | // --------------------------------------------------------------------------- | |
19 | ||
14f355c2 | 20 | #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) |
103aec29 | 21 | #pragma implementation "printdlg.h" |
2bda0e17 KB |
22 | #endif |
23 | ||
24 | // For compilers that support precompilation, includes "wx.h". | |
2bda0e17 KB |
25 | #include "wx/wxprec.h" |
26 | ||
a3b46648 | 27 | #ifdef __BORLANDC__ |
103aec29 | 28 | #pragma hdrstop |
2bda0e17 KB |
29 | #endif |
30 | ||
12bdd77c JS |
31 | // Don't use the Windows print dialog if we're in wxUniv mode and using |
32 | // the PostScript architecture | |
33 | #if wxUSE_PRINTING_ARCHITECTURE && (!defined(__WXUNIVERSAL__) || !wxUSE_POSTSCRIPT_ARCHITECTURE_IN_MSW) | |
f6bcfd97 BP |
34 | |
35 | #ifndef WX_PRECOMP | |
36 | #include "wx/app.h" | |
37 | #endif | |
38 | ||
c061373d | 39 | #include "wx/cmndata.h" |
2bda0e17 KB |
40 | #include "wx/printdlg.h" |
41 | #include "wx/dcprint.h" | |
42 | ||
2bda0e17 | 43 | #include <stdlib.h> |
42e69d6b VZ |
44 | |
45 | #include "wx/msw/private.h" | |
46 | ||
2bda0e17 KB |
47 | #include <commdlg.h> |
48 | ||
49 | #ifndef __WIN32__ | |
103aec29 | 50 | #include <print.h> |
2bda0e17 KB |
51 | #endif |
52 | ||
103aec29 VZ |
53 | // --------------------------------------------------------------------------- |
54 | // wxPrintDialog | |
55 | // --------------------------------------------------------------------------- | |
56 | ||
c061373d | 57 | IMPLEMENT_CLASS(wxWindowsPrintDialog, wxPrintDialogBase) |
2bda0e17 | 58 | |
c061373d | 59 | wxWindowsPrintDialog::wxWindowsPrintDialog(wxWindow *p, wxPrintDialogData* data) |
2bda0e17 | 60 | { |
7bcb11d3 | 61 | Create(p, data); |
2bda0e17 KB |
62 | } |
63 | ||
c061373d | 64 | wxWindowsPrintDialog::wxWindowsPrintDialog(wxWindow *p, wxPrintData* data) |
103aec29 VZ |
65 | { |
66 | wxPrintDialogData data2; | |
67 | if ( data ) | |
68 | data2 = *data; | |
69 | ||
70 | Create(p, &data2); | |
71 | } | |
72 | ||
c061373d | 73 | bool wxWindowsPrintDialog::Create(wxWindow *p, wxPrintDialogData* data) |
2bda0e17 | 74 | { |
7bcb11d3 JS |
75 | m_dialogParent = p; |
76 | m_printerDC = NULL; | |
078cf5cb | 77 | m_destroyDC = true; |
7bcb11d3 JS |
78 | |
79 | if ( data ) | |
80 | m_printDialogData = *data; | |
103aec29 | 81 | |
7bcb11d3 | 82 | m_printDialogData.SetOwnerWindow(p); |
2bda0e17 | 83 | |
078cf5cb | 84 | return true; |
2bda0e17 KB |
85 | } |
86 | ||
c061373d | 87 | wxWindowsPrintDialog::~wxWindowsPrintDialog() |
2bda0e17 | 88 | { |
7bcb11d3 JS |
89 | if (m_destroyDC && m_printerDC) |
90 | delete m_printerDC; | |
2bda0e17 KB |
91 | } |
92 | ||
c061373d | 93 | int wxWindowsPrintDialog::ShowModal() |
2bda0e17 | 94 | { |
7bcb11d3 | 95 | m_printDialogData.ConvertToNative(); |
103aec29 | 96 | |
f6bcfd97 BP |
97 | PRINTDLG* p = (PRINTDLG *)m_printDialogData.GetNativeData() ; |
98 | if (m_dialogParent) | |
99 | p->hwndOwner = (HWND) m_dialogParent->GetHWND(); | |
100 | else if (wxTheApp->GetTopWindow()) | |
101 | p->hwndOwner = (HWND) wxTheApp->GetTopWindow()->GetHWND(); | |
102 | else | |
103 | p->hwndOwner = 0; | |
104 | ||
105 | bool ret = (PrintDlg( p ) != 0); | |
106 | ||
107 | p->hwndOwner = 0; | |
108 | ||
078cf5cb | 109 | if ( ret != false && ((PRINTDLG *)m_printDialogData.GetNativeData())->hDC) |
7bcb11d3 JS |
110 | { |
111 | wxPrinterDC *pdc = new wxPrinterDC((WXHDC) ((PRINTDLG *)m_printDialogData.GetNativeData())->hDC); | |
112 | m_printerDC = pdc; | |
113 | m_printDialogData.ConvertFromNative(); | |
114 | return wxID_OK; | |
115 | } | |
116 | else | |
117 | { | |
7bcb11d3 JS |
118 | return wxID_CANCEL; |
119 | } | |
2bda0e17 KB |
120 | } |
121 | ||
c061373d | 122 | wxDC *wxWindowsPrintDialog::GetPrintDC() |
2bda0e17 | 123 | { |
7bcb11d3 JS |
124 | if (m_printerDC) |
125 | { | |
078cf5cb | 126 | m_destroyDC = false; |
7bcb11d3 JS |
127 | return m_printerDC; |
128 | } | |
129 | else | |
130 | return (wxDC*) NULL; | |
2bda0e17 KB |
131 | } |
132 | ||
103aec29 VZ |
133 | // --------------------------------------------------------------------------- |
134 | // wxPageSetupDialog | |
135 | // --------------------------------------------------------------------------- | |
2bda0e17 | 136 | |
c061373d RR |
137 | IMPLEMENT_CLASS(wxPageSetupDialog, wxDialog) |
138 | ||
103aec29 | 139 | wxPageSetupDialog::wxPageSetupDialog() |
2bda0e17 | 140 | { |
7bcb11d3 | 141 | m_dialogParent = NULL; |
2bda0e17 KB |
142 | } |
143 | ||
103aec29 | 144 | wxPageSetupDialog::wxPageSetupDialog(wxWindow *p, wxPageSetupData *data) |
2bda0e17 | 145 | { |
7bcb11d3 | 146 | Create(p, data); |
2bda0e17 KB |
147 | } |
148 | ||
149 | bool wxPageSetupDialog::Create(wxWindow *p, wxPageSetupData *data) | |
150 | { | |
7bcb11d3 | 151 | m_dialogParent = p; |
103aec29 | 152 | |
7bcb11d3 JS |
153 | if (data) |
154 | m_pageSetupData = (*data); | |
103aec29 | 155 | |
2bda0e17 | 156 | #if defined(__WIN95__) |
7bcb11d3 | 157 | m_pageSetupData.SetOwnerWindow(p); |
2bda0e17 | 158 | #endif |
078cf5cb | 159 | return true; |
2bda0e17 KB |
160 | } |
161 | ||
103aec29 | 162 | wxPageSetupDialog::~wxPageSetupDialog() |
2bda0e17 KB |
163 | { |
164 | } | |
165 | ||
103aec29 | 166 | int wxPageSetupDialog::ShowModal() |
2bda0e17 KB |
167 | { |
168 | #ifdef __WIN95__ | |
169 | m_pageSetupData.ConvertToNative(); | |
f6bcfd97 BP |
170 | PAGESETUPDLG *p = (PAGESETUPDLG *)m_pageSetupData.GetNativeData(); |
171 | if (m_dialogParent) | |
172 | p->hwndOwner = (HWND) m_dialogParent->GetHWND(); | |
173 | else if (wxTheApp->GetTopWindow()) | |
174 | p->hwndOwner = (HWND) wxTheApp->GetTopWindow()->GetHWND(); | |
175 | else | |
176 | p->hwndOwner = 0; | |
177 | BOOL retVal = PageSetupDlg( p ) ; | |
178 | p->hwndOwner = 0; | |
179 | if (retVal) | |
2bda0e17 | 180 | { |
7bcb11d3 JS |
181 | m_pageSetupData.ConvertFromNative(); |
182 | return wxID_OK; | |
2bda0e17 KB |
183 | } |
184 | else | |
7bcb11d3 | 185 | return wxID_CANCEL; |
2bda0e17 KB |
186 | #else |
187 | wxGenericPageSetupDialog *genericPageSetupDialog = new wxGenericPageSetupDialog(GetParent(), & m_pageSetupData); | |
188 | int ret = genericPageSetupDialog->ShowModal(); | |
189 | m_pageSetupData = genericPageSetupDialog->GetPageSetupData(); | |
078cf5cb | 190 | genericPageSetupDialog->Close(true); |
2bda0e17 KB |
191 | return ret; |
192 | #endif | |
193 | } | |
194 | ||
f6bcfd97 BP |
195 | #endif |
196 | // wxUSE_PRINTING_ARCHITECTURE |