]> git.saurik.com Git - wxWidgets.git/blob - src/msw/printdlg.cpp
Fixed missing brace in app.cpp
[wxWidgets.git] / src / msw / printdlg.cpp
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 and Markus Holzem
9 // Licence: wxWindows license
10 /////////////////////////////////////////////////////////////////////////////
11
12 #ifdef __GNUG__
13 #pragma implementation "printdlg.h"
14 #endif
15
16 // For compilers that support precompilation, includes "wx.h".
17 #include "wx/wxprec.h"
18
19 #ifdef __BORLANDC__
20 #pragma hdrstop
21 #endif
22
23 #ifndef WX_PRECOMP
24 #endif
25
26 #include "wx/printdlg.h"
27 #include "wx/dcprint.h"
28
29 // Have to emulate page setup dialog for Win16
30 #if !defined(__WIN95__)
31 #include "wx/generic/prntdlgg.h"
32 #endif
33
34 #include <stdlib.h>
35 #include <windows.h>
36 #include <commdlg.h>
37
38 #ifndef __WIN32__
39 #include <print.h>
40 #endif
41
42 // Clash with Windows header files
43 #ifdef StartDoc
44 #undef StartDoc
45 #endif
46
47 #if !USE_SHARED_LIBRARY
48 IMPLEMENT_DYNAMIC_CLASS(wxPrintDialog, wxDialog)
49 IMPLEMENT_CLASS(wxPageSetupDialog, wxDialog)
50 #endif
51
52 wxPrintDialog::wxPrintDialog(void):
53 wxDialog()
54 {
55 m_dialogParent = NULL;
56 m_printerDC = NULL;
57 m_destroyDC = TRUE;
58 }
59
60 wxPrintDialog::wxPrintDialog(wxWindow *p, wxPrintDialogData* data):
61 wxDialog()
62 {
63 Create(p, data);
64 }
65
66 bool wxPrintDialog::Create(wxWindow *p, wxPrintDialogData* data)
67 {
68 m_dialogParent = p;
69 m_printerDC = NULL;
70 m_destroyDC = TRUE;
71
72 if ( data )
73 m_printDialogData = *data;
74
75 m_printDialogData.SetOwnerWindow(p);
76
77 return TRUE;
78 }
79
80 wxPrintDialog::~wxPrintDialog(void)
81 {
82 if (m_destroyDC && m_printerDC)
83 delete m_printerDC;
84 }
85
86 int wxPrintDialog::ShowModal(void)
87 {
88 m_printDialogData.ConvertToNative();
89
90 bool ret = (PrintDlg( (PRINTDLG *)m_printDialogData.GetNativeData() ) != 0);
91 if ( ret != FALSE && ((PRINTDLG *)m_printDialogData.GetNativeData())->hDC)
92 {
93 wxPrinterDC *pdc = new wxPrinterDC((WXHDC) ((PRINTDLG *)m_printDialogData.GetNativeData())->hDC);
94 m_printerDC = pdc;
95 m_printDialogData.ConvertFromNative();
96 return wxID_OK;
97 }
98 else
99 {
100 /*
101 char buf[256];
102 DWORD exError = CommDlgExtendedError();
103 sprintf(buf, "ret = %d, ex error = %d", (int) ret, (int) exError);
104 wxMessageBox(buf);
105 */
106 return wxID_CANCEL;
107 }
108 }
109
110 wxDC *wxPrintDialog::GetPrintDC(void)
111 {
112 if (m_printerDC)
113 {
114 m_destroyDC = FALSE;
115 return m_printerDC;
116 }
117 else
118 return (wxDC*) NULL;
119 }
120
121 /*
122 * wxPageSetupDialog
123 */
124
125 wxPageSetupDialog::wxPageSetupDialog(void):
126 wxDialog()
127 {
128 m_dialogParent = NULL;
129 }
130
131 wxPageSetupDialog::wxPageSetupDialog(wxWindow *p, wxPageSetupData *data):
132 wxDialog()
133 {
134 Create(p, data);
135 }
136
137 bool wxPageSetupDialog::Create(wxWindow *p, wxPageSetupData *data)
138 {
139 m_dialogParent = p;
140
141 if (data)
142 m_pageSetupData = (*data);
143
144 #if defined(__WIN95__)
145 m_pageSetupData.SetOwnerWindow(p);
146 #endif
147 return TRUE;
148 }
149
150 wxPageSetupDialog::~wxPageSetupDialog(void)
151 {
152 }
153
154 int wxPageSetupDialog::ShowModal(void)
155 {
156 #ifdef __WIN95__
157 m_pageSetupData.ConvertToNative();
158 if (PageSetupDlg( (PAGESETUPDLG *)m_pageSetupData.GetNativeData() ))
159 {
160 m_pageSetupData.ConvertFromNative();
161 return wxID_OK;
162 }
163 else
164 return wxID_CANCEL;
165 #else
166 wxGenericPageSetupDialog *genericPageSetupDialog = new wxGenericPageSetupDialog(GetParent(), & m_pageSetupData);
167 int ret = genericPageSetupDialog->ShowModal();
168 m_pageSetupData = genericPageSetupDialog->GetPageSetupData();
169 genericPageSetupDialog->Close(TRUE);
170 return ret;
171 #endif
172 }
173