Colorized cell of xbrowse

Colorized cell of xbrowse

Postby Silvio.Falconi » Fri Mar 04, 2022 10:16 am

I have to color the xbrowse cells on each line with a different color depending on the value of the cell, I made
WITH OBJECT oBrw

....
FOR i := 1 TO LEN(:aCols)
oCol := :aCols[ i ]
oCol:nWidth := 30
if i >1
oCol:bClrStd := {|i| { ChangeColor( oBrw, i ) } }
endif
NEXT

:CreateFromCode()
END

static function ChangeColor( oBrw, n )
return {|| { CLR_BLACK, ColorCell( oBrw:aRow[ n ]:VALUE ) } }

static function ColorCell( num )
local nColor := GetSysColor( 15 ) //for demo
local nColor1 := CLR_HGREEN
local nColor2 := CLR_HRED
local ncolor3 := GetSysColor( 15 )


/* IF num<3
nColor :=nColor1
elseif num>3
nColor := nColor2
elseif num<9
nColor := nColor3
endif*/

return nColor


where is the error ?
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
User avatar
Silvio.Falconi
 
Posts: 7052
Joined: Thu Oct 18, 2012 7:17 pm

Re: Colorized cell of xbrowse

Postby vilian » Fri Mar 04, 2022 11:39 am

Silvio,

I think you should change this

oCol:bClrStd := {|i| { ChangeColor( oBrw, i ) } }

For this:

oCol:bClrStd := {|| { ChangeColor( oBrw, i ) } }

But "i" is the variable of the FOR and when the browse is created the value of "i" will be the size of oBrw:aCols + 1
Sds,
Vilian F. Arraes
vilian@vfatec.com.br
Belém-Pa-Brazil
User avatar
vilian
 
Posts: 975
Joined: Wed Nov 09, 2005 2:17 am
Location: Brazil

Re: Colorized cell of xbrowse

Postby Silvio.Falconi » Sat Mar 05, 2022 8:17 am

vilian wrote:Silvio,

I think you should change this

oCol:bClrStd := {|i| { ChangeColor( oBrw, i ) } }

For this:

oCol:bClrStd := {|| { ChangeColor( oBrw, i ) } }

But "i" is the variable of the FOR and when the browse is created the value of "i" will be the size of oBrw:aCols + 1


the problem is then the function ChangeColor() not found the "i" variable
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
User avatar
Silvio.Falconi
 
Posts: 7052
Joined: Thu Oct 18, 2012 7:17 pm

Re: Colorized cell of xbrowse

Postby Marc Venken » Sat Mar 05, 2022 10:56 am

Marc Venken
Using: FWH 23.04 with Harbour
User avatar
Marc Venken
 
Posts: 1426
Joined: Tue Jun 14, 2016 7:51 am
Location: Belgium

Re: Colorized cell of xbrowse

Postby Silvio.Falconi » Sat Mar 05, 2022 11:53 am

Marc Venken wrote:Maybe you have also the issue with Detached Locals ?

http://forums.fivetechsupport.com/viewtopic.php?f=3&t=41373&hilit=detached+local


I need something of this
Image
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
User avatar
Silvio.Falconi
 
Posts: 7052
Joined: Thu Oct 18, 2012 7:17 pm

Re: Colorized cell of xbrowse

Postby nageswaragunupudi » Sun Mar 06, 2022 1:36 am

Code: Select all  Expand view
oCol:bClrStd := ChangeColor( oBrw, i )
 
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10627
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: Colorized cell of xbrowse

Postby Silvio.Falconi » Sun Mar 06, 2022 4:19 pm

nageswaragunupudi wrote:
Code: Select all  Expand view
oCol:bClrStd := ChangeColor( oBrw, i )
 


Nages,
give me error


WITH OBJECT oBrw
:nRowHeight := 22
:nClrBorder := CLR_GRAY
:lDrawBorder := .t.
:nColorBox := CLR_HRED
:nMarqueeStyle := MARQSTYLE_HIGHLWIN7
:lHscroll := .f.
:l2007 := .F.
:l2015 := .f.
:nStretchCol := STRETCHCOL_WIDEST
:lAllowRowSizing := .F.
:lAllowColSwapping := .F.
:lAllowColHiding := .F.
:lRecordSelector := .F.
:nColDividerStyle := LINESTYLE_LIGHTGRAY
:nRowDividerStyle := LINESTYLE_LIGHTGRAY
:nRowDividerStyle := LINESTYLE_NOLINES
:nColDividerStyle := LINESTYLE_LIGHTGRAY
:lDisplayZeros := .t. //Ineed the value zero
FOR i := 1 TO LEN(:aCols)
oCol := :aCols[ i ]
oCol:nWidth := 30
if i >1
oCol:bClrStd := ChangeColor( oBrw, i )
oCol:bClrSelFocus := {|| { CLR_BLACK, { { 1, RGB( 252, 235, 220 ), RGB( 255, 0,0 ) } }}}
endif
NEXT
:CreateFromCode()
:aCols[ 1 ]:nWidth := 100
:aCols[ 1 ]:nDataStrAlign := AL_LEFT
:SetStyle( 2018 )
end with


static function ChangeColor( oBrw, n )
return {|| { CLR_BLACK, ColorCell( oBrw:aRow[ n ]:VALUE ) } }

static function ColorCell( num )
local nColor := GetSysColor( 15 )
If num= 0
nColor := CLR_HGREEN
elseif num >0 .and. num < 8
nColor := CLR_WHITE
elseif num >9
nColor := CLR_HRED
endif
return nColor
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
User avatar
Silvio.Falconi
 
Posts: 7052
Joined: Thu Oct 18, 2012 7:17 pm

Re: Colorized cell of xbrowse

Postby FranciscoA » Mon Mar 07, 2022 2:12 am

Silvio.Falconi wrote:
nageswaragunupudi wrote:
Code: Select all  Expand view
oCol:bClrStd := ChangeColor( oBrw, i )
 


Nages,
give me error


WITH OBJECT oBrw
:nRowHeight := 22
:nClrBorder := CLR_GRAY
:lDrawBorder := .t.
:nColorBox := CLR_HRED
:nMarqueeStyle := MARQSTYLE_HIGHLWIN7
:lHscroll := .f.
:l2007 := .F.
:l2015 := .f.
:nStretchCol := STRETCHCOL_WIDEST
:lAllowRowSizing := .F.
:lAllowColSwapping := .F.
:lAllowColHiding := .F.
:lRecordSelector := .F.
:nColDividerStyle := LINESTYLE_LIGHTGRAY
:nRowDividerStyle := LINESTYLE_LIGHTGRAY
:nRowDividerStyle := LINESTYLE_NOLINES
:nColDividerStyle := LINESTYLE_LIGHTGRAY
:lDisplayZeros := .t. //Ineed the value zero
FOR i := 1 TO LEN(:aCols)
oCol := :aCols[ i ]
oCol:nWidth := 30
if i >1
oCol:bClrStd := ChangeColor( oBrw, i )
oCol:bClrSelFocus := {|| { CLR_BLACK, { { 1, RGB( 252, 235, 220 ), RGB( 255, 0,0 ) } }}}
endif
NEXT
:CreateFromCode()
:aCols[ 1 ]:nWidth := 100
:aCols[ 1 ]:nDataStrAlign := AL_LEFT
:SetStyle( 2018 )
end with


static function ChangeColor( oBrw, n )
return {|| { CLR_BLACK, ColorCell( oBrw:aRow[ n ]:VALUE ) } }

static function ColorCell( num )
local nColor := GetSysColor( 15 )
If num= 0
nColor := CLR_HGREEN
elseif num >0 .and. num < 8
nColor := CLR_WHITE
elseif num >9
nColor := CLR_HRED
endif
return nColor



Code: Select all  Expand view
static function ChangeColor( oBrw, n )
//return {|| { CLR_BLACK, ColorCell( oBrw:aRow[ n ]:VALUE ) } }    //Aquí hay un error. Cambia esta linea por la siguiente.  //There is an error here. Change this line to the next.
return {|| { CLR_BLACK, ColorCell( oBrw:aRow[ n ] ) } }
 
