Dialog Color / Gradient

Re: Dialog Color / Gradient

Postby cnavarro » Wed Jan 11, 2017 8:22 pm

Rick, Thanks to you for everything
Cristobal Navarro
Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noción del tiempo
El secreto de la felicidad no está en hacer lo que te gusta, sino en que te guste lo que haces
User avatar
cnavarro
 
Posts: 6548
Joined: Wed Feb 15, 2012 8:25 pm
Location: España

Re: Dialog Color / Gradient

Postby cdmmaui » Fri Jan 13, 2017 7:41 pm

Dear Rick,

Thank you!
*~*~*~*~*~*~*~*~*~*
Darrell Ortiz
CDM Software Solutions, Inc.
https://www.cdmsoft.com
User avatar
cdmmaui
 
Posts: 689
Joined: Fri Oct 28, 2005 9:53 am
Location: Houston ∙ Chicago ∙ Los Angeles ∙ Miami ∙ London ∙ Hong Kong

Re: Dialog Color / Gradient

Postby cdmmaui » Fri Jan 13, 2017 7:41 pm

Dear Cristobal,

Thank you very much!

Sincerely,
*~*~*~*~*~*~*~*~*~*
Darrell Ortiz
CDM Software Solutions, Inc.
https://www.cdmsoft.com
User avatar
cdmmaui
 
Posts: 689
Joined: Fri Oct 28, 2005 9:53 am
Location: Houston ∙ Chicago ∙ Los Angeles ∙ Miami ∙ London ∙ Hong Kong

Re: Dialog Color / Gradient

Postby cnavarro » Wed Jan 18, 2017 2:15 am

New better version

To all users: please, add new themes


Code: Select all  Expand view

//----------------------------------------------------------------------------//
// 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

//----------------------------------------------------------------------------//
 
Cristobal Navarro
Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noción del tiempo
El secreto de la felicidad no está en hacer lo que te gusta, sino en que te guste lo que haces
User avatar
cnavarro
 
Posts: 6548
Joined: Wed Feb 15, 2012 8:25 pm
Location: España

Re: Dialog Color / Gradient

Postby cnavarro » Wed Jan 18, 2017 1:14 pm

Mr Rao send me this comment and image

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 )


Image

Very important for the correct definition of gradients
Cristobal Navarro
Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noción del tiempo
El secreto de la felicidad no está en hacer lo que te gusta, sino en que te guste lo que haces
User avatar
cnavarro
 
Posts: 6548
Joined: Wed Feb 15, 2012 8:25 pm
Location: España

Re: Dialog Color / Gradient

Postby cdmmaui » Wed Jan 18, 2017 2:10 pm

Gracias Cristobal!
*~*~*~*~*~*~*~*~*~*
Darrell Ortiz
CDM Software Solutions, Inc.
https://www.cdmsoft.com
User avatar
cdmmaui
 
Posts: 689
Joined: Fri Oct 28, 2005 9:53 am
Location: Houston ∙ Chicago ∙ Los Angeles ∙ Miami ∙ London ∙ Hong Kong

Re: Dialog Color / Gradient

Postby nanoespinoza » Mon Oct 28, 2024 4:35 am

Estimados todos.

Se tiene alguna actualización para esta función.

Saludos

Fernando Espinoza A.
nanoespinoza
 
Posts: 141
Joined: Thu Mar 16, 2017 4:08 pm
Location: Ecuador

Re: Dialog Color / Gradient

Postby karinha » Mon Oct 28, 2024 1:12 pm

nanoespinoza wrote:Estimados todos.

Se tiene alguna actualización para esta función.

Saludos

Fernando Espinoza A.


Buenos días Fernando. ¿Qué te falta?

Code: Select all  Expand view

// C:\FWH\SAMPLES\GRADDLGS.PRG - 20/12/2017. - Very good.

#Include "FiveWin.ch"

FUNCTION Main()

   LOCAL oFont
   LOCAL oDlg, oGet, oBtn, aGet := ARRAY(10)
   LOCAL cTest  := SPACE(12)
   LOCAL nTest  := 1234567

   SET _3DLOOK ON

   DEFINE FONT oFont NAME "Ms Sans Serif"  SIZE 00, -14 BOLD

   DEFINE DIALOG oDlg TITLE "DlgGradient" FROM 2, 2 TO 15, 50 FONT oFont

   oDlg:lHelpIcon := .F.

   @ 1.5, 02 GET aGet[6] VAR cTest OF oDlg SIZE 120, 12 PIXEL FONT oFont ;
      PICTURE "@KR 9,999,999.99" UPDATE

   @ 4.5, 4 BUTTON oBtn PROMPT "&Ok" SIZE 45, 12 OF oDlg ;
      ACTION ( oDlg:End(), MsgInfo( cTest ) ) DEFAULT

   @ 4.5, 15 BUTTON "&Cancel" SIZE 45, 12 OF oDlg ACTION ( oDlg:End() ) CANCEL

   GradDlgs( "SolidChoral" )

   ACTIVATE DIALOG oDlg CENTERED

   oFont:End()

RETURN NIL
// ----------------------------------------------------------------------------//
// 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 .NOT. Empty( aGrad )

      SetDlgGradient( aGrad )

   ENDIF

RETURN( aThemes )
// -------------------
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( { { 005.9000, 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()

   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
 


Regards, saludos.
João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
User avatar
karinha
 
Posts: 7824
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil

Re: Dialog Color / Gradient

Postby nanoespinoza » Tue Oct 29, 2024 2:24 am

No es tanto como que le falte algo, sino, que consultaba si tenía alguna mejora visual importante.
nanoespinoza
 
Posts: 141
Joined: Thu Mar 16, 2017 4:08 pm
Location: Ecuador

Previous

Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 45 guests