Page 1 of 1

HMG Manual on PRINT RECTANGLE Miss Leading ?

Posted: Mon Jun 02, 2014 3:30 am
by hmgchang
Dear All,

Maybe this info will be useful, on HMG DOC :
HmgManual_PrintRectangle.JPG
HmgManual_PrintRectangle.JPG (104.72 KiB) Viewed 2047 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

HMG Manual on PRINT RECTANGLE Miss Leading ?

Posted: Mon Jun 02, 2014 3:48 pm
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.

Re: HMG Manual on PRINT RECTANGLE Miss Leading ?

Posted: Fri Feb 15, 2019 10:40 am
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

Re: HMG Manual on PRINT RECTANGLE Miss Leading ?

Posted: Fri Feb 15, 2019 11:27 am
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 ;

Re: HMG Manual on PRINT RECTANGLE Miss Leading ?

Posted: Sat Feb 16, 2019 2:15 pm
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.

Re: HMG Manual on PRINT RECTANGLE Miss Leading ?

Posted: Sat Feb 16, 2019 2:44 pm
by mustafa
+1
Regards
Mustafa

Re: HMG Manual on PRINT RECTANGLE Miss Leading ?

Posted: Sun Feb 24, 2019 5:41 pm
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

Re: HMG Manual on PRINT RECTANGLE Miss Leading ?

Posted: Mon Feb 25, 2019 12:55 pm
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().

Re: HMG Manual on PRINT RECTANGLE Miss Leading ?

Posted: Mon Feb 25, 2019 1:20 pm
by mol
Thanks Grigorij for clarification