BTNBMP 16.04 : Translucent buttons, Textured buttons, HGrad

BTNBMP 16.04 : Translucent buttons, Textured buttons, HGrad

Postby nageswaragunupudi » Mon May 16, 2016 10:45 am

Translucent Buttons

Using Alpha Color Fills

Image
Mouse Over is on top button

Code:
Code: Select all  Expand view
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

Image
Mouse Over is on Right Button
Code:
Code: Select all  Expand view
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


Image
Mouse Over is on bottom button
Code: Select all  Expand view
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
User avatar
nageswaragunupudi
 
Posts: 10632
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: BTNBMP 16.04 : Translucent buttons, Textured buttons, HGrad

Postby Silvio.Falconi » Fri Jun 02, 2017 9: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=3&t=34150&start=0
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 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
User avatar
Silvio.Falconi
 
Posts: 7056
Joined: Thu Oct 18, 2012 7:17 pm


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 129 guests