package Toolbar;

sub new {
my $pkg  = shift;
my $setup = {};

$setup->{Buttons} 		= [];
$setup->{Help}			= [];
$setup->{Frame} 		= '';
$setup->{Activebutton}		= '';
$setup->{GridRowValue}		= 0;
$setup->{GridColumnValue}	= 1;

bless $setup,$pkg;
return $setup;
}#end new

sub Activebutton {
my  $pkg = shift;

if(@_){$pkg->{Activebutton} = shift;}
else{return $pkg->{Activebutton};}
}




sub Addbutton { 
my ($pkg,$hash) = @_;

$pkg->{GridColumnValue}++;

my $b = $pkg->{Frame}->Button(	-height 		=> -1,
				-fg 			=> 'black',
				-state			=> $$hash{"State"},
				-activebackground	=> 'lemonchiffon1',
				-font 			=> '-adobe-helvetica-bold-r-normal--14-100-100-100-p-82-iso8859-1'
		)->grid(	-row			=> $pkg->{GridRowValue},
				-column			=> $pkg->{GridColumnValue},
				-pady			=> 2,
				-padx			=> 2);
				
my $image = $b->Photo(-file => $$hash{"Title"});
$b->configure(-image => $image);

#$b->configure(-bitmap => '@/nfs/disk65/bsw/DODO-Ver-P02/tick.bmp');
push @{$pkg->{Buttons}},$b;

}# end Addbutton


sub Helpmessage {
my ($pkg,$item,$m) = @_;


my $h = $pkg->{Frame}->Label(	-width 			=> 50, 
				-height 		=> -1,
				-relief			=> 'sunken',
				-bg			=> 'grey85',
				-fg			=> 'grey73',
				-text			=> $m,
				-font 			=> '-adobe-helvetica-bold-r-normal--14-100-100-100-p-82-iso8859-1'
		)->grid(	-row			=> $item,
				-column			=> 2,
				-pady			=> 10,
				-padx			=> 10);
				
push @{$pkg->{Help}},$h;
}

sub State {
my $pkg = shift;
my $bg = 'grey85';
my $fg = 'grey73';


if(@_)
{
	$pkg->{State} = shift;
	
	foreach(@{$pkg->{Buttons}})
	{$_->configure(		-state			=> $pkg->{State});}
	
	if($pkg->{State} =~ /normal/)
	{
		$bg = 'lemonchiffon1';
		$fg = 'black';				
	}
	
	foreach(@{$pkg->{Help}})
	{$_->configure(		-bg			=> $bg,
				-fg			=> $fg);}
	
	
	
	
}
else
{
	return $pkg->{State};
}


}


sub Display {
my ($pkg, $parent, $row, $column) = @_;


$pkg->{Frame} = $$parent->Frame(		-relief 	=> 'ridge',
						-borderwidth 	=> 2,
						-anchor		=> 'center'
				)->grid(	-row 		=> $row,
						-column 	=> $column,
						-padx		=> 10,
						-pady		=> 4,
						-sticky 	=>'n');


}# end display


sub Setcommand {
my ($pkg,$button,$cmd) = @_;

$pkg->{Buttons}->[$button]->configure( -command => $cmd);

}

1;
