|
Boost : |
From: John Torjo (john.lists_at_[hidden])
Date: 2004-09-24 04:13:22
Reece Dunn wrote:
> A windowing framework should abstract the windowing facilities of a
> particular platform. Here are my list of requirements for this type of
> framework:
>
> [1] Support constructor-based window creation, e.g.:
>
> frame.add( new gui::button( "Boost!" ));
did you mean frame->add(..)?
I really think that every window object should have - behind the scenes
- a shared pointer.
One reason for this is:
// I assume you want another pointer to the window,
// not another on-the-screen window.
frame a = b;
>
> The justification for this is that I find using an OnCreate + Create
> style for creating windows (MFC and WTL) or similar is too complex: the
indeed so ;)
> There has been discussions in earlier threads (Java style GUI in C++)
> about using boost::signal as an event handler. I have two questions
> regarding this:
> (1) if I have n message types, do I need n boost::signal objects? If so,
> this would increase the size of each component. Also, what if you want a
> "handle all events" handler.
> (2) if generic events are defined in an 'event' object, and a handler
> function has the form:
>
> event_handled_type eventfn( const event & e );
>
> what if you want to support:
>
> event_handled_type pressed( const mouse_event & me );
> event_handled_type key_down( const key_event & ke );
In my view, I assume this is possible.
All you need is a constructor for mouse_event that takes an event param.
Something like:
mouse_event::mouse_event(const event & e) {
// interpret the event as a mouse event
}
Same goes for key_event. In fact, Dec 04 issue of CUJ should be dealing
with this issue ;)
Best,
John
-- John Torjo -- john_at_[hidden] Contributing editor, C/C++ Users Journal -- "Win32 GUI Generics" -- generics & GUI do mix, after all -- http://www.torjo.com/win32gui/ -- v1.4 - save_dlg - true binding of your data to UI controls! + easily add validation rules (win32gui/examples/smart_dlg)
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk