New FWH 19.03

Re: New FWH 19.03

Postby nageswaragunupudi » Thu Apr 11, 2019 8:01 am

And, most importantly, the problem DOES EXIST WITH SAYTEXT( )


We kept aside all other works and did extensive tests. The samples we produced above prove that the alleged problem does NOT exist with SayText() whether used as a command or direct call to the method.

What I have found is if you use @SayText( ) it does change the color default for @Say( ).


We tested again. This is a sample to show that use of color with SayText() does NOT change the color default for the method Say()
Code: Select all  Expand view  RUN

#include "fivewin.ch"

function Main()

   local oPrn
   local oBrushRed, oBrushGrn
   local oFont, oFont2, oFont3, oFont4

   DEFINE BRUSH oBrushRed COLOR CLR_RED
   DEFINE BRUSH oBrushGrn COLOR CLR_HGREEN

   PRINT oPrn PREVIEW

   DEFINE FONT oFont  NAME "TAHOMA"   SIZE 0,-20 BOLD OF oPrn
   DEFINE FONT oFont2 NAME "VERDANA"  SIZE 0,-14 OF oPrn
   DEFINE FONT oFont3 NAME "Segoe UI" SIZE 0,-16 OF oPrn
   DEFINE FONT oFont4 NAME "ARIAL NARROW" SIZE 0,-10 OF oPrn

   PAGE

   oPrn:Say(  500,400, "Say(): Default color", oFont )
   oPrn:Say(  800,400, "Say(): CLR_HRED"     , oFont,, CLR_HRED )
   oPrn:Say( 1100,400, "Say(): Default color", oFont )
   oPrn:Say( 1400,400, "Say(): Default color", oFont )

   oPrn:SayText( 1700, 400, "SayText(): BLUE on GREEN",  3000,200, oFont, , CLR_BLUE, oBrushGrn )

   oPrn:Say( 2000,400, "Say(): Default color", oFont )

   oPrn:SayText( 2300, 400, "SayText(): YELLOW on HRED", 3000,200, oFont, , CLR_YELLOW, oBrushRed )

   oPrn:Say( 2600,400, "Say(): Default color", oFont )

   oPrn:SayText( 2900, 400, "SayText(): DEFAULT COLOR",  3000,200, oFont )

   oPrn:Say( 3200,400, "Say(): Default color", oFont )
   oPrn:Say( 3500,400, "Say(): " + FWVERSION,  oFont )

   ENDPAGE
   ENDPRINT

   RELEASE FONT oFont, oFont2, oFont3
   RELEASE BRUSH oBrushRed, oBrushGrn

return nil
 


Image

Please let us know if we are missing something.
Regards

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

Re: New FWH 19.03

Postby nageswaragunupudi » Thu Apr 11, 2019 8:15 am

I can fix the problem in my code by using @SayText( ) throughout when mixing in color.


If you like to use :SayText() for its additional features, you may do so in your future programs.

But please do not waste your time in modifying your existing programs by replacing Say()s with SayText()s only for the purpose of color.

We assure you that very soon we will provide you with a solution to use :Say() method itself to get what you wanted. Please give us a couple of days.
Regards

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

Re: New FWH 19.03

Postby Silvio.Falconi » Thu Apr 11, 2019 9:01 am

Mr Nages,
I'm using a new method on Printer Class ( not mine) for Justity a text
METHOD JustifyText( cText, nLen, oFont, lPixel )

Code: Select all  Expand view  RUN
METHOD JustifyText( cText, nLen, oFont, lPixel ) CLASS TPrinter

   local cAuxi:=ALLTRIM(cText), nLenPixel:=0, nSpace:=1

   local aWords:={}, i:=0, cSubst:="", cSpell:="", lDone:=.T.

   for i = 1 to len(cText)

      cSubst :=  SUBST(cText,i,1)

      if cSubst = " "

         aadd(aWords,cSpell)

         cSpell = ""

      endif

      cSpell +=  cSubst

   next

   if .not.empty(cSpell)

      aadd(aWords,cSpell)

   endif

   if len(aWords)=0 .OR. len(aWords)=1

      return cText

   endif

   if lPixel = nil .or. .not.lPixel

      nLenPixel = Max( 0, ( nLen * 10 * ::nHorzRes() / ::nHorzSize() ) - ::nXoffset )

   else

      nLenPixel = nLen

   endif

   while .T.

      cAuxi = ""

      lDone = .F.

      for i = 1 to len(aWords)

         IF i # len(aWords)

            cAuxi += aWords[ i ] + SPACE(nSpace)

         ENDIF

      next

      IF ::GetTextWidth( cAuxi, oFont ) >= nLenPixel

         lDone = .T.

         EXIT

      ENDIF

      nSpace ++

   enddo

   IF lDone

      cText = cAuxi

   ENDIF

