Miniwindows OOP Approach

Posted by Grek on Fri 08 Aug 2008 11:54 PM — 4 posts, 18,391 views.

Sweden #0
This is what I've managed to produce so far, I'm pretty
satisfied with it.

http://paste.servut.us/tyuk

Still plenty of potential in it I think.

(2am, first night working on this, some stuff still not perfect :))
Amended on Fri 08 Aug 2008 11:55 PM by Grek
Australia Forum Administrator #1
Looks good, you might want to make helper functions to draw a nice button inside a round rectangle, that shift slightly when you click it, and so on.

A good idea to modularize this stuff.
Sweden #2
Yeah, lots of work to do :)

A little sample of what I've done so far, http://i34.tinypic.com/rh5qtv.png

Redirecting tells to that window.

TextWindows are created by specifying top and left distance, it's possible to put them in a container window and have the position relatively calculated. thus by moving the container window you automatically move the content as well, will probably be more useful when creating gauges and buttons.

Adding new text is done with the writeline(line) method.
Australia Forum Administrator #3
You shouldn't have to use a container window. See the way I did help displays here:

http://www.gammon.com.au/forum/?id=8819

To display a lot of text, you just need to cache the text in a table. Then to display a particular page you simply index into the table (eg. if there are 20 lines per page and you want page 3, that is line 60). Then draw the next 20 lines from that point.

The forwards and back arrows, however you draw them (I used a Next and Prev hyperlink, but it could have been arrows on a "scroll bar" on the side) simply add or subtract a page-size from the current position variable.

This method lets you handle massive amounts of text without having to set up large extra windows.

I haven't had time to do it yet, but I envisaged you could make each line a hotspot, and if you clicked on it, it could be selected (ie drawn in inverse) and then copied to the clipboard if wanted.