Color of rows in the cell

Color of rows in the cell

Postby Natter » Mon Jan 23, 2023 11:59 am

Hi,

To display lines in different colors in the xbrowse cell, I specify aCols [1]: aClrText: = {CLR _ BLACK, CLR_RED}.
Is it possible to make this setting not for all xBrose lines, but according to a certain condition ?
Natter
 
Posts: 1222
Joined: Mon May 14, 2007 9:49 am

Re: Color of rows in the cell

Postby leandro » Mon Jan 23, 2023 7:20 pm

Code: Select all  Expand view  RUN

....
....

        :bClrStd            :=  {|| if(Len( aDeta ) > 0 , ;
                                    { CLR_BLACK,clrEstFondo(aDeta[oBrw:nArrayAt]["estado"]) } ,;
                                    { CLR_BLACK,clrEstFondo("S") } ) } 
        :bClrSelFocus       :=  {|| if(Len( aDeta ) > 0 , ;
                                    { CLR_WHITE,clrEstSelec(aDeta[oBrw:nArrayAt]["estado"]) } ,;
                                    { CLR_WHITE,clrEstSelec("S") }) }   


....
....


****************************
*CAMBIA EL COLOR DE LA CELDA
****************************
Function clrEstFondo(valor)
If valor=="S"
    Return nRGB(255,255,255) //Blanco
ElseIf valor=="N"
    Return nRGB(187,255,187) //Verde Claro
ElseIf valor=="M"
    Return nRGB(187,187,255) //Azul Claro
ElseIf valor=="B"
    Return nRGB(255,187,187) //Rojo Claro
Else
    Return nRGB(255,255,255) //Blanco
Endif

*****************************************
*CAMBIA EL COLOR DE LA CELDA SELECCIONADO
*****************************************
Function clrEstSelec(valor)
If valor=="S"
    Return RGB( 117, 186, 255 )
ElseIf valor=="N"
    Return nRGB(0,210,0) //Verde Oscuro
ElseIf valor=="M"
    Return nRGB(119,119,255) //Azul Oscuro
ElseIf valor=="B"
    Return nRGB(255,117,117) //Rojo Oscuro
Else
    Return RGB( 117, 186, 255 ) 
Endif


 
Saludos
LEANDRO AREVALO
Bogotá (Colombia)
https://hymlyma.com
https://hymplus.com/
leandroalfonso111@gmail.com
leandroalfonso111@hotmail.com

[ Embarcadero C++ 7.60 for Win32 ] [ FiveWin 23.07 ] [ xHarbour 1.3.0 Intl. (SimpLex) (Build 20230914) ]
User avatar
leandro
 
Posts: 1676
Joined: Wed Oct 26, 2005 2:49 pm
Location: Colombia

Re: Color of rows in the cell

Postby Natter » Tue Jan 24, 2023 7:18 am

This is an example for the whole cell, but I asked about coloring the lines in the cell with different colors.

tex1+CRLF+text2+CRLF+text3
Natter
 
Posts: 1222
Joined: Mon May 14, 2007 9:49 am

Re: Color of rows in the cell

Postby nageswaragunupudi » Wed Jan 25, 2023 8:25 pm

Natter wrote:Hi,

To display lines in different colors in the xbrowse cell, I specify aCols [1]: aClrText: = {CLR _ BLACK, CLR_RED}.
Is it possible to make this setting not for all xBrose lines, but according to a certain condition ?


Code: Select all  Expand view  RUN
#include "fivewin.ch"

function Main()

   local oDlg, oBrw, oCol, oFont, oBold, oItalic, oImpact
   local aClr1 := { CLR_HRED,CLR_GREEN,CLR_HBLUE }
   local aClr2 := { CLR_HBLUE,CLR_HRED,CLR_GREEN }
   local aData := { { "123", "ONE" + CRLF + "JANUARY" + CRLF + "MONDAY" }, ;
                    { "234", "TWO" + CRLF + "FEBRUARY" + CRLF + "TUESDAY" }, ;
                    { "345", "THREE" + CRLF + "MARCH" + CRLF + "WEDNESDAY" } }


   DEFINE FONT oFont    NAME "TAHOMA" SIZE 0,-14
   DEFINE FONT oImpact  NAME "IMPACT" SIZE 0,-35
   DEFINE FONT oBold    NAME "VERDANA" SIZE 0,-18 BOLD
   DEFINE FONT oItalic  NAME "Times New Roman" SIZE 0,-16 BOLD ITALIC

   DEFINE DIALOG oDlg SIZE 500,500 PIXEL TRUEPIXEL FONT oFont



   @ 20,20 XBROWSE oBrw SIZE -20,-20 PIXEL OF oDlg ;
      DATASOURCE aData AUTOCOLS CELL LINES NOBORDER

   WITH OBJECT oBrw
      :nDataStrAligns   := AL_CENTER
      :aCols[ 1 ]:oDataFont   := oImpact
      WITH OBJECT ( oCol := oBrw:aCols[ 2 ] )
         :aDataFont  := { oBold, oFont, oItalic }
         :bClrStd    := { || oCol:aClrText   := If( oBrw:KeyNo % 2 == 0, aClr1, aClr2 ), ;
            { 0, CLR_WHITE } }
      END
      :nRowHeight    := 100
      :CreateFromCode()
   END

   ACTIVATE DIALOG oDlg CENTERED

   RELEASE FONT oFont, oBold, oItalic, oImpact

return nil
 


Image
Regards

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

Re: Color of rows in the cell

Postby Natter » Thu Jan 26, 2023 9:59 am

Thank you, Rao!
Natter
 
Posts: 1222
Joined: Mon May 14, 2007 9:49 am

Re: Color of rows in the cell

Postby nageswaragunupudi » Sat Jan 28, 2023 1:15 pm

Simplification in the next version:

1) aDataFont and aClrText can also be codeblocks. These codeblocks are evaluated with two params, viz, the column object and lHiLite.

The above code can be written like this:
Code: Select all  Expand view  RUN
WITH OBJECT oBrw:aCols[ 2 ]
   :aClrText   := { |oCol,lHilite| If( lHilite, { CLR_WHITE, CLR_WHITE, CLR_WHITE }, ;
                    If( oCol:oBrw:KeyNo % 2 == 0, aClr1, aClr2 ) ) }
END
 


2) We know bClrStd returns a color pair { nClrText, nClrBack }
If instead of returning a single color as nClrText, if we return an array of colors, those colors are used in the place of aClrText.

This example code also works like the above sample:
Code: Select all  Expand view  RUN
WITH OBJECT oBrw:aCols[ 2 ]
   :bClrStd := { || If( oBrw:KeyNo % 2 == 0, { aClr1, CLR_WHITE }, { aClr2, CLR_WHITE } ) }
END
 
Regards

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


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 98 guests