xBrowse cell overlaps

Post Reply
User avatar
frose
Posts: 392
Joined: Tue Mar 10, 2009 11:54 am
Location: Germany, Rietberg
Contact:

xBrowse cell overlaps

Post by frose »

Dear Rao,

is it possible to overlap (free) cells in xBrowse, like it is in Excel?

Little screen shot, showing overlapped cells in Excel:
http://depositfiles.com/files/3bb77rcog
Windows 11 Pro 22H2 22621.1848
Microsoft (R) Windows (R) Resource Compiler Version 10.0.10011.16384
Harbour 3.2.0dev (r2008190002)
FWH 23.10 x86
Marcelo Via Giglio
Posts: 1077
Joined: Fri Oct 07, 2005 3:33 pm
Location: Cochabamba - Bolivia
Has thanked: 1 time

Re: xBrowse cell overlaps

Post by Marcelo Via Giglio »

Hello,

I think this id not possible with the native xBrowse, you need to change the code, maybe can be possible to add a data (object attribute) to change the paint behavior

In the PaintData Method of TXBrwColumn Class change the follow lines

Code: Select all | Expand

     
//DrawTextEx( hDC, cData,;
//            {nRow, nCol, nRow + nHeight, Min( nCol + nWidth, ::oBrw:BrwWidth() - 5 ) },;
//            ::nDataStyle )

Draw TextEx( hDC, cData,;
                   { nRow, nCol, nRow + nHeight, nCol + GetTextWidth( hDC, cData ) },;
                     ::nDataStyle )
 


this is a simple test, I am using very old version of xBrowse ( I don't update my FW yet :-) ), please test and comment

saludos

Marcelo
User avatar
frose
Posts: 392
Joined: Tue Mar 10, 2009 11:54 am
Location: Germany, Rietberg
Contact:

Re: xBrowse cell overlaps

Post by frose »

Hi Marcelo,

thank you very much for your code snippet.

It works for the last column, see screen shot:
Image

But it doesn't work for (empty) cells, as shown here:
Image

Do you have an idea to change the code for overlapping (empty) cells?

Even better: switch (property) for each column with the following values:
- Do not overlap cells
- Overlap only empty cells
- Overlap cells even if they are not empty
Windows 11 Pro 22H2 22621.1848
Microsoft (R) Windows (R) Resource Compiler Version 10.0.10011.16384
Harbour 3.2.0dev (r2008190002)
FWH 23.10 x86
User avatar
nageswaragunupudi
Posts: 10721
Joined: Sun Nov 19, 2006 5:22 am
Location: India
Been thanked: 8 times
Contact:

Re: xBrowse cell overlaps

Post by nageswaragunupudi »

>>
I think this id not possible with the native xBrowse, you need to change the code, maybe can be possible to add a data (object attribute) to change the paint behavior
>>
This observation is not correct.

If oCol:bPaintText is assigned with our codeblock, xbrowse does NOT paint cell text on its own and instead calls our codeblock with the parameters ( oCol, hDC, cData, aRect, aColors, lHighLite ). It is for the programmer to use this facility,
Regards

G. N. Rao.
Hyderabad, India
User avatar
frose
Posts: 392
Joined: Tue Mar 10, 2009 11:54 am
Location: Germany, Rietberg
Contact:

Re: xBrowse cell overlaps

Post by frose »

Rao,

If oCol:bPaintText is assigned with our codeblock, xbrowse does NOT paint cell text on its own and instead calls our codeblock with the parameters ( oCol, hDC, cData, aRect, aColors, lHighLite ). It is for the programmer to use this facility,


So, we can achieve the above described behaviour with the actual version of xBrowse!?

If so, please give me some more advices, what I have to do. Here is my sample code:

Code: Select all | Expand

FUNCTION Main()

   LOCAL oDlg, oBrw, oCol, aRecord, nAt := 1
   
   USE Customer
   
   aRecord = Array( Customer->( FCount() ) )
   
   DEFINE DIALOG oDlg SIZE 300, 300

   @ 0, 0 XBROWSE oBrw OF oDlg ARRAY aRecord // AUTOSORT

   oCol := oBrw:AddCol()
   oCol:bStrData = { || Customer->( FieldName( oBrw:nArrayAt ) ) }
   oCol:cHeader = "FieldName"  

   oCol := oBrw:AddCol()
   oCol:bStrData = { || Customer->( FieldGet( oBrw:nArrayAt ) ) }
   oCol:cHeader = "Value"  

   oCol := oBrw:AddCol()
   oCol:bStrData = { || "" }
   oCol:cHeader = "Empty"  
   oCol:bPaintText = { || NIL }
   
   oBrw:nMarqueeStyle = MARQSTYLE_HIGHLROW

   oBrw:CreateFromCode()
   oBrw:bKeyCount = { || Customer->( FCount() ) }
   
   oDlg:oClient = oBrw  
     
   ACTIVATE DIALOG oDlg CENTERED ON INIT oDlg:Resize()
     
RETURN NIL
Windows 11 Pro 22H2 22621.1848
Microsoft (R) Windows (R) Resource Compiler Version 10.0.10011.16384
Harbour 3.2.0dev (r2008190002)
FWH 23.10 x86
Marcelo Via Giglio
Posts: 1077
Joined: Fri Oct 07, 2005 3:33 pm
Location: Cochabamba - Bolivia
Has thanked: 1 time

Re: xBrowse cell overlaps

Post by Marcelo Via Giglio »

Hello,

I think Mr. Rao is right, what happend is I worked with very old xBrowse source :-)

