How to print filled rectangle?

General Help regarding HMG, Compilation, Linking, Samples

Moderator: Rathinagiri

User avatar
mol
Posts: 3825
Joined: Thu Sep 11, 2008 5:31 am
Location: Myszków, Poland
Contact:

How to print filled rectangle?

Post by mol »

Hi guys (sorry, no women found :( )
I wanna print black rectangle. How Can I do that?
User avatar
Rathinagiri
Posts: 5482
Joined: Tue Jul 29, 2008 6:30 pm
DBs Used: MariaDB, SQLite, SQLCipher and MySQL
Location: Sivakasi, India
Contact:

Re: How to print filled rectangle?

Post by Rathinagiri »

In draw command, 'filled' facility is available. I noticed now that it is not available in 'print'. I think some changes in source code is required. :(
East or West HMG is the Best.
South or North HMG is worth.
...the possibilities are endless.
User avatar
mol
Posts: 3825
Joined: Thu Sep 11, 2008 5:31 am
Location: Myszków, Poland
Contact:

Re: How to print filled rectangle?

Post by mol »

I've tried to print line with width like a height of required rectangle - it works, but .... :-( line has rounded endings and my rectangle looked like egg :lol:
User avatar
mol
Posts: 3825
Joined: Thu Sep 11, 2008 5:31 am
Location: Myszków, Poland
Contact:

Re: How to print filled rectangle?

Post by mol »

Maybe is somewhere place to define style of pen of line and I don't know where???
User avatar
Rathinagiri
Posts: 5482
Joined: Tue Jul 29, 2008 6:30 pm
DBs Used: MariaDB, SQLite, SQLCipher and MySQL
Location: Sivakasi, India
Contact:

Re: How to print filled rectangle?

Post by Rathinagiri »

Hi,

We have to alter HMG source and recreate the library file.

If you are really interested, replace "HB_FUNC ( _HMG_PRINTER_C_RECTANGLE )" in c_controlmisc.c (around line #998) with the following.

This will make all the rectangles to be filled.

Code: Select all

HB_FUNC ( _HMG_PRINTER_C_RECTANGLE )
{

	// 1: hDC
	// 2: y
	// 3: x
	// 4: toy
	// 5: tox
	// 6: width
	// 7: R Color
	// 8: G Color
	// 9: B Color
	// 10: lWindth
	// 11: lColor 

	int r ;
	int g ;
	int b ;

	int x = hb_parni(3) ;
	int y = hb_parni(2) ;

	int tox = hb_parni(5) ;
	int toy = hb_parni(4) ;

	int width ;

	HDC hdcPrint = (HDC) hb_parnl(1) ;
	HGDIOBJ hgdiobj;
//	HPEN hpen;
    HBRUSH hbrush;
    
	if ( hdcPrint != 0 )
	{

		// Width

		if ( hb_parl(10) )
		{
			width = hb_parni(6) ;
		}
		else
		{
			width = 1 * 10000 / 254 ;
		}

		// Color

		if ( hb_parl(11) )
		{
			r = hb_parni(7) ;
			g = hb_parni(8) ;
			b = hb_parni(9) ;
		}
		else
		{
			r = 0 ;
			g = 0 ;
			b = 0 ;
		}
        hbrush = CreateSolidBrush((COLORREF) RGB((int) r,(int) g,(int) b));
//		hpen = CreatePen( (int) PS_SOLID, ( width * GetDeviceCaps ( hdcPrint , LOGPIXELSX ) / 1000 ), (COLORREF) RGB( r , g , b ) );

		hgdiobj = SelectObject( (HDC) hdcPrint , hbrush );

		Rectangle( (HDC) hdcPrint , 
			( x * GetDeviceCaps ( hdcPrint , LOGPIXELSX ) / 1000 ) - GetDeviceCaps ( hdcPrint , PHYSICALOFFSETX ) ,
			( y * GetDeviceCaps ( hdcPrint , LOGPIXELSY ) / 1000 ) - GetDeviceCaps ( hdcPrint , PHYSICALOFFSETY ) ,	 
			( tox * GetDeviceCaps ( hdcPrint , LOGPIXELSX ) / 1000 ) - GetDeviceCaps ( hdcPrint , PHYSICALOFFSETX ) ,
			( toy * GetDeviceCaps ( hdcPrint , LOGPIXELSY ) / 1000 ) - GetDeviceCaps ( hdcPrint , PHYSICALOFFSETY ) 
			);

		SelectObject( (HDC) hdcPrint , (HGDIOBJ) hgdiobj );

		DeleteObject( hbrush );
//		DeleteObject( hpen );

	}

}
East or West HMG is the Best.
South or North HMG is worth.
...the possibilities are endless.
User avatar
swapan
Posts: 242
Joined: Mon Mar 16, 2009 4:23 am
Location: Kolkata, India
Contact:

Re: How to print filled rectangle?

Post by swapan »

Great Rathi! Hope you'll note down this "would be correction" for future version.
Thanks & Regards,
Swapan Das

http://www.swapandas.com/
User avatar
Rathinagiri
Posts: 5482
Joined: Tue Jul 29, 2008 6:30 pm
DBs Used: MariaDB, SQLite, SQLCipher and MySQL
Location: Sivakasi, India
Contact:

Re: How to print filled rectangle?

Post by Rathinagiri »

swapan wrote:Great Rathi! Hope you'll note down this "would be correction" for future version.
No Swapan, It is not a correction. :) It is a feature. It will be useful only if you want filled rectangle. All the rectangles hereafter will be filled. We have to add an option "filled" in the command, like in draw to have both filled and non-filled rectangles.
East or West HMG is the Best.
South or North HMG is worth.
...the possibilities are endless.
User avatar
mol
Posts: 3825
Joined: Thu Sep 11, 2008 5:31 am
Location: Myszków, Poland
Contact:

Re: How to print filled rectangle?

Post by mol »

I think, it must be special parameter "filled" - after this correction we must draw all rectangles from lines...
User avatar
Rathinagiri
Posts: 5482
Joined: Tue Jul 29, 2008 6:30 pm
DBs Used: MariaDB, SQLite, SQLCipher and MySQL
Location: Sivakasi, India
Contact:

Re: How to print filled rectangle?

Post by Rathinagiri »

For having this feature, we have to alter i_print.ch, h_controlmisc.prg and c_controlmisc.c. I will do it tonight, verify it and give it to you.
East or West HMG is the Best.
South or North HMG is worth.
...the possibilities are endless.
Post Reply