Tcl-pTk

 view release on metacpan or  search on metacpan

lib/Tcl/pTk/ttkBrowseEntry.pm  view on Meta::CPAN


This option is provided for compatibility with BrowseEntry, but is ignored. (The Combobox
widget always sets its listwidth the same as the width of the entry)

=item B<-state>

Specifies one of three states for the widget: normal, readonly, or
disabled.

=item B<-style>

This option is provided for compatibility with BrowseEntry, but is ignored.

=item B<-variable>

Specifies the variable in which the entered value is to be stored.

=back

=head1 METHODS

=over 4

=item B<insert(>I<index>, I<string>B<)>

Inserts the text of I<string> at the specified I<index>. This string
then becomes available as one of the choices.

=item B<delete(>I<index1>, I<index2>B<)>

Deletes items from I<index1> to I<index2>.

=item B<get(>I<index1>, I<index2>B<)>

gets items from I<index1> to I<index2>. This is there for compatibility with BrowseEntry.
 
=item B<choiceget>

Get the current selected choice. This directly maps to the I<get> method of the combobox

        
=back


=cut



use Tcl::pTk qw(Ev);
use Carp;
use strict;


use base qw(Tcl::pTk::Frame);
Construct Tcl::pTk::Widget 'ttkBrowseEntry';

sub Populate {
    my ($cw, $args) = @_;
     
    # Set foreground and background options to undef, unless defined during widget creation
    #   This keeps Tcl::pTk::Derived from setting these options from the options database, which is
    #    not needed for ttk widgets, and also makes -state => 'disabled' not look right
    foreach my $option( qw/ -foreground -background /){
            $args->{$option} = undef unless( defined($args->{$option} ));
    }
    
    # combobox widget
    my $lpack = delete $args->{-labelPack};
    if (not defined $lpack) {
	$lpack = [-side => 'left', -anchor => 'e'];
    }

    $cw->SUPER::Populate($args);


    my $label;
    if (exists $args->{-label}) {
	$label = $cw->ttkLabel(
			   -text => delete $args->{-label},
			  );
        $cw->Advertise('label' => $label );
        $label->pack(@$lpack);
    }
    
    # Setup label options that will be ignored  (setup to just be passive), because they don't
    #  exists in the substituted tile widget
    my @ignoreOptions = ( qw/ 
    -label -labelActivebackground -labelActiveforeground -labelAnchor -labelBackground
    -labelBitmap -labelBorderwidth -labelCompound -labelCursor -labelDisabledforeground
    -labelFont -labelForeground -labelHeight -labelHighlightbackground -labelHighlightcolor 
    -labelHighlightthickness -labelImage -labelJustify -labelPack -labelPadx -labelPady 
    -labelRelief -labelState -labelTakefocus -labelUnderline -labelVariable -labelWidth -labelWraplength 
    /);
    my %ignoreConfigSpecs = map( ($_ => [ "PASSIVE", $_, $_, undef ]), @ignoreOptions);

    my $cb = $cw->ttkCombobox();
    $cb->pack( -side => 'right', -fill => 'x', -expand => 1); 
    $cw->Advertise('combobox' => $cb);

    $cw->Delegates(DEFAULT => $cb); # methods are handled by the combobox
    $cw->ConfigSpecs( 
		      DEFAULT => [ 'combobox' ],  # Default options go to ttkCombobox
                      -arrowimage      => ['PASSIVE', 'arrowimage', 'arrowimage', undef], # ignored for compatibility with BrowseEntry
                      -autolimitheight => ['PASSIVE', 'autolimitheight', 'autolimitheight', undef], # ignored for compatibility with BrowseEntry
                      -autolistwidth  => ['PASSIVE', 'autolimitwidth', 'autolimitwidth', undef],    # ignored for compatibility with BrowseEntry
                      -browsecmd       => ['CALLBACK', 'browsecmd',  'browsecmd',  undef], 
                      -browse2cmd      => ['CALLBACK', 'browse2cmd', 'browse2cmd', undef], 
                      -buttontakefocus => [ {-takefocus => $cb}, qw/takefocus takefocus/, undef],
                      -choices         => [ {-values => $cb}, qw/choices choices/, undef],
                      -colorstate      => ['PASSIVE', 'colorstate', 'colorstate', undef], # ignored for compatibility with BrowseEntry
                      -listcmd         => ['CALLBACK', 'listcmd',  'listcmd',  undef], 
                      -listheight      => [ {-height => $cb}, qw/listheight listheight/, undef],
                      -listwidth       => ['PASSIVE', 'listwidth', 'listwidth', undef], # ignored for compatibility with BrowseEntry 
                                                                                        # (combobox listbox is always the same as -width, 
                                                                                        #   so not needed)
                      -variable        => [ {-textvariable => $cb}, qw/textvariable textvariable/, undef],
                      
                      -command     => '-browsecmd',
                      -options     => '-choices',
		      %ignoreConfigSpecs, 
                      



( run in 1.572 second using v1.01-cache-2.11-cpan-364913b4093 )