2009-11-22 03:00 UTC+0100 Viktor Szakats (harbour.01 syenar.hu)

* contrib/hbwin/win_tprn.prg
    ! Accidentally missed GetDocumentProperties() method added.
    % Converted all INLINE methods to normal ones (for optimal performance).

  * contrib/hbwin/win_tcom.prg
    % Converted all INLINE methods to normal ones (for optimal performance).

  * contrib/hbwin/win_prn1.c
    % Using hb_arraySet*() APIs.

  * contrib/hbwin/win_prn2.c
    * Minor formatting.
This commit is contained in:
Viktor Szakats
2009-11-22 02:00:56 +00:00
parent 868781febc
commit 2d9cd201eb
5 changed files with 133 additions and 38 deletions

View File

@@ -17,6 +17,20 @@
past entries belonging to author(s): Viktor Szakats.
*/
2009-11-22 03:00 UTC+0100 Viktor Szakats (harbour.01 syenar.hu)
* contrib/hbwin/win_tprn.prg
! Accidentally missed GetDocumentProperties() method added.
% Converted all INLINE methods to normal ones (for optimal performance).
* contrib/hbwin/win_tcom.prg
% Converted all INLINE methods to normal ones (for optimal performance).
* contrib/hbwin/win_prn1.c
% Using hb_arraySet*() APIs.
* contrib/hbwin/win_prn2.c
* Minor formatting.
2009-11-21 00:00 UTC+0100 Viktor Szakats (harbour.01 syenar.hu)
* contrib/hbwin/win_prn2.c
! Fixed PRINTEREXISTS() in UNICODE mode (hidden by wrong cast).

View File

@@ -596,10 +596,10 @@ static int CALLBACK FontEnumCallBack( LOGFONT * lplf, TEXTMETRIC * lpntm, DWORD
char * pszFaceName = HB_TCHAR_CONVFROM( lplf->lfFaceName );
hb_arrayNew( SubItems, 4 );
hb_itemPutC( hb_arrayGetItemPtr( SubItems, 1 ), pszFaceName );
hb_itemPutL( hb_arrayGetItemPtr( SubItems, 2 ), lplf->lfPitchAndFamily & FIXED_PITCH );
hb_itemPutL( hb_arrayGetItemPtr( SubItems, 3 ), FontType & TRUETYPE_FONTTYPE );
hb_itemPutNL( hb_arrayGetItemPtr( SubItems, 4 ), lpntm->tmCharSet );
hb_arraySetC( SubItems, 1, pszFaceName );
hb_arraySetL( SubItems, 2, lplf->lfPitchAndFamily & FIXED_PITCH );
hb_arraySetL( SubItems, 3, FontType & TRUETYPE_FONTTYPE );
hb_arraySetNL( SubItems, 4, lpntm->tmCharSet );
hb_arrayAddForward( ( PHB_ITEM ) pArray, SubItems );
hb_itemRelease( SubItems );
HB_TCHAR_FREE( pszFaceName );

View File

@@ -108,7 +108,7 @@ static BOOL hb_PrinterExists( const char * pszPrinterName )
for( a = 0; ! Result && a < returned; ++a, ++pPrinterEnum )
{
char * pszData = HB_TCHAR_CONVFROM( pPrinterEnum->pPrinterName );
Result = strcmp( pszPrinterName, pszData ) == 0;
Result = ( strcmp( pszPrinterName, pszData ) == 0 );
HB_TCHAR_FREE( pszData );
}
}

View File

