CodeManager
view release on metacpan or search on metacpan
lib/Prima/CodeManager/Outlines.pm view on Meta::CPAN
$traverse = sub {
my ( $node, $level, $lastChild) = @_;
$lines[ $level] = $lastChild ? undef : ( $i ? $i - 0.5 : 0.5);
if (( $i % STACK_FRAME) == STACK_FRAME - 1) {
push( @{$self-> {stackFrames}}, [@stack[0..$level]]);
push( @{$self-> {lineDefs}}, [@lines[0..$level]]);
}
$i++;
$level++;
if ( $node-> [DOWN] && $node-> [EXPANDED]) {
$stack[$level] = 0;
my $c = @{$node-> [DOWN]};
for ( @{$node-> [DOWN]}) {
$traverse-> ( $_, $level, --$c ? 0 : 1);
$stack[$level]++;
}
}
};
$stack[0] = 0;
my $c = @{$self-> {items}};
for (@{$self-> {items}}) {
$traverse-> ( $_, 0, --$c ? 0 : 1);
$stack[0]++;
}
undef $traverse;
$self-> {count} = $i;
my $fullc = $self-> {fullCalibrate};
my ( $notifier, @notifyParms) = $self-> get_notify_sub(q(MeasureItem));
my $maxWidth = 0;
my $indent = $self-> {indent};
$self-> push_event;
$self-> begin_paint_info;
$self-> iterate( sub {
my ( $current, $parent, $index, $position, $level, $visibility) = @_;
my $iw = $fullc ? undef : $current-> [WIDTH];
unless ( defined $iw) {
$notifier-> ( @notifyParms, $current, $level, \$iw);
$current-> [WIDTH] = $iw;
}
my $iwc = $iw + ( 2.5 + $level) * $indent;
$maxWidth = $iwc if $maxWidth < $iwc;
return 0;
});
$self-> end_paint_info;
$self-> pop_event;
$self-> {maxWidth} = $maxWidth;
}
sub calibrate
{
my $self = $_[0];
$self-> {fullCalibrate} = 1;
$self-> reset_tree;
delete $self-> {fullCalibrate};
$self-> update_tree;
}
sub update_tree
{
my $self = $_[0];
$self-> topItem( $self-> {topItem});
$self-> offset( $self-> {offset});
}
sub draw_items
{
my ($self, $canvas, $paintStruc) = @_;
my ( $notifier, @notifyParms) = $self-> get_notify_sub(q(DrawItem));
$self-> push_event;
for ( @$paintStruc) { $notifier-> ( @notifyParms, $canvas, @$_); }
$self-> pop_event;
}
sub set_auto_height
{
my ( $self, $auto) = @_;
$self-> itemHeight( $self-> font-> height) if $auto;
$self-> {autoHeight} = $auto;
}
sub set_extended_select
{
my ( $self, $esel) = @_;
$self-> {extendedSelect} = $esel;
}
sub set_focused_item
{
my ( $self, $foc) = @_;
my $oldFoc = $self-> {focusedItem};
$foc = $self-> {count} - 1 if $foc >= $self-> {count};
$foc = -1 if $foc < -1;
return if $self-> {focusedItem} == $foc;
return if $foc < -1;
$self-> {focusedItem} = $foc;
$self-> selectedItems([$foc])
if $self-> {multiSelect} && $self-> {extendedSelect} && ! exists $self-> {anchor};
$self-> notify(q(SelectItem), [[$foc, undef, 1]]) if $foc >= 0;
return if $self-> {doingExpand};
my $topSet = undef;
if ( $foc >= 0) {
my $rows = $self-> {rows} ? $self-> {rows} : 1;
if ( $foc < $self-> {topItem}) {
$topSet = $foc;
} elsif ( $foc >= $self-> {topItem} + $rows) {
$topSet = $foc - $rows + 1;
}
}
$self-> topItem( $topSet) if defined $topSet;
( $oldFoc, $foc) = ( $foc, $oldFoc) if $foc > $oldFoc;
my @a = $self-> get_active_area;
my $ih = $self-> {itemHeight};
my $lastItem = $self-> {topItem} + $self-> {rows};
$self-> invalidate_rect(
( run in 0.834 second using v1.01-cache-2.11-cpan-df04353d9ac )