I once wrote a GUI system which might be of interest; Smoke. It can be downloaded on my web site (
www.neuraldk.org).
The code was written some time ago (it was done for a highschool project) but should give a good idea on how to develop a GUI system.
My GUI supported MDI windows, was based extensively on the MacOS (lookswise, anyway) and was developed on top of my graphics library (Petal) and therefore ran on both DOS and Linux, so I would hope something can be grabbed from the code.
Essentially, you want to use a similar approach to virtual consoles. Each window has its own graphics device abstraction, and writes to its window as if it's fully visible. When the screen is painted (only those portions which have changed!) then you have a few alternatives:
- draw all windows, back to front, potentially overwritting the previous window
- maintain a linked list of "visible" rectanges per window, and display only those portions of the window that are actually visible (what my GUI does)
- do the same as above, but use a span buffer for visible portions, instead (this more easily allows shaped windows)
- and more, I'm sure...
One thing to note about my GUI is that if you're smart about it (or even make an interesting mistake) it's possible to draw onto the window border, which should never be possible.
And a better OO approach would be for the window itself to be a gui widget itself (like a button) rather then some other entity.
--Jeff