Hey Omer,
2010/6/2 omer katz <[email protected]>:
>
> Hello,
> I had been thinking about a way to automate even more the process of
> creating user interfaces in Wt.
> If we could define widgets on the XML file like this for example:
>>
>> <Widget type="WTextEdit" name="foo" value="bar" />
>
> It would make development of user interfaces much easier and even cheaper as
> regular web developers could just do it themselves.
> It will also allow us to create the Wt Creator much more easily.
Aside from conerns with syntax, I cannot but agree with the idea. This
syntax is in fact the initial syntax I used for WTemplate, but mixing
XHTML tags with new invented tags makes it hard to easily spot the
variables in a template -- and this is why I changed from <WWidget ...
> to ${ } syntax.
Still, the XML approach may be more appropriate in this case,
especially if you consider that a widget may contain other widgets.
> How to achieve this?
>
> By creating a compile time tool that will generate the necessary functions
> from the xml file.
> By replacing the Widget node with a placeholder like replacing the widget
> node with {$foo} in our example and generating a production use xml file.
> Using a small set of macros
> Using the RapidXML parser that wt already uses
Here though, I believe there are many better options. I recommend to
use a an approach inspired by the factory design using type lists,
described in "Modern C++ Design: Generic Programming and Design
Patterns Applied" by Andrei Alexandrescu (see
http://erdani.com/book/main.html)
Properties for a particular class should be described using a traits class.
Something special should be done to handle nested contents, whose
support for a particular class (like WContainerWidget) is also
described in the traits class. Layout managers may require some
hard-wired support, or could perhaps also be handled by a factory.
All this together would avoid the need for code generation, would
avoid code bloat when particular widgets are not used (by excluding
them from the type-list), and offers great flexibility over all. Code
generation has no place in modern C++.
> The system shall allow to bind JavaScript or C++ code to events like this:
>>
>> <Widget type="WSilder" name="foo" value="bar">
>>
>> <Event name="valueChanged" language="JavaScript">
>>
>> function handler(value) { alert (value); }
>>
>> </Event>
>>
>> </Widget>
Event handling using C++ code is indeed hard to describe in my system,
but at the same time C++ code should be in a C++ file so that you can
edit it with an editor that understands it.
Regards,
koen
------------------------------------------------------------------------------
This SF.net email is sponsored by Sprint
What will you do first with EVO, the first 4G phone?
Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first
_______________________________________________
witty-interest mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/witty-interest