diff --git a/harbour/contrib/hbwin/tests/testprn.prg b/harbour/contrib/hbwin/tests/testprn.prg index c05d381706..cf85246a53 100644 --- a/harbour/contrib/hbwin/tests/testprn.prg +++ b/harbour/contrib/hbwin/tests/testprn.prg @@ -150,7 +150,7 @@ STATIC PROCEDURE PrintBitMap( oPrn, cBitFile ) ELSEIF !File( cBitFile ) Alert( cBitFile + " not found " ) ELSE - oBMP := WinBMP():New() + oBMP := Win_BMP():New() IF oBmp:loadFile( cBitFile ) oBmp:Draw( oPrn, { 200, 200, 2000, 1500 } ) diff --git a/harbour/contrib/hbwin/win_misc.c b/harbour/contrib/hbwin/win_misc.c index e685d47a08..7c5b123c48 100644 --- a/harbour/contrib/hbwin/win_misc.c +++ b/harbour/contrib/hbwin/win_misc.c @@ -106,7 +106,7 @@ HB_FUNC( WIN_RUNDETACHED ) &pi ) /* Pointer to PROCESS_INFORMATION structure */ ) { - hb_stornl( pi.dwProcessId, 2 ); + hb_stornl( pi.dwProcessId, 3 ); hb_retl( TRUE ); /* Close process and thread handles. */ diff --git a/harbour/contrib/hbwin/win_prn1.c b/harbour/contrib/hbwin/win_prn1.c index fa77066c82..6150861d29 100644 --- a/harbour/contrib/hbwin/win_prn1.c +++ b/harbour/contrib/hbwin/win_prn1.c @@ -89,45 +89,43 @@ static HB_GARBAGE_FUNC( win_HDC_release ) { - void ** phDC = ( void ** ) Cargo; + void ** ph = ( void ** ) Cargo; /* Check if pointer is not NULL to avoid multiple freeing */ - if( phDC && * phDC ) + if( ph && *ph ) { /* Destroy the object */ - DeleteDC( ( HDC ) * phDC ); + DeleteDC( ( HDC ) *ph ); /* set pointer to NULL to avoid multiple freeing */ - * phDC = NULL; + *ph = NULL; } } static HDC win_HDC_par( int iParam ) { if( ISNUM( iParam ) ) - { return ( HDC ) ( HB_PTRDIFF ) hb_parnint( iParam ); - } else { - void ** phDC = ( void ** ) hb_parptrGC( win_HDC_release, iParam ); + void ** ph = ( void ** ) hb_parptrGC( win_HDC_release, iParam ); - return phDC ? ( HDC ) * phDC : NULL; + return ph ? ( HDC ) * ph : hb_parptr( iParam ); } } static HB_GARBAGE_FUNC( win_HPEN_release ) { - void ** phPEN = ( void ** ) Cargo; + void ** ph = ( void ** ) Cargo; /* Check if pointer is not NULL to avoid multiple freeing */ - if( phPEN && * phPEN ) + if( ph && * ph ) { /* Destroy the object */ - DeleteObject( ( HDC ) * phPEN ); + DeleteObject( ( HDC ) * ph ); /* set pointer to NULL to avoid multiple freeing */ - * phPEN = NULL; + * ph = NULL; } } @@ -136,9 +134,9 @@ HB_FUNC( WIN_CREATEDC ) if( ISCHAR( 1 ) ) { LPTSTR lpText = HB_TCHAR_CONVTO( hb_parc( 1 ) ); - void ** phDC = ( void ** ) hb_gcAlloc( sizeof( HDC * ), win_HDC_release ); - * phDC = ( void * ) CreateDC( TEXT( "" ), lpText, NULL, NULL ); - hb_retptrGC( phDC ); + void ** ph = ( void ** ) hb_gcAlloc( sizeof( HDC * ), win_HDC_release ); + *ph = ( void * ) CreateDC( TEXT( "" ), lpText, NULL, NULL ); + hb_retptrGC( ph ); HB_TCHAR_FREE( lpText ); } else @@ -185,6 +183,13 @@ HB_FUNC( WIN_ENDDOC ) hb_retl( Result ); } +HB_FUNC( WIN_ABORTDOC ) +{ + HDC hDC = win_HDC_par( 1 ); + + hb_retl( hDC && ( AbortDoc( hDC ) > 0 ) ); +} + HB_FUNC( WIN_DELETEDC ) { void ** phDC = ( void ** ) hb_parptrGC( win_HDC_release, 1 ); @@ -600,19 +605,19 @@ HB_FUNC( WIN_SETPEN ) HDC hDC = win_HDC_par( 1 ); HPEN hOldPen; - void ** phPEN = ( void ** ) hb_gcAlloc( sizeof( HPEN * ), win_HPEN_release ); + void ** ph = ( void ** ) hb_gcAlloc( sizeof( HPEN * ), win_HPEN_release ); - * phPEN = ( void * ) CreatePen( hb_parni( 2 ), /* pen style */ - hb_parni( 3 ), /* pen width */ - ( COLORREF ) hb_parnl( 4 ) /* pen color */ - ); + * ph = ( void * ) CreatePen( hb_parni( 2 ), /* pen style */ + hb_parni( 3 ), /* pen width */ + ( COLORREF ) hb_parnl( 4 ) /* pen color */ + ); - hOldPen = ( HPEN ) SelectObject( hDC, ( HPEN ) * phPEN ); + hOldPen = ( HPEN ) SelectObject( hDC, ( HPEN ) * ph ); if( hOldPen ) DeleteObject( hOldPen ); - hb_retptrGC( phPEN ); + hb_retptrGC( ph ); } HB_FUNC( WIN_FILLRECT ) diff --git a/harbour/contrib/hbwin/win_prn2.c b/harbour/contrib/hbwin/win_prn2.c index 3b1efa697d..b4dfd8b850 100644 --- a/harbour/contrib/hbwin/win_prn2.c +++ b/harbour/contrib/hbwin/win_prn2.c @@ -73,12 +73,12 @@ BOOL hb_isLegacyDevice( LPSTR pPrinterName ) int n = 0; LPSTR pszPrnDev[] = { "lpt1", "lpt2", "lpt3", "lpt4", "lpt5", "lpt6", "com1", "com2", "com3", "com4", NULL }; - while( pszPrnDev[n] && !bLegacyDev ) + while( pszPrnDev[ n ] && !bLegacyDev ) { bLegacyDev = ( hb_strnicmp( pPrinterName, pszPrnDev[n], strlen( pszPrnDev[n] ) ) == 0 ); n++; } - return ( bLegacyDev ); + return bLegacyDev; } @@ -161,8 +161,9 @@ BOOL hb_GetDefaultPrinter( char * pPrinterName, LPDWORD pdwBufferSize ) if( fnGetDefaultPrinter ) { - Result = ( *fnGetDefaultPrinter ) ( pPrinterName, pdwBufferSize ); + Result = ( *fnGetDefaultPrinter )( pPrinterName, pdwBufferSize ); } + FreeLibrary( hWinSpool ); } } @@ -175,17 +176,14 @@ BOOL hb_GetDefaultPrinter( char * pPrinterName, LPDWORD pdwBufferSize ) { dwSize = 0; while( pPrinterName[ dwSize ] != '\0' && pPrinterName[ dwSize ] != ',' ) - { dwSize++; - } + pPrinterName[ dwSize ] = '\0'; *pdwBufferSize = dwSize + 1; Result = TRUE; } else - { *pdwBufferSize = dwSize + 1; - } } if( !Result && osvi.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS ) @@ -233,23 +231,19 @@ BOOL hb_GetDefaultPrinter( char * pPrinterName, LPDWORD pdwBufferSize ) } } } - return ( Result ); + return Result; } HB_FUNC( GETDEFAULTPRINTER ) { - char szDefaultPrinter[MAXBUFFERSIZE]; - DWORD pdwBufferSize = MAXBUFFERSIZE; + char szDefaultPrinter[ MAXBUFFERSIZE ]; + DWORD pdwBufferSize = sizeof( szDefaultPrinter ); if( hb_GetDefaultPrinter( szDefaultPrinter, &pdwBufferSize ) ) - { hb_retclen( szDefaultPrinter, pdwBufferSize - 1 ); - } else - { hb_retc( NULL ); - } } BOOL hb_GetPrinterNameByPort( char * pPrinterName, LPDWORD pdwBufferSize, @@ -257,7 +251,7 @@ BOOL hb_GetPrinterNameByPort( char * pPrinterName, LPDWORD pdwBufferSize, { BOOL Result = FALSE, bFound = FALSE; ULONG needed, returned, a; - PRINTER_INFO_5 *pPrinterEnum, *buffer; + PRINTER_INFO_5 * pPrinterEnum, * buffer; HB_TRACE( HB_TR_DEBUG, ( "hb_GetPrinterNameByPort(%p,%p)", pPrinterName, pPortName ) ); @@ -275,14 +269,11 @@ BOOL hb_GetPrinterNameByPort( char * pPrinterName, LPDWORD pdwBufferSize, char * szPortName = HB_TCHAR_CONVFROM( pPrinterEnum->pPortName ); if( bSubStr ) - { - bFound = hb_strnicmp( szPortName, pPortName, strlen( pPortName ) ) == 0; - } + bFound = ( hb_strnicmp( szPortName, pPortName, strlen( pPortName ) ) == 0 ); else - { bFound = ( hb_stricmp( szPortName, pPortName ) == 0 ); - } HB_TCHAR_FREE( szPortName ); + if( bFound ) { char * szPrinterName = HB_TCHAR_CONVFROM( pPrinterEnum->pPrinterName ); @@ -310,13 +301,9 @@ HB_FUNC( PRINTERPORTTONAME ) if( ISCHAR( 1 ) && hb_parclen( 1 ) > 0 && hb_GetPrinterNameByPort( szDefaultPrinter, &pdwBufferSize, hb_parcx( 1 ), ISLOG( 2 ) ? hb_parl( 2 ) : FALSE ) ) - { hb_retc( szDefaultPrinter ); - } else - { hb_retc( NULL ); - } } # define BIG_PRINT_BUFFER (1024*32) @@ -349,37 +336,28 @@ LONG hb_PrintFileRaw( UCHAR * cPrinterName, UCHAR * cFileName, UCHAR * cDocName && ( nRead > 0 ) ) { if( printBuffer[ nRead - 1 ] == 26 ) - { nRead--; /* Skip the EOF() character */ - } + WritePrinter( hPrinter, printBuffer, nRead, &nWritten ); } Result = 1; CloseHandle( hFile ); } else - { Result = -6; - } EndPagePrinter( hPrinter ); } else - { Result = -4; - } EndDocPrinter( hPrinter ); } else - { Result = -3; - } HB_TCHAR_FREE( lpDocName ); ClosePrinter( hPrinter ); } else - { Result = -2; - } HB_TCHAR_FREE( lpPrinterName ); @@ -407,12 +385,12 @@ HB_FUNC( GETPRINTERS ) DWORD Flags = PRINTER_ENUM_LOCAL | PRINTER_ENUM_CONNECTIONS; BOOL bPrinterNamesOnly = TRUE; BOOL bLocalPrintersOnly; - PRINTER_INFO_4 *buffer4, *pPrinterEnum4; - PRINTER_INFO_5 *buffer, *pPrinterEnum; - PRINTER_INFO_2 *pPrinterInfo2; + PRINTER_INFO_4 * buffer4, * pPrinterEnum4; + PRINTER_INFO_5 * buffer, * pPrinterEnum; + PRINTER_INFO_2 * pPrinterInfo2; ULONG needed = 0, returned = 0, a; PHB_ITEM SubItems, File, Port, Net, Driver, ArrayPrinter; - char *pszData; + char * pszData; ArrayPrinter = hb_itemNew( NULL ); SubItems = hb_itemNew( NULL ); @@ -421,16 +399,13 @@ HB_FUNC( GETPRINTERS ) Net = hb_itemNew( NULL ); Driver = hb_itemNew( NULL ); - hb_arrayNew( ArrayPrinter, 0 ); buffer = NULL; HB_TRACE( HB_TR_DEBUG, ( "GETPRINTERS()" ) ); if( ISLOG( 1 ) ) - { - bPrinterNamesOnly = !hb_parl( 1 ); - } + bPrinterNamesOnly = ! hb_parl( 1 ); bLocalPrintersOnly = ISLOG( 2 ) ? hb_parl( 2 ) : FALSE; @@ -450,7 +425,7 @@ HB_FUNC( GETPRINTERS ) { for( a = 0; a < returned; a++, pPrinterEnum4++ ) { - if( !bLocalPrintersOnly + if( ! bLocalPrintersOnly || pPrinterEnum4->Attributes & PRINTER_ATTRIBUTE_LOCAL ) { pszData = HB_TCHAR_CONVFROM( pPrinterEnum4->pPrinterName ); @@ -464,7 +439,7 @@ HB_FUNC( GETPRINTERS ) { for( a = 0; a < returned; a++, pPrinterEnum4++ ) { - if( !bLocalPrintersOnly + if( ! bLocalPrintersOnly || pPrinterEnum4->Attributes & PRINTER_ATTRIBUTE_LOCAL ) { if( OpenPrinter( pPrinterEnum4->pPrinterName, &hPrinter, NULL ) ) @@ -481,8 +456,7 @@ HB_FUNC( GETPRINTERS ) hb_arrayNew( SubItems, 0 ); - if( GetPrinter - ( hPrinter, 2, ( LPBYTE ) pPrinterInfo2, needed, &needed ) ) + if( GetPrinter( hPrinter, 2, ( LPBYTE ) pPrinterInfo2, needed, &needed ) ) { pszData = HB_TCHAR_CONVFROM( pPrinterInfo2->pPortName ); hb_itemPutC( Port, pszData ); @@ -498,20 +472,11 @@ HB_FUNC( GETPRINTERS ) } if( pPrinterEnum4->Attributes & PRINTER_ATTRIBUTE_LOCAL ) - { hb_itemPutC( Net, "LOCAL" ); - } + else if( pPrinterEnum4->Attributes & PRINTER_ATTRIBUTE_NETWORK ) + hb_itemPutC( Net, "NETWORK" ); else - { - if( pPrinterEnum4->Attributes & PRINTER_ATTRIBUTE_NETWORK ) - { - hb_itemPutC( Net, "NETWORK" ); - } - else - { - hb_itemPutC( Net, "ERROR" ); - } - } + hb_itemPutC( Net, "ERROR" ); hb_arrayAddForward( SubItems, File ); hb_arrayAddForward( SubItems, Port ); @@ -558,7 +523,7 @@ HB_FUNC( GETPRINTERS ) /* Tony (ABC) 11/1/2005 1:40PM. */ for( a = 0; a < returned; a++, pPrinterEnum++ ) { - if( !bLocalPrintersOnly + if( ! bLocalPrintersOnly || pPrinterEnum->Attributes & PRINTER_ATTRIBUTE_LOCAL ) { if( OpenPrinter( pPrinterEnum->pPrinterName, &hPrinter, NULL ) ) @@ -574,9 +539,7 @@ HB_FUNC( GETPRINTERS ) hb_itemPutC( File, pszData ); HB_TCHAR_FREE( pszData ); - if( GetPrinter - ( hPrinter, 2, ( LPBYTE ) pPrinterInfo2, needed, - &needed ) ) + if( GetPrinter( hPrinter, 2, ( LPBYTE ) pPrinterInfo2, needed, &needed ) ) { pszData = HB_TCHAR_CONVFROM( pPrinterInfo2->pPortName ); hb_itemPutC( Port, pszData ); @@ -592,20 +555,11 @@ HB_FUNC( GETPRINTERS ) } if( pPrinterEnum->Attributes & PRINTER_ATTRIBUTE_LOCAL ) - { hb_itemPutC( Net, "LOCAL" ); - } + else if( pPrinterEnum->Attributes & PRINTER_ATTRIBUTE_NETWORK ) + hb_itemPutC( Net, "NETWORK" ); else - { - if( pPrinterEnum->Attributes & PRINTER_ATTRIBUTE_NETWORK ) - { - hb_itemPutC( Net, "NETWORK" ); - } - else - { - hb_itemPutC( Net, "ERROR" ); - } - } + hb_itemPutC( Net, "ERROR" ); hb_arrayAddForward( SubItems, File ); hb_arrayAddForward( SubItems, Port ); @@ -624,27 +578,18 @@ HB_FUNC( GETPRINTERS ) hb_arrayNew( SubItems, 0 ); hb_itemPutC( File, pPrinterEnum->pPrinterName ); hb_itemPutC( Port, pPrinterEnum->pPortName ); - - if ( pPrinterEnum->Attributes & PRINTER_ATTRIBUTE_LOCAL) - { - hb_itemPutC( Net,"LOCAL" ); - } - else - { - if ( pPrinterEnum->Attributes & PRINTER_ATTRIBUTE_NETWORK) - { - hb_itemPutC( Net,"NETWORK" ); - } - else - { - hb_itemPutC( Net, "ERROR" ); - } - } - hb_arrayAddForward( SubItems , File ) ; - hb_arrayAddForward( SubItems , Port ) ; - hb_arrayAddForward( SubItems, Net ) ; - hb_arrayAddForward( ArrayPrinter , SubItems ); + if( pPrinterEnum->Attributes & PRINTER_ATTRIBUTE_LOCAL) + hb_itemPutC( Net,"LOCAL" ); + else if( pPrinterEnum->Attributes & PRINTER_ATTRIBUTE_NETWORK) + hb_itemPutC( Net, "NETWORK" ); + else + hb_itemPutC( Net, "ERROR" ); + + hb_arrayAddForward( SubItems, File ); + hb_arrayAddForward( SubItems, Port ); + hb_arrayAddForward( SubItems, Net ); + hb_arrayAddForward( ArrayPrinter, SubItems ); #endif } } diff --git a/harbour/contrib/hbwin/win_tprn.prg b/harbour/contrib/hbwin/win_tprn.prg index 6bb5bb6227..cd581db463 100644 --- a/harbour/contrib/hbwin/win_tprn.prg +++ b/harbour/contrib/hbwin/win_tprn.prg @@ -73,8 +73,8 @@ #ifndef __PLATFORM__WINDOWS -FUNCTION WIN_PRN() - RETURN NIL +PROCEDURE WIN_PRN() + RETURN #else @@ -91,25 +91,25 @@ FUNCTION WIN_PRN() // Device Parameters for GetDeviceCaps() -#define HORZSIZE 4 // Horizontal size in millimeters -#define VERTSIZE 6 // Vertical size in millimeters -#define HORZRES 8 // Horizontal width in pixels -#define VERTRES 10 // Vertical height in pixels -#define NUMBRUSHES 16 // Number of brushes the device has -#define NUMPENS 18 // Number of pens the device has -#define NUMFONTS 22 // Number of fonts the device has -#define NUMCOLORS 24 // Number of colors the device supports -#define RASTERCAPS 38 // Bitblt capabilities +#define HORZSIZE 4 // Horizontal size in millimeters +#define VERTSIZE 6 // Vertical size in millimeters +#define HORZRES 8 // Horizontal width in pixels +#define VERTRES 10 // Vertical height in pixels +#define NUMBRUSHES 16 // Number of brushes the device has +#define NUMPENS 18 // Number of pens the device has +#define NUMFONTS 22 // Number of fonts the device has +#define NUMCOLORS 24 // Number of colors the device supports +#define RASTERCAPS 38 // Bitblt capabilities -#define LOGPIXELSX 88 // Logical pixels/inch in X -#define LOGPIXELSY 90 // Logical pixels/inch in Y +#define LOGPIXELSX 88 // Logical pixels/inch in X +#define LOGPIXELSY 90 // Logical pixels/inch in Y -#define PHYSICALWIDTH 110 // Physical Width in device units -#define PHYSICALHEIGHT 111 // Physical Height in device units -#define PHYSICALOFFSETX 112 // Physical Printable Area x margin -#define PHYSICALOFFSETY 113 // Physical Printable Area y margin -#define SCALINGFACTORX 114 // Scaling factor x -#define SCALINGFACTORY 115 // Scaling factor y +#define PHYSICALWIDTH 110 // Physical Width in device units +#define PHYSICALHEIGHT 111 // Physical Height in device units +#define PHYSICALOFFSETX 112 // Physical Printable Area x margin +#define PHYSICALOFFSETY 113 // Physical Printable Area y margin +#define SCALINGFACTORX 114 // Scaling factor x +#define SCALINGFACTORY 115 // Scaling factor y /* bin selections */ #define DMBIN_FIRST DMBIN_UPPER @@ -144,512 +144,521 @@ FUNCTION WIN_PRN() CLASS WIN_PRN - METHOD New(cPrinter) - METHOD Create() // CreatesDC and sets "Courier New" font, set Orientation, Copies, Bin# - // Create() ( & StartDoc() ) must be called before printing can start. - METHOD Destroy() // Calls EndDoc() - restores default font, Deletes DC. - // Destroy() must be called to avoid memory leaks - METHOD StartDoc(cDocame) // Calls StartPage() - METHOD EndDoc(lAbortDoc) // Calls EndPage() if lAbortDoc not .T. - METHOD StartPage() - METHOD EndPage(lStartNewPage) // If lStartNewPage == .T. then StartPage() is called for the next page of output - METHOD NewLine() - METHOD NewPage() - METHOD SetFont(cFontName, nPointSize, nWidth, nBold, lUnderline, lItalic, nCharSet) - // NB: nWidth is in "CharactersPerInch" - // _OR_ { nMul, nDiv } which equates to "CharactersPerInch" - // _OR_ ZERO ( 0 ) which uses the default width of the font - // for the nPointSize - // IF nWidth (or nDiv) is < 0 then Fixed font is emulated + METHOD New( cPrinter ) + METHOD Create() // CreatesDC and sets "Courier New" font, set Orientation, Copies, Bin# + // Create() ( & StartDoc() ) must be called before printing can start. + METHOD Destroy() // Calls EndDoc() - restores default font, Deletes DC. + // Destroy() must be called to avoid memory leaks + METHOD StartDoc( cDocame ) // Calls StartPage() + METHOD EndDoc( lAbortDoc ) // Calls EndPage() if lAbortDoc not .T. + METHOD StartPage() + METHOD EndPage( lStartNewPage ) // If lStartNewPage == .T. then StartPage() is called for the next page of output + METHOD NewLine() + METHOD NewPage() + METHOD SetFont( cFontName, nPointSize, nWidth, nBold, lUnderline, lItalic, nCharSet ) + // NB: nWidth is in "CharactersPerInch" + // _OR_ { nMul, nDiv } which equates to "CharactersPerInch" + // _OR_ ZERO ( 0 ) which uses the default width of the font + // for the nPointSize + // IF nWidth (or nDiv) is < 0 then Fixed font is emulated - METHOD SetDefaultFont() + METHOD SetDefaultFont() - METHOD GetFonts() // Returns array of { "FontName", lFixed, lTrueType, nCharSetRequired } - METHOD Bold(nBoldWeight) - METHOD UnderLine(lOn) - METHOD Italic(lOn) - METHOD SetDuplexType(nDuplexType) // Get/Set current Duplexmode - METHOD SetPrintQuality(nPrintQuality) // Get/Set Printquality - METHOD CharSet(nCharSet) + METHOD GetFonts() // Returns array of { "FontName", lFixed, lTrueType, nCharSetRequired } + METHOD Bold( nBoldWeight ) + METHOD UnderLine( lOn ) + METHOD Italic( lOn ) + METHOD SetDuplexType( nDuplexType ) // Get/Set current Duplexmode + METHOD SetPrintQuality( nPrintQuality ) // Get/Set Printquality + METHOD CharSet( nCharSet ) - METHOD SetPos(nX, nY) // **WARNING** : (Col,Row) _NOT_ (Row,Col) - METHOD SetColor(nClrText, nClrPane, nAlign) INLINE (; - ::TextColor:=nClrText, ::BkColor:=nClrPane, ::TextAlign:=nAlign,; - win_SetColor( ::hPrinterDC, nClrText, nClrPane, nAlign) ) + METHOD SetPos( nX, nY ) // **WARNING** : (Col,Row) _NOT_ (Row,Col) + METHOD SetColor( nClrText, nClrPane, nAlign ) INLINE (; + ::TextColor := nClrText, ::BkColor := nClrPane, ::TextAlign := nAlign,; + win_SetColor( ::hPrinterDC, nClrText, nClrPane, nAlign ) ) - METHOD TextOut(cString, lNewLine, lUpdatePosX, nAlign) // nAlign : 0 == left, 1 == right, 2 == centered - METHOD TextOutAt(nPosX,nPosY, cString, lNewLine, lUpdatePosX, nAlign) // **WARNING** : (Col,Row) _NOT_ (Row,Col) + METHOD TextOut( cString, lNewLine, lUpdatePosX, nAlign ) // nAlign : 0 == left, 1 == right, 2 == centered + METHOD TextOutAt( nPosX, nPosY, cString, lNewLine, lUpdatePosX, nAlign ) // **WARNING** : (Col,Row) _NOT_ (Row,Col) - METHOD SetPen(nStyle, nWidth, nColor) INLINE (; - ::PenStyle:=nStyle, ::PenWidth:=nWidth, ::PenColor:=nColor,; - win_SetPen(::hPrinterDC, nStyle, nWidth, nColor) ) - METHOD Line(nX1, nY1, nX2, nY2) INLINE win_LineTo(::hPrinterDC, nX1, nY1, nX2, nY2) - METHOD Box(nX1, nY1, nX2, nY2, nWidth, nHeight) INLINE win_Rectangle(::hPrinterDC, nX1, nY1, nX2, nY2, nWidth, nHeight) - METHOD Arc(nX1, nY1, nX2, nY2) INLINE win_Arc(::hPrinterDC, nX1, nY1, nX2, nY2) - METHOD Ellipse(nX1, nY1, nX2, nY2) INLINE win_Ellipse(::hPrinterDC, nX1, nY1, nX2, nY2) - METHOD FillRect(nX1, nY1, nX2, nY2, nColor) INLINE win_FillRect(::hPrinterDC, nX1, nY1, nX2, nY2, nColor) - METHOD GetCharWidth() - METHOD GetCharHeight() - METHOD GetTextWidth(cString) - METHOD GetTextHeight(cString) - METHOD DrawBitMap(oBmp) + METHOD SetPen( nStyle, nWidth, nColor ) INLINE (; + ::PenStyle := nStyle, ::PenWidth := nWidth, ::PenColor := nColor,; + win_SetPen(::hPrinterDC, nStyle, nWidth, nColor ) ) + METHOD Line( nX1, nY1, nX2, nY2 ) INLINE win_LineTo( ::hPrinterDC, nX1, nY1, nX2, nY2 ) + METHOD Box( nX1, nY1, nX2, nY2, nWidth, nHeight ) INLINE win_Rectangle( ::hPrinterDC, nX1, nY1, nX2, nY2, nWidth, nHeight ) + METHOD Arc( nX1, nY1, nX2, nY2 ) INLINE win_Arc( ::hPrinterDC, nX1, nY1, nX2, nY2 ) + METHOD Ellipse( nX1, nY1, nX2, nY2 ) INLINE win_Ellipse( ::hPrinterDC, nX1, nY1, nX2, nY2 ) + METHOD FillRect( nX1, nY1, nX2, nY2, nColor ) INLINE win_FillRect( ::hPrinterDC, nX1, nY1, nX2, nY2, nColor ) + METHOD GetCharWidth() + METHOD GetCharHeight() + METHOD GetTextWidth( cString ) + METHOD GetTextHeight( cString ) + METHOD DrawBitMap( oBmp ) // Clipper DOS compatible functions. - METHOD SetPrc(nRow, nCol) // Based on ::LineHeight and current ::CharWidth - METHOD PRow() - METHOD PCol() - METHOD MaxRow() // Based on ::LineHeight & Form dimensions - METHOD MaxCol() // Based on ::CharWidth & Form dimensions + METHOD SetPrc( nRow, nCol ) // Based on ::LineHeight and current ::CharWidth + METHOD PRow() + METHOD PCol() + METHOD MaxRow() // Based on ::LineHeight & Form dimensions + METHOD MaxCol() // Based on ::CharWidth & Form dimensions - METHOD MM_TO_POSX( nMm ) // Convert position on page from MM to pixel location Column - METHOD MM_TO_POSY( nMm ) // " " " " " " " " " Row - METHOD INCH_TO_POSX( nInch ) // Convert position on page from INCH to pixel location Column - METHOD INCH_TO_POSY( nInch ) // " " " " " " " " " Row + METHOD MM_TO_POSX( nMm ) // Convert position on page from MM to pixel location Column + METHOD MM_TO_POSY( nMm ) // " " " " " " " " " Row + METHOD INCH_TO_POSX( nInch ) // Convert position on page from INCH to pixel location Column + METHOD INCH_TO_POSY( nInch ) // " " " " " " " " " Row - METHOD TextAtFont( nPosX, nPosY, cString, cFont, nPointSize,; // Print text string at location - nWidth, nBold, lUnderLine, lItalic, lNewLine,; // in specified font and color. - lUpdatePosX, nColor, nAlign ) // Restore original font and colour - // after printing. - METHOD SetBkMode( nMode ) INLINE win_SetBkMode( ::hPrinterDc, nMode ) // OPAQUE == 2 or TRANSPARENT == 1 - // Set Background mode + METHOD TextAtFont( nPosX, nPosY, cString, cFont, nPointSize,; // Print text string at location + nWidth, nBold, lUnderLine, lItalic, lNewLine,; // in specified font and color. + lUpdatePosX, nColor, nAlign ) // Restore original font and colour + // after printing. + METHOD SetBkMode( nMode ) INLINE win_SetBkMode( ::hPrinterDc, nMode ) // OPAQUE == 2 or TRANSPARENT == 1 + // Set Background mode - METHOD GetDeviceCaps( nCaps ) INLINE win_GetDeviceCaps( ::hPrinterDC, nCaps) + METHOD GetDeviceCaps( nCaps ) INLINE win_GetDeviceCaps( ::hPrinterDC, nCaps) - VAR PrinterName INIT "" - VAR Printing INIT .F. - VAR HavePrinted INIT .F. - VAR hPrinterDc INIT 0 + VAR PrinterName INIT "" + VAR Printing INIT .F. + VAR HavePrinted INIT .F. + VAR hPrinterDc INIT 0 // These next 4 variables must be set before calling ::Create() if // you wish to alter the defaults - VAR FormType INIT 0 - VAR BinNumber INIT 0 - VAR Landscape INIT .F. - VAR Copies INIT 1 + VAR FormType INIT 0 + VAR BinNumber INIT 0 + VAR Landscape INIT .F. + VAR Copies INIT 1 - VAR SetFontOk INIT .F. - VAR FontName INIT "" // Current Point size for font - VAR FontPointSize INIT 12 // Point size for font - VAR FontWidth INIT {0,0} // {Mul, Div} Calc width: nWidth:= MulDiv(nMul, GetDeviceCaps(shDC,LOGPIXELSX), nDiv) - // If font width is specified it is in "characters per inch" to emulate DotMatrix - VAR fBold INIT 0 HIDDEN // font darkness weight ( Bold). See wingdi.h or WIN SDK CreateFont() for valid values - VAR fUnderLine INIT .F. HIDDEN // UnderLine is on or off - VAR fItalic INIT .F. HIDDEN // Italic is on or off - VAR fCharSet INIT 1 HIDDEN // Default character set == DEFAULT_CHARSET ( see wingdi.h ) + VAR SetFontOk INIT .F. + VAR FontName INIT "" // Current Point size for font + VAR FontPointSize INIT 12 // Point size for font + VAR FontWidth INIT { 0, 0 } // {Mul, Div} Calc width: nWidth:= MulDiv(nMul, GetDeviceCaps(shDC,LOGPIXELSX), nDiv) + // If font width is specified it is in "characters per inch" to emulate DotMatrix + VAR fBold INIT 0 HIDDEN // font darkness weight ( Bold). See wingdi.h or WIN SDK CreateFont() for valid values + VAR fUnderLine INIT .F. HIDDEN // UnderLine is on or off + VAR fItalic INIT .F. HIDDEN // Italic is on or off + VAR fCharSet INIT 1 HIDDEN // Default character set == DEFAULT_CHARSET ( see wingdi.h ) - VAR PixelsPerInchY - VAR PixelsPerInchX - VAR PageHeight INIT 0 - VAR PageWidth INIT 0 - VAR TopMargin INIT 0 - VAR BottomMargin INIT 0 - VAR LeftMargin INIT 0 - VAR RightMargin INIT 0 - VAR LineHeight INIT 0 - VAR CharHeight INIT 0 - VAR CharWidth INIT 0 - VAR fCharWidth INIT 0 HIDDEN - VAR BitmapsOk INIT .F. - VAR NumColors INIT 1 - VAR fDuplexType INIT 0 HIDDEN // DMDUP_SIMPLEX, 22/02/2007 change to 0 to use default printer settings - VAR fPrintQuality INIT 0 HIDDEN // DMRES_HIGH, 22/02/2007 change to 0 to use default printer settings - VAR fNewDuplexType INIT 0 HIDDEN - VAR fNewPrintQuality INIT 0 HIDDEN - VAR fOldLandScape INIT .F. HIDDEN - VAR fOldBinNumber INIT 0 HIDDEN - VAR fOldFormType INIT 0 HIDDEN + VAR PixelsPerInchY + VAR PixelsPerInchX + VAR PageHeight INIT 0 + VAR PageWidth INIT 0 + VAR TopMargin INIT 0 + VAR BottomMargin INIT 0 + VAR LeftMargin INIT 0 + VAR RightMargin INIT 0 + VAR LineHeight INIT 0 + VAR CharHeight INIT 0 + VAR CharWidth INIT 0 + VAR fCharWidth INIT 0 HIDDEN + VAR BitmapsOk INIT .F. + VAR NumColors INIT 1 + VAR fDuplexType INIT 0 HIDDEN // DMDUP_SIMPLEX, 22/02/2007 change to 0 to use default printer settings + VAR fPrintQuality INIT 0 HIDDEN // DMRES_HIGH, 22/02/2007 change to 0 to use default printer settings + VAR fNewDuplexType INIT 0 HIDDEN + VAR fNewPrintQuality INIT 0 HIDDEN + VAR fOldLandScape INIT .F. HIDDEN + VAR fOldBinNumber INIT 0 HIDDEN + VAR fOldFormType INIT 0 HIDDEN - VAR PosX INIT 0 - VAR PosY INIT 0 + VAR PosX INIT 0 + VAR PosY INIT 0 - VAR TextColor - VAR BkColor - VAR TextAlign + VAR TextColor + VAR BkColor + VAR TextAlign - VAR PenStyle - VAR PenWidth - VAR PenColor + VAR PenStyle + VAR PenWidth + VAR PenColor ENDCLASS -METHOD New(cPrinter) CLASS WIN_PRN - ::PrinterName := IIF(!EMPTY(cPrinter), cPrinter, GetDefaultPrinter()) - RETURN(Self) +METHOD New( cPrinter ) CLASS WIN_PRN + ::PrinterName := IIF( EMPTY( cPrinter ), GetDefaultPrinter(), cPrinter ) + RETURN Self METHOD Create() CLASS WIN_PRN - LOCAL Result:= .F. - ::Destroy() // Finish current print job if any - IF !EMPTY(::hPrinterDC:= win_CreateDC(::PrinterName)) + LOCAL lResult := .F. + ::Destroy() // Finish current print job if any + IF ! EMPTY( ::hPrinterDC := win_CreateDC( ::PrinterName ) ) - // Set Form Type - // Set Number of Copies - // Set Orientation - // Set Duplex mode - // Set PrintQuality - win_SetDocumentProperties(::hPrinterDC, ::PrinterName, ::FormType, ::Landscape, ::Copies, ::BinNumber, ::fDuplexType, ::fPrintQuality) - // Set mapping mode to pixels, topleft down - win_SetMapMode(::hPrinterDC,MM_TEXT) -// win_SetTextCharacterExtra(::hPrinterDC,0); // do not add extra char spacing even if bold - // Get Margins etc... here - ::PageWidth := win_GetDeviceCaps(::hPrinterDC,PHYSICALWIDTH) - ::PageHeight := win_GetDeviceCaps(::hPrinterDC,PHYSICALHEIGHT) - ::LeftMargin := win_GetDeviceCaps(::hPrinterDC,PHYSICALOFFSETX) - ::RightMargin := (::PageWidth - ::LeftMargin)+1 - ::PixelsPerInchY := win_GetDeviceCaps(::hPrinterDC,LOGPIXELSY) - ::PixelsPerInchX := win_GetDeviceCaps(::hPrinterDC,LOGPIXELSX) - ::LineHeight := INT(::PixelsPerInchY / 6) // Default 6 lines per inch == # of pixels per line - ::TopMargin := win_GetDeviceCaps(::hPrinterDC,PHYSICALOFFSETY) - ::BottomMargin := (::PageHeight - ::TopMargin)+1 + // Set Form Type + // Set Number of Copies + // Set Orientation + // Set Duplex mode + // Set PrintQuality + win_SetDocumentProperties( ::hPrinterDC, ::PrinterName, ::FormType, ::Landscape, ::Copies, ::BinNumber, ::fDuplexType, ::fPrintQuality ) + // Set mapping mode to pixels, topleft down + win_SetMapMode( ::hPrinterDC, MM_TEXT ) +// win_SetTextCharacterExtra( ::hPrinterDC, 0 ); // do not add extra char spacing even if bold + // Get Margins etc... here + ::PageWidth := win_GetDeviceCaps( ::hPrinterDC, PHYSICALWIDTH ) + ::PageHeight := win_GetDeviceCaps( ::hPrinterDC, PHYSICALHEIGHT ) + ::LeftMargin := win_GetDeviceCaps( ::hPrinterDC, PHYSICALOFFSETX ) + ::RightMargin := ( ::PageWidth - ::LeftMargin ) + 1 + ::PixelsPerInchY := win_GetDeviceCaps( ::hPrinterDC, LOGPIXELSY ) + ::PixelsPerInchX := win_GetDeviceCaps( ::hPrinterDC, LOGPIXELSX ) + ::LineHeight := INT( ::PixelsPerInchY / 6 ) // Default 6 lines per inch == # of pixels per line + ::TopMargin := win_GetDeviceCaps( ::hPrinterDC, PHYSICALOFFSETY ) + ::BottomMargin := ( ::PageHeight - ::TopMargin ) + 1 - // Set .T. if can print bitmaps - ::BitMapsOk := win_BitMapsOk(::hPrinterDC) + // Set .T. if can print bitmaps + ::BitMapsOk := win_BitMapsOk( ::hPrinterDC ) - // supports Colour - ::NumColors := win_GetDeviceCaps(::hPrinterDC,NUMCOLORS) + // supports Colour + ::NumColors := win_GetDeviceCaps( ::hPrinterDC, NUMCOLORS ) - // Set the standard font - ::SetDefaultFont() - ::HavePrinted:= ::Printing:= .F. - ::fOldFormType:= ::FormType // Last formtype used - ::fOldLandScape:= ::LandScape - ::fOldBinNumber:= ::BinNumber - ::fNewDuplexType := ::fDuplexType - ::fNewPrintQuality := ::fPrintQuality - Result:= .T. - ENDIF - RETURN(Result) + // Set the standard font + ::SetDefaultFont() + ::HavePrinted := ::Printing := .F. + ::fOldFormType := ::FormType // Last formtype used + ::fOldLandScape := ::LandScape + ::fOldBinNumber := ::BinNumber + ::fNewDuplexType := ::fDuplexType + ::fNewPrintQuality := ::fPrintQuality + lResult := .T. + ENDIF + RETURN lResult METHOD Destroy() CLASS WIN_PRN - IF !EMPTY(::hPrinterDc) - IF ::Printing - ::EndDoc() - ENDIF - ::hPrinterDC:= win_DeleteDC(::hPrinterDC) - ENDIF - RETURN(.T.) + IF !EMPTY( ::hPrinterDc ) + IF ::Printing + ::EndDoc() + ENDIF + ::hPrinterDC := win_DeleteDC( ::hPrinterDC ) + ENDIF + RETURN .T. -METHOD StartDoc(cDocName) CLASS WIN_PRN - LOCAL Result - IF cDocName == NIL - cDocName:= win_GetExeFileName()+" ["+DTOC(DATE())+' - '+TIME()+"]" - ENDIF - IF (Result:= win_StartDoc(::hPrinterDc, cDocName)) - IF !(Result:= ::StartPage(::hPrinterDc)) - ::EndDoc(.T.) - ELSE - ::Printing:= .T. - ENDIF - ENDIF - RETURN(Result) +METHOD StartDoc( cDocName ) CLASS WIN_PRN + LOCAL lResult + IF cDocName == NIL + cDocName := win_GetExeFileName() + " [" + DTOC( DATE() ) + ' - ' + TIME() + "]" + ENDIF + IF ( lResult := win_StartDoc( ::hPrinterDc, cDocName ) ) + IF !( lResult := ::StartPage( ::hPrinterDc ) ) + ::EndDoc( .T. ) + ELSE + ::Printing := .T. + ENDIF + ENDIF + RETURN lResult -METHOD EndDoc(lAbortDoc) CLASS WIN_PRN - IF lAbortDoc == NIL - lAbortDoc:= .F. - ENDIF - IF !::HavePrinted - lAbortDoc:= .T. - ENDIF - IF !lAbortDoc - ::EndPage(.F.) - ENDIF - win_EndDoc(::hPrinterDC,lAbortDoc) - ::Printing:= .F. - ::HavePrinted:= .F. - RETURN(.T.) +METHOD EndDoc( lAbortDoc ) CLASS WIN_PRN + IF ::HavePrinted + DEFAULT lAbortDoc TO .F. + ELSE + lAbortDoc := .T. + ENDIF + IF lAbortDoc + win_AbordDoc( ::hPrinterDC ) + ELSE + ::EndPage( .F. ) + win_EndDoc( ::hPrinterDC ) + ENDIF + ::Printing := .F. + ::HavePrinted := .F. + RETURN .T. METHOD StartPage() CLASS WIN_PRN - LOCAL lLLandScape, nLBinNumber, nLFormType, nLDuplexType, nLPrintQuality - LOCAL lChangeDP:= .F. - IF ::LandScape != ::fOldLandScape // Direct-modify property - lLLandScape:= ::fOldLandScape := ::LandScape - lChangeDP:= .T. - ENDIF - IF ::BinNumber != ::fOldBinNumber // Direct-modify property - nLBinNumber:= ::fOldBinNumber := ::BinNumber - lChangeDP:= .T. - ENDIF - IF ::FormType != ::fOldFormType // Direct-modify property - nLFormType:= ::fOldFormType := ::FormType - lChangeDP:= .T. - ENDIF - IF ::fDuplexType != ::fNewDuplexType // Get/Set property - nLDuplexType:= ::fDuplexType:= ::fNewDuplexType - lChangeDP:= .T. - ENDIF - IF ::fPrintQuality != ::fNewPrintQuality // Get/Set property - nLPrintQuality:= ::fPrintQuality:= ::fNewPrintQuality - lChangeDP:= .T. - ENDIF - IF lChangeDP - win_SetDocumentProperties(::hPrinterDC, ::PrinterName, nLFormType, lLLandscape, , nLBinNumber, nLDuplexType, nLPrintQuality) - ENDIF - win_StartPage(::hPrinterDC) - ::PosX:= ::LeftMargin - ::PosY:= ::TopMargin - RETURN(.T.) + LOCAL lLLandScape + LOCAL nLBinNumber + LOCAL nLFormType + LOCAL nLDuplexType + LOCAL nLPrintQuality + LOCAL lChangeDP := .F. -METHOD EndPage(lStartNewPage) CLASS WIN_PRN - IF lStartNewPage == NIL - lStartNewPage:= .T. - ENDIF - win_EndPage(::hPrinterDC) - IF lStartNewPage - ::StartPage() - IF win_OS_ISWIN9X() // Reset font on Win9X - ::SetFont() - ENDIF - ENDIF - RETURN(.T.) + IF ::LandScape != ::fOldLandScape // Direct-modify property + lLLandScape := ::fOldLandScape := ::LandScape + lChangeDP := .T. + ENDIF + IF ::BinNumber != ::fOldBinNumber // Direct-modify property + nLBinNumber := ::fOldBinNumber := ::BinNumber + lChangeDP := .T. + ENDIF + IF ::FormType != ::fOldFormType // Direct-modify property + nLFormType := ::fOldFormType := ::FormType + lChangeDP := .T. + ENDIF + IF ::fDuplexType != ::fNewDuplexType // Get/Set property + nLDuplexType := ::fDuplexType := ::fNewDuplexType + lChangeDP := .T. + ENDIF + IF ::fPrintQuality != ::fNewPrintQuality // Get/Set property + nLPrintQuality := ::fPrintQuality := ::fNewPrintQuality + lChangeDP := .T. + ENDIF + IF lChangeDP + win_SetDocumentProperties( ::hPrinterDC, ::PrinterName, nLFormType, lLLandscape, , nLBinNumber, nLDuplexType, nLPrintQuality ) + ENDIF + win_StartPage( ::hPrinterDC ) + ::PosX := ::LeftMargin + ::PosY := ::TopMargin + RETURN .T. + +METHOD EndPage( lStartNewPage ) CLASS WIN_PRN + IF lStartNewPage == NIL + lStartNewPage := .T. + ENDIF + win_EndPage( ::hPrinterDC ) + IF lStartNewPage + ::StartPage() + IF win_OS_ISWIN9X() // Reset font on Win9X + ::SetFont() + ENDIF + ENDIF + RETURN .T. METHOD NewLine() CLASS WIN_PRN - ::PosX:= ::LeftMargin - ::PosY+= ::LineHeight - RETURN(::PosY) + ::PosX := ::LeftMargin + ::PosY += ::LineHeight + RETURN ::PosY METHOD NewPage() CLASS WIN_PRN - ::EndPage(.T.) - RETURN(.T.) - + ::EndPage( .T. ) + RETURN .T. // If font width is specified it is in "characters per inch" to emulate DotMatrix // An array {nMul,nDiv} is used to get precise size such a the Dot Matric equivalent // of Compressed print == 16.67 char per inch == { 3,-50 } // If nDiv is < 0 then Fixed width printing is forced via ExtTextOut() -METHOD SetFont(cFontName, nPointSize, nWidth, nBold, lUnderline, lItalic, nCharSet) CLASS WIN_PRN - LOCAL cType - IF cFontName !=NIL - ::FontName:= cFontName - ENDIF - IF nPointSize!=NIL - ::FontPointSize:= nPointSize - ENDIF - IF nWidth != NIL - cType:= VALTYPE(nWidth) - IF cType='A' - ::FontWidth := nWidth - ELSEIF cType='N' .AND. !EMPTY(nWidth) - ::FontWidth := {1,nWidth } - ELSE - ::FontWidth := {0, 0 } - ENDIF - ENDIF - IF nBold != NIL - ::fBold := nBold - ENDIF - IF lUnderLine != NIL - ::fUnderline:= lUnderLine - ENDIF - IF lItalic != NIL - ::fItalic := lItalic - ENDIF - IF nCharSet != NIL - ::fCharSet := nCharSet - ENDIF - IF (::SetFontOk:= win_CreateFont( ::hPrinterDC, ::FontName, ::FontPointSize, ::FontWidth[1], ::FontWidth[2], ::fBold, ::fUnderLine, ::fItalic, ::fCharSet)) - ::fCharWidth := ::GetCharWidth() - ::CharWidth:= ABS(::fCharWidth) - ::CharHeight:= ::GetCharHeight() - ENDIF - ::FontName:= win_GetPrinterFontName(::hPrinterDC) // Get the font name that Windows actually used - RETURN(::SetFontOk) +METHOD SetFont( cFontName, nPointSize, nWidth, nBold, lUnderline, lItalic, nCharSet ) CLASS WIN_PRN + LOCAL cType + IF cFontName != NIL + ::FontName := cFontName + ENDIF + IF nPointSize != NIL + ::FontPointSize := nPointSize + ENDIF + IF nWidth != NIL + cType := VALTYPE( nWidth ) + IF cType == "A" + ::FontWidth := nWidth + ELSEIF cType == "N" .AND. !EMPTY( nWidth ) + ::FontWidth := { 1, nWidth } + ELSE + ::FontWidth := { 0, 0 } + ENDIF + ENDIF + IF nBold != NIL + ::fBold := nBold + ENDIF + IF lUnderLine != NIL + ::fUnderline:= lUnderLine + ENDIF + IF lItalic != NIL + ::fItalic := lItalic + ENDIF + IF nCharSet != NIL + ::fCharSet := nCharSet + ENDIF + IF ( ::SetFontOk := win_CreateFont( ::hPrinterDC, ::FontName, ::FontPointSize, ::FontWidth[1], ::FontWidth[2], ::fBold, ::fUnderLine, ::fItalic, ::fCharSet ) ) + ::fCharWidth := ::GetCharWidth() + ::CharWidth := ABS( ::fCharWidth ) + ::CharHeight := ::GetCharHeight() + ENDIF + ::FontName := win_GetPrinterFontName( ::hPrinterDC ) // Get the font name that Windows actually used + RETURN ::SetFontOk METHOD SetDefaultFont() - RETURN(::SetFont("Courier New",12,{1, 10}, 0, .F., .F., 0)) + RETURN ::SetFont( "Courier New", 12, { 1, 10 }, 0, .F., .F., 0 ) -METHOD Bold(nWeight) CLASS WIN_PRN - LOCAL Result:= ::fBold - IF nWeight!= NIL - ::fBold:= nWeight - IF ::Printing - ::SetFont() - ENDIF - ENDIF - RETURN(Result) +METHOD Bold( nWeight ) CLASS WIN_PRN + LOCAL nOldValue := ::fBold + IF nWeight != NIL + ::fBold := nWeight + IF ::Printing + ::SetFont() + ENDIF + ENDIF + RETURN nOldValue -METHOD Underline(lUnderLine) CLASS WIN_PRN - LOCAL Result:= ::fUnderline - IF lUnderLine!= NIL - ::fUnderLine:= lUnderLine - IF ::Printing - ::SetFont() - ENDIF - ENDIF - RETURN(Result) +METHOD Underline( lUnderLine ) CLASS WIN_PRN + LOCAL lOldValue := ::fUnderline + IF lUnderLine != NIL + ::fUnderLine := lUnderLine + IF ::Printing + ::SetFont() + ENDIF + ENDIF + RETURN lOldValue -METHOD Italic(lItalic) CLASS WIN_PRN - LOCAL Result:= ::fItalic - IF lItalic!= NIL - ::fItalic:= lItalic - IF ::Printing - ::SetFont() - ENDIF - ENDIF - RETURN(Result) +METHOD Italic( lItalic ) CLASS WIN_PRN + LOCAL lOldValue := ::fItalic + IF lItalic != NIL + ::fItalic := lItalic + IF ::Printing + ::SetFont() + ENDIF + ENDIF + RETURN lOldValue -METHOD CharSet(nCharSet) CLASS WIN_PRN - LOCAL Result:= ::fCharSet - IF nCharSet!= NIL - ::fCharSet:= nCharSet - IF ::Printing - ::SetFont() - ENDIF - ENDIF - RETURN(Result) +METHOD CharSet( nCharSet ) CLASS WIN_PRN + LOCAL nOldValue := ::fCharSet + IF nCharSet != NIL + ::fCharSet := nCharSet + IF ::Printing + ::SetFont() + ENDIF + ENDIF + RETURN nOldValue -METHOD SetDuplexType(nDuplexType) CLASS WIN_PRN - LOCAL Result:= ::fDuplexType - IF nDuplexType!= NIL - ::fNewDuplexType:= nDuplexType - IF !::Printing - ::fDuplexType:= nDuplexType - ENDIF - ENDIF - RETURN(Result) +METHOD SetDuplexType( nDuplexType ) CLASS WIN_PRN + LOCAL nOldValue := ::fDuplexType + IF nDuplexType != NIL + ::fNewDuplexType := nDuplexType + IF !::Printing + ::fDuplexType := nDuplexType + ENDIF + ENDIF + RETURN nOldValue -METHOD SetPrintQuality(nPrintQuality) CLASS WIN_PRN - LOCAL Result:= ::fPrintQuality - IF nPrintQuality!= NIL - ::fNewPrintQuality:= nPrintQuality - IF !::Printing - ::fPrintQuality:= nPrintQuality - ENDIF - ENDIF - RETURN(Result) +METHOD SetPrintQuality( nPrintQuality ) CLASS WIN_PRN + LOCAL nOldValue := ::fPrintQuality + IF nPrintQuality != NIL + ::fNewPrintQuality := nPrintQuality + IF !::Printing + ::fPrintQuality := nPrintQuality + ENDIF + ENDIF + RETURN nOldValue METHOD GetFonts() CLASS WIN_PRN - RETURN(win_ENUMFONTS(::hPrinterDC)) + RETURN win_ENUMFONTS( ::hPrinterDC ) METHOD SetPos(nPosX, nPosY) CLASS WIN_PRN - LOCAL Result:= {::PosX, ::PosY} - IF nPosX != NIL - ::PosX:= INT(nPosX) - ENDIF - IF nPosY != NIL - ::PosY:= INT(nPosY) - ENDIF - RETURN(Result) + LOCAL aOldValue := { ::PosX, ::PosY } + IF nPosX != NIL + ::PosX := INT( nPosX ) + ENDIF + IF nPosY != NIL + ::PosY := INT( nPosY ) + ENDIF + RETURN aOldValue -METHOD TextOut(cString, lNewLine, lUpdatePosX, nAlign) CLASS WIN_PRN - LOCAL nPosX - IF nAlign == NIL - nAlign:= 0 - ENDIF - IF lUpdatePosX == NIL - lUpdatePosX:=.T. - ENDIF - IF lNewLine == NIL - lNewLine:= .F. - ENDIF - IF cString!=NIL - nPosX:= win_TextOut(::hPrinterDC,::PosX, ::PosY, cString, LEN(cString), ::fCharWidth, nAlign) - ::HavePrinted:= .T. - IF lUpdatePosX - ::PosX+= nPosX - ENDIF - IF lNewLine - ::NewLine() - ENDIF - ENDIF - RETURN( .T. ) +METHOD TextOut( cString, lNewLine, lUpdatePosX, nAlign ) CLASS WIN_PRN + LOCAL nPosX + IF nAlign == NIL + nAlign := 0 + ENDIF + IF lUpdatePosX == NIL + lUpdatePosX := .T. + ENDIF + IF lNewLine == NIL + lNewLine := .F. + ENDIF + IF cString != NIL + nPosX := win_TextOut( ::hPrinterDC, ::PosX, ::PosY, cString, LEN( cString ), ::fCharWidth, nAlign ) + ::HavePrinted := .T. + IF lUpdatePosX + ::PosX += nPosX + ENDIF + IF lNewLine + ::NewLine() + ENDIF + ENDIF + RETURN .T. -METHOD TextOutAt(nPosX,nPosY, cString, lNewLine, lUpdatePosX, nAlign) CLASS WIN_PRN - IF lNewLine == NIL - lNewLine:= .F. - ENDIF - IF lUpdatePosX == NIL - lUpdatePosX:= .T. - ENDIF - ::SetPos(nPosX,nPosY) - ::TextOut(cString, lNewLine, lUpdatePosX, nAlign) - RETURN(.T.) +METHOD TextOutAt( nPosX, nPosY, cString, lNewLine, lUpdatePosX, nAlign ) CLASS WIN_PRN + IF lNewLine == NIL + lNewLine := .F. + ENDIF + IF lUpdatePosX == NIL + lUpdatePosX := .T. + ENDIF + ::SetPos( nPosX, nPosY ) + ::TextOut( cString, lNewLine, lUpdatePosX, nAlign ) + RETURN .T. METHOD GetCharWidth() CLASS WIN_PRN - LOCAL nWidth - IF ::FontWidth[2] < 0 .AND. !EMPTY(::FontWidth[1]) - nWidth:= win_MulDiv(::FontWidth[1], ::PixelsPerInchX,::FontWidth[2]) - ELSE - nWidth:= win_GetCharSize(::hPrinterDC) - ENDIF - RETURN(nWidth) + LOCAL nWidth + IF ::FontWidth[ 2 ] < 0 .AND. !EMPTY( ::FontWidth[ 1 ] ) + nWidth := win_MulDiv( ::FontWidth[ 1 ], ::PixelsPerInchX, ::FontWidth[ 2 ] ) + ELSE + nWidth := win_GetCharSize( ::hPrinterDC ) + ENDIF + RETURN nWidth METHOD GetCharHeight() CLASS WIN_PRN - RETURN win_GetCharSize(::hPrinterDC, .T.) + RETURN win_GetCharSize( ::hPrinterDC, .T. ) -METHOD GetTextWidth(cString) CLASS WIN_PRN - LOCAL nWidth - IF ::FontWidth[2] < 0 .AND. !EMPTY(::FontWidth[1]) - nWidth:= LEN(cString) * ::CharWidth - ELSE - nWidth:= win_GetTextSize(::hPrinterDC, cString, LEN(cString)) // Return Width in device units - ENDIF - RETURN(nWidth) +METHOD GetTextWidth( cString ) CLASS WIN_PRN + LOCAL nWidth + IF ::FontWidth[ 2 ] < 0 .AND. !EMPTY( ::FontWidth[ 1 ] ) + nWidth := LEN( cString ) * ::CharWidth + ELSE + nWidth := win_GetTextSize( ::hPrinterDC, cString, LEN( cString ) ) // Return Width in device units + ENDIF + RETURN nWidth -METHOD GetTextHeight(cString) CLASS WIN_PRN - RETURN(win_GetTextSize(::hPrinterDC, cString, LEN(cString), .F.)) // Return Height in device units +METHOD GetTextHeight( cString ) CLASS WIN_PRN + RETURN win_GetTextSize( ::hPrinterDC, cString, LEN( cString ), .F. ) // Return Height in device units -METHOD DrawBitMap(oBmp) CLASS WIN_PRN - LOCAL Result:= .F. - IF ::BitMapsOk .AND. ::Printing .AND. !EMPTY(oBmp:BitMap) - IF (Result:= win_DrawBitMap(::hPrinterDc, oBmp:BitMap,oBmp:Rect[1], oBmp:Rect[2], oBmp:rect[3], oBmp:Rect[4])) - ::HavePrinted:= .T. - ENDIF - ENDIF - RETURN(Result) +METHOD DrawBitMap( oBmp ) CLASS WIN_PRN + LOCAL lResult := .F. + IF ::BitMapsOk .AND. ::Printing .AND. !EMPTY( oBmp:BitMap ) + IF ( lResult := win_DrawBitMap( ::hPrinterDc, oBmp:BitMap, oBmp:Rect[ 1 ], oBmp:Rect[ 2 ], oBmp:rect[ 3 ], oBmp:Rect[ 4 ] ) ) + ::HavePrinted := .T. + ENDIF + ENDIF + RETURN lResult -METHOD SetPrc(nRow, nCol) CLASS WIN_PRN - ::SetPos((nCol * ::CharWidth)+ ::LeftMArgin, (nRow * ::LineHeight) + ::TopMargin) - RETURN(NIL) +METHOD SetPrc( nRow, nCol ) CLASS WIN_PRN + ::SetPos( ( nCol * ::CharWidth ) + ::LeftMArgin, ( nRow * ::LineHeight ) + ::TopMargin ) + RETURN NIL METHOD PROW() CLASS WIN_PRN - RETURN(INT((::PosY- ::TopMargin)/::LineHeight)) // No test for Div by ZERO + RETURN INT( ( ::PosY- ::TopMargin ) / ::LineHeight ) // No test for Div by ZERO METHOD PCOL() CLASS WIN_PRN - RETURN(INT((::PosX - ::LeftMargin)/::CharWidth)) // Uses width of current character + RETURN INT( ( ::PosX - ::LeftMargin ) / ::CharWidth ) // Uses width of current character METHOD MaxRow() CLASS WIN_PRN - RETURN(INT(((::BottomMargin-::TopMargin)+1) / ::LineHeight) - 1) + RETURN INT( ( ( ::BottomMargin - ::TopMargin ) + 1) / ::LineHeight ) - 1 METHOD MaxCol() CLASS WIN_PRN - RETURN(INT(((::RightMargin-::LeftMargin)+1 ) / ::CharWidth) - 1) + RETURN INT( ( ( ::RightMargin - ::LeftMargin ) + 1 ) / ::CharWidth ) - 1 METHOD MM_TO_POSX( nMm ) CLASS WIN_PRN - RETURN( INT( ( ( nMM * ::PixelsPerInchX ) / MM_TO_INCH ) - ::LeftMargin ) ) + RETURN INT( ( ( nMM * ::PixelsPerInchX ) / MM_TO_INCH ) - ::LeftMargin ) METHOD MM_TO_POSY( nMm ) CLASS WIN_PRN - RETURN( INT( ( ( nMM * ::PixelsPerInchY ) / MM_TO_INCH ) - ::TopMargin ) ) + RETURN INT( ( ( nMM * ::PixelsPerInchY ) / MM_TO_INCH ) - ::TopMargin ) METHOD INCH_TO_POSX( nInch ) CLASS WIN_PRN - RETURN( INT( ( nInch * ::PixelsPerInchX ) - ::LeftMargin ) ) + RETURN INT( ( nInch * ::PixelsPerInchX ) - ::LeftMargin ) METHOD INCH_TO_POSY( nInch ) CLASS WIN_PRN - RETURN( INT( ( nInch * ::PixelsPerInchY ) - ::TopMargin ) ) + RETURN INT( ( nInch * ::PixelsPerInchY ) - ::TopMargin ) METHOD TextAtFont( nPosX, nPosY, cString, cFont, nPointSize, nWidth, nBold, lUnderLine, lItalic, nCharSet, lNewLine, lUpdatePosX, nColor, nAlign ) CLASS WIN_PRN - LOCAL lCreated:= .F., nDiv:= 0, cType - DEFAULT nPointSize TO ::FontPointSize - IF cFont != NIL - cType:= VALTYPE(nWidth) - IF cType='A' - nDiv := nWidth[ 1 ] - nWidth:= nWidth[ 2 ] - ELSEIF cType='N' .AND. !EMPTY(nWidth) - nDiv:= 1 + LOCAL lCreated := .F. + LOCAL nDiv := 0 + LOCAL cType + + DEFAULT nPointSize TO ::FontPointSize + + IF cFont != NIL + cType := VALTYPE( nWidth ) + IF cType == 'A' + nDiv := nWidth[ 1 ] + nWidth := nWidth[ 2 ] + ELSEIF cType == 'N' .AND. !EMPTY( nWidth ) + nDiv := 1 ENDIF - lCreated:= win_CreateFont( ::hPrinterDC, cFont, nPointSize, nDiv, nWidth, nBold, lUnderLine, lItalic, nCharSet ) - ENDIF - IF nColor != NIL - nColor:= SetColor( ::hPrinterDC, nColor ) - ENDIF - ::TextOutAt( nPosX, nPosY, cString, lNewLine, lUpdatePosX, nAlign) - IF lCreated - ::SetFont() // Reset font - ENDIF - IF nColor != NIL - SetColor( ::hPrinterDC, nColor ) // Reset Color - ENDIF - RETURN( .T. ) + lCreated := win_CreateFont( ::hPrinterDC, cFont, nPointSize, nDiv, nWidth, nBold, lUnderLine, lItalic, nCharSet ) + ENDIF + IF nColor != NIL + nColor := SetColor( ::hPrinterDC, nColor ) + ENDIF + ::TextOutAt( nPosX, nPosY, cString, lNewLine, lUpdatePosX, nAlign) + IF lCreated + ::SetFont() // Reset font + ENDIF + IF nColor != NIL + SetColor( ::hPrinterDC, nColor ) // Reset Color + ENDIF + RETURN .T. // Bitmap class @@ -657,41 +666,40 @@ CLASS WIN_BMP EXPORTED: - METHOD New() - METHOD LoadFile(cFileName) - METHOD Create() - METHOD Destroy() - METHOD Draw(oPrn,arectangle) - VAR Rect INIT { 0,0,0,0 } // Coordinates to print BitMap - // XDest, // x-coord of destination upper-left corner - // YDest, // y-coord of destination upper-left corner - // nDestWidth, // width of destination rectangle - // nDestHeight, // height of destination rectangle - // See WinApi StretchDIBits() - VAR BitMap INIT "" - VAR FileName INIT "" + METHOD New() + METHOD LoadFile( cFileName ) + METHOD Create() + METHOD Destroy() + METHOD Draw( oPrn, arectangle ) + VAR Rect INIT { 0,0,0,0 } // Coordinates to print BitMap + // XDest, // x-coord of destination upper-left corner + // YDest, // y-coord of destination upper-left corner + // nDestWidth, // width of destination rectangle + // nDestHeight, // height of destination rectangle + // See WinApi StretchDIBits() + VAR BitMap INIT "" + VAR FileName INIT "" ENDCLASS METHOD New() CLASS WIN_BMP - RETURN Self + RETURN Self -METHOD LoadFile(cFileName) CLASS WIN_BMP - ::FileName:= cFileName - ::Bitmap := win_LoadBitMapFile(::FileName) - RETURN !EMPTY(::Bitmap) +METHOD LoadFile( cFileName ) CLASS WIN_BMP + ::FileName := cFileName + ::Bitmap := win_LoadBitMapFile( ::FileName ) + RETURN ! EMPTY( ::Bitmap ) METHOD Create() CLASS WIN_BMP // Compatibility function for Alaska Xbase++ - Return Self + RETURN Self METHOD Destroy() CLASS WIN_BMP // Compatibility function for Alaska Xbase++ - RETURN NIL + RETURN NIL -METHOD Draw(oPrn, aRectangle) CLASS WIN_BMP // Pass a TPRINT class reference & Rectangle array - ::Rect := aRectangle - RETURN oPrn:DrawBitMap(Self) +METHOD Draw( oPrn, aRectangle ) CLASS WIN_BMP // Pass a TPRINT class reference & Rectangle array + ::Rect := aRectangle + RETURN oPrn:DrawBitMap( Self ) CLASS XBPBITMAP FROM WIN_BMP // Compatibility Class for Alaska Xbase++ - ENDCLASS #endif