]> git.saurik.com Git - wxWidgets.git/blob - src/msw/printdlg.cpp
radiobox now sends notification messages when the selection is changed from
[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 // ===========================================================================
13 // declarations
14 // ===========================================================================
15
16 // ---------------------------------------------------------------------------
17 // headers
18 // ---------------------------------------------------------------------------
19
20 #ifdef __GNUG__
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 #include "wx/printdlg.h"
32 #include "wx/dcprint.h"
33
34 // Have to emulate page setup dialog for Win16
35 #if !defined(__WIN95__)
36 #include "wx/generic/prntdlgg.h"
37 #endif
38
39 #include <stdlib.h>
40 #include <windows.h>
41 #include <commdlg.h>
42
43 #ifndef __WIN32__
44 #include <print.h>
45 #endif
46
47 // Clash with Windows header files
48 #ifdef StartDoc
49 #undef StartDoc
50 #endif
51
52 // ---------------------------------------------------------------------------
53 // wxWin macros
54 // ---------------------------------------------------------------------------
55
56 #if !USE_SHARED_LIBRARY
57 IMPLEMENT_DYNAMIC_CLASS(wxPrintDialog, wxDialog)
58 IMPLEMENT_CLASS(wxPageSetupDialog, wxDialog)
59 #endif
60
61 // ===========================================================================
62 // implementation
63 // ===========================================================================
64
65 // ---------------------------------------------------------------------------
66 // wxPrintDialog
67 // ---------------------------------------------------------------------------
68
69 wxPrintDialog::wxPrintDialog()
70 {
71 m_dialogParent = NULL;
72 m_printerDC = NULL;
73 m_destroyDC = TRUE;
74 }
75
76 wxPrintDialog::wxPrintDialog(wxWindow *p, wxPrintDialogData* data)
77 {
78 Create(p, data);
79 }
80
81 wxPrintDialog::wxPrintDialog(wxWindow *p, wxPrintData* data)
82 {
83 wxPrintDialogData data2;
84 if ( data )
85 data2 = *data;
86
87 Create(p, &data2);
88 }
89
90 bool wxPrintDialog::Create(wxWindow *p, wxPrintDialogData* data)
91 {
92 m_dialogParent = p;
93 m_printerDC = NULL;
94 m_destroyDC = TRUE;
95
96 if ( data )
97 m_printDialogData = *data;
98
99 m_printDialogData.SetOwnerWindow(p);
100
101 return TRUE;
102 }
103
104 wxPrintDialog::~wxPrintDialog()
105 {
106 if (m_destroyDC && m_printerDC)
107 delete m_printerDC;
108 }
109
110 int wxPrintDialog::ShowModal()
111 {
112 m_printDialogData.ConvertToNative();
113
114 bool ret = (PrintDlg( (PRINTDLG *)m_printDialogData.GetNativeData() ) != 0);
115 if ( ret != FALSE && ((PRINTDLG *)m_printDialogData.GetNativeData())->hDC)
116 {
117 wxPrinterDC *pdc = new wxPrinterDC((WXHDC) ((PRINTDLG *)m_printDialogData.GetNativeData())->hDC);
118 m_printerDC = pdc;
119 m_printDialogData.ConvertFromNative();
120 return wxID_OK;
121 }
122 else
123 {
124 return wxID_CANCEL;
125 }
126 }
127
128 wxDC *wxPrintDialog::GetPrintDC()
129 {
130 if (m_printerDC)
131 {
132 m_destroyDC = FALSE;
133 return m_printerDC;
134 }
135 else
136 return (wxDC*) NULL;
137 }
138
139 // ---------------------------------------------------------------------------
140 // wxPageSetupDialog
141 // ---------------------------------------------------------------------------
142
143 wxPageSetupDialog::wxPageSetupDialog()
144 {
145 m_dialogParent = NULL;
146 }
147
148 wxPageSetupDialog::wxPageSetupDialog(wxWindow *p, wxPageSetupData *data)
149 {
150 Create(p, data);
151 }
152
153 bool wxPageSetupDialog::Create(wxWindow *p, wxPageSetupData *data)
154 {
155 m_dialogParent = p;
156
157 if (data)
158 m_pageSetupData = (*data);
159
160 #if defined(__WIN95__)
161 m_pageSetupData.SetOwnerWindow(p);
162 #endif
163 return TRUE;
164 }
165
166 wxPageSetupDialog::~wxPageSetupDialog()
167 {
168 }
169
170 int wxPageSetupDialog::ShowModal()
171 {
172 #ifdef __WIN95__
173 m_pageSetupData.ConvertToNative();
174 if (PageSetupDlg( (PAGESETUPDLG *)m_pageSetupData.GetNativeData() ))
175 {
176 m_pageSetupData.ConvertFromNative();
177 return wxID_OK;
178 }
179 else
180 return wxID_CANCEL;
181 #else
182 wxGenericPageSetupDialog *genericPageSetupDialog = new wxGenericPageSetupDialog(GetParent(), & m_pageSetupData);
183 int ret = genericPageSetupDialog->ShowModal();
184 m_pageSetupData = genericPageSetupDialog->GetPageSetupData();
185 genericPageSetupDialog->Close(TRUE);
186 return ret;
187 #endif
188 }
189