MacArthur, Ian (SELEX) (UK) schrieb:
>> just my 2ct, begin/end is a little like pascal and there is no need to
>> ident the inner block. thats the advantage of the with macro (besides
>> some disadvantages)
>
> Sure - if you like that style, you can do that with the existing
> implementation of course.
> Doesn't suit the way I think about the groups though, so might not suit
> my patterns...
i stumbled about this initialisation issue when reading code and trying
to figure out which widget belongs to what group. i think code like this
is more readable:
Window *window= new Window(...);
with(window) {
MenuBar *menu = new MenuBar(...);
Group *group = new Group(...);
with(group) {
//add some more
//with(another) {
// ...
//}
}
//back to window
}
which would reflect the hirachical widget tree,
the same layout as would be shown in fluid.
disadvantage is the use of a macro,
another advantage might be that all new vars get automatic local scope
which would made it more easy to copy and paste complete trees.
this macro should work too but generates some compiler warnings if used
in nested blocks (which could safely be ignored):
#define with(group) for(int once=((group)->begin(),1); once--;
(group)->end())
if suits perfectly my understanding of widget creation. previously i did
simple indention like this
begin()
new Widget...
...
end()
just to see where the widgets belong too.
if code gets a little longer it is really difficult to read unindented
trees.
greeting
_______________________________________________
fltk mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk