]> git.saurik.com Git - wxWidgets.git/blame_incremental - src/os2/dcprint.cpp
Don't build tex2rtf and HelpGen utils in non-GUI buildbot builds.
[wxWidgets.git] / src / os2 / dcprint.cpp
... / ...
CommitLineData
1/////////////////////////////////////////////////////////////////////////////
2// Name: src/os2/dcprint.cpp
3// Purpose: wxPrinterDC class
4// Author: David Webster
5// Modified by:
6// Created: 10/14/99
7// RCS-ID: $Id$
8// Copyright: (c) David Webster
9// Licence: wxWindows licence
10/////////////////////////////////////////////////////////////////////////////
11
12// For compilers that support precompilation, includes "wx.h".
13#include "wx/wxprec.h"
14
15#if wxUSE_PRINTING_ARCHITECTURE
16
17#include "wx/dcprint.h"
18#include "wx/os2/dcprint.h"
19
20#define INCL_DEV
21#define INCL_GPI
22#define INCL_PM
23#include<os2.h>
24
25#ifndef WX_PRECOMP
26 #include "wx/app.h"
27 #include "wx/math.h"
28 #include "wx/string.h"
29 #include "wx/log.h"
30 #include "wx/window.h"
31#endif
32
33#include "wx/os2/private.h"
34
35IMPLEMENT_ABSTRACT_CLASS(wxPrinterDCImpl, wxPMDCImpl)
36
37wxPrinterDCImpl::wxPrinterDCImpl( wxPrinterDC *owner, const wxPrintData& rPrintData ) :
38 wxPMDCImpl( owner )
39{
40 m_printData = rPrintData;
41 m_isInteractive = false;
42 m_hDC = wxGetPrinterDC(rPrintData);
43 m_ok = (m_hDC != 0);
44 if (m_hDC)
45 SetMapMode(wxMM_TEXT);
46 SetBrush(*wxBLACK_BRUSH);
47 SetPen(*wxBLACK_PEN);
48} // end of wxPrinterDC::wxPrinterDC
49
50wxPrinterDCImpl::wxPrinterDCImpl( wxPrinterDC *owner, WXHDC hTheDC ) :
51 wxPMDCImpl( owner )
52{
53 m_isInteractive = false;
54 m_hDC = hTheDC;
55 m_ok = true;
56 if (m_hDC)
57 {
58 SetMapMode(wxMM_TEXT);
59 }
60 SetBrush(*wxBLACK_BRUSH);
61 SetPen(*wxBLACK_PEN);
62} // end of wxPrinterDC::wxPrinterDC
63
64void wxPrinterDCImpl::Init()
65{
66 if (m_hDC)
67 {
68 SetMapMode(wxMM_TEXT);
69
70 SetBrush(*wxBLACK_BRUSH);
71 SetPen(*wxBLACK_PEN);
72 }
73} // end of wxPrinterDC::Init
74
75bool wxPrinterDCImpl::StartDoc(const wxString& WXUNUSED(rsMessage))
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
84 if (filename.empty())
85 docinfo.lpszOutput = NULL;
86 else
87 docinfo.lpszOutput = (const wxChar *) filename;
88
89 docinfo.lpszDatatype = NULL;
90 docinfo.fwType = 0;
91
92 if (!m_hDC)
93 return false;
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();
114 wxLogDebug(wxT("wxDC::StartDoc failed with error: %d\n"), lastError);
115 }
116#endif
117 return (ret > 0);
118*/
119 return true;
120} // end of wxPrinterDC::StartDoc
121
122void wxPrinterDCImpl::EndDoc()
123{
124// if (m_hDC) ::EndDoc((HDC) m_hDC);
125} // end of wxPrinterDC::EndDoc
126
127void wxPrinterDCImpl::StartPage()
128{
129// if (m_hDC)
130// ::StartPage((HDC) m_hDC);
131} // end of wxPrinterDC::StartPage
132
133void wxPrinterDCImpl::EndPage()
134{
135// if (m_hDC)
136// ::EndPage((HDC) m_hDC);
137} // end of wxPrinterDC::EndPage
138
139wxRect wxPrinterDCImpl::GetPaperRect() const
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
147#if 0
148// Returns default device and port names
149static bool wxGetDefaultDeviceName( wxString& rsDeviceName, wxString& rsPortName )
150{
151 rsDeviceName = wxEmptyString;
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
180 return false;
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 }
202 return !deviceName.empty();
203*/
204 return true;
205} // end of wxGetDefaultDeviceName
206#endif
207
208// Gets an HDC for the specified printer configuration
209WXHDC WXDLLEXPORT wxGetPrinterDC( const wxPrintData& WXUNUSED(rPrintDataConst) )
210{
211 HDC hDC = NULLHANDLE;
212/*
213 wxPrintData printData = printDataConst;
214 printData.ConvertToNative();
215
216 wxChar* driverName = NULL;
217
218 wxString devNameStr = printData.GetPrinterName();
219 wxChar* deviceName;
220 wxChar* portName = NULL; // Obsolete in WIN32
221
222 if (devNameStr.empty())
223 deviceName = NULL;
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
234 if (devNameStr.empty())
235 {
236 // Retrieve the default device name
237 wxString portName;
238 bool ret = wxGetDefaultDeviceName(devNameStr, portName);
239
240 wxASSERT_MSG( ret, wxT("Could not get default device name.") );
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;
255} // end of wxGetPrinterDC
256
257void wxPrinterDCImpl::DoDrawBitmap( const wxBitmap& rBmp,
258 wxCoord WXUNUSED(vX),
259 wxCoord WXUNUSED(vY),
260 bool WXUNUSED(bUseMask))
261{
262 wxCHECK_RET( rBmp.IsOk(), wxT("invalid bitmap in wxPrinterDC::DrawBitmap") );
263
264// int nWidth = rBmp.GetWidth();
265// int nHeight = rBmp.GetHeight();
266
267 // TODO:
268
269} // end of wxPrinterDC::DoDrawBitmap
270
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),
278 wxRasterOperationMode WXUNUSED(nRop),
279 bool WXUNUSED(bUseMask),
280 wxCoord WXUNUSED(xsrcMask),
281 wxCoord WXUNUSED(ysrcMask) )
282{
283 bool bSuccess = true;
284
285 // TODO:
286
287 return bSuccess;
288} // end of wxPrintDCImpl::DoBlit
289
290#endif //wxUSE_PRINTING_ARCHITECTURE