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

[MacPerl] periodic text to window



Hi.  I have a question.  I'm writing a little tcp/ip client server
program, and I'd like to have one of the features be as follows:  When I
launch the server part, it listens to the port and opens up three windows
each 200 x 200 pixels.  When the client connects, it can issue many
commands. One of the commands is to have it send a one line string to a
window of the clients choice.
  All the tcp/ip stuff I can do fine, my problem is the window code.  I
know how to create the windows, but what I need is:

code that puts the text to the correct window and updates the window.

I wrote a test thing that opened up a window, and in the MacPerl window, I
had it send a line of text, and I used DrawString to display it.  I moved
the cursor down and then I tried sending another line, but i can't make it
upddate the window unless I do some window event, like resizing.  Here is
what I got.  Any help would be appreciated.

How do make it "work": Type in the text and hit enter.  Go up to the other
window, do a resize in the bottom right-hand corner, click back on the
MacPerl window and then click to the right of the new "text: " prompt that
appears.  Type the next line of text, repeat...

#!perl

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

$helvetica = GetFNum "Helvetica" or die $^E;
$times = GetFNum "Times" or die $^E;
$bounds = new Rect 50, 50, 550, 290;
$win = new MacWindow $bounds, "Hello, World!", 1, documentProc, 1;
$curpos = 12;

$win->sethook("redraw", \&test);

WaitNextEvent while $win->window;

dispose $win;

sub test
{
  print "text: ";
  $line = <STDIN>;
  chop($line);
  DrawOurWindow($line)
}

sub DrawOurWindow
{
  $line2 = shift;
 	TextFont($helvetica);
	 TextSize(12);
	 TextFace(normal);
  MoveTo 0,$curpos;
	 DrawString "$line2 $curpos";
  $curpos += 14;
}




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