thin tree widget




Hi,

I recently hacked up a tree display for the Debian package manager. CTree
was not usable, because the display contains thousands of items and half a
dozen columns, and all parts of it can change at any time. So copying all
this data into CTree wasted a bunch of memory, and was also unacceptably
slow (every user action which affected the tree caused around a 1-second
pause). Following a suggestion from Jason Gunthorpe (Apt author), I ended
up writing a tree display in C++, which renders to a drawing area. The key
characteristic of this tree is that it "attaches" to an external data
structure, rather than requiring you to stuff the data into the tree.
It is thus very fast and uses little additional memory.

This seems like a generally useful thing; a filesystem or database display
would also need a widget like this. For example, you can sort of notice
that gmc is having issues with the tree display; gnome-apt's tree is much
smoother and faster.

My question is: I don't know how to make a nice C interface for one. It's
rumored that some other toolkits have one of these; what do they do?

In C++, I just provide a Node interface, and users subclass Node and then
pass a Node* to the tree. Node has functions like:
  draw_column(int col);
  expand();
  collapse();
  
etc., whatever you'd do to a tree node. Would a simple struct full of
function pointers be reasonable?

Anyway, I am not going to do this soon, but I don't really feel like
extending my drawing-area tree hack to be properly full-featured, so I
would like to write (or have :-) a real C widget eventually.

Thoughts on how to implement this? Just thought I'd get it on the
agenda...

Havoc




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]