colorize a xbrowse with a brush

colorize a xbrowse with a brush

Postby Silvio.Falconi » Tue Nov 07, 2023 9:06 am

I want to color the columns with a brush, I don't know the contents of each column, it can be alphanumeric, numeric, logical, data
and I want to color it if it doesn't contain any data

I made and I used Empty function

Code: Select all  Expand view

         For n=1 to LEN(oBrw:aCols)
            oCol := oBrw:aCols[ n ]
             oCol:oBrush := {|| iif( Empty(oBrw:aArrayData[oBrw:KeyNo(),n] ), oBrush, nil ) }
         Next n
 


but not run ok

I tried also with a codeblock

Code: Select all  Expand view

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

static function GenClrBlock( oCol,oBrush )
   local oBrw  := oCol:oBrw
   local nCol  := oCol:nCreationOrder
   local xCol

    return { || iif( Empty(oBrw:aArrayData[oBrw:KeyNo(),nCol] ), ;
            oBrush, nil ) }
 


any solution ?
I made a minimal test to try
Code: Select all  Expand view

 #include "fivewin.ch"
#include "xbrowse.ch"

function main()

  local oDlg, oBrw
  local aData    := { { "One", "Two" }, { " ", "2" }, { "Five", "Six" }  }
  local oBrush

   DEFINE BRUSH oBrush   STYLE BDIAGONAL COLOR  CLR_BLUE
   DEFINE DIALOG oDlg SIZE 300,200 PIXEL TITLE "Test brush"

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

   WITH OBJECT oBrw
       For n=1 to LEN(oBrw:aCols)
          oCol := oBrw:aCols[ n ]
             oCol:oBrush := { ||iif( Empty(oBrw:aArrayData[oBrw:KeyNo(),n] ), oBrush, nil ) }
          next
      :CreateFromCode()
   END

   ACTIVATE DIALOG oDlg CENTERED

return nil
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: 7061
Joined: Thu Oct 18, 2012 7:17 pm

Re: colorize a xbrowse with a brush

Postby nageswaragunupudi » Tue Nov 07, 2023 1:09 pm

For setting background color of empty cells, we need not use brush
Code: Select all  Expand view
XBROWSER aData SETUP ;
   oBrw:bClrStds := { |b,o| { CLR_BLACK, If( o != nil .and. Empty( o:Value ), ;
      CLR_BLUE, CLR_WHITE ) } }
 


For setting a brush for empty columns
Code: Select all  Expand view
DEFINE BRUSH oBrush FILE "..\bitmaps\backgrnd\pebbles.bmp"
XBROWSER aData SETUP oBrw:oBrushs := { |o| If( Empty( o:Value ), oBrush, nil ) }
RELEASE BRUSH oBrush
 
Regards

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

Re: colorize a xbrowse with a brush

Postby Silvio.Falconi » Wed Nov 08, 2023 9:04 am

nageswaragunupudi wrote:For setting background color of empty cells, we need not use brush
Code: Select all  Expand view
XBROWSER aData SETUP ;
   oBrw:bClrStds := { |b,o| { CLR_BLACK, If( o != nil .and. Empty( o:Value ), ;
      CLR_BLUE, CLR_WHITE ) } }
 


For setting a brush for empty columns
Code: Select all  Expand view
DEFINE BRUSH oBrush FILE "..\bitmaps\backgrnd\pebbles.bmp"
XBROWSER aData SETUP oBrw:oBrushs := { |o| If( Empty( o:Value ), oBrush, nil ) }
RELEASE BRUSH oBrush
 


Nages,
I try with
Code: Select all  Expand view
:oBrushs := { |o| If( o != nil .and. Empty( o:Value ), oBrush, nil ) }


it runs well only when it doesn't find a text in the cell, but when I have an image or a color in the cell the command imposes the new brush


samples

when there are images ( with :bBmpData )



or when on a column there is a color
Code: Select all  Expand view

        WITH OBJECT  oBrowse:aCols[6]
           :bClrStd := {|| { CLR_WHITE,IIF(oBrowse:aArrayData[ oBrowse:nArrayAt,6],(oBrowse:aArrayData[ oBrowse:nArrayAt,8]),CLR_WHITE)}}
           :bEditValue :={ || "" }
           :nDataStrAlign := AL_CENTER
        END
 


oBrowse:aArrayData[ oBrowse:nArrayAt,6] is a logic value

I f I rem this line * :bEditValue :={ || "" }

then I have this




any solution pls
Last edited by Silvio.Falconi on Thu Nov 09, 2023 7:29 am, edited 1 time in total.
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: 7061
Joined: Thu Oct 18, 2012 7:17 pm

Re: colorize a xbrowse with a brush

Postby nageswaragunupudi » Wed Nov 08, 2023 3:04 pm

Code: Select all  Expand view
oBrw:aRow

is same as
Code: Select all  Expand view
oBrw:aArrayData[oBrw:nArrayAt]



Code: Select all  Expand view
:oBrushs := { |o| If( o != nil .and. Empty( o:Value ) .and. ;
              Empty( o:oBrw:aRow[ 6 ] ) .and. ;
              Empty( XEval( o:bBmpData, o:Value, .t., o ) ) .and. ;
              Empty( XEval( o:bStrImage, o, o:oBrw ) ), oBrush, nil ) }
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10643
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 49 guests