Francisco J. Alegría P.
Chinandega, Nicaragua.

Fwxh-MySql-TMySql
User avatar
FranciscoA
 
Posts: 2158
Joined: Fri Jul 18, 2008 1:24 am
Location: Chinandega, Nicaragua, C.A.

Re: Colorized cell of xbrowse

Postby Silvio.Falconi » Mon Mar 07, 2022 11:42 am

I have also error

Error occurred at: 07-03-2022, 12:37:57
Error description: Error BASE/1075 Parametro errato: >
Args:
[ 1] = U
[ 2] = N 0

Stack Calls
===========
Called from: source\tipico.prg => COLORCELL( 189 )
Called from: source\tipico.prg => (b)CHANGECOLOR( 183 )


the xbrowse
Code: Select all  Expand view

@ 90, 10 XBROWSE  oBrw OF oDlgRitardo  SIZE -10,-80 PIXEL NOBORDER
      oBrw:SetArray(aData,,,.F.)
      SetupBrowserRit(oBrw)
 



proc SetupBrowserTip(oBrw)

Code: Select all  Expand view

proc SetupBrowserTip(oBrw)
   ADD COLUMN TO oBrw HEADER "Combinazione" DATA {|v,oCol| oCol:oBrw:aArrayData[oCol:oBrw:nArrayAt,1] } CENTER
   ADD COLUMN TO oBrw HEADER "Ba"     DATA {|v,oCol| oCol:oBrw:aArrayData[oCol:oBrw:nArrayAt,2] } CENTER
   ADD COLUMN TO oBrw HEADER "Ca"     DATA {|v,oCol| oCol:oBrw:aArrayData[oCol:oBrw:nArrayAt,3] } CENTER
   ADD COLUMN TO oBrw HEADER "FI"     DATA {|v,oCol| oCol:oBrw:aArrayData[oCol:oBrw:nArrayAt,4] } CENTER
   ADD COLUMN TO oBrw HEADER "Ge"     DATA {|v,oCol| oCol:oBrw:aArrayData[oCol:oBrw:nArrayAt,5] } CENTER
   ADD COLUMN TO oBrw HEADER "Mi"     DATA {|v,oCol| oCol:oBrw:aArrayData[oCol:oBrw:nArrayAt,6] } CENTER
   ADD COLUMN TO oBrw HEADER "Na"     DATA {|v,oCol| oCol:oBrw:aArrayData[oCol:oBrw:nArrayAt,7] } CENTER
   ADD COLUMN TO oBrw HEADER "Pa"     DATA {|v,oCol| oCol:oBrw:aArrayData[oCol:oBrw:nArrayAt,8] } CENTER
   ADD COLUMN TO oBrw HEADER "Ro"     DATA {|v,oCol| oCol:oBrw:aArrayData[oCol:oBrw:nArrayAt,9] } CENTER
   ADD COLUMN TO oBrw HEADER "To"     DATA {|v,oCol| oCol:oBrw:aArrayData[oCol:oBrw:nArrayAt,10] } CENTER
   ADD COLUMN TO oBrw HEADER "Ve"     DATA {|v,oCol| oCol:oBrw:aArrayData[oCol:oBrw:nArrayAt,11] } CENTER
   ADD COLUMN TO oBrw HEADER "Nz"     DATA {|v,oCol| oCol:oBrw:aArrayData[oCol:oBrw:nArrayAt,12] } CENTER


   WITH OBJECT oBrw
 

      :nRowHeight    := 22
      :nClrBorder := CLR_GRAY
      :lDrawBorder := .t.
      :nColorBox := CLR_HRED
      :nMarqueeStyle       := MARQSTYLE_HIGHLWIN7
      :lHscroll            := .f.
      :l2007               := .F.
      :l2015               := .f.
      :nStretchCol         := STRETCHCOL_WIDEST
      :lAllowRowSizing     := .F.
      :lAllowColSwapping   := .F.
      :lAllowColHiding     := .F.
      :lRecordSelector     := .F.
      :nColDividerStyle    := LINESTYLE_LIGHTGRAY
      :nRowDividerStyle    := LINESTYLE_LIGHTGRAY
      :nRowDividerStyle    := LINESTYLE_NOLINES
      :nColDividerStyle    := LINESTYLE_LIGHTGRAY
      :lDisplayZeros       := .t.

        FOR i := 1 TO LEN(:aCols)
         oCol := :aCols[ i ]
         oCol:nWidth   := 30
         if i >1  
               oCol:bClrStd := ChangeColor( oBrw, i )
           endif
      NEXT

     
      :CreateFromCode()
      :aCols[ 1 ]:nWidth   := 100
      :aCols[ 1 ]:nDataStrAlign   := AL_LEFT
      :SetStyle( 2018 )
   end with
