]> git.saurik.com Git - wxWidgets.git/blame - src/msw/printdlg.cpp
::GetWindowText() -> wxGetWindowText
[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$
8// Copyright: (c) Julian Smart and Markus Holzem
103aec29 9// Licence: wxWindows license
2bda0e17
KB
10/////////////////////////////////////////////////////////////////////////////
11
103aec29
VZ
12// ===========================================================================
13// declarations
14// ===========================================================================
15
16// ---------------------------------------------------------------------------
17// headers
18// ---------------------------------------------------------------------------
19
2bda0e17 20#ifdef __GNUG__
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
31#include "wx/printdlg.h"
32#include "wx/dcprint.h"
33
34// Have to emulate page setup dialog for Win16
35#if !defined(__WIN95__)
103aec29 36 #include "wx/generic/prntdlgg.h"
2bda0e17
KB
37#endif
38
39#include <stdlib.h>
40#include <windows.h>
41#include <commdlg.h>
42
43#ifndef __WIN32__
103aec29 44 #include <print.h>
2bda0e17
KB
45#endif
46
47// Clash with Windows header files
48#ifdef StartDoc
49#undef StartDoc
50#endif
51
103aec29
VZ
52// ---------------------------------------------------------------------------
53// wxWin macros
54// ---------------------------------------------------------------------------
55
2bda0e17 56#if !USE_SHARED_LIBRARY
103aec29
VZ
57 IMPLEMENT_DYNAMIC_CLASS(wxPrintDialog, wxDialog)
58 IMPLEMENT_CLASS(wxPageSetupDialog, wxDialog)
2bda0e17
KB
59#endif
60
103aec29
VZ
61// ===========================================================================
62// implementation
63// ===========================================================================
64
65// ---------------------------------------------------------------------------
66// wxPrintDialog
67// ---------------------------------------------------------------------------
68
69wxPrintDialog::wxPrintDialog()
2bda0e17 70{
7bcb11d3
JS
71 m_dialogParent = NULL;
72 m_printerDC = NULL;
73 m_destroyDC = TRUE;
2bda0e17
KB
74}
75
103aec29 76wxPrintDialog::wxPrintDialog(wxWindow *p, wxPrintDialogData* data)
2bda0e17 77{
7bcb11d3 78 Create(p, data);
2bda0e17
KB
79}
80
103aec29
VZ
81wxPrintDialog::wxPrintDialog(wxWindow *p, wxPrintData* data)
82{
83 wxPrintDialogData data2;
84 if ( data )
85 data2 = *data;
86
87 Create(p, &data2);
88}
89
7bcb11d3 90bool wxPrintDialog::Create(wxWindow *p, wxPrintDialogData* data)
2bda0e17 91{
7bcb11d3
JS
92 m_dialogParent = p;
93 m_printerDC = NULL;
94 m_destroyDC = TRUE;
95
96 if ( data )
97 m_printDialogData = *data;
103aec29 98
7bcb11d3 99 m_printDialogData.SetOwnerWindow(p);
2bda0e17 100
7bcb11d3 101 return TRUE;
2bda0e17
KB
102}
103
103aec29 104wxPrintDialog::~wxPrintDialog()
2bda0e17 105{
7bcb11d3
JS
106 if (m_destroyDC && m_printerDC)
107 delete m_printerDC;
2bda0e17
KB
108}
109
103aec29 110int wxPrintDialog::ShowModal()
2bda0e17 111{
7bcb11d3 112 m_printDialogData.ConvertToNative();
103aec29 113
7bcb11d3
JS
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 {
7bcb11d3
JS
124 return wxID_CANCEL;
125 }
2bda0e17
KB
126}
127
103aec29 128wxDC *wxPrintDialog::GetPrintDC()
2bda0e17 129{
7bcb11d3
JS
130 if (m_printerDC)
131 {
132 m_destroyDC = FALSE;
133 return m_printerDC;
134 }
135 else
136 return (wxDC*) NULL;
2bda0e17
KB
137}
138
103aec29
VZ
139// ---------------------------------------------------------------------------
140// wxPageSetupDialog
141// ---------------------------------------------------------------------------
2bda0e17 142
103aec29 143wxPageSetupDialog::wxPageSetupDialog()
2bda0e17 144{
7bcb11d3 145 m_dialogParent = NULL;
2bda0e17
KB
146}
147
103aec29 148wxPageSetupDialog::wxPageSetupDialog(wxWindow *p, wxPageSetupData *data)
2bda0e17 149{
7bcb11d3 150 Create(p, data);
2bda0e17
KB
151}
152
153bool wxPageSetupDialog::Create(wxWindow *p, wxPageSetupData *data)
154{
7bcb11d3 155 m_dialogParent = p;
103aec29 156
7bcb11d3
JS
157 if (data)
158 m_pageSetupData = (*data);
103aec29 159
2bda0e17 160#if defined(__WIN95__)
7bcb11d3 161 m_pageSetupData.SetOwnerWindow(p);
2bda0e17 162#endif
7bcb11d3 163 return TRUE;
2bda0e17
KB
164}
165
103aec29 166wxPageSetupDialog::~wxPageSetupDialog()
2bda0e17
KB
167{
168}
169
103aec29 170int wxPageSetupDialog::ShowModal()
2bda0e17
KB
171{
172#ifdef __WIN95__
173 m_pageSetupData.ConvertToNative();
174 if (PageSetupDlg( (PAGESETUPDLG *)m_pageSetupData.GetNativeData() ))
175 {
7bcb11d3
JS
176 m_pageSetupData.ConvertFromNative();
177 return wxID_OK;
2bda0e17
KB
178 }
179 else
7bcb11d3 180 return wxID_CANCEL;
2bda0e17
KB
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