| 1 | package Tk::AppWindow::Ext::StatusBar::SImageItem; | ||
| 2 | |||
| 3 | use strict; | ||
| 4 | use warnings; | ||
| 5 | |||
| 6 | use Tk; | ||
| 7 | use base qw( Tk::AppWindow::Ext::StatusBar::STextItem); | ||
| 8 | Construct Tk::Widget 'SImageItem'; | ||
| 9 | |||
| 10 | sub Populate { | ||
| 11 | my ($self,$args) = @_; | ||
| 12 | |||
| 13 | $self->SUPER::Populate($args); | ||
| 14 | |||
| 15 | $self->ConfigSpecs( | ||
| 16 | -valueimages => ['PASSIVE', undef, undef, {}], | ||
| 17 | # DEFAULT => ['SELF'], | ||
| 18 | ); | ||
| 19 | } | ||
| 20 | |||
| 21 | sub Update { | ||
| 22 | my $self = shift; | ||
| 23 | my $value = $self->Callback(-updatecommand => $self); | ||
| 24 | my $imagehash = $self->cget('-valueimages'); | ||
| 25 | my $image = $imagehash->{$value}; | ||
| 26 | $image = 'error' unless defined $image; | ||
| 27 | unless (ref $image) { | ||
| 28 | $self->configure(-bitmap => $image); | ||
| 29 | } else { | ||
| 30 | $self->configure(-image => $image); | ||
| 31 | } | ||
| 32 | } | ||
| 33 | |||
| 34 | 1; |