AAC-Pvoice
view release on metacpan or search on metacpan
lib/AAC/Pvoice/Panel.pm view on Meta::CPAN
sub Clear
{
my $self = shift;
$self->{tls}->Remove($_) for (0..$self->{lastrow});
foreach my $row (@{$self->{rows}})
{
$_->Destroy for $row->GetChildren();
$row->Destroy
}
$_->Destroy for @{$self->{unselectablerows}};
$self->{text}->Destroy if exists $self->{text};
$self->{title}->Destroy if exists $self->{title};
$self->{rows} = [];
$self->{unselectablerows} = [];
$self->SUPER::Clear();
$self->{totalrows} = 0;
$self->{lastrow} = 0;
$self->Refresh;
}
sub Finalize
{
my $self = shift;
my $dc = Wx::WindowDC->new($self);
$self->DrawBackground($dc);
unless ($self->{disabletextrow})
{
# Create the TextControl
my $font = Wx::Font->new( 24, # font size
wxSWISS, # font family
wxNORMAL, # style
wxNORMAL, # weight
0,
'Comic Sans MS',# face name
wxFONTENCODING_SYSTEM);
$font->SetUnderlined(1);
$self->{ta} = Wx::TextAttr->new( Wx::Colour->new(0,0,0), # textcol
Wx::Colour->new(255,255,255),# backgr.
$font); # font
my $rowsizer = Wx::GridSizer->new(1,0);
$self->{text} = Wx::TextCtrl->new( $self, # parent
-1, # id
'', # text
wxDefaultPosition,# position
[4*($self->{realx}/5),60], # size
wxTE_RICH|
wxTE_MULTILINE); # style
# set the text-attributes
$self->{text}->SetDefaultStyle($self->{ta});
$rowsizer->Add($self->{text}, # what to add
0, # unused
wxALIGN_CENTRE|wxALL, # style
$self->{itemspacing}); # padding
$self->{tls}->Add($rowsizer, 0, wxALIGN_CENTRE, 0);
$self->{textrowsizer} = $rowsizer;
$self->{text}->SetValue(my $x = $self->RetrieveText);
$self->{text}->SetStyle(0, length($self->{text}->GetValue), $self->{ta});
$self->{text}->Refresh(); # Added to test it on the Mercury...added text
# isn't visible there...
}
$self->{title}->SetBackgroundColour($self->BackgroundColour) unless $self->{disabletitle};
$self->{tls}->AddGrowableCol(0);
$self->Layout;
# Select the first row
$self->{selectedrow} = 0;
$self->{selecteditem} = 0;
$self->SetSelectionBorder($self->{rows}->[$self->{selectedrow}]) if $self->{rowcolumnscanning} && not $self->{editmode};
$self->{rowselection} = 1;
$self->Refresh;
$self->Update();
$self->{unfinished} = 0;
}
sub Next
{
my $self = shift;
return if ($self->{editmode} || $self->{unfinished});
$self->{input}->QuitAutoscan;
if ($self->{rowselection})
{
$self->SetNormalBorder($self->{rows}->[$self->{selectedrow}]) if $self->{rowcolumnscanning};
if ($self->{selectedrow} < ($self->{totalrows}-1))
{
$self->{selectedrow}++;
}
else
{
$self->{selectedrow} = 0;
}
$self->SetSelectionBorder($self->{rows}->[$self->{selectedrow}]) if $self->{rowcolumnscanning};
}
else
{
$self->SetNormalBorder($self->{rows}->[$self->{selectedrow}]->{items}->[$self->{selecteditem}]) if $self->{rowcolumnscanning};
if ($self->{selecteditem} < ($self->{rows}->[$self->{selectedrow}]->{totalitems}-1))
{
$self->{selecteditem}++;
}
else
{
$self->{selecteditem} = 0;
}
$self->SetSelectionBorder($self->{rows}->[$self->{selectedrow}]->{items}->[$self->{selecteditem}]) if $self->{rowcolumnscanning};
}
$self->{input}->StartAutoscan;
}
sub Select
{
my $self = shift;
return if $self->{editmode};
$self->{input}->QuitAutoscan;
if (($self->{rowselection}) && (@{$self->{rows}->[$self->{selectedrow}]->{items}} == 1))
{
$self->{rowselection} = 0;
$self->{selecteditem} = 0;
}
if ($self->{rowselection})
{
$self->SetNormalBorder($self->{rows}->[$self->{selectedrow}]) if $self->{rowcolumnscanning};
$self->{rowselection} = 0;
$self->{selecteditem} = 0;
$self->SetSelectionBorder($self->{rows}->[$self->{selectedrow}]->{items}->[$self->{selecteditem}]) if $self->{rowcolumnscanning};
}
else
{
$self->SetNormalBorder($self->{rows}->[$self->{selectedrow}]->{items}->[$self->{selecteditem}]) if $self->{rowcolumnscanning};
$self->SetSelectionBorder($self->{rows}->[$self->{selectedrow}]) if $self->{rowcolumnscanning};
&{$self->{rows}->[$self->{selectedrow}]->{actions}->[$self->{selecteditem}]};
$self->{rowselection} = 1;
}
$self->{input}->StartAutoscan;
}
sub ToRowSelection
{
my $self = shift;
return if $self->{editmode};
$self->SetNormalBorder($self->{rows}->[$self->{selectedrow}]->{items}->[$self->{selecteditem}]) if $self->{rowcolumnscanning};
$self->SetSelectionBorder($self->{rows}->[$self->{selectedrow}]) if $self->{rowcolumnscanning};
$self->{rowselection} = 1;
}
sub DisplayAddText
{
my $self = shift;
push @{$self->{displaytextsave}}, $_[0];
$self->{text}->AppendText($_[0]);
$self->{text}->Refresh(); # Added to test it on the Mercury...added text
# isn't visible there...
}
sub SpeechAddText
{
my $self = shift;
push @{$self->{speechtextsave}}, $_[0];
}
sub RetrieveText
{
my $self = shift;
return wantarray ? @{$self->{displaytextsave}} : join('', @{$self->{displaytextsave}});
}
sub ClearText
{
my $self = shift;
$self->{displaytextsave}=[];
$self->{speechtextsave}=[];
$self->{text}->SetValue('');
$self->{text}->Refresh(); # Added to test it on the Mercury...added text
# isn't visible there...
}
sub BackspaceText
{
my $self = shift;
pop @{$self->{displaytextsave}};
pop @{$self->{speechtextsave}};
$self->{text}->SetValue(my $x = $self->RetrieveText);
$self->{text}->SetStyle(0, length($self->{text}->GetValue), $self->{ta});
$self->{text}->Refresh(); # Added to test it on the Mercury...added text
# isn't visible there...
}
sub SpeechRetrieveText
{
my $self = shift;
return wantarray ? @{$self->{speechtextsave}} : join('', @{$self->{speechtextsave}});
}
1;
__END__
=pod
=head1 NAME
AAC::Pvoice::Panel - The base where a pVoice application consists of
=head1 SYNOPSIS
use AAC::Pvoice::Panel;
=head1 DESCRIPTION
=head1 USAGE
=head2 new(parent, id, size, position, style, disabletextrow, itemspacing, selectionborderwidth, disabletitle)
This is the constructor for a new AAC::Pvoice::Panel. The first 5 parameters are
equal to the parameters for a normal Wx::Panel, see the wxPerl documentation
for those parameters.
=over 4
=item disabletextrow
This is s a boolean (1 or 0), which determines
if the text-input field at the bottom of the screen should be hidden or
not. Normally this inputfield will be shown (for an application like pVoice
this is normal, because that will contain the text the user is writing),
but for an application like pMusic this row is not nessecary, so it can be
disabled.
=item itemspacing
This is the spacing used between the rows that are appended.
=item selectionborderwidth
This is the width of the border around a selected row or a selected item.
=item disabletitle
This is also a boolean (1 or 0), which determines if the panel should
reserve space for a title. If disabletitle is set to 1, AddTitle won't have
( run in 1.558 second using v1.01-cache-2.11-cpan-8f98c5d2c55 )