AAC-Pvoice
view release on metacpan or search on metacpan
lib/AAC/Pvoice/Panel.pm view on Meta::CPAN
$dc->DrawRoundedRectangle($x-($self->{itemspacing}/2-1), $y-($self->{itemspacing}/2-1), $xsize+($self->{itemspacing}/2+1), $ysize+($self->{itemspacing}/2+1), $self->RoundCornerRadius);
$dc->EndDrawing;
}
sub SetSelectionBorder
{
my $self = shift;
$self->{selectedwindow} = shift;
$self->{setselection} = 1;
my $dc = Wx::WindowDC->new($self->{selectedwindow}->GetParent);
$self->DrawBorder($dc);
}
sub SetNormalBorder
{
my $self = shift;
$self->{selectedwindow} = shift;
$self->{setselection} = 0;
my $dc = Wx::WindowDC->new($self->{selectedwindow}->GetParent);
$self->DrawBorder($dc);
}
sub RoundCornerRadius
{
my $self = shift;
$self->{radius} = shift || $self->{radius};
return $self->{radius};
}
sub xsize
{
my $self = shift;
$self->{xsize} = shift || $self->{xsize};
return $self->{xsize}-2*$self->RoundCornerRadius;
}
sub ysize
{
my $self = shift;
$self->{ysize} = shift || $self->{ysize};
return $self->{ysize}-2*$self->RoundCornerRadius;
}
sub lastrow
{
my $self = shift;
return $self->{lastrow};
}
sub SelectColour
{
my $self = shift;
$self->{selectcolour} = shift || $self->{selectcolour};
return $self->{selectcolour};
}
sub BackgroundColour
{
my $self = shift;
$self->{backgroundcolour} = shift || $self->{backgroundcolour};
return $self->{backgroundcolour};
}
sub DrawBackground
{
my $self = shift;
my $dc = shift;
$dc->SetBrush(Wx::Brush->new($self->BackgroundColour, wxSOLID));
$dc->SetPen(Wx::Pen->new($self->BackgroundColour, 1, wxSOLID));
$dc->DrawRoundedRectangle(0,0,$self->{realx}, $self->{realy}, $self->RoundCornerRadius);
}
sub AddTitle
{
my ($self, $title) = @_;
return if $self->{disabletitle};
my $titleupdate = exists $self->{title};
if ($titleupdate)
{
$self->{tls}->Remove($self->{title});
}
# Create the TextControl
$self->{title} = Wx::StaticText->new( $self,
-1,
$title,
wxDefaultPosition,
wxDefaultSize,
wxALIGN_CENTRE);
$self->TitleFont();
# Don't use 'Add' here...the title should be on top!!
$self->{tls}->Prepend($self->{title},0, wxALIGN_CENTRE, 0);
}
sub TitleFont
{
my $self = shift;
$self->{titlefont} = shift || $self->{titlefont};
return if not $self->{titlefont};
$self->{title}->SetFont($self->{titlefont}) if $self->{title};
return $self->{titlefont};
}
sub Append
{
my $self = shift;
my $row = shift;
my $unselectable = shift;
$self->{tls}->Add($row, # what to add
0, # unused
wxALIGN_CENTRE, # style
0); # padding
# setup the input event handling unless we're in editmode
unless ($self->{editmode})
{
$row->{input} = AAC::Pvoice::Input->newchild($row);
$row->{input}->Next( sub{$self->Next});
$row->{input}->Select(sub{$self->Select});
my $index=0;
foreach my $child ($row->GetChildren)
{
lib/AAC/Pvoice/Panel.pm view on Meta::CPAN
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
any effect at all.
=back
=head2 SetEditmode($onoff)
This sets Editmode on or off (depending on $onoff to be a true or false value).
Editmode means that the typical pVoice input doesn't work anymore, and is
typically used in combination with AAC::Pvoice::EditableRow...
=head2 xsize
This returns the x-size of the panel in pixels.
=head2 ysize
This returns the y-size of the panel in pixels.
=head2 RoundCornerRadius
This sets the radius for the round corners that are used to draw the panel
background and to draw the selectionborder around rows and buttons.
=head2 lastrow
This retrieves the index of the last row that was added to the panel.
=head2 SelectColour(Wx::Colour)
This gets or sets the colour that indicates a selected row or selected item. It
takes a Wx::Colour (or a predefined colour constant) as a parameter.
=head2 BackgroundColour(Wx::Colour)
This gets or sets the normal backgroundcolour. It
takes a Wx::Colour (or a predefined colour constant) as a parameter.
=head2 AddTitle(title)
This method sets the title of the page and draws it on the AAC::Pvoice::Panel.
By default it uses the Comic Sans MS font at a size of 18pt. You can change
this using TitleFont.
=head2 TitleFont(Wx::Font)
This method gets or sets the Wx::Font used to write the Title.
=head2 Append(row, unselectable)
This method adds a row (AAC::Pvoice::Row or any subclass of Wx::Window) to
the panel. If this row shouldn't be selectable by the user, you should set
unselectable to 1. Omitting this parameter, or setting it to 0 makes the
row selectable.
=head2 Clear
This method clears the panel completely and destroys all objects on it.
=head2 Finalize
This method 'finalizes' the panel by creating the textinput row (if appliccable)
and setting up the selection of the first row. You always need to call
this method before being able to let the user interact with the pVoice panel.
=head2 Next
This method normally won't be called directly. It will highlight the 'next'
row (when we're in 'rowselection') or the next item inside a row (when
we're in 'columnselection')
=head2 Select
This method normally won't be called directly either. It will either 'select'
the row that is highlighted and thus go into columnselection, or, when we're
in columnselection, invoke the callback associated with that item and
go into rowselection again.
=head2 ToRowSelection
This method will remove the highlighting of an item (if nessecary) and highlight
the entire current row again and set rowselection back on.
=head2 DisplayAddText(text)
In pVoice-like applications there's a difference between 'displaytext' (which is
the text that the user actually is writing and which should be displayed on the
textrow) and the speech (phonetical) text (which is not displayed, but -if nessecary-
differs from the text as we would write it, so a speechsynthesizer sounds
better.
This method adds text to the displaytext. It is saved internally and displayed
on the textrow
=head2 SpeechAddText(text)
( run in 1.803 second using v1.01-cache-2.11-cpan-ceb78f64989 )