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

  1. #include "FiveWin.ch"
  2.  
  3. //----------------------------------------------------------------------------//
  4.  
  5. CLASS TBrush
  6.  
  7.    DATA   hBrush, hBitmap
  8.  
  9.    METHOD New( cStyle, nRGBColor, cBmpFile, cBmpRes ) CONSTRUCTOR
  10.  
  11.    METHOD cGenPRG()
  12.  
  13.    METHOD Release()
  14.  
  15. ENDCLASS
  16.  
  17. //----------------------------------------------------------------------------//
  18.  
  19. METHOD New( cStyle, nRGBColor, cBmpFile, cBmpRes ) CLASS TBrush
  20.  
  21.    local nAt
  22.    local aNewTypes := { "BORLAND", "BRICKS", "TILED" }
  23.    local aStdTypes := { "HORIZONTAL", "VERTICAL", "FDIAGONAL", "BDIAGONAL",;
  24.                         "CROSS", "DIAGCROSS" }
  25.  
  26.    ::hBrush  = 0
  27.    ::hBitmap = 0
  28.  
  29.    do case
  30.       case cStyle == nil .and. nRGBColor != nil
  31.            ::hBrush = CreateSolidBrush( nRGBColor )
  32.  
  33.       case cStyle != nil
  34.            do case
  35.               case ( nAt := AScan( aNewTypes, cStyle ) ) != 0
  36.                    ::hBitmap = FWBrushes( nAt )
  37.                    ::hBrush = If( ::hBitmap > 0,;
  38.                                   CreatePatternBrush( ::hBitmap ), )
  39.  
  40.               case ( nAt := AScan( aStdTypes, cStyle ) ) != 0
  41.                    ::hBrush = CreateHatchBrush( nAt - 1, nRGBColor )
  42.  
  43.               otherwise
  44.                  if File( cBmpFile )
  45.                     ::hBitMap = ReadBitmap( 0, cBmpFile )
  46.                     ::hBrush = If( ::hBitmap > 0,;
  47.                                    CreatePatternBrush( ::hBitmap ), )
  48.                  endif
  49.            endcase
  50.  
  51.       case cBmpFile != nil
  52.            if File( cBmpFile )
  53.               ::hBitMap = ReadBitmap( 0, cBmpFile )
  54.               ::hBrush = If( ::hBitmap > 0, CreatePatternBrush( ::hBitmap ), )
  55.            endif
  56.  
  57.       case cBmpRes != nil
  58.            ::hBitmap = LoadBitmap( GetResources(), cBmpRes )
  59.            ::hBrush  = If( ::hBitmap > 0, CreatePatternBrush( ::hBitmap ),)
  60.    endcase
  61.  
  62.  
  63. return nil
  64.  
  65. //----------------------------------------------------------------------------//
  66.  
  67. METHOD cGenPRG() CLASS TBrush
  68.  
  69.    local cPrg := ""
  70.  
  71.    cPrg += CRLF + ;
  72.            "   DEFINE BRUSH oBrush " + ;
  73.            If( ::hBitmap != 0, 'BITMAP "brush.bmp"', "" ) + CRLF
  74.  
  75. return cPrg
  76.  
  77. //----------------------------------------------------------------------------//
  78.  
  79. METHOD Release() CLASS TBrush
  80.  
  81.    if ::hBrush != nil .and. ::hBrush > 0
  82.        DeleteObject( ::hBrush )
  83.    endif
  84.  
  85.    if ::hBitmap != nil .and. ::hBitMap > 0
  86.       DeleteObject( ::hBitmap )
  87.    endif
  88.  
  89.    ::hBrush  = 0
  90.    ::hBitmap = 0
  91.  
  92. return nil
  93.  
  94. //----------------------------------------------------------------------------//
  95.