Print Problem with FWH2104

Re: Print Problem with FWH2104

Postby nageswaragunupudi » Tue Jun 08, 2021 11:38 am

vilian wrote:Mr Rao,

My previous version is FWH1905, may be it is the reason i have different results.


Thanks, I will check and get back.
Regards

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

Re: Print Problem with FWH2104

Postby Euclides » Tue Jun 08, 2021 12:16 pm

Hi! Sorry for jumping in...
With FWH 18.01 the printing works as Vilian expects.
Regrds, Euclides
User avatar
Euclides
 
Posts: 156
Joined: Wed Mar 28, 2007 1:19 pm

Re: Print Problem with FWH2104

Postby nageswaragunupudi » Tue Jun 08, 2021 12:21 pm

Euclides wrote:Hi! Sorry for jumping in...
With FWH 18.01 the printing works as Vilian expects.
Regrds, Euclides


Thanks
Regards

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

Re: Print Problem with FWH2104

Postby nageswaragunupudi » Wed Jun 09, 2021 3:35 pm

Mr. Vilian

I am sorry. You mentioned FWH1905 in your first post and it was my mistake to compare with FWH1909.

It is true that there was a change in the behavior of RoundBox() between FWH1906 and FWH1909, due to the wrong behavior of this method till 1906 as explained later. The methods Line() and Box() continue to function the same till now.

Syntax of methods Line(), Box() and RoundBox(), Arc(), Chord(), Ellipse(), Pie() have the first 4 parameters nTop, nLeft, nBottom, nRight.
Code: Select all  Expand view  RUN

METHOD Line(     nTop, nLeft, nBottom, nRight, oPen )
METHOD Box(      nRow, nCol, nBottom, nRight, oPen )
METHOD RoundBox( nRow, nCol, nBottom, nRight, nWidth, nHeight, oPen, nBGColor )
 


From the above syntax, we should expect the following code:
Code: Select all  Expand view  RUN

#include "fivewin.ch"

function Main()

   local oPrn, oPen
   local nTop, nLeft, nRight

   nLeft    :=  200
   nRight   := 3000

   PRINT oPrn PREVIEW
   DEFINE PEN oPen WIDTH 5 COLOR CLR_BLACK OF oPrn
   PAGE
   oPrn:Say(      300, nLeft, FWVERSION )
   oPrn:Line(     nTop := 500, nLeft, nTop + 300, nRight, oPen )
   oPrn:Box(      nTop += 400, nLeft, nTop + 300, nRight, oPen )
   oPrn:RoundBox( nTop += 400, nLeft, nTop + 300, nRight,  200, 200, oPen )
   ENDPAGE
   ENDPRINT

return nil
 

to produce a print image like this:
Image

But till FWH1906, this code produces a wrong image like this:
Image

Till FWH1906, RoundBox() was behaving wrongly by
- treating nTop as nLeft and nLeft as nTop
- treating nBottom as nRight and nRight as nBottom.

This is the only method with this wrong behaviour, where as all other methods like Line(),Box(),Arc(),Chord(),Pie(),Ellipse() were working correctly.

Note: The defined width of Pen also was being ignored, which was fixed in FWH1909.

This wrong behavior of RoundBox() was fixed in FWH1909. At that time, there was also a compelling requirement to make this method compatible both in syntax and functionality with the same methods across FWH like FWPDF( HaruPDF ), Window, etc.

In addition, these methods, Box(), RoundBox(), Pie() and Circle() were greatly enhanced.

Whatsnew.txt of FWH1909:
- Method RoundBox() was not working correctly. Fixed and enhanced. Methods
Box and Ellipse are also enhanced.

METHOD Box( nTop, nLeft, nBottom, nRight, [uPen], [uBrush], [aText], ;
[cUnits] )
METHOD RoundBox( nRow, nCol, nBottom, nRight, nWidth, nHeight, [uPen], ;
[uBrush], [aText], [cUnits] )
METHOD Ellipse( nTop, nLeft, nBottom, nRight, [uPen], [uBrush], [aText], ;
[cUnits] )
METHOD FillRect( aRect, uBrush, [cUnits] )


The enhancements included:
- Enables specifying the text to be printed inside the shape, without the need to use Say() separately.
- Enables background with solid colors, transparent colors, and images.
- Totally avoid complex calculations to convert physical units like INCHES/CM to pixels by specifying the units as the last parameter.

However, unfortunately, the backward compatibility was broken. This is regretted but keeping the overall considerations, this could not be avoided.

Please cooperate and modify this line in the above program like this:
Original code:
Code: Select all  Expand view  RUN

      IF lDrawBox
         oPrn:RoundBox(aPos[2],aPos[1],aPos[2]+aTam[1],aPos[1]+aTam[2],20,20,oPenSolid,If(lFill,CLR_HGRAY,NIL))
      ENDIF
 


