1 |
# An object that may be repeated over several rows. |
# An object that may be repeated over several rows. |
2 |
|
# Repeatable screen objects' height defaults to 1, not to "stretch" |
3 |
package neb::Tree::RepeatableScreenObject; |
package neb::Tree::RepeatableScreenObject; |
4 |
use strict; |
use strict; |
5 |
use English; |
use English; |
14 |
sub is_repeated |
sub is_repeated |
15 |
{ |
{ |
16 |
my $self = shift; |
my $self = shift; |
17 |
|
my $rows = $self->rows; |
18 |
return defined($self->attribute("rows")); |
|
19 |
|
return $rows ne "1"; |
20 |
} |
} |
21 |
|
|
22 |
sub rows |
sub rows |
23 |
{ |
{ |
24 |
my $self = shift; |
my $self = shift; |
25 |
|
my $rows = shift; |
26 |
|
|
27 |
|
$self->attribute("rows", $rows) if defined($rows); |
28 |
return ($self->attribute("rows") || 1); |
return ($self->attribute("rows") || 1); |
29 |
} |
} |
30 |
|
|
33 |
my $self = shift; |
my $self = shift; |
34 |
my $height = shift; |
my $height = shift; |
35 |
|
|
36 |
return $self->SUPER::height($height) unless $self->is_repeated; |
if (!$self->is_repeated) |
37 |
|
{ |
38 |
defined($self->SUPER::height) or $self->SUPER::height(1); |
$self->SUPER::height($height) if defined($height); |
39 |
|
$height = $self->SUPER::height; |
40 |
$self->attribute("rows", int($height/$self->SUPER::height)) if defined($height); |
return $self->SUPER::height(1) unless defined($height); |
41 |
|
return $height eq "*" ? undef : $height; |
42 |
return $self->SUPER::height * $self->rows; |
} |
43 |
|
|
44 |
|
$self->SUPER::height(1); |
45 |
|
$self->rows($height) if defined($height); |
46 |
|
$height = $self->rows; |
47 |
|
return $height eq "*" ? undef : $height; |
48 |
} |
} |
49 |
|
|
50 |
1; |
1; |