| 1 | package Tk::ECWarning; | ||
| 2 | |||
| 3 | $VERSION='0.00'; | ||
| 4 | |||
| 5 | use Tk qw(Ev); | ||
| 6 | use strict; | ||
| 7 | use Carp; | ||
| 8 | use base qw(Tk::Derived Tk::Toplevel); | ||
| 9 | use Tk::widgets qw(Button Label Frame); | ||
| 10 | |||
| 11 | Construct Tk::Widget 'ECWarning'; | ||
| 12 | |||
| 13 | sub Cancel { | ||
| 14 | my ($w) = @_; | ||
| 15 | $w -> {Configure}{-response} = 'Cancel'; | ||
| 16 | } | ||
| 17 | |||
| 18 | sub Ok { | ||
| 19 | my ($w) = @_; | ||
| 20 | $w -> {Configure}{-response} = 'Ok'; | ||
| 21 | } | ||
| 22 | |||
| 23 | sub Populate { | ||
| 24 | my ($w, $args) = @_; | ||
| 25 | $w->SUPER::Populate($args); | ||
| 26 | |||
| 27 | $w->ConfigSpecs( | ||
| 28 | -font => ['CHILDREN',undef,undef,'*-helvetica-medium-r-*-*-12-*'], | ||
| 29 | -message => ['PASSIVE', undef, undef, ''], | ||
| 30 | -response => ['PASSIVE', undef, undef, ''] | ||
| 31 | ); | ||
| 32 | |||
| 33 | $w -> configure (-title => 'Warning'); | ||
| 34 | |||
| 35 | my $l = $w -> Component( Label => 'entry_label', | ||
| 36 | -textvariable => \$w->{Configure}{-message}); | ||
| 37 | $l -> grid( -column => 2, -row => 1, -padx => 5, -pady => 5, | ||
| 38 | -columnspan => 3); | ||
| 39 | |||
| 40 | $b = $w -> Button(-text => 'Ok', -command => ['Ok', $w], | ||
| 41 | -width => 10 ); | ||
| 42 | $b->grid(-column=>2,-row=>2,-padx=>5,-pady=>5,-sticky=>'nsew'); | ||
| 43 | |||
| 44 | |||
| 45 | $b = $w->Button( -text => 'Cancel', -command => ['Cancel', $w], | ||
| 46 | -width => 10); | ||
| 47 | $b->grid( -column => 4, -row => 2, -padx => 5, -pady => 5, | ||
| 48 | -sticky => 'nsew' ); | ||
| 49 | $w -> withdraw; | ||
| 50 | return $w; | ||
| 51 | } | ||
| 52 | |||
| 53 | sub Show { | ||
| 54 | my ($w, @args) = @_; | ||
| 55 | $w -> Popup(@args); | ||
| 56 | $w -> waitVariable (\$w->{Configure}{-response}); | ||
| 57 | $w -> withdraw; | ||
| 58 | return $w->{Configure}{-response}; | ||
| 59 | } | ||
| 60 | |||
| 61 | 1; |