#!/usr/local/bin/perl 
#######################################################################
# This software has been created by Genome Research Limited (GRL).    # 
# GRL hereby grants permission to use, copy, modify and distribute    # 
# this software and its documentation for non-commercial purposes     # 
# without fee at the user's own risk on the basis set out below.      #
# GRL neither undertakes nor accepts any duty whether contractual or  # 
# otherwise in connection with the software, its use or the use of    # 
# any derivative, and makes no representations or warranties, express #
# or implied, concerning the software, its suitability, fitness for   #
# a particular purpose or non-infringement.                           #
# In no event shall the authors of the software or GRL be responsible # 
# or liable for any loss or damage whatsoever arising in any way      # 
# directly or indirectly out of the use of this software or its       # 
# derivatives, even if advised of the possibility of such damage.     #
# Our software can be freely distributed under the conditions set out # 
# above, and must contain this copyright notice.                      #
#######################################################################

# $Id: owl_view_selector.pm,v 1.4 1998/09/23 08:30:23 dn1 Exp $
# $Log: owl_view_selector.pm,v $
# Revision 1.4  1998/09/23  08:30:23  dn1
# *** empty log message ***
#
# Revision 1.3  1998/06/24  08:45:56  dn1
# *** empty log message ***
#

require Exporter;

@owl_view_selector::ISA = qw(Exporter);
@owl_view_selector::EXPORT = qw(view_selector);

#use Data::Dumper;

package owl_view_selector;

# DN1
################################################################################
#Interrogate the database for blocks of 'created' samples for the correct view #
################################################################################
# Supply the module with 

sub view_selector {
    my ($mw, $possibles) = @_;
    my $selectedView = "";
    my $choice;
    my $win = $mw->Toplevel;
    $win->configure (-title => "view_selector");
    my $frame = $win->Frame();
    my $label = $frame->Label(-text => "Please select a database view for this session.");
    $label->pack(-side=> 'top');
    my $scrllist = $frame->ScrlListbox (
					-bg => 'lemonchiffon1',
					-scrollbars => 'e',
					-label => "You can choose from the following.",
					-height => 10,
					-width => 30
					);
    $scrllist->bind ('<Double-Button-1>' => sub { 
	$choice = $scrllist->get('active');
	if ($choice eq ''){
	    return;
	}
	$selectedView = $choice;
	$win->destroy();

    });
    $scrllist->pack(-side => 'left', -expand => 1, -fill => 'both');
    $scrllist->insert('end', @$possibles);
    $frame->pack;
    # A frame for some buttons
    my $frameb = $win->Frame();
    $frameb->pack(-side => 'bottom', -expand => 'no', -fill => 'both');
    my $w_dismiss = $frameb->Button(
				    -text    => 'Cancel',
				    -command => sub {
					$selectedView = "None";
					$win->destroy();
				    });
    $w_dismiss->pack(-side => 'right',  -expand => 1);
    $frame->waitWindow;
    return $selectedView;
}

1;





