palmer@unc.UUCP (Thomas C. Palmer) (12/19/85)
I'm having considerable trouble writing a DA in Megamax C. Instead of going into gory details, would some kind soul either post or mail me a sample DA in Megamax C? (Wouldn't a DA skel be a nice Christmas present?) Thanks much. Merry Christmas all. -- -Tom Thomas C. Palmer palmer@unc decvax!mcnc!unc!palmer
tim@ism780c.UUCP (Tim Smith) (12/24/85)
In article <758@unc.unc.UUCP> palmer@unc.UUCP (Thomas C. Palmer) writes: > > I'm having considerable trouble writing a DA in Megamax C. >Instead of going into gory details, would some kind soul either >post or mail me a sample DA in Megamax C? (Wouldn't a DA skel >be a nice Christmas present?) Thanks much. > ------------------- Cut Here ------------------------ /* * Simplest possible DA in Megamax C */ #include "clock.c" /* sample DA that comes with Megamax C */ ------------------- End Here ------------------------ I have a simple DA written in Megamax C. If I can find it, I will send it or post it. -- Tim Smith sdcrdcf!ism780c!tim || ima!ism780!tim || ihnp4!cithep!tim
tim@ism780c.UUCP (Tim Smith) (12/27/85)
>In article <758@unc.unc.UUCP> palmer@unc.UUCP (Thomas C. Palmer) writes: > > I'm having considerable trouble writing a DA in Megamax C. > Instead of going into gory details, would some kind soul either > post or mail me a sample DA in Megamax C? (Wouldn't a DA skel > be a nice Christmas present?) Thanks much. > Ok, here is a sample DA written in Megamax C. It doesn't do anything spectacular. It just displays a window with the mouse location shown in local and global coordinates. As for a DA Skel, MacTutor had a DA called Shell, in Megamax C, a few issues ago. It puts up a window and a menu. It mostly works, except for update events ( see note in my DA source below ). If you can get this from someone, and it seems to bomb in some way related to menus, then look at your RMaker output. My copy of RMaker puts bad stuff in the resource ID of the menu defintion proc, which I have to fix using ResEdit before it works. Maybe Megamax has an old version of RMaker? Anyway, this has nothing to do with the DA below! ------------------------- Cut Here --------------------------- /* * MousePosition DA : display mouse position in a window. Both * global and local positions are shown. Local position is in the * coordinate system of whatever FrontWindow() feels like returning. */ /* * Notes: * Don't forget to tell the linker that this is a DRVR! * * Don't forget to install the INIT and DATA resources * when you install the DA. ( FONT/DA mover should do this for * for you, but ResEdit doesn't ). */ #include <stdio.h> #include <acc.h> #include <desk.h> #include <qd.h> #include <event.h> #include <res.h> #include <misc.h> #include <mem.h> #include <menu.h> #include <te.h> #include <font.h> #include <file.h> #include <win.h> #include <control.h> #include <device.h> ACC( 0x2400, 10, 0, 0, 7, "Mouse @" ) accopen( dctl, pb ) dctlentry *dctl; paramblockrec *pb; { WindowPeek mywindow; Rect wr; if ( dctl->dCtlWindow == NULL ) { SetRect( &wr, 50, 50, 150, 74 ); mywindow = NewWindow( NULL, &wr, "Mouse", 0, RDocProc, -1L, -1, 0L ); mywindow->windowKind = dctl->dCtlRefNum; dctl->dCtlWindow = mywindow; } else CloseDeskAcc( dctl->dCtlRefNum ); return 0; } accclose( dctl, pb ) dctlentry *dctl; paramblockrec *pb; { DisposeWindow( dctl->dCtlWindow ); dctl->dCtlWindow = NULL; return 0; } accctl( dctl, pb ) dctlentry *dctl; paramblockrec *pb; { WindowPtr mywindow; GrafPtr saveport; char outstr[ 100 ]; Point mouseloc, Gmouseloc; static int lasth = -1, lastv = -1; Rect wr; mywindow = dctl->dCtlWindow; if ( mywindow == NULL ) return 0; GetPort( &saveport ); SetPort( FrontWindow() ); /* to get local coordinates */ GetMouse( &mouseloc ); Gmouseloc = mouseloc; LocalToGlobal( &Gmouseloc ); if ( mouseloc.a.v != lastv || mouseloc.a.h != lasth ) { SetPort( (GrafPtr)mywindow ); SetRect( &wr, 0, 0, 200, 100 ); EraseRect( &wr ); sprintf( outstr, "L:%d,%d", lasth = mouseloc.a.h, lastv = mouseloc.a.v ); MoveTo( 4, 11 ); DrawString( outstr ); sprintf( outstr, "G:%d,%d", Gmouseloc.a.h, Gmouseloc.a.v ); MoveTo( 4, 23 ); DrawString( outstr ); } /* * Call {Begin,End}Update to clear the update event. Both * the clock DA that comes with Megamax C, and the Shell DA * from MacTutor fail to do this, which is why they mess up * windows behind their windows when run from an application * other than the Finder. Here is what happens if you leave * out the {Begin,End}Update calls: * * As soon as the DA window becomes the frontmost window * that needs updating, GetNextEvent() starts reporting * an update event for it. Since update events are not * placed in the event queue, it keeps reporting this * update event until something is done about it. It does * not report update events for any windows that are behind * the DA window. * * The application ignores these update events, since they * are for a DA window. Hence, things don't get updated * until you close the DA. * * The strange thing is that this does NOT happen when you * run under the Finder. It looks like the Finder notices * that there is a malfunctioning DA and deals with it. * I haven't a clue as to WHY it does this. * * I suspect that Megamax and the MacTutor author only * tested their DAs under the finder. */ BeginUpdate( mywindow ); EndUpdate( mywindow ); SetPort( saveport ); return 0; } accprime() {} accstatus() {} ------------------------------ Cut Me! -------------------------------- -- Tim Smith sdcrdcf!ism780c!tim || ima!ism780!tim || ihnp4!cithep!tim