Curses-UI
view release on metacpan or search on metacpan
lib/Curses/UI/Notebook.pm view on Meta::CPAN
($this->{-border} ? 4 : 0) -
($this->{-sbborder} ? 4 : 0);
$this->{-sw} = $this->{-bw} -
$this->{-ipadleft} -
$this->{-ipadright} -
($this->{-border} ? 2 : 0) -
($this->{-sbborder} ? 2 : 0);
$this->{-sy} = $this->{-by} +
$this->{-ipadtop} +
($this->{-border} ? 3 : 0) +
($this->{-sbborder} ? 3 : 0);
$this->{-sx} = $this->{-bx} +
$this->{-ipadleft} +
($this->{-border} ? 1 : 0) +
($this->{-sbborder} ? 1 : 0);
my @args = (
$this->{-sh},
$this->{-sw},
$this->{-sy},
$this->{-sx},
);
debug_msg " creating canvasscr with args " . join(",", @args);
$this->{-canvasscr} = $this->{-parent}->{-canvasscr}->derwin(@args);
unless (defined $this->{-canvasscr})
{
debug_msg " screen is too small for window widget!";
$Curses::UI::screen_too_small++;
return $this;
}
unless (defined $this->{-borderscr}) {
$this->{-bh} = $this->{-sh};
$this->{-bw} = $this->{-sw};
$this->{-by} = $this->{-sy};
$this->{-bx} = $this->{-sx};
}
return $this;
}
sub draw($;$) {
debug_msg;
my $this = shift;
my $no_doupdate = shift || 0;
debug_msg " \$no_doupdate = $no_doupdate";
# Return immediately if this object is hidden or if
# the screen is currently too small.
return if $this->hidden;
return if $Curses::UI::screen_too_small;
# Identify various pages of interest.
my $first_page = $this->first_page;
my $next_page = $this->next_page;
my $last_page = $this->last_page;
my $active_page = $this->active_page;
# Identify page window.
my $page_win = $this->{-borderscr};
# Hide cursor.
eval { curs_set(0) }; # not available on every system.
# Enable colors if desired.
if ($Curses::UI::color_support) {
debug_msg " enabling color support";
my $co = $Curses::UI::color_object;
my $pair = $co->get_color_pair(
$this->{-fg},
$this->{-bg}
);
$page_win->attron(COLOR_PAIR($pair));
}
my $ch_hbar = $this->{-border} ? ACS_HLINE : '-';
my $ch_vbar = $this->{-border} ? ACS_VLINE : '|';
my $ch_tl = $this->{-border} ? ACS_ULCORNER : '+';
my $ch_tr = $this->{-border} ? ACS_URCORNER : '+';
my $ch_bl = $this->{-border} ? ACS_LLCORNER : '+';
my $ch_br = $this->{-border} ? ACS_LRCORNER : '+';
my $ch_ttee = $this->{-border} ? ACS_TTEE : '+';
my $ch_btee = $this->{-border} ? ACS_BTEE : '+';
my $ch_ltee = $this->{-border} ? ACS_LTEE : '+';
my $ch_rtee = $this->{-border} ? ACS_RTEE : '+';
# Draw tabs along with a border if desired.
my($x, $y) = (0, 0);
$y = 1 if ($this->{-border} or $this->{-sbborder});
foreach my $page (@{$this->{-pages}}) {
debug_msg " drawing tab for page '$page'";
if ($this->{-border} or $this->{-sbborder}) {
debug_msg " adding left border at x=$x";
$page_win->addch(0, $x, ($page eq $first_page ? $ch_tl : $ch_ttee));
$page_win->addch(1, $x, $ch_vbar);
$page_win->addch(2, $x,
($page eq $first_page ?
($page eq $active_page ?
$ch_vbar :
$ch_ltee
) :
($page eq $active_page ?
$ch_br :
($page eq $next_page ?
$ch_bl :
$ch_btee
)
)
)
);
++$x;
}
debug_msg " adding $this->{-ipadleft} space" . ($this->{-ipadright} == 1 ? "" : "s") . " of padding at x=$x";
if ($this->{-border} or $this->{-sbborder}) {
for (my $i = 0; $i < $this->{-ipadleft}; $i++) {
$page_win->addch(0, $x, $ch_hbar);
#
$page_win->addch(2, $x, ($page eq $active_page ? ' ' : $ch_hbar));
++$x;
}
( run in 0.909 second using v1.01-cache-2.11-cpan-39bf76dae61 )