On 08/16/11 00:25, Julian Schindler wrote:
> 1. When adding some more items to the tree (more than matching into a window)
> and adding a widget to each of them, the visualization is not correct, as the
> items are displayed outside the tree. The simply are added below the others,
> not taking into account the end of the Fl_Tree widget.
Can you show some code demonstrating this?
I can't quite tell what you mean here.
Not surprised there might be problems with
grouping widgets into the tree; the tree widget is
new in this release, and in particular, parenting widgets
to the tree is not well tested.
> 2. When scrolling, all the items with widgets disappear. They are simply not
> drawn, but can still be clicked. When doing so, they reappear magically. But
> when clicking on other items, they disappear again.
> You can test that behaviour when simply adding this to the test/tree.cxx
I modified your example a little, which seems to work for me:
// Add 500 items in numerical order
tree->sortorder(FL_TREE_SORT_NONE);
for ( int t=0; t<500; t++ ) {
static char s[80];
sprintf(s, "500 Items/item %04d", t);
Fl_Tree_Item *i = tree->add(s);
tree->begin(); // <-- ensure new
group parented to tree
Fl_Group *grp = new Fl_Group(0,0,140,18); // make group at 0,0
grp->begin();
Fl_Button *abut = new Fl_Button(0,2,65,15); // ensure x/y is
within group
sprintf(s, "A-%04d", t); abut->copy_label(s); // unique label
abut->labelsize(10);
abut->callback(Button_CB);
Fl_Button *bbut = new Fl_Button(75,2,65,15); // ensure x/y is
within group
sprintf(s, "B-%04d", t); bbut->copy_label(s); // unique label
bbut->labelsize(10);
bbut->callback(Button_CB);
grp->end();
grp->resizable(grp);
i->widget(grp);
tree->end();
}
The main thing being adding tree->begin() and tree->end()
around each child group creation that's assigned to each item.
This was just to make it consistent with the other working code
in the example that shows parenting buttons into the tree.
I changed a few other things to suit my taste for debugging,
but probably aren't necessary to make it work; made the labels
of the buttons unique to check they were showing up correctly,
and changed the coordinate space of the group and buttons
to be 0,0 to simplify the positioning math.
> // Add 500 items in numerical order
> tree->sortorder(FL_TREE_SORT_NONE);
> for ( int t=0; t<500; t++ ) {
> static char s[80];
> sprintf(s, "500 Items/item %04d", t);
> Fl_Tree_Item *i = tree->add(s);
> static Fl_Group *grp[500];
> grp[t] = new Fl_Group(100,100,140,18); // build group.. tree
> handles position
> grp[t]->color(FL_WHITE);
> grp[t]->begin();
> Fl_Button *abut = new Fl_Button(grp[t]->x()+0
> ,grp[t]->y()+2,65,15,"D1");
> abut->labelsize(10);
> abut->callback(Button_CB);
> Fl_Button *bbut = new
> Fl_Button(grp[t]->x()+75,grp[t]->y()+2,65,15,"D2");
> bbut->labelsize(10);
> bbut->callback(Button_CB);
> grp[t]->end();
> grp[t]->resizable(grp[t]);
> i->widget(grp[t]);
> }
> 3. I wanted to have a widget added to an item with the exact width
> of the item from the tree structure on the left to the slider on the right.
> I hoped to get that size with Fl_Tree_Item::w(), but unfortunately this
> function always returns 0. Esp. when the resize function is called
> (e.g. when scrolling), the width argument of it is always 0 as well.
> So how can I get the width?
Again, can you include a small compilable example showing how
you're getting the width of the item?
I believe the widths are calculated when the widget is draw()n,
so if you're calling it before it's drawn, that might be the issue.
_______________________________________________
fltk mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk