]> git.saurik.com Git - wxWidgets.git/blame_incremental - src/msw/printdlg.cpp
taken the function unused under CE inside #ifndef __WXWINCE__
[wxWidgets.git] / src / msw / printdlg.cpp
... / ...
CommitLineData
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$
8// Copyright: (c) Julian Smart
9// Licence: wxWindows licence
10/////////////////////////////////////////////////////////////////////////////
11
12// ===========================================================================
13// declarations
14// ===========================================================================
15
16// ---------------------------------------------------------------------------
17// headers
18// ---------------------------------------------------------------------------
19
20#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
21 #pragma implementation "printdlg.h"
22#endif
23
24// For compilers that support precompilation, includes "wx.h".
25#include "wx/wxprec.h"
26
27#ifdef __BORLANDC__
28 #pragma hdrstop
29#endif
30
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)
34
35#ifndef WX_PRECOMP
36 #include "wx/app.h"
37#endif
38
39#include "wx/printdlg.h"
40#include "wx/dcprint.h"
41
42#include <stdlib.h>
43
44#include "wx/msw/private.h"
45
46#include <commdlg.h>
47
48#ifndef __WIN32__
49 #include <print.h>
50#endif
51
52// ---------------------------------------------------------------------------
53// wxWin macros
54// ---------------------------------------------------------------------------
55
56 IMPLEMENT_DYNAMIC_CLASS(wxPrintDialog, wxDialog)
57 IMPLEMENT_CLASS(wxPageSetupDialog, wxDialog)
58
59// ===========================================================================
60// implementation
61// ===========================================================================
62
63// ---------------------------------------------------------------------------
64// wxPrintDialog
65// ---------------------------------------------------------------------------
66
67wxPrintDialog::wxPrintDialog()
68{
69 m_dialogParent = NULL;
70 m_printerDC = NULL;
71 m_destroyDC = TRUE;
72}
73
74wxPrintDialog::wxPrintDialog(wxWindow *p, wxPrintDialogData* data)
75{
76 Create(p, data);
77}
78
79wxPrintDialog::wxPrintDialog(wxWindow *p, wxPrintData* data)
80{
81 wxPrintDialogData data2;
82 if ( data )
83 data2 = *data;
84
85 Create(p, &data2);
86}
87
88bool wxPrintDialog::Create(wxWindow *p, wxPrintDialogData* data)
89{
90 m_dialogParent = p;
91 m_printerDC = NULL;
92 m_destroyDC = TRUE;
93
94 if ( data )
95 m_printDialogData = *data;
96
97 m_printDialogData.SetOwnerWindow(p);
98
99 return TRUE;
100}
101
102wxPrintDialog::~wxPrintDialog()
103{
104 if (m_destroyDC && m_printerDC)
105 delete m_printerDC;
106}
107
108int wxPrintDialog::ShowModal()
109{
110 m_printDialogData.ConvertToNative();
111
112 PRINTDLG* p = (PRINTDLG *)m_printDialogData.GetNativeData() ;
113 if (m_dialogParent)
114 p->hwndOwner = (HWND) m_dialogParent->GetHWND();
115 else if (wxTheApp->GetTopWindow())
116 p->hwndOwner = (HWND) wxTheApp->GetTopWindow()->GetHWND();
117 else
118 p->hwndOwner = 0;
119
120 bool ret = (PrintDlg( p ) != 0);
121
122 p->hwndOwner = 0;
123
124 if ( ret != FALSE && ((PRINTDLG *)m_printDialogData.GetNativeData())->hDC)
125 {
126 wxPrinterDC *pdc = new wxPrinterDC((WXHDC) ((PRINTDLG *)m_printDialogData.GetNativeData())->hDC);
127 m_printerDC = pdc;
128 m_printDialogData.ConvertFromNative();
129 return wxID_OK;
130 }
131 else
132 {
133 return wxID_CANCEL;
134 }
135}
136
137wxDC *wxPrintDialog::GetPrintDC()
138{
139 if (m_printerDC)
140 {
141 m_destroyDC = FALSE;
142 return m_printerDC;
143 }
144 else
145 return (wxDC*) NULL;
146}
147
148// ---------------------------------------------------------------------------
149// wxPageSetupDialog
150// ---------------------------------------------------------------------------
151
152wxPageSetupDialog::wxPageSetupDialog()
153{
154 m_dialogParent = NULL;
155}
156
157wxPageSetupDialog::wxPageSetupDialog(wxWindow *p, wxPageSetupData *data)
158{
159 Create(p, data);
160}
161
162bool wxPageSetupDialog::Create(wxWindow *p, wxPageSetupData *data)
163{
164 m_dialogParent = p;
165
166 if (data)
167 m_pageSetupData = (*data);
168
169#if defined(__WIN95__)
170 m_pageSetupData.SetOwnerWindow(p);
171#endif
172 return TRUE;
173}
174
175wxPageSetupDialog::~wxPageSetupDialog()
176{
177}
178
179int wxPageSetupDialog::ShowModal()
180{
181#ifdef __WIN95__
182 m_pageSetupData.ConvertToNative();
183 PAGESETUPDLG *p = (PAGESETUPDLG *)m_pageSetupData.GetNativeData();
184 if (m_dialogParent)
185 p->hwndOwner = (HWND) m_dialogParent->GetHWND();
186 else if (wxTheApp->GetTopWindow())
187 p->hwndOwner = (HWND) wxTheApp->GetTopWindow()->GetHWND();
188 else
189 p->hwndOwner = 0;
190 BOOL retVal = PageSetupDlg( p ) ;
191 p->hwndOwner = 0;
192 if (retVal)
193 {
194 m_pageSetupData.ConvertFromNative();
195 return wxID_OK;
196 }
197 else
198 return wxID_CANCEL;
199#else
200 wxGenericPageSetupDialog *genericPageSetupDialog = new wxGenericPageSetupDialog(GetParent(), & m_pageSetupData);
201 int ret = genericPageSetupDialog->ShowModal();
202 m_pageSetupData = genericPageSetupDialog->GetPageSetupData();
203 genericPageSetupDialog->Close(TRUE);
204 return ret;
205#endif
206}
207
208#endif
209 // wxUSE_PRINTING_ARCHITECTURE