File: n_gradient.sru
Size: 5332
Date: Sun, 03 Feb 2019 05:14:22 +0100
$PBExportHeader$n_gradient.sru
forward
global type n_gradient from nonvisualobject
end type
type gradient_rect from structure within n_gradient
end type
type trivertex from structure within n_gradient
end type
end forward

type gradient_rect from structure
   long     upperleft
   long     lowerright
end type

type trivertex from structure
   long     x
   long     y
   unsignedinteger      red
   unsignedinteger      green
   unsignedinteger      blue
   unsignedinteger      alpha
end type

global type n_gradient from nonvisualobject autoinstantiate
end type

type prototypes
Function Boolean GradientFill( &
   Long hDC, &
   TRIVERTEX pVertex[], &
   Long nVertex, &
   GRADIENT_RECT pMesh, &
   Long nMesh, &
   Long ulMode &
   ) Library "msimg32.dll" alias for "GradientFill"

end prototypes

type variables
Constant Long GRADIENT_FILL_RECT_H = 0
Constant Long GRADIENT_FILL_RECT_V = 1

end variables

forward prototypes
public subroutine vertical (long hdc, integer x, integer y, integer width, integer height, long color1, long color2)
public subroutine horizontal (long hdc, integer x, integer y, integer width, integer height, long color1, long color2)
public subroutine splitrgb (long al_color, ref unsignedinteger aui_red, ref unsignedinteger aui_green, ref unsignedinteger aui_blue)
end prototypes

public subroutine vertical (long hdc, integer x, integer y, integer width, integer height, long color1, long color2);// -----------------------------------------------------------------------------
// SCRIPT:     n_gradient.Vertical
//
// PURPOSE:    This function performs a vertical gradient fill.
//
// ARGUMENTS:  hdc      - The device context
//             x        - The X coordinate of the rectangle
//             y        - The Y coordinate of the rectangle
//             width    - The Width of the rectangle
//             height   - The Height of the rectangle
//             color1   - The color of the Top edge
//             color2   - The color of the Bottom edge
//
// DATE        PROG/ID     DESCRIPTION OF CHANGE / REASON
// ----------  --------    -----------------------------------------------------
// 07/26/2013  RolandS     Initial coding
// -----------------------------------------------------------------------------

TRIVERTEX vertex[2]
GRADIENT_RECT gRect
UInt lui_Red, lui_Green, lui_Blue

SplitRGB(color1, lui_Red, lui_Green, lui_Blue)

vertex[1].X = x
vertex[1].Y = y
vertex[1].Red   = lui_Red
vertex[1].Green = lui_Green
vertex[1].Blue  = lui_Blue

SplitRGB(color2, lui_Red, lui_Green, lui_Blue)

vertex[2].X = width
vertex[2].Y = height
vertex[2].Red   = lui_Red
vertex[2].Green = lui_Green
vertex[2].Blue  = lui_Blue

gRect.UpperLeft  = 0
gRect.LowerRight = 1

GradientFill(hdc, vertex, 2, gRect, 1, GRADIENT_FILL_RECT_V)

end subroutine

public subroutine horizontal (long hdc, integer x, integer y, integer width, integer height, long color1, long color2);// -----------------------------------------------------------------------------
// SCRIPT:     n_gradient.Vertical
//
// PURPOSE:    This function performs a vertical gradient fill.
//
// ARGUMENTS:  hdc      - The device context
//             x        - The X coordinate of the rectangle
//             y        - The Y coordinate of the rectangle
//             width    - The Width of the rectangle
//             height   - The Height of the rectangle
//             color1   - The color of the Left edge
//             color2   - The color of the Right edge
//
// DATE        PROG/ID     DESCRIPTION OF CHANGE / REASON
// ----------  --------    -----------------------------------------------------
// 07/26/2013  RolandS     Initial coding
// -----------------------------------------------------------------------------

TRIVERTEX vertex[2]
GRADIENT_RECT gRect
UInt lui_Red, lui_Green, lui_Blue

SplitRGB(color1, lui_Red, lui_Green, lui_Blue)

vertex[1].X = x
vertex[1].Y = y
vertex[1].Red   = lui_Red
vertex[1].Green = lui_Green
vertex[1].Blue  = lui_Blue

SplitRGB(color2, lui_Red, lui_Green, lui_Blue)

vertex[2].X = width
vertex[2].Y = height
vertex[2].Red   = lui_Red
vertex[2].Green = lui_Green
vertex[2].Blue  = lui_Blue

gRect.UpperLeft  = 0
gRect.LowerRight = 1

GradientFill(hdc, vertex, 2, gRect, 1, GRADIENT_FILL_RECT_H)

end subroutine

public subroutine splitrgb (long al_color, ref unsignedinteger aui_red, ref unsignedinteger aui_green, ref unsignedinteger aui_blue);// -----------------------------------------------------------------------------
// SCRIPT:     n_gradient.SplitRGB
//
// PURPOSE:    This function splits color into Red/Green/Blue.
//
// ARGUMENTS:  al_color    - The color value to be split
//             aui_red     - The RED value (by ref)
//             aui_green   - The GREEN value (by ref)
//             aui_blue    - The BLUE value (by ref)
//
// DATE        PROG/ID     DESCRIPTION OF CHANGE / REASON
// ----------  --------    -----------------------------------------------------
// 07/26/2013  RolandS     Initial coding
// -----------------------------------------------------------------------------

aui_Red = Mod(al_Color, 256)
aui_Red *= 256

al_Color /= 256
aui_Green   = Mod(al_Color, 256)
aui_Green *= 256

aui_Blue = al_Color / 256
aui_Blue *= 256

end subroutine

on n_gradient.create
call super::create
TriggerEvent( this, "constructor" )
end on

on n_gradient.destroy
TriggerEvent( this, "destructor" )
call super::destroy
end on