From: Brock Peabody (brock.peabody_at_[hidden])
Date: 2003-08-01 08:28:46
> -----Original Message-----
> From: boost-bounces_at_[hidden]
> On Behalf Of David Abrahams
> Sent: Wednesday, July 30, 2003 6:31 PM
> To: boost_at_[hidden]
> Subject: [boost] Re: GUI/GDI template library
> I think so. See Boost.Python and Boost.Spirit for examples.
I think Spirit was on my mind while doing this. Anyway, I guess I have
developed the beginnings of a sublanguage. This example shows just a
few elements that I have so far extracted from my work environment.
This example compiles under MSVC 6.0. I probably have lots of missing
typenames right now. I know that the implementation is not boost ready
- it was violently ripped from my libraries and jumbled together. The
interface is demonstrated in boost_gui_test/dialog.cpp. Notice that in
dialog.h and dialog.cpp there are no direct references to any MFC/Win32
I have uploaded the code into the yahoo files section. It's called
All of the functions in the library deal with what I'll term GUI
objects. Some of the things you can do to a GUI object are:
> copy it
> position it in a Rectangle
> call set() on it with a user defined object. In this example I use an
> employee object. It loads component controls with the employee
> call get() on it with a user defined object. It extracts data from
> the controls into the UDT
> register a function object for change notification by calling
> query the GUI for data errors
> ask the GUI what its size requirements are
> tell the GUI to clear itself.
There are more things than just these. Most of the time the system will
take care of calling all of the necessary functions. In my example the
only call is to set().
Here are some of the 'composition' functions that can be used to build
GUI's that are included in the example.
row(x0, x1, ... xn)
Row takes 1 to a macro defined number of GUI objects. It returns a GUI
object that manages the GUIs it contains and arranges them horizontally.
column(y0, y1, ... yn)
Just like row but arranges objects vertically.
group(std::string label, GUI g);
Group returns a GUI object that draws a box around the one it is passed,
and puts the given label at the top.
I also use three types of GUI 'atoms'.
> static text. If you pass an item that is convertible (I literally use
> boost::is_convertible) to std::string to a GUI composition function,
> it will generate a static text object inline.
edit(<data exchange information>)
edit() generates an inline edit control. You have to tell edit (and
other GUI atoms) how they will exchange data with the UDT. I've got the
system set up to handle three ways right now. I know there is a
better(more general) way to do this but am limited by VC 6.
1) pointer to member - edit(&employee::ssn)
2) pointer to get and set functions - edit(&employee::get_pay_rate,
2) pointer to mutable and const get functions. Usually used when an
object has complex subobjects which are accessed by functions that
return mutable and const references when the parent object is mutable or
const, respectively. I do not include an example of this because the
interface is (much) less than ideal under VC 6.0.
date_time(<data exchange information>)
This actually is only capable of exchanging dates right now. We pass
dates around as integers in the form of yyyymmdd. This should be
changed to use the boost date_time library, but you get the idea.
There are some atoms that are included in the example library but not
demonstrated. If there is interest I will do some more thorough
> control_container<> - a structure that adapts a more standard windows
> derived class (from my controls library or user defined) into a GUI
> exchange() - adapts a GUI object to a different exchange interface:
exchange(my_edit, &employee::ssn) <-> edit(&employee::ssn)
> control() - makes it easier to construct control containers:
There are a lot of concepts I have not included in the example but have
> grids of GUIs
> check_boxes, buttons, radio buttons
> tying the above to GUI's so that their enabled states can be changed
> automatically. vector/map based combo boxes vector/map based list
> boxes vector/map based list controls
> vector/map based grid controls
> masked edits
> easily defining/integrating sub-windows
Anyway, if there is any interest I can make better documentation and
examples. Is anyone interested in this direction for a GUI library? I
would certainly want to rework the implementation from the ground up,
but even the way it is, it's pretty powerful.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk