colorize xbrowse on specific col/row

colorize xbrowse on specific col/row

Postby Silvio.Falconi » Tue May 31, 2022 8:10 am

I have an array with two element
I save on it the coordinates to colorize


Image

If I make

For n= 1 to Len(aPos)
nRow:= aPos[n][1]
nCol:= aPos[n][2]

oBrw1:aCols[nCol]:bClrStd := {|| { CLR_BLACK,IIf(oBrw1:nArrayAt=nRow, nColor1,CLR_WHITE) } }

next

it colorize only the last nRow , so I think it need to make a codeblock but I not Know How make it

Can U help me pls
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: colorize xbrowse on specific col/row

Postby Silvio.Falconi » Tue May 31, 2022 9:27 am

I tried with

Code: Select all  Expand view
Function  SetColumn_Series(oBrw1,aPos)
       local nRow,nCol
       local n
       local oCol
       local xCol
       local kCol
       local yCol
     local  ncolor1:=  RGB( 255, 0,0  )
     local  nColor2 := RGB( 252, 235, 220  )

       For n= 1 to Len(aPos)
          nRow:= aPos[n][1]
          nCol:= aPos[n][2]

    // column 7 - 11
   If nCol <= 6
      xCol:= nCol + 6

      oBrw1:aCols[xCol]:bClrStd := ChangeColor(nRow,nCol,oBrw1, nColor1,nColor2)

   Endif

 //  columns 12 - 16
       If nCol <= 6
          kCol:= nCol + 11 -1
           oBrw1:aCols[kCol]:bClrStd := ChangeColor(nRow,nCol,oBrw1, nColor1,nColor2)
           Endif

  next n



   For n= 1 to Len(aPos)
       nRow:= aPos[n][1]
       oBrw1:aCols[ 1]:bClrStd := ChangeColor(nRow,nCol,oBrw1, nColor1,nColor2)
      next
    return nil

static function  ChangeColor(nRow,nCol,oBrw1, nColor1,nColor2)
   return {|| { IIf(oBrw1:nArrayAt=nRow,CLR_WHITE,GetBackColor('teal')), MakeColor(oBrw1,nCol,nRow) } }



Function MakeColor(oBrw1,nCol,nRow)

   IF oBrw1:nArrayat == nRow
      return GetBackColor('darkblue')
   else
     return GetBackColor('whitesmoke')
   Endif
   return nil


 



Run but there are errors look the image

Image



where I draw the red circle why the procedure not colorize ?
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: colorize xbrowse on specific col/row

Postby nageswaragunupudi » Wed Jun 01, 2022 3:27 am

I am giving a very simple sample.
You may adopt this logic to your situation.
Code: Select all  Expand view
function BrwColorCells()

   local oDlg, oFont, oBrw, oCol
   local aPos  := { { 1, 2 }, { 1, 4 }, { 2, 1 }, { 3, 3 }, { 4, 2 }, { 4, 4 } }
   local aData := ;
         {  { 11, 12, 13, 14 } ;
         ,  { 21, 22, 23, 24 } ;
         ,  { 31, 32, 33, 34 } ;
         ,  { 41, 42, 43, 44 } }

   XBROWSER aPos TITLE "HIGHLIGHT CELLS" SETUP oBrw:cHeaders := { "ROW", "COL" }

   DEFINE FONT oFont NAME "VERDANA" SIZE 0,-20 BOLD
   DEFINE DIALOG oDlg SIZE 400,250 PIXEL TRUEPIXEL FONT oFont
   @ 20,20 XBROWSE oBrw SIZE -20,-20 PIXEL OF oDlg ;
      DATASOURCE aData AUTOCOLS LINES NOBORDER

   for each oCol in oBrw:aCols
      oCol:bClrStd   := GenClrBlock( oCol, aPos )
   next

   oBrw:cHeaders := { "1", "2", "3", "4" }
   oBrw:nWidths := "9999"
   oBrw:CreateFromCode()

   ACTIVATE DIALOG oDlg CENTERED
   RELEASE FONT oFont

return nil

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

static function GenClrBlock( oCol, aPos )

   local oBrw  := oCol:oBrw
   local nCol  := oCol:nCreationOrder
   local xCol

   xCol  := nCol // your calculation