return cText

 



How I can use it with new command PRINT TO oPrn TEXT ?
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: 7075
Joined: Thu Oct 18, 2012 7:17 pm

Re: New FWH 19.03

Postby nageswaragunupudi » Thu Apr 11, 2019 10:02 am

We will add justify to the Say methods. Thanks
But the above solution is not enough.
We need to be pixel accurate and handle multi-line text. The logic will be more complex.
Regards

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

Re: New FWH 19.03

Postby nageswaragunupudi » Thu Apr 11, 2019 2:11 pm

oPrn:Say( nRow, nCol, cText, oFont, nWidth, nClrText, nBkMode, nPad )

I can say, that after i use a certain color for text, this color are stay in further oPrn:say()s! If i will back to black i must this explicit define in the next oPrn:say()!


Please also see:
viewtopic.php?f=3&t=36920

If the method Say() is called with the parameters nClrText and/or nBkMode, the text color an bkmode are not reset when the method ends. The new text color and bkmode remain as defaults for all subsequent says, till they are reset either by another call to Say() method with a different color and bkmode or explicitly changed by SetTextColor() / SetBkMode().

In other words, calling Say() with a text color, switches the color for the current and all subsequent says, rather than using the color for that particular say only.

This is the most used method of TPrinter class.

This behavior has been there all the years from the time the method was created. All the programmers who used the method with colors knew this behavior and made their programs subject to this behavior.

Changing this behavior now may be convenient for those starting to use colors now, but might affect the behaviour of many existing applications.

Therefore this behavior will continue to be the default behavior so the existing applications are not affected.

A new CLASSDATA lResetSayColors INIT .f.
is provided now. If this is set to .T. by calling
TPrinter():lResetSayColos := .t.
in the beginning of the application, Say() method will now reset the color to the old color when exiting. The text color applies to that particual Say only and does not change the default.

Revised say method:
Code: Select all  Expand view  RUN

METHOD Say( nRow, nCol, cText, oFont, nWidth, nClrText, nBkMode, nPad ) ;
   CLASS TPrinter

   local nTemp, nClrTextOld, nOldBkMode

   if ::hDC = 0
      return nil
   endif

   DEFAULT oFont := ::oFont ,;
       nBkMode := 1     ,;
       nPad    := ::nPad

   if oFont != nil
      oFont:Activate( ::hDCOut )
   endif

   nOldBkMode := SetbkMode( ::hDCOut, nBkMode )         // 1,2 transparent or Opaque

   if nClrText != nil
      nClrTextOld  := SetTextColor( ::hDCOut, nClrText )
   endif

   if Empty( nWidth )
      do case
         case nPad == PAD_RIGHT
              nCol := Max( 0, nCol - ::GetTextWidth( cText, oFont ) )
         case nPad == PAD_CENTER
              nCol := Max( 0, nCol - ( ::GetTextWidth( cText, oFont ) / 2 ) )
      endcase
      SetTextAlign( ::hDCOut, TA_LEFT )
      TextOut(  ::hDCOut, nRow, nCol, cText )
   else
      do case
         case nPad == PAD_RIGHT
              nTemp := nCol + nWidth
              SetTextAlign( ::hDCOut, TA_RIGHT )
         case nPad == PAD_CENTER
              nTemp := nCol + ( nWidth / 2 )
              SetTextAlign( ::hDCOut, TA_CENTER )
         otherwise
              nTemp := nCol
              SetTextAlign( ::hDCOut, TA_LEFT )
      endcase
      ExtTextOut( ::hDCOut, nRow, nTemp,;
                  { nRow, nCol, nRow + oFont:nHeight * 1.5, nCol + nWidth },;
                  cText, ETO_CLIPPED )
   endif

   if oFont != nil
      oFont:DeActivate( ::hDCOut )
   endif

   if ::lResetSayColors
      if nClrTextOld != nil
         SetTextColor( ::hDCOut, nClrTextOld )
      endif
      SetBkMode( ::hDCOut, nOldBkMode )
   endif

return nil
 



Usage:
Code: Select all  Expand view  RUN

#include "fivewin.ch"

function Main()

   local oPrn, oFont

   //
   TPrinter():lResetSayColors := .t.   // New class data
   //

   PRINT oPrn PREVIEW

   DEFINE FONT oFont  NAME "TAHOMA"   SIZE 0,-20 BOLD OF oPrn

   PAGE

   oPrn:Say(  500,400, "Say(): Default color", oFont )
   oPrn:Say(  800,400, "Say(): CLR_HRED"     , oFont,, CLR_HRED )
   oPrn:Say( 1100,400, "Say(): Default color", oFont )
   oPrn:Say( 1400,400, "Say(): Default color", oFont )
   oPrn:Say( 1700,400, "Say(): CLR_GREEN",     oFont,, CLR_GREEN )
   oPrn:Say( 2000,400, "Say(): Default color", oFont )

   ENDPAGE
   ENDPRINT

   RELEASE FONT oFont

