Boost logo

Boost :

From: John Torjo (john.lists_at_[hidden])
Date: 2004-08-19 01:23:42


>
> On the FOX mailing list, a number of people subscribe to quite a few of the GUI toolkit mailing lists that have been mentioned. The general consensus was that a templated approach to building GUI's, just doesn't work... and it has been tried a number of times... The main reason is that GUI's require dynamic / run-time binding between different widgets/components.

How about win32gui ;) ?
Note that it's Windows specific.

>
> For example:
>
> - To bind a mouse click to an onscreen button, you may use a templated approch to the binding.

Got that right!
More specifically, take a look at how I allow handling of events for
win32gui. I requires no message loop.

> - Then you would like a keyboard shortcut to be bound to the same event
>
> -> no problem, as both of these cases can be coded by end-programmer. In particular, it works because the library knows about these event types.

Not necessary. Actually, I need not know of any events. The programmer
knows which event/command/notification to bind to, and it simply does so.

Example:

handle_event on_size( [some_args]) {
     ....
     return event<WM_SIZE>().HANDLED_BY(&me::on_size);
}

(note: I only comment here for Win32 issues. You might be right for
cross-platform issues though)

>
> What happens if you decide to embed the Gecko HTML redering engine inside a window frame (ie so that it saves you from having to build your own HTML rendering engine)? The problem is that you have to dynamically route messages from the foreign window, into you own event processing mechanism - which simply doesn't work with a compile-time approach. Admittedly, this is a contrived example, but the premise holds for a number of common usage scenarios.
>

Why would you say that? See above.

> Also, static event mapping systems result in a N x M mapping of events to widgets. If you have say 20 event types and 100 widgets, you end up with 200 combinations of actions that need to be coded by the end-programmer. Dynamic binding allows some toolkits to make this an N + M problem, which greatly reduces the size of your end-programmer code that needs to be written.

Note: I think I've solved this problem with the way win32gui is handing
events.

Also note that there is so much more to GUI programming than events.

Best,
John

-- 
John Torjo
Freelancer
-- john_at_[hidden]
Contributing editor, C/C++ Users Journal
-- "Win32 GUI Generics" -- generics & GUI do mix, after all
-- http://www.torjo.com/win32gui/
-- v1.3beta released - check out splitter/simple_viewer,
    a File Explorer/Viewer all in about 200 lines of code!
Professional Logging Solution for FREE
-- http://www.torjo.com/code/logging.zip (logging           - C++)
-- http://www.torjo.com/logview/         (viewing/filtering - Win32)
-- http://www.torjo.com/logbreak/        (debugging         - Win32)

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