[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

[MacPerl-Toolbox] Re: [MacPerl] HAL Lives!



> The speech seems to clobber the QuickDraw calls for displaying the PICT,
> which doesn't get drawn until after the speaking is done (although the
> color fade works as expected). Is there a work-around for this?

The redraw hook is not called until the next WaitNextEvent or two. You
can either put in a few WNEs, or call it yourself.
> 
> A plainDbox(), instead of the floatProc() would be nice, but until I get
> an event handler written (or someone else steps forward with one) (click
> on the "HAL 9000" logo to close?)...

See demo program at end for detecting clicks in a rectangle.

> $65,000 question: has anyone ever done anything with SpeechRecognition.pm?

Yes. ( And shouldn't that be $65,535? :)

> How to detect monitor resolution, and center HAL in the screen, regardless?

GetMainDevice()->gdRect will return the boundaries of the main screen.
See demo program at end for example.

-------------------------------

#!perl -w
# Rectangle click demo

use Mac::Windows;
use Mac::QuickDraw;
use Mac::Events;

sub ltwh {new Rect ($_[0], $_[1], $_[0] + $_[2], $_[1] + $_[3])}

$wbounds = new Rect (0, 0, 150, 150);
$rbounds = ltwh(50, 50, 50, 50);
$srect = GetMainDevice->gdRect;

$win = new MacColorWindow (
  Mac::QuickDraw::OffsetRect($wbounds,
    $srect->left + ($srect->right - $srect->left - $wbounds->right) / 2,
    $srect->top + ($srect->bottom - $srect->top - $wbounds->bottom) / 3,
      # change 3 to 2 for truly centered window.
  ), 
  "Test", 1, noGrowDocProc, 1);
$win->sethook(drawgrowicon => sub {});
$win->sethook(click => sub {
  my ($win, $pt) = @_;
  if (PtInRect($pt, $rbounds)) {
    my $tix = TickCount() + 20;
    my $inv = 0;
    while (TickCount() < $tix) {
      InvertRect $rbounds; $inv = !$inv;
    }
    InvertRect $rbounds if $inv;
  }
});
$win->sethook(redraw => sub {
  PaintRect $rbounds;
});

WaitNextEvent while $win->window;
END {$win->dispose}

__END__


-- 
 Kevin Reid: |    Macintosh:      
  "I'm me."  | Think different.

==== Want to unsubscribe from this list?
==== Send mail with body "unsubscribe" to macperl-toolbox-request@macperl.org