Page 1 of 1

drawHTMLinRect

Posted: 31 May 2006 16:46
by Steve Lympany
I couldn't find an "HTML renderer" anywhere. CustomIE provided by Gildas is excellent, but I wanted to have several text boxes in a form, and to print them in their correct position, which has entirely different requirements.

So, here is a class that renders basic HTML, and draws it in a rectangle. Printing is also coded.
The class could be extended to create controls such as buttons and checkboxes to allow pretty text (selected words bold, underlined, green etc.), all defined using standard HTML.

There is a slight bug with the wrapping, but it seems OK 99% of the time. I'll update it when I find out what the problem is.

The html tags understood are (but with angled brackets):
{b}bold...
{u}...
{i}...
{li} (list)
{br}
{hr} (horizontal line)
{color="#AA66FF"}

The example has a single form. The drawHTMLinRect is used in a control called "test_control" (this is not printed), but you can also add text boxes just by clicking in "white space" in the form. These boxes can be printed, and you can edit the text in them by double clicking. You can also drag them to new positions.

<b>The main call is:
drawHTMLinRect::hdraw(WW,HTML,RCT,Font)
</b>
WW is a domain which passes either the drawwindow + GDI, or a printdocument + GDI. There is a missing predicate in pfc printdocument - you need to add getfont. This simply involves adding two lines - just find setfont in printdocument and repeat them for getfont().

Steve Lympany

Posted: 4 Jun 2006 17:38
by Steve Lympany
Bugfix

Here is a bugfix. I just attach the package rather than a project.

Posted: 7 Jul 2006 14:50
by Steve Lympany
<b>Update</b>

The class has been renamed drawHTML

The predicates are now:

drawHTML::drawText() - call similar to vpi::drawText()
drawHTML::drawTextInRect() - call similar to vpi::drawTextInRect()
drawHTML::getTextTextent() - call similar to vpi::getTextTextent()


A small project is attached, which includes printing.

Posted: 28 May 2010 21:39
by Steve Lympany
Updated for VIP7.3.

Not very sleek, but it works (in general!)

If you need it for Vip7.2, just create a new VIP7.2 project, and copy the project files (.pro, .i etc)

Everyone's welcome to improve it.

Steve Lympany

Posted: 30 Nov 2010 10:06
by Steve Lympany
Hello

I have done a re-write of this code, and provide it as a DLL. There is an attachment file limit size on this forum, so to download the DLL, please go to:

http://www.acsumama.com/VIPDeveloper/drawHTML.htm

An example executable and manual are also there. Also see:

http://wiki.visual-prolog.com/index.php ... TML_drawer

For other little tools, see:
http://www.acsumama.com/VIPDeveloper/vip_developer.htm

Steve

Posted: 29 May 2011 21:09
by Steve Lympany
Hi,

Here is an update - DLL version 1.0.0.6. I've added a bit of extra functionality.

http://www.acsumama.com/vip/drawhtml/index.htm

There is a movie (you may have to wait 20 seconds for it to load) so you immediately can see what it does:

http://www.acsumama.com/vip/drawhtml/drawhtmlmovie.htm

Steve