FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin para Harbour/xHarbour TReport: lAutoFit
Posts: 211
Joined: Wed Jul 16, 2008 12:59 PM
TReport: lAutoFit
Posted: Mon Apr 21, 2014 09:30 PM
Amigos del foro:

Cansado de que mis reportes se deformen segun los diferentes tipos/MARCAS de impresoras: PdfCreator, HP DeskJet 305, Canon iP2700 y otros, decidi modificar la clase tReport de la siguiente forma:

Defini dos nuevas datas
Code (fw): Select all Collapse
   DATA lAutoFit, lReFit


El el metodo New() las inicialice
Code (fw): Select all Collapse
   ::lAutoFit  := .f.
   ::lReFit := .f.


En el metodo Activate() añadi el siguiente codigo (es el que hace el Fit (Ajuste), disminuyendo el tamaño de los FONT)
Code (fw): Select all Collapse
   if ::lReFit
      do while !::lStable .AND. ::nRptWidth > ( ::nWidth - ::nLeftMargin - ::nRightMargin )// .and. ( ::lScreen .or. ::lPrinter )
         Aeval(::aFont,;
               {|oFont,elem,oNewFont| ;
                 oNewFont:= TFont():New( oFont:cFaceName           ,;
                                         INT(oFont:nWidth * 0.999) ,;
                                         INT(oFont:nHeight * 0.999),;
                                         .F.                       ,;
                                         oFont:lBold               ,;
                                         oFont:nEscapement         ,;
                                         oFont:nOrientation        ,;
                                         oFont:nWeight             ,;
                                         oFont:lItalic             ,;
                                         oFont:lUnderline          ,;
                                         oFont:lStrikeOut          ,;
                                         oFont:nCharSet            ,;
                                         oFont:nOutPrecision       ,;
                                         oFont:nClipPrecision      ,;
                                         oFont:nQuality           ),;
                 oFont:End(),;
                 ::aFont[elem] := oNewFont })
         ::Stabilize()
      enddo 
   endif


En el metodo Stabilize() modifique el siguiente codigo
Code (fw): Select all Collapse
   if ::nRptWidth > ( ::nWidth - ::nLeftMargin - ::nRightMargin ) .and. ( ::lScreen .or. ::lPrinter )
      if ::lAutoLand .and. ;
         ! ::lIsNarrow .and. ;
         ::oDevice:GetOrientation() == PORTRAIT
         ::lStable   := .f.
         ::lIsNarrow := .t.
         return nil
      endif

      if ::lAutoFit         
         ::lStable   := .f.
         ::lReFit := .t.   
         return nil         
      endif                 

      if ! MsgYesNo( TXT_REPORT_WIDTH, TXT_ATENTION )
         ::lStable := .f.
         return nil
      endif
   endif


Y lo uso de la siguiente forma:
Code (fw): Select all Collapse
   oRpt:=TReport():New(...)
   oRpt:lAutoFit := .T.


y todo perfecto por el momento...

Por favor si alguien puede revisarlo y probarlo para ver si funciona bien o hay que mejorar algo.

Atentamente,

Rolando.
Cochabamba, Bolivia
Posts: 211
Joined: Wed Jul 16, 2008 12:59 PM
Re: TReport: lAutoFit
Posted: Mon Apr 21, 2014 09:33 PM
Hola amigos.

Nuevamente Yo (Rolando)

OJO: solo sirve para disminur el ANCHO.

Atentamente,

Rolando

Continue the discussion