return nil
 


Image
Regards

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

Re: New FWH 19.03

Postby TimStone » Thu Apr 11, 2019 4:39 pm

Good Morning,

Seeing the behavior in my application, and accepting the results of your testing, puzzles me, but at this time I only have to focus on the one one printout ( Invoice ) to which I added color. I realize you are working on a solution, and I appreciate that, but since it's just the one .prg file of concern right now, the best way is to use SayText( ) consistently throughout ( rather than have a mix ).

I missed the previous comments about memo printing. That is a huge benefit and I will work with that today. Thanks for pointing it out in this thread. It applies here and would allow me to eliminate a lot of code lines.

Tim
Tim Stone
http://www.MasterLinkSoftware.com
http://www.autoshopwriter.com
timstone@masterlinksoftware.com
Using: FWH 23.10 with Harbour 3.2.0 / Microsoft Visual Studio Community 2022-24 32/64 bit
User avatar
TimStone
 
Posts: 2945
Joined: Fri Oct 07, 2005 1:45 pm
Location: Trabuco Canyon, CA USA

Re: New FWH 19.03

Postby TimStone » Thu Apr 11, 2019 5:21 pm

Looking at printing text from a memo field.

I'm getting no output from these lines of code. What is incorrect ?

Code: Select all  Expand view  RUN

   cDisText :=  "This is a great piece of memo text.  I'd like it to print in condensed mode."
   oPrn:SayText( nRow, 2 * nCsp, cDisText, 7.0 ,nil, oFcond, , CLR_RED, nil , "INCHES" )
 


Using the format previously ( parsing and printing with memoline ), oFcond is fine as a condensed print font. (. DEFINE FONT oFcond NAME "Courier New" SIZE 0, -8 OF oPrn )

Thanks
Tim Stone
http://www.MasterLinkSoftware.com
http://www.autoshopwriter.com
timstone@masterlinksoftware.com
Using: FWH 23.10 with Harbour 3.2.0 / Microsoft Visual Studio Community 2022-24 32/64 bit
User avatar
TimStone
 
Posts: 2945
Joined: Fri Oct 07, 2005 1:45 pm
Location: Trabuco Canyon, CA USA

Re: New FWH 19.03

Postby TimStone » Thu Apr 11, 2019 10:23 pm

Here is a very unusual situation, and I see it when using SayText( ).

Code: Select all  Expand view  RUN

               nRow += 2 * nRsp
               oPrn:Box( nRow, nCsp * 1, nRow + nRsp, 83 * nCsp, oPben )
               oPrn:SayText( nRow, 5 * nCsp, MemoLine( oPrintInspect:svcdes, 70, 1,, .T. ),,, oFbold )
               nRow += 2 * nRsp
 


