FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour BTNBMP 16.04 : Translucent buttons, Textured buttons, HGrad
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
BTNBMP 16.04 : Translucent buttons, Textured buttons, HGrad
Posted: Mon May 16, 2016 10:45 AM
Translucent Buttons

Using Alpha Color Fills


Mouse Over is on top button

Code:
Code (fw): Select all Collapse
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 (fw): Select all Collapse
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 (fw): Select all Collapse
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.
Regards



G. N. Rao.

Hyderabad, India
Posts: 7318
Joined: Thu Oct 18, 2012 07:17 PM
Re: BTNBMP 16.04 : Translucent buttons, Textured buttons, HGrad
Posted: Fri Jun 02, 2017 09:47 AM

Mr Rao can you make a test for use LMover data because here make me error
pls see the last message at

viewtopic.php?f=3t=34150start=0

&&

Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)

I use : FiveWin for Harbour March-April 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com

Continue the discussion