Re: Dialog Color / Gradient
Posted: Wed Jan 11, 2017 8:22 pm
Rick, Thanks to you for everything
www.FiveTechSoft.com
http://forums.fivetechsoft.com/
Code: Select all
//----------------------------------------------------------------------------//
// Gradient for Dialogs: Thanks to Rick Lipkin
//----------------------------------------------------------------------------//
Function GradDlgs( cTheme )
local x
local aGrad := {}
local aTmp := {}
local aThemes := {;
{ "SolidWhite", { { 0.5, nRGB( 255, 255, 255 ), nRGB( 255, 255, 255 ) } } }, ;
{ "BlueGreen", { { 1.00, 14671839, 7419904 }, { 1.00, 7419904, 14671839 } } }, ;
{ "SolidGreenBlue", { { 0.01, 9994298, 9994298 },{ 0.01, 9994298, 9994298 } } },;
{ "SolidDarkBlue", { { 0.50, 4720905, 4720905 }, { 0.50, 4720905, 4720905 } } }, ;
{ "SolidBlue", { { 0.01, 16711680, 16711680 },{ 0.01, 16711680, 16711680 } } }, ;
{ "DarkBlue", { { 0.0, 8388608, 13619151 },{ 0.0, 13619151, 8388608 } } }, ;
{ "LightGreen", { { .50, nRGB(210,235,216), nRGB( 255, 255, 255 ) } } }, ;
{ "LightBlue", { { .50, nRGB( 201, 217, 237 ), nRGB( 231, 242, 255 ) } } }, ;
{ "LightGrey", { { .50, nRGB( 216, 216, 216 ), nRGB( 255, 255, 255 ) } } }, ;
{ "Standard", { { .50, nRGB( 236, 233, 216 ), nRGB( 255, 255, 255 ) } } }, ;
{ "DarkGrey", { { 0.87, 16777215, 11513775 },{ 0.87,11513775, 16777215 } } }, ;
{ "SolidGrey", { { .50, nRGB( 233, 233, 233 ), nRGB( 233, 233, 233 ) } } }, ;
{ "SolidChoral", { { 0.01,8388736,8388736 },{ 0.01,8388736,8388736 } } }, ;
{ "LightYellow", { { 0.01,8440801,16777215 },{ 0.75,16777215,8440801 } } }, ;
{ "GreenBlue", { { .50, nRGB( 192, 192, 192 ), nRGB( 45, 121, 147 ) } } } ;
}
DEFAULT cTheme := ""
if Valtype( cTheme ) == "C"
AEVal( aThemes, { | a | AAdd( aTmp, Upper( a[ 1 ] ) ) } )
x := Ascan( aTmp, Upper( cTheme ) )
if !Empty( x )
aGrad := aThemes[ x ][ 2 ]
endif
else
if Valtype( cTheme ) == "A"
aGrad := cTheme
endif
endif
if !Empty( aGrad )
SetDlgGradient( aGrad )
endif
Return aThemes
//----------------------------------------------------------------------------//
Gradient { { 0.0, 8388608, 13619151 },{ 0.0, 13619151, 8388608 } }
is same as { { 1, 13619151, 8388608 } }
The first element of { 0.0, 8388608, 13619151 } is ignored when painting.
Gradient spec is like this
{ { n1, clr11, clr12 }, ;
{ n2, clr21, clr22 }, ;
........
{ nN, clrN1, clrN2 } }
Where n1 + n2 + ... nN = 1
If this total is > 1, gradients above 1 are ignored
if this total is < 1 last gradient is streched.
First gradient is painted in dlg:nheight * n1 pixels
Second gradient is painted in dlg:nheight * n2 pixels
and so on.
To get a better understanding please see the gradient painting logic
If the intention is to paint both gradients the specification should be something like this:
{ { 0.5, 8388608, 13619151 },{ 0.5, 13619151, 8388608 } }
( 0.5 and 0.5 can be 0.3 and 0.7 or 0.6 and 0.4, etc where both add up to 1.0 )