Add files via upload

This commit is contained in:
45RPM Software 2021-12-14 18:40:24 +00:00 committed by GitHub
commit 0a88bcecae
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 5 additions and 0 deletions

1
MandyWindow.c Normal file
View File

@ -0,0 +1 @@
/***** * MandyWindow.c * * A simple fractal generator * * *****/ #include "mwMenus.h" #include "mwWindow.h" extern WindowPtr mwWindow; extern Rect dragRect; void InitMacintosh(void); void HandleMouseDown (EventRecord *theEvent); void HandleEvent(void); /* InitMacintosh() Initialize all the managers & memory */ void InitMacintosh(void) { MaxApplZone(); InitGraf(&thePort); InitFonts(); FlushEvents(everyEvent, 0); InitWindows(); InitMenus(); TEInit(); InitDialogs(0L); InitCursor(); } void HandleMouseDown (EventRecord *theEvent) { WindowPtr theWindow; int windowCode = FindWindow (theEvent->where, &theWindow); switch (windowCode) { case inSysWindow: SystemClick (theEvent, theWindow); break; case inMenuBar: AdjustMenus(); HandleMenu(MenuSelect(theEvent->where)); break; case inDrag: if (theWindow == mwWindow) DragWindow(mwWindow, theEvent->where, &dragRect); break; case inContent: if (theWindow == mwWindow) { if (theWindow != FrontWindow()) SelectWindow(mwWindow); else InvalRect(&mwWindow->portRect); } break; case inGoAway: if (theWindow == mwWindow && TrackGoAway(mwWindow, theEvent->where)) HideWindow(mwWindow); break; } } void HandleEvent(void) { int ok; EventRecord theEvent; HiliteMenu(0); SystemTask (); /* Handle desk accessories */ ok = GetNextEvent (everyEvent, &theEvent); if (ok) { switch (theEvent.what) { case mouseDown: HandleMouseDown(&theEvent); break; case keyDown: case autoKey: if ((theEvent.modifiers & cmdKey) != 0) { AdjustMenus(); HandleMenu(MenuKey((char) (theEvent.message & charCodeMask))); } break; case updateEvt: BeginUpdate(mwWindow); DrawContent(((WindowPeek) mwWindow)->hilited); EndUpdate(mwWindow); break; case activateEvt: InvalRect(&mwWindow->portRect); break; } } } void main(void) { InitMacintosh(); SetUpMenus(); SetUpWindow(); for (;;) { HandleEvent(); } }

1
mwMenus.c Normal file
View File

@ -0,0 +1 @@
/***** * mwMenus.c * * Routines for Mandy Fractal Generator menus. * *****/ #include "mwMenus.h" extern WindowPtr mwWindow; extern int width; MenuHandle appleMenu, fileMenu, editMenu, fractalMenu; enum { appleID = 1, fileID, editID, fractalID }; enum { openItem = 1, closeItem, quitItem = 4 }; /* SetUpMenus() Set up the menus. Normally, weÕd use a resource file, but for this example weÕll supply ÒhardwiredÓ strings. */ void SetUpMenus(void) { InsertMenu(appleMenu = NewMenu(appleID, "\p\024"), 0); InsertMenu(fileMenu = NewMenu(fileID, "\pFile"), 0); InsertMenu(editMenu = NewMenu(editID, "\pEdit"), 0); InsertMenu(fractalMenu = NewMenu(fractalID, "\pFractal"), 0); DrawMenuBar(); AddResMenu(appleMenu, 'DRVR'); AppendMenu(fileMenu, "\pOpen/O;Close/W;(-;Quit/Q"); AppendMenu(editMenu, "\pUndo/Z;(-;Cut/X;Copy/C;Paste/V;Clear"); AppendMenu(fractalMenu, "\pTree/T;Mandelbrot/M;Julia/J"); } /* AdjustMenus() Enable or disable the items in the Edit menu if a DA window comes up or goes away. Our application doesn't do anything with the Edit menu. */ static void enable (MenuHandle menu, short item, short ok); void AdjustMenus(void) { register WindowPeek wp = (WindowPeek) FrontWindow(); short kind = wp ? wp->windowKind : 0; Boolean DA = kind < 0; enable(editMenu, 1, DA); enable(editMenu, 3, DA); enable(editMenu, 4, DA); enable(editMenu, 5, DA); enable(editMenu, 6, DA); enable(fileMenu, openItem, !((WindowPeek) mwWindow)->visible); enable(fileMenu, closeItem, DA || ((WindowPeek) mwWindow)->visible); // CheckItem(widthMenu, width, true); } static void enable(MenuHandle menu, short item, short ok) { if (ok) EnableItem(menu, item); else DisableItem(menu, item); } /* HandleMenu(mSelect) Handle the menu selection. mSelect is what MenuSelect() and MenuKey() return: the high word is the menu ID, the low word is the menu item */ void HandleMenu (long mSelect) { int menuID = HiWord(mSelect); int menuItem = LoWord(mSelect); Str255 name; GrafPtr savePort; WindowPeek frontWindow; switch (menuID) { case appleID: GetPort(&savePort); GetItem(appleMenu, menuItem, name); OpenDeskAcc(name); SetPort(savePort); break; case fileID: switch (menuItem) { case openItem: ShowWindow(mwWindow); SelectWindow(mwWindow); break; case closeItem: if ((frontWindow = (WindowPeek) FrontWindow()) == 0L) break; if (frontWindow->windowKind < 0) CloseDeskAcc(frontWindow->windowKind); else if ((frontWindow = (WindowPeek) mwWindow) != NULL) HideWindow(mwWindow); break; case quitItem: ExitToShell(); break; } break; case editID: if (!SystemEdit(menuItem-1)) SysBeep(5); break; case fractalID: CheckItem(fractalMenu, width, false); width = menuItem; InvalRect(&mwWindow->portRect); break; } }

1
mwMenus.h Normal file
View File

@ -0,0 +1 @@
/***** * mwMenus.h * * Public interfaces for mwMenus.h * ****/ void AdjustMenus(void); void HandleMenu (long mSelect); void SetUpMenus(void);

1
mwWindow.c Normal file

File diff suppressed because one or more lines are too long

1
mwWindow.h Normal file
View File

@ -0,0 +1 @@
/***** * mwWindow.h * * Public interfaces for mwWindow.c * *****/ void DrawContent (short active); void SetUpWindow(void);