SetDlgGradient
-
- Posts: 128
- Joined: Tue Mar 20, 2007 3:13 pm
- Has thanked: 1 time
SetDlgGradient
Hey guys,
I would like to know if the gradient generated by the setdlggrandient function can be horizontal?
regards
I would like to know if the gradient generated by the setdlggrandient function can be horizontal?
regards
- nageswaragunupudi
- Posts: 10721
- Joined: Sun Nov 19, 2006 5:22 am
- Location: India
- Been thanked: 8 times
- Contact:
Re: SetDlgGradient
Try like this:
If the last element of the gradient array is .F., instead of an array, the gradient is horizontal.
Code: Select all | Expand
SetDlgGradient( { { 0.6, CLR_BLUE, CLR_WHITE }, { 0.4, CLR_WHITE, CLR_BLUE }, .F. } )
Regards
G. N. Rao.
Hyderabad, India
G. N. Rao.
Hyderabad, India
- karinha
- Posts: 7935
- Joined: Tue Dec 20, 2005 7:36 pm
- Location: São Paulo - Brasil
- Been thanked: 3 times
- Contact:
Re: SetDlgGradient
Code: Select all | Expand
// C:\FWH..\SAMPLES\GRADHOR2.PRG
#include "fivewin.ch"
FUNCTION Main()
LOCAL oDlg, aGrad, oBrush, oBrush1, oBrush2
aGrad := { { 0.4, CLR_GREEN, CLR_HGREEN }, ;
{ 0.6, CLR_HGREEN, CLR_GREEN } }
DEFINE BRUSH oBrush GRADIENT aGrad STYLE HORIZONTAL // or VERTICAL
DEFINE BRUSH oBrush1 COLOR nRGB( 250, 213, 174 ) STYLE HORIZONTAL
DEFINE BRUSH oBrush2 COLOR nRGB( 192, 192, 192 ) STYLE HORIZONTAL
DEFINE DIALOG oDlg TITLE "- Gradient Horizontal -" SIZE 350, 350 ;
PIXEL TRUEPIXEL RESIZABLE BRUSH oBrush // OR GRADIENT aGrad
oDlg:lhelpIcon := .F.
ACTIVATE DIALOG oDlg CENTERED
RELEASE BRUSH oBrush
RETURN NIL
// FIN / END
João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
-
- Posts: 128
- Joined: Tue Mar 20, 2007 3:13 pm
- Has thanked: 1 time
- Rick Lipkin
- Posts: 2668
- Joined: Fri Oct 07, 2005 1:50 pm
- Location: Columbia, South Carolina USA
Re: SetDlgGradient
I have put several of my gradients into functions .. very easy to use ...
Rick Lipkin
Code: Select all | Expand
//-------------------
Func GreyButtonGrad()
// 2010 grey button skin
Local bGrad
bGrad := { | lInvert | If( ! lInvert, ;
{ { 1, nRGB( 255, 255, 255 ), nRGB( 207, 207, 207 ) } }, ;
{ { 1/3, nRGB( 255, 253, 222 ), nRGB( 255, 231, 151 ) }, ;
{ 2/3, nRGB( 255, 215, 84 ), nRGB( 255, 233, 162 ) } } ) }
Return( bGrad )
//---------------------------
Func BlueGreenGrad()
Local xGrad4 := {{ 1.00,14671839, 7419904 }, { 1.00,7419904, 14671839 }} // med blue
SetDlgGradient( xGrad4 )
Return(nil)
//---------------------
Func SolidGreenBlue()
SetDlgGradient({ { 0.01,9994298,9994298 },{ 0.01,9994298,9994298 } })
Return(nil)
//-------------
Func SolidDarkBlue()
SetDlgGradient( { { 0.50,4720905,4720905 },{ 0.50,4720905,4720905 } })
Return(nil)
//-------------------
Func SolidBlue()
SetDlgGradient( { { 0.01,16711680,16711680 },{ 0.01,16711680,16711680 } })
Return(nil)
//------------------
Func DarkBlueGrad()
SetDlgGradient({ { 0.0,8388608,13619151 },{ 0.0,13619151,8388608 } })
Return(nil)
//--------------
Func LightGreenGrad()
SetDlgGradient( { { .50, nRGB(210,235,216), nRGB( 255, 255, 255 ) } } )
Return(nil)
//------------------
Func LightBlueGrad()
SetDlgGradient( { { .50, nRGB( 201, 217, 237 ), nRGB( 231, 242, 255 ) } } )
Return(nil)
//------------------
Func LightGreyGrad()
SetDlgGradient( { { .50, nRGB( 216, 216, 216 ), nRGB( 255, 255, 255 ) } } )
Return(nil)
//-----------------
Func StandardGrad()
SetDlgGradient( { { .50, nRGB( 236, 233, 216 ), nRGB( 255, 255, 255 ) } } )
Return(nil)
//--------------------
Func DarkGreyGrad()
SetDlgGradient({{ 0.90, 14671839, 4144959 },{ 0.1, 4144959, 14671839 }}) // .80
Return(nil)
//------------------------------------
Func SolidWhite()
SetDlgGradient( { { 0.01,16777215,16777215 },{ 0.01,16777215,16777215 } })
Return(nil)
//--------------------
Func SolidGrey()
SetDlgGradient( { { .50, nRGB( 233, 233, 233 ), nRGB( 233, 233, 233 ) } } )
Return(nil)
//--------------------
Func SolidChoral()
SetDlgGradient(aGrad := { { 0.01,8388736,8388736 },{ 0.01,8388736,8388736 } })
Return(nil)
//-----------------
Func LightYellow()
SetDlgGradient( { { 0.01,8440801,16777215 },{ 0.75,16777215,8440801 } })
Return(nil)
//-------------------
Func GreenBlueGrad()
SetDlgGradient( { { .50, nRGB( 192, 192, 192 ), nRGB( 45, 121, 147 ) } } )
Return(nil)
- nageswaragunupudi
- Posts: 10721
- Joined: Sun Nov 19, 2006 5:22 am
- Location: India
- Been thanked: 8 times
- Contact:
Re: SetDlgGradient
Please ensure that the sum of the first column of all sub-arrays is 1.0.I have put several of my gradients into functions .. very easy to use ...
Otherwise, your examples mislead other users who are new.
Regards
G. N. Rao.
Hyderabad, India
G. N. Rao.
Hyderabad, India
- Rick Lipkin
- Posts: 2668
- Joined: Fri Oct 07, 2005 1:50 pm
- Location: Columbia, South Carolina USA
Re: SetDlgGradient
Rao
I am a bit perplexed ? ... These functions work just fine for me ... what have I done wrong or need to change ?
Thanks
Rick Lipkin
ps, I have noticed with newer versions of FWH that the above gradients paint slower than in previous versions of FWH
I am a bit perplexed ? ... These functions work just fine for me ... what have I done wrong or need to change ?
Thanks
Rick Lipkin
ps, I have noticed with newer versions of FWH that the above gradients paint slower than in previous versions of FWH
- karinha
- Posts: 7935
- Joined: Tue Dec 20, 2005 7:36 pm
- Location: São Paulo - Brasil
- Been thanked: 3 times
- Contact:
Re: SetDlgGradient
Good morning Rick, can you make a complete example showing how your functions work?
Buenos días Rick, ¿puedes hacer un ejemplo completo que muestre cómo funcionan tus funciones?
Tipo así:
Like that:
Regards, saludos.
Buenos días Rick, ¿puedes hacer un ejemplo completo que muestre cómo funcionan tus funciones?
Tipo así:
Like that:
Code: Select all | Expand
// C:\FWH..\SAMPLES\GRADHOR3.PRG
#include "FiveWin.ch"
#define CLR_MSPURPLE RGB( 0, 120, 215 )
#define CLR_MSRED RGB( 232, 17, 35 )
#define CLR_MSGRAY RGB( 229, 229, 229 )
FUNCTION FitcadExe() // (tip_fun)
LOCAL itcadexe, oFont
LOCAL lsalva := .F.
LOCAL ncodexe, cdesexe, ocodexe, odesexe
LOCAL oBtn2_itcadexe, oBtn8_itcadexe
LOCAL oCursorBtn := TCursor():New(, 'HAND' )
nCodexe := Space( 04 )
cDesexe := Space( 50 )
DEFINE FONT oFont NAME "Ms Sans Serif" SIZE 00, -16 // BOLD
DEFINE DIALOG itcadexe FROM 0, 0 TO 216, 513 TITLE 'Gradient Example' ;
PIXEL TRANSPARENT FONT oFont STYLE nOR( DS_MODALFRAME, WS_POPUP, ;
WS_CAPTION, WS_SYSMENU, WS_MINIMIZEBOX )
itcadexe:lhelpIcon := .F.
@ 20, 3 SAY "Codigo do exemplo:" SIZE 86, 10 PIXEL OF itcadexe UPDATE ;
COLOR CLR_WHITE, CLR_BLACK
@ 33, 3 SAY "Descricao do exemplo:" SIZE 86, 10 PIXEL OF itcadexe UPDATE ;
COLOR CLR_WHITE, CLR_BLACK
IF Set( _SET_INSERT, ! Set( _SET_INSERT ) )
Set( _SET_INSERT, ! Set( _SET_INSERT ) )
ENDIF
@ 19, 89 GET ocodexe VAR ncodexe SIZE 24, 12 PIXEL OF itcadexe ;
READONLY UPDATE COLOR CLR_MSPURPLE, CLR_BLACK
ocodexe:lBtnTransparent := .T. // transparent button get oGet3
ocodexe:lAdjustBtn := .T. // Button Get Adjust Witdh oGet3
ocodexe:lDisColors := .F. // Deactive disable color
ocodexe:nClrTextDis := CLR_WHITE // Color text disable status
ocodexe:nClrPaneDis := CLR_BLUE // Color Pane disable status
@ 32, 89 GET odesexe VAR cdesexe SIZE 162, 12 PIXEL OF itcadexe ;
PICTURE "@!" UPDATE COLOR CLR_MSPURPLE, CLR_BLACK
@ 70, 76 BTNBMP oBtn2_itcadexe PROMPT "Confirma" FLAT 2007 CENTER UPDATE ;
OF itcadexe PIXEL SIZE 42, 35 action ( lsalva := .T., itcadexe:end() )
oBtn2_itcadexe:lCancel := .T.
oBtn2_itcadexe:nClrBorder := iif( oBtn2_itcadexe:lMOver, RGB( 219, 230, 244 ), RGB( 219, 230, 244 ) )
oBtn2_itcadexe:oCursor := oCursorBtn
@ 70, 138 BTNBMP oBtn8_itcadexe PROMPT "Voltar" FLAT 2007 CENTER UPDATE ;
OF itcadexe PIXEL SIZE 42, 35 action ( lsalva := .F., itcadexe:end() )
oBtn8_itcadexe:lCancel := .T.
// Rick
oBtn8_itcadexe:bClrGrad := { | lInvert | If( ! lInvert, ;
{ { 1, nRGB( 255, 255, 255 ), nRGB( 207, 207, 207 ) } }, ;
{ { 1/3, nRGB( 255, 253, 222 ), nRGB( 255, 231, 151 ) }, ;
{ 2/3, nRGB( 255, 215, 84 ), nRGB( 255, 233, 162 ) } } ) }
oBtn8_itcadexe:nClrBorder := iif( oBtn8_itcadexe:lMOver, RGB( 219, 230, 244 ), RGB( 219, 230, 244 ) )
oBtn8_itcadexe:oCursor := oCursorBtn
tGradtela( itcadexe, ( 46 ) ) // GRADIENT
ACTIVATE DIALOG itcadexe CENTERED
IF Set( _SET_INSERT, ! Set( _SET_INSERT ) )
Set( _SET_INSERT, ! Set( _SET_INSERT ) )
ENDIF
oFont:End()
RETURN NIL
FUNCTION tGradtela( par_obj, par_percent )
LOCAL naltura_BTN := par_percent * 2
LOCAL npercent_par_obj := Round( ( naltura_BTN / par_obj:nHeight ), 2 )
par_obj:aGradcolors := { { ( 1 - npercent_par_obj ), nRGB( 110, 193, 248 ), nRGB( 0, 64, 254 ) }, ;
{ npercent_par_obj, nRGB( 255, 255, 255 ), nRGB( 255, 255, 255 ) } }
RETURN .T.
Function GreyButtonGrad()
// 2010 grey button skin
Local bGrad
bGrad := { | lInvert | If( ! lInvert, ;
{ { 1, nRGB( 255, 255, 255 ), nRGB( 207, 207, 207 ) } }, ;
{ { 1/3, nRGB( 255, 253, 222 ), nRGB( 255, 231, 151 ) }, ;
{ 2/3, nRGB( 255, 215, 84 ), nRGB( 255, 233, 162 ) } } ) }
Return( bGrad )
// FIN / END - kapiabafwh@gmail.com
João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
- Rick Lipkin
- Posts: 2668
- Joined: Fri Oct 07, 2005 1:50 pm
- Location: Columbia, South Carolina USA
Re: SetDlgGradient
Here is the button gradient
Above is how I code the gradients and use them as function wrappers to make the coding easier ..
Rick Lipkin
Code: Select all | Expand
REDEFINE BTNBMP oBtn2 ID 251 of oGrps ; // cancel
RESOURCE "CANCEL" ;
PROMPT "&Cancel" LEFT 2007;
ACTION( loK := .F., oGrps:END() ) ;
GRADIENT GreyButtonGrad()
oButt2:lCancel := .t.
//-----------------
Func GreyButtonGrad()
// 2010 grey button skin
Local bGrad
bGrad := { | lInvert | If( ! lInvert, ;
{ { 1, nRGB( 255, 255, 255 ), nRGB( 207, 207, 207 ) } }, ;
{ { 1/3, nRGB( 255, 253, 222 ), nRGB( 255, 231, 151 ) }, ;
{ 2/3, nRGB( 255, 215, 84 ), nRGB( 255, 233, 162 ) } } ) }
Return( bGrad )
Code: Select all | Expand
DEFINE FONT oFont NAME "Ms Sans Serif" SIZE 00, -16 // BOLD
//--- rick added gradient here
LightGreyGrad()
SetGetColorFocus( rgb(209,224,252) ) // color for gets
DEFINE DIALOG itcadexe FROM 0, 0 TO 216, 513 TITLE 'Gradient Example' ;
PIXEL TRANSPARENT FONT oFont STYLE nOR( DS_MODALFRAME, WS_POPUP, ;
WS_CAPTION, WS_SYSMENU, WS_MINIMIZEBOX )
Rick Lipkin
- karinha
- Posts: 7935
- Joined: Tue Dec 20, 2005 7:36 pm
- Location: São Paulo - Brasil
- Been thanked: 3 times
- Contact:
Re: SetDlgGradient
Code: Select all | Expand
// C:\FWH..\SAMPLES\GRADHOR3.PRG
#include "FiveWin.ch"
#define CLR_MSPURPLE RGB( 0, 120, 215 )
#define CLR_MSRED RGB( 232, 17, 35 )
#define CLR_MSGRAY RGB( 229, 229, 229 )
FUNCTION FitcadExe() // (tip_fun)
LOCAL itcadexe, oFont
LOCAL lsalva := .F.
LOCAL ncodexe, cdesexe, ocodexe, odesexe
LOCAL oBtn2_itcadexe, oBtn8_itcadexe
LOCAL oCursorBtn := TCursor():New(, 'HAND' )
nCodexe := Space( 04 )
cDesexe := Space( 50 )
DEFINE FONT oFont NAME "Ms Sans Serif" SIZE 00, -16 // BOLD
//--- rick added gradient here
// LightGreyGrad() // NO ME GUSTA
// BlueGreenGrad() // BIEN / GOOD
SolidGreenBlue() // BIEN / GOOD
SetGetColorFocus( RGB( 209, 224, 252 ) ) // color for gets
DEFINE DIALOG itcadexe FROM 0, 0 TO 216, 513 TITLE 'Gradient Example' ;
PIXEL TRANSPARENT FONT oFont STYLE nOR( DS_MODALFRAME, WS_POPUP, ;
WS_CAPTION, WS_SYSMENU, WS_MINIMIZEBOX )
itcadexe:lhelpIcon := .F.
@ 20, 3 SAY "Codigo do exemplo:" SIZE 86, 10 PIXEL OF itcadexe UPDATE ;
COLOR CLR_WHITE, CLR_BLACK
@ 33, 3 SAY "Descricao do exemplo:" SIZE 86, 10 PIXEL OF itcadexe UPDATE ;
COLOR CLR_WHITE, CLR_BLACK
IF Set( _SET_INSERT, ! Set( _SET_INSERT ) )
Set( _SET_INSERT, ! Set( _SET_INSERT ) )
ENDIF
@ 19, 89 GET ocodexe VAR ncodexe SIZE 24, 12 PIXEL OF itcadexe ;
READONLY UPDATE COLOR CLR_MSPURPLE, CLR_BLACK
ocodexe:lBtnTransparent := .T. // transparent button get oGet3
ocodexe:lAdjustBtn := .T. // Button Get Adjust Witdh oGet3
ocodexe:lDisColors := .F. // Deactive disable color
ocodexe:nClrTextDis := CLR_WHITE // Color text disable status
ocodexe:nClrPaneDis := CLR_BLUE // Color Pane disable status
@ 32, 89 GET odesexe VAR cdesexe SIZE 162, 12 PIXEL OF itcadexe ;
PICTURE "@!" UPDATE COLOR CLR_MSPURPLE, CLR_BLACK
@ 70, 76 BTNBMP oBtn2_itcadexe PROMPT "Confirma" FLAT 2007 CENTER UPDATE ;
OF itcadexe PIXEL SIZE 42, 35 action ( lsalva := .T., itcadexe:end() ) ;
GRADIENT LightGreyGrad() // No funciona.
oBtn2_itcadexe:lCancel := .T.
oBtn2_itcadexe:nClrBorder := iif( oBtn2_itcadexe:lMOver, RGB( 219, 230, 244 ), RGB( 219, 230, 244 ) )
oBtn2_itcadexe:oCursor := oCursorBtn
@ 70, 138 BTNBMP oBtn8_itcadexe PROMPT "Voltar" FLAT 2007 CENTER UPDATE ;
OF itcadexe PIXEL SIZE 42, 35 action ( lsalva := .F., itcadexe:end() ) ;
GRADIENT DarkBlueGrad() // no funciona // LightGreyGrad() // No funciona
oBtn8_itcadexe:lCancel := .T.
// Rick Enabled
/*
oBtn8_itcadexe:bClrGrad := { | lInvert | If( ! lInvert, ;
{ { 1, nRGB( 255, 255, 255 ), nRGB( 207, 207, 207 ) } }, ;
{ { 1/3, nRGB( 255, 253, 222 ), nRGB( 255, 231, 151 ) }, ;
{ 2/3, nRGB( 255, 215, 84 ), nRGB( 255, 233, 162 ) } } ) }
*/
oBtn8_itcadexe:nClrBorder := iif( oBtn8_itcadexe:lMOver, RGB( 219, 230, 244 ), RGB( 219, 230, 244 ) )
oBtn8_itcadexe:oCursor := oCursorBtn
// Enable for Rick
// tGradtela( itcadexe, ( 46 ) ) // GRADIENT
ACTIVATE DIALOG itcadexe CENTERED
IF Set( _SET_INSERT, ! Set( _SET_INSERT ) )
Set( _SET_INSERT, ! Set( _SET_INSERT ) )
ENDIF
oFont:End()
RETURN NIL
FUNCTION tGradtela( par_obj, par_percent )
LOCAL naltura_BTN := par_percent * 2
LOCAL npercent_par_obj := Round( ( naltura_BTN / par_obj:nHeight ), 2 )
par_obj:aGradcolors := { { ( 1 - npercent_par_obj ), nRGB( 110, 193, 248 ), nRGB( 0, 64, 254 ) }, ;
{ npercent_par_obj, nRGB( 255, 255, 255 ), nRGB( 255, 255, 255 ) } }
RETURN .T.
FUNCTION GreyButtonGrad()
// 2010 grey button skin
LOCAL bGrad
bGrad := { | lInvert | If( ! lInvert, ;
{ { 1, nRGB( 255, 255, 255 ), nRGB( 207, 207, 207 ) } }, ;
{ { 1/3, nRGB( 255, 253, 222 ), nRGB( 255, 231, 151 ) }, ;
{ 2/3, nRGB( 255, 215, 84 ), nRGB( 255, 233, 162 ) } } ) }
RETURN( bGrad )
FUNCTION BlueGreenGrad()
LOCAL xGrad4 := {{ 1.00, 14671839, 7419904 }, { 1.00,7419904, 14671839 }} // med blue
SetDlgGradient( xGrad4 )
RETURN NIL
FUNCTION SolidGreenBlue()
SetDlgGradient({ { 0.01, 9994298, 9994298 },{ 0.01, 9994298, 9994298 } })
RETURN NIL
FUNCTION SolidDarkBlue()
SetDlgGradient( { { 0.50,4720905,4720905 },{ 0.50,4720905,4720905 } })
RETURN NIL
FUNCTION SolidBlue()
SetDlgGradient( { { 0.01,16711680,16711680 },{ 0.01,16711680,16711680 } })
RETURN NIL
FUNCTION DarkBlueGrad()
SetDlgGradient({ { 0.0, 8388608, 13619151 },{ 0.0, 13619151, 8388608 } })
RETURN NIL
FUNCTION LightGreenGrad()
SetDlgGradient( { { .50, nRGB(210,235,216), nRGB( 255, 255, 255 ) } } )
RETURN NIL
FUNCTION LightBlueGrad()
SetDlgGradient( { { .50, nRGB( 201, 217, 237 ), nRGB( 231, 242, 255 ) } } )
RETURN NIL
FUNCTION LightGreyGrad()
SetDlgGradient( { { .50, nRGB( 216, 216, 216 ), nRGB( 255, 255, 255 ) } } )
RETURN NIL
FUNCTION StandardGrad()
SetDlgGradient( { { .50, nRGB( 236, 233, 216 ), nRGB( 255, 255, 255 ) } } )
RETURN NIL
FUNCTION DarkGreyGrad()
SetDlgGradient({{ 0.90, 14671839, 4144959 },{ 0.1, 4144959, 14671839 }}) // .80
RETURN NIL
FUNCTION SolidWhite()
SetDlgGradient( { { 0.01,16777215,16777215 },{ 0.01,16777215,16777215 } })
RETURN NIL
FUNCTION SolidGrey()
SetDlgGradient( { { .50, nRGB( 233, 233, 233 ), nRGB( 233, 233, 233 ) } } )
RETURN NIL
FUNCTION SolidChoral()
LOCAL aGrad
SetDlgGradient( aGrad := { { 0.01,8388736,8388736 },{ 0.01,8388736,8388736 } })
RETURN NIL
FUNCTION LightYellow()
SetDlgGradient( { { 0.01,8440801,16777215 },{ 0.75,16777215,8440801 } })
RETURN NIL
FUNCTION GreenBlueGrad()
SetDlgGradient( { { .50, nRGB( 192, 192, 192 ), nRGB( 45, 121, 147 ) } } )
RETURN NIL
// FIN / END - kapiabafwh@gmail.com
João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
-
- Posts: 128
- Joined: Tue Mar 20, 2007 3:13 pm
- Has thanked: 1 time