]> git.saurik.com Git - wxWidgets.git/blame - src/msw/printdlg.cpp
showing a bevel button for a multiline label (is not multline on the OS level, but...
[wxWidgets.git] / src / msw / printdlg.cpp
CommitLineData
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
JS
8// Copyright: (c) Julian Smart
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
2bda0e17
KB
39#include "wx/printdlg.h"
40#include "wx/dcprint.h"
41
42// Have to emulate page setup dialog for Win16
43#if !defined(__WIN95__)
103aec29 44 #include "wx/generic/prntdlgg.h"
2bda0e17
KB
45#endif
46
47#include <stdlib.h>
42e69d6b
VZ
48
49#include "wx/msw/private.h"
50
2bda0e17
KB
51#include <commdlg.h>
52
53#ifndef __WIN32__
103aec29 54 #include <print.h>
2bda0e17
KB
55#endif
56
103aec29
VZ
57// ---------------------------------------------------------------------------
58// wxWin macros
59// ---------------------------------------------------------------------------
60
103aec29
VZ
61 IMPLEMENT_DYNAMIC_CLASS(wxPrintDialog, wxDialog)
62 IMPLEMENT_CLASS(wxPageSetupDialog, wxDialog)
2bda0e17 63
103aec29
VZ
64// ===========================================================================
65// implementation
66// ===========================================================================
67
68// ---------------------------------------------------------------------------
69// wxPrintDialog
70// ---------------------------------------------------------------------------
71
72wxPrintDialog::wxPrintDialog()
2bda0e17 73{
7bcb11d3
JS
74 m_dialogParent = NULL;
75 m_printerDC = NULL;
76 m_destroyDC = TRUE;
2bda0e17
KB
77}
78
103aec29 79wxPrintDialog::wxPrintDialog(wxWindow *p, wxPrintDialogData* data)
2bda0e17 80{
7bcb11d3 81 Create(p, data);
2bda0e17
KB
82}
83
103aec29
VZ
84wxPrintDialog::wxPrintDialog(wxWindow *p, wxPrintData* data)
85{
86 wxPrintDialogData data2;
87 if ( data )
88 data2 = *data;
89
90 Create(p, &data2);
91}
92
7bcb11d3 93bool wxPrintDialog::Create(wxWindow *p, wxPrintDialogData* data)
2bda0e17 94{
7bcb11d3
JS
95 m_dialogParent = p;
96 m_printerDC = NULL;
97 m_destroyDC = TRUE;
98
99 if ( data )
100 m_printDialogData = *data;
103aec29 101
7bcb11d3 102 m_printDialogData.SetOwnerWindow(p);
2bda0e17 103
7bcb11d3 104 return TRUE;
2bda0e17
KB
105}
106
103aec29 107wxPrintDialog::~wxPrintDialog()
2bda0e17 108{
7bcb11d3
JS
109 if (m_destroyDC && m_printerDC)
110 delete m_printerDC;
2bda0e17
KB
111}
112
103aec29 113int wxPrintDialog::ShowModal()
2bda0e17 114{
7bcb11d3 115 m_printDialogData.ConvertToNative();
103aec29 116
f6bcfd97
BP
117 PRINTDLG* p = (PRINTDLG *)m_printDialogData.GetNativeData() ;
118 if (m_dialogParent)
119 p->hwndOwner = (HWND) m_dialogParent->GetHWND();
120 else if (wxTheApp->GetTopWindow())
121 p->hwndOwner = (HWND) wxTheApp->GetTopWindow()->GetHWND();
122 else
123 p->hwndOwner = 0;
124
125 bool ret = (PrintDlg( p ) != 0);
126
127 p->hwndOwner = 0;
128
7bcb11d3
JS
129 if ( ret != FALSE && ((PRINTDLG *)m_printDialogData.GetNativeData())->hDC)
130 {
131 wxPrinterDC *pdc = new wxPrinterDC((WXHDC) ((PRINTDLG *)m_printDialogData.GetNativeData())->hDC);
132 m_printerDC = pdc;
133 m_printDialogData.ConvertFromNative();
134 return wxID_OK;
135 }
136 else
137 {
7bcb11d3
JS
138 return wxID_CANCEL;
139 }
2bda0e17
KB
140}
141
103aec29 142wxDC *wxPrintDialog::GetPrintDC()
2bda0e17 143{
7bcb11d3
JS
144 if (m_printerDC)
145 {
146 m_destroyDC = FALSE;
147 return m_printerDC;
148 }
149 else
150 return (wxDC*) NULL;
2bda0e17
KB
151}
152
103aec29
VZ
153// ---------------------------------------------------------------------------
154// wxPageSetupDialog
155// ---------------------------------------------------------------------------
2bda0e17 156
103aec29 157wxPageSetupDialog::wxPageSetupDialog()
2bda0e17 158{
7bcb11d3 159 m_dialogParent = NULL;
2bda0e17
KB
160}
161
103aec29 162wxPageSetupDialog::wxPageSetupDialog(wxWindow *p, wxPageSetupData *data)
2bda0e17 163{
7bcb11d3 164 Create(p, data);
2bda0e17
KB
165}
166
167bool wxPageSetupDialog::Create(wxWindow *p, wxPageSetupData *data)
168{
7bcb11d3 169 m_dialogParent = p;
103aec29 170
7bcb11d3
JS
171 if (data)
172 m_pageSetupData = (*data);
103aec29 173
2bda0e17 174#if defined(__WIN95__)
7bcb11d3 175 m_pageSetupData.SetOwnerWindow(p);
2bda0e17 176#endif
7bcb11d3 177 return TRUE;
2bda0e17
KB
178}
179
103aec29 180wxPageSetupDialog::~wxPageSetupDialog()
2bda0e17
KB
181{
182}
183
103aec29 184int wxPageSetupDialog::ShowModal()
2bda0e17
KB
185{
186#ifdef __WIN95__
187 m_pageSetupData.ConvertToNative();
f6bcfd97
BP
188 PAGESETUPDLG *p = (PAGESETUPDLG *)m_pageSetupData.GetNativeData();
189 if (m_dialogParent)
190 p->hwndOwner = (HWND) m_dialogParent->GetHWND();
191 else if (wxTheApp->GetTopWindow())
192 p->hwndOwner = (HWND) wxTheApp->GetTopWindow()->GetHWND();
193 else
194 p->hwndOwner = 0;
195 BOOL retVal = PageSetupDlg( p ) ;
196 p->hwndOwner = 0;
197 if (retVal)
2bda0e17 198 {
7bcb11d3
JS
199 m_pageSetupData.ConvertFromNative();
200 return wxID_OK;
2bda0e17
KB
201 }
202 else
7bcb11d3 203 return wxID_CANCEL;
2bda0e17
KB
204#else
205 wxGenericPageSetupDialog *genericPageSetupDialog = new wxGenericPageSetupDialog(GetParent(), & m_pageSetupData);
206 int ret = genericPageSetupDialog->ShowModal();
207 m_pageSetupData = genericPageSetupDialog->GetPageSetupData();
208 genericPageSetupDialog->Close(TRUE);
209 return ret;
210#endif
211}
212
f6bcfd97
BP
213#endif
214 // wxUSE_PRINTING_ARCHITECTURE