home *** CD-ROM | disk | FTP | other *** search
- 18-Jun-88 14:24:47-MDT,6409;000000000000
- Return-Path: <u-lchoqu%sunset@cs.utah.edu>
- Received: from cs.utah.edu by SIMTEL20.ARPA with TCP; Sat, 18 Jun 88 14:24:39 MDT
- Received: by cs.utah.edu (5.54/utah-2.0-cs)
- id AA22091; Sat, 18 Jun 88 14:24:42 MDT
- Received: by sunset.utah.edu (5.54/utah-2.0-leaf)
- id AA24499; Sat, 18 Jun 88 14:24:39 MDT
- Date: Sat, 18 Jun 88 14:24:39 MDT
- From: u-lchoqu%sunset@cs.utah.edu (Lee Choquette)
- Message-Id: <8806182024.AA24499@sunset.utah.edu>
- To: rthum@simtel20.arpa
- Subject: BMUG4.c
-
- /* Sample evolving program for BMUG Developers Group */
-
- /* Code to demonstrate Events F.A. Huxham 2/20/85 */
- /* Code to demonstrate Windows D.J. Burnard 3/6/85 */
- /* Code to demonstrate Menus J.Y. Takatsuka 3/20/85 */
- /* Code to demonstrate QuickDraw & DA's F.A. Huxham 4/3/85 */
-
- #include "Events.h"
- #include "Window.h"
- #include "Menu.h"
- #include "QuickDraw.h"
-
- #define TRUE 1
- #define FALSE 0
- #define NIL 0
-
- /* Menu Stuff */
- #define Desk_ID 100
- #define Shape_ID 101
- #define Cursor_ID 102
- #define Special_ID 103
-
- struct P_Str
- {
- char count;
- char contents[255];
- };
-
- MenuHandle DeskMenu;
- MenuHandle shapeMenu;
- MenuHandle cursorMenu;
- MenuHandle SpecialMenu;
-
- EventRecord theEvent;
- WindowPtr whichWindow;
- Rect screen,theRect,PictureRect,icon1;
- short windowcode,i;
- CursHandle theCursor;
- PatHandle thePattern;
- PicHandle thePicture;
- PolyHandle thePolygon;
- Handle saucer1;
- long newSize,tempCurs;
-
- struct P_Str *DAName;
-
- struct P_Str *CtoPstr();
- int strlen(str)char *str;
- {int i=0;while (str[i++]);return i-1;}
-
- SetUpMenus()
- {
- /* Desk Accessory Menu */
- DeskMenu = NewMenu (Desk_ID,CtoPstr("\24"));
- AddResMenu (DeskMenu, 'DRVR');
- InsertMenu (DeskMenu, 0);
-
- /* shape menu */
- shapeMenu = NewMenu (Shape_ID, CtoPstr("Shapes"));
- AppendMenu (shapeMenu, CtoPstr("Clear Screen;(-;Frame Rect;Paint Rect"));
- AppendMenu (shapeMenu, CtoPstr("Erase Rect;Invert Rect;Fill Rect"));
- AppendMenu (shapeMenu, CtoPstr("(-;Frame Oval;Paint Oval;Erase Oval"));
- AppendMenu (shapeMenu, CtoPstr("Invert Oval;Fill Oval;(-;Quit"));
- InsertMenu (shapeMenu,0);
- DisableItem(shapeMenu,2);
- DisableItem(shapeMenu,8);
- DisableItem(shapeMenu,14);
-
- /* Cursors Menu */
- cursorMenu = NewMenu (Cursor_ID, CtoPstr("Cursors"));
- AppendMenu (cursorMenu, CtoPstr("I-Beam;Cross;Plus;Watch;Arrow"));
- InsertMenu (cursorMenu, 0);
-
- /* Special Menu */
- SpecialMenu = NewMenu (Special_ID, CtoPstr("Special"));
- AppendMenu (SpecialMenu, CtoPstr("Draw Picture;Draw Polygon;Animation"));
- InsertMenu (SpecialMenu, 0);
-
- DrawMenuBar();
- }
-
- main() /* main() */
- {
-
- InitWindows();
- InitCursor();
- InitFonts();
- FlushEvents(everyEvent);
- InitMenus();
- SetUpMenus();
- SetRect(&screen,0,20,512,342);
- SetRect(&theRect,150,100,362,242);
- SetRect(&PictureRect,48,51,464,291);
-
-
- while (TRUE) {
- SystemTask();
- if (GetNextEvent(everyEvent,&theEvent)) {
- switch (theEvent.what) {
-
- case keyDown:
- break;
-
- case mouseDown:
- windowcode=FindWindow(&theEvent.where,&whichWindow);
- switch (windowcode) {
- case inDesk:
- break;
-
- case inMenuBar:
- DoWhatTheMenuSays(MenuSelect(&theEvent.where));
- break;
-
- case inSysWindow:
- SystemClick(&theEvent,whichWindow);
- break;
-
- case inContent:
- break;
-
- case inDrag:
- break;
-
- case inGrow:
- break;
-
- case inGoAway:
- break;
-
- } /* end of switch(windowcode) */
- break;
-
- default:
- break;
- } /* end of switch(theEvent.what) */
- } /* end of if(GetNext...) */
- } /* end of while(True) */
- } /* end of procedure main() */
-
-
- DoWhatTheMenuSays(menuResult,)
- long menuResult;
- {
- short menuID, itemNumber;
- menuID = HiWord (menuResult);
- itemNumber = LoWord (menuResult);
-
- switch (menuID)
- {
- case Shape_ID:
- switch (itemNumber)
- {
- case 1:
- EraseRect(&screen);
- break;
-
- case 3:
- FrameRect(&theRect);
- break;
-
- case 4:
- PaintRect(&theRect);
- break;
-
- case 5:
- EraseRect(&theRect);
- break;
-
- case 6:
- InvertRect(&theRect);
- break;
-
- case 7:
- thePattern = GetPattern(4);
- FillRect(&theRect,*thePattern);
- break;
-
- case 9:
- FrameOval(&theRect);
- break;
-
- case 10:
- PaintOval(&theRect);
- break;
-
- case 11:
- EraseOval(&theRect);
- break;
-
- case 12:
- InvertOval(&theRect);
- break;
-
- case 13:
- thePattern = GetPattern(3);
- FillOval(&theRect,*thePattern);
- break;
-
- case 15:
- ExitToShell();
- break;
-
- } /* end of case shapeMenu */
- break; /* case Shape_ID */
-
- case Cursor_ID:
- switch (itemNumber) {
- case 1:
- theCursor = GetCursor(1);
- SetCursor(*theCursor);
- break;
-
- case 2:
- theCursor = GetCursor(2);
- SetCursor(*theCursor);
- break;
-
- case 3:
- theCursor = GetCursor(3);
- SetCursor(*theCursor);
- break;
-
- case 4:
- theCursor = GetCursor(4);
- SetCursor(*theCursor);
- break;
-
- case 5:
- InitCursor();
- break;
-
- } /* end of menu CursorMenu */
- break;
-
- case Desk_ID:
- GetItem(DeskMenu,itemNumber,&DAName);
- OpenDeskAcc(&DAName);
- break;
-
- case Special_ID:
- switch (itemNumber) {
-
- case 1:
- thePicture = GetPicture(1);
- DrawPicture(thePicture,&PictureRect);
- break;
-
- case 2:
- thePolygon = OpenPoly();
- MoveTo(300,100);
- LineTo(400,200);
- LineTo(200,200);
- LineTo(300,100);
- ClosePoly();
- thePattern = GetPattern(11);
- FillPoly(thePolygon,*thePattern);
- FramePoly(thePolygon);
- KillPoly(thePolygon);
- break;
-
- case 3:
- i = 0;
- HideCursor();
- EraseRect(&screen);
- SetRect(&icon1,-33,50,-1,82);
- saucer1 = GetIcon(1);
- PlotIcon(&icon1,saucer1);
- while (i<544)
- {
- OffsetRect(&icon1,1,0);
- PlotIcon(&icon1,saucer1);
- i++;
- }
- ShowCursor();
- break;
-
- } /* end of menu SpecialMenu */
- } /* end of switch (menuID) */
- HiliteMenu(0);
-
- } /* end of procedure DoWhatTheMenuSays() */
-
-
-
-
-