Normally this prints fine. However, if I get to the bottom of a page ( a page is 66 rows, and I'm talking about line 59 ), the box prints perfectly, but only about the top 1/5th of the text ( which is in the box ) prints. I'm refering to the the top 1/5th of the height of the text.

As I said, if it falls higher on the page, it is perfect. It only occurs toward the bottom 1.4 inches of the paper. Also, if I print a SayText( ) to the left with a colored text ( ie. white on black background ) that prints perfectly. It is very puzzling.

I suspect a printer setting rather than an issue with the code ... but would certainly appreciate any suggestions for me to investigate.
Tim Stone
http://www.MasterLinkSoftware.com
http://www.autoshopwriter.com
timstone@masterlinksoftware.com
Using: FWH 23.10 with Harbour 3.2.0 / Microsoft Visual Studio Community 2022-24 32/64 bit
User avatar
TimStone
 
Posts: 2945
Joined: Fri Oct 07, 2005 1:45 pm
Location: Trabuco Canyon, CA USA

Re: New FWH 19.03

Postby nageswaragunupudi » Thu Apr 11, 2019 11:52 pm

TimStone wrote:Looking at printing text from a memo field.

I'm getting no output from these lines of code. What is incorrect ?

Code: Select all  Expand view  RUN

   cDisText :=  "This is a great piece of memo text.  I'd like it to print in condensed mode."
   oPrn:SayText( nRow, 2 * nCsp, cDisText, 7.0 ,nil, oFcond, , CLR_RED, nil , "INCHES" )
 


Using the format previously ( parsing and printing with memoline ), oFcond is fine as a condensed print font. (. DEFINE FONT oFcond NAME "Courier New" SIZE 0, -8 OF oPrn )

Thanks


Please make sure that all of Row, Col, Width and Height are expressed in the same units (inches in this case). I doubt that probably nRow and nCsp are in pixels.

Please see this test program:
Code: Select all  Expand view  RUN
#include "fivewin.ch"

function Main()

   local oPrn, oFcond, cDisText, nRow, ncSp, nLastRow

   PRINT oPrn PREVIEW

   DEFINE FONT oFcond NAME "Courier New" SIZE 0, -8 OF oPrn

   PAGE

   nRow  := 1.5
   ncSp  := 0.5

   cDisText :=  "This is a great piece of memo text.  I'd like it to print in condensed mode."
   nLastRow := oPrn:SayText( nRow, 2 * nCsp, cDisText, 2.0 ,nil, oFcond, , CLR_HRED, nil , "INCHES" )

   //
   cDisText := "I missed the previous comments about memo printing. That is a huge benefit " + ;
               "and I will work with that today. Thanks for pointing it out in this thread. " + ;
               "It applies here and would allow me to eliminate a lot of code lines."

   nRow     := nLastRow + 0.2
   nLastRow := oPrn:SayText( nRow, 2 * nCsp, cDisText, 2.0 ,nil, oFcond, , CLR_HRED, nil , "INCHES" )


   //
   cDisText :=  "This is a great piece of memo text.  I'd like it to print in condensed mode."
   nRow     := nLastRow + 0.2
   nLastRow := oPrn:SayText( nRow, 2 * nCsp, cDisText, 2.0 ,nil, oFcond, , CLR_HRED, nil , "INCHES" )


   ENDPAGE
   ENDPRINT

   RELEASE FONT oFcond

return nil
 


Image

I am sorry, I am not able to react immediately to your next posting.
Regards

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

Re: New FWH 19.03

Postby TimStone » Fri Apr 12, 2019 1:14 am

OK ... so I got the text output working. That is nice. However, here is the complication. I have a long "disclaimer" on this invoice. It starts on page two but will need to run over to page 3. Since I print one line at a time with the memoline output, after each line I can check to see if I've reached the maximum lines per page, and then I can do a page eject, print the new header, and continue the disclaimer text.

To do this with SayText( ) we would need another parameter to call a function after each line is printed which can check the line count and print the header. Here is what I call currently:

Code: Select all  Expand view  RUN

FUNCTION WOPAGEHEAD( oPrn, aHead )

   IF nRow >= nPageRows * nRsp
      ENDPAGE
      PAGE
      nPageCount++
      WOHEADER( oPrn, aHead )
   ENDIF

RETURN NIL
 


The function WOHEADER( ) actually prints the header on the new page and sets nRow.

Perhaps this can be for a future update ?
Tim Stone
http://www.MasterLinkSoftware.com
http://www.autoshopwriter.com
timstone@masterlinksoftware.com
Using: FWH 23.10 with Harbour 3.2.0 / Microsoft Visual Studio Community 2022-24 32/64 bit
User avatar
TimStone
 
Posts: 2945
Joined: Fri Oct 07, 2005 1:45 pm
Location: Trabuco Canyon, CA USA

Re: New FWH 19.03

Postby nageswaragunupudi » Fri Apr 12, 2019 4:45 am

Please change this line
Code: Select all  Expand view  RUN
              oPrn:SayText( nRow, 5 * nCsp, MemoLine( oPrintInspect:svcdes, 70, 1,, .T. ),,, oFbold )
 

by specifying both width and height.
Similar to the following line
Code: Select all  Expand view  RUN
 oPrn:SayText( nRow, 5 * nCsp, MemoLine( oPrintInspect:svcdes, 70, 1,, .T. ), 75 * nCsp, nRsp, oFbold )
 

You may decide the actual width and height required.
Regards

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

Re: New FWH 19.03

Postby kajot » Sat Apr 13, 2019 6:32 am

to Antonio

could You send me
Fivehcm.lib , Fivehmx.lib

to FWH v.19.03
I am using xHB.com
xHarbour 1.2.3 Intl. (SimpLex) (Build 20181212)

my email
inkom@hot.pl
best regards
kajot
User avatar
kajot
 
Posts: 339
Joined: Thu Nov 02, 2006 6:53 pm
Location: Poland

Re: New FWH 19.03

Postby kajot » Sat Apr 13, 2019 6:38 am

to Antonio

I am using
xHB.com with Pelles ISO C Compiler, Version 3.00.0
best regards
kajot
User avatar
kajot
 
Posts: 339
Joined: Thu Nov 02, 2006 6:53 pm
Location: Poland

Re: New FWH 19.03

Postby Antonio Linares » Sat Apr 13, 2019 10:23 am

Kajot,

They are included in FWH 19.03 standard setup
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42122
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: New FWH 19.03

Postby kajot » Sat Apr 13, 2019 11:23 am

ok

if for bcc58 is it for too
best regards
kajot
User avatar
kajot
 
Posts: 339
Joined: Thu Nov 02, 2006 6:53 pm
Location: Poland

PreviousNext

Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 39 guests