HMG Manual on PRINT RECTANGLE Miss Leading ?

Moderator: Rathinagiri

Post Reply
User avatar
hmgchang
Posts: 273
Joined: Tue Aug 13, 2013 4:46 am
Location: Indonesia

HMG Manual on PRINT RECTANGLE Miss Leading ?

Post by hmgchang »

Dear All,

Maybe this info will be useful, on HMG DOC :
HmgManual_PrintRectangle.JPG
HmgManual_PrintRectangle.JPG (104.72 KiB) Viewed 4875 times
I tried this :

Code: Select all

@10, 10 PRINT RECTANGLE ;
  TO 20, 20 PENWIDTH 0.1 ;
  ROUNDED FILLED
I got an compile error !
To make it work, change "ROUNDED FILLED" to "FILLED ROUNDED"

Code: Select all

@10, 10 PRINT RECTANGLE ;
  TO 20, 20 PENWIDTH 0.1 ;
  FILLED ROUNDED
Maybe its good to put the FILLED before ROUNDED in HMG Doc.

BTW, is it possibly to have a TRANSPARANT or NO-FILL rectangle ?

TIA

best rgds,
Chang
Just Hmg It !
User avatar
Pablo César
Posts: 4059
Joined: Wed Sep 08, 2010 1:18 pm
Location: Curitiba - Brasil

HMG Manual on PRINT RECTANGLE Miss Leading ?

Post by Pablo César »

hmgchang wrote:To make it work, change "ROUNDED FILLED" to "FILLED ROUNDED"
Thank you Mr. Chang for your reporting.

@ Rathi / Claudio, IMHO this could be solved by changing:

1. Changing "ROUNDED" differantiating as command in files:
  • C:\hmg.3.3.0\INCLUDE\i_print.ch
    C:\hmg.3.3.0\INCLUDE\hmg_hpdf.ch
Change this:
#xcommand @ <Row> , <Col> HPDFPRINT RECTANGLE TO <ToRow> , <ToCol> ;
        [ <lwidth : PENWIDTH> <Width> ] ;
        [ <lcolor : COLOR> <aColor> ] ;
        [ <lfilled: FILLED> ] ;
        ROUNDED ;
        [ CURVE <nCurve> ] ;
        => ;
        _HMG_HPDF_ROUNDRECTANGLE ( <Row> , <Col> , <ToRow> , <ToCol> , <Width> , <aColor>\[1\] , <aColor>\[2\] , <aColor>\[3\] , <.lwidth.> , <.lcolor.>, <.lfilled.>, <nCurve> )

For this one:
#xcommand @ <Row> , <Col> HPDFPRINT RECTANGLE ROUNDED TO <ToRow> , <ToCol> ;
        [ <lwidth : PENWIDTH> <Width> ] ;
        [ <lcolor : COLOR> <aColor> ] ;
        [ <lfilled: FILLED> ];
        [ CURVE <nCurve> ];
        => ;
        _HMG_HPDF_ROUNDRECTANGLE ( <Row> , <Col> , <ToRow> , <ToCol> , <Width> , <aColor>\[1\] , <aColor>\[2\] , <aColor>\[3\] , <.lwidth.> , <.lcolor.>, <.lfilled.>, <nCurve> )


2. At sources app and demos examples:
@ 160,20 PRINT RECTANGLE ROUNDED ;
         TO 200,190 ;
         PENWIDTH 0.1;
         COLOR {255,255,0};
         FILLED

We do not know if with this changing will bring many prejudices with retro-compatibility. Probably there is not much cases similar like this. Or just correct the DOC file.
HMGing a better world
"Matter tells space how to curve, space tells matter how to move."
Albert Einstein
User avatar
mol
Posts: 3718
Joined: Thu Sep 11, 2008 5:31 am
Location: Myszków, Poland
Contact:

Re: HMG Manual on PRINT RECTANGLE Miss Leading ?

Post by mol »

Hi guys!

I want to print filled rectangle with red color.
But, I always get black border, even if I set penwidth to 0.00
What's wrong?

there is conversion in i_print_ch:

Code: Select all

#xtranslate @ <Row> , <Col> PRINT RECTANGLE TO <ToRow> , <ToCol> ;
	[ <lwidth : PENWIDTH> <Width> ] ;
	[ <lcolor : COLOR> <aColor> ] ;
	[ <lfilled: FILLED> ]; 
	=> ;
   iif( _HMG_SYSDATA \[ 513 \],_HMG_HPDF_RECTANGLE ( <Row> , <Col> , <ToRow> , <ToCol> , <Width> , <aColor>\[1\] , <aColor>\[2\] , <aColor>\[3\] , <.lwidth.> , <.lcolor.> ,<.lfilled.>), _HMG_PRINTER_H_RECTANGLE ( _HMG_SYSDATA \[ 374 \] , <Row> , <Col> , <ToRow> , <ToCol> , <Width> , <aColor>\[1\] , <aColor>\[2\] , <aColor>\[3\] , <.lwidth.> , <.lcolor.> ,<.lfilled.>) )
but, when I try to place code:

Code: Select all

@	nRow , nCol PRINT RECTANGLE to ;
				nRow + 100, nCol+100;
				.F.,; //	PENWIDTH 0.0 ;
				COLOR {255,0,0};
				FILLED
I got compiler error
User avatar
mol
Posts: 3718
Joined: Thu Sep 11, 2008 5:31 am
Location: Myszków, Poland
Contact:

Re: HMG Manual on PRINT RECTANGLE Miss Leading ?

Post by mol »

In my opinion, this piece of source code is wrong:

Code: Select all

		if ( hb_parl(10) )
		{
			width = hb_parni(6) ;
		}
		else
		{
			width = 1 * 10000 / 254 ;
		}
When you want to print rectangle without border, the width is seto to width = 1 * 10000 / 254 ;
User avatar
mol
Posts: 3718
Joined: Thu Sep 11, 2008 5:31 am
Location: Myszków, Poland
Contact:

Re: HMG Manual on PRINT RECTANGLE Miss Leading ?

Post by mol »

I want to place my solution, maybe it will be useful for someone!
You can set color and width of border.
Thanks to Claudio Soto, his BosTaurus library is really treasure!

Code: Select all

*-----------------
function PrintFilledRectangle
	param nRow, nCol, nWidth, nHeight, aColorRGBFill, aColorRGBLine, nWidthLine
	local hDC
	local aDPI
	aDPI := HMG_GetPrinterResolution( OpenPrinterGetDC() )
	hDC := _HMG_SYSDATA[374]
	nRow -= GetPrintableAreaVerticalOffset()
	nRow := Int( nRow * aDPI[1] / 25.4)
	nCol -= GetPrintableAreaHorizontalOffset()
	nCol := Int( nCol * aDPI[2] / 25.4)
	nWidth := Int( nWidth * aDPI[1] / 25.4)
	nHeight := Int( nHeight * aDPI[2] / 25.4)
	BT_DrawFillRectangle (hDC, nRow, nCol, nWidth, nHeight, aColorRGBFill, aColorRGBLine, nWidthLine)
 return .t.
User avatar
mustafa
Posts: 1158
Joined: Fri Mar 20, 2009 11:38 am
DBs Used: DBF
Location: Alicante - Spain
Contact:

Re: HMG Manual on PRINT RECTANGLE Miss Leading ?

Post by mustafa »

+1
Regards
Mustafa
User avatar
mol
Posts: 3718
Joined: Thu Sep 11, 2008 5:31 am
Location: Myszków, Poland
Contact:

Re: HMG Manual on PRINT RECTANGLE Miss Leading ?

Post by mol »

I found problem with BosTaurus library.
I wanted to generate text with center alignment.
I was tried to use BT_DrawTextEx, but it never generated center aligned text.
The probles is consta BT_TEXT_CENTER which is declared as 6
It should be declared as 1.
When I've corrected sources, everything works OK
User avatar
gfilatov
Posts: 1060
Joined: Fri Aug 01, 2008 5:42 am
Location: Ukraine
Contact:

Re: HMG Manual on PRINT RECTANGLE Miss Leading ?

Post by gfilatov »

mol wrote: Sun Feb 24, 2019 5:41 pm I found problem with BosTaurus library.
I wanted to generate text with center alignment.
I was tried to use BT_DrawTextEx, but it never generated center aligned text.
The probles is consta BT_TEXT_CENTER which is declared as 6
It should be declared as 1.
When I've corrected sources, everything works OK
Hi Mol,

I have a small clarification about that problem :idea:

There is a difference between BT_DrawText and BT_DrawTextEx functions.
The first one uses C-function TextOUt() for a text output and his format option is BT_TEXT_CENTER (aka TA_CENTER).
But second function uses internally C-function DrawText() with the format flag DT_CENTER.
So, the following options
/*
* DrawText() Format Flags
*/
#define DT_TOP 0x00000000
#define DT_LEFT 0x00000000
#define DT_CENTER 0x00000001
#define DT_RIGHT 0x00000002
#define DT_VCENTER 0x00000004
#define DT_BOTTOM 0x00000008
should be used with the function BT_DrawTextEx().
Kind Regards,
Grigory Filatov

"Everything should be made as simple as possible, but no simpler." Albert Einstein
User avatar
hmgchang
Posts: 273
Joined: Tue Aug 13, 2013 4:46 am
Location: Indonesia

Re: HMG Manual on PRINT RECTANGLE Miss Leading ?

Post by hmgchang »

mol wrote: Sat Feb 16, 2019 2:15 pm I want to place my solution, maybe it will be useful for someone!
You can set color and width of border.
Thanks to Claudio Soto, his BosTaurus library is really treasure!

Code: Select all

*-----------------
function PrintFilledRectangle
	param nRow, nCol, nWidth, nHeight, aColorRGBFill, aColorRGBLine, nWidthLine
	local hDC
	local aDPI
	aDPI := HMG_GetPrinterResolution( OpenPrinterGetDC() )
	hDC := _HMG_SYSDATA[374]
	nRow -= GetPrintableAreaVerticalOffset()
	nRow := Int( nRow * aDPI[1] / 25.4)
	nCol -= GetPrintableAreaHorizontalOffset()
	nCol := Int( nCol * aDPI[2] / 25.4)
	nWidth := Int( nWidth * aDPI[1] / 25.4)
	nHeight := Int( nHeight * aDPI[2] / 25.4)
	BT_DrawFillRectangle (hDC, nRow, nCol, nWidth, nHeight, aColorRGBFill, aColorRGBLine, nWidthLine)
 return .t.
I've tried this with START PRINTDOC
START PRINTPAGE
.....

but nothing happen... no any rectangle printed...

Pls advised and thanks all...
Just Hmg It !
Post Reply