Code: Select all | Expand

 
...
if !Empty( cData )
      oFont:Activate( hDC )
      SetTextColor( hDC, aColors[ 1 ] )
      SetBkColor( hDC, aColors[ 2 ] )
      //DrawTextEx( hDC, cData,;
      //            {nRow, nCol, nRow + nHeight, Min( nCol + nWidth, ::oBrw:BrwWidth() - 5 ) },;
      //            ::nDataStyle )
         DrawTextEx( hDC, cData,;
                     { nRow, nCol, nRow + nHeight, nCol + GetTextWidth( hDC, cData ) },;
                     ::nDataStyle )
      //-------------------------
      oFont:Deactivate( hDC )
   endif
...
 


The xbrowse's source has only 4561 lines

I am sorry, I will try to see it with other xBrowse version

regards

Marcelo
User avatar
frose
Posts: 392
Joined: Tue Mar 10, 2009 11:54 am
Location: Germany, Rietberg
Contact:

Re: xBrowse cell overlaps

Post by frose »

Dear Marcelo, dear Rao,

I've adopted your proposals and now my sample code looks as follows:

Code: Select all | Expand

FUNCTION Main()

   LOCAL oDlg, oBrw, oCol, aRecord, nAt := 1
   
   USE Customer
   
   aRecord = Array( Customer->( FCount() ) )
   
   DEFINE DIALOG oDlg SIZE 300, 300

   @ 0, 0 XBROWSE oBrw OF oDlg ARRAY aRecord // AUTOSORT

   // 1. column
   oCol := oBrw:AddCol()
   oCol:bStrData = { || Customer->( FieldName( oBrw:nArrayAt ) ) }
   oCol:cHeader = "FieldName"  

   // 2. column
   oCol := oBrw:AddCol()
   oCol:bStrData = { || Customer->( FieldGet( oBrw:nArrayAt ) ) }
   oCol:cHeader = "Value"  
   
   // Overlapping this column
   oCol:bPaintText = { | oCol, hDC, cData, aRect | DrawTextEx( hDC, cData, { aRect[ 1 ], aRect[ 2 ], aRect[ 3 ], aRect[ 2 ] + GetTextWidth( hDC, cData ) }, oCol:nDataStyle ) }
   
   // 3. column
   oCol := oBrw:AddCol()
   oCol:bStrData = { || "abc" }
   oCol:cHeader = "Empty"  
   // Don't draw this column
   oCol:bPaintText = { || NIL }
   
   oBrw:nMarqueeStyle = MARQSTYLE_HIGHLROW

   oBrw:CreateFromCode()
   oBrw:bKeyCount = { || Customer->( FCount() ) }
   
   oDlg:oClient = oBrw  
     
   ACTIVATE DIALOG oDlg CENTERED ON INIT oDlg:Resize()
     
RETURN NIL
 

Even though the third column draw nothing, it still overwrites the content of the second column!

Any ideas?
Windows 11 Pro 22H2 22621.1848
Microsoft (R) Windows (R) Resource Compiler Version 10.0.10011.16384
Harbour 3.2.0dev (r2008190002)
FWH 23.10 x86
User avatar
frose
Posts: 392
Joined: Tue Mar 10, 2009 11:54 am
Location: Germany, Rietberg
Contact:

Re: xBrowse cell overlaps

Post by frose »

Hi to all,

one possible solution is, setting

Code: Select all | Expand

oCol:lColTransparent := .T.

but the content of the selected row disappears:

Image

And color settings has no effect for transparent cells :(

Code for the column 'Empty':

Code: Select all | Expand

oCol:bClrStd := { || { CLR_BLACK, CLR_CYAN } }
oCol:lColTransparent := .T.

the cell doesn't change the color:
Image

Any ideas?
Windows 11 Pro 22H2 22621.1848
Microsoft (R) Windows (R) Resource Compiler Version 10.0.10011.16384
Harbour 3.2.0dev (r2008190002)
FWH 23.10 x86
User avatar
frose
Posts: 392
Joined: Tue Mar 10, 2009 11:54 am
Location: Germany, Rietberg
Contact:

Re: xBrowse cell overlaps acc. merge columns

Post by frose »

Another much more better solution:

Merge columns similar to merge rows, see testmerg.prg

Unfortunately this feature is not (yet) implemented in xBrowse.
Windows 11 Pro 22H2 22621.1848
Microsoft (R) Windows (R) Resource Compiler Version 10.0.10011.16384
Harbour 3.2.0dev (r2008190002)
FWH 23.10 x86
Post Reply