package ATR::Tk::CardRowParent;

use strict;
use warnings;
use base 'ATR::Tk::CardRowMouse';

=haed1 NAME

ATR::Tk::CardRowParent - a CardRow manager specialised for a mated mouse

=cut

# $Id: CardRowParent.pm,v 1.4 2005/02/04 16:15:49 mca Exp $

#----------------------------------------------------------------------------
#
# GUI setup info

# sub fieldInfo
# sub fieldInfo_Accessors
#    Currently the same as CardRowMouse...  some fields not used


#----------------------------------------------------------------------------
#
# Data change code

sub penned { $_[0]->adopted } # XXX: Bogus... fixes choice for button-ness, should be whether the mouse is on the card..?
# vaguely works because the button/entry choice is only evaluated once for the mating card
sub setPenned { die "the penned is bodged..." }

sub notifyMouseNameEdit {
    my $self = shift;
    # XXX: Rather specific to new mating setup
    $self->guiCard->redefaultFields; # update cardname, licence fields
}

sub rowSlotSex {
    my $self = shift;
    my $rowName = $self->name;
    return $1 if $rowName =~ /^par_([MF])$/;
    die "Unknown row name '$rowName' for parent slot on card";
}

sub saveCardMouse {
    my ($self, $mouse) = @_;

    my $since = ${ $self->guiCard->Subwidget('carddate')->getTextRef }; # XXX: Double-dirty private access!
    $since = $since ? ATR::Date->new_GuessDate($since, '00:00:00') : undef;
    $self->guiCard->pair->addParent
      (-mouse => $mouse,
       -slot => $self->rowSlotSex,
       -since => $since,
      );
}


1;
