FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin para Harbour/xHarbour posible mejora en Tprinter
Posts: 1516
Joined: Thu May 27, 2010 02:06 PM

posible mejora en Tprinter

Posted: Thu May 23, 2013 07:45 AM
Ser铆a bueno a帽adir este par de metodos a la clase tPrinter , quitar铆a algo de trabajo .

Code (fw): Select all Collapse
METHOD CmBox( nRow, nCol, nBottom, nRight, oPen ) CLASS TPrinter
local aTmp := ::CmRect2Pix({ nRow, nCol, nBottom, nRight })
聽 聽 聽 ::Box( aTmp[1], atmp[2], aTmp[3], aTmp[4], oPen ) 
Return nil

METHOD CmLine( nRow, nCol, nBottom, nRight, oPen ) CLASS TPrinter
local aTmp := ::CmRect2Pix({ nRow, nCol, nBottom, nRight })
聽 聽 聽 ::Line( aTmp[1], atmp[2], aTmp[3], aTmp[4], oPen ) 
Return nil
Posts: 44162
Joined: Thu Oct 06, 2005 05:47 PM

Re: posible mejora en Tprinter

Posted: Thu May 23, 2013 08:09 AM
Manuel,

gracias! Incluido para el pr贸ximo build :-)

He modificado tu c贸digo asi:

Code (fw): Select all Collapse
METHOD CmBox( nRow, nCol, nHeight, nWidth, oPen ) CLASS TPrinter

   local aTmp := ::CmRect2Pix( { nRow, nCol, nRow + nHeight - 1, nCol + nWidth - 1 } )
   
return ::Box( aTmp[ 1 ], aTmp[ 2 ], aTmp[ 3 ], aTmp[ 4 ], oPen )
 
METHOD CmLine( nRow, nCol, nHeight, nWidth, oPen ) CLASS TPrinter

   local aTmp := ::CmRect2Pix( { nRow, nCol, nRow + nHeight - 1, nCol + nWidth - 1 } )
   
return ::Line( aTmp[ 1 ], aTmp[ 2 ], aTmp[ 3 ], aTmp[ 4 ], oPen )
regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 1516
Joined: Thu May 27, 2010 02:06 PM

Re: posible mejora en Tprinter

Posted: Thu May 23, 2013 08:31 AM

Esa implementaci贸n me parece muy correcta , pero rompe un poco con el paralelismo con ::box() y ::line() que no usan alto y ancho sino cordenadas "finales" .
Para mi es mas c贸moda tu implementacion , pero ... 驴 Como lo ves ?

Posts: 44162
Joined: Thu Oct 06, 2005 05:47 PM

Re: posible mejora en Tprinter

Posted: Thu May 23, 2013 09:02 AM

Manuel,

Tienes raz贸n, es preferible implementarlo de la misma forma usada anteriormemte :-)

gracias!

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 1516
Joined: Thu May 27, 2010 02:06 PM

Re: posible mejora en Tprinter

Posted: Thu May 23, 2013 09:49 AM
mas mejora :

Code (fw): Select all Collapse
METHOD Pix2Cmtr(nRow, nCol) INLINE ;
                   ( nRow := ( nRow * 25.4 / ::nLogPixelX() ) / 10 ,;
                     nCol := ( nCol * 25.4 / ::nLogPixelY() ) /10  ,;
                     {nRow, nCol}                )
Posts: 44162
Joined: Thu Oct 06, 2005 05:47 PM

Re: posible mejora en Tprinter

Posted: Thu May 23, 2013 09:53 AM

Incluido tambien, gracias! :-)

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 1516
Joined: Thu May 27, 2010 02:06 PM

Re: posible mejora en Tprinter

Posted: Thu May 23, 2013 10:12 AM
Aun mas . Estas devuelven el punto que centra el texto en la p谩gina .
La longuitud del texto en cm.
imprime un texto con un box .
imprime un texto con un box centrado en la pagina ( ideal para titulos)
Ya esta completo .

Code (fw): Select all Collapse
METHOD CmtrGetTextWidth( cText, oFont ) INLINE ( ::GetTextWidth( cText, oFont ) * 25.4 / ::nLogPixelX() ) / 10

