XBrowse Multi Line Cell With Different Fonts
- David Williams
- Posts: 82
- Joined: Fri Mar 03, 2006 6:26 pm
- Location: Ireland
XBrowse Multi Line Cell With Different Fonts
Hi All
I'm trying to show a calendar type browse where within each cell, I have 3 lines of text. I want to show the second line in a larger font with the first and third line smaller.
Any suggestions?
TIA David
I'm trying to show a calendar type browse where within each cell, I have 3 lines of text. I want to show the second line in a larger font with the first and third line smaller.
Any suggestions?
TIA David
Re: XBrowse Multi Line Cell With Different Fonts
Hello David,
please have a look at /samples/Testxbr6.prg

Best Regards
Uwe
please have a look at /samples/Testxbr6.prg

Best Regards
Uwe

Since 1995 ( the first release of FW 1.9 )
i work with FW.
If you have any questions about special functions, maybe i can help.
i work with FW.
If you have any questions about special functions, maybe i can help.
- nageswaragunupudi
- Posts: 10721
- Joined: Sun Nov 19, 2006 5:22 am
- Location: India
- Been thanked: 8 times
- Contact:
Re: XBrowse Multi Line Cell With Different Fonts
The above sample shows usage of oCol:bPaintText.
This offers total flexibility to the programmer and he can paint any cell in his own way.
There is another feature where two or more columns can be painted in a single cell.
By specifying something like
oBrw:aCols[ 1 ]:SetColsAsRows( 1, 2, 3 ), contents of columns 1,2,3 are painted as 3 rows in column 1 and columns 2 and 3 are not displayed. We can specify different fonts, colors, alignment, etc to these columns as usual, except that they are painted under one another as subrows of the cell instead of showing in adjacent columns.
Here is an example. Please compile and run as it is.

To understand the concept better, please insert this code just after preparing the array
The raw array data looks like this.

Now let us apply formatting to the columns. Every 3rd columns has the same formatting.
For this just comment the line of code in the above sample
Without this line, each column is displayed side by side.

Now let us paint cols 2 and 3 under col-1. cols 5 and 6 under col 4 and so on.
This is done by restoring the line
Now the final outcome is what we see in the first screen-shot
This offers total flexibility to the programmer and he can paint any cell in his own way.
There is another feature where two or more columns can be painted in a single cell.
By specifying something like
oBrw:aCols[ 1 ]:SetColsAsRows( 1, 2, 3 ), contents of columns 1,2,3 are painted as 3 rows in column 1 and columns 2 and 3 are not displayed. We can specify different fonts, colors, alignment, etc to these columns as usual, except that they are painted under one another as subrows of the cell instead of showing in adjacent columns.
Here is an example. Please compile and run as it is.
Code: Select all | Expand
function MultiLineCells
local oDlg, oBrw, aFont[ 3 ]
local aData := Array( 4, 12 )
local n,i,j
n := 1
for i := 1 to 4
for j := 1 to 10 step 3
aData[ i, j ] := NToCDOW( ( n - 1 ) % 7 + 1 )
aData[ i, j + 1 ] := n
aData[ i, j + 2 ] := "Some details that may take more than one line"
n++
next
next
DEFINE FONT aFont[ 1 ] NAME "TAHOMA" SIZE 0,-16 BOLD
DEFINE FONT aFont[ 2 ] NAME "IMPACT" SIZE 0,-34
DEFINE FONT aFont[ 3 ] NAME "TIMES ROMAN" SIZE 0,-12 ITALIC
DEFINE DIALOG oDlg SIZE 700,500 PIXEL
@ 10,10 XBROWSE oBrw SIZE -10,-10 PIXEL OF oDlg DATASOURCE aData AUTOCOLS ;
LINES NOBORDER
WITH OBJECT oBrw
:nWidths := 150
:nRowHeight := 100
for i := 1 to 10 STEP 3
WITH OBJECT :aCols[ i ]
:oDataFont := aFont[ 1 ]
:nDataStrAlign := AL_CENTER
END
WITH OBJECT :aCols[ i + 1 ]
:oDataFont := aFont[ 2 ]
:nDataStrAlign := AL_CENTER
:bClrStd := { || { CLR_HRED, CLR_WHITE } }
END
WITH OBJECT :aCols[ i + 2 ]
:oDataFont := aFont[ 3 ]
:nDataLines := 2
END
:aCols[ i ]:SetColsAsRows( i, i + 1, i + 2 )
next
//
:CreateFromCode()
END
ACTIVATE DIALOG oDlg CENTERED
AEval( aFont, { |o| o:End() } )
return nil

To understand the concept better, please insert this code just after preparing the array
Code: Select all | Expand
XBROWSER aData
The raw array data looks like this.

Now let us apply formatting to the columns. Every 3rd columns has the same formatting.
For this just comment the line of code in the above sample
Code: Select all | Expand
// :aCols[ i ]:SetColsAsRows( i, i + 1, i + 2 )
Without this line, each column is displayed side by side.

Now let us paint cols 2 and 3 under col-1. cols 5 and 6 under col 4 and so on.
This is done by restoring the line
Code: Select all | Expand
:aCols[ i ]:SetColsAsRows( i, i + 1, i + 2 )
Now the final outcome is what we see in the first screen-shot
Regards
G. N. Rao.
Hyderabad, India
G. N. Rao.
Hyderabad, India
- Otto
- Posts: 6403
- Joined: Fri Oct 07, 2005 7:07 pm
- Has thanked: 24 times
- Been thanked: 2 times
- Contact:
Re: XBrowse Multi Line Cell With Different Fonts
Dear Mr. Rao,
I want to try this program but get following error msg:
Application
===========
Path and name: C:\fwh\samples\testbrw.exe (32 bits)
Size: 2,104,832 bytes
Compiler version: xHarbour build 1.2.1 Intl. (SimpLex) (Rev. 6715)
FiveWin Version: FWHX 12.03
Windows version: 6.1, Build 7601 Service Pack 1
Time from start: 0 hours 0 mins 1 secs
Error occurred at: 09/03/13, 20:50:12
Error description: Error BASE/1081 Argument error: +
Args:
[ 1] = N 20
[ 2] = U
Stack Calls
===========
Called from: .\source\classes\XBROWSE.PRG => TXBRWCOLUMN:PAINTCELL( 9690 )
Called from: .\source\classes\XBROWSE.PRG => TXBRWCOLUMN:PAINTDATA( 9561 )
Called from: .\source\classes\XBROWSE.PRG => TXBROWSE:PAINT( 1434 )
Called from: .\source\classes\XBROWSE.PRG => TXBROWSE:DISPLAY( 1253 )
Thanks in advance
Otto
I want to try this program but get following error msg:
Application
===========
Path and name: C:\fwh\samples\testbrw.exe (32 bits)
Size: 2,104,832 bytes
Compiler version: xHarbour build 1.2.1 Intl. (SimpLex) (Rev. 6715)
FiveWin Version: FWHX 12.03
Windows version: 6.1, Build 7601 Service Pack 1
Time from start: 0 hours 0 mins 1 secs
Error occurred at: 09/03/13, 20:50:12
Error description: Error BASE/1081 Argument error: +
Args:
[ 1] = N 20
[ 2] = U
Stack Calls
===========
Called from: .\source\classes\XBROWSE.PRG => TXBRWCOLUMN:PAINTCELL( 9690 )
Called from: .\source\classes\XBROWSE.PRG => TXBRWCOLUMN:PAINTDATA( 9561 )
Called from: .\source\classes\XBROWSE.PRG => TXBROWSE:PAINT( 1434 )
Called from: .\source\classes\XBROWSE.PRG => TXBROWSE:DISPLAY( 1253 )
Thanks in advance
Otto
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
- alerchster
- Posts: 97
- Joined: Mon Oct 22, 2012 4:43 pm
- Has thanked: 2 times
Re: XBrowse Multi Line Cell With Different Fonts
Hallo Otto
Rao's sample runs fine with FWH1307 but not with FWH1203 - there are many changes in xbrowse.prg...
Rao's sample runs fine with FWH1307 but not with FWH1203 - there are many changes in xbrowse.prg...
Regards
Ing. Anton Lerchster
Ing. Anton Lerchster
- Otto
- Posts: 6403
- Joined: Fri Oct 07, 2005 7:07 pm
- Has thanked: 24 times
- Been thanked: 2 times
- Contact:
Re: XBrowse Multi Line Cell With Different Fonts
Hello Anton,
thank you. You are right. With the new Fivewin Version this sample is working fine.
Best regards,
Otto
thank you. You are right. With the new Fivewin Version this sample is working fine.
Best regards,
Otto
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
- David Williams
- Posts: 82
- Joined: Fri Mar 03, 2006 6:26 pm
- Location: Ireland
Re: XBrowse Multi Line Cell With Different Fonts
Thanks Everyone,
Roa, your sample works perfect and helps me a lot with understanding the power of XBrowse.
Thanks again
David
Roa, your sample works perfect and helps me a lot with understanding the power of XBrowse.

Thanks again
David
Re: XBrowse Multi Line Cell With Different Fonts
Otto wrote:Dear Mr. Rao,
I want to try this program but get following error msg:
Application
===========
Path and name: C:\fwh\samples\testbrw.exe (32 bits)
Size: 2,104,832 bytes
Compiler version: xHarbour build 1.2.1 Intl. (SimpLex) (Rev. 6715)
FiveWin Version: FWHX 12.03
Windows version: 6.1, Build 7601 Service Pack 1
Time from start: 0 hours 0 mins 1 secs
Error occurred at: 09/03/13, 20:50:12
Error description: Error BASE/1081 Argument error: +
Args:
[ 1] = N 20
[ 2] = U
Stack Calls
===========
Called from: .\source\classes\XBROWSE.PRG => TXBRWCOLUMN:PAINTCELL( 9690 )
Called from: .\source\classes\XBROWSE.PRG => TXBRWCOLUMN:PAINTDATA( 9561 )
Called from: .\source\classes\XBROWSE.PRG => TXBROWSE:PAINT( 1434 )
Called from: .\source\classes\XBROWSE.PRG => TXBROWSE:DISPLAY( 1253 )
Thanks in advance
Otto
With these changes in version 12.03 I managed to work:
Code: Select all | Expand
METHOD PaintData( nRow, nCol, nHeight, lHighLite, lSelected, nOrder, nPaintRow ) CLASS TXBrwColumn
.../...
if Empty( ::nDataHeight )
::nDataHeight := ::DataHeight()
endif
nDataHeight := If( Empty( ::aRows ), nHeight, ::nDataHeight )
::PaintCell( nRow, nCol, nDataHeight, lHighLite, lSelected, nOrder, nPaintRow )
if ! Empty( ::aRows )
for n := 2 to Len( ::aRows )
.../...
nDataHeight := If( n == Len( ::aRows ), nHeight, oCol:nDataHeight )
if Empty( nDataHeight )
if Empty( oCol:nDataHeight )
oCol:nDataHeight := oCol:DataHeight()
endif
nDataHeight := oCol:nDataHeight
endif
oCol:PaintCell( nRow, nCol, nDataHeight, lHighLite, lSelected, nOrder, nPaintRow )
next n
endif
return nil

Cristobal Navarro
Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noción del tiempo
El secreto de la felicidad no está en hacer lo que te gusta, sino en que te guste lo que haces
Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noción del tiempo
El secreto de la felicidad no está en hacer lo que te gusta, sino en que te guste lo que haces
- Otto
- Posts: 6403
- Joined: Fri Oct 07, 2005 7:07 pm
- Has thanked: 24 times
- Been thanked: 2 times
- Contact:
Re: XBrowse Multi Line Cell With Different Fonts
Dear Mr. Rao,
can you please Show me how to get the right values from a dblClick.
Thanks in advance
Otto
Brw:bLDblClick := { |nKey| msginfo( ) }
can you please Show me how to get the right values from a dblClick.
Thanks in advance
Otto
Brw:bLDblClick := { |nKey| msginfo( ) }
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
- nageswaragunupudi
- Posts: 10721
- Joined: Sun Nov 19, 2006 5:22 am
- Location: India
- Been thanked: 8 times
- Contact:
Re: XBrowse Multi Line Cell With Different Fonts
Dear Mr Otto
I do not clearly understand what are the right values you want to know. Can you please explain clearly?
oBrw:bLDClick := { |nRow, nCol, nFlags, oBrw| <func>( nRow,nCol,nFlags,oBrw )}
oCol:bLDClickData := { |nRow, nCol, nFlags, oBrw| <func>( nRow,nCol,nFlags,oCol )}
I do not clearly understand what are the right values you want to know. Can you please explain clearly?
oBrw:bLDClick := { |nRow, nCol, nFlags, oBrw| <func>( nRow,nCol,nFlags,oBrw )}
oCol:bLDClickData := { |nRow, nCol, nFlags, oBrw| <func>( nRow,nCol,nFlags,oCol )}
Regards
G. N. Rao.
Hyderabad, India
G. N. Rao.
Hyderabad, India
- Otto
- Posts: 6403
- Joined: Fri Oct 07, 2005 7:07 pm
- Has thanked: 24 times
- Been thanked: 2 times
- Contact:
Re: XBrowse Multi Line Cell With Different Fonts
Dear Mr. Rao,
I tried:
oBrw:bLDblClick := { |nKey| msginfo( oBrw:aCols[ 1 ]:Value ) }
But this gives me always the value of the first column.
I would need the value of the column the user clicks.
Thanks in advance
Otto
I tried:
oBrw:bLDblClick := { |nKey| msginfo( oBrw:aCols[ 1 ]:Value ) }
But this gives me always the value of the first column.
I would need the value of the column the user clicks.
Thanks in advance
Otto
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
- Rick Lipkin
- Posts: 2668
- Joined: Fri Oct 07, 2005 1:50 pm
- Location: Columbia, South Carolina USA
Re: XBrowse Multi Line Cell With Different Fonts
Otto
I asked a similar question and Rao suggested using this ..
This will give you the text within the cell clicked.
Rick Lipkin
I asked a similar question and Rao suggested using this ..
Code: Select all | Expand
cText := oLbx:SelectedCol():Value
This will give you the text within the cell clicked.
Rick Lipkin
Re: XBrowse Multi Line Cell With Different Fonts
Otto, not sure if you're looking for:
Code: Select all | Expand
:bLDblClick := { | nRow, nCol, nFlag | MsgInfo( oBrw:aCols[ oBrw:MouseColPos( nCol ) ]:Value ) }
Cristobal Navarro
Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noción del tiempo
El secreto de la felicidad no está en hacer lo que te gusta, sino en que te guste lo que haces
Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noción del tiempo
El secreto de la felicidad no está en hacer lo que te gusta, sino en que te guste lo que haces
- nageswaragunupudi
- Posts: 10721
- Joined: Sun Nov 19, 2006 5:22 am
- Location: India
- Been thanked: 8 times
- Contact:
Re: XBrowse Multi Line Cell With Different Fonts
Mr Otto
Mr Rick's suggestion is correct.
oBrw:bLDClick := { || MsgInfo( oBrw:SelectedCol():Value ) }
Mr Navarro
Your solution can give wrong results in some cases.
MouseColPos( nCol ) gives you the number of visible column in the window. There could be some hidden columns or columns to the left of the visible area.
We should take oBrw:ColAtPos( MouseColPos( nCol ) )
Instead we better take oBrw:SelectedCol().
Mr Rick's suggestion is correct.
oBrw:bLDClick := { || MsgInfo( oBrw:SelectedCol():Value ) }
Mr Navarro
Your solution can give wrong results in some cases.
MouseColPos( nCol ) gives you the number of visible column in the window. There could be some hidden columns or columns to the left of the visible area.
We should take oBrw:ColAtPos( MouseColPos( nCol ) )
Instead we better take oBrw:SelectedCol().
Regards
G. N. Rao.
Hyderabad, India
G. N. Rao.
Hyderabad, India
Re: XBrowse Multi Line Cell With Different Fonts
Mr. Rao thank you very much for your explanations and arguments
Cristobal Navarro
Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noción del tiempo
El secreto de la felicidad no está en hacer lo que te gusta, sino en que te guste lo que haces
Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noción del tiempo
El secreto de la felicidad no está en hacer lo que te gusta, sino en que te guste lo que haces