home *** CD-ROM | disk | FTP | other *** search
/ DP Tool Club 16 / CD_ASCQ_16_0994.iso / news / 4611 / fw16d.ins / SOURCE / CLASSES / PRINTER.PRG < prev    next >
Text File  |  1994-05-14  |  3KB  |  114 lines

  1. #include "FiveWin.ch"
  2.  
  3. #define HORZSIZE            4
  4. #define VERTSIZE            6
  5. #define HORZRES             8
  6. #define VERTRES            10
  7. #define LOGPIXELSX         88
  8. #define LOGPIXELSY         90
  9.  
  10. #define MM_TEXT             1
  11. #define MM_LOMETRIC         2
  12. #define MM_HIMETRIC         3
  13. #define MM_LOENGLISH        4
  14. #define MM_HIENGLISH        5
  15. #define MM_TWIPS            6
  16. #define MM_ISOTROPIC        7
  17. #define MM_ANISOTROPIC      8
  18.  
  19. static oPrinter
  20.  
  21. //----------------------------------------------------------------------------//
  22.  
  23. CLASS TPrinter
  24.  
  25.    DATA   hDC
  26.  
  27.    METHOD New( cDocument, oWnd ) CONSTRUCTOR
  28.  
  29.    METHOD StartPage() INLINE  StartPage( ::hDC )
  30.  
  31.    METHOD EndPage()   INLINE  EndPage( ::hDC )
  32.  
  33.    METHOD End()       INLINE  EndDoc( ::hDC ), DeleteDC( ::hDC )
  34.  
  35.    METHOD Say( nRow, nCol, cText, oFont )
  36.  
  37.    METHOD SetPos( nRow, nCol )  VIRTUAL
  38.    METHOD Line( nRow, nCol )    VIRTUAL
  39.  
  40.    METHOD Box( nRow, nCol, nBottom, nRight ) INLINE ;
  41.                       Rectangle( ::hDC, nRow, nCol, nBottom, nRight )
  42.  
  43.    METHOD nVertRes()  INLINE  GetDeviceCaps( ::hDC, VERTRES  )
  44.    METHOD nHorzRes()  INLINE  GetDeviceCaps( ::hDC, HORZRES  )
  45.  
  46.    METHOD nVertSize() INLINE  GetDeviceCaps( ::hDC, VERTSIZE )
  47.    METHOD nHorzSize() INLINE  GetDeviceCaps( ::hDC, HORZSIZE )
  48.  
  49.    METHOD nLogPixelsX() INLINE GetDeviceCaps( ::hDC, LOGPIXELSX )
  50.    METHOD nLogPixelsY() INLINE GetDeviceCaps( ::hDC, LOGPIXELSY )
  51.  
  52.    METHOD SetPixelMode()  INLINE SetMapMode( ::hDC, MM_TEXT )
  53.    METHOD SetTwipsMode()  INLINE SetMapMode( ::hDC, MM_TWIPS )
  54.  
  55.    METHOD SetLoInchMode() INLINE SetMapMode( ::hDC, MM_LOENGLISH )
  56.    METHOD SetHiInchMode() INLINE SetMapMode( ::hDC, MM_HIENGLISH )
  57.  
  58.    METHOD SetLoMetricMode() INLINE SetMapMode( ::hDC, MM_LOMETRIC )
  59.    METHOD SetHiMetricMode() INLINE SetMapMode( ::hDC, MM_HIMETRIC )
  60.  
  61.    METHOD SetIsotropicMode()   INLINE SetMapMode( ::hDC, MM_ISOTROPIC )
  62.    METHOD SetAnisotropicMode() INLINE SetMapMode( ::hDC, MM_ANISOTROPIC )
  63.  
  64.    METHOD SetWindowExt( nUnitsWidth, nUnitsHeight ) INLINE ;
  65.                         SetWindowExt( ::hDC, nUnitsWidth, nUnitsHeight )
  66.  
  67.    METHOD SetViewPortExt( nWidth, nHeight ) INLINE ;
  68.                           SetViewPortExt( ::hDC, nWidth, nHeight )
  69.  
  70. ENDCLASS
  71.  
  72. //----------------------------------------------------------------------------//
  73.  
  74. METHOD New( cDocument, oWnd ) CLASS TPrinter
  75.  
  76.    ::hDC = GetPrintDC( If( oWnd == nil, GetActiveWindow(), oWnd:hWnd ) )
  77.  
  78.    StartDoc( ::hDC, cDocument )
  79.  
  80. return nil
  81.  
  82. //----------------------------------------------------------------------------//
  83.  
  84. METHOD Say( nRow, nCol, cText, oFont ) CLASS TPrinter
  85.  
  86.    if oFont != nil
  87.       oFont:Activate( ::hDC )
  88.    endif
  89.  
  90.    TextOut( ::hDC, nRow, nCol, cText )
  91.  
  92.    if oFont != nil
  93.       oFont:DeActivate( ::hDC )
  94.    endif
  95.  
  96. return nil
  97.  
  98. //----------------------------------------------------------------------------//
  99. // Friend functions
  100.  
  101. function PrintBegin( cDocName )
  102.  
  103. return ( oPrinter := TPrinter():New( cDocName ) )
  104.  
  105. //----------------------------------------------------------------------------//
  106.  
  107. function PageBegin() ; oPrinter:StartPage() ; return nil
  108.  
  109. function PageEnd() ; oPrinter:EndPage(); return nil
  110.  
  111. function PrintEnd() ; oPrinter:End() ; oPrinter := nil; return nil
  112.  
  113. //----------------------------------------------------------------------------//
  114.