Curses-UI-Grid
view release on metacpan or search on metacpan
lib/Curses/UI/Grid/Row.pm view on Meta::CPAN
return $this;
}
sub draw_row(;$) {
my $this = shift;
my $no_doupdate = shift || 0;
# Return immediately if this object is hidden.
return $this if $this->hidden;
my $p=$this->parent();
$this->canvasscr->attron(A_BOLD) if($this->{-focus});
$p->run_event('-onrowdraw',$this);
# Let there be color for data cell
# for header grid's colors
my $fg=($this->type ne 'head') ? $this->fg : $p->{-fg} ;
my $bg=($this->type ne 'head') ? $this->bg : $p->{-bg} ;
my $pair=$p->set_color($fg,$bg,$this->canvasscr);
my $c=\@{ $p->{_cells} };
for my $i(0 .. $#{$c} ) {
$p->id2cell( $$c[$i] )->draw_cell(1,$this);;
}
$this->canvasscr->attroff(A_BOLD) if($this->{-focus});
$p->color_off($pair,$this->canvasscr);
$this->draw_vline() if($this->type ne "head");
$this->canvasscr->noutrefresh;
return $this;
}
sub draw_vline {
my $this = shift;
my $grid = $this->parent;
my $pair = $grid->set_color(
($grid->{-bfg} || '') ne '-1'
? $grid->{-bfg}
: $grid->{-fg},
$this->bg,
$this->canvasscr
);
foreach my $x (@{$grid->vertical_lines}) {
$this->canvasscr->move($this->y,$x);
$this->canvasscr->vline(ACS_VLINE,1);
}
$grid->color_off($pair, $this->canvasscr);
$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->parent()->{-bg};
}
sub fg() {
my $this = shift;
my $fg= shift;
$this->{-fg_}=$fg if(defined $fg);
return $this->{-fg_} ? $this->{-fg_} :exists( $this->{-fg} ) ? $this->{-fg} : $this->parent()->{-fg};
}
sub event_onfocus() {
my $this = shift;
my $p=$this->parent;
return $p->focus($this) unless($this->focusable);
# Let the parent find another widget to focus
# if this widget is not focusable.
$this->{-focus} = 1;
$p->run_event('-onrowfocus',$this);
$p->{-row_idx}=$p->{-rowid2idx}{ $this->{-id} };
# clear date change info
$this->{-cell_undo} = {};
$this->draw(1);
my $cell = $p->get_foused_cell;
$cell->event_onfocus if (defined $cell);
return $this;
}
sub event_onblur() {
my $this = shift;
my $p=$this->parent;
#check if data row was changed
my $changed=0;
for my $k (keys %{ $this->{-cell_undo} } ) {
if( $this->{-cell_undo}{$k} ne $this->{-cell}{$k} ) {
$changed=1;
last;
}
}
if($changed) {
my $ret= $p->run_event('-onrowchange',$this);
#if event return values and it's equal 0 then cancell onblur event
if(defined $ret) {
if($ret eq "0") {
return '';
}
}
}
#If the Container loose it focus
#the current focused child must be unfocused
my $cell = $this->parent->get_foused_cell;
#test if current row can be unfocused otherwise cancel current event
if(defined $cell) {
my $ret = $cell->event_onblur();
return 0 if(defined $ret && !$ret);
}
my $ret=$p->run_event('-onrowblur',$this);
if(defined $ret) {
if($ret eq "0") {
( run in 0.906 second using v1.01-cache-2.11-cpan-5b529ec07f3 )