                                 TGradBtn

This component is yet another button.  It is derived from TCustomControl.

For Delphi 2/3/4.  It might work with Delphi 1, but I don't know.

Version 1.0 11/97 Initial release to the public.
Version 1.1 12/97 Added Presets.  Add KeyPress to allow Enter key to act as
                  Click. Also added btnFrameSize property, but I don't like it
                  much 'cause it overlays the gradient, and I'm too lazy to
                  figure out a solution.
Version 1.2 1/98  
                  Tony BenBrahim (startech@neosoft.com) made a VAST improvement by
                  adding drawing and handling for accelerator keys(&).  Thanks, Tony!
                  Fixed bug - made tsRaised the default TextStyle.
                  Added code to indicate if button has Focus.
                  Made Focus indicator optional with ShowFocus property
                  Added two events - OnMouseEnter and OnMouseLeave.
                  Cleaned up code a little.}

Version 1.3 07/98
                  Added Justification property for alignment of caption, per a
                  suggestion from Yves MailHot. Thanks!
Version 1.4 02/99
             Added code to Re-Draw Button back to its original state if
             mouse is down and moved away, to more closely resemble a typical
             button behavior.  Suggestion and code from Andy Daxer, Munich.
             Also modified the code for the Elliptic style of gradient to use
             integer math instaed of real numbers, greatly improving the speed
             of redraw.  The code was contributed by Dr. Allan Harkness, from
             Paisley, Scotland.  Thanks a great deal to you both, this component
             keeps getting better all the time, with insightful and generous
             help from people like you. Dr. Harkin has also shared other
             improvements as follows:  When button is disabled, it looks that
             way.  Drop-down menu support, you can associate a popup menu with
             the button (the little triangle thingy).  A new preset called
             Brassed Off.  NOTE - Drop down menu support only available with D4.
             I also changed the code so that the button is always re-drawn on
             a click.  There was a bug where if a user program error occured
             in the OnClick code, the button was left in a 'down' state.  I
             _think_ I fixed this...}


Installation:  Unzip the files
               Put the .PAS and .DCR in a folder together
               Start Delphi
               From Component menu, select install
               Find the folder you unzipped the files into
               By default, the component will go on the 'Samples' tab.  To
                 change this, you can edit the source and go to the bottom
                 in the Register procedure and change it to whatever tab 
                 you want.  Or, edit the palette later.    

After downloading freeware components and studying the techniques of others,
I experimented with this until it 'seems' to work OK.  I'll warn you now:

This component is provided as-is, no warranties express or implied as to the
fitness for use or anything else in the entire universe.  The author is not
liable for any damages, heartbreak, bad luck, earthquakes or any other thing
that anyone could ever think of to get mad about or try to weasel money out
of me for.

I am releasing this component fully aware that there are probably bugs in the code;
I am notorious for not putting any error-checking routines in my units because
of course like many other people I have the attitude that when it breaks, I'll
fix it then.  Otherwise, it must be good code.  Also, I am a self-taught programmer.
The code is not elegant; on the contrary, it is pretty ugly.

OK, enough about that.

**  This button looks best in 16-bit or higher colors.  16 or 256 color
    just don't cut it;  I'm sorry, but that's the way it is.  If anyone would
    like to clue me in on how to make it look good in 256 colors, I would
    appreciate it.

This was created on a 800X600 resolution 16bit color setting.  Take that for
what it's worth.


No new methods beyond what TCustomComponent has.

New properties:

BeginColor - this is the starting color value for the gradient being drawn.
EndColor   - this is the final color value for the gradient being drawn.
           - if you make these two values the same, you won't get any gradient,
             but you could have just a colored button that way.

BtnFrameSize - size of frame around the button.

BtnHiliteClr - the button has a frame around it.  This is the color of the 
               upper and left sides.  It can be changed if the default is 
               not visible or looks bad with the gradient colors chosen.

BtnShadowClr - the lower and right side frame color.

DropDownMenu - Add a PopupMenu to your form, and you can assign it to the GradBtn.

GradientStyle - Currently available styles are gsVertical [Top to Bottom],
                gsHorizontal [Left to Right], gsElliptic [Outside to Inside],
                gsRectangle [Outside to Inside], gsVertCenter [Top and Bottom to Center],
                and gsHorizCenter [Left and Right to Center].

ShowFocus - a Boolean to let you decide if the FocusRect is drawn when the button
            has the focus.  

SwapColors - a Boolean.  By default, when the button is pressed the BeginClr
             and EndClr values are reversed, then back to normal when released.
             By setting this value to false, this behavior is turned off.

TextShadeType - 3D text shading, either stLight or stHeavy.  stLight just gives 
                a highlight around the text.  stHeavy adds a shadow as well.

TextStyle - 3D effect, tsNone for no 3D, tsRaised for a Caption that 'sticks up',
            or tsInset for a Caption that is 'sunken' into the button.

TxtHiliteClr - this sets the color for the highlight of 3D text effects of tsRaised
               or tsInset. Depending on the gradient colors and font colors, this
               may need to be adjusted to look right.

TxtShadowClr - this sets the color for the shadow of 3D text effects, assuming that
               stHeavy is TextShadeType, for the same reasons as above for hilite.

Events:  OnMouseEnter and OnMouseLeave - These expose the mouse enter/leave messages,
         you can assign code to these events. 

That's it.  Mostly you just have to try it out and play with the different settings.

Harm  harmans@uswest.net


        