Page 1 of 1

XBROWSE COLOR ROWS

Posted: Fri Sep 18, 2020 7:34 am
by Otto
Dear Mr. Rao,
Can you please help me.
I try to change row colors.
With a button I do:
oBrw:bClrStd := {||{CLR_WHITE,rgb(240, 173, 78) }}

But if I look into the paint method of xBrowse, there are no changes:
METHOD Display() CLASS TXBrowse

local nSecs := SECONDS()

if !::lCreated
return nil
endif

fwlog Eval( ::bClrSel )
...

Can you please show me how I can change bClrStd.

Best regards,
Otto

Re: XBROWSE COLOR ROWS

Posted: Fri Sep 18, 2020 10:41 am
by cnavarro
Dear Otto
This run OK for me ( in ACTION Button )

Code: Select all

oBrw1:bClrStd := { || { CLR_WHITE, CLR_BLACK } }
 oBrw1:Refresh()
 

Re: XBROWSE COLOR ROWS

Posted: Fri Sep 18, 2020 12:08 pm
by Otto
WIKI

Postby Otto » Fri Sep 18, 2020 12:01 pm
Dear Cristobal,
I inserted the code into yunus.prg.

static function Invoices() and commented

// BrwColors( oBrw ).

This is not working.

If BrwColors( oBrw ) is uncommented, then I get black background but not the rows.

Maybe it is different when there is mdi?

Best regards,
Otto

Re: XBROWSE COLOR ROWS

Posted: Fri Sep 18, 2020 1:48 pm
by nageswaragunupudi
Mr. Otto

Please try

Code: Select all

oBrw:bClrStds := {||{CLR_WHITE,rgb(240, 173, 78) }}
 
Note: bClrStds not bClrStd

Re: XBROWSE COLOR ROWS

Posted: Fri Sep 18, 2020 2:46 pm
by ukoenig
Thank You Mr. Rao,

I added for a test 2 buttons to YUNUS.prg
( switching row-colors on button-action )

Image

Code: Select all

static function Clients()
..
..
// I added 2 buttons

      DEFINE BUTTON OF oBar PROMPT "Color" RESOURCE "magic" ;
         ACTION BrwColors1( oBrw, 1 )
     
     DEFINE BUTTON OF oBar PROMPT "Reset" RESOURCE "prev" ;
         ACTION BrwColors1( oBrw, 2 )

// ---------------

static function BrwColors1( oBrw, nStatus )

IF nStatus = 1
     oBrw:bClrStds = { || If( oBrw:KeyNo() % 2 == 0, ;
     { If( ( oBrw:cAlias )->( Deleted() ), CLR_HRED, CLR_BLACK ),;
       RGB( 240, 173, 78 ) }, ;
     { If( ( oBrw:cAlias )->( Deleted() ), CLR_HRED, CLR_BLACK ),;
       nRGB( 255, 217, 197 ) } ) }
ELSE
     oBrw:bClrStds = { || If( oBrw:KeyNo() % 2 == 0, ;
     { If( ( oBrw:cAlias )->( Deleted() ), CLR_HRED, CLR_BLACK ),;
       RGB( 198, 255, 198 ) }, ;
     { If( ( oBrw:cAlias )->( Deleted() ), CLR_HRED, CLR_BLACK ),;
       RGB( 232, 255, 232 ) } ) }
ENDIF
oBrw:Refresh()

return nil

 
working with conditions and multiple colors

Image

Code: Select all

static function BrwColors1( oBrw, nStatus )

IF nStatus = 1
     oBrw:bClrStds = { || If( oBrw:KeyNo() > 6 .and. oBrw:KeyNo() < 12 ; 
       .or. oBrw:KeyNo() > 14 .and. oBrw:KeyNo() < 18 , ;  // any condition
       { If( ( oBrw:cAlias )->( Deleted() ), CLR_HRED, CLR_BLACK ),;
         If( oBrw:KeyNo() > 6 .and. oBrw:KeyNo() < 12, nRGB( 240, 173, 78 ), nRGB( 140, 168, 197 ) ) }, ;
         { If( ( oBrw:cAlias )->( Deleted() ), CLR_HRED, CLR_BLACK ),;
           If( oBrw:KeyNo() % 2 == 0, nRGB( 198, 255, 198 ), nRGB( 232, 255, 232 ) ) } ) }
ELSE
     oBrw:bClrStds = { || If( oBrw:KeyNo() % 2 == 0, ;
          { If( ( oBrw:cAlias )->( Deleted() ), CLR_HRED, CLR_BLACK ),;
                 nRGB( 198, 255, 198 ) }, ;
          { If( ( oBrw:cAlias )->( Deleted() ), CLR_HRED, CLR_BLACK ),;
                 nRGB( 232, 255, 232 ) } ) }
ENDIF
oBrw:Refresh()

return nil
 
regards
Uwe :D

Re: XBROWSE COLOR ROWS

Posted: Fri Sep 18, 2020 7:02 pm
by Otto
Dear Mr Rao, Critobal and Uwe,
many thanks for your help. It works.

Mr. Rao can you please explain to me
the differences of bClrStds and bClrStd.

Best regards,
Otto

Re: XBROWSE COLOR ROWS

Posted: Sat Sep 19, 2020 6:12 am
by nageswaragunupudi

Code: Select all

oBrw:bClrStds := b
 
is equivalent to

Code: Select all

for n := 1 to Len( oBrw:aCols )
   oBrw:aCols[ n ]:bClrStd := b
next
 

Re: XBROWSE COLOR ROWS

Posted: Sat Sep 19, 2020 6:36 am
by Otto
Dear Mr. Rao,
thank you so much for your help.
Have a nice Sunday and best regards,
Otto