# Copyright (c) 1995-1999 Nick Ing-Simmons. All rights reserved.
# This program is free software; you can redistribute it and/or
# modify it under the same terms as Perl itself.
# An example of a geometry manager "widget" in perl
$VERSION = '3.016'; # $Id: //depot/Tk8/Tk/Tiler.pm#16 $
Construct Tk
::Widget
'Tiler';
sub Tk
::Widget
::ScrlTiler
{ shift->Scrolled('Tiler' => @_) }
return (wantarray) ?
() : 0;
$obj->SUPER::Populate
($args);
$obj->{LayoutPending
} = 0;
$obj->ConfigSpecs('-takefocus' => ['SELF', 'takeFocus','TakeFocus',1],
'-highlightthickness' => ['SELF', 'highlightThickness','HighlightThickness',2],
'-yscrollcommand' => ['CALLBACK',undef,undef,undef],
'-columns' => ['PASSIVE','columns','Columns',5],
'-rows' => ['PASSIVE','rows','Rows',10]
my $r = $w->cget('-rows');
my $c = $w->cget('-columns');
my $bw = $w->cget(-highlightthickness
);
if (defined $r && defined $c)
$w->GeometryRequest($c*$w->{Sw
}+2*$bw,$r*$w->{Sh
}+2*$bw);
my $bw = $m->cget(-highlightthickness
);
my $why = $m->{LayoutPending
};
my $w = $m->{Sw
} || 1; # max width of slave
my $h = $m->{Sh
} || 1; # max height of slave
# Set size and position of slaves
my $rows = $m->{Rows
} = int(($H-2*$bw)/$h) || 1;
my $cols = $m->{Cols
} = int(($W-2*$bw)/$w) || 1;
my $need = $m->{Need
} = int( (@
{$m->{Slaves
}}+$cols-1)/$cols );
$m->{Start
} = ($need - $rows) if ($m->{Start
} + $rows > $need);
$m->{Start
} = 0 if ($m->{Start
} < 0);
foreach $s (@
{$m->{Slaves
}})
$s->ResizeWindow($w,$h) if ($why & 1);
$s->ResizeWindow($w,$h) if ($why & 1);
if (defined $m->{Prev
} && $m->{Prev
} > $m->{Start
})
my ($s,$x,$y) = (@
$posn);
$m->{Prev
} = $m->{Start
};
$m->Callback(-yscrollcommand
=> $m->{Start
}/$need,$row/$need) if $need;
$m->afterIdle(['Layout',$m]) unless ($m->{LayoutPending
});
$m->{LayoutPending
} |= $why;
$m->change_size if ($sz);
@
{$m->{Slaves
}} = grep($_ != $s,@
{$m->{Slaves
}});
push(@
{$m->{Slaves
}},$s);
$m->SlaveGeometryRequest($s);
$m->{Start
} = int($m->{Need
} * $frac);
my ($m,$delta,$type) = @_;
$delta *= $m->{Rows
}/2 if ($type eq 'pages');
sub yview
{ my $w = shift; my $c = shift; $w->$c(@_) }
print 'Focus ',$w->PathName,"\n";
$mw->bind($class,'<Configure>',['QueueLayout',8]);
$mw->bind($class,'<FocusIn>', 'NoOp');
$mw->YscrollBind($class);