1 /*****************************************************************************\
2 Copyright (c) 2002 - 2006, Hewlett-Packard Co.
5 Redistribution and use in source and binary forms, with or without
6 modification, are permitted provided that the following conditions
8 1. Redistributions of source code must retain the above copyright
9 notice, this list of conditions and the following disclaimer.
10 2. Redistributions in binary form must reproduce the above copyright
11 notice, this list of conditions and the following disclaimer in the
12 documentation and/or other materials provided with the distribution.
13 3. Neither the name of Hewlett-Packard nor the names of its
14 contributors may be used to endorse or promote products derived
15 from this software without specific prior written permission.
17 THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR IMPLIED
18 WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
19 MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
20 NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
22 TO, PATENT INFRINGEMENT; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
23 OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
24 ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 \*****************************************************************************/
30 #include "PrinterProperties.h"
33 PlatformServices::PlatformServices () : SystemServices ()
37 PlatformServices::~PlatformServices ()
41 float PlatformServices::power (float x, float y)
43 return float (pow (x, y));
46 BYTE * PlatformServices::AllocMem (int iMemSize)
48 return (BYTE *) malloc (iMemSize);
51 void PlatformServices::FreeMem (BYTE *pMem)
56 DWORD PlatformServices::GetSystemTickCount (void)
61 DRIVER_ERROR PlatformServices::BusyWait (DWORD msec)
66 void PlatformServices::DisplayPrinterStatus (DISPLAY_STATUS ePrinterStatus)
70 DRIVER_ERROR PlatformServices::ReadDeviceID (BYTE *strID, int iSize)
72 DRIVER_ERROR eResult = IO_ERROR;
76 BOOL PlatformServices::GetStatusInfo (BYTE *bStatReg)
82 DRIVER_ERROR PlatformServices::FromDevice (BYTE *pReadBuff, DWORD *wReadCount)
87 DRIVER_ERROR PlatformServices::ToDevice (const BYTE *pBuffer, DWORD *dwCount)
93 BOOL CreatePrinterProperties ()
95 pSys = new PlatformServices ();
96 pSys->IOMode.bDevID = FALSE;
97 pSys->IOMode.bStatus = FALSE;
98 pPC = new PrintContext (pSys);
99 iLastPrinter = MAX_PRINTER_TYPE;
103 int GetPrinterProperties (PrinterProperties *pPrinterProperties)
108 if (pPrinterProperties == NULL)
114 bResult = CreatePrinterProperties ();
115 if (bResult == FALSE)
117 return (int) bResult;
124 if (iCurrentPrinter == iLastPrinter)
136 err = pPC->SelectDevice ((PRINTER_TYPE) iCurrentPrinter);
139 if (iCurrentPrinter < iLastPrinter)
147 strcpy (pPrinterProperties->szClassName, ModelName[iCurrentPrinter]);
148 for (i = 0; i < (int) (sizeof (PaperSizeInfoData) / sizeof (PaperSizeInfo)); i++)
150 err = pPC->SetPaperSize (PaperSizeInfoData[i].iPaperSize, 0);
151 if (err == WARN_ILLEGAL_PAPERSIZE)
155 strcpy (pPrinterProperties->szPaperSize, PaperSizeInfoData[i].szName);
156 pPrinterProperties->fPhysicalWidth = pPC->PhysicalPageSizeX ();
157 pPrinterProperties->fPhysicalHeight = pPC->PhysicalPageSizeY ();
158 pPrinterProperties->fPrintableWidth = pPC->PrintableWidth ();
159 pPrinterProperties->fPrintableHeight = pPC->PrintableHeight ();
160 pPrinterProperties->fTopLeftX = pPC->PrintableStartX ();
161 pPrinterProperties->fTopLeftY = pPC->PrintableStartY ();
163 fprintf (stdout, "%s,%s,%.4f,%.4f,%.4f,%.4f,%.4f,%.4f\n",
164 pPrinterProperties->szClassName,
165 pPrinterProperties->szPaperSize,
166 pPrinterProperties->fPhysicalWidth,
167 pPrinterProperties->fPhysicalHeight,
168 pPrinterProperties->fTopLeftX,
169 pPrinterProperties->fTopLeftY,
170 pPrinterProperties->fPrintableWidth,
171 pPrinterProperties->fPrintableHeight);
179 PrinterProperties pPrProp;
180 GetPrinterProperties (&pPrProp);