home *** CD-ROM | disk | FTP | other *** search
/ DP Tool Club 16 / CD_ASCQ_16_0994.iso / news / 4611 / fw16d.ins / SOURCE / CLASSES / FONT.PRG < prev    next >
Text File  |  1994-06-03  |  5KB  |  118 lines

  1. #include "FiveWin.ch"
  2.  
  3. #define FW_BOLD 700
  4.  
  5. //----------------------------------------------------------------------------//
  6.  
  7. CLASS TFont
  8.  
  9.    DATA   cFaceName
  10.    DATA   hFont, hFontOld
  11.    DATA   lBold, lItalic, lUnderline, lStrikeOut
  12.    DATA   nHeight, nWidth, nEscapement, nOrientation, nWeight
  13.    DATA   nCharSet, nOutPrecision, nClipPrecision, nQuality, nPitchFamily
  14.  
  15.    METHOD New( cFaceName, nWidth, nHeight, lFromUser,;
  16.                lBold, nEscapement, nOrientation, nWeight, lItalic,;
  17.                lUnderline, lStrikeOut, nCharSet, nOutPrecision,;
  18.                nClipPrecision, nQuality ) CONSTRUCTOR
  19.  
  20.    METHOD Choose( nRGBColor )     // passed by reference
  21.  
  22.    METHOD Release() INLINE If( ::hFont != 0, DeleteObject( ::hFont ),)
  23.  
  24.    METHOD Activate( hDC ) INLINE ::hFontOld := SelectObject( hDC, ::hFont )
  25.  
  26.    METHOD DeActivate( hDC ) INLINE  SelectObject( hDC, ::hFontOld )
  27.  
  28. ENDCLASS
  29.  
  30. //----------------------------------------------------------------------------//
  31.  
  32. METHOD New( cFaceName, nWidth, nHeight, lFromUser, lBold,;
  33.             nEscapement, nOrientation, nWeight, lItalic, lUnderline,;
  34.             lStrikeOut, nCharSet, nOutPrecision, nClipPrecision,;
  35.             nQuality ) CLASS TFont
  36.  
  37.    local aFont, nRGBColor
  38.  
  39.    DEFAULT nEscapement := 0, nOrientation := 0, nWeight := 0, lItalic := .f.,;
  40.            lFromUser := .f., lUnderLine := .f., lStrikeOut := .f.,;
  41.            nCharSet := 0, nOutPrecision := 0, nClipPrecision := 0,;
  42.            nQuality := 0, lBold := .f.
  43.  
  44.    if lBold
  45.       nWeight = nOr( nWeight, FW_BOLD )
  46.       ::lBold = lBold
  47.    endif
  48.  
  49.    if lFromUser
  50.       aFont     = ChooseFont( , @nRGBColor )
  51.       lFromUser = ! Empty( aFont[ LF_FACENAME ] )
  52.    endif
  53.  
  54.    ::cFaceName      = If( lFromUser, aFont[ LF_FACENAME ], cFaceName )
  55.    ::nHeight        = If( lFromUser, aFont[ LF_HEIGHT ], nHeight )
  56.    ::nWidth         = If( lFromUser, aFont[ LF_WIDTH ], nWidth )
  57.    ::nEscapement    = If( lFromUser, aFont[ LF_ESCAPEMENT ], nEscapement )
  58.    ::nOrientation   = If( lFromUser, aFont[ LF_ORIENTATION ], nOrientation )
  59.    ::nWeight        = If( lFromUser, aFont[ LF_WEIGHT ], nWeight )
  60.    ::lItalic        = If( lFromUser, aFont[ LF_ITALIC ], lItalic )
  61.    ::lUnderLine     = If( lFromUser, aFont[ LF_UNDERLINE ], lUnderLine )
  62.    ::lStrikeOut     = If( lFromUser, aFont[ LF_STRIKEOUT ], lStrikeOut )
  63.    ::nCharSet       = If( lFromUser, aFont[ LF_CHARSET ], nCharSet )
  64.    ::nOutPrecision  = If( lFromUser, aFont[ LF_OUTPRECISION ], nOutPrecision )
  65.    ::nClipPrecision = If( lFromUser, aFont[ LF_CLIPPRECISION ], nClipPrecision )
  66.    ::nQuality       = If( lFromUser, aFont[ LF_QUALITY ], nQuality )
  67.    ::nPitchFamily   = If( lFromUser, aFont[ LF_PITCHANDFAMILY ], 0 )
  68.    ::hFontOld       = 0
  69.  
  70.    if ::cFaceName != "System"
  71.       ::hFont = CreateFont( { ::nHeight, ::nWidth, ::nEscapement,;
  72.                               ::nOrientation, ::nWeight, ::lItalic,;
  73.                               ::lUnderLine, ::lStrikeOut, ::nCharSet,;
  74.                               ::nOutPrecision, ::nClipPrecision,;
  75.                               ::nQuality, ::nPitchFamily, ::cFaceName } )
  76.    endif
  77.  
  78. return nil
  79.  
  80. //----------------------------------------------------------------------------//
  81.  
  82. METHOD Choose( nRGBColor ) CLASS TFont
  83.  
  84.    local aFont := ChooseFont( { ::nHeight, ::nWidth, ::nEscapement,;
  85.                                 ::nOrientation, ::nWeight, ::lItalic,;
  86.                                 ::lUnderLine, ::lStrikeOut, ::nCharSet,;
  87.                                 ::nOutPrecision, ::nClipPrecision,;
  88.                                 ::nQuality, ::nPitchFamily, ::cFaceName },;
  89.                                @nRGBColor )
  90.  
  91.    ::cFaceName      = aFont[ LF_FACENAME ]
  92.    ::nHeight        = aFont[ LF_HEIGHT ]
  93.    ::lBold          = lAnd( ::nHeight, FW_BOLD )
  94.    ::nWidth         = aFont[ LF_WIDTH ]
  95.    ::nEscapement    = aFont[ LF_ESCAPEMENT ]
  96.    ::nOrientation   = aFont[ LF_ORIENTATION ]
  97.    ::nWeight        = aFont[ LF_WEIGHT ]
  98.    ::lItalic        = aFont[ LF_ITALIC ]
  99.    ::lUnderLine     = aFont[ LF_UNDERLINE ]
  100.    ::lStrikeOut     = aFont[ LF_STRIKEOUT ]
  101.    ::nCharSet       = aFont[ LF_CHARSET ]
  102.    ::nOutPrecision  = aFont[ LF_OUTPRECISION ]
  103.    ::nClipPrecision = aFont[ LF_CLIPPRECISION ]
  104.    ::nQuality       = aFont[ LF_QUALITY ]
  105.    ::nPitchFamily   = aFont[ LF_PITCHANDFAMILY ]
  106.  
  107.    if ::cFaceName != "System"
  108.       ::hFont = CreateFont( { ::nHeight, ::nWidth, ::nEscapement,;
  109.                               ::nOrientation, ::nWeight, ::lItalic,;
  110.                               ::lUnderLine, ::lStrikeOut, ::nCharSet,;
  111.                               ::nOutPrecision, ::nClipPrecision,;
  112.                               ::nQuality, ::nPitchFamily, ::cFaceName } )
  113.    endif
  114.  
  115. return Self            //  returns a reference to the Object
  116.  
  117. //----------------------------------------------------------------------------//
  118.