return { || If( AScan( aPos, { |a| a[ 1 ] == oBrw:nArrayAt .and. a[ 2 ] == xCol } ) > 0, ;
            { CLR_WHITE, CLR_BLUE }, { CLR_BLACK, CLR_WHITE } ) }

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


Please run this program as it is without changes.
And then adopt the GenClrBlock(...) to your requirements (particularly deriving xCol from nCol )
Regards

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

Re: colorize xbrowse on specific col/row

Postby Silvio.Falconi » Wed Jun 01, 2022 7:01 am

nageswaragunupudi wrote:I am giving a very simple sample.
You may adopt this logic to your situation.
Code: Select all  Expand view
function BrwColorCells()

   local oDlg, oFont, oBrw, oCol
   local aPos  := { { 1, 2 }, { 1, 4 }, { 2, 1 }, { 3, 3 }, { 4, 2 }, { 4, 4 } }
   local aData := ;
         {  { 11, 12, 13, 14 } ;
         ,  { 21, 22, 23, 24 } ;
         ,  { 31, 32, 33, 34 } ;
         ,  { 41, 42, 43, 44 } }

   XBROWSER aPos TITLE "HIGHLIGHT CELLS" SETUP oBrw:cHeaders := { "ROW", "COL" }

   DEFINE FONT oFont NAME "VERDANA" SIZE 0,-20 BOLD
   DEFINE DIALOG oDlg SIZE 400,250 PIXEL TRUEPIXEL FONT oFont
   @ 20,20 XBROWSE oBrw SIZE -20,-20 PIXEL OF oDlg ;
      DATASOURCE aData AUTOCOLS LINES NOBORDER

   for each oCol in oBrw:aCols
      oCol:bClrStd   := GenClrBlock( oCol, aPos )
   next

   oBrw:cHeaders := { "1", "2", "3", "4" }
   oBrw:nWidths := "9999"
   oBrw:CreateFromCode()

   ACTIVATE DIALOG oDlg CENTERED
   RELEASE FONT oFont

return nil

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

static function GenClrBlock( oCol, aPos )

   local oBrw  := oCol:oBrw
   local nCol  := oCol:nCreationOrder
   local xCol

   xCol  := nCol // your calculation

return { || If( AScan( aPos, { |a| a[ 1 ] == oBrw:nArrayAt .and. a[ 2 ] == xCol } ) > 0, ;
            { CLR_WHITE, CLR_BLUE }, { CLR_BLACK, CLR_WHITE } ) }

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


Please run this program as it is without changes.
And then adopt the GenClrBlock(...) to your requirements (particularly deriving xCol from nCol )


Thanks Rao
your test run ok

but I have specific coordinates and I wanted to translate the position also in other columns that are not described in the array

for example to explain to you

in the xbrowse I have three groups (extracts, delays, frequencies)

if in the array I have the number 55 and the calculation gives me the coordinate
nRow = 1
nCol = 3

in the array I have {1, 3}

I want to color in row 1:

the first column
column 3 (Extracted Numbers group)
column 9 (column 3 of the Delays group)
column 14 of the group (column 3 frequencies)
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: colorize xbrowse on specific col/row

Postby Silvio.Falconi » Wed Jun 01, 2022 7:36 am

Resolved With another array

Image

Code: Select all  Expand view
For n=1 to len(aCoo)
           nRow:= aCoo[n][1]
           nCol:= aCoo[n][2]
           // for the first column
           aadd(aPos, {nRow,1   } )
           If nCol <= 6
              aadd(aPos, {nRow,nCol} )
           If nCol <= 6
              nCol+= 5
              aadd(aPos, {nRow,nCol    } )
              nCol+= 5
              aadd(aPos, {nRow,nCol    } )
           Endif
          Endif
       Next

 for each oCol in oBrw1:aCols
       oCol:bClrStd   := GenClrBlock( oCol, apos)
      next

 


But I must modifiy the color on first column because I wish only the text orange ...:)
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: colorize xbrowse on specific col/row

Postby Silvio.Falconi » Wed Jun 01, 2022 7:48 am

Final

Image



thanks Rao
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: No registered users and 87 guests