nYoffset and nXoffset

nYoffset and nXoffset

Postby Silvio.Falconi » Fri Jan 12, 2024 3:36 pm

Could someone explain to me how to implement oPrn:nYoffset and oPrn:nXoffset in a print with a practical example?
what is the purpose of oPrn:nYoffset and oPrn:nXoffset ?
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
User avatar
Silvio.Falconi
 
Posts: 7033
Joined: Thu Oct 18, 2012 7:17 pm

Re: nYoffset and nXoffset

Postby Otto » Sun Jan 14, 2024 11:39 pm

nXoffset and nYoffset are only used in the methods:

New - Sets nXoffset and nYoffset based on printer settings.

Cmtr2Pix - Uses nXoffset and nYoffset to convert centimeters to pixels.

Mmtr2Pix - Uses nXoffset and nYoffset to convert millimeters to pixels.

Inch2Pix - Uses nXoffset and nYoffset to convert inches to pixels.

CmRect2Pix - Uses nXoffset and nYoffset to convert a rectangle from centimeters to pixels.

Pix2Mmtr - Uses nXoffset and nYoffset in the comment, but not directly in the code.

Pix2Inch - Uses nXoffset and nYoffset in the comment, but not directly in the code.

// Set the X and Y offsets for printing
oPrn:nXoffset := 10; // Set X offset to 10 units
oPrn:nYoffset := 20; // Set Y offset to 20 units

// Now, when you print something, it will start from the offset position

These methods use nXoffset and nYoffset to convert units of measurement and adjust the print position on the page.
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
User avatar
Otto
 
Posts: 6312
Joined: Fri Oct 07, 2005 7:07 pm

Re: nYoffset and nXoffset

Postby Silvio.Falconi » Mon Jan 15, 2024 7:41 am

Otto wrote:nXoffset and nYoffset are only used in the methods:

New - Sets nXoffset and nYoffset based on printer settings.

Cmtr2Pix - Uses nXoffset and nYoffset to convert centimeters to pixels.

Mmtr2Pix - Uses nXoffset and nYoffset to convert millimeters to pixels.

Inch2Pix - Uses nXoffset and nYoffset to convert inches to pixels.

CmRect2Pix - Uses nXoffset and nYoffset to convert a rectangle from centimeters to pixels.

Pix2Mmtr - Uses nXoffset and nYoffset in the comment, but not directly in the code.

Pix2Inch - Uses nXoffset and nYoffset in the comment, but not directly in the code.

// Set the X and Y offsets for printing
oPrn:nXoffset := 10; // Set X offset to 10 units
oPrn:nYoffset := 20; // Set Y offset to 20 units

// Now, when you print something, it will start from the offset position

These methods use nXoffset and nYoffset to convert units of measurement and adjust the print position on the page.


Thanks i saw when i use oprn:box and the coordinates are 0,0,2,20 It build a box more big of the Page

On default wich are the values of xoffset and y offset?
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
User avatar
Silvio.Falconi
 
Posts: 7033
Joined: Thu Oct 18, 2012 7:17 pm

Re: nYoffset and nXoffset

Postby Silvio.Falconi » Mon Jan 15, 2024 8:43 am

there is something not working

in my program I have this result

Let me start by saying I don't use xoffset and yoffset

and the values for the HP laserjet professional P1606dn printer are 94 and 94



Image



on another test I made now the same not use xoffset and yoffset
and the values for the HP laserjet professional P1606dn printer are 94 and 94
the result is different

Image

this is the test

Code: Select all  Expand view

#include "fivewin.ch"

Function test()
local oPrn
local cDescRep := "Trying xoffset and yOffset"
local aPrn := GetPrinters()

//-------------------------------------------------------//


local nWidth      := 20  +0.2
local nHeight     := 7.80 +0.5
local nGutter     := 0.5
local nRows       := 3
local nCols        := 1
local nPrintHeight   := nRows * ( nHeight + nGutter ) - nGutter
local nPrintWidth    := nCols * ( nWidth  + nGutter ) - nGutter
local nTopMargin     := 0
local nLeftMargin    := 0
local  nTop     := nTopMargin
local nLeft := nLeftMargin
local nPageH := 29.7      //A4
local nPageW := 21
//-------------------------------------------------------//

          IF nTopMargin= 0
                    nTopMargin     := ( nPageH - nPrintHeight ) / 2
                    nLeftMargin    := ( nPageW - nPrintWidth  ) / 2
                 ENDIF

            nTop  := nTopMargin
            nLeft := nLeftMargin

xbrowser aPrn



oPrn:=PrintBegin(cDescRep,.F.,.t.,,.T.)


? oPrn:nYoffset,oPrn:nXoffset   // give me 94,94

*           oPrn:nYoffset  :=0
*           oPrn:nXoffset  :=0

PageBegin()

    //first Box
      PrintBox(nTop, nLeft, nWidth, nHeight,0,0,20,1.2,oPrn)

    //second Box
      PrintBox(nTop, nLeft, nWidth, nHeight,1.2,0,20,7.8,oPrn)


  PageEnd()
PrintEnd()
return nil


//---------------------------------------------------------------------//
Function PrintBox(nRow, nCol, nWidth, nHeight,nX,nY,nLar,nAlt,oPrn)
local oFnt
local cFontname:= "Arial"
local nFontSize:= 12
local lBold:= .f.
local lItalic:= .f.
local X,Y,Z,K
local lBordo:= .t.
local nColorBordo:= CLR_BLACK
local nSizeBordo:=0.01
local nBackcolor :=CLR_WHITE
local cText:=""
local nColorFont:= CLR_BLACK
local nAlignOriz:= 1
local nAlignVert:= 1
local cUnit:= "CM"


       nRow     += 0.2
       nCol     += 0.2
       nWidth   -= 0.4
       nHeight  -= 0.4

       x:=  nRow+nX
       y:=  nCol+nY
       z:=  x+nAlt
       k:=  y+nLar



     //--------------------------------------------------------------------------//
      oFnt:=TFont():New(cFontName ,0,-nFontSize,.F.,lBold ,,,,lItalic,,,,,,,oPrn)
       IF lBordo
         oPrn:Box(X, Y, Z, K,;
                { nColorBordo, (nSizeBordo) }, nBackcolor, ;
                {cText,  oFnt, nColorFont, "TL" }, ;
                 cUnit )
      else
          oPrn:Box(X, Y, Z, K,;
                { CLR_WHITE, 1 }, CLR_WHITE, ;
                {cText,  oFnt, nColorFont, "TL" }, ;
                 cUnit )
        endif
         oFnt:end()
      //----------------------------------------------------------------------------//

  return nil
 



the following parameters are identical to both tests but behave differently

the Box values are also the same




Code: Select all  Expand view

local nWidth      := 20  +0.2
local nHeight     := 7.80 +0.5
local nGutter     := 0.5
local nRows       := 3
local nCols        := 1
local nPrintHeight   := nRows * ( nHeight + nGutter ) - nGutter
local nPrintWidth    := nCols * ( nWidth  + nGutter ) - nGutter

                    nTopMargin     := ( nPageH - nPrintHeight ) / 2
                    nLeftMargin    := ( nPageW - nPrintWidth  ) / 2

 


If I insert

oPrn:nYoffset := 150
oPrn:nXoffset := 120

I have this result


Image
Last edited by Silvio.Falconi on Mon Jan 15, 2024 9:00 am, edited 1 time in total.
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
User avatar
Silvio.Falconi
 
Posts: 7033
Joined: Thu Oct 18, 2012 7:17 pm

Re: nYoffset and nXoffset

Postby Otto » Mon Jan 15, 2024 8:56 am

Link in printer.prg and insert some msgInfo().
Try to find the differences.
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
User avatar
Otto
 
Posts: 6312
Joined: Fri Oct 07, 2005 7:07 pm

Re: nYoffset and nXoffset

Postby Silvio.Falconi » Mon Jan 15, 2024 9:00 am

Otto wrote:Link in printer.prg and insert some msgInfo().
Try to find the differences.



I update the message see the last picture
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
User avatar
Silvio.Falconi
 
Posts: 7033
Joined: Thu Oct 18, 2012 7:17 pm

Re: nYoffset and nXoffset

Postby Otto » Mon Jan 15, 2024 9:12 am

I do not see that method box supports: nXoffset or nYottset.
Look into printer.prg.
METHOD Box( nRow, nCol, nBottom, nRight, oPen ) INLINE ;
Rectangle( ::hDCOut, nRow, nCol, nBottom, nRight,;
If( oPen != nil, oPen:hPen, 0 ) )
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
User avatar
Otto
 
Posts: 6312
Joined: Fri Oct 07, 2005 7:07 pm

Re: nYoffset and nXoffset

Postby Silvio.Falconi » Mon Jan 15, 2024 9:47 am

Otto wrote:I do not see that method box supports: nXoffset or nYottset.
Look into printer.prg.
METHOD Box( nRow, nCol, nBottom, nRight, oPen ) INLINE ;
Rectangle( ::hDCOut, nRow, nCol, nBottom, nRight,;
If( oPen != nil, oPen:hPen, 0 ) )


it's not the problem of oPrn:Box, but I think you have an old version of Tprinter ( printer.prg) , so now the Box method of Tprinter is

Code: Select all  Expand view
METHOD Box( nTop, nLeft, nBottom, nRight, anoPen, noBrush, aText, cUnits )


I need to Know the parameters when the user select a printer, I think .....

many values are changed when the user prints because a printer is selected that returns certain values and changes the values entered into the test
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
User avatar
Silvio.Falconi
 
Posts: 7033
Joined: Thu Oct 18, 2012 7:17 pm

Re: nYoffset and nXoffset

Postby Silvio.Falconi » Mon Jan 15, 2024 10:19 am

I saw now on a oldest Tprinter class modified by Luis Krause

Vampire Path he fixed inverted values to ::nXOffset and ::nYOffset

probably fwhteannon modified these parameters taking into account Luis Krause's measures so the error in nxOffsett and nYOffset still remains
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
User avatar
Silvio.Falconi
 
Posts: 7033
Joined: Thu Oct 18, 2012 7:17 pm

Re: nYoffset and nXoffset

Postby Silvio.Falconi » Mon Jan 15, 2024 10:36 am

TRy this

if you make

aOffset = PrnOffset( oPrn )

xbrowser aOffset

and then

? oPrn:nYoffset,oPrn:nXoffset

give you different values


here

aOffset = PrnOffset( oPrn ) give me 0,0
oPrn:nYoffset,oPrn:nXoffset give me 94,94

on class Tprinter the offset values are take from the function PrnOffset( oPrn ) line 419/421
Code: Select all  Expand view

 if ::hDC != 0
      aOffset    = PrnOffset( ::hDC )
      ::nXOffset = aOffset[ 1 ]
      ::nYOffset = aOffset[ 2 ]



If I add to project tPrinter class and add at line 434

? ::nXOffset,::nYOffset

give me 94,94

then on my test.prg

I make
? ::nXOffset,::nYOffset

and it give me 0,0

WHY ?
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
User avatar
Silvio.Falconi
 
Posts: 7033
Joined: Thu Oct 18, 2012 7:17 pm

Re: nYoffset and nXoffset

Postby Silvio.Falconi » Mon Jan 15, 2024 11:04 am

what I want you to understand is that
if I print a Box here at school
I have to change the parameters of nXoffset and yOffset to 120,150 because I use the HP laserjet printer
you imagine that if my program is used in another school
with another printer that I don't know the parameters are wrong and the print comes off the sheet
I can't have any worries like that, the program should always work the same way
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
User avatar
Silvio.Falconi
 
Posts: 7033
Joined: Thu Oct 18, 2012 7:17 pm

Re: nYoffset and nXoffset

Postby Otto » Mon Jan 15, 2024 11:19 am

I understand but don't have a solution.
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
User avatar
Otto
 
Posts: 6312
Joined: Fri Oct 07, 2005 7:07 pm


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 48 guests