| 1 | package Tk::PopColor; | ||
| 2 | |||
| 3 | use strict; | ||
| 4 | use warnings; | ||
| 5 | use vars qw($VERSION); | ||
| 6 | $VERSION = '0.12'; | ||
| 7 | use Tk; | ||
| 8 | |||
| 9 | use base qw(Tk::Derived Tk::Poplevel); | ||
| 10 | |||
| 11 | Construct Tk::Widget 'PopColor'; | ||
| 12 | |||
| 13 | require Tk::ColorPicker; | ||
| 14 | |||
| 15 | =head1 NAME | ||
| 16 | |||
| 17 | Tk::PopColor - Pop A Tk::ColorPicker widget relative to a widget. | ||
| 18 | |||
| 19 | =head1 SYNOPSIS | ||
| 20 | |||
| 21 | use Tk::PopColor; | ||
| 22 | my $pop = $window->PopColor( | ||
| 23 | -widget => $widget, | ||
| 24 | ); | ||
| 25 | $pop->popUp; | ||
| 26 | |||
| 27 | =head1 DESCRIPTION | ||
| 28 | |||
| 29 | Inherits L<Tk::Poplevel> | ||
| 30 | |||
| 31 | Tk::PopColor is a L<Tk::Poplevel> containing a L<Tk::ColorPicker>. | ||
| 32 | See these two for options and methods. | ||
| 33 | |||
| 34 | =cut | ||
| 35 | |||
| 36 | sub Populate { | ||
| 37 | my ($self,$args) = @_; | ||
| 38 | |||
| 39 | $self->SUPER::Populate($args); | ||
| 40 | |||
| 41 | my $picker = $self->ColorPicker( | ||
| 42 | )->pack(-fill => 'both'); | ||
| 43 | $self->Advertise(Picker => $picker); | ||
| 44 | $self->ConfigSpecs( | ||
| 45 | DEFAULT => [ $picker ], | ||
| 46 | ); | ||
| 47 | |||
| 48 | $self->Delegates( | ||
| 49 | DEFAULT => $picker, | ||
| 50 | ); | ||
| 51 | } | ||
| 52 | |||
| 53 | sub popDown { | ||
| 54 | my $self = shift; | ||
| 55 | my $color = $self->compoundColor; | ||
| 56 | $self->historyAdd($self->compoundColor); | ||
| 57 | $self->SUPER::popDown | ||
| 58 | } | ||
| 59 | |||
| 60 | sub popCancel { | ||
| 61 | my $self = shift; | ||
| 62 | $self->SUPER::popDown | ||
| 63 | } | ||
| 64 | |||
| 65 | sub popUp { | ||
| 66 | my $self = shift; | ||
| 67 | $self->ConfigMode(1); | ||
| 68 | $self->SUPER::popUp; | ||
| 69 | $self->historyUpdate; | ||
| 70 | $self->after(300, ['ConfigMode', $self, 0]);; | ||
| 71 | } | ||
| 72 | |||
| 73 | |||
| 74 | =head1 LICENSE | ||
| 75 | |||
| 76 | Same as Perl. | ||
| 77 | |||
| 78 | =head1 AUTHOR | ||
| 79 | |||
| 80 | Hans Jeuken (hanje at cpan dot org) | ||
| 81 | |||
| 82 | =cut | ||
| 83 | |||
| 84 | =head1 BUGS | ||
| 85 | |||
| 86 | Unknown. If you find any, please contact the author. | ||
| 87 | |||
| 88 | =cut | ||
| 89 | |||
| 90 | 1; | ||
| 91 | __END__ |