Does FX/Ruby have some standard icons?

I’m trying to be vaguely clever, by only expanding
tree items when someone double clicks on them,
thus improving perceived performance (in terms of
startup time).

However, I’d like the user to know whether an item
has children. Ie, whether it makes sense to
double click on an item.

Hence, I’d like to put two different icons next to
the tree nodes, depending upon whether they have
children in the data. FOX won’t know about the
children yet, since they won’t be added to the
tree list until the double click, so it doesn’t
display a “+” sign.

Are there any “standard” icons, or do I need to
actually have my own images, in order to add icons?

If there are, how do I get access to them? Can
someone point me to the right part of the
documentation?

TIA.

Harry O.

Harry Ohlsen wrote:

I’m trying to be vaguely clever, by only expanding tree items when
someone double clicks on them, thus improving perceived performance (in
terms of startup time).

However, I’d like the user to know whether an item has children. Ie,
whether it makes sense to double click on an item.

Hence, I’d like to put two different icons next to the tree nodes,
depending upon whether they have children in the data. FOX won’t know
about the children yet, since they won’t be added to the tree list until
the double click, so it doesn’t display a “+” sign.

You are talking about two different issues with regards to how tree
items are drawn.

The first issue is whether the boxes with the +/- signs appear to the
left of (non-leaf) tree items. Two different options for the FXTreeList
widget control affect this. For root-level tree items, if you pass in
the TREELIST_ROOT_BOXES option you’ll see these boxes; if not, you
won’t. For other (non-root) tree items, the TREELIST_SHOWS_BOXES option
serves the same purpose.

The second issue (and independent of the first) is which icon(s) are
displayed when a tree item is open or closed. If you’re using, for
example, FXTreeList#addItemLast to append child items to a parent node,
you can pass the “open” and “closed” icons as the third and fourth
arguments to addItemLast:

 treeList.addItemLast(parentItem, "Item Text", openIcon, closedIcon)

for the other methods on FXTreeList, see the API docs here:

 http://www.fxruby.org/doc/api

So for the application you’ve described, it sounds like you’d want to
turn off display of all of the “boxes”, then use custom icons for the
leaf and non-leaf items, as appropriate.

Are there any “standard” icons, or do I need to actually have my own
images, in order to add icons?

You’ll need to provide your own icons. Any of the icons used for tree
lists in the FXRuby examples (e.g. splitter.rb) are fair game, if that
helps.

The first issue is whether the boxes with the +/- signs appear to the
left of (non-leaf) tree items. Two different options for the FXTreeList
widget control affect this. For root-level tree items, if you pass in
the TREELIST_ROOT_BOXES option you’ll see these boxes; if not, you
won’t. For other (non-root) tree items, the TREELIST_SHOWS_BOXES option
serves the same purpose.

Thanks. I want the ‘+’ signs. What I was getting at is that at the time the
window is displayed, the top-level nodes won’t have any children (because I’m
not inserting them into the tree until the user clicks on the node).

The default behaviour seems to be to show the ‘+’ signs when there are
children, which is fine by me. It was nice to see that when I add child
nodes after the window has been drawn, the ‘+’ signs get added automatically
… not surprising, but it would have been a pain if they weren’t.

The second issue (and independent of the first) is which icon(s) are
displayed when a tree item is open or closed. If you’re using, for
example, FXTreeList#addItemLast to append child items to a parent node,
you can pass the “open” and “closed” icons as the third and fourth
arguments to addItemLast:

 treeList.addItemLast(parentItem, "Item Text", openIcon, closedIcon)

Yep. I saw that in the RDoc for the API. What I was hoping was that there
might be some way of asking FOX to use something like, say, the system’s
standard icon for a file folder … assuming such a “standard” icon exists
… rather than having to load my own image. Needing to do that isn’t really
a big issue, it just means that deploying the program requires including the
image files, rather than just giving someone the single Ruby file.

I guess I could do something sneaky like encode the icons as data and put them
after END in the Ruby code, so they can be read in at runtime. Probably
more effort than it’s worth, but I might do that, just as an experiment.

You’ll need to provide your own icons. Any of the icons used for tree
lists in the FXRuby examples (e.g. splitter.rb) are fair game, if that
helps.

Excellent! I’ll give them a go.

By the way, are there any reasonably detailed tutorials on using FOX, other
than the one that comes with the library? It’s too bad that the Ruby book
market isn’t better, because I reckon a book devoted to FX/Ruby would be
great.

Thanks for all the help.

Cheers,

Harry O.

···

On Tue, 11 Feb 2003 17:37, Lyle Johnson wrote:

Harry Ohlsen wrote:

By the way, are there any reasonably detailed tutorials on using FOX, other
than the one that comes with the library?

I see a few FOX tutorials listed on the Wiki site:

 http://www.fifthplanet.net/cgi-bin/wiki.pl?Tutorials

and at least one claims to be FXRuby-specific. I can’t comment on how
detailed they are.