////////////////////////////////////////////////////////////////////////////////
// Hover/Flat/Hyperlink/Picture Button object
// Shekar C. Reddy [PowerObject!]
// http://www.schtoo.com/pbstation/object.php?ID=hover
// http://groups.yahoo.com/group/PowerObject
// Date: 12-Jul-05
////////////////////////////////////////////////////////////////////////////////

Hover/Flat/Hyperlink Button object

This was an object that I originally got from:

   http://www.schtoo.com/pbstation/object.php?ID=hover

and added more features to it two years ago for my work - MATRIX (dB) Explorer:

   . Flat UI
   . Caption     -> Text
   . Executable  -> Enabled
   . Default     -> Enter
   . Cancel      -> Escape
   . Help        -> F1

   . Picture
   . HoverPicture
   . PushPicture
   . Invert
   . Left Text-Alignment for Picture buttons

   . Border
   . BorderStyle -> LineStyle
   . BorderThickness
   . Improved states -> Normal/Hover...

   . DisabledTextColor
   . BackgroundColor
   . FillColor

   . Default Text
   . Default Pointers

   . Hyperlink URL
   . Link/Visited-Link colors
   . Overloaded Navigate()s...

   . Setter/Getter functions (INDIRECT keyword!)
   . Shared/common Variables for a 'consistent' look-n-feel across multiple instances!
   . Etc...

I thought of sharing this object with others instead of keeping it to myself and my software. I've uploaded the zip file along with a demo window that shows its usage and various coding hints, onto:

http://groups.yahoo.com/group/PowerObject/files/PowerBuilder/PB8-HoverFlatHyperlinkButton.zip
http://groups.yahoo.com/group/PowerObject/message/15877
[glue the URLs if broken/wrapped]

Usage is made simpler for the developer using setter/getter functions. So, instead of calling methods, you would simply assign values to its instance vars, like so:


// Sets Default, '&OK' text, thicker border and AppStarting! pointer
This.Default = TRUE


// Sets Cancel, '&Cancel' text, dotted border and Arrow! pointer
This.Cancel  = TRUE
This.of_SetBorderStyle( C_CANCEL, Continuous! )   // Set Line border


// Sets Text to '&Help - F1', thin border and Help! pointer
This.Help         = TRUE
This.Picture      = "help.bmp"
This.HoverPicture = "help-hover.bmp"   // Optional
This.PushPicture  = "help-push.bmp"    // Optional


This.Caption = "Dis&abled"

// Sets Enabled to false, No! pointer and beeps on click
This.Executable = FALSE
This.of_SetNormalState( C_STATE_HOVER )   // "Slightly" raised border


// URL option works by simply clicking on the button [no need to call of_Navigate()]
This.Caption = "PowerObject!"

// Sets the URL, Hand! pointer and launches browser on click
This.URL = "http://groups.yahoo.com/group/PowerObject"
This.of_SetBorder( FALSE )      // Borderless/Flat UI


// Set and Navigate to a different URL
This.of_Navigate( "http://groups.yahoo.com/group/CSharpNET" )


Note some of the action vars (Property-methods) are named differently due to conflict with the existing properties of the StaticText control such as Executable, Caption... Here are all the setter/getter functions that are implemented to work as "Properties":

   . Caption      -> of_SetText()
   . Executable   -> of_SetEnabled()
   . Default      -> of_SetDefault()
   . Cancel       -> of_SetCancel()
   . Help         -> of_SetHelp()
   . Picture      -> of_SetPictureName()
   . HoverPicture -> of_SetHoverPictureName()
   . PushPicture  -> of_SetPushPictureName()
   . Invert       -> of_SetInvert()
   . URL          -> of_SetURL()


Example:
--------
ls_Text   = This.Caption   // Getter [of_GetXxx()/of_IsXxx()]
This.Help = TRUE           // Setter


The Cancel action is implemented by an embeded insivible CommandButton control inside the object :~)

In addition to the above that have corresponding set/get methods, here are the traditional methods that you may like to invoke to tame the interface:

   . of_Navigate( string )
   . of_SetBorder( boolean )
   . of_SetBorderStyle( mode, lineStyle )
   . of_SetBorderThickness( mode, integer )
   . of_SetImageOffset( integer )
   . of_SetNormalState( state )
   . Etc...


Here are some constants that you may need while calling some of its traditional methods:

   // Public
   . C_MODE_DEFAULT = 0
   . C_MODE_CANCEL  = -1
   . C_MODE_NORMAL  = 1

   // Private - Access denied
   . C_STATE_NORMAL = 1
   . C_STATE_HOVER  = 2
   . C_COLOR_LINK   = RGB(   0, 0, 255 )
   . C_COLOR_VLINK  = RGB( 192, 0,   0 )


The initialization code is to be placed in the "Constructor!" event (not the DragDrop! event that loads when you open up the script painter) while the execution code goes into ue_Clicked!. Invert is defaulted to FALSE and kicks off (if set to TRUE) if Hover/Push-PictureNames are not set. Also, Invert changes the background color of the button to dark-gray when 'pushed'. You can use 'any-size' images for the pictures but you will have to resize the button as well as the picture control manually and using methods. However, 16x16 images would do just well for buttons. For more info, take a look at the included demo window and the scripts therein.

They say we can tell a PowerBuilder application from a mile off because we cannot create modern-looking applications using it. This button can spice up your interface and your users can get a kick out of it. In any case, this object is meant for versions 9 and below.

Hope you enjoy the object...

---
PowerObject!
Owner/Moderator

NOTICE: This tool is offered for FREE with absolutely no support or responsibility. Use it at your own risk! And, please give due credit to the people who created/contributed to this code.
