2010/6/29 Koen Deforche <[email protected]>
> 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.
I suppose that RapidXML supports querying for a certain XML tag.
So it's not trouble there.
You just GetElementByTagName("Widget") and read the attributes for each one.
I am suggesting a compile time tool since I wouldn't like the user to
specify the needed type within the code itself as well.
I was a Loki developer. Of course I know traits.
The problem is that if we are parsing the type and are creating a new one,
the type will have to be deducted on *runtime*.
I thought about refactoring WidgetMap to contain empty widgets which will be
cloned but adding each existing widget is a nightmare.
Unfortunately C++ lacks reflection so we're stuck here with either a compile
time tool or some factory that can map strings to objects.
> > 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
>
------------------------------------------------------------------------------
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