]> git.saurik.com Git - wxWidgets.git/blame - src/os2/dcprint.cpp
Don't build tex2rtf and HelpGen utils in non-GUI buildbot builds.
[wxWidgets.git] / src / os2 / dcprint.cpp
CommitLineData
27476f73 1/////////////////////////////////////////////////////////////////////////////
cb7d7375 2// Name: src/os2/dcprint.cpp
27476f73 3// Purpose: wxPrinterDC class
fb46a9a6 4// Author: David Webster
27476f73 5// Modified by:
fb46a9a6 6// Created: 10/14/99
27476f73 7// RCS-ID: $Id$
fb46a9a6 8// Copyright: (c) David Webster
65571936 9// Licence: wxWindows licence
27476f73
DW
10/////////////////////////////////////////////////////////////////////////////
11
27476f73
DW
12// For compilers that support precompilation, includes "wx.h".
13#include "wx/wxprec.h"
fb46a9a6 14
df91131c
WS
15#if wxUSE_PRINTING_ARCHITECTURE
16
6d50343d 17#include "wx/dcprint.h"
2c24e7ad 18#include "wx/os2/dcprint.h"
6d50343d 19
fb46a9a6
DW
20#define INCL_DEV
21#define INCL_GPI
22#define INCL_PM
23#include<os2.h>
24
27476f73 25#ifndef WX_PRECOMP
df91131c
WS
26 #include "wx/app.h"
27 #include "wx/math.h"
28 #include "wx/string.h"
e4db172a 29 #include "wx/log.h"
cdccdfab 30 #include "wx/window.h"
27476f73
DW
31#endif
32
27476f73 33#include "wx/os2/private.h"
7e99520b 34
2c24e7ad 35IMPLEMENT_ABSTRACT_CLASS(wxPrinterDCImpl, wxPMDCImpl)
27476f73 36
2c24e7ad
SN
37wxPrinterDCImpl::wxPrinterDCImpl( wxPrinterDC *owner, const wxPrintData& rPrintData ) :
38 wxPMDCImpl( owner )
27476f73 39{
e1a688e4 40 m_printData = rPrintData;
cb7d7375 41 m_isInteractive = false;
e1a688e4 42 m_hDC = wxGetPrinterDC(rPrintData);
27476f73 43 m_ok = (m_hDC != 0);
27476f73
DW
44 if (m_hDC)
45 SetMapMode(wxMM_TEXT);
27476f73
DW
46 SetBrush(*wxBLACK_BRUSH);
47 SetPen(*wxBLACK_PEN);
e1a688e4 48} // end of wxPrinterDC::wxPrinterDC
27476f73 49
2c24e7ad
SN
50wxPrinterDCImpl::wxPrinterDCImpl( wxPrinterDC *owner, WXHDC hTheDC ) :
51 wxPMDCImpl( owner )
27476f73 52{
cb7d7375 53 m_isInteractive = false;
e1a688e4 54 m_hDC = hTheDC;
cb7d7375 55 m_ok = true;
27476f73
DW
56 if (m_hDC)
57 {
27476f73
DW
58 SetMapMode(wxMM_TEXT);
59 }
60 SetBrush(*wxBLACK_BRUSH);
61 SetPen(*wxBLACK_PEN);
e1a688e4 62} // end of wxPrinterDC::wxPrinterDC
27476f73 63
2c24e7ad 64void wxPrinterDCImpl::Init()
27476f73 65{
e1a688e4
DW
66 if (m_hDC)
67 {
68 SetMapMode(wxMM_TEXT);
27476f73 69
e1a688e4
DW
70 SetBrush(*wxBLACK_BRUSH);
71 SetPen(*wxBLACK_PEN);
72 }
73} // end of wxPrinterDC::Init
74
2c24e7ad 75bool wxPrinterDCImpl::StartDoc(const wxString& WXUNUSED(rsMessage))
27476f73
DW
76{
77/* TODO: PM's implementation
78 DOCINFO docinfo;
79 docinfo.cbSize = sizeof(DOCINFO);
80 docinfo.lpszDocName = (const wxChar*)message;
81
82 wxString filename(m_printData.GetFilename());
83
cb7d7375 84 if (filename.empty())
27476f73
DW
85 docinfo.lpszOutput = NULL;
86 else
87 docinfo.lpszOutput = (const wxChar *) filename;
88
27476f73
DW
89 docinfo.lpszDatatype = NULL;
90 docinfo.fwType = 0;
27476f73
DW
91
92 if (!m_hDC)
cb7d7375 93 return false;
27476f73
DW
94
95 int ret =
96#ifndef __WIN32__
97 ::StartDoc((HDC) m_hDC, &docinfo);
98#else
99#ifdef UNICODE
100 ::StartDocW((HDC) m_hDC, &docinfo);
101#else
102#ifdef __TWIN32__
103 ::StartDoc((HDC) m_hDC, &docinfo);
104#else
105 ::StartDocA((HDC) m_hDC, &docinfo);
106#endif
107#endif
108#endif
109
110#ifndef __WIN16__
111 if (ret <= 0)
112 {
113 DWORD lastError = GetLastError();
223d09f6 114 wxLogDebug(wxT("wxDC::StartDoc failed with error: %d\n"), lastError);
27476f73
DW
115 }
116#endif
117 return (ret > 0);
118*/
cb7d7375 119 return true;
e1a688e4 120} // end of wxPrinterDC::StartDoc
27476f73 121
2c24e7ad 122void wxPrinterDCImpl::EndDoc()
27476f73
DW
123{
124// if (m_hDC) ::EndDoc((HDC) m_hDC);
e1a688e4 125} // end of wxPrinterDC::EndDoc
27476f73 126
2c24e7ad 127void wxPrinterDCImpl::StartPage()
27476f73
DW
128{
129// if (m_hDC)
130// ::StartPage((HDC) m_hDC);
e1a688e4 131} // end of wxPrinterDC::StartPage
27476f73 132
2c24e7ad 133void wxPrinterDCImpl::EndPage()
27476f73
DW
134{
135// if (m_hDC)
136// ::EndPage((HDC) m_hDC);
e1a688e4 137} // end of wxPrinterDC::EndPage
f415cab9 138
6d52ca53 139wxRect wxPrinterDCImpl::GetPaperRect() const
f415cab9
JS
140{
141 // Use page rect if we can't get paper rect.
142 wxCoord w, h;
143 GetSize(&w, &h);
144 return wxRect(0, 0, w, h);
145}
146
9923c37d 147#if 0
27476f73 148// Returns default device and port names
cb7d7375 149static bool wxGetDefaultDeviceName( wxString& rsDeviceName, wxString& rsPortName )
27476f73 150{
cb7d7375 151 rsDeviceName = wxEmptyString;
27476f73
DW
152/*
153 LPDEVNAMES lpDevNames;
154 LPSTR lpszDriverName;
155 LPSTR lpszDeviceName;
156 LPSTR lpszPortName;
157
158 PRINTDLG pd;
159
160 // Cygwin has trouble believing PRINTDLG is 66 bytes - thinks it is 68
161#ifdef __GNUWIN32__
162 pd.lStructSize = 66; // sizeof(PRINTDLG);
163#else
164 pd.lStructSize = sizeof(PRINTDLG);
165#endif
166
167 pd.hwndOwner = (HWND)NULL;
168 pd.hDevMode = NULL; // Will be created by PrintDlg
169 pd.hDevNames = NULL; // Ditto
170 pd.Flags = PD_RETURNDEFAULT;
171 pd.nCopies = 1;
172
173 if (!PrintDlg((LPPRINTDLG)&pd))
174 {
175 if ( pd.hDevMode )
176 GlobalFree(pd.hDevMode);
177 if (pd.hDevNames)
178 GlobalFree(pd.hDevNames);
179
cb7d7375 180 return false;
27476f73
DW
181 }
182
183 if (pd.hDevNames)
184 {
185 lpDevNames = (LPDEVNAMES)GlobalLock(pd.hDevNames);
186 lpszDriverName = (LPSTR)lpDevNames + lpDevNames->wDriverOffset;
187 lpszDeviceName = (LPSTR)lpDevNames + lpDevNames->wDeviceOffset;
188 lpszPortName = (LPSTR)lpDevNames + lpDevNames->wOutputOffset;
189 GlobalUnlock(pd.hDevNames);
190 GlobalFree(pd.hDevNames);
191 pd.hDevNames=NULL;
192
193 deviceName = lpszDeviceName;
194 portName = lpszPortName;
195 }
196
197 if (pd.hDevMode)
198 {
199 GlobalFree(pd.hDevMode);
200 pd.hDevMode=NULL;
201 }
6d50343d 202 return !deviceName.empty();
27476f73 203*/
cb7d7375 204 return true;
e1a688e4 205} // end of wxGetDefaultDeviceName
9923c37d 206#endif
27476f73
DW
207
208// Gets an HDC for the specified printer configuration
cb7d7375 209WXHDC WXDLLEXPORT wxGetPrinterDC( const wxPrintData& WXUNUSED(rPrintDataConst) )
27476f73 210{
9dea36ef 211 HDC hDC = NULLHANDLE;
27476f73
DW
212/*
213 wxPrintData printData = printDataConst;
214 printData.ConvertToNative();
215
d3b9f782 216 wxChar* driverName = NULL;
27476f73
DW
217
218 wxString devNameStr = printData.GetPrinterName();
219 wxChar* deviceName;
d3b9f782 220 wxChar* portName = NULL; // Obsolete in WIN32
27476f73 221
cb7d7375 222 if (devNameStr.empty())
d3b9f782 223 deviceName = NULL;
27476f73
DW
224 else
225 deviceName = WXSTRINGCAST devNameStr;
226
227 LPDEVMODE lpDevMode = (LPDEVMODE) NULL;
228
229 HGLOBAL hDevMode = (HGLOBAL)(DWORD) printData.GetNativeData();
230
231 if ( hDevMode )
232 lpDevMode = (DEVMODE*) GlobalLock(hDevMode);
233
cb7d7375 234 if (devNameStr.empty())
27476f73
DW
235 {
236 // Retrieve the default device name
237 wxString portName;
238 bool ret = wxGetDefaultDeviceName(devNameStr, portName);
239
223d09f6 240 wxASSERT_MSG( ret, wxT("Could not get default device name.") );
27476f73
DW
241
242 deviceName = WXSTRINGCAST devNameStr;
243 }
244
245#ifdef __WIN32__
246 HDC hDC = CreateDC(driverName, deviceName, portName, (DEVMODE *) lpDevMode);
247#else
248 HDC hDC = CreateDC(driverName, deviceName, portName, (LPSTR) lpDevMode);
249#endif
250
251 if (hDevMode && lpDevMode)
252 GlobalUnlock(hDevMode);
253*/
254 return (WXHDC) hDC;
e1a688e4
DW
255} // end of wxGetPrinterDC
256
2c24e7ad
SN
257void wxPrinterDCImpl::DoDrawBitmap( const wxBitmap& rBmp,
258 wxCoord WXUNUSED(vX),
259 wxCoord WXUNUSED(vY),
260 bool WXUNUSED(bUseMask))
e1a688e4 261{
a1b806b9 262 wxCHECK_RET( rBmp.IsOk(), wxT("invalid bitmap in wxPrinterDC::DrawBitmap") );
e1a688e4 263
9923c37d
DW
264// int nWidth = rBmp.GetWidth();
265// int nHeight = rBmp.GetHeight();
e1a688e4
DW
266
267 // TODO:
268
269} // end of wxPrinterDC::DoDrawBitmap
270
2c24e7ad
SN
271bool wxPrinterDCImpl::DoBlit( wxCoord WXUNUSED(vXdest),
272 wxCoord WXUNUSED(vYdest),
273 wxCoord WXUNUSED(vWidth),
274 wxCoord WXUNUSED(vHeight),
275 wxDC* WXUNUSED(pSource),
276 wxCoord WXUNUSED(vXsrc),
277 wxCoord WXUNUSED(vYsrc),
89efaf2b 278 wxRasterOperationMode WXUNUSED(nRop),
2c24e7ad
SN
279 bool WXUNUSED(bUseMask),
280 wxCoord WXUNUSED(xsrcMask),
281 wxCoord WXUNUSED(ysrcMask) )
e1a688e4 282{
cb7d7375 283 bool bSuccess = true;
e1a688e4
DW
284
285 // TODO:
286
287 return bSuccess;
2c24e7ad 288} // end of wxPrintDCImpl::DoBlit
e1a688e4 289
7e99520b 290#endif //wxUSE_PRINTING_ARCHITECTURE