Which road to take: Textarea, HTML, Printer?

BlitzMax Forums/BlitzMax Programming/Which road to take: Textarea, HTML, Printer?

Grisu(Posted 2008) [#1]
Hi there!

I'm currently searching for the best solution for a max gui app I want to code.
My app needs to perform some simple calculations based on certain user inputs
and output the results on screen and on the printer. Support for tables would be great too.

Example:
--------------------------------------------
Item no. | Description | Price
--------------------------------------------
1 | this is an example | 100,00 EUR
2 | this is an example2 | 50,00 EUR
---------------------------------------------
| Sum | 150,00 EUR
| 19% VAT of 150,00 EUR| 28,50 EUR
---------------------------------------------
| Total | 178,50 EUR
---------------------------------------------
* the table grid should be in line! :(

A. Should I take the HTML road for this and use a HTML gadget?
- Is it possible to create a simple gui button that prints out the HTML file currently in view?
- Is it possible to generate a HTML file "on the fly" and load it into the gadget without using the hdd at all?
- Are there any HTML modules that would help me creating such output files as shown above?
- Is it possible to create a custom popup menu for the HTML gadget?

B. Should I use a textarea or listbox plus a printer module instead?
- Is there a reliable! printer module out there yet? Kanati's print mod?
- Is there support for different text styles (bold...) and fonts?
- Is there a way to print the contents of a textarea or listbox?

I just don't want to reinvent the wheel or find out that I have started the wrong way.

So what approach would you prefer?
Any alternatives I haven't thought of? ;)

Thanks, Grisu


SebHoll(Posted 2008) [#2]
OK, here we go: ;-)
Edit: Why didn't you post in the GUI Programming forum? :-)

Should I take the HTML road for this and use a HTML gadget?
If you want proper tables and/or graphics, then yes.

- Is it possible to create a simple gui button that prints out the HTML file currently in view?
Definitely, have a look at GadgetPrint().

- Is it possible to generate a HTML file "on the fly" and load it into the gadget without using the hdd at all?
Yep, I think you can use Javascript to do this. Look up HTMLViewRun() and the javascript command: 'document.write'.

- Are there any HTML modules that would help me creating such output files as shown above?
It might be overkill, but you may want to have a look at Brucey's XSLT module which is basically an industry-standard template specification that uses XML.

- Is it possible to create a custom popup menu for the HTML gadget?
Probably, by using the HTMLVIEW_NOCONTEXTMENU flag with CreateHTMLView() and MaxGUI's standard PopupWindowMenu() command. You'd have to be able to capture right-clicks though... Another idea would be to use javascript to process right-clicks.

Should I use a textarea or listbox plus a printer module instead?
You could do, but it's hard to insert graphics/tables. I added GadgetPrint() support for text-areas to the new Windows GUI driver module (in Axe v0.40 I think).

- Is there a reliable! printer module out there yet? Kanati's print mod?
See previous question.

- Is there support for different text styles (bold...) and fonts?
As you know, only in text-areas, and the formatting should be retained when it is printed using GadgetPrint().

- Is there a way to print the contents of a textarea or listbox?
Text-area, yes - use GadgetPrint()! List-box, not directly, but you could use a list-box, and then write the list-box data to a hidden text-area and apply formatting there, then print that.

So what approach would you prefer?
Well, it depends what you need. Text-areas will be quick to format, code and add to on the fly (and you can print text with the formatting), but it's near impossible to get tables/graphics into them. HTML Views you can also print from, but it's probably slightly harder to output too - however, you'll be able to use tables/graphics etc.


Vertex(Posted 2008) [#3]
I thnk you should use Bruceys wxWidget GUI with the gadget wxSheet. There is also a wxPrintOut module.
http://blitzbasic.com/Community/topics.php?forum=124

But I think that actually the wxPrintOut module is not completly translated(I don't find wxPrinterDC or wxPostScriptDC)

Also there is a PDF lib to create PDF files in BMax:
http://www.blitzbasic.com/codearcs/codearcs.php?code=1513

cu olli


Brucey(Posted 2008) [#4]
Vertex, you should take a look at the printing sample : wx.mod/samples/printing/printing.bmx
I've had it working on Mac and Win2k.

And on OS X you can even redirect the print to a PDF if you like.

:-)