FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour gradient effect
Posts: 1392
Joined: Mon May 14, 2007 09:49 AM
gradient effect
Posted: Wed Jan 21, 2009 10:10 AM

Hi, all !

This programm with DIALOG is fine, but with WINDOW I not got of gradient effect. Why ?

DEFINE WINDOW oDlg

@ 0.5, 1 FOLDER oFld PAGES "One", "Two" SIZE 190, 140

ACTIVATE WINDOW oDlg ;
ON PAINT GradientFill( hDC, 0, 0, oDlg:nHeight, oDlg:nWidth, { { 0.50, 16054371, 8388608 } } ) ;
ON INIT SetDialogsGradient( oFld )

Posts: 4043
Joined: Wed Dec 19, 2007 06:40 PM
Re: gradient effect
Posted: Wed Jan 21, 2009 12:00 PM
Hello,

You have to define the Gradient-Style :
----------------------------------------------
local aGrad := { { 0.50, COLOR1, COLOR2 }, ;
{ 0.50, COLOR2, COLOR1 } }
The Direction ( Horizontal or Vertical .T., .F.
-----------------------------------------------------
GradientFill( hDC, 0, 0, oWnd:nHeight, oWnd:nWidth, aGrad, .T. )

Different ways, how to do it in relation to FWH-Versions

....
....

DEFINE WINDOW oWnd TITLE "Background for Windows and Dialog" 

DEFINE BUTTONBAR oBar OF oWnd SIZE 80, 75 2007 RIGHT 

// Gradient-Bar
// ---------------
oBar:bClrGrad :=  { | lInvert | If( ! lInvert, ;
		{ { 0.90,11892819,16777215 },{ 0.90,16777215,11892819 } },;
		{ { 0.50,128,16777215 }, { 0.50,16777215,128 } } ) }
oBar:nClrText := 0

DEFINE BUTTON oBtn1 OF oBar ACTION ( ..... )  ;
RESOURCE "magic" PROMPT "Project" + CRLF + "Selection" TOOLTIP "Bar-Select"

SET MESSAGE OF oWnd TO "Windows- and Dialog-Background-Settings" ;
CENTERED CLOCK KEYBOARD 2007

// Gradient with Alpha-Blended BMP
// ---------------------------------------
ACTIVATE WINDOW oWnd MAXIMIZED ;
ON PAINT ( W_GRAD( hDC, oWnd ), ALPHA_BMP(hDC) ) ;
VALID MsgYesNo( "Do you want to end?" )

RETURN NIL

// --------- GRADIENT-Functions for different FWH-Versions ---------

STATIC FUNCTION W_GRAD( hDC, oWnd )
local aGrad := { { 0.50, COLOR1, COLOR2 }, ;
                       { 0.50, COLOR2, COLOR1 } }         

IF W_DIRECT = 1 // Horizontal
   IF FWHVERS < 7.09
      //  Gradient-Array is not supported !!!!
      DegradeW ( hDC, oWnd )  
   ENDIF
   IF FWHVERS >= 7.09 .and. FWHVERS < 8.07 
      //  Gradient-Array is not supported !!!!	
      Gradient( hDC, { 0, 0, oWnd:nHeight, oWnd:nWidth }, COLOR1, COLOR2, .T. )
   ENDIF
   IF FWHVERS >= 8.07
      GradientFill( hDC,  0, 0, oWnd:nHeight, oWnd:nWidth, aGrad, .T. )
  ENDIF
ELSE
   IF FWHVERS < 7.09
      DegradeW ( hDC, oWnd )  
   ENDIF
   IF FWHVERS >= 7.09 .and. FWHVERS < 8.07	
      Gradient( hDC, { 0, 0, oWnd:nHeight, oWnd:nWidth }, COLOR1, COLOR2, .F. )
   ENDIF
   IF FWHVERS >= 8.07
      GradientFill( hDC,  0, 0, oWnd:nHeight, oWnd:nWidth, aGrad, .F. )
   ENDIF	
ENDIF

RETURN NIL

// ------ FOR FWH-Versions < 7.09 without GRADIENT - Functions  -------

STATIC FUNCTION DegradeW ( hDC, oWnd ) 

LOCAL nStep , nStepY 
LOCAL oBrush 
LOCAL i, r,g,b 
LOCAL r0,g0,b0 
LOCAL r1, g1, b1 
LOCAL rD, gD, bD 
LOCAL aRect := GETCLIENTRECT( oWnd:hWnd )

nStep  := ( aRect[ 3 ] - aRect[ 1 ] ) 
nStepY := ( aRect[ 3 ] - aRect[ 1 ] ) / nStep 
aRect[ 3 ] = aRect[ 1 ] + nStepY 

r0 := nRGBRed (W_COLOR1) 
g0 := nRGBGreen (W_COLOR1) 
b0 := nRGBBlue (W_COLOR1) 
r1 := nRGBRed (W_COLOR2) 
g1 := nRGBGreen (W_COLOR2) 
b1 := nRGBBlue (W_COLOR2) 
rD := r1-r0 
gD := g1-g0 
bD := b1-b0 

r := 256*rD/Max(nStep,1) 
g := 256*gD/Max(nStep,1) 
b := 256*bD/Max(nStep,1) 

r0*=256 
g0*=256 
b0*=256 

FOR i = 0 TO nStep-1 STEP nStepY 
	r0 += r 
	g0 += g 
	b0 += b 
	DEFINE BRUSH oBrush COLOR nRGB( r0/256, g0/256, b0/256 ) 
	FILLRECT( hDC, aRect, oBrush:hBrush ) 
	RELEASE BRUSH oBrush 

	aRect[ 1 ] += nStepY 
	aRect[ 3 ] += nStepY 
NEXT 

RETURN (nil)

// ----------------------------

STATIC FUNCTION ALPHA_BMP(hDC)
LOCAL oBmp1

DEFINE BITMAP oBmp1 FILENAME "A_LOGO.bmp"
ABPaint( hDC, 50, 50, oBmp1:hBitmap, 220 )

RETURN( NIL )


I hope, I can finish the new tools in a short time.
There are 40 different tests added : Windows, Dialogs, Folders and xBrowse with all possible combinations.
The needed source is generated from the preview.
I think it covers all settings and can easy included in Your own source-code.

Regards
Uwe :-)
Since 1995 ( the first release of FW 1.9 )

i work with FW.

If you have any questions about special functions, maybe i can help.
Posts: 1392
Joined: Mon May 14, 2007 09:49 AM
Re: gradient effect
Posted: Wed Jan 21, 2009 09:22 PM

Thank, Uwe !! :D

Continue the discussion