Return nil
//--------------------------------------------------------------------------------//
static function ChangeColor( oBrw, n )
return {|| { CLR_BLACK, ColorCell( oBrw:aRow[ n ]) } }

static function ColorCell( num )
   local nColor  :=  GetSysColor( 15 )
   If num= 0
      nColor := CLR_HGREEN
    elseif num >0 .and. num < 8
      nColor := CLR_WHITE
    elseif num >9
        nColor := CLR_HRED
     endif
     return nColor



 
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
User avatar
Silvio.Falconi
 
Posts: 7052
Joined: Thu Oct 18, 2012 7:17 pm

Re: Colorized cell of xbrowse

Postby Jimmy » Mon Mar 07, 2022 1:56 pm

hi Silvio,

you try to "add" Codeblock in a Loop but your "Counter" does not work that Way.

you need to use a "String" to build a Codeblock so this might work
Code: Select all  Expand view
LOCAL cString := "{|| { CLR_BLACK, ColorCell( oBrw:aRow[" + STR( n ) + "] ) } }"
RETURN &cString
greeting,
Jimmy
User avatar
Jimmy
 
Posts: 1725
Joined: Thu Sep 05, 2019 5:32 am
Location: Hamburg, Germany

Re: Colorized cell of xbrowse - Resolved!!

Postby Silvio.Falconi » Tue Mar 08, 2022 12:30 pm

Resolved!!!

Image

FOR i := 2 TO LEN(:aCols)
oCol := :aCols[ i ]
oCol:nWidth := 30
:aCols[ i ]:bClrStd := ChangeColor( oBrw, i )
NEXT
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
User avatar
Silvio.Falconi
 
Posts: 7052
Joined: Thu Oct 18, 2012 7:17 pm

Re: Colorized cell of xbrowse

Postby Silvio.Falconi » Tue Mar 08, 2022 12:39 pm

If I use
:nMarqueeStyle := MARQSTYLE_HIGHLWIN7
the n I not see the right color

How I can to hav the bar nmarquee on only first column ?
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
User avatar
Silvio.Falconi
 
Posts: 7052
Joined: Thu Oct 18, 2012 7:17 pm

Re: Colorized cell of xbrowse

Postby FranciscoA » Wed Mar 09, 2022 1:13 am

Silvio.Falconi wrote:How I can to hav the bar nmarquee on only first column ?


I do it like that:

Code: Select all  Expand view
  WITH OBJECT oBrw
      :nMarqueeStyle       := MARQSTYLE_HIGHLCELL
      :lColChangeNotify  := .t.  
      :bChange               := { |o| if( o:nColSel<>1, ( o:nColSel:=1, o:RefreshCurrent() ), nil ) }
      :CreateFromCode()
   END
Francisco J. Alegría P.
Chinandega, Nicaragua.

Fwxh-MySql-TMySql
User avatar
FranciscoA
 
Posts: 2158
Joined: Fri Jul 18, 2008 1:24 am
Location: Chinandega, Nicaragua, C.A.

Re: Colorized cell of xbrowse

Postby Silvio.Falconi » Wed Mar 09, 2022 12:19 pm

THANKS

Image
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
User avatar
Silvio.Falconi
 
Posts: 7052
Joined: Thu Oct 18, 2012 7:17 pm


Return to FiveWin for Harbour/xHarbour

Who is online

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