#!/usr/bin/perl -w
use strict;

# We do not want STDERR to clutter our screen.
open STDERR, ">/dev/null";

use FindBin;
use lib "$FindBin::RealBin/../lib";
use Curses::UI;
my $cui = new Curses::UI ( -clear_on_exit => 1 );

my $win = $cui->add('window_id', 'Window');

my $values = [ 1,2,3,4,5,6,7 ];
my $labels = {
	1  => 'First',
	2  => 'Second',
	3  => 'Third',
	4  => 'Fourth',
	5  => 'Fifth',
	6  => 'Sixth',
	7  => 'Seventh',
};

$win->add(
	'label1', 'Label',
	-text => "Press <CTRL+Q> to leave this demo."
);

$win->add(
	'label2', 'Label',
	-y => 1,
	-text => "Press / or ? to search through a listbox",
);

$win->add(
        'listbox1', 'ListBox',
	-y         => 3,
	-title     => 'values',
        -values    => $values,
	-border    => 1,
 	-width     => 11,
	-height    => 9,
);

$win->add(
        'listbox2', 'ListBox',
	-x         => 12,
	-y         => 3,
	-title     => 'labels',
        -values    => $values,
        -labels    => $labels,
	-border    => 1,
 	-width     => 11,
	-height    => 9,
);

$win->add(
        'listbox3', 'ListBox',
	-title     => 'multi',
	-x         => 24,
	-y         => 3,
        -values    => $values,
        -labels    => $labels,
	-border    => 1,
 	-width     => 14,
	-height    => 9,
	-multi     => 1,
);

$win->add(
        'listbox4', 'ListBox',
	-x         => 39,
	-y         => 3,
	-title     => 'radio',
        -values    => $values,
        -labels    => $labels,
	-border    => 1,
 	-width     => 14,
	-height    => 9,
	-radio     => 1,
);

$win->add(
        'listbox5', 'ListBox',
	-y         => 12,
	-title     => 'scroll',
        -values    => [ @$values, @$values ],
        -labels    => $labels,
	-vscrollbar => 1,
	-border    => 1,
 	-width     => 11,
	-height    => 9,
);

$win->add(
        'listbox6', 'ListBox',
	-y         => 12,
        -x         => 12,
	-title     => 'wraprnd',
        -values    => $values,
        -labels    => $labels,
	-border    => 1,
 	-width     => 11,
	-height    => 9,
	-wraparound => 1,
);

$win->add(
        'listbox7', 'ListBox',
	-y         => 12,
        -x         => 24,
	-radio	   => 1,
        -values    => [
		"Of course it's also",
		"possible to create a",
		"listbox without a ",
		"border as you can ",
		"see in this example.",			
        ],
	-ipad    => 1,
 	-width     => 29,
	-height    => 9,
);

$win->returnkeys("\cC", "\cQ");

$win->focus;

