FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour xBrowse cell overlaps
Posts: 392
Joined: Tue Mar 10, 2009 11:54 AM
xBrowse cell overlaps
Posted: Thu Apr 29, 2010 02:53 PM
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
Posts: 1088
Joined: Fri Oct 07, 2005 03:33 PM
Re: xBrowse cell overlaps
Posted: Thu Apr 29, 2010 03:53 PM
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 (fw): Select all Collapse
      
//DrawTextEx( hDC, cData,;
//            {nRow, nCol, nRow + nHeight, Min( nCol + nWidth, ::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
Posts: 392
Joined: Tue Mar 10, 2009 11:54 AM
Re: xBrowse cell overlaps
Posted: Fri Apr 30, 2010 08:27 AM
Hi Marcelo,

thank you very much for your code snippet.

It works for the last column, see screen shot:


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


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
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: xBrowse cell overlaps
Posted: Fri Apr 30, 2010 11:21 AM

>>
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
Posts: 392
Joined: Tue Mar 10, 2009 11:54 AM
Re: xBrowse cell overlaps
Posted: Fri Apr 30, 2010 12:39 PM
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 (fw): Select all Collapse
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
Posts: 1088
Joined: Fri Oct 07, 2005 03:33 PM
Re: xBrowse cell overlaps
Posted: Sat May 01, 2010 08:57 PM
Hello,

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

Code (fw): Select all Collapse
   
...
if !Empty( cData )
      oFont:Activate( hDC )
      SetTextColor( hDC, aColors[ 1 ] )
      SetBkColor( hDC, aColors[ 2 ] )
      //DrawTextEx( hDC, cData,;
      //            {nRow, nCol, nRow + nHeight, Min( nCol + nWidth, ::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
Posts: 392
Joined: Tue Mar 10, 2009 11:54 AM
Re: xBrowse cell overlaps
Posted: Mon May 03, 2010 09:06 AM
Dear Marcelo, dear Rao,

I've adopted your proposals and now my sample code looks as follows:
Code (fw): Select all Collapse
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
Posts: 392
Joined: Tue Mar 10, 2009 11:54 AM
Re: xBrowse cell overlaps
Posted: Mon May 03, 2010 12:25 PM
Hi to all,

one possible solution is, setting

Code (fw): Select all Collapse
oCol:lColTransparent := .T.

but the content of the selected row disappears:



And color settings has no effect for transparent cells :-)

Code for the column 'Empty':
Code (fw): Select all Collapse
oCol:bClrStd := { || { CLR_BLACK, CLR_CYAN } }
oCol:lColTransparent := .T.

the cell doesn't change the color:


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
Posts: 392
Joined: Tue Mar 10, 2009 11:54 AM
Re: xBrowse cell overlaps acc. merge columns
Posted: Fri May 07, 2010 07:32 AM
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

Continue the discussion