Structuring a Custom TextBox?

BlitzMax Forums/BlitzMax Programming/Structuring a Custom TextBox?

Gabriel(Posted 2006) [#1]
I'm having some doubts about the best way to structure a custom textbox. All my Gadgets that contain text have a TextList ( TList ) which contains all the text lines to be rendered. I do it like this so that I can optimize my text rendering by just rendering every Text Line in one fell swoop. ( The TextLine Type has a list of it's own. )

When I destroy the gadget, it destroys all the textlines, which prompts them to remove themselves from both lists. This works well.

A textbox, however, has text objects which are not always visible. So I need to access the text objects from the TextBox object and either add/remove them to/from the list or change their visibility. I haven't decided yet whether it will be quicker to add/remove and render all or have a visibility check for every single text object. Will have to benchmark.

I'm just not sure of the best way to handle the organization of it. I'm thinking an array would be best, but the other gadgets don't really need an array, and I like how clean it is to have the text objects destroy themselves without me having to clean the array out from the textbox. Probably no real reason, but it seems cleaner to me.

On the other hand, the textbox is not resizable so all I really need is a firstvisible and lastvisible field to show the first and last visible text lines in the textbox. Then if the user scrolls up, hide the last, move both last and first back one in the list and show the first.

Any thoughts on which method ( or a third method if you don't like either ) would be fastest/cleanest would be appreciated. I think I've just overthought this over the past few days when I haven't been able to code.


Chris C(Posted 2006) [#2]
I'd use a list over an array personally


Gabriel(Posted 2006) [#3]
Yep, I've been mulling this over for the past few hours, and I'd come to the same conclusion. Doesn't seem like this is the right place for an array.