NAME

WxPerl::TreeCtrlMapped - a more reasonably perlish wxTreeCtrl

ABOUT

I want a better TreeCtrl

Troubles with wxTreeCtrl: o data is ad-hoc nested in TreeCtrl using TreeItemData o no random-access to tree without mapping id => TreeItemId o no reverse-lookup for id without putting it in TreeItemData

So, we want get_id($item), get_item($id)

And, a way to store a single object as the data (that's not incompatible with the id mapping.) If I'm going to store the id and an object, I would have to say Wx::TreeItemData->new({id => $id, object => $object), which is just too much given the $tree->GetPlData()->{object} calls that would always be following it around.

get_data($id|$item)
set_data($id|$item, $data)

TODO

Probably some more convenient get_children() and such methods.

Maybe overriding the Wx::TreeItemId to allow it to have a data() method, but this could get somewhat tangled WRT events.

Overrides

In each of these methods, the TreeItemData parameter in the base class is replaced with a scalar $id, or an array [$id, $object].

$object can be whatever you want it to be. It will be returned when you call get_data().

AddRoot

$tree->AddRoot($text, $image, $selimage, $id_or_array);

AppendItem

$tree->AppendItem($parent, $text, $image, $selimage, $id_or_array);

InsertItem

$tree->InsertItem($parent, $prev, $text, $img, $selimg, $id_or_array);

PrependItem

$tree->PrependItem($parent, $text, $image, $selImage, $id_or_array);

Cleanup

These are overridden to cleanup the mappings.

Delete

$tree->Delete($item);

DeleteAllItems

$tree->DeleteAllItems;

DeleteChildren

$tree->DeleteChildren($item);

Internals

_new_data

my $data = $self->_new_data($id);

Or:

my $data = $self->_new_data([$id, $object]);

_map_new

my $item = $self->_map_new($item);

_map_item

$self->_map_item($id, $item);

_clear

$self->_clear;

Lookups

get_item

$self->get_item;

get_id

my $id = $self->get_id($item);

Data

get_data

$self->get_data($id|$item);

set_data

$self->set_data($id|$item, $data);

AUTHOR

Eric Wilhelm <ewilhelm at cpan dot org>

http://scratchcomputing.com/

COPYRIGHT

Copyright (C) 2006 Eric L. Wilhelm and OSoft, All Rights Reserved.

NO WARRANTY

Absolutely, positively NO WARRANTY, neither express or implied, is offered with this software. You use this software at your own risk. In case of loss, no person or entity owes you anything whatsoever. You have been warned.

LICENSE

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.