CLASS HStyle INHERIT HObject
CLASS VAR aStyles INIT { }
DATA id
DATA nOrient
DATA aColors
DATA oBitmap
DATA nBorder
DATA tColor
DATA oPen
DATA aCorners
METHOD New( aColors, nOrient, aCorners, nBorder, tColor, oBitmap )
METHOD Draw( hDC, nLeft, nTop, nRight, nBottom )
ENDCLASS
METHOD New( aColors, nOrient, aCorners, nBorder, tColor, oBitmap ) CLASS HStyle
LOCAL i, nlen := Len( ::aStyles )
nBorder := Iif( nBorder == Nil, 0, nBorder )
tColor := Iif( tColor == Nil, -1, tColor )
nOrient := Iif( nOrient == Nil .OR. nOrient > 9, 1, nOrient )
FOR i := 1 TO nlen
IF hwg_aCompare( ::aStyles[i]:aColors, aColors ) .AND. ;
hwg_aCompare( ::aStyles[i]:aCorners, aCorners ) .AND. ;
Valtype(::aStyles[i]:tColor) == Valtype(tColor) .AND. ;
::aStyles[i]:nBorder == nBorder .AND. ;
::aStyles[i]:tColor == tColor .AND. ;
::aStyles[i]:nOrient == nOrient .AND. ;
( ( ::aStyles[i]:oBitmap == Nil .AND. oBitmap == Nil ) .OR. ;
( ::aStyles[i]:oBitmap != Nil .AND. oBitmap != Nil .AND. ::aStyles[i]:oBitmap:name == oBitmap:name ) )
RETURN ::aStyles[ i ]
ENDIF
NEXT
::aColors := aColors
::nOrient := nOrient
::nBorder := nBorder
::tColor := tColor
::aCorners := aCorners
::oBitmap := oBitmap
IF nBorder > 0
::oPen := HPen():Add( BS_SOLID, nBorder, tColor )
ENDIF
AAdd( ::aStyles, Self )
::id := Len( ::aStyles )
RETURN Self
METHOD Draw( hDC, nLeft, nTop, nRight, nBottom ) CLASS HStyle
IF ::oBitmap == Nil
hwg_drawGradient( hDC, nLeft, nTop, nRight, nBottom, ::nOrient, ::aColors,, ::aCorners )
ELSE
hwg_SpreadBitmap( hDC, ::oBitmap:handle, nLeft, nTop, nRight, nBottom )
ENDIF
IF !Empty( ::oPen )
hwg_Selectobject( hDC, ::oPen:handle )
hwg_Rectangle( hDC, nLeft, nTop, nRight-1, nBottom-1 )
ENDIF
RETURN Nil
Esse HStyle faz o desenho da janela, seja controle ou Dialog mesmo.