MaxGUI: Create a HTML page on the fly?
BlitzMax Forums/BlitzMax Programming/MaxGUI: Create a HTML page on the fly?
| ||
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 |
| ||
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. ??? |
| ||
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. |
| ||
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 |
| ||
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 |
| ||
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)? |
| ||
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) |
| ||
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: |
| ||
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? |
| ||
they have to be on HD (html gadget reads everything from HD) |
| ||
It is on hdd, it would be just incbined into the main exe. But I guess its too much for this simple gadget. |
| ||
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. |
| ||
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>');" |
| ||
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. |
| ||
have you checked out the HTMLVIEW_NONAVIGATE style of CreateHTMLView? see the helpfile under CreateHTMLView |
| ||
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. :) |