view release on metacpan or search on metacpan
is 0 to prevent 'illegal division by zero'
AAC::Pvoice::EditableRow now has some sensible defaults to prevent
'Use of uninitialized value' warnings
AAC::Pvoice::Input can now handle one button input
0.7 AAC::Pvoice::Input
* now allows keyboard input
* now allows direct mouseclicks on the buttons
AAC::Pvoice::Panel
* now uses a round cornered background and
* no longer simply sets the background for the normal and
selected state, but draws a round cornered border around
the rows and buttons that are selected
* finally got the screensizing correctly...no more weird
calculating stuff...
AAC::Pvoice::Bitmap
* now produces round cornered bitmaps
AAC::Pvoice::Row
* no longer uses too large images (screensizing update)
AAC::Pvoice::EditableRow
* no longer uses too large images (screensizing update)
supported by Device::ParallelPort. This dependency has to do with AAC::Pvoice::Input, which
needs to be able to poll the parallel port in case it needs to communicate
with the 'Adremo' electrical wheelchair. For this I'm using
Device::ParallelPort, which has drivers for Linux and Win32.
As of version 0.6 the modules allow you to use your application in
One or Two-button mode. See the documentation of AAC::Pvoice::Input for details.
As of version 0.9 you need Image::Magick.
At the very least you should be able to use this set of instructions
to install the module...
perl Makefile.PL
make
make test
make install
If you are on a windows box you should use 'nmake' rather than 'make'.
lib/AAC/Pvoice.pm view on Meta::CPAN
AAC::Pvoice - Create GUI software for disabled people
=head1 SYNOPSIS
use AAC::Pvoice
# this includes all AAC::Pvoice modules
=head1 DESCRIPTION
AAC::Pvoice is a set of modules to create software for people who can't
use a normal mouse and/or keyboard. To see an application that uses this
set of modules, take a look at pVoice (http://www.pvoice.org, or the
sources on http://opensource.pvoice.org).
AAC::Pvoice is in fact a wrapper around many wxPerl classes, to make it
easier to create applications like pVoice.
=head1 USAGE
=head2 AAC::Pvoice::MessageBox(message, caption, style, parent, x, y)
This function is similar to Wx::MessageBox. It uses the same parameters as
Wx::MessageBox does. Currently the style parameter doesn't support the
icons that can be set on Wx::MessageBox.
See the individual module's documentation
=head1 BUGS
probably a lot, patches welcome!
=head1 AUTHOR
lib/AAC/Pvoice/Bitmap.pm view on Meta::CPAN
$tmpdc->SetFont($cfont);
$tmpdc->DrawText($caption, int(($x-$cw)/2),$y-$ch);
}
my $tmpfile = File::Temp::tmpnam();
$newbmp->SaveFile($tmpfile, wxBITMAP_TYPE_PNG);
local $/ = undef;
open(my $fh, "<$tmpfile");
binmode($fh);
my $image = <$fh>;
close($fh);
$cache->set("$file-$x-$y-$caption-$ibg-$blowup-$pbg-$mtime", $image);
}
my $fh = IO::Scalar->new(\$image);
my $contenttype = 'image/png';
return Wx::Bitmap->new(Wx::Image->newStreamMIME($fh, $contenttype))
}
sub wxColor2hex
{
lib/AAC/Pvoice/Bitmap.pm view on Meta::CPAN
$img->Border(width => int(($x - $img->Get('width'))/2) - $radius/2,
height => int((($y-$textheight) - $img->Get('height'))/2) - $radius/2,
fill => $ibg);
# Call the Composite method of the background image, with the logo image as an argument.
$background->Composite(image=>$img,compose=>'over', gravity => 'North');
$background->Set(quality=>100);
$background->Set(magick => 'png');
$image = $background->imagetoblob();
$cache->set("$file-$x-$y-$caption-$ibg-$blowup-$pbg-$mtime", $image);
undef $background;
undef $img;
}
my $fh = IO::Scalar->new(\$image);
my $contenttype = 'image/png';
return Wx::Bitmap->new(Wx::Image->newStreamMIME($fh, $contenttype))
}
lib/AAC/Pvoice/Bitmap.pm view on Meta::CPAN
=item image
This is the path to the image you want to have.
=item maxX, maxY
These are the maximum X and Y size of the resulting image. If the original
image is larger, it will be resized (maintaining the aspect ratio) to
match these values as closely as possible. If the 'blowup' parameter is
set to a true value, it will also enlarge images that are smaller than
maxX and maxY to get the largest possible image within these maximum values.
=item caption
This is an optional caption below the image. The caption's font is Comic Sans MS
and will have a pointsize that will make the caption fit within the maxX
of the image. The resulting height of the caption is subtracted from the
maxY
=item background
lib/AAC/Pvoice/Input.pm view on Meta::CPAN
{
# BEWARE: $self is the wxWindow subclass the timer
# belongs to!
my ($self, $event) = @_;
# do nothing if the device is not adremo or
# if we're already running
return if ($self->{monitorrun} ||
(not $self->{input}->{next}) ||
(not $self->{input}->{select}) ||
$self->{pause});
# set the flag that we're checking the port
$self->{monitorrun} = 1;
$self->{pp} = Device::ParallelPort->new() if not $self->{pp};
my $curvalue = $self->{pp}->get_status();
if (not defined $curvalue)
{
# clear the flag that we're checking the port and return
$self->{monitorrun} = 0;
return
}
$self->{lastvalue} = 0 if not exists $self->{lastvalue};
lib/AAC/Pvoice/Input.pm view on Meta::CPAN
The module uses Device::ParallelPort, so it should be able to run
on Win32 as well as Linux platforms.
=head1 USAGE
=head2 new($window)
This constructor takes the window (AAC::Pvoice::Panel typically) on which
the events and timer will be called as a parameter.
If the configuration (read using Wx::ConfigBase::Get) has a key called
'Device' (which can be set to 'icon', 'keys' , 'mouse' or 'adremo') is set to 'adremo', it
will start polling the parallel port every x milliseconds, where x is the
value of the configuration key 'Interval'. This setting is only useful if you connect
an "Adremo" electrical wheelchair to the parallel port of your PC (for more
information see http://www.adremo.nl).
If the key 'Device' is set to 'icon' it will respond to the left and right
mouse button, and if it's set to 'keys' it will respond to the configuration
keys 'SelectKey' and 'NextKey' (which are the keyboard codes for the 'select'
and 'next' events respectively.
AAC::Pvoice::Input has the ability to operate with either one or two buttons.
If you want to use only one button, you need to set the configuration key "Buttons"
to 1, and it will automatically invoke the subroutine you pass to Next()
at an interval of the value set in the configuration key OneButtonInterval (set in milliseconds).
The default for is to operate in two button mode, and if OneButtonInterval is not
set, it will use a default of 2000 milliseconds if "Buttons" is set to 1.
=head2 newchild($window)
This semi-constructor takes the window (usually a child of the panel you
passed to the new() constructor, on which the events will be called as a parameter.
It doesn't start the timers for polling the parallel port and automatic
invocation of the Next() subroutine, because those timers otherwise would
be started multiple times.
Apart from starting those timers, this method works exactly like the new()
=head2 Next(sub)
This method takes a coderef as parameter. This coderef will be invoked when
the 'Next' event happens.
If the Device (see 'new') is set to 'icon', and a right mousebutton is
clicked, a 'Next' event is generated.
If the Device is set to 'adremo' and the headsupport of the wheelchair
is moved to the right, that will also generate a 'Next' event.
If the Device is set to 'keys' and a key is pressed that corresponds with the
keycode set in the 'NextKey', this will generate a 'Next' event too.
=head2 Select(sub)
This method takes a coderef as parameter. This coderef will be invoked when
the 'Select' event happens.
If the Device (see 'new') is set to 'icon', and a left mousebutton is
clicked, a 'Select' event is generated.
If the Device is set to 'adremo' and the headsupport of the wheelchair
is moved to the left, that will also generate a 'Select' event.
If the Device is set to 'keys' and a key is pressed that corresponds with the
keycode set in the 'SelectKey', this will generate a 'Select' event too.
=head2 GetDevice
This method will return the value of the configuration key called 'Device'
=head2 SetupMouse($window, $subgetfocus, $subup, $sublosefocus)
This method is used to setup a button for normal mouse input (when
configuration key 'Device' is set to 'mouse'). It takes the wxWindow
(typically a Wx::BitmapButton) that should respond to this way of
input as the first parameter.
$subgetfocus is the coderef that should be invoked when the mousecursor
hovers over this $window (EVT_ENTER).
$subup is the coderef that should be invoked when the left mousebutton
is released (EVT_LEFT_UP).
$sublosefocus is the coderef that should be invoked when the $window
loses focus (EVT_LEAVE).
=head2 StartMonitor
This method will start polling the the parallel port for input of the Adremo
Electrical Wheelchair.
=head2 QuitMonitor
This method will stop the timer that monitors the parallel port.
=head2 PauseMonitor($bool)
This method will pause ($bool is set to 1) or restart ($bool is set to 0)
the timer that monitors the parallel port.
=head2 StartAutoscan
This method will start the timer that invokes the Next() event every n milliseconds.
=head2 QuitAutoscan
This method will stop the timer that invokes the Next() method.
=head2 PauseAutoscan($bool)
This method will pause ($bool is set to 1) or restart ($bool is set to 0)
the timer that invokes the Next() method.
=head1 BUGS
probably a lot, patches welcome!
=head1 AUTHOR
lib/AAC/Pvoice/Panel.pm view on Meta::CPAN
0,
'Comic Sans MS', # face name
wxFONTENCODING_SYSTEM)) unless $self->TitleFont;
$self->AddTitle('');
my $usableysize = $y - 2*$self->{title}->GetSize()->GetHeight();
# If we want to use a textrow, we have to subtract another 60
# pixels from the y size, since the textrow is always 60 pixels high.
$usableysize-=60 unless $self->{disabletextrow};
$self->ysize($usableysize);
}
# set the default colours...these can of course be changed...
$self->SelectColour(Wx::Colour->new(255,131,131));
$self->BackgroundColour(Wx::Colour->new(220,220,220));
$self->SetSizer($self->{tls});
$self->SetAutoLayout(1);
$self->{displaytextsave} = [];
$self->{speechtextsave} = [];
# Initialize the input stuff
lib/AAC/Pvoice/Panel.pm view on Meta::CPAN
sub SetEditmode
{
my $self = shift;
$self->{editmode} = shift;
}
sub OnPaint
{
my ($self, $event) = @_;
$self->{setselection} = 1;
my $dc = Wx::PaintDC->new($self);
$self->SetBackgroundColour($self->{parent}->GetBackgroundColour);
$self->DrawBackground($dc);
if ($self->{rowcolumnscanning} && not $self->{editmode})
{
$dc = Wx::WindowDC->new($self->{selectedwindow}->GetParent);
$self->DrawBorder($dc);
}
$event->Skip;
}
lib/AAC/Pvoice/Panel.pm view on Meta::CPAN
sub DrawBorder
{
my $self = shift;
my $dc = shift;
my $window = $self->{selectedwindow};
my ($x, $y) = $window->GetPositionXY;
my $size = $window->GetSize;
my ($xsize, $ysize) = ($size->GetWidth, $size->GetHeight);
$dc->BeginDrawing;
$dc->SetBrush(wxTRANSPARENT_BRUSH);
$dc->SetPen(Wx::Pen->new($self->{setselection} ? $self->SelectColour :
$self->BackgroundColour, $self->{selectionborder}, wxSOLID));
$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};
}
lib/AAC/Pvoice/Panel.pm view on Meta::CPAN
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)
{
$child->{input} = AAC::Pvoice::Input->newchild($child);
$child->{input}->Next( sub{$self->Next});
lib/AAC/Pvoice/Panel.pm view on Meta::CPAN
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});
lib/AAC/Pvoice/Panel.pm view on Meta::CPAN
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
lib/AAC/Pvoice/Panel.pm view on Meta::CPAN
=head2 BackspaceText
This method removes the last text added to the speech *and* displaytext.
Make sure that both speechtext and displaytext have the same amount of
text added, because it just pops off the last item from both lists and
updates the textrow.
=head2 PauseInput($bool)
This method makes sure that the timers that are used for the input (using
AAC::Pvoice::Input) are paused if $bool is set to 1. If $bool is 0, they're
restarted.
=head1 BUGS
probably a lot, patches welcome!
=head1 AUTHOR
Jouke Visser