Using Alpha Color Fills
Mouse Over is on top button
Code:
- Code: Select all Expand view RUN
- function BtnTest()
local oDlg, oBtn, oBrush, oFont, n
DEFINE FONT oFont NAME "Verdana" SIZE 0,-20
DEFINE BRUSH oBrush FILE "..\bitmaps\sea.bmp" RESIZE //"penguins.jpg" RESIZE
DEFINE DIALOG oDlg SIZE 600,420 PIXEL TRUEPIXEL BRUSH oBrush ;
TITLE FWVERSION + " : TRANSLUCENT BUTTONS"
@ 040,060 BTNBMP oBtn PROMPT " Translucent" + CRLF + "Buttons ";
FILE "..\bitmaps\alphabmp\ichat.bmp" ;
SIZE 300,100 PIXEL OF oDlg LEFT 2007 ;
FONT oFont COLOR CLR_WHITE,CLR_BLACK
oBtn:bClrGrad := { |lInvert| If( lInvert, 0x60FFA54A, nARGB( 64, 0, 192, 0 ) ) }
@ 220,060 BTNBMP oBtn PROMPT "Alpha Color Fills" ;
FILE "..\bitmaps\pngs\image8.png" ;
SIZE 300,090 PIXEL OF oDlg TOP 2007 ;
FONT oFont COLOR CLR_YELLOW,CLR_BLACK
oBtn:bClrGrad := { |lInvert| If( lInvert, 0x80FFA54A, nARGB( 54, 0, 192, 0 ) ) }
ACTIVATE DIALOG oDlg CENTERED
RELEASE BRUSH oBrush
RELEASE FONT oFont
return nil
Texured Buttons
Mouse Over is on Right Button
Code:
- Code: Select all Expand view RUN
- function BtnTest2()
local oDlg, oBtn, aBru[ 2 ]
DEFINE BRUSH aBru[ 1 ] FILE "..\bitmaps\backgrnd\wood.bmp"
DEFINE BRUSH aBru[ 2 ] FILE "..\bitmaps\backgrnd\rainbow.bmp" //stucco.bmp"
DEFINE DIALOG oDlg SIZE 480,240 PIXEL
@ 10, 10 BTNBMP oBtn FILE "..\bitmaps\alphabmp\calendar.bmp" CENTER SIZE 96,96 PIXEL OF oDlg 2007
oBtn:bClrGrad := { |lInvert| If( lInvert, aBru[ 2 ]:hBrush, aBru[ 1 ]:hBrush ) }
oBtn:lEllipse := .t.
@ 10,120 BTNBMP oBtn FILE "..\bitmaps\alphabmp\calendar.bmp" CENTER SIZE 96,96 PIXEL OF oDlg 2007
oBtn:bClrGrad := { |lInvert| If( lInvert, aBru[ 2 ]:hBrush, aBru[ 1 ]:hBrush ) }
oBtn:lEllipse := .t.
ACTIVATE DIALOG oDlg CENTERED
RELEASE BRUSH aBru[ 1 ], aBru[ 2 ]
return nil
Horizontal Gradients
Mouse Over is on bottom button
- Code: Select all Expand view RUN
- function BtnTest3()
local oDlg, oBtn, oFont
DEFINE FONT oFont NAME "TAHOMA" SIZE 0,-24
DEFINE DIALOG oDlg SIZE 260,250 PIXEL FONT oFont
@ 10, 10 BTNBMP oBtn FILE "..\bitmaps\32x32\cascade.bmp" ;
PROMPT "Horizontal Gradients" LEFT SIZE 110,48 PIXEL OF oDlg 2007
oBtn:bClrGrad := { |lInvert| If( lInvert, { { .5, METRO_MAGENTA, METRO_YELLOW }, ;
{ .5, METRO_YELLOW, METRO_MAGENTA }, ;
.f. }, ;
{ { .5, CLR_GREEN, CLR_HGREEN }, ;
{ .5, CLR_HGREEN, CLR_GREEN }, ;
.f. } ) }
@ 70, 10 BTNBMP oBtn FILE "..\bitmaps\32x32\cascade.bmp" ;
PROMPT "Horizontal Gradients" RIGHT SIZE 110,48 PIXEL OF oDlg 2007
oBtn:bClrGrad := { |lInvert| If( lInvert, { { .5, METRO_MAGENTA, METRO_YELLOW }, ;
{ .5, METRO_YELLOW, METRO_MAGENTA }, ;
.f. }, ;
{ { .5, CLR_GREEN, CLR_HGREEN }, ;
{ .5, CLR_HGREEN, CLR_GREEN }, ;
.f. } ) }
ACTIVATE DIALOG oDlg CENTERED
RELEASE FONT oFont
return nil
In FWH 16.04, greater flexibility is provided for specifying bClrGrad of TBtnBmp.
As in earlier versions, we can assign out own bClrGrad overriding the default bClrGrad provided by default for styles 2007 to 2015. Once we provide our own bClrGrad, it does not matter if the style is 2007 ... 2015.
But in the earlier versions, the codeblock should return a valid Gradient Array. bClrGrad is evaluated with 2 params lMouseOver, oBtnObject.
Now the bClrGrad can return a Gradient Array or an RGB color or an ARGB color ( Alpha Color ) or a Brush Handle or a GDI+ Brush Object. This facility provides us unlimited possibilities for designing the buttons.
Small note on ARGB:
RGB is a 24 bit number. When expressed in Hex : "BBGGRR"
ARGB is a 32 bit number. Expressed in Hex: "AARRGGBB"
For quick usage FWH provides nARGB() function
Usage:
nARGB( nAlpha, nRed, nGreen, nBlue )
or
nARGB( nAlpha, nRGBColor )
Extensions to Gradient Array:
A valid Gradient array is a multi-dimensional Array, each element being an array defining a single gradient.
Now, it is possible to optionally specify last element as a Logical Value. .T. indicates Vertical Gradient and .F. indicates Horizontal gradient.