METHOD CmtrTextToCenter( cText, oFont ) INLINE 聽;
聽 聽 聽 聽(( ::nHorzSiZe() / 10 聽 ) /2 ) - 聽( ( ::GetTextWidth( cText, oFont ) * 25.4 / ::nLogPixelX() ) / 10) /2

METHOD TextInBoxCentered(nTop,cText,cmExRow,cmExCol,ofont,oPen,nColor ) INLINE 聽;
聽 聽 ::TextInBox( nTop, ::CmtrTextToCenter( cText, oFont ),cText,cmExRow,cmExCol,ofont,oPen,nColor )

METHOD TextInBox(nTop,nLeft,cText,cmExRow,cmExCol,oFont,oPen,nColor ) CLASS TPrinter

local cmTextWidth 聽 := ( ::GetTextWidth( cText, oFont ) * 25.4 / ::nLogPixelX() ) / 10
local cmTextHeight 聽:= ( ::GetTextHeight( cText, oFont ) * 25.4 / ::nLogPixelY() ) / 10

聽 聽 聽 聽::cmBox( nTop - cmExRow 聽, ;
聽 聽 聽 聽 聽 聽 聽 聽 聽nLeft - cmExCol ,;
聽 聽 聽 聽 聽 聽 聽 聽 聽nTop + cmTextWidth 聽+ cmExRow , ;
聽 聽 聽 聽 聽 聽 聽 聽 聽nLeft+ cmTextHeight + cmExCol , ;
聽 聽 聽 聽 聽 聽 聽 聽 聽oPen )

聽 聽 聽聽::cmsay( nTop,nLeft,cText,oFont,,nColor )

RETURN nil
Posts: 72
Joined: Tue Oct 02, 2012 04:36 PM

Re: posible mejora en Tprinter

Posted: Thu May 30, 2013 02:50 PM

Estimado....

que bueno estas nuevas mejoras.... podr铆as publica como te queda la clase arregada ?

gracias totales

david

Posts: 1144
Joined: Mon Feb 05, 2007 07:15 PM

Re: posible mejora en Tprinter

Posted: Thu May 30, 2013 03:15 PM

En s铆ntesis , si todo esto va de la mano con un TestPrn.Prg, es mas significativo.
saludos.

Cesar Cortes Cruz

SysCtrl Software

Mexico



' Sin +- FWH es mejor "
Posts: 1516
Joined: Thu May 27, 2010 02:06 PM

Re: posible mejora en Tprinter

Posted: Thu May 30, 2013 04:33 PM
davidObarrio wrote:Estimado....

que bueno estas nuevas mejoras.... podr铆as publica como te queda la clase arregada ?

gracias totales

david

Siento no poder enviar la clase tprinter pertenece a Fivetech y esta bajo licencia , por ello he publicar los trozos de c贸digo variados pero no la clase completa.

sysctrl2 wrote:En s铆ntesis , si todo esto va de la mano con un TestPrn.Prg, es mas significativo.
saludos.

Intentar茅 hacer un ejemplo sencillo entre hoy y ma帽ana , aunque ahora mismo estoy algo liado , si ma帽ana no publico el sample la cosa tendra que esperar a que vuelva pues salgo el sabado de viaje para toda la semana . Para la vuelta prometido que tienes algo .
Saludos.
Posts: 1516
Joined: Thu May 27, 2010 02:06 PM

Re: posible mejora en Tprinter

Posted: Thu May 30, 2013 04:56 PM
Aqui dejo un testprint7.prg rapido .No lo he testeado pues no estoy en windows pero tiene que funcionar si a帽adimos los metodos anteriores.

Code (fw): Select all Collapse
#include "FiveWin.ch"
 function Main()
    local oPrn, cText 
    local  oFont
    local cmLeft
    local cmTexto
  
  
   PRINTER oPrn PREVIEW

      DEFINE FONT oFont NAME "Courier New" SIZE 0, -10 OF oPrn
      DEFINE PEN  oPen1  STYLE PS_SOLID WIDTH 2 OF oPrn
     
      PAGE

        oPrn:TextInBox( 10,5,"Texto dentro de box",0.2,0.2,oFont,oPen1 )
        oPrn:TextInBoxCentered(8,"Texto Centrado en pagina dentro de box",0.2,0.2,ofont,oPen1 )

         cmLeft:= oPrn:CmtrTextToCenter( "Texto que debemos centrar", oFont )
        oPrn:cmSay(12,cmLeft,"Texto que debemos centrar",oFont )

        cmText:= oPrn:CmtrGetTextWidth( "Texto del que queremos saber su longuitud en centimetros", oFont )

        oPrn:cmSay(14,5,"El texto anterior mide "+AllTrim(Str(cmtext))+ " cm.",oFont )
                       
      ENDPAGE          
      
   ENDPRINTER
   
  
   oFont:End()

return
Posts: 44162
Joined: Thu Oct 06, 2005 05:47 PM

Re: posible mejora en Tprinter

Posted: Thu May 30, 2013 05:21 PM

Manuel,

A帽adido para FWH 13.05, gracias! :-)

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 1516
Joined: Thu May 27, 2010 02:06 PM

Re: posible mejora en Tprinter

Posted: Thu May 30, 2013 08:26 PM
Antonio , En el c贸digo existe un gazapo en el metodo TextInBox ( cambiado alto * ancho )
La forma correcta es esta :
Code (fw): Select all Collapse
METHOD TextInBox(nTop,nLeft,cText,cmExRow,cmExCol,oFont,oPen,nColor ) CLASS TPrinter

local cmTextWidth 聽 := ( ::GetTextWidth( cText, oFont ) * 25.4 / ::nLogPixelX() ) / 10
local cmTextHeight 聽:= ( ::GetTextHeight( cText, oFont ) * 25.4 / ::nLogPixelY() ) / 10

聽 聽 聽 聽::cmBox( nTop - cmExRow 聽, ;
聽 聽 聽 聽 聽 聽 聽 聽 聽nLeft - cmExCol ,;
聽 聽 聽 聽 聽 聽 聽 聽 聽nTop + cmTextHeight 聽+ cmExRow , ;
聽 聽 聽 聽 聽 聽 聽 聽 聽nLeft+cmTextWidth 聽+ cmExCol , ;
聽 聽 聽 聽 聽 聽 聽 聽 聽oPen )

聽 聽 聽 ::cmsay( nTop,nLeft,cText,oFont,,nColor )

RETURN nil


el testprint7 revisado :

Code (fw): Select all Collapse
#include "FiveWin.ch"
聽function Main()
聽 聽 local oPrn, cText 
聽 聽 local 聽oFont
聽 聽 local cmLeft
聽 聽 local cmTexto
聽 
聽 
聽 聽PRINTER oPrn PREVIEW

聽 聽 聽 DEFINE FONT oFont NAME "Courier New" SIZE 0, -10 OF oPrn
聽 聽 聽 DEFINE PEN 聽oPen1 聽STYLE PS_SOLID WIDTH 2 OF oPrn
聽 聽 聽
聽 聽 聽 PAGE

聽 聽 聽 聽 oPrn:TextInBox( 10,5,"Texto dentro de box",0.2,0.2,oFont,oPen1 )
聽 聽 聽 聽 oPrn:TextInBoxCentered(8,"Texto Centrado en pagina dentro de box",0.2,0.2,ofont,oPen1 )

聽 聽 聽 聽 聽cmLeft:= oPrn:CmtrTextToCenter( "Texto que debemos centrar", oFont )
聽 聽 聽 聽 oPrn:cmSay(12,cmLeft,"Texto que debemos centrar",oFont )

聽 聽 聽 聽 cmText:= oPrn:CmtrGetTextWidth( "Texto del que queremos saber su longuitud en centimetros", oFont )

聽 聽 聽 聽 oPrn:cmSay(14,5,"El texto anterior mide "+AllTrim(Str(cmtext))+ " cm.",oFont )
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽
聽 聽 聽 ENDPAGE 聽 聽 聽 聽 聽
聽 聽 聽 
聽 聽ENDPRINTER
聽 聽
聽 
聽 聽oFont:End()

return


el resultado del test :
Posts: 682
Joined: Tue Feb 14, 2006 09:48 AM

Re: posible mejora en Tprinter

Posted: Fri May 31, 2013 06:54 AM

Buen trabajo, gracias por tu tiempo y esfuerzo en mejorar las clases, y por compartir ese trabajo.

Saludos desde Mallorca
Biel Maim贸
http://bielsys.blogspot.com/

Continue the discussion