Como se pone texto en vertical en la cabecera de un xbrowse

Como se pone texto en vertical en la cabecera de un xbrowse

Postby Vladimir Zorrilla » Sat Mar 07, 2009 12:16 pm

Pue eso amigos
saben como

Mil gracias
ME INTERESA FW Y XHB POR SER OPEN SOURCE
Vladimir Zorrilla
 
Posts: 225
Joined: Tue Feb 28, 2006 4:25 pm
Location: PERU

Re: Como se pone texto en vertical en la cabecera de un xbrowse

Postby Daniel Garcia-Gil » Sat Mar 07, 2009 1:57 pm

Saludos..

Por favor revisa /FWH/samples/testxbr5.prg
User avatar
Daniel Garcia-Gil
 
Posts: 2365
Joined: Wed Nov 02, 2005 11:46 pm
Location: Isla de Margarita

Re: Como se pone texto en vertical en la cabecera de un xbrowse

Postby Vladimir Zorrilla » Sat Mar 07, 2009 9:53 pm

NO CUENTO CON ESE EJEMPLO

PODRIA ALGUIEN PUBLICARLO POR FAVOR
ME INTERESA FW Y XHB POR SER OPEN SOURCE
Vladimir Zorrilla
 
Posts: 225
Joined: Tue Feb 28, 2006 4:25 pm
Location: PERU

Re: Como se pone texto en vertical en la cabecera de un xbrowse

Postby Daniel Garcia-Gil » Sun Mar 08, 2009 1:42 am

Saludos Vladimir

te dejo esta pequeña funcion que he elaborado para ese fin
fVerticalTxt( cText, nSpa, nAlign )

cText, es el texto a colocar en vertical, puedes usar varias palabras

nSpa es la catidad de espacios en blanco que separan las columnas, si el texto vertical tubiese mas de una columna

nAlign es la justificacion 0=TOP, 1=BOTTOM y 2=CENTER

esta funcion tiene como limitante ( al momento de usar varias palabras ) el tipo de letra a usar, debes usas un letra donde todos sus caracteres tengan el mismo ancho

dejo un screenshot y el link para que descargues el ejemplo, dejo el codigo del mismo

http://www.sitasoft.com/fivewin/test/testvhd.rar

Image

Code: Select all  Expand view
#include "fivewin.ch"
#include "xbrowse.ch"



function main

   local oWnd
   local oBrw
   local aArray
   local oFont
   
   aArray := { { "one", "two", "three", "four" },;
               { "one", "two", "three", "four" },;
               { "one", "two", "three", "four" },;
               { "one", "two", "three", "four" },;
               { "one", "two", "three", "four" } }
 
   define font oFont name "courier new"
                                                         
   define window oWnd title "Test xBrowse Verticar Header" from 0,0 to 400,800 pixel
   
   @ 0,0 xbrowse oBrw array aArray of oWnd font oFont ;
   head { fVerticalTxt( "Vertical Text in xBrowse Header TOP ALIGN", 2,0 ),;
   fVerticalTxt( "Vertical Text in xBrowse Header BOTTOM ALIGN", 2,1 ),;
   fVerticalTxt( "Vertical Text in xBrowse Header CENTER ALIGN", 2,2 ),;
   fVerticalTxt( "OneLine" ) } ;
   sizes {180,180,180,180} ;
   cols { 1,2,3,4 }
   
   oBrw:aCols[ 1 ]:nHeadstrAlign := 0
   oBrw:aCols[ 2 ]:nHeadstrAlign := 1
   oBrw:aCols[ 3 ]:nHeadstrAlign := 2
   oBrw:aCols[ 4 ]:nHeadstrAlign := 2
   
   
   oBrw:nHeaderLines := 8
   
   oBrw:createfromcode()

   oWnd:oClient := oBrw

   
   activate window oWnd

return nil

function fVerticalTxt( cText, nSpa, nAlign )
   local aOutPut
   local aWord := {}
   local cWord
   local cOut := ""
   local nTotalWord := 0
   local nRow, nCol, n, i, j
   local nCount, nHalf
   local nOffSet:= 0
   local nMaxWord := 0
   
   default nAlign := 1,;
           nSpa := 1

   while nOffSet < len( cText )
      cWord = cStrWord( cText, @nOffset, " " )
      if cWord == " "
         loop
      else
         nMaxWord := max( nMaxWord, len( cWord ) )
         aadd( aWord, cWord )
         nTotalWord++
      endif
   end
 
   aOutPut := array( nTotalWord, nMaxWord )
 
   nRow := 1
   nCol := 0
   
   for n = 1 to nTotalWord
 
      if nCol + len( aWord[ n ] )  > nMaxWord
         nCol := 1
         nRow++
      else
         nCol++
      endif
   
      for i = 1 to len( aWord[ n ] )
        aOutPut[ nRow, nCol ] = substr( aWord[ n ], i, 1 )
        nCol++
      next
     
   next

   nCount := 0
   for n = 1 to nRow
      i = nMaxWord
      while aOutPut[ n,i-- ] == nil
         nCount++
      end
      if nCount > 0
 
         do case
            case nAlign = 1
               for j = nMaxWord to nCount + 1 step - 1
                  aOutPut[ n,j ] := aOutPut[ n,j-nCount ]
               next
               for j = 1 to nCount
                  aOutPut[ n,j ] := NIL
               next
            case nAlign = 2
               nHalf := (int( nMaxWord / 2 ) - round( ( nMaxWord - nCount )/2, 0 ) )
               if nCount > 0
                  for j = nMaxWord - nHalf  to 1 step - 1
                     aOutPut[ n,j ] := if( j - nHalf < 1, NIL, aOutPut[ n,j - nHalf ] )
                  next
               endif
         endcase
      endif
      nCount := 0
   next

 
  for n = 1 to nMaxWord
     for i = 1 to nRow
        cOut += if ( aOutPut[ i,n ] == NIL, " ", aOutPut[ i,n ] ) + if ( i != nRow, space( nSpa ), "" )
     next
     cOut += CRLF
  next
 
return cOut
User avatar
Daniel Garcia-Gil
 
Posts: 2365
Joined: Wed Nov 02, 2005 11:46 pm
Location: Isla de Margarita

Re: Como se pone texto en vertical en la cabecera de un xbrowse

Postby Daniel Garcia-Gil » Sun Mar 08, 2009 1:04 pm

He descubierto que obtenemos un mejor resultado cambiando esta linea...

Code: Select all  Expand view
nHalf := (int( nMaxWord / 2 ) - round( ( nMaxWord - nCount )/2, 0 ) )


por esta

Code: Select all  Expand view
nHalf := (round( ( nMaxWord )/2, 0 ) - round( ( nMaxWord - nCount )/2, 0 ) )


mis disculpas por el detalle
User avatar
Daniel Garcia-Gil
 
Posts: 2365
Joined: Wed Nov 02, 2005 11:46 pm
Location: Isla de Margarita


Return to FiveWin para Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 56 guests