Share Tips, Code Samples, etc. with the Visual Prolog community.
Steve Lympany
VIP Member
Posts: 56
Joined: 31 Mar 2001 23:01

drawHTMLinRect

Unread post 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
Attachments
html_parser.zip
Pretty text defined by standard HTML tags, drawn and printed
(31.89 KiB) Downloaded 1949 times
Steve Lympany
VIP Member
Posts: 56
Joined: 31 Mar 2001 23:01

Unread post by Steve Lympany »

Bugfix

Here is a bugfix. I just attach the package rather than a project.
Attachments
HTML_parse.zip
Package for HTML renderer
(10.63 KiB) Downloaded 1889 times
Steve Lympany
VIP Member
Posts: 56
Joined: 31 Mar 2001 23:01

Unread post 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.
Attachments
dev_oneHTML.zip
HTML rendering. Use simple HTML to have pretty text
(35.68 KiB) Downloaded 1919 times
Steve Lympany
VIP Member
Posts: 56
Joined: 31 Mar 2001 23:01

Unread post 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
Attachments
dev_html_1003.zip
(63.87 KiB) Downloaded 1419 times
Steve Lympany
VIP Member
Posts: 56
Joined: 31 Mar 2001 23:01

Unread post 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
Steve Lympany
VIP Member
Posts: 56
Joined: 31 Mar 2001 23:01

Unread post 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
Post Reply