HMG Manual on PRINT RECTANGLE Miss Leading ?

Moderator: Rathinagiri

Post Reply
User avatar
hmgchang
Posts: 240
Joined: Tue Aug 13, 2013 4:46 am
Location: Indonesia
Has thanked: 1 time
Been thanked: 4 times

HMG Manual on PRINT RECTANGLE Miss Leading ?

Post by hmgchang » Mon Jun 02, 2014 3:30 am

Dear All,

Maybe this info will be useful, on HMG DOC :
HmgManual_PrintRectangle.JPG
HmgManual_PrintRectangle.JPG (104.72 KiB) Viewed 1329 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
Has thanked: 100 times
Been thanked: 179 times

Post by Pablo César » Mon Jun 02, 2014 3:48 pm

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: 3139
Joined: Thu Sep 11, 2008 5:31 am
Location: Myszków, Poland
Has thanked: 194 times
Been thanked: 107 times
Contact:

Post by mol » Fri Feb 15, 2019 10:40 am

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: 3139
Joined: Thu Sep 11, 2008 5:31 am
Location: Myszków, Poland
Has thanked: 194 times
Been thanked: 107 times
Contact:

Post by mol » Fri Feb 15, 2019 11:27 am

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: 3139
Joined: Thu Sep 11, 2008 5:31 am
Location: Myszków, Poland
Has thanked: 194 times
Been thanked: 107 times
Contact:

Post by mol » 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.

User avatar
mustafa
Posts: 779
Joined: Fri Mar 20, 2009 11:38 am
DBs Used: DBF
Location: Alicante - Spain
Been thanked: 107 times
Contact:

Post by mustafa » Sat Feb 16, 2019 2:44 pm

+1
Regards
Mustafa

User avatar
mol
Posts: 3139
Joined: Thu Sep 11, 2008 5:31 am
Location: Myszków, Poland
Has thanked: 194 times
Been thanked: 107 times
Contact:

Post by mol » 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

User avatar
gfilatov
Posts: 605
Joined: Fri Aug 01, 2008 5:42 am
Location: Ukraine
Has thanked: 19 times
Been thanked: 166 times
Contact:

Post by gfilatov » Mon Feb 25, 2019 12:55 pm

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
mol
Posts: 3139
Joined: Thu Sep 11, 2008 5:31 am
Location: Myszków, Poland
Has thanked: 194 times
Been thanked: 107 times
Contact:

Post by mol » Mon Feb 25, 2019 1:20 pm

Thanks Grigorij for clarification

Post Reply