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