]> git.saurik.com Git - wxWidgets.git/blame - src/msw/printdlg.cpp
Changed system colours for better default display of wxGrid. Please revert
[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>
42e69d6b
VZ
40
41#include "wx/msw/private.h"
42
2bda0e17
KB
43#include <commdlg.h>
44
45#ifndef __WIN32__
103aec29 46 #include <print.h>
2bda0e17
KB
47#endif
48
103aec29
VZ
49// ---------------------------------------------------------------------------
50// wxWin macros
51// ---------------------------------------------------------------------------
52
103aec29
VZ
53 IMPLEMENT_DYNAMIC_CLASS(wxPrintDialog, wxDialog)
54 IMPLEMENT_CLASS(wxPageSetupDialog, wxDialog)
2bda0e17 55
103aec29
VZ
56// ===========================================================================
57// implementation
58// ===========================================================================
59
60// ---------------------------------------------------------------------------
61// wxPrintDialog
62// ---------------------------------------------------------------------------
63
64wxPrintDialog::wxPrintDialog()
2bda0e17 65{
7bcb11d3
JS
66 m_dialogParent = NULL;
67 m_printerDC = NULL;
68 m_destroyDC = TRUE;
2bda0e17
KB
69}
70
103aec29 71wxPrintDialog::wxPrintDialog(wxWindow *p, wxPrintDialogData* data)
2bda0e17 72{
7bcb11d3 73 Create(p, data);
2bda0e17
KB
74}
75
103aec29
VZ
76wxPrintDialog::wxPrintDialog(wxWindow *p, wxPrintData* data)
77{
78 wxPrintDialogData data2;
79 if ( data )
80 data2 = *data;
81
82 Create(p, &data2);
83}
84
7bcb11d3 85bool wxPrintDialog::Create(wxWindow *p, wxPrintDialogData* data)
2bda0e17 86{
7bcb11d3
JS
87 m_dialogParent = p;
88 m_printerDC = NULL;
89 m_destroyDC = TRUE;
90
91 if ( data )
92 m_printDialogData = *data;
103aec29 93
7bcb11d3 94 m_printDialogData.SetOwnerWindow(p);
2bda0e17 95
7bcb11d3 96 return TRUE;
2bda0e17
KB
97}
98
103aec29 99wxPrintDialog::~wxPrintDialog()
2bda0e17 100{
7bcb11d3
JS
101 if (m_destroyDC && m_printerDC)
102 delete m_printerDC;
2bda0e17
KB
103}
104
103aec29 105int wxPrintDialog::ShowModal()
2bda0e17 106{
7bcb11d3 107 m_printDialogData.ConvertToNative();
103aec29 108
7bcb11d3
JS
109 bool ret = (PrintDlg( (PRINTDLG *)m_printDialogData.GetNativeData() ) != 0);
110 if ( ret != FALSE && ((PRINTDLG *)m_printDialogData.GetNativeData())->hDC)
111 {
112 wxPrinterDC *pdc = new wxPrinterDC((WXHDC) ((PRINTDLG *)m_printDialogData.GetNativeData())->hDC);
113 m_printerDC = pdc;
114 m_printDialogData.ConvertFromNative();
115 return wxID_OK;
116 }
117 else
118 {
7bcb11d3
JS
119 return wxID_CANCEL;
120 }
2bda0e17
KB
121}
122
103aec29 123wxDC *wxPrintDialog::GetPrintDC()
2bda0e17 124{
7bcb11d3
JS
125 if (m_printerDC)
126 {
127 m_destroyDC = FALSE;
128 return m_printerDC;
129 }
130 else
131 return (wxDC*) NULL;
2bda0e17
KB
132}
133
103aec29
VZ
134// ---------------------------------------------------------------------------
135// wxPageSetupDialog
136// ---------------------------------------------------------------------------
2bda0e17 137
103aec29 138wxPageSetupDialog::wxPageSetupDialog()
2bda0e17 139{
7bcb11d3 140 m_dialogParent = NULL;
2bda0e17
KB
141}
142
103aec29 143wxPageSetupDialog::wxPageSetupDialog(wxWindow *p, wxPageSetupData *data)
2bda0e17 144{
7bcb11d3 145 Create(p, data);
2bda0e17
KB
146}
147
148bool wxPageSetupDialog::Create(wxWindow *p, wxPageSetupData *data)
149{
7bcb11d3 150 m_dialogParent = p;
103aec29 151
7bcb11d3
JS
152 if (data)
153 m_pageSetupData = (*data);
103aec29 154
2bda0e17 155#if defined(__WIN95__)
7bcb11d3 156 m_pageSetupData.SetOwnerWindow(p);
2bda0e17 157#endif
7bcb11d3 158 return TRUE;
2bda0e17
KB
159}
160
103aec29 161wxPageSetupDialog::~wxPageSetupDialog()
2bda0e17
KB
162{
163}
164
103aec29 165int wxPageSetupDialog::ShowModal()
2bda0e17
KB
166{
167#ifdef __WIN95__
168 m_pageSetupData.ConvertToNative();
169 if (PageSetupDlg( (PAGESETUPDLG *)m_pageSetupData.GetNativeData() ))
170 {
7bcb11d3
JS
171 m_pageSetupData.ConvertFromNative();
172 return wxID_OK;
2bda0e17
KB
173 }
174 else
7bcb11d3 175 return wxID_CANCEL;
2bda0e17
KB
176#else
177 wxGenericPageSetupDialog *genericPageSetupDialog = new wxGenericPageSetupDialog(GetParent(), & m_pageSetupData);
178 int ret = genericPageSetupDialog->ShowModal();
179 m_pageSetupData = genericPageSetupDialog->GetPageSetupData();
180 genericPageSetupDialog->Close(TRUE);
181 return ret;
182#endif
183}
184