Boost logo

Boost :

From: Benjamin Munson (benjaminm_at_[hidden])
Date: 2005-09-02 23:28:41


Hi. I'm Ben, first time poster, occasional lurker.

I've been playing around with ideas for a nice cross platform C++ GUI,
something I think is lacking. Is there any interest in this? More
importantly, are there any thoughts on how this should best be done, and
  features that would be needed.

My idea was to have a base window class, with child windows derived from
that (admitedly my ideas are retardly simple on occasion), and a special
toplevel window derived too. The base window class would obviously need
a number of virtual functions for mouse/key/painting etc and I'm not
sure how much this would affect performance, I expect at most you'd have
two or three levels of inheritance working, and maybe a dozen or so
virtuals? Because I'd like this to be usable in real-time systems (like
games) rather than just event driven ones I thought that a desktop class
would work well as a top level control for all the windows.

To handle the drawing itself, I thought some kind of canvas object,
obviously this would be the most platform specific part, with members
for the different drawing operations you might need,
lines/rects/blitting etc.

I've actually worked up a test version of a lot of this, a win32 version
and a glut version. The win32 version obviously uses the win32 api. The
glut version uses glut but no acceleration at all, everything is
rendered to a bitmap and glBitmap'ed to the screen at the end, so all
lines etc use software algorithms. Also, the glut version unfortunately
isn't totally portable for font based reasons, I had to use windows
fonts since glut doesn't let you use truetype fonts afaik. The test
version implements the top level window, a textbox and button class.

Another point I'd like advice on is how best to handle the platform
specific parts of a library like this. Right now, there are three
classes (desktop, canvas and window_top_level) with platform specific
parts variables or that need seperate versions of methods. I've just
used #defines to configure which platform is used, and for ease of
finding things I've grouped the platform specific parts in seperate
files (so I have a window_top_level.cpp, window_top_level_glut.cpp and
window_top_level_windows.cpp) with the common methods in the named cpp
file. I have a feeling this might not be the best way of doing things.
And ideas? I think it might be better if each platform has an entire
implementation in one file to itself.

I'm sorry if this is a bit rambling, it's a bit of a mind dump to be
honest. I can stick the demo online if anyone is interested. If you are,
let me know.

Ben.


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk