The Blog of Anders Nissen

fredag, juli 29, 2005

Multi-Line Text Class

Yay! I've just managed to get my SDL multi-line text object working! :D

It's build on top of my single-line SDL text object, but has some additional features such as:
- Splitting text string into multiple lines at new-line characters
- Setting a maximum width for the text
- The text will automatically have its width compared against the maximum, and split into multiple lines of text at an appropriate location and all within the bounding width.
- The list of text lines works exactly like the regular single-line version and has the same interface, so they can be used interchangeably.

Here's a screenie. The top line is the original text, and the highlighted lines are the multi-line text object.


It's only about 200 lines of code, but it wrecked quite a bit of havoc, so I've spend a few days working on it, and code marginally related to it. However, I believe that the changes I've made to the areas of code closer to the core has made it more robust . :)