Tk-DKW

 view release on metacpan or  search on metacpan

Tk/CheckBox.pm  view on Meta::CPAN

package Tk::CheckBox;

use Tk;
use Tk::Canvas;
use Tk::Frame;

use vars qw ($VERSION);
use strict;
use Carp;

$VERSION = '0.01';

use base qw (Tk::Derived Tk::Frame);

Tk::Widget->Construct ('CheckBox');

*textvariable = \&Tk::CheckBox::TextVariable;
*get = \&Tk::CheckBox::CurrentState;
*disable = \&Tk::CheckBox::Disable;
*enable = \&Tk::CheckBox::Enable;
*state = \&Tk::CheckBox::State;
*set = \&Tk::CheckBox::State;

sub ClassInit
   {
    my ($p_Class, $p_Window) = (@_);
    $p_Window->bind ($p_Class, '<ButtonPress-1>', 'State');
    $p_Window->bind ($p_Class, '<space>', 'State');
    $p_Window->bind ($p_Class, '<Control-Tab>','focusNext');
    $p_Window->bind ($p_Class, '<Control-Shift-Tab>','focusPrev');
    $p_Window->bind ($p_Class, '<Tab>', 'focus');
    return $p_Class;
   }

sub new
   {
    my $p_Class = shift;
    my $this = $p_Class->SUPER::new (@_);
    $this->MapWindow();

    my $l_Canvas = $this->Component
       (
        'Canvas' => 'Canvas',
        '-background' => $this->cget ('-background'),
        '-height' => 15,
        '-width' => 15,
       );

    $l_Canvas->pack
       (
        '-fill' => 'both',
        '-expand' => 'true',
       );

    $this->{m_CheckMark} = $l_Canvas->create
       (
        'polygon',
        0, 8,
        3, 12,
        4, 14,
        4, 15,
        11, 4,
        15, 0,
        4, 11,
        0, 8,
       );

    $l_Canvas->Tk::bind ('<ButtonPress-1>' => sub {$this->State();});
    $this->bind ('<Tab>' => sub {$this->focus();});
    $this->Enable();
    $this->State ('off');
    return $this;
   }



( run in 2.418 seconds using v1.01-cache-2.11-cpan-e1769b4cff6 )