Curses-UI-Grid
view release on metacpan or search on metacpan
lib/Curses/UI/Grid/Cell.pm view on Meta::CPAN
return $this;
}
sub event_onblur() {
my $this = shift;
my $grid =$this->parent;
$this->xpos($this->align eq 'L' ? 0 : $this->current_width - 1);
$this->xoffset(0);
$grid->run_event('-oncellblur',$this)
or return;
if (ref($this->row) && $this->row->type ne 'head' ) {
my $undo = $this->row->get_undo_value($this->id);
my $text = $this->text;
# if data was changed
$grid->run_event('-oncellchange', $this)
or return
if ($undo || '') ne ($text || '');
}
$grid->{-cell_idx_prev} = $grid->{-cellid2idx}{$this->{-id}};
$this->{-focus} = 0;
$this->draw;
$this;
}
sub overwriteoff() { shift()->{-overwritetext}=0 }
sub overwriteon() { shift()->{-overwritetext}=1 }
sub overwritetext($;) {
my $this=shift;
my $result=!$this->{-overwrite} ? $this->{-overwrite} : $this->{-overwritetext};
$this->overwriteoff();
return $result;
}
sub has_focus() {
my $this=shift;
my $grid =$this->parent;
my $result=0;
$result=1 if($this->{-focus});
return $result;
}
sub focus($;) {
my $this=shift;
# Let the parent focus this object.
my $parent = $this->parent;
$parent->focus($this) if defined $parent;
$this->draw(1);
return $this;
}
sub bg() {
my $this = shift;
my $bg=shift;
$this->{-bg_}=$bg if(defined $bg);
return $this->{-bg_} ? $this->{-bg_} : exists( $this->{-bg} ) && $this->{-bg} ? $this->{-bg} : $this->row->bg;
}
sub fg() {
my $this = shift;
my $fg=shift;
$this->{-fg_}=$fg if(defined $fg);
return $this->{-fg_} ? $this->{-fg_} : exists( $this->{-fg} ) && $this->{-bg} ? $this->{-fg} : $this->row->fg;
}
sub row() {
my ($this, $row) = @_;
$this->{-row} = $row
if defined $row;
$this->{-row} = $this->parent->get_foused_row
if(!ref($this->{-row}) || ref($this->{-row}) ne 'Curses::UI::Grid::Row');
return $this->{-row};
}
sub align() { uc(shift()->{-align}) }
sub frozen() { shift->{-frozen} }
# defined width
sub width() {
my ($self, $width) = @_;
$self->{-width} = $width if(defined $width);
$self->{-width};
}
#current width
sub current_width {
my ($this, $current_width) = @_;
$this->{-current_width} = $current_width
if (defined $current_width);
return $this->{-current_width};
}
sub cleanup {
my $this = shift;
my $grid = $this->parent;
if ($grid) {
delete $this->{-cellid2idx}{$this->id};
delete $this->{-id2cell}{$this->id};
$grid->{-columns}--;
$this->{$_} = ''
for (qw(-canvasscr -parent -row));
}
}
sub label {
my ($this, $label) = @_;
$this->{-label} = $label
if defined $label;
$this->{-label};
}
sub DESTROY {
my $this = shift;
$this->cleanup;
}
__END__
( run in 1.243 second using v1.01-cache-2.11-cpan-5b529ec07f3 )