Article View: comp.sources.mac
Article #26Waiting -- A Processor Monitor under MultiFinder
From: Erik Kilk
Date: Sat, 14 Nov 1987 05:40
Date: Sat, 14 Nov 1987 05:40
125 lines
3635 bytes
3635 bytes
[Waiting -- A Processor Monitor under MultiFinder]
Here is a little application you can run under MultiFinder and let
sit in the background. It puts up a tiny title-less window with an
indicator representing how much time it is waiting for processing
time. This is one calculation of how busy your computer is. The
indicator draws a filled in arc where a full circle represents one
full second (or more). Try running an editor and watch it while
you are typing. When activated, you can drag the window around by
just grabbing anywhere in its contents. Its position will be saved
for the next time the program is run. Partial sources are included.
The rest is SimpleTools 3 which is a general purpose event loop
manager and will be posted here in the near future (SimpleTools 2 was
posted here months ago).
[Moderator's note: The binary has been posted to comp.binaries.mac.]
Erik Kilk
---
#!/bin/sh
# shar: Shell Archiver
# Run the following text with /bin/sh to create:
# Waiting.c
sed 's/^X//' << 'SHAR_EOF' > Waiting.c
X#include <Quickdraw.h>
X#include <EventMgr.h>
X#include <ResourceMgr.h>
X#include "simple.h"
X
Xextern long Ticks : 0x16A;
Xextern long yieldTime;
Xextern Rect dragrect;
X
Xtypedef struct wait_data {
X Point windtop;
X int yield;
X int res1, res2, res3;
X} wait_data;
X
Xlong leaving_time;
XRect whole;
XWindowPtr thewindow;
XPoint top;
Xwait_data **data;
X
Xidle ()
X{
X long time_away, angle;
X time_away = Ticks - leaving_time;
X angle = time_away * 6L;
X if (angle > 360L) angle = 360L;
X SetPort (thewindow);
X EraseArc (&whole, 0, (int) angle - 350);
X PaintArc (&whole, 0, (int) angle);
X leaving_time = Ticks;
X}
X
Xmovewindow(x,y,windp,event)
Xint x,y;
XWindowPtr windp;
XEventRecord *event;
X{
X DragWindow (windp, event->where, &dragrect);
X}
X
Xgot_about ()
X{
X Alert (1000, 0L);
X}
X
Xgot_quit ()
X{
X if (data != 0L) {
X top.h = thewindow -> portRect.left;
X top.v = thewindow -> portRect.top;
X SetPort (thewindow);
X LocalToGlobal (&top);
X HLock (data);
X (**data).windtop = top;
X (**data).yield = (int) yieldTime;
X HUnlock (data);
X ChangedResource (data);
X WriteResource (data);
X }
X ExitToShell();
X}
X
Xget_data ()
X{
X data = (wait_data **) GetResource ('WAIT', 0);
X top.h = -1; top.v = -1; yieldTime = -1;
X if (data) {
X HLock (data);
X top = (**data).windtop;
X yieldTime = (long) (**data).yield;
X HUnlock (data);
X }
X if (!PtInRect (top, &dragrect)) {
X top.h = 2;
X top.v = 22;
X }
X if (yieldTime <= 0 || yieldTime > 1000)
X yieldTime = 1;
X}
X
Xmain ()
X{
X simpletools ("About Waiting...");
X menu (applestring, "About Waiting...", got_about);
X menu (applestring, "About Waiting...", itemenable);
X menu ("File", "Quit/Q", got_quit);
X SetRect (&whole, 1, 1, 11, 11);
X wprocid = 3;
X windmenu = 0;
X get_data ();
X thewindow = window ("Waiting",top.h,top.v,top.h+12,top.v+12,0L,0L,
X idle, movewindow);
X run (idle);
X leaving_time = Ticks;
X runsimpletools ();
X}
SHAR_EOF
exit
---
Technical Details
Message-ID:
<12985@felix.UUCP>Path:
arc1-ca.pugleaf.net!utzoo!mnetor!uunet!ccicpg!felix!macintoshShow Full Headers
Complete Article Headers
Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: arc1-ca.pugleaf.net!utzoo!mnetor!uunet!ccicpg!felix!macintosh From: erik@hpsadla.HP (Erik Kilk) Newsgroups: comp.sources.mac Subject: Waiting -- A Processor Monitor under MultiFinder Message-ID: <12985@felix.UUCP> Date: Sat, 14-Nov-87 00:40:55 EST Article-I.D.: felix.12985 Posted: Sat Nov 14 00:40:55 1987 Date-Received: Sun, 15-Nov-87 17:29:28 EST Sender: macintosh@felix.UUCP Lines: 125 Approved: bytebug@felix.UUCP (Roger L. Long)