69 void EmuPrint_ESC_P2(
W32_PRINTER_INFO *pInfo,
const void *pText,
size_t uiLength,
int isunicode );
77 , {
"ESC/P2", EmuPrint_ESC_P2 }
97 node->
device = strdup(device);
134 if( strcasecmp( pszDevice, node->
device )==0 )
150 if( strcasecmp( pszPrinterName, node->
printer_name )==0 )
158 DWORD dwNeeded = 0, dwReturned = 0;
159 PRINTER_INFO_5 *result =
NULL;
160 DWORD dwFlags = PRINTER_ENUM_DEFAULT;
166 BOOL fResult = EnumPrinters(dwFlags,
175 if (GetLastError()!=ERROR_INSUFFICIENT_BUFFER)
178 result = (PRINTER_INFO_5*) realloc( result, dwNeeded );
182 fResult = EnumPrinters(dwFlags,
191 *pCount = dwReturned;
198 DWORD dwNeeded = 0, dwReturned = 0;
199 PRINTER_INFO_2 *result =
NULL;
200 DWORD dwFlags = PRINTER_ENUM_LOCAL | PRINTER_ENUM_CONNECTIONS;
206 BOOL fResult = EnumPrinters(dwFlags,
215 if (GetLastError()!=ERROR_INSUFFICIENT_BUFFER)
218 result = (PRINTER_INFO_2*) realloc( result, dwNeeded );
222 fResult = EnumPrinters(dwFlags,
231 *pCount = dwReturned;
242 HMODULE hMod = LoadLibrary(TEXT(
"winspool.drv"));
245 LPCTSTR pszPrinterId = TEXT(
"GetDefaultPrinterW");
247 LPCTSTR pszPrinterId = TEXT(
"GetDefaultPrinterA");
251 if (pfnGetDefaultPrinter!=
NULL) {
254 BOOL fResult = pfnGetDefaultPrinter(
NULL, &dwSize);
256 if (GetLastError()!=ERROR_INSUFFICIENT_BUFFER)
258 buffer = (TCHAR*) realloc(buffer, dwSize *
sizeof(TCHAR));
259 fResult = pfnGetDefaultPrinter(buffer, &dwSize);
269 result = strdup(printers->pPrinterName);
280 for( i=0; i!=count; ++i ) {
281 PRINTER_INFO_2 *printer = printers + i;
282 if( printer->pServerName==
NULL ) {
284 LPTSTR pPortName = printer->pPortName;
285 LPTSTR pFoundPos = strchr(pPortName,
',');
292 if( strncasecmp( pPortName,
"LPT", 3 )==0 ) {
299 pPortName = pFoundPos + 1;
300 while( isspace( *pPortName ) )
302 pFoundPos = strchr(pPortName,
',');
304 if( strncasecmp( pPortName,
"LPT", 3 )==0 ) {
319 int iPort = iStartPort - 1;
322 if( printer_name!=
NULL ) {
328 sprintf( Buffer,
"LPT%d", iPort );
330 }
while( node!=
NULL );
334 free( printer_name );
344 int i, count, iPort = iStartPort - 1;
347 for( i=0; i!=count; ++i ) {
348 PRINTER_INFO_2 *printer = printers + i;
353 sprintf( Buffer,
"LPT%d", iPort );
355 }
while( node!=
NULL );
388 char *printer_name =
NULL;
389 char *doc_title =
NULL;
394 if( lpt_proto!=
NULL )
400 if( *lpt_proto->
emu!=0 ) {
407 if( strcasecmp( lpt_proto->
emu, pEmu->
pszId )==0 ) {
414 if( lpt_proto!=
NULL )
422 if( *lpt_proto->
name )
424 printer_name = strdup( lpt_proto->
name );
446 if( printer_name ==
NULL ) {
449 if( *lpt_proto->
emu!=
'\0' ) {
452 hDc = CreateDCA(
"WINSPOOL",
459 fResult = OpenPrinter(printer_name, &hPrinter,
NULL);
467 doc_title = strdup( lpt_proto->
title );
469 doc_title = strdup(
"FreeBASIC document" );
473 if( *lpt_proto->
emu!=
'\0' ) {
476 memset( &docInfo, 0,
sizeof(DOCINFO) );
477 docInfo.cbSize =
sizeof(DOCINFO);
478 docInfo.lpszDocName = doc_title;
479 iJob = StartDoc( hDc, &docInfo );
483 dwJob = (
DWORD) iJob;
487 DocInfo.pDocName = doc_title;
488 DocInfo.pOutputFile =
NULL;
489 DocInfo.pDatatype = TEXT(
"RAW");
491 dwJob = StartDocPrinter( hPrinter, 1, (BYTE*) &DocInfo );
505 pInfo->
dwJob = dwJob;
512 pInfo->
Emu.
dwSizeX = GetDeviceCaps( hDc, HORZRES );
513 pInfo->
Emu.
dwSizeY = GetDeviceCaps( hDc, VERTRES );
514 pInfo->
Emu.
dwOffsetX = GetDeviceCaps( hDc, PHYSICALOFFSETX );
515 pInfo->
Emu.
dwOffsetY = GetDeviceCaps( hDc, PHYSICALOFFSETY );
516 pInfo->
Emu.
dwDPI_X = GetDeviceCaps( hDc, LOGPIXELSX );
517 pInfo->
Emu.
dwDPI_Y = GetDeviceCaps( hDc, LOGPIXELSY );
533 pInfo->
Emu.
hFont = CreateFontIndirect( &lf );
540 SetTextAlign( hDc, TA_TOP | TA_LEFT | TA_NOUPDATECP );
549 if( *lpt_proto->
emu !=
'\0' ) {
552 EndDocPrinter( hPrinter );
555 if( hPrinter!=
NULL ) {
556 ClosePrinter( hPrinter );
563 if( printer_name!=
NULL )
564 free( printer_name );
565 if( doc_title!=
NULL )
567 if( lpt_proto!=
NULL )
578 memset( lf, 0,
sizeof( LOGFONT ) );
580 lf->lfWeight = FW_NORMAL;
581 lf->lfCharSet = OEM_CHARSET;
582 lf->lfOutPrecision = OUT_DEFAULT_PRECIS;
583 lf->lfClipPrecision = CLIP_DEFAULT_PRECIS;
584 lf->lfQuality = DRAFT_QUALITY;
587 lf->lfPitchAndFamily = FIXED_PITCH | FF_MODERN;
588 strcpy( lf->lfFaceName,
"System" );
591 lf->lfPitchAndFamily = VARIABLE_PITCH | FF_SWISS;
592 strcpy( lf->lfFaceName,
"MS Sans Serif" );
602 GetTextMetrics( pInfo->
hDc, &tm );
612 StartPage( pInfo->
hDc );
626 while( uiLength-- ) {
629 char ch = *(
char *)pText;
630 pText +=
sizeof(char);
642 TextOutW( pInfo->
hDc,
654 EndPage( pInfo->
hDc );
673 StartPage( pInfo->
hDc );
675 EndPage( pInfo->
hDc );
676 while( rows >= page_rows ) {
677 StartPage( pInfo->
hDc );
678 EndPage( pInfo->
hDc );
734 while( uiLength!=0 ) {
736 unsigned uiLengthTTY = uiLength, ui;
738 for( ui=0; ui!=uiLength; ++ui ) {
740 char ch = ((
char *)pText)[ui];
757 if( uiLength!=uiLengthTTY ) {
761 switch( chControl ) {
768 pText += uiLengthTTY *
sizeof(char);
769 uiLength -= uiLengthTTY;
774 while( uiLength!=0 ) {
776 unsigned uiLengthTTY = uiLength, ui;
778 for( ui=0; ui!=uiLength; ++ui ) {
797 if( uiLength!=uiLengthTTY ) {
801 switch( chControl ) {
808 pText += uiLengthTTY *
sizeof(
FB_WCHAR);
809 uiLength -= uiLengthTTY;
826 const char *pachText,
841 }
else if( !WritePrinter( pInfo->
hPrinter,
848 }
else if ( dwWritten != length ) {
864 }
else if( !WritePrinter( pInfo->
hPrinter,
871 }
else if ( dwWritten != length *
sizeof(
FB_WCHAR )) {
884 EndPage( pInfo->
hDc );
885 EndDoc( pInfo->
hDc );
886 DeleteDC( pInfo->
hDc );