Boost logo

Boost :

From: Phil Richards (news_at_[hidden])
Date: 2004-03-05 11:39:28


On Thu, 04 Mar 2004 11:32:24 -0500, David Abrahams wrote:
> Sure, though I would never call the function "add". I'd be looking for
> declarative DSELs like:
> window("Warning: now entering twilight zone") [
> text_field("my favorite color is:"),
> button("OK") | button("cancel")
> ]

I like this approach. I can see how the expression in the "[...]" can be
an abstract structure that is only converted into concrete widgets when
passed to a "real" window factory, and that opens up all sorts of
possibilities for reuse of GUI design patterns.

  widget_ast common_buttons(button("OK") | button("Cancel"));

  window("Window 1")[
    text_field("Hello"),
    common_buttons
  ]
  window("Window 2")[
    text_field("Goodbye"),
    common_buttons
  ]

It also gives a really rather neat way of supporting multiple concrete
widget sets:

  widget_ast demo_widgets(/*...*/);

  gtk_window("gtk window")[demo_widgets]; // specifically GTK+ widgets
  qt_window("qt window")[demo_widgets]; // specifically QT widgets

It isn't immediately obvious how to bind actions to the various widgets -
it doesn't seem sensible for it to be done at the AST level since you
wouldn't generally want all OK buttons to perform the same action...

Anyway, I was just adding my support for a less procedural approach to
constructing GUIs.

phil

-- 
change name before "@" to "phil" for email

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