Jeff,
I don't have any ready made examples of Wx::TreeListCtrl in virtual mode
but you would use it in the same way you would virtualize a
Wx::TreeCtrl. (If that's any help at all).
I've never used Wx::TreeListCtrl in this way, but assuming Wx::TreeCtrl
like operation:
The basis of 'virtual' operation is that you only add top level nodes to
the Tree initially without adding any 'child' nodes. Use the method
$tree->SetItemHasChildren to indicate that each node has children,
without actually populating them.
Then, respond to EVT_TREE_ITEM_EXPANDING to populate the child nodes on
request.
When creating any node you add the data you need to expand children and
populate column text. (maybe just a key that you use to lookup data source).
my $nodedata = {
somedata1 => $info1,
somedata2 => $info2,
somedata3 => $mykey,
};
my $newitem = $treelist->AppendItem(
$parentitem,
$text,
$imageidx,
-1,
Wx::TreeItemData->new( $nodedata ),
);
.....
sub OnGetItemText {
my ($self, $itemdata, $column) = @_;
my $nodedata = $itemdata->GetData();
# .. do stuff
return $columntext;
}
sub OnItemExpanding {
my ($self, $event) = @_;
my $item = $event->GetItem();
my $nodedata = $self->{treelistctrl}->GetPlData($item);
# which is really just a shortcut for
my $nodedata = $self->{treelistctrl}->GetItemData($item)->GetData();
#........
}
Whether this is practical in terms of virtual operation depends on the
nature of your data. If one node has 50,000 direct children, I'm not
sure what performance will be like as I think you would need to add
50,000 nodes. But maybe this means a tree isn't your best display
option. You can make a properly virtual Wx::ListCtrl or Wx::Grid, or go
totally down the custom route with something like Wx::VListBox.
If using Wx::TreeListCtrl You might choose to collapse nodes on the same
level and discard their data whenever a node is expanded.
Hope It Helps
Mark
On 18/07/2011 15:18, jeff wrote:
Hi all - especially Mark ;-),
Trying to use the treelistctrl in virtual mode with columns. Would also
like to use some of the background and font features.
Not understanding the relationship between OnGetItemText method and
wxTreeItemData ( and how to use the the wxTreeItemId ).
If some one has a simple example of wxtreelistctrl in virtual mode they
could post I would appreciate - not much in the way of examples coming
back from Google.
Thanks,
Jeff