Page 1 of 1

FW 16.11: XBrowse multi-font/colored cells

PostPosted: Mon Nov 28, 2016 8:48 am
by nageswaragunupudi
Different lines, separated by CRLF, in the data of a cell can be painted with different fonts and colors by using oCol:aClrText and oCol:aDataFont

Image

Sample: fwh\samples\xbfntclr.prg
Code: Select all  Expand view
/*
* XBrowse
* Different lines in different fonts and colors
*
*/


#include "fivewin.ch"

REQUEST DBFCDX

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

function Main()

   field STATE,CODE
   local oDlg, oFont, oBrw
   local aFont1[ 2 ], aFont2[ 4 ]

   USE STATES NEW SHARED VIA "DBFCDX"
   INDEX ON CODE TAG CODE TO TMP MEMORY
   SET ORDER TO TAG CODE
   USE CUSTOMER NEW ALIAS CUST SHARED VIA "DBFCDX"
   SET RELATION TO STATE INTO STATES
   GO TOP

   DEFINE FONT oFont NAME "TAHOMA" SIZE 0,-14

   DEFINE FONT aFont1[ 1 ] NAME "VIVALDI" SIZE 0,-30
   DEFINE FONT aFont1[ 2 ] NAME "Verdana" SIZE 0,-20

   DEFINE FONT aFont2[ 1 ] NAME "TIMES NEW ROMAN" SIZE 0,-18
   DEFINE FONT aFont2[ 2 ] NAME "TAHOMA" SIZE 0,-16 BOLD
   DEFINE FONT aFont2[ 4 ] NAME "TAHOMA" SIZE 0,-16 ITALIC BOLD

   DEFINE DIALOG oDlg SIZE 700,800 PIXEL TRUEPIXEL FONT oFont ;
      TITLE "FWH16.11: XBROWSE Multiple Fonts and Colors"

   @ 20,20 XBROWSE oBrw SIZE -20,-20 PIXEL OF oDlg DATASOURCE "CUST" ;
      COLUMNS "TRIM(FIRST) + CHR(13)+CHR(10) + LAST", ;
              "TRIM(STREET) + CHR(13)+CHR(10) + TRIM(CITY) +CHR(13)+CHR(10) + TRIM(ZIP) + CHR(13)+CHR(10) + TRIM(STATES->NAME)", ;
              "TRIM(FIRST) + CHR(13)+CHR(10)+TRIM(LAST)" ;
      HEADERS "NAME", "ADDRESS", "CUSTOMER" ;
      JUSTIFY AL_CENTER, AL_CENTER, AL_CENTER ;
      LINES NOBORDER

   WITH OBJECT oBrw
      :nRowHeight    := 100
      :nWidths       := { 200, 250, 150 }
      :nHeadStrAligns:= AL_CENTER
      :nStretchCol   := 2
      :lFitGridHeight:= .t.

      WITH OBJECT :name
         :aDataFont  := aFont1
         :aClrText   := { CLR_HBLUE, CLR_HRED }
      END

      WITH OBJECT :address
         :aDataFont  := aFont2
         :aClrText   := { nil, CLR_HRED, nil, CLR_GREEN }
      END

      WITH OBJECT :aCols[ 3 ]
         :nDataStrAlign := AL_LEFT + AL_BOTTOM
         :bStrImage     := { || "c:\fwh\bitmaps\olga1.jpg" }
         :aImgRect      := { nil, 0.3, 0.7, nil, "CIRCLE" }
      END
      //
      :CreateFromCode()
   END

   ACTIVATE DIALOG oDlg CENTERED

   RELEASE FONT oFont
   AEval( aFont1, { |o| If( o == nil,,o:End() ) } )
   AEval( aFont2, { |o| If( o == nil,,o:End() ) } )


return nil

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

This sample also shows how to compose text and image in the same cell using text alignment and DATA aImgRect

Re: FW 16.11: XBrowse multi-font/colored cells

PostPosted: Mon Nov 28, 2016 10:09 am
by Antonio Linares
very nice and useful :-)

Re: FW 16.11: XBrowse multi-font/colored cells

PostPosted: Mon Nov 28, 2016 2:08 pm
by joseluisysturiz
Saludos Mr. NAO, cuando puedas prodria hecharle un ojo a este tema,? saludos, gracias... :shock:

viewtopic.php?f=6&t=33221

Re: FW 16.11: XBrowse multi-font/colored cells

PostPosted: Mon Nov 28, 2016 6:23 pm
by TimStone
At one time, in my distant memory, it was possible to have a header with grouping in a browse. On some columns, there might just be the normal title, but it was possible to group several columns under a title. For example:

| | Section 1 |
Col 1 | Col 2 | Col 3 | Col 4 | Col 5 | Col 6

Can we do this in xBrowse currently ? Sorry ... not seeing it in the docs ...

Sorry ... it lines up in preview, but not on forum. Col 3, 4, 5 are under the group heading Section 1

Re: FW 16.11: XBrowse multi-font/colored cells

PostPosted: Mon Nov 28, 2016 6:37 pm
by nageswaragunupudi
Syntax:
oBrw:SetGroupHeader( cGrpHdr, [nFrom], [nUpto], [oFont], [nAlign] )

In the above case:

oBrw:SetGroupHeader( "Section 1", 3, 5 )

Re: FW 16.11: XBrowse multi-font/colored cells

PostPosted: Mon Nov 28, 2016 6:59 pm
by TimStone
Thank you.

Re: FW 16.11: XBrowse multi-font/colored cells

PostPosted: Tue Nov 29, 2016 3:11 pm
by nageswaragunupudi
joseluisysturiz wrote:Saludos Mr. NAO, cuando puedas prodria hecharle un ojo a este tema,? saludos, gracias... :shock:

viewtopic.php?f=6&t=33221

Yes, I will

Re: FW 16.11: XBrowse multi-font/colored cells

PostPosted: Tue Nov 29, 2016 4:25 pm
by joseluisysturiz
nageswaragunupudi wrote:
joseluisysturiz wrote:Saludos Mr. NAO, cuando puedas prodria hecharle un ojo a este tema,? saludos, gracias... :shock:

viewtopic.php?f=6&t=33221

Yes, I will


Muchas gracias... :shock: