Tk::TixWidget - methods for Tix widgets


Tk-Tree documentation Contained in the Tk-Tree distribution.

Index


Code Index:

NAME

Top

Tk::TixWidget - methods for Tix widgets

SYNOPSIS

Top

    use Tk::TixWidget;
    @ISA = qw(Tk::Widget Tk::TixWidget);

DESCRIPTION

Top

Tk::TixWidget provides methods that emulate the those used by Tcl/Tix widgets. There are currently only two methods supported: tixEvent and tixGetimage.

tixGetimage( name )

Top

Given name, look for an image file with that base name and return a Tk::Image. File extensions are tried in this order: xpm, gif, ppm, xbm until a valid iamge is found. If no image is found, try a builtin image with that name.

tixEvent( option, ?value? )

Top

Return or set the tixEvent variable option. Currently, the only option used is "type".

AUTHOR

Top

Chris Dean <ctdean@cogit.com>


Tk-Tree documentation Contained in the Tk-Tree distribution.

#
# TixWidget -- General tix methods.
#
# Chris Dean <ctdean@cogit.com> 

package Tk::TixWidget;

use strict;

use Tk;
use Tk::Submethods ( 'tixEvent' => [qw(type)] );

sub tixEvent {
    my $w = shift;
    my $option = shift;
    my $data = $w->privateData( "Tk::TixWidget" );
    
    $data->{$option} = shift if @_;
    return( $data->{$option} );
}

use vars qw( %Images %IMAGE_METHODS );

%IMAGE_METHODS = ( 
    xpm => "Pixmap",
    gif => "Photo",
    ppm => "Photo",
    xbm => "Bitmap"
);

sub tixGetimage {
    my( $w, $name ) = @_;

    return( $Images{$name} ) if $Images{$name};

    foreach my $type (qw( xpm gif ppm xbm )) {
        my $method = $IMAGE_METHODS{$type};
        my $file = Tk->findINC( "$name.$type" );
        next unless( $file && $method );
        $Images{$name} = $w->$method( -file => $file );
        return( $Images{$name} );
    }

    # Try built-in bitmaps
    $Images{$name} = $w->Pixmap( -id => $name );
    return( $Images{$name} );
}

1;

__END__