modify as:
Code: Select all  Expand view  RUN

      IF lDrawBox
#if FW_VersionNo > 19060
         oPrn:RoundBox(aPos[1],aPos[2],aPos[1]+aTam[2],aPos[2]+aTam[1],20,20,oPenSolid,If(lFill,CLR_HGRAY,NIL))
#else
         oPrn:RoundBox(aPos[2],aPos[1],aPos[2]+aTam[1],aPos[1]+aTam[2],20,20,oPenSolid,If(lFill,CLR_HGRAY,NIL))
#endif
      ENDIF
 


Please cooperate.
Regards

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

Re: Print Problem with FWH2104

Postby nageswaragunupudi » Wed Jun 09, 2021 3:37 pm

One of the enhancements to methods Line(), Box() and RoundBox(), Arc(), Chord(), Ellipse(), Pie(), etc., is to specify the Units (INCHES/CM/MM) as the last parameter. This avoids the need to do complex calculations in our program for converting INCHES/CM/MM to pixels while printing.

Another enhancement to methods Box(), RoundBox(), and Ellipse() is to enable specifying the text to be printed inside the box. The text can be multi-line and multi-fonts. This avoids calculating the precise position and using Say() to print the text at the correct position.

Example Code:
Code: Select all  Expand view  RUN

   oPrn:RoundBox( 1.0, 1.0, 2.0, 7.5, 0.4, 0.4, oPen, CLR_YELLOW, ;
      { "HORIZONTAL" + CRLF + FWVERSION, { oFont, oFontS }, CLR_HRED }, "INCHES" )
 


All the coordinates are specified in "inches". The unit is specified as "INCHES" in the last parameter. The method converts the coordinates into pixels and prints the box. We need not calculate the coordinates by converting inches into pixels.

We provided a two-line text with two fonts. The method takes care of centering the multi-line text and prints using the specified fonts. This relieves us from the complex calculations to center the multi-font message inside the box.

This is a sample program:
Code: Select all  Expand view  RUN

#include "fivewin.ch"

function Main()

   local oPrn, oPen, oPen2, oFont, oFontV, oFontS, oFont14V, oBrush
   local cSyntax := "Syntax :" + CRLF + ;
         "RoundBox( nTop, nLeft, nBottom, nRight, nRndW, nRndH, oPen, onBack, aText, cUnits )"
   local cText := "aText :" + CRLF + "{ cText, oFont, nClrText, [cAlign] }"

   DEFINE BRUSH oBrush FILE "c:\fwh\bitmaps\backgrnd\browback.bmp"

   PRINT oPrn PREVIEW

   DEFINE PEN oPen WIDTH 3 COLOR CLR_HRED OF oPrn
   DEFINE PEN oPen2 WIDTH 1 COLOR CLR_BLACK OF oPrn
   DEFINE FONT oFontS NAME "ARIAL" SIZE 0,-12 OF oPrn
   DEFINE FONT oFont  NAME "ARIAL" SIZE 0,-20 OF oPrn
   DEFINE FONT oFontV NAME "ARIAL" SIZE 0,-20 BOLD NESCAPEMENT 900 OF oPrn
   DEFINE FONT oFont14V NAME "ARIAL" SIZE 0,-14 NESCAPEMENT 900 OF oPrn

   PAGE

   oPrn:RoundBox( 1.0, 1.0, 2.0, 7.5, 0.4, 0.4, oPen, CLR_YELLOW, ;
      { "HORIZONTAL" + CRLF + FWVERSION, { oFont, oFontS }, CLR_HRED }, "INCHES" )

   oPrn:RoundBox( 2.2, 1.0, 4.2, 2.0, 0.2, 0.2, oPen, CLR_GRAY,  ;
      { "VERTICAL" + CRLF + "TEXT", oFontV, CLR_YELLOW }, "INCHES" )

   oPrn:RoundBox( 5.9, 1.5, 7.1, 2.1, 0.1, 0.1, oPen2, CLR_HGRAY, ;
      { "Faturas", oFont14V, CLR_BLACK }, "INCHES" )

   oPrn:RoundBox( 7.1, 1.5, 8.3, 2.1, 0.1, 0.1, oPen2, CLR_HGRAY, ;
      { "Cálculo" + CRLF + "Imposto", oFont14V, CLR_BLACK }, "INCHES" )

   oPrn:RoundBox( 8.3, 1.5, 10.2, 2.1, 0.1, 0.1, oPen2, CLR_HGRAY, ;
      { "Transportador", oFont14V, CLR_BLACK }, "INCHES" )

   oPrn:RoundBox( 2.2, 3.0, 4.2, 7.5, 0.3, 0.3, oPen, oBrush, ;
            { cSyntax, oFont, CLR_BLACK }, "INCHES" )

   oPrn:RoundBox( 4.4, 3.0, 5.9, 7.5, 0.3, 0.3, oPen, CLR_WHITE, ;
            { cText, oFont, CLR_BLACK }, "INCHES" )

   ENDPAGE
   ENDPRINT

