MaxGUI: Create a HTML page on the fly?

BlitzMax Forums/BlitzMax Programming/MaxGUI: Create a HTML page on the fly?

Grisu(Posted 2006) [#1]
Hi!

Atm I'm displaying a simple plain textfile in a textarea of my app and then use FormatTextArea to highlight and color certain lines/words.

Could I do something similar by creating a HTML file out of the text on the fly and then display it with a HTMLView?

Are there any bmx modules for such operations? As I don't want to do that for about 200+ files by hand.

Thanks,
Grisu


ImaginaryHuman(Posted 2006) [#2]
A html file is just a text file. You don't need any conversion.

Just temporarily save the file to disk and have the htmlview display the file.

???


Grisu(Posted 2006) [#3]
Yeah, but I need to write all functions to change the text itself and save it into the html-syntax.

So I was hoping for a module that makes this part easier.


Gavin Beard(Posted 2006) [#4]
if u use a hmtlview...it'll be displayed as webpage, so it'll formated the correct colors if u use the correct html tags when saying it to disk


EOF(Posted 2006) [#5]
I do this for Framework Assistant.
Just written a simple 'html' type specifically for generating the html source.
All it consists of is a TList and some Methods for creating the various parts of the HTML source.
Something like this:
htm.Clear
htm.WriteHeader
htm.AddText "whatever text here"
htm.AddText "more text blah .."
htm.WriteFooter
htm.Save

Then I use HTMLViewGo to display the page.

For colored text I do this:
htm.AddText "<font color='#0000FF'>I am blue</font>"


I also make use the following tags:

<p> .. </p>       for paragraphs
<br>              line break
<hr>              horizontal bar/line



Grisu(Posted 2006) [#6]
Thanks Jim.

1.
I don't want to reinvent the wheel and I never spend time on html coding by hand. Could I use your type construct? :)


2.
Is it possible to search for a certain string inside the HTMLViewGo or even change the font color of a certain string (same as FormatTextAreaText)?


Perturbatio(Posted 2006) [#7]
Is it possible to search for a certain string inside the HTMLViewGo or even change the font color of a certain string (same as FormatTextAreaText)?

yes, you could wrap the text in a span and set a style for it specifically.

i.e.

some text <span style="color:#ff0000">Your text</span> other text


you can specify color in hex values, named colors or RGB values with rgb(r,g,b)


EOF(Posted 2006) [#8]
Something quick to get you going ..

This will let you write text in different colors as well as BOLD , ITALICS, UNDERLINE

The example shows a simple HTML-generated file.
After clicking the NOTIFY button a modified version is shown.

I have used Blitz forum codes for text formatting.
See the ParseLine() function and example text.

The basics:
htm:HTML_Type

Methods/Functions
------------------------------------------------------------
htm.Clear               - clears the text (and creates a header)
htm.AddText t$          - adds an entry
htm.AddLink url$,desc$  - adds a link to url/file etc..
htm.Change f$,r$        - searches for f$ and replaces with r$
htm.Show htmviewgadget  - show results into a view gadget
htm.Cleanup             - removes temporary htm file and text



The source:



Grisu(Posted 2006) [#9]
This will keep me busy for a long while.
I'll add you to my credits window.

Thanks a lot.

P.S.: Could I also load incbined images to show up in the html file? Or do they have to be in extracted form on hdd?


Dreamora(Posted 2006) [#10]
they have to be on HD (html gadget reads everything from HD)


Grisu(Posted 2006) [#11]
It is on hdd, it would be just incbined into the main exe.
But I guess its too much for this simple gadget.


Perturbatio(Posted 2006) [#12]
actually, I'm not sure, but I think you probably could, you'd just need to find a way of telling the browser that you app is a web server and then dealing with the request for the image yourself (i.e. output headers then spew out the image data).

The browser object should handle it fine.


grable(Posted 2006) [#13]
You could allso write it at runtime using javascript.

example:
HtmlViewGo htmlview, "about:" ' needed for a proper document object, can use any kind of html url though.
Delay 100 ' needed for the about page to load properly
HtmlViewGo htmlview, "javascript:document.write('<html><body>Hello World!</body></html>');"



Grisu(Posted 2006) [#14]
Wow, nice find grable!

Is it possible to check if the user clicks a certain link url inside the htmlwindow?

If so I could check for these and display the images in a normal canavs. As a result I could incbin all media inside my main exe and no could just there go and grab it.


assari(Posted 2006) [#15]
have you checked out the HTMLVIEW_NONAVIGATE style of CreateHTMLView? see the helpfile under CreateHTMLView


Grisu(Posted 2006) [#16]
Thanks assari!

So in theory I could readout the Evendata via EventText$()
And get the url = my Image link and make bmx to load it into the canavas. Now THATS COOL. :)