Pvoice.pm untested

filter: Statementstmt 0.0% 0 / 91 Branchbran 0.0% 0 / 14 Conditioncond 0.0% 0 / 9 MC/DCmcdc 0.0% 0 / 5 Subroutinesub 0.0% 0 / 15 Podpod 0.0% 0 / 2 totaltotal 0.0% 0 / 136 CC 8 SCAR 33.1
CC
8
Cov
0%
MessageBox
72.0
BEGIN
2.0
BEGIN
2.0
CRAP 27.5
1 package AAC::Pvoice;
2
3 use strict;
4 use warnings;
5
6 use Wx qw(:everything);
7 use Wx::Perl::Carp;
8 use AAC::Pvoice::Bitmap;
9 use AAC::Pvoice::Input;
10 use AAC::Pvoice::Row;
11 use AAC::Pvoice::EditableRow;
12 use AAC::Pvoice::Panel;
13 use AAC::Pvoice::Dialog;
14 use Text::Wrap qw(wrap);
15
16 BEGIN {
17 use Exporter ();
18 use vars qw ($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);
19 $VERSION = 0.91;
20 @ISA = qw (Exporter);
21 @EXPORT = qw (MessageBox);
22 @EXPORT_OK = qw ();
23 %EXPORT_TAGS = ();
24 }
25
26 sub MessageBox
27 {
28 my ($message, $caption, $style, $parent, $x, $y) = @_;
29 $caption ||= 'Message';
30 $style ||= wxOK;
31 $x ||= -1;
32 $y ||= -1;
33
34 $Text::Wrap::columns = 25;
35 $message = wrap('','',$message)."\n";
36
37 my $width = 0;
38 $width = 25 if $style & wxOK;
39 $width = 30 if $style & wxYES_NO;
40 $width = 60 if $style & wxCANCEL;
41
42 my $p = Wx::Frame->new(undef, -1, 'tmp');
43 my $m = Wx::StaticText->new($p, -1, $message, wxDefaultPosition, wxDefaultSize, wxALIGN_CENTRE);
44 $m->SetFont(Wx::Font->new( 10, # font size
45 wxDECORATIVE, # font family
46 wxNORMAL, # style
47 wxNORMAL, # weight
48 0,
49 'Comic Sans MS', # face name
50 wxFONTENCODING_SYSTEM));
51
52 my $h = $m->GetSize->GetHeight;
53 $p->Destroy;
54
55 my $d = AAC::Pvoice::Dialog->new(undef, -1, $caption, [$x,$y], [310,100+$h]);
56
57 my $messagectrl = Wx::StaticText->new($d->{panel},
58 -1,
59 $message,
60 wxDefaultPosition,
61 wxDefaultSize,
62 wxALIGN_CENTRE);
63 $messagectrl->SetBackgroundColour($d->{backgroundcolour});
64 $messagectrl->SetFont(Wx::Font->new(10, # font size
65 wxDECORATIVE, # font family
66 wxNORMAL, # style
67 wxNORMAL, # weight
68 0,
69 'Comic Sans MS', # face name
70 wxFONTENCODING_SYSTEM));
71
72 $d->Append($messagectrl,1);
73 my $ok = [Wx::NewId,AAC::Pvoice::Bitmap->new('',50,25,'OK', Wx::Colour->new(255, 230, 230)),sub{$d->SetReturnCode(wxOK); $d->Close()}];
74 my $yes = [Wx::NewId,AAC::Pvoice::Bitmap->new('',50,30,'Yes', Wx::Colour->new(255, 230, 230)),sub{$d->SetReturnCode(wxYES); $d->Close()}];
75 my $no = [Wx::NewId,AAC::Pvoice::Bitmap->new('',50,25,'No', Wx::Colour->new(255, 230, 230)),sub{$d->SetReturnCode(wxNO); $d->Close()}];
76 my $cancel = [Wx::NewId,AAC::Pvoice::Bitmap->new('',50,60,'Cancel',Wx::Colour->new(255, 230, 230)),sub{$d->SetReturnCode(wxCANCEL);$d->Close()}];
77 my $items = [];
78 push @$items, $ok if $style & wxOK;
79 push @$items, $yes if $style & wxYES_NO;
80 push @$items, $no if $style & wxYES_NO;
81 push @$items, $cancel if $style & wxCANCEL;
82 $d->Append(AAC::Pvoice::Row->new($d->{panel}, # parent
83 scalar(@$items), # max
84 $items, # items
85 wxDefaultPosition, # pos
86 wxDefaultSize,
87 $width,
88 25,
89 $d->{ITEMSPACING},
90 $d->{backgroundcolour}),
91 0); #selectable
92 return $d->ShowModal();
93 }
94
95 =pod
96
97 =head1 NAME
98
99 AAC::Pvoice - Create GUI software for disabled people
100
101 =head1 SYNOPSIS
102
103 use AAC::Pvoice
104 # this includes all AAC::Pvoice modules
105
106
107 =head1 DESCRIPTION
108
109 AAC::Pvoice is a set of modules to create software for people who can't
110 use a normal mouse and/or keyboard. To see an application that uses this
111 set of modules, take a look at pVoice (http://www.pvoice.org, or the
112 sources on http://opensource.pvoice.org).
113
114 AAC::Pvoice is in fact a wrapper around many wxPerl classes, to make it
115 easier to create applications like pVoice.
116
117
118 =head1 USAGE
119
120 =head2 AAC::Pvoice::MessageBox(message, caption, style, parent, x, y)
121
122 This function is similar to Wx::MessageBox. It uses the same parameters as
123 Wx::MessageBox does. Currently the style parameter doesn't support the
124 icons that can be set on Wx::MessageBox.
125
126 See the individual module's documentation
127
128 =head1 BUGS
129
130 probably a lot, patches welcome!
131
132
133 =head1 AUTHOR
134
135 Jouke Visser
136 jouke@pvoice.org
137 http://jouke.pvoice.org
138
139 =head1 COPYRIGHT
140
141 This program is free software; you can redistribute
142 it and/or modify it under the same terms as Perl itself.
143
144 The full text of the license can be found in the
145 LICENSE file included with this module.
146
147
148 =head1 SEE ALSO
149
150 perl(1), Wx, AAC::Pvoice::Panel, AAC::Pvoice::Bitmap, AAC::Pvoice::Row
151 AAC::Pvoice::EditableRow, AAC::Pvoice::Input
152
153 =cut
154
155
156 1;
157 __END__