TReport: lAutoFit

TReport: lAutoFit

Postby RSalazarU » Mon Apr 21, 2014 9: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: Select all  Expand view

   DATA lAutoFit, lReFit
 


El el metodo New() las inicialice
Code: Select all  Expand view

   ::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: Select all  Expand view

   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: Select all  Expand view

   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: Select all  Expand view

   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
RSalazarU
 
Posts: 211
Joined: Wed Jul 16, 2008 12:59 pm
Location: Cochabamba-Bolivia

Re: TReport: lAutoFit

Postby RSalazarU » Mon Apr 21, 2014 9:33 pm

Hola amigos.

Nuevamente Yo (Rolando)

OJO: solo sirve para disminur el ANCHO.

Atentamente,

Rolando
RSalazarU
 
Posts: 211
Joined: Wed Jul 16, 2008 12:59 pm
Location: Cochabamba-Bolivia


Return to FiveWin para Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 12 guests