@@ -80,26 +80,24 @@ CREATE CLASS win_Com
PROTECT cPortName INIT ""
METHOD Init( cPortName, nBaudRate, nParity, nByteSize, nStopBits )
METHOD QueueSize( nInQueue, nOutQueue ) INLINE win_ComSetQueueSize( ::nPort, nInQueue, nOutQueue )
METHOD TimeOuts( nReadInterval, nReadMultiplier, nReadConstant, nWriteMultiplier, nWriteConstant ) ;
INLINE win_ComSetTimeOuts( ::nPort, nReadInterval, nReadMultiplier, nReadConstant, nWriteMultiplier, nWriteConstant )
METHOD QueueSize( nInQueue, nOutQueue )
METHOD TimeOuts( nReadInterval, nReadMultiplier, nReadConstant, nWriteMultiplier, nWriteConstant )
METHOD Read( /* @ */ cString, nLength )
METHOD Recv( nLength, nResult ) INLINE win_ComRecv( ::nPort, nLength, @nResult )
METHOD Recv( nLength, nResult )
METHOD RecvTo( cDelim, nMaxlen )
METHOD Write( cString ) INLINE win_ComWrite( ::nPort, cString )
METHOD Status( lCTS, lDSR, lRing, lDCD ) INLINE win_ComStatus( ::nPort, @lCTS, @lDSR, @lRing, @lDCD )
METHOD QueueStatus( lCTSHold, lDSRHold, lDCDHold, lXoffHold, lXoffSent, nInQueue, nOutQueue ) ;
INLINE win_ComQueueStatus( ::nPort, @lCTSHold, @lDSRHold, @lDCDHold, @lXoffHold, @lXoffSent, @nInQueue, @nOutQueue )
METHOD SetRTS( lCTS ) INLINE win_ComSetRTS( ::nPort, lCTS ) /* boolean return is the status of the call not the line! */
METHOD SetDTR( lDTR ) INLINE win_ComSetDTR( ::nPort, lDTR ) /* boolean return is the status of the call not the line! */
METHOD RTSFlow( nRTS ) INLINE win_ComRTSFlow( ::nPort, nRTS )
METHOD DTRFlow( nDTR ) INLINE win_ComDTRFlow( ::nPort, nDTR )
METHOD XonXoffFlow( lXonXoff ) INLINE win_ComXonXoffFlow( ::nPort, lXonXoff )
METHOD Purge( lRXBuffer, lTXBuffer ) INLINE win_ComPurge( ::nPort, lRXBuffer, lTXBuffer )
METHOD PurgeRX() INLINE win_ComPurge( ::nPort, .T., .F. )
METHOD PurgeTX() INLINE win_ComPurge( ::nPort, .F., .T. )
METHOD Close( nDrain ) INLINE win_ComClose( ::nPort, iif( Empty( nDrain ), 0, nDrain ) )
METHOD DebugDCB( nDebug ) INLINE win_ComDebugDCB( ::nPort, nDebug )
METHOD Write( cString )
METHOD Status( lCTS, lDSR, lRing, lDCD )
METHOD QueueStatus( lCTSHold, lDSRHold, lDCDHold, lXoffHold, lXoffSent, nInQueue, nOutQueue )
METHOD SetRTS( lCTS )
METHOD SetDTR( lDTR )
METHOD RTSFlow( nRTS )
METHOD DTRFlow( nDTR )
METHOD XonXoffFlow( lXonXoff )
METHOD Purge( lRXBuffer, lTXBuffer )
METHOD PurgeRX()
METHOD PurgeTX()
METHOD Close( nDrain )
METHOD DebugDCB( nDebug )
METHOD ErrorText()
ENDCLASS
@@ -117,12 +115,21 @@ METHOD Init( cPortName, nBaudRate, nParity, nByteSize, nStopBits ) CLASS win_Com
RETURN self
METHOD QueueSize( nInQueue, nOutQueue ) CLASS win_Com
RETURN win_ComSetQueueSize( ::nPort, nInQueue, nOutQueue )
METHOD TimeOuts( nReadInterval, nReadMultiplier, nReadConstant, nWriteMultiplier, nWriteConstant ) CLASS win_Com
RETURN win_ComSetTimeOuts( ::nPort, nReadInterval, nReadMultiplier, nReadConstant, nWriteMultiplier, nWriteConstant )
METHOD Read( /* @ */ cString, nLength ) CLASS win_Com
cString := Space( nlength )
RETURN win_ComRead( ::nPort, @cString )
METHOD Recv( nLength, nResult ) CLASS win_Com
RETURN win_ComRecv( ::nPort, nLength, @nResult )
METHOD RecvTo( cDelim, nMaxlen ) CLASS win_Com
LOCAL nResult
LOCAL cRecv := ""
@@ -150,6 +157,45 @@ METHOD RecvTo( cDelim, nMaxlen ) CLASS win_Com
RETURN cRecv
METHOD Write( cString ) CLASS win_Com
RETURN win_ComWrite( ::nPort, cString )
METHOD Status( lCTS, lDSR, lRing, lDCD ) CLASS win_Com
RETURN win_ComStatus( ::nPort, @lCTS, @lDSR, @lRing, @lDCD )
METHOD QueueStatus( lCTSHold, lDSRHold, lDCDHold, lXoffHold, lXoffSent, nInQueue, nOutQueue ) CLASS win_Com
RETURN win_ComQueueStatus( ::nPort, @lCTSHold, @lDSRHold, @lDCDHold, @lXoffHold, @lXoffSent, @nInQueue, @nOutQueue )
METHOD SetRTS( lCTS ) CLASS win_Com
RETURN win_ComSetRTS( ::nPort, lCTS ) /* boolean return is the status of the call not the line! */
METHOD SetDTR( lDTR ) CLASS win_Com
RETURN win_ComSetDTR( ::nPort, lDTR ) /* boolean return is the status of the call not the line! */
METHOD RTSFlow( nRTS ) CLASS win_Com
RETURN win_ComRTSFlow( ::nPort, nRTS )
METHOD DTRFlow( nDTR ) CLASS win_Com
RETURN win_ComDTRFlow( ::nPort, nDTR )
METHOD XonXoffFlow( lXonXoff ) CLASS win_Com
RETURN win_ComXonXoffFlow( ::nPort, lXonXoff )
METHOD Purge( lRXBuffer, lTXBuffer ) CLASS win_Com
RETURN win_ComPurge( ::nPort, lRXBuffer, lTXBuffer )
METHOD PurgeRX() CLASS win_Com
RETURN win_ComPurge( ::nPort, .T., .F. )
METHOD PurgeTX() CLASS win_Com
RETURN win_ComPurge( ::nPort, .F., .T. )
METHOD Close( nDrain ) CLASS win_Com
RETURN win_ComClose( ::nPort, iif( Empty( nDrain ), 0, nDrain ) )
METHOD DebugDCB( nDebug ) CLASS win_Com
RETURN win_ComDebugDCB( ::nPort, nDebug )
/* Since the win_Com functions are an amalgamation of Win functions this allows
you to see what call did the deed when things go wrong. */

View File

@@ -84,6 +84,7 @@ CREATE CLASS WIN_PRN
METHOD EndPage( lStartNewPage ) // If lStartNewPage == .T. then StartPage() is called for the next page of output
METHOD NewLine()
METHOD NewPage()
METHOD GetDocumentProperties()
METHOD SetFont( cFontName, nPointSize, nWidth, nBold, lUnderline, lItalic, nCharSet )
// NB: nWidth is in "CharactersPerInch"
// _OR_ { nMul, nDiv } which equates to "CharactersPerInch"
@@ -103,22 +104,18 @@ CREATE CLASS WIN_PRN
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 SetColor( 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 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 SetPen( nStyle, nWidth, nColor )
METHOD Line( nX1, nY1, nX2, nY2 )
METHOD Box( nX1, nY1, nX2, nY2, nWidth, nHeight )
METHOD Arc( nX1, nY1, nX2, nY2 )
METHOD Ellipse( nX1, nY1, nX2, nY2 )
METHOD FillRect( nX1, nY1, nX2, nY2, nColor )
METHOD GetCharWidth()
METHOD GetCharHeight()
METHOD GetTextWidth( cString )
@@ -141,10 +138,10 @@ CREATE CLASS WIN_PRN
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 SetBkMode( nMode ) // OPAQUE == 2 or TRANSPARENT == 1
// Set Background mode
METHOD GetDeviceCaps( nCaps ) INLINE win_GetDeviceCaps( ::hPrinterDC, nCaps)
METHOD GetDeviceCaps( nCaps )
VAR PrinterName INIT ""
VAR Printing INIT .F.
@@ -350,6 +347,9 @@ METHOD NewPage() CLASS WIN_PRN
::EndPage( .T. )
RETURN .T.
METHOD GetDocumentProperties() CLASS WIN_PRN
RETURN win_GetDocumentProperties( ::PrinterName, @::FormType, @::Landscape, @::Copies, @::BinNumber, @::fDuplexType, @::fPrintQuality )
// 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 }
@@ -392,7 +392,7 @@ METHOD SetFont( cFontName, nPointSize, nWidth, nBold, lUnderline, lItalic, nChar
::FontName := win_GetPrinterFontName( ::hPrinterDC ) // Get the font name that Windows actually used
RETURN ::SetFontOk
METHOD SetDefaultFont()
METHOD SetDefaultFont() CLASS WIN_PRN
RETURN ::SetFont( "Courier New", 12, { 1, 10 }, 0, .F., .F., 0 )
METHOD Bold( nWeight ) CLASS WIN_PRN
@@ -470,6 +470,14 @@ METHOD SetPos( nPosX, nPosY ) CLASS WIN_PRN
RETURN aOldValue
METHOD SetColor( nClrText, nClrPane, nAlign ) CLASS WIN_PRN
::TextColor := nClrText
::BkColor := nClrPane
::TextAlign := nAlign
RETURN win_SetColor( ::hPrinterDC, nClrText, nClrPane, nAlign )
METHOD TextOut( cString, lNewLine, lUpdatePosX, nAlign ) CLASS WIN_PRN
LOCAL nPosX
@@ -498,6 +506,27 @@ METHOD TextOutAt( nPosX, nPosY, cString, lNewLine, lUpdatePosX, nAlign ) CLASS W
::TextOut( cString, lNewLine, lUpdatePosX, nAlign )
RETURN .T.
METHOD SetPen( nStyle, nWidth, nColor ) CLASS WIN_PRN
::PenStyle := nStyle
::PenWidth := nWidth
::PenColor := nColor
RETURN win_SetPen(::hPrinterDC, nStyle, nWidth, nColor )
METHOD Line( nX1, nY1, nX2, nY2 ) CLASS WIN_PRN
RETURN win_LineTo( ::hPrinterDC, nX1, nY1, nX2, nY2 )
METHOD Box( nX1, nY1, nX2, nY2, nWidth, nHeight ) CLASS WIN_PRN
RETURN win_Rectangle( ::hPrinterDC, nX1, nY1, nX2, nY2, nWidth, nHeight )
METHOD Arc( nX1, nY1, nX2, nY2 ) CLASS WIN_PRN
RETURN win_Arc( ::hPrinterDC, nX1, nY1, nX2, nY2 )
METHOD Ellipse( nX1, nY1, nX2, nY2 ) CLASS WIN_PRN
RETURN win_Ellipse( ::hPrinterDC, nX1, nY1, nX2, nY2 )
METHOD FillRect( nX1, nY1, nX2, nY2, nColor ) CLASS WIN_PRN
RETURN win_FillRect( ::hPrinterDC, nX1, nY1, nX2, nY2, nColor )
METHOD GetCharWidth() CLASS WIN_PRN
LOCAL nWidth
IF ::FontWidth[ 2 ] < 0 .AND. ! Empty( ::FontWidth[ 1 ] )
@@ -588,6 +617,12 @@ METHOD TextAtFont( nPosX, nPosY, cString, cFont, nPointSize, nWidth, nBold, lUnd
ENDIF
RETURN .T.
METHOD SetBkMode( nMode ) CLASS WIN_PRN
RETURN win_SetBkMode( ::hPrinterDc, nMode )
METHOD GetDeviceCaps( nCaps ) CLASS WIN_PRN
RETURN win_GetDeviceCaps( ::hPrinterDC, nCaps)
// Bitmap class
CREATE CLASS WIN_BMP