| 1 | package Gapp::Table; | ||
| 2 | { | ||
| 3 | $Gapp::Table::VERSION = '0.60'; | ||
| 4 | } | ||
| 5 | |||
| 6 | |||
| 7 | use Moose; | ||
| 8 | use MooseX::LazyRequire; | ||
| 9 | use MooseX::SemiAffordanceAccessor; | ||
| 10 | use MooseX::StrictConstructor; | ||
| 11 | extends 'Gapp::Container'; | ||
| 12 | |||
| 13 | use Gapp::TableMap; | ||
| 14 | use Gapp::Types qw( GappTableMap ); | ||
| 15 | |||
| 16 | has '+gclass' => ( | ||
| 17 | default => 'Gtk2::Table', | ||
| 18 | ); | ||
| 19 | |||
| 20 | has 'map' => ( | ||
| 21 | is => 'rw', | ||
| 22 | isa => GappTableMap, | ||
| 23 | coerce => 1, | ||
| 24 | lazy_required => 1, | ||
| 25 | ); | ||
| 26 | |||
| 27 | has '_active_cell' => ( | ||
| 28 | is => 'rw', | ||
| 29 | isa => 'Maybe[Int]', | ||
| 30 | ); | ||
| 31 | |||
| 32 | sub current_cell { | ||
| 33 | my ( $self ) = @_; | ||
| 34 | $self->_active_cell ? $self->map->cells->[ $self->_active_cell ] : undef; | ||
| 35 | } | ||
| 36 | |||
| 37 | sub next_cell { | ||
| 38 | my ( $self ) = @_; | ||
| 39 | |||
| 40 | my $x = defined $self->_active_cell ? $self->_active_cell + 1 : 0; | ||
| 41 | my $cell = $self->map->cells->[$x]; | ||
| 42 | $self->_set_active_cell( $cell ? $x : undef ); | ||
| 43 | return $cell; | ||
| 44 | } | ||
| 45 | |||
| 46 | |||
| 47 | before _construct_gobject => sub { | ||
| 48 | my $self = shift; | ||
| 49 | return $self->set_args( [ $self->map->row_count, $self->map->col_count, 0 ] ); | ||
| 50 | }; | ||
| 51 | |||
| 52 | |||
| 53 | |||
| 54 | 1; | ||
| 55 | |||
| 56 | |||
| 57 | __END__ |