| 1 | package Tk::ListBrowser::Column; | ||
| 2 | |||
| 3 | =head1 NAME | ||
| 4 | |||
| 5 | Tk::ListBrowser::Column - Column organizer for Tk::ListBrowser. | ||
| 6 | |||
| 7 | =head1 SYNOPSIS | ||
| 8 | |||
| 9 | require Tk::ListBrowser; | ||
| 10 | my $ib= $window->ListBrowser(@options, | ||
| 11 | -arrange => 'column', | ||
| 12 | )->pack; | ||
| 13 | $ib->add('item_1', -image => $image1, -text => $text1); | ||
| 14 | $ib->add('item_2', -image => $image2, -text => $text2); | ||
| 15 | $ib->refresh; | ||
| 16 | |||
| 17 | =head1 DESCRIPTION | ||
| 18 | |||
| 19 | Contains all the drawing routines for L<Tk::ListBrowser> to | ||
| 20 | draw and navigate the list in a column organized manner. | ||
| 21 | |||
| 22 | No user serviceable parts inside. | ||
| 23 | |||
| 24 | =cut | ||
| 25 | |||
| 26 | use strict; | ||
| 27 | use warnings; | ||
| 28 | use vars qw ($VERSION); | ||
| 29 | $VERSION = 0.10; | ||
| 30 | |||
| 31 | use base qw(Tk::ListBrowser::Row); | ||
| 32 | |||
| 33 | sub new { | ||
| 34 | my $class = shift; | ||
| 35 | my $self = $class->SUPER::new(@_); | ||
| 36 | return $self | ||
| 37 | } | ||
| 38 | |||
| 39 | sub nextPosition { | ||
| 40 | my ($self, $x, $y, $column, $row) = @_; | ||
| 41 | my $cellheight = $self->cget('-cellheight'); | ||
| 42 | my $cellwidth = $self->cget('-cellwidth'); | ||
| 43 | my $newy = $y + ($cellheight * 2); | ||
| 44 | my ($cwidth, $cheight) = $self->canvasSize; | ||
| 45 | if ($newy >= $cheight) { | ||
| 46 | $y = $self->cget('-margintop'); | ||
| 47 | $x = $x + $cellwidth + 1; | ||
| 48 | $row = 0; | ||
| 49 | $column ++; | ||
| 50 | } else { | ||
| 51 | $y = $y + $cellheight + 1; | ||
| 52 | $row ++; | ||
| 53 | } | ||
| 54 | return ($x, $y, $column, $row) | ||
| 55 | } | ||
| 56 | |||
| 57 | sub scroll { | ||
| 58 | return 'horizontal' | ||
| 59 | } | ||
| 60 | |||
| 61 | sub type { | ||
| 62 | return 'column' | ||
| 63 | } | ||
| 64 | |||
| 65 | =head1 LICENSE | ||
| 66 | |||
| 67 | Same as Perl. | ||
| 68 | |||
| 69 | =head1 AUTHOR | ||
| 70 | |||
| 71 | Hans Jeuken (hanje at cpan dot org) | ||
| 72 | |||
| 73 | =head1 TODO | ||
| 74 | |||
| 75 | =over 4 | ||
| 76 | |||
| 77 | =back | ||
| 78 | |||
| 79 | =head1 BUGS AND CAVEATS | ||
| 80 | |||
| 81 | If you find any bugs, please report them here: L<https://github.com/haje61/Tk-ListBrowser/issues>. | ||
| 82 | |||
| 83 | =cut | ||
| 84 | |||
| 85 | 1; |