return nil


Image
Regards

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

Re: Print Problem with FWH2104

Postby vilian » Wed Jun 09, 2021 5:06 pm

Mr Rao,
Thank you for the great explanation about RoundBox() and other functions. For sure i will apply this in my code and improve it.
However, there is one problem yet. IF you try my example in both versions(1905/2104) you could see that the lines are stronger in the new version. I think it's happening as result of some change in TPEN class. Could you fix it too ?
Sds,
Vilian F. Arraes
vilian@vfatec.com.br
Belém-Pa-Brazil
User avatar
vilian
 
Posts: 978
Joined: Wed Nov 09, 2005 2:17 am
Location: Brazil

Re: Print Problem with FWH2104

Postby vilian » Wed Jun 09, 2021 5:50 pm

and what are the possible values to [cAlign] in aText ?

Is possible align the text to LEFT(Horizontal) and TOP(Vertical) ?
Sds,
Vilian F. Arraes
vilian@vfatec.com.br
Belém-Pa-Brazil
User avatar
vilian
 
Posts: 978
Joined: Wed Nov 09, 2005 2:17 am
Location: Brazil

Re: Print Problem with FWH2104

Postby nageswaragunupudi » Thu Jun 10, 2021 3:32 am

"" -> Center vertically and horizontally (default)
"T" -> Top - Center
"B" -> Bottom - Center
"L" -> Left - VCenter
"R" -> Right - VCenter
"TL" -> Top Left
and any combination of T or B with L or R

This notation is used in most methods and functions (printer and windows)
Regards

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

Re: Print Problem with FWH2104

Postby nageswaragunupudi » Thu Jun 10, 2021 6:23 am

vilian wrote:Mr Rao,
Thank you for the great explanation about RoundBox() and other functions. For sure i will apply this in my code and improve it.
However, there is one problem yet. IF you try my example in both versions(1905/2104) you could see that the lines are stronger in the new version. I think it's happening as result of some change in TPEN class. Could you fix it too ?


Till FWH1906, there was no effect of the clause "OF oPrn".
What we were getting is a normal pen for screen. Not for printer.

If you want the same Pen now, just remove the clause "OF oPrn"
It is from FWH1909, when we use oPrn (or any device), the width of the pen is calculated for that oPrn or Device.
Regards

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

Re: Print Problem with FWH2104

Postby vilian » Thu Jun 10, 2021 11:10 am

Thank you ;)
Sds,
Vilian F. Arraes
vilian@vfatec.com.br
Belém-Pa-Brazil
User avatar
vilian
 
Posts: 978
Joined: Wed Nov 09, 2005 2:17 am
Location: Brazil

Re: Print Problem with FWH2104

Postby vilian » Thu Jun 10, 2021 12:24 pm

Mr Rao,
Another thing. I'm trying to do this:

Code: Select all  Expand view  RUN
oPrn:RoundBox(aPos[1],aPos[2],aPos[1]+aTam[2],aPos[2]+aTam[1],20,20,::oPenSolid,,{cTexto,oFont,CLR_BLACK,cPadTexto})


But, the cTexto is printed using the last font used in the report, not with oFont that I passed. Do you know why ?
Sds,
Vilian F. Arraes
vilian@vfatec.com.br
Belém-Pa-Brazil
User avatar
vilian
 
Posts: 978
Joined: Wed Nov 09, 2005 2:17 am
Location: Brazil

Re: Print Problem with FWH2104

Postby nageswaragunupudi » Thu Jun 10, 2021 12:49 pm

But, the cTexto is printed using the last font used in the report, not with oFont that I passed. Do you know why ?

This is not possible. Text will be printed with the font provided in the array only.
Please check your program again and make sure that oFont in the array is really a font object and is not nil.
Regards

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

Re: Print Problem with FWH2104

Postby vilian » Thu Jun 10, 2021 5:47 pm

You are right ;)
Sds,
Vilian F. Arraes
vilian@vfatec.com.br
Belém-Pa-Brazil
User avatar
vilian
 
Posts: 978
Joined: Wed Nov 09, 2005 2:17 am
Location: Brazil

Previous

Return to FiveWin for Harbour/xHarbour

Who is online

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