OWLNext    7.0
Borland's Object Windows Library for the modern age
Loading...
Searching...
No Matches
printdc.cpp
Go to the documentation of this file.
1//----------------------------------------------------------------------------
2// ObjectWindows
3// Copyright (c) 1992, 1996 by Borland International, All Rights Reserved
4//
5/// \file
6/// Implementation of TPrintDC
7//----------------------------------------------------------------------------
8#include <owl/pch.h>
9
10#include <owl/dc.h>
11#include <owl/module.h>
12
13#if defined(OWL5_COMPAT)
14
15//
16// Supply missing function definition and macros for newer Win32 function
17// needed for TPrintDC::DeviceCapabilities.
18//
19 extern "C" {
24 #if defined(UNICODE)
25 #define DeviceCapabilitiesEx DeviceCapabilitiesExW
26 #else
27 #define DeviceCapabilitiesEx DeviceCapabilitiesExA
28 #endif // !UNICODE
29 }
30
31 #define PROC_DEVICECAPABILITIES MAKEINTRESOURCE(91)
32
33#endif
34
35namespace owl {
36
38
39#if defined(OWL5_COMPAT)
40
41//
42// Needed for TPrintDC::DeviceCapabilities.
43//
44class TPrinterDriverLibrary : public TModule {
45 public:
46 TPrinterDriverLibrary(const tstring& drvName);
47
49};
50
51//
52//
53//
54TPrinterDriverLibrary::TPrinterDriverLibrary(const tstring& drvName)
55:
56 TModule(drvName, true, true, false), // shouldLoad, mustLoad and !addToList
58{
59}
60
61#endif
62
63//
64/// Creates a TPrintDC object for the DC given by handle.
65//
66TPrintDC::TPrintDC(HDC handle, TAutoDelete autoDelete)
67:
69{
70 memset(&DocInfo, 0, sizeof(DocInfo));
71 DocInfo.cbSize = sizeof(DocInfo);
72 DocInfo.lpszOutput = _T("");
73 DocInfo.lpszDatatype = _T("");
74}
75
76//
77/// Creates a TPrintDC object for the given printer device name and initialization data.
78/// Pass `nullptr` for initData to use the default initializations specified by the user.
79//
82{
83 memset(&DocInfo, 0, sizeof(DocInfo));
84 DocInfo.cbSize = sizeof(DocInfo);
85 DocInfo.lpszOutput = _T("");
86 DocInfo.lpszDatatype = _T("");
87}
88
89#if defined(OWL5_COMPAT)
90
91//
92/// Creates a TPrintDC object given the print driver, device, output, and initialization data.
93/// Pass `nullptr` for initData to use the default initializations specified by the user.
94//
97:
99{
100 memset(&DocInfo, 0, sizeof(DocInfo));
101 DocInfo.cbSize = sizeof(DocInfo);
102 DocInfo.lpszOutput = _T("");
103 DocInfo.lpszDatatype = _T("");
104}
105
106//
107/// String-aware overload
108//
110 : TCreatedDC(driver, device, output, initData)
111{
112 memset(&DocInfo, 0, sizeof(DocInfo));
113 DocInfo.cbSize = sizeof(DocInfo);
114 DocInfo.lpszOutput = _T("");
115 DocInfo.lpszDatatype = _T("");
116}
117
118//
119/// Retrieves data about the specified capability of the named printer driver,
120/// device, and port, and places the results in the output char array. The driver,
121/// device, and port names must be zero-terminated strings. The devmode argument
122/// points to a DEVMODE struct. If devmode is 0 (the default), DeviceCapabilities
123/// retrieves the current default initialization values for the specified printer
124/// driver; otherwise, it retrieves the values contained in the DEVMODE structure.
125/// The format of the output array depends on the capability being queried. If
126/// output is 0 (the default), DeviceCapabilities returns the number of bytes
127/// required in the output array. Possible values for capability are as follows:
128/// - \c \b DC_BINNAMES The function enumerates the paper bins on the given device. If a
129/// device driver supports this constant, the output array is a data structure that
130/// contains two members. The first member is an array identifying valid paper bins:
131/// \code
132/// short BinList[cBinMax]
133/// \endcode
134/// The second member is an array of character strings specifying the bin names:
135/// \code
136/// char PaperNames[cBinMax][cchBinName]
137/// \endcode
138/// If a device driver does not support this value, the output array is empty and
139/// the return value is NULL.
140/// If output is NULL, the return value specifies the number of bins supported.
141/// - \c \b DC_BINS The function retrieves a list of constants that identify the available
142/// bins and copies the list to the output array. If this array is NULL, the
143/// function returns the number of supported bins. The following bin identifiers can
144/// be returned:
145/// \code
146/// DMBIN_AUTO
147/// DMBIN_CASSETTE
148/// DMBIN_ENVELOPE
149/// DMBIN_ENVMANUAL
150/// DMBIN_FIRST
151/// DMBIN_LARGECAPACITY
152/// DMBIN_LARGEFMT
153/// DMBIN_LAST
154/// DMBIN_LOWER
155/// DMBIN_MANUAL
156/// DMBIN_MIDDLE
157/// DMBIN_ONLYONE
158/// DMBIN_SMALLFMT
159/// DMBIN_TRACTOR
160/// DMBIN_UPPER
161/// \endcode
162/// - \c \b DC_DRIVER The function returns the driver version number.
163/// - \c \b DC_DUPLEX The function returns the level of duplex support. The return value is
164/// 1 if the function supports duplex output; otherwise it is 0.
165/// - \c \b DC_ENUMRESOLUTIONS
166/// The function copies a list of available printer resolutions to the output array.
167/// The resolutions are copied as pairs of int32 integers; the first value of the
168/// pair specifies the horizontal resolution and the second value specifies the
169/// vertical resolution. If output is 0, the function returns the number of
170/// supported resolutions.
171/// - \c \b DC_EXTRA The function returns the number of bytes required for the
172/// device-specific data that is appended to the DEVMODE structure.
173/// - \c \b DC_FIELDS The function returns a value indicating which members of the DEVMODE
174/// structure are set by the device driver. This value can be one or more of the
175/// following constants:
176/// \code
177/// DM_ORIENTATION
178/// DM_PAPERSIZE
179/// DM_PAPERLENGTH
180/// DM_PAPERWIDTH
181/// DM_SCALE
182/// DM_COPIES
183/// DM_DEFAULTSOURCE
184/// DM_PRINTQUALITY
185/// DM_COLOR
186/// DM_DUPLEX
187/// DM_YRESOLUTION
188/// DM_TTOPTION
189/// DC_FILEDEPENDENCIES
190/// \endcode
191/// The function returns a list of files that must be loaded when the device driver
192/// is installed. If output is 0 and this value is specified, the function returns
193/// the number of file names that must be loaded. If output is nonzero, the function
194/// returns the specified number of 64-character file names.
195/// - \c \b DC_MAXEXTENT The function returns the maximum supported paper-size. These
196/// dimensions are returned in a POINT structure; the x member gives the maximum
197/// paper width and the y member gives the maximum paper length.
198/// - \c \b DC_MINEXTENT The function returns the minimum supported paper-size. These
199/// dimensions are returned in a POINT structure; the x member gives the minimum
200/// paper width and the y member gives the minimum paper length.
201/// - \c \b DC_ORIENTATION This function returns the number of degrees that a
202/// portrait-oriented paper is rotated counterclockwise to produce landscape
203/// orientation. if the return value is 0, there is no landscape orientation. If the
204/// return value is 90, the portrait-oriented paper is rotated 90 degrees (as is the
205/// case when HP laser printers are used). if the return value is 270, the
206/// portrait-oriented paper is rotated 270 degrees (as is the case when dot-matrix
207/// printers are used).
208/// - \c \b DC_PAPERNAMES This function returns a list of supported paper names such as
209/// Letter size or Legal size. The output array points to an array containing the
210/// paper names. If the output array is 0, the function returns the number of
211/// available paper sizes.
212/// - \c \b DC_PAPERS The function retrieves a list of supported paper sizes and copies it
213/// to the output array. The function returns the number of sizes identified in the
214/// array. If output is 0, the function returns the number of supported paper sizes.
215/// - \c \b DC_PAPERSIZE The function retrieves the supported paper sizes (specified in .1
216/// millimeter units) and copies them to the output array.
217/// - \c \b DC_SIZE The function returns the size of the DEVMODE structure required by the
218/// given device driver.
219/// - \c \b DC_TRUETYPE This function returns the printer driver's TrueType font
220/// capabilities. The values returned can be one or more of the following constants:
221/// - \c \b DCTT_BITMAP Device supports printing TrueType fonts as graphics. (Dot-matrix and
222/// PCL printers)
223/// - \c \b DCTT_DOWNLOAD Device supports downloading TryeType fonts. (PostScript and PCL
224/// printers)
225/// - \c \b DCTT_SUBDEV Device supports substituting device fonts for TrueType fonts.
226/// (PostScript printers)
227/// - \c \b DC_VERSION The function returns the device driver version number.
228/// If DeviceCapabilities succeeds, the return value depends on the value of
229/// capability, as noted above. Otherwise, the return value is GDI_ERROR.
230///
231/// \note This function is deprecated. Use Win32 DeviceCapabilities instead.
232//
233uint32
234TPrintDC::DeviceCapabilities(LPCTSTR driver,
237 int capability,
240{
241 // Hand call DeviceCapabilities due to Win32s missing function!
242 //
243 uint32 caps = 0;
244
245#if !defined(WINELIB)
246 // Try the Win32 DeviceCapabilitiesEx function
247 //
249 if (GetLastError() != ERROR_CALL_NOT_IMPLEMENTED)
250 return caps;
251#endif
252
253 // Locate & call the DeviceCapabilities function within the printer driver
254 // itself.
255 //
256 try {
258 caps = driverLib.DeviceCapabilities(device, port, (uint16)capability, output, devmode);
259 }
260 catch (...) {
261 }
262 return caps;
263}
264
265//
266/// String-aware overload
267//
268uint32 TPrintDC::DeviceCapabilities(
269 const tstring& driver,
270 const tstring& device,
271 const tstring& port,
272 int capability,
275{
276 return DeviceCapabilities(
277 driver.empty() ? 0 : driver.c_str(),
278 device.empty() ? 0 : device.c_str(),
279 port.empty() ? 0 : port.c_str(),
281 output,
282 devmode);
283}
284
285#endif
286
287} // OWL namespace
288/* ========================================================================== */
289
An abstract TDC class, TCreatedDC serves as the base for DCs that are created and deleted.
Definition dc.h:724
TPrintDC(HDC handle, TAutoDelete autoDelete=NoAutoDelete)
Creates a TPrintDC object for the DC given by handle.
Definition printdc.cpp:66
#define _T(x)
Definition cygwin.h:51
Definition of GDI DC encapsulation classes: TDC, TWindowDC, TScreenDC, TDesktopDC,...
TAutoDelete
Flag for Handle ctors to control Handle deletion in dtor.
Definition gdibase.h:70
Definition of class TModule.
Object Windows Library (OWLNext Core)
Definition animctrl.h:22
unsigned long uint32
Definition number.h:34
OWL_DIAGINFO
Definition animctrl.cpp:14
unsigned short uint16
Definition number.h:33
std::string tstring
Definition defs.h:79