Okey-dokey - I've attached a patch (against rev. 6951) that add's a
user_data() method to Fl_Tree_Item, and also an insert() and add() method to
Fl_Tree so that nodes can be added to items without needing the prefs
struct.
Have also replaced the type of any icon fields from Fl_Pixmap to its
superclass Fl_Image, so that code is more flexible. Needed to fix a few
bugs in the positioning and drawing of items with icons too, in
Fl_Tree_Item::draw().
The final change I made was to make Fl_Tree's find_children() method public
(instead of protected), as I think this is quite a useful function call.
As for handling the expanding/collapsing events, I suggest that these run
the callback function, although I'm not sure what the best way to find out
exactly why the callback was made. So I think I'll leave this to the FLTK
guru's in case I make a pig's ear out of it.
Cheers
Seb
"Greg Ercolano" <[email protected]> wrote in message
news:[email protected]...
SebHoll wrote:
All good questions..
1) How do I find the address of the 'prefs' struct that is associated
with an Fl_Tree instance? I don't like using the menu style 'add' call
in Fl_Tree for adding nodes (one reason is that my node label may have a
'/' in it), and prefer to add child nodes directly to the parents using
the 'insert' command, but I don't know where to get the prefs to pass as
an argument to the function.
Yes, I should add an accessor for that.
Feel free to tweak the Fl_Tree.H file to add what you need,
and then either email me the modified file(s) as an attachment
or a patch, and I'll apply it.
Fl_Tree is still quite young, and I don't really fancy myself as
a GUI API designer. So you'll likely catch some obvious things
I need to add or forgot to.
This week and weekend is exceptionally nutty in my life, so
I probably won't get to any of this before you do, so by all
means either send me patches, or remind me again if you don't
see any posts here showing a release update.
2) Is there a method for returning an array of the selected nodes?
There isn't, but there should be.
At the moment I'm iterating through all the nodes and constructing
this myself
Right, that's the way to do it as currently designed.
There should probably be a method that returns a populated
Fl_Tree_Item_Array.
I'll see about adding that.
3) With Flu_Tree_Browser I was able to associate a 'user_data' value with
each
one of the items (that I set as a pointer to a corresponding struct in
the rest
of my programs). This was extremely useful - does Fl_Tree support
anything similar?
Huh, not sure how I missed that, but yes, there should be.
I thought actually I did have something like that, but I'm not seeing it,
hmm.. Will add that too.
4) What's the best was to detect when a node has been collapsed/expanded
by the user, and find out which item this occurred for?
I didn't plan in anything for that, but yes, there probably
should be a callback or something for this.. wasn't sure what
was the best way to implement that.
I could either go with separate expand/collapse callbacks,
or a virtual that you can override, or..? Wasn't sure which
was best, any suggs from the core guys would be helpful here.
Any help with any of the above would be amazing.
Many thanks,
Seb
_______________________________________________
fltk mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk