]> git.saurik.com Git - wxWidgets.git/blame - src/msw/printdlg.cpp
Fixed missing brace in app.cpp
[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
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".
2bda0e17
KB
17#include "wx/wxprec.h"
18
a3b46648 19#ifdef __BORLANDC__
2bda0e17
KB
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
48IMPLEMENT_DYNAMIC_CLASS(wxPrintDialog, wxDialog)
49IMPLEMENT_CLASS(wxPageSetupDialog, wxDialog)
50#endif
51
52wxPrintDialog::wxPrintDialog(void):
7bcb11d3 53wxDialog()
2bda0e17 54{
7bcb11d3
JS
55 m_dialogParent = NULL;
56 m_printerDC = NULL;
57 m_destroyDC = TRUE;
2bda0e17
KB
58}
59
7bcb11d3
JS
60wxPrintDialog::wxPrintDialog(wxWindow *p, wxPrintDialogData* data):
61wxDialog()
2bda0e17 62{
7bcb11d3 63 Create(p, data);
2bda0e17
KB
64}
65
7bcb11d3 66bool wxPrintDialog::Create(wxWindow *p, wxPrintDialogData* data)
2bda0e17 67{
7bcb11d3
JS
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);
2bda0e17 76
7bcb11d3 77 return TRUE;
2bda0e17
KB
78}
79
80wxPrintDialog::~wxPrintDialog(void)
81{
7bcb11d3
JS
82 if (m_destroyDC && m_printerDC)
83 delete m_printerDC;
2bda0e17
KB
84}
85
86int wxPrintDialog::ShowModal(void)
87{
7bcb11d3
JS
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 }
2bda0e17
KB
108}
109
110wxDC *wxPrintDialog::GetPrintDC(void)
111{
7bcb11d3
JS
112 if (m_printerDC)
113 {
114 m_destroyDC = FALSE;
115 return m_printerDC;
116 }
117 else
118 return (wxDC*) NULL;
2bda0e17
KB
119}
120
121/*
7bcb11d3
JS
122* wxPageSetupDialog
123*/
2bda0e17
KB
124
125wxPageSetupDialog::wxPageSetupDialog(void):
7bcb11d3 126wxDialog()
2bda0e17 127{
7bcb11d3 128 m_dialogParent = NULL;
2bda0e17
KB
129}
130
131wxPageSetupDialog::wxPageSetupDialog(wxWindow *p, wxPageSetupData *data):
7bcb11d3 132wxDialog()
2bda0e17 133{
7bcb11d3 134 Create(p, data);
2bda0e17
KB
135}
136
137bool wxPageSetupDialog::Create(wxWindow *p, wxPageSetupData *data)
138{
7bcb11d3
JS
139 m_dialogParent = p;
140
141 if (data)
142 m_pageSetupData = (*data);
143
2bda0e17 144#if defined(__WIN95__)
7bcb11d3 145 m_pageSetupData.SetOwnerWindow(p);
2bda0e17 146#endif
7bcb11d3 147 return TRUE;
2bda0e17
KB
148}
149
150wxPageSetupDialog::~wxPageSetupDialog(void)
151{
152}
153
154int wxPageSetupDialog::ShowModal(void)
155{
156#ifdef __WIN95__
157 m_pageSetupData.ConvertToNative();
158 if (PageSetupDlg( (PAGESETUPDLG *)m_pageSetupData.GetNativeData() ))
159 {
7bcb11d3
JS
160 m_pageSetupData.ConvertFromNative();
161 return wxID_OK;
2bda0e17
KB
162 }
163 else
7bcb11d3 164 return wxID_CANCEL;
2bda0e17
KB
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