home *** CD-ROM | disk | FTP | other *** search
/ Carousel Volume 2 #1 / carousel.iso / mactosh / code / c_bmug5.sit < prev    next >
Encoding:
Text File  |  1988-06-20  |  17.0 KB  |  711 lines

  1. 18-Jun-88 15:13:21-MDT,18034;000000000000
  2. Return-Path: <u-lchoqu%sunset@cs.utah.edu>
  3. Received: from cs.utah.edu by SIMTEL20.ARPA with TCP; Sat, 18 Jun 88 15:12:51 MDT
  4. Received: by cs.utah.edu (5.54/utah-2.0-cs)
  5.     id AA22096; Sat, 18 Jun 88 14:25:13 MDT
  6. Received: by sunset.utah.edu (5.54/utah-2.0-leaf)
  7.     id AA24506; Sat, 18 Jun 88 14:25:10 MDT
  8. Date: Sat, 18 Jun 88 14:25:10 MDT
  9. From: u-lchoqu%sunset@cs.utah.edu (Lee Choquette)
  10. Message-Id: <8806182025.AA24506@sunset.utah.edu>
  11. To: rthum@simtel20.arpa
  12. Subject: BMUG5.c
  13.  
  14. #include    "MacCDefs.h"
  15. #include     "Window.h"
  16. #include     "Events.h"
  17. #include     "TextEdit.h"
  18. #include     "Font.h"
  19. #include     "Menu.h"
  20.  
  21.     
  22. #define     FALSE    0
  23. #define    NIL            0
  24. #define     TRUE         1
  25. #define     Desk_ID     200
  26. #define     Edit_ID     201
  27. #define     Window_ID 202
  28. #define    TE_ID        203
  29. #define    Font_ID    204
  30. #define    Style_ID    205
  31. #define    iBeamCursor    1
  32.  
  33. #define    teNormal        0x0000
  34. #define    teBold            0x0100
  35. #define    teItalic            0x0200
  36. #define    teUnderline    0x0400
  37. #define    teOutline        0x0800
  38. #define    teShadow    0x1000
  39. #define    teCondense    0x2000
  40. #define    teExtend        0x4000
  41.  
  42. //    Global Variables
  43.  
  44.     WindowPtr             theWindow,windPtrA,windPtrB;
  45.     WindowRecord     windRecordA,windRecordB;
  46.     TEHandle            theText;
  47.     Rect                     screenRect         = {0, 0, 384, 512};
  48.     Rect                     windowRectA,windowRectB;
  49.     MenuHandle         deskMenu,editMenu,windowMenu,teMenu,fontMenu,styleMenu;
  50.     char                        *titleA = "\10Window A";
  51.     char                        *titleB = "\10Window B";
  52.     short                    doUpdates;
  53.     CursHandle            iBeam;
  54.  
  55. //    External or Non-Integer functions
  56.  
  57.     WindowPtr     openWindow();
  58.     TEHandle    openTE();
  59.     extern             struct P_Str *CtoPstr();
  60.  
  61.     int strlen(str) char *str;
  62.         {int i=0; while (str[i++]); return i-1;}
  63.         
  64.     reStartProc()
  65.         {ExitToShell();}
  66.  
  67.  
  68. //    Initialization Routine
  69.  
  70. Init()                                                                                                      /* Init() */
  71.     InitDialogs(reStartProc);
  72.     TEInit();
  73.     putUpMenus();
  74.     iBeam = GetCursor(iBeamCursor);
  75.  
  76.     SetRect(&windowRectA ,5, 50, 500, 290);
  77.     SetRect(&windowRectB ,5, 60, 500, 300);
  78.         
  79.     theWindow = NIL;
  80.     theText = NIL;
  81.     doUpdates = TRUE;
  82.     
  83.     windPtrB = openWindow(&windRecordB,&windowRectB,titleB);
  84.     windPtrA = openWindow(&windRecordA,&windowRectA,titleA);
  85. }
  86.     
  87.  
  88. //    Main
  89.  
  90. main()                                                                                                                 /* main() */
  91.     char         c;
  92.     short         windowcode;
  93.     
  94.     EventRecord     theEvent;
  95.     WindowPtr         mouseWindow;
  96.     WindowPtr         tempWindow;
  97.                     
  98.     
  99.     Init();
  100.     
  101.     InitCursor();
  102.     FlushEvents(-1);
  103.     SelectWindow(windPtrA);                       /* Generate an activate event for window A */
  104.     SetPort(windPtrA);
  105.     
  106.     while (TRUE)  {
  107.     
  108.         SystemTask();
  109.         if(theText) {
  110.             TEIdle(theText);
  111.             ChangeMouse();
  112.         }
  113.         
  114.         
  115.         if (GetNextEvent(everyEvent, &theEvent)) {
  116.             switch ( theEvent.what )  {
  117.                   case autoKey:
  118.                  case keyDown:  
  119.                         c = theEvent.message & charCodeMask;
  120.                         if ((theEvent.modifiers & cmdKey)) {
  121.                             doMenuItem(MenuKey(c));
  122.                         } else {
  123.                             if(theText) TEKey(c, theText);
  124.                         }
  125.                     break;
  126.                 
  127.       
  128.                   case mouseDown: 
  129.                     windowcode = FindWindow(&theEvent.where, &mouseWindow);
  130.                     
  131.                     /* mouseDown occurs in active window */
  132.                     if ((FrontWindow() == mouseWindow) && (mouseWindow != NIL)) {
  133.                           activeWindowEvt(&theEvent,mouseWindow,windowcode);
  134.                         break;
  135.                       }
  136.                     
  137.                     /* mouseDown occurs in inactive window */
  138.                     if ((FrontWindow() != mouseWindow) && (mouseWindow != NIL)) {
  139.                             /* Activate window if not Front window -UNLESS cmdKey & inDrag */
  140.                             if( !((theEvent.modifiers & cmdKey) && (windowcode == inDrag)) ) {
  141.                                 SelectWindow(mouseWindow);
  142.                                 break;
  143.                             }
  144.                         inactiveWindowEvt(&theEvent,mouseWindow,windowcode);
  145.                         break;
  146.                     }
  147.         
  148.                     /* mouseDown does not occur in a window */
  149.                     if (mouseWindow == NIL) {
  150.                           notaWindowEvt(&theEvent,mouseWindow,windowcode);
  151.                         break;
  152.                     }
  153.                     
  154.                  case updateEvt:
  155.                     if(doUpdates) doUpdateEvt(&theEvent);
  156.                     break;
  157.       
  158.                  case activateEvt:
  159.                     doActivateEvt(&theEvent);
  160.                     break;
  161.  
  162.             }
  163.         }
  164.     }  
  165. }
  166.  
  167.  
  168. //    mouseDown event handler #1 - Active window                           /* activeWindowEvt() */
  169.  
  170. activeWindowEvt(theEvent,mouseWindow,windowcode)
  171. EventRecord        *theEvent;
  172. WindowPtr            mouseWindow;
  173. short                    windowcode;
  174. {
  175.     long                 growResult;
  176.  
  177.     SetPort(mouseWindow);
  178.     switch ( windowcode ) {
  179.         case inContent: 
  180.             GlobalToLocal(&theEvent->where);
  181.             TEClick(&theEvent->where,(theEvent->modifiers & shiftKey)? TRUE :FALSE, theText);
  182.             break;
  183.                                 
  184.         case inDrag:
  185.             DragWindow(mouseWindow, &theEvent->where, &screenRect);
  186.             break;
  187.                                   
  188.         case inGrow:
  189.             growResult = GrowWindow(mouseWindow, &theEvent->where, &screenRect);
  190.             SizeWindow(mouseWindow, LoWord(growResult), HiWord(growResult), TRUE);
  191.             EraseRect(&mouseWindow->portRect);
  192.             InvalRect(&mouseWindow->portRect);
  193.             SizeTE(mouseWindow);
  194.             DrawGrowIcon(mouseWindow);
  195.             break;
  196.                                     
  197.         case inGoAway:
  198.             if (TrackGoAway(theWindow, &theEvent->where))  {
  199.                 TEDispose(theText);
  200.                 theText = NIL;
  201.                 if(theWindow == windPtrA) windPtrA = NIL;
  202.                 if(theWindow == windPtrB) windPtrB = NIL;
  203.                 DisposeWindow(theWindow);
  204.                 theWindow = NIL;
  205.                 SetMenus(theText,FALSE);
  206.             }
  207.             break;
  208.             
  209.         case inSysWindow:
  210.             SystemClick(theEvent,mouseWindow);
  211.             break;
  212.     } 
  213. }
  214.  
  215.  
  216. //    mouseDown event handler #2 - inactive  window                       /* inactiveWindowEvt() */      
  217.  
  218. inactiveWindowEvt(theEvent,mouseWindow,windowcode)
  219. EventRecord        *theEvent;
  220. WindowPtr            mouseWindow;
  221. short                    windowcode;
  222. {
  223.     switch ( windowcode ) {
  224.         case inDrag:
  225.             DragWindow(mouseWindow, &theEvent->where, &screenRect);
  226.             break;
  227.         case inSysWindow:
  228.             SystemClick(theEvent,mouseWindow);
  229.             break;
  230.     }
  231. }
  232.  
  233.  
  234. //    mouseDown event handler #3 -  no window                                    /* notaWindowEvt() */      
  235.  
  236. notaWindowEvt(theEvent,mouseWindow,windowcode)
  237. EventRecord        *theEvent;
  238. WindowPtr            mouseWindow;
  239. short                    windowcode;
  240. {
  241.     switch ( windowcode ) {
  242.         case inMenuBar:
  243.             doMenuItem(MenuSelect(&theEvent->where));
  244.             break;
  245.         case inDesk:
  246.             SysBeep(1);
  247.             break;
  248.     }
  249. }
  250.  
  251.  
  252. //    Update event handler                                                                         /* doUpdateEvt() */
  253.  
  254. doUpdateEvt(theEvent)
  255. EventRecord    *theEvent;
  256. {
  257.     WindowPtr        tempWindow,oldPort;
  258.     TEHandle        tempText;
  259.     
  260.     GetPort(&oldPort);
  261.     SetPort(tempWindow = (WindowPtr)theEvent->message);
  262.     BeginUpdate(tempWindow);
  263.     tempText = (TEHandle)GetWRefCon(tempWindow);
  264.     TEUpdate(&tempWindow->portRect, tempText);
  265.     DrawGrowIcon(tempWindow);
  266.     EndUpdate(tempWindow);
  267.     SetPort(oldPort);
  268.     return;
  269.  }
  270.  
  271.  
  272.  //    Activate event handler                                                                         /* doActivateEvt() */
  273.  
  274. doActivateEvt(theEvent)
  275. EventRecord    *theEvent;
  276. {
  277.     WindowPtr        tempWindow;
  278.     TEHandle         tempText;
  279.     
  280.     SetPort(tempWindow = (WindowPtr)theEvent->message);
  281.     tempText = (TEHandle)GetWRefCon(tempWindow);
  282.     if ((theEvent->modifiers & activeFlag)) {
  283.         theWindow = tempWindow;
  284.         TEActivate(theText = tempText);
  285.         SetMenus(theText,TRUE);
  286.     } else {
  287.         TEDeactivate(tempText);
  288.         theText = NIL;
  289.         SetMenus(theText,FALSE);
  290.     }
  291.     DrawGrowIcon(tempWindow);
  292.     return;
  293. }
  294.  
  295.  
  296. //    Put up a new Window
  297.  
  298. WindowPtr openWindow(wRec,rect,title)                                            /* openWindow() */
  299. WindowRecord    *wRec;
  300. Rect                    *rect;
  301. char                    *title;
  302. {
  303.     WindowPtr     tempWindow;
  304.     TEHandle    tempText;
  305.     
  306.     tempWindow = NewWindow(wRec,rect, title, TRUE, 0, -1, TRUE, 0);
  307.     SetPort(tempWindow);
  308.     TextFont(newYork);
  309.     TextFace(boldStyle);
  310.     TextSize(12);
  311.     tempText = openTE(tempWindow);
  312.     SetWRefCon(tempWindow, tempText);
  313.     TEUpdate(&(*tempText)->viewRect, tempText);
  314.     (*tempText)->crOnly = 1;
  315.     return tempWindow;
  316. }
  317.  
  318.  
  319. //    Get a New a TEHandle
  320.  
  321. TEHandle openTE(tempWindow)
  322. WindowPtr tempWindow;
  323. {
  324.     Rect             destRect, viewRect;
  325.  
  326.     DupPortRect(tempWindow, &viewRect);
  327.     viewRect.right -= 16;        /* Make room for scroll bar */
  328.     viewRect.bottom -= 16;    /* Make room for scroll bar */
  329.     DupPortRect(tempWindow, &destRect);
  330.     destRect.right -= 16;        /* Make room for scroll bar */
  331.     destRect.bottom -= 16;    /* Make room for scroll bar */
  332.     destRect.left += 4;            /* indent a bit */
  333.     return TENew(&destRect, &viewRect);
  334. }
  335.   
  336.  
  337.  
  338. //    ReSize Suffix Rects
  339.  
  340. sizeTE(tempWindow)                                                                                            /* sizeTE() */
  341. WindowPtr tempWindow;
  342. {
  343.     Rect             rect;
  344.     TEHandle    tempText;
  345.     
  346.     tempText = (TEHandle)GetWRefCon(tempWindow);
  347.     DupPortRect(tempWindow, &rect);
  348.     rect.right -= 16;        /* Make room for scroll bar */
  349.     rect.bottom -= 16;    /* Make room for scroll bar */
  350.     BlockMove(&rect, &(*tempText)->viewRect, sizeof(Rect));
  351.     rect.left += 4;            /* indent a bit */
  352.     BlockMove(&rect, &(*tempText)->destRect, sizeof(Rect));
  353.     TECalText(tempText);
  354. }
  355.     
  356.  
  357. //    Make a new Rect based on size of tempWindow's portRect
  358.  
  359. DupPortRect(tempWindow, rect)                                                                  /* DupPortRect() */
  360. WindowPtr     tempWindow;
  361. Rect             *rect;
  362. {
  363.     BlockMove(&tempWindow->portRect, rect, sizeof(Rect));
  364. }
  365.  
  366.  
  367. //    Puts up Menus
  368.  
  369. putUpMenus()
  370. {
  371. InitMenus();
  372.  
  373. /* Desk Accessory menu */
  374.     deskMenu = NewMenu(Desk_ID,CtoPstr("\024"));
  375.     AppendMenu(deskMenu,CtoPstr("About BMUG5...;(-"));
  376.     AddResMenu(deskMenu, 'DRVR');
  377.     InsertMenu(deskMenu, 0);
  378.  
  379. /* Edit menu */
  380.     editMenu = NewMenu(Edit_ID, CtoPstr("Edit"));
  381.     AppendMenu(editMenu,CtoPstr("(Undo/Z;(-;Cut/X;Copy/C;Paste/V;Clear/Z;(-;Select All"));
  382.     InsertMenu(editMenu, 0);
  383.  
  384. /* "Windows" menu */
  385.     windowMenu = NewMenu(Window_ID, CtoPstr("Windows"));
  386.     AppendMenu(windowMenu,CtoPstr("Window A/A;Window B/B;Do Updates;(-;Item 5/5;Quit/."));
  387.     doUpdates = TRUE;
  388.     CheckItem(windowMenu,3,doUpdates);
  389.     InsertMenu(windowMenu, 0);
  390.  
  391. /* "TE" menu */
  392.     teMenu = NewMenu(TE_ID, CtoPstr("TEStuff"));
  393.     AppendMenu(teMenu,CtoPstr("Left/L;Center/M;Right/R;(-;WordWrap"));
  394.     InsertMenu(teMenu, 0);
  395.  
  396. /* "Font" menu */
  397.     fontMenu = NewMenu(Font_ID, CtoPstr("Font"));
  398.     AppendMenu(fontMenu,CtoPstr("Chicago;New York;Geneva;Monaco"));
  399.     AppendMenu(fontMenu,CtoPstr("(-;9 point;10 point;12 point;14 point"));
  400.     InsertMenu(fontMenu, 0);
  401.  
  402. /* "Style" menu */
  403.     styleMenu = NewMenu(Style_ID, CtoPstr("Style"));
  404.     AppendMenu(styleMenu,CtoPstr("Normal;Bold;Italic;Underline;Outlined;Shadow;Condense;Extend"));
  405.     InsertMenu(styleMenu, 0);
  406.  
  407. DrawMenuBar();
  408. }
  409.  
  410.  
  411. //    Do what the menu says...
  412.  
  413. doMenuItem(menuresult)
  414. long     menuresult;
  415.     struct P_Str    accessoryName;
  416.     short     menuID, itemNumber;
  417.     
  418.     menuID = HiWord(menuresult);
  419.     itemNumber = menuresult;
  420.     
  421.     switch ( menuID ) {
  422.         case Window_ID:
  423.             switch ( itemNumber ) {
  424.                 case 1:                 /* item 1 is Window A*/
  425.                     if(windPtrA == NIL) {
  426.                         windPtrA = openWindow(&windRecordA,&windowRectA,titleA);
  427.                     } 
  428.                     SelectWindow(windPtrA);    
  429.                     break;
  430.                     
  431.                 case 2:                 /* item 2 is Window B*/
  432.                     if(windPtrB == NIL) {
  433.                         windPtrB = openWindow(&windRecordB,&windowRectB,titleB);
  434.                     } 
  435.                     SelectWindow(windPtrB);    
  436.                     break;
  437.                     
  438.                 case 3:                 /* item 3 is do updates */
  439.                     doUpdates = ((doUpdates) ? FALSE : TRUE);
  440.                     CheckItem(windowMenu,itemNumber,doUpdates);
  441.                     break;
  442.                     
  443.                 case 5:                 /* item 5 */
  444.                     break;
  445.                     
  446.                 case 6:                    /* item 6 is quit */
  447.                     ExitToShell();
  448.                     break;
  449.             }
  450.             break;
  451.         
  452.         case Desk_ID:
  453.             if(itemNumber == 1) {        /* item 1 is about window */
  454.                 AboutWindow();
  455.             } else {
  456.                 GetItem(deskMenu, itemNumber, &accessoryName);
  457.                 OpenDeskAcc(&accessoryName);
  458.             }
  459.             break;
  460.  
  461.         case TE_ID:
  462.             if(!theText) break;
  463.             switch(itemNumber) {
  464.                 case 1:            /* item 1 is Left Justification */
  465.                     TESetJust(teJustLeft,theText);
  466.                     break;
  467.                 case 2:            /* item 2 is Center Justification */
  468.                     TESetJust(teJustCenter,theText);
  469.                     break;
  470.                 case 3:            /* item 3 is Right Justification */
  471.                     TESetJust(teJustRight,theText);
  472.                     break;
  473.                 case 5:            /* item 5 is WordWrap */
  474.                     (*theText)->crOnly *= -1;
  475.                     EraseRect(&(*theText)->viewRect);
  476.                     break;
  477.             }
  478.             TECalText(theText);
  479.             TEUpdate(&(*theText)->viewRect, theText);
  480.             SetMenus(theText,TRUE);
  481.             break;
  482.         
  483.         case Edit_ID:
  484.             if( SystemEdit(itemNumber-1) ) break;
  485.             if(!theText) break;
  486.             switch(itemNumber) {
  487.                 case 3:            /* item 3 is Cut */
  488.                     TECut(theText);
  489.                     break;
  490.                 case 4:            /* item 4 is Copy */
  491.                     TECopy(theText);
  492.                     break;
  493.                 case 5:            /* item 5 is Paste */
  494.                     TEPaste(theText);
  495.                     break;
  496.                 case 6:            /* item 6 is Clear */
  497.                     TEDelete(theText);
  498.                     break;
  499.                 case 8:            /* item 8 is Select All */
  500.                     TESetSelect(0,65000,theText);
  501.                     break;
  502.             }
  503.             break;
  504.  
  505.         case Font_ID:
  506.             if(!theText) break;
  507.             switch(itemNumber) {
  508.                 case 1:            /* case 1 is Chicago */
  509.                     (*theText)->txFont = sysFont;
  510.                     break;
  511.                 case 2:            /* case 2 is New York */
  512.                     (*theText)->txFont = newYork;
  513.                     break;
  514.                 case 3:            /* case 3 is Geneva */
  515.                     (*theText)->txFont = geneva;
  516.                     break;
  517.                 case 4:            /* case 4 is Monaco */
  518.                     (*theText)->txFont = monaco;
  519.                     break;
  520.                 case 6:            /* case 6 is 9 point */
  521.                     (*theText)->txSize = 9;
  522.                     break;
  523.                 case 7:            /* case 7 is 10 point */
  524.                     (*theText)->txSize = 10;
  525.                     break;
  526.                 case 8:            /* case 8 is 12 point */
  527.                     (*theText)->txSize = 12;
  528.                     break;
  529.                 case 9:            /* case 9 is 14 point */
  530.                     (*theText)->txSize = 14;
  531.                     break;
  532.             }
  533.             EraseRect(&(*theText)->viewRect);
  534.             TECalText(theText);
  535.             TEUpdate(&(*theText)->viewRect, theText);
  536.             SetMenus(theText,TRUE);
  537.             break;
  538.             
  539.         case Style_ID:
  540.             if(!theText) break;
  541.             switch(itemNumber) {
  542.                 case 1:            /* case 1 is Normal    */
  543.                     (*theText)->txFace = teNormal;
  544.                     break;
  545.                 case 2:            /* case 2 is Bold    */
  546.                     (*theText)->txFace ^= teBold;
  547.                     break;
  548.                 case 3:            /* case 3 is Italic    */
  549.                     (*theText)->txFace ^= teItalic;
  550.                     break;
  551.                 case 4:            /* case 4 is Underline    */
  552.                     (*theText)->txFace ^= teUnderline;
  553.                     break;
  554.                 case 5:            /* case 5 is Outline    */
  555.                     (*theText)->txFace ^= teOutline;
  556.                     break;
  557.                 case 6:            /* case 6 is Shadow    */
  558.                     (*theText)->txFace ^= teShadow;
  559.                     break;
  560.                 case 7:            /* case 7 is Condense    */
  561.                     (*theText)->txFace ^= teCondense;
  562.                     break;
  563.                 case 8:            /* case 8 is Extend */
  564.                     (*theText)->txFace ^= teExtend;
  565.                     break;
  566.             }
  567.             EraseRect(&(*theText)->viewRect);
  568.             TECalText(theText);
  569.             TEUpdate(&(*theText)->viewRect, theText);
  570.             SetMenus(theText,TRUE);
  571.             break;
  572.  
  573.     }
  574.     HiliteMenu(0);
  575. }
  576.  
  577.  
  578. //    Set up Menus for current TextWindow
  579.  
  580. SetMenus(tempText,flag)                                                                               /* SetMenus() */        
  581. TEHandle    tempText;
  582. short            flag;
  583. {
  584.     int        i;
  585.     
  586.     for(i=1;i<6;i++) {
  587.         CheckItem(teMenu,i,FALSE);
  588.     }
  589.     for(i=1;i<10;i++) {
  590.         CheckItem(fontMenu,i,FALSE);
  591.     }
  592.     for(i=1;i<9;i++) {
  593.         CheckItem(styleMenu,i,FALSE);
  594.     }
  595.     if(!flag) return;
  596.         
  597.     switch((*theText)->just) {
  598.         case teJustLeft:
  599.             CheckItem(teMenu,1,TRUE);
  600.             break;
  601.         case teJustCenter:
  602.             CheckItem(teMenu,2,TRUE);
  603.             break;
  604.         case teJustRight:
  605.             CheckItem(teMenu,3,TRUE);
  606.             break;
  607.     }
  608.     if( (*theText)->crOnly > -1 )    CheckItem(teMenu,5,TRUE);    
  609.     switch((*theText)->txFont) {
  610.         case sysFont:            
  611.             CheckItem(fontMenu,1,TRUE);
  612.             break;
  613.         case newYork:        
  614.             CheckItem(fontMenu,2,TRUE);
  615.             break;
  616.         case geneva:        
  617.             CheckItem(fontMenu,3,TRUE);
  618.             break;
  619.         case monaco:            
  620.             CheckItem(fontMenu,4,TRUE);
  621.             break;
  622.     }
  623.     switch((*theText)->txSize) {
  624.         case 9:            
  625.             CheckItem(fontMenu,6,TRUE);
  626.             break;
  627.         case 10:        
  628.             CheckItem(fontMenu,7,TRUE);
  629.             break;
  630.         case 12:        
  631.             CheckItem(fontMenu,8,TRUE);
  632.             break;
  633.         case 14:        
  634.             CheckItem(fontMenu,9,TRUE);
  635.             break;
  636.     }
  637.     if( (*theText)->txFace == teNormal )        CheckItem(styleMenu,1,TRUE);    
  638.     if( (*theText)->txFace & teBold)             CheckItem(styleMenu,2,TRUE);
  639.     if( (*theText)->txFace & teItalic)             CheckItem(styleMenu,3,TRUE);
  640.     if( (*theText)->txFace & teUnderline)    CheckItem(styleMenu,4,TRUE);
  641.     if( (*theText)->txFace & teOutline)            CheckItem(styleMenu,5,TRUE);
  642.     if( (*theText)->txFace & teShadow)        CheckItem(styleMenu,6,TRUE);
  643.     if( (*theText)->txFace & teCondense)    CheckItem(styleMenu,7,TRUE);
  644.     if( (*theText)->txFace & teExtend)            CheckItem(styleMenu,8,TRUE);
  645. }
  646.  
  647.  
  648. //    Put up About Window
  649.  
  650. AboutWindow()
  651. {
  652.     Rect            creditR;
  653.     Rect            lineR;
  654.     GrafPtr    port;
  655.     WindowPtr    creditW;
  656.     EventRecord    anEvent;
  657.     long            dummy;
  658.     char         *line1 = "BMUG Developers Group - April 17,1985";
  659.     char            *line2 = "Sample Program #5";
  660.     char            *line3 = "written by Dave Burnard";
  661.     char            *line4 = "developed using Consulair Mac C(tm)";
  662.     
  663.     GetPort(&port);                                // must preserve port
  664.     SetRect(&lineR,5,5,345,20);
  665.     SetRect(&creditR,75,120,425,220);
  666.     creditW = NewWindow((WindowPeek)  NIL,&creditR,"\1x",TRUE,dBoxProc,(WindowPtr) -1,TRUE,0);
  667.     SetPort(creditW);
  668.     
  669.     TextSize(12);
  670.     TextFont(0);
  671.     TextBox(line1,strlen(line1),&lineR,teJustCenter);
  672.     OffsetRect(&lineR,0,20);
  673.     TextBox(line2,strlen(line2),&lineR,teJustCenter);
  674.     OffsetRect(&lineR,0,20);
  675.     TextBox(line3,strlen(line3),&lineR,teJustCenter);
  676.     OffsetRect(&lineR,0,20);
  677.     TextBox(line4,strlen(line4),&lineR,teJustCenter);
  678.             
  679.     do {
  680.         GetNextEvent(everyEvent, &anEvent);
  681.     } while (anEvent.what != mouseDown);
  682.     
  683.     DisposeWindow(creditW);
  684.     
  685.     SetPort(port);
  686.  
  687.     return;
  688. }
  689.  
  690.  
  691. //    Change Mouse if over active Text region
  692.  
  693. ChangeMouse()
  694. {
  695.     Point    mousePt;
  696.     if( ((WindowPeek) FrontWindow() )->windowKind == userKind) {
  697.         GetMouse(&mousePt);
  698.         if( PtInRect(&mousePt,&(*theText)->viewRect) ) {
  699.             SetCursor(*iBeam);
  700.         } else {
  701.             SetCursor(&QD->arrow);
  702.         }
  703.     } else {
  704.         SetCursor(&QD->arrow);
  705.     }
  706.     
  707. }
  708.