Class Printer

Class Printer

Postby Carles » Tue May 31, 2011 2:40 pm

Hi,

If i print this code, i've error in coordenates. Do you know why ?

Code: Select all  Expand view
// Printing in portrait and in landscape

#include "fivewin.ch"

#define PAD_LEFT            0
#define PAD_RIGHT           1
#define PAD_CENTER          2

function Main()
   local oPrn, oFont, oPen
   Local nLinI, nColI, nLinF, nColF
 

   PRINT oPrn NAME "Impresión en Vertical.." PREVIEW
      DEFINE FONT oFont NAME "Arial" SIZE 0, -10 BOLD OF oPrn
      DEFINE PEN oPen WIDTH  2                        OF oPrn
 
      oPrn:SetPage(9)    // A4
      oPrn:SetPortrait() //Vertical

      PAGE
         nLinI := 0
         nColI := 0
         nLinF := 28.5
         nColF := 20.0

         oPrn:Cmtr2Pix(@nLinI, @nColI)
         oPrn:cmtr2Pix(@nLinF, @nColF)

         oPrn:Box(nLinI, nColI, nLinF, nColF, oPen  )

         oPrn:cmSay( 0  ,  0  , "Superior Izquierda (0,0)" , oFont,,CLR_BLACK,,PAD_LEFT  )
         oPrn:cmSay( 0  , 10.5, "Superior Centro (0,10.5)" , oFont,,CLR_BLACK,,PAD_CENTER )
         oPrn:cmSay( 0  , 20.0, "Superior Derecha (0, 20)" , oFont,,CLR_BLACK,,PAD_RIGHT )
         oPrn:cmSay(28.0, 0   , "Inferior Izquierda (28,0)", oFont,,CLR_BLACK,,PAD_LEFT  )
         oPrn:cmSay(28.0, 10.5, "Inferior Centro (28,10.5)", oFont,,CLR_BLACK,,PAD_CENTER )
         oPrn:cmSay(28.0, 20.0, "Inferior Derecha (28,20)" , oFont,,CLR_BLACK,,PAD_RIGHT )
      ENDPAGE
   ENDPRINT

return nil


Compiled with 11.4
Salutacions, saludos, regards

"...programar es fácil, hacer programas es difícil..."

UT Page -> https://carles9000.github.io/
Forum UT -> https://discord.gg/bq8a9yGMWh
Skype -> https://join.skype.com/cnzQg3Kr1dnk
User avatar
Carles
 
Posts: 1134
Joined: Fri Feb 10, 2006 2:34 pm
Location: Barcelona

Re: Class Printer

Postby Enrico Maria Giordano » Tue May 31, 2011 2:48 pm

Try

Code: Select all  Expand view
oPrn:Say(oPrn:nVertRes(), oPrn:nHorzRes(), "Inferior Derecha (28,20)" , oFont,,CLR_BLACK,,PAD_RIGHT )


EMG
User avatar
Enrico Maria Giordano
 
Posts: 8712
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: Class Printer

Postby Carles » Wed Jun 01, 2011 7:39 am

Ciao Enrico,

Grazie per il tip :-). The problem is if i use for example the method ::CmSay() and i want to print exactly in 28,20, when i print it's in 27.6, 19.5. In topic viewtopic.php?f=6&t=21659&p=115222#p115222 are a good solution for this problem (at themoment...).

Grazie Enrico
Salutacions, saludos, regards

"...programar es fácil, hacer programas es difícil..."

UT Page -> https://carles9000.github.io/
Forum UT -> https://discord.gg/bq8a9yGMWh
Skype -> https://join.skype.com/cnzQg3Kr1dnk
User avatar
Carles
 
Posts: 1134
Joined: Fri Feb 10, 2006 2:34 pm
Location: Barcelona

Re: Class Printer

Postby Enrico Maria Giordano » Wed Jun 01, 2011 10:07 am

Yes, you have to add the unprintable margin offset.

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8712
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: Class Printer

Postby Carles » Wed Jun 01, 2011 11:50 am

Ciao Enrico,

I don't know if you have add offset but if you see for example method CmSay you add offset, but the result is wrong...

Code: Select all  Expand view
 METHOD CmSay( nRow, nCol, cText, oFont, nWidth, nClrText, nBkMode, nPad, lO2A );
       INLINE ;
       ( ::Cmtr2Pix( @nRow, @nCol ),;
         If( nWidth # Nil, ( ::Cmtr2Pix( 0, @nWidth ), nWidth += ::nYOffset ), nil ),;
         ::Say( nRow, nCol, cText, oFont, nWidth, nClrText, nBkMode, nPad, lO2A ) )


I don't understand nothing de nothing :roll:

[EDITED] I'm sorry. Now i see than only add offset if u specified parameter width... But dont undertand...
Salutacions, saludos, regards

"...programar es fácil, hacer programas es difícil..."

UT Page -> https://carles9000.github.io/
Forum UT -> https://discord.gg/bq8a9yGMWh
Skype -> https://join.skype.com/cnzQg3Kr1dnk
User avatar
Carles
 
Posts: 1134
Joined: Fri Feb 10, 2006 2:34 pm
Location: Barcelona

Re: Class Printer

Postby nageswaragunupudi » Thu Jun 02, 2011 12:26 am

Code: Select all  Expand view
nWidth += ::nYOffset

Applying offset to width does not appear to make sense.

Even then nYOffset has no relevance to horizontal dimension like width. Probably it was intended to be nXOffset.

What if "nWidth += ::nYOffset" is omitted?
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10631
Joined: Sun Nov 19, 2006 5:22 am
Location: India


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 113 guests