home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 7 / Apprentice-Release7.iso / Source Code / C / Applications / POV-Ray 3.0.2 / src / MacSource / TE32K / windows.c < prev   
Encoding:
C/C++ Source or Header  |  1994-07-21  |  18.6 KB  |  963 lines  |  [TEXT/KAHL]

  1. #include <Controls.h>
  2. #include <Desk.h>
  3. #include <StandardFile.h>
  4. #include <Events.h>
  5. #include <Scrap.h>
  6. #include <ToolUtils.h>
  7.  
  8. #include "TE32K.h"
  9. #include <stdio.h>
  10.  
  11.  
  12. #define    INDENT    5
  13.  
  14. extern    WindowPtr        theWPtr;
  15. extern    TE32KHandle        theTEH32K;
  16. extern    ControlHandle    theVScroll,theHScroll;
  17. extern    Cursor            editCursor,waitCursor;
  18. extern    char            changed;
  19. extern    SFReply            mySFReply;
  20. extern    short                defaultFont,defaultFontSize;
  21.  
  22. #if defined(powerc) || defined(__powerc)
  23. extern QDGlobals            qd;
  24. #endif
  25.  
  26.  
  27. SetUpCursors()
  28. {
  29. CursHandle    hCurs;
  30.     
  31.     hCurs = GetCursor(iBeamCursor);
  32.     editCursor = **hCurs;
  33.     
  34.     hCurs = GetCursor(watchCursor);
  35.     waitCursor = **hCurs;
  36. }
  37.  
  38.  
  39.  
  40. DoMouseDown(theEvent)
  41. EventRecord    *theEvent;
  42. {
  43. WindowPtr    whichWindow;
  44. short            windowCode;
  45.  
  46.     windowCode = FindWindow(theEvent->where,&whichWindow);
  47.     
  48.     switch (windowCode = FindWindow(theEvent->where,&whichWindow)) 
  49.     {
  50.         case inMenuBar:
  51.             DoCommand(MenuSelect(theEvent->where));
  52.             break;
  53.             
  54.         case inSysWindow:
  55.             SystemClick(theEvent,whichWindow);
  56.             break;
  57.             
  58.         case inContent:
  59.             if (whichWindow != FrontWindow())
  60.                 SelectWindow(whichWindow);
  61.             
  62.             else if (IsOurWindow(whichWindow))
  63.                 DoContent(whichWindow,theEvent);
  64.             
  65.             break;
  66.         
  67.         case inDrag:
  68.             if (whichWindow != FrontWindow())
  69.                 SelectWindow(whichWindow);
  70.             
  71.             else if (IsOurWindow(whichWindow))
  72.                 DoDrag(whichWindow,theEvent);
  73.             
  74.             break;
  75.             
  76.         case inGrow:
  77.             if (whichWindow != FrontWindow())
  78.                 SelectWindow(whichWindow);
  79.             
  80.             else if (IsOurWindow(whichWindow))
  81.                 DoGrow(whichWindow,theEvent);
  82.             
  83.             break;
  84.         
  85.         case inZoomIn:
  86.         case inZoomOut:
  87.             if (whichWindow != FrontWindow())
  88.                 SelectWindow(whichWindow);
  89.             
  90.             else if (IsOurWindow(whichWindow) && TrackBox(whichWindow,theEvent->where,windowCode))
  91.                 DoZoom(whichWindow,windowCode);
  92.             
  93.             break;
  94.         
  95.         case inGoAway:
  96.             if (whichWindow != FrontWindow())
  97.                 SelectWindow(whichWindow);
  98.             
  99.             else if (IsOurWindow(whichWindow) && TrackGoAway(whichWindow,theEvent->where))
  100.                 DoCloseWindow(whichWindow);
  101.             
  102.             break;
  103.     }
  104. }
  105.  
  106.  
  107.  
  108.  
  109.  
  110.  
  111. IsOurWindow(whichWindow)
  112. WindowPtr    whichWindow;
  113. {
  114.     if (theWPtr && whichWindow == theWPtr)
  115.         return(true);
  116.     else
  117.         return(false);
  118. }
  119.  
  120.  
  121.  
  122. void ActivateScrollbar(ControlHandle scrollbar, Boolean becomingActive)
  123. {
  124.     Rect iRect;
  125.     
  126.     iRect = (**scrollbar).contrlRect;
  127.     if (becomingActive) {
  128.         (**scrollbar).contrlVis = 255;
  129.         Draw1Control(scrollbar);
  130.     } else {
  131.         (**scrollbar).contrlVis = 0;
  132.         InsetRect(&iRect, 1, 1);
  133.         EraseRect(&iRect);
  134.     }
  135.     ValidRect(&iRect);
  136. }
  137.  
  138.  
  139.  
  140. DoActivateDeactivate(whichWindow,adFlag)
  141. WindowPtr    whichWindow;char    adFlag;
  142. {
  143. GrafPtr            oldPort;
  144.  
  145.     if (whichWindow == theWPtr)
  146.     {
  147.         GetPort(&oldPort);
  148.         SetPort(whichWindow);
  149.         
  150.         ActivateScrollbar(theVScroll, adFlag);
  151.         ActivateScrollbar(theHScroll, adFlag);
  152.         
  153.         if (adFlag)
  154.             TE32KActivate(theTEH32K);
  155.         else
  156.             TE32KDeactivate(theTEH32K);
  157.         
  158.         DrawGrowIcon(whichWindow);
  159.         
  160.         SetPort(oldPort);
  161.         
  162.         return(true);
  163.     }
  164.     
  165.     else
  166.         return(false);
  167. }
  168.  
  169.  
  170.  
  171.  
  172.  
  173.  
  174. DoCloseWindow(whichWindow)
  175. WindowPtr    whichWindow;
  176. {
  177. short        userChoice;
  178.  
  179.     if (theWPtr && whichWindow==theWPtr)
  180.     {
  181.         if (changed)
  182.         {
  183.             userChoice = YesNoCancel("Save changes?",3);
  184.             
  185.             if (userChoice == 3)
  186.                 return(false);
  187.             
  188.             else if (userChoice == 1 && !SaveTextFile(theTEH32K,&mySFReply))
  189.                 return(false);
  190.         }        
  191.         
  192.         if (theVScroll) DisposeControl(theVScroll);
  193.         if (theHScroll) DisposeControl(theHScroll);
  194.         if (theTEH32K) TE32KDispose(theTEH32K);
  195.         if (theWPtr) DisposeWindow(theWPtr);
  196.         
  197.         theWPtr = 0L;
  198.         theTEH32K = 0L;
  199.         theVScroll = 0L;
  200.         theHScroll = 0L;
  201.         
  202.         return(true);
  203.     }
  204.     
  205.     else
  206.         return(false);
  207. }
  208.  
  209.  
  210.  
  211. DoGrow(whichWindow,theEvent)
  212. WindowPtr    whichWindow;EventRecord    *theEvent;
  213. {
  214. Rect            tempRect;
  215. long            newSize;
  216. GrafPtr            oldPort;
  217.  
  218.     if (theWPtr && whichWindow==theWPtr)
  219.     {
  220.         SetRect(&tempRect,100,50,32767,32767);
  221.         newSize = GrowWindow(whichWindow,theEvent->where,&tempRect);
  222.         SizeWindow(whichWindow,LoWord(newSize),HiWord(newSize),0xff);
  223.         tempRect = whichWindow->portRect;
  224.         GetPort(&oldPort);
  225.         SetPort(whichWindow);
  226.         EraseRect(&tempRect);
  227.         InvalRect(&tempRect);
  228.         
  229.         MoveControl(theVScroll,tempRect.right+1-16,tempRect.top-1);
  230.         SizeControl(theVScroll,16,whichWindow->portRect.bottom-14-(whichWindow->portRect.top-1));
  231.         
  232.         MoveControl(theHScroll,tempRect.left-1,tempRect.bottom+1-16);
  233.         SizeControl(theHScroll,whichWindow->portRect.right-14-(whichWindow->portRect.left-1),16);
  234.         
  235.         AdjustForResizedWindow();
  236.         
  237.         SetPort(oldPort);
  238.         
  239.         return(true);
  240.     }
  241.     
  242.     else
  243.         return(false);
  244. }
  245.  
  246.  
  247.  
  248.  
  249. DoZoom(whichWindow,windowCode)
  250. WindowPtr    whichWindow;short windowCode;
  251. {
  252. Rect            tempRect;
  253. GrafPtr            oldPort;
  254.  
  255.     if (theWPtr && whichWindow==theWPtr)
  256.     {
  257.         GetPort(&oldPort);
  258.         SetPort(whichWindow);
  259.         
  260.         tempRect = whichWindow->portRect;
  261.         EraseRect(&tempRect);
  262.         
  263.         ZoomWindow(whichWindow, windowCode, 0);
  264.         
  265.         tempRect = whichWindow->portRect;
  266.         EraseRect(&tempRect);
  267.         
  268.         MoveControl(theVScroll,tempRect.right+1-16,tempRect.top-1);
  269.         SizeControl(theVScroll,16,whichWindow->portRect.bottom-14-(whichWindow->portRect.top-1));
  270.         
  271.         MoveControl(theHScroll,tempRect.left-1,tempRect.bottom+1-16);
  272.         SizeControl(theHScroll,whichWindow->portRect.right-14-(whichWindow->portRect.left-1),16);
  273.         
  274.         AdjustForResizedWindow();
  275.         
  276.         tempRect = whichWindow->portRect;
  277.         InvalRect(&tempRect);
  278.         
  279.         SetPort(oldPort);
  280.         
  281.         return(true);
  282.     }
  283.     
  284.     else
  285.         return(false);
  286. }
  287.  
  288.  
  289.  
  290. DoDrag(whichWindow,theEvent)
  291. WindowPtr    whichWindow;EventRecord    *theEvent;
  292. {
  293. Rect            tempRect;
  294.  
  295.     if (theWPtr && whichWindow == theWPtr)
  296.     {
  297.         SetRect(&tempRect,qd.screenBits.bounds.left+10,qd.screenBits.bounds.top+25,qd.screenBits.bounds.right-10,qd.screenBits.bounds.bottom-25);
  298.         DragWindow(whichWindow,theEvent->where,&tempRect);
  299.         return(true);
  300.     }
  301.     
  302.     else
  303.         return(false);
  304. }
  305.  
  306.  
  307.  
  308.  
  309. AdjustScrollBar()
  310. {
  311. short        ctlVal,screenLines,numLines,oldVal;
  312.  
  313.     ctlVal = ((*theTEH32K)->viewRect.top - (*theTEH32K)->destRect.top)/(*theTEH32K)->lineHeight;
  314.     screenLines = ((*theTEH32K)->viewRect.bottom - (*theTEH32K)->viewRect.top)/(**theTEH32K).lineHeight;
  315.     numLines = (**theTEH32K).nLines;
  316.     
  317.     if (ctlVal > numLines-screenLines)
  318.         SetCtlMax(theVScroll,ctlVal);
  319.     else
  320.         SetCtlMax(theVScroll,(numLines-screenLines > 0) ? numLines-screenLines : 0);
  321.     
  322.     oldVal = GetCtlValue(theVScroll);
  323.     
  324.     if (oldVal != ctlVal)
  325.         SetCtlValue(theVScroll,ctlVal);
  326.     
  327.     
  328.     
  329.     ctlVal = ((*theTEH32K)->viewRect.left - (*theTEH32K)->destRect.left)/(*theTEH32K)->lineHeight;
  330.     numLines = GetCtlMax(theHScroll);
  331.     
  332.     if (ctlVal < 0)
  333.         ctlVal = 0;
  334.     else if (ctlVal > numLines)
  335.         ctlVal = numLines;
  336.     
  337.     oldVal = GetCtlValue(theHScroll);
  338.     
  339.     if (oldVal != ctlVal)
  340.         SetCtlValue(theHScroll,ctlVal);
  341. }
  342.  
  343.  
  344.  
  345. AdjustForResizedWindow()
  346. {
  347. Rect        tempRect;
  348.  
  349.     SetRect(&tempRect,(theWPtr)->portRect.left+INDENT,(theWPtr)->portRect.top+INDENT,(theWPtr)->portRect.right-15-INDENT,(theWPtr)->portRect.bottom-16-INDENT);
  350.     tempRect.bottom = tempRect.top + ((tempRect.bottom - tempRect.top)/(*theTEH32K)->lineHeight)*(*theTEH32K)->lineHeight;
  351.     
  352.     RectToLongRect(&tempRect,&((*theTEH32K)->viewRect));
  353.     
  354.     RectToLongRect(&tempRect,&((*theTEH32K)->destRect));
  355.     (*theTEH32K)->destRect.top -= (long) GetCtlValue(theVScroll)*(*theTEH32K)->lineHeight;
  356.     (*theTEH32K)->destRect.left -= (long) GetCtlValue(theHScroll)*(*theTEH32K)->lineHeight;
  357.     
  358.     (**theTEH32K).destRect.right -= 10;
  359.     
  360.     TE32KFromScrap();
  361.     
  362.     SetCursor(&waitCursor);
  363.     TE32KCalText(theTEH32K);
  364.     InitCursor();
  365.     
  366.     AdjustScrollBar();
  367. }
  368.  
  369.  
  370.  
  371. pascal void myScrollProc(theControl, theCode)
  372. ControlHandle    theControl;short    theCode;
  373. {
  374. long        scrollAmt,lines;
  375. short            controlMax,controlMin,controlVal;
  376. RgnHandle    updateRgn;
  377.     
  378.     if (theVScroll && theControl==theVScroll)
  379.     {
  380.         controlMax = GetCtlMax(theControl);
  381.         controlMin = GetCtlMin(theControl);
  382.         controlVal = GetCtlValue(theControl);
  383.         
  384.         updateRgn = NewRgn();
  385.         
  386.         switch (theCode) 
  387.         {
  388.             case inUpButton:
  389.                 if (controlVal > controlMin)
  390.                 {
  391.                     SetCtlValue(theControl,controlVal-1);
  392.                     
  393.                     TE32KScroll(0L,(long) (**theTEH32K).lineHeight,theTEH32K);
  394.                 }
  395.                 
  396.                 break;
  397.                 
  398.             case inDownButton: 
  399.                 if (controlVal < controlMax)
  400.                 {
  401.                     SetCtlValue(theControl,controlVal+1);
  402.                     
  403.                     TE32KScroll(0L,(long) -(**theTEH32K).lineHeight,theTEH32K);
  404.                 }
  405.                 
  406.                 break;
  407.     
  408.             case inPageUp: 
  409.                 if (controlVal > controlMin)
  410.                 {
  411.                     lines = ((*theTEH32K)->viewRect.bottom - (*theTEH32K)->viewRect.top)/(**theTEH32K).lineHeight;
  412.                     scrollAmt = (controlVal-lines < controlMin) ? controlVal-controlMin : lines;
  413.                     SetCtlValue(theControl,controlVal-scrollAmt);
  414.                     TE32KScroll(0L,(long) ((long) scrollAmt * (long) (**theTEH32K).lineHeight),theTEH32K);
  415.                 }
  416.                 
  417.                 break;
  418.     
  419.             case inPageDown: 
  420.                 if (controlVal < controlMax)
  421.                 {
  422.                     lines = ((**theTEH32K).viewRect.bottom - (**theTEH32K).viewRect.top)/(**theTEH32K).lineHeight;
  423.                     scrollAmt = (controlVal+lines > controlMax) ? controlMax-controlVal : lines;
  424.                     SetCtlValue(theControl,controlVal+scrollAmt);
  425.                     TE32KScroll(0L,(long) ((long) -scrollAmt * (long) (**theTEH32K).lineHeight),theTEH32K);
  426.                 }
  427.                 
  428.                 break;
  429.         }
  430.         
  431.         AdjustScrollBar();
  432.         
  433.         DisposeRgn(updateRgn);
  434.     }
  435.     
  436.     else if (theHScroll && theControl==theHScroll)
  437.     {
  438.         controlMax = GetCtlMax(theControl);
  439.         controlMin = GetCtlMin(theControl);
  440.         controlVal = GetCtlValue(theControl);
  441.         
  442.         updateRgn = NewRgn();
  443.         
  444.         switch (theCode) 
  445.         {
  446.             case inUpButton:
  447.                 if (controlVal > controlMin)
  448.                 {
  449.                     SetCtlValue(theControl,controlVal-1);
  450.                     
  451.                     TE32KScroll((long) (**theTEH32K).lineHeight,0L,theTEH32K);
  452.                 }
  453.                 
  454.                 break;
  455.                 
  456.             case inDownButton: 
  457.                 if (controlVal < controlMax)
  458.                 {
  459.                     SetCtlValue(theControl,controlVal+1);
  460.                     
  461.                     TE32KScroll((long) -(**theTEH32K).lineHeight,0L,theTEH32K);
  462.                 }
  463.                 
  464.                 break;
  465.     
  466.             case inPageUp: 
  467.                 if (controlVal > controlMin)
  468.                 {
  469.                     lines = ((*theTEH32K)->viewRect.right - (*theTEH32K)->viewRect.left)/(2 * (**theTEH32K).lineHeight);
  470.                     scrollAmt = (controlVal-lines < controlMin) ? controlVal-controlMin : lines;
  471.                     SetCtlValue(theControl,controlVal-scrollAmt);
  472.                     TE32KScroll((long) ((long) scrollAmt * (long) (**theTEH32K).lineHeight),0L,theTEH32K);
  473.                 }
  474.                 
  475.                 break;
  476.     
  477.             case inPageDown: 
  478.                 if (controlVal < controlMax)
  479.                 {
  480.                     lines = ((*theTEH32K)->viewRect.right - (*theTEH32K)->viewRect.left)/(2 * (**theTEH32K).lineHeight);
  481.                     scrollAmt = (controlVal+lines > controlMax) ? controlMax-controlVal : lines;
  482.                     SetCtlValue(theControl,controlVal+scrollAmt);
  483.                     TE32KScroll((long) -((long) scrollAmt * (long) (**theTEH32K).lineHeight),0L,theTEH32K);
  484.                 }
  485.                 
  486.                 break;
  487.         }
  488.         
  489.         AdjustScrollBar();
  490.         
  491.         DisposeRgn(updateRgn);
  492.     }
  493. }
  494.  
  495.  
  496.  
  497.  
  498.  
  499. DoContent(whichWindow,theEvent)
  500. WindowPtr    whichWindow;EventRecord    *theEvent;
  501. {
  502. GrafPtr            oldPort;
  503. ControlHandle    whichControl;
  504. short                cntlCode;
  505. long            oldVal;
  506. Rect            tempRect;
  507. static    ControlActionUPP scrollProcUPP = nil;
  508.  
  509.     if (!scrollProcUPP)
  510.         scrollProcUPP = NewControlActionProc(myScrollProc);
  511.  
  512.     if (theWPtr && whichWindow==theWPtr)
  513.     {
  514.         GetPort(&oldPort);
  515.         SetPort(whichWindow);
  516.         
  517.         LongRectToRect(&((**theTEH32K).viewRect),&tempRect);
  518.         
  519.         GlobalToLocal(&(theEvent->where));
  520.         
  521.         cntlCode = FindControl(theEvent->where,whichWindow,&whichControl);
  522.         
  523.         if (theVScroll && whichControl == theVScroll && cntlCode != 0)
  524.         {
  525.             if (cntlCode == inThumb)
  526.             {
  527.                 oldVal = GetCtlValue(whichControl);
  528.                 
  529.                 TrackControl(whichControl,theEvent->where,0L);
  530.                 
  531.                 TE32KScroll(0L,(long) ((oldVal - (long) GetCtlValue(whichControl)) * (long) (**theTEH32K).lineHeight),theTEH32K);
  532.             }
  533.             
  534.             else
  535.                 TrackControl(whichControl,theEvent->where,scrollProcUPP);
  536.         }
  537.         
  538.         else if (theHScroll && whichControl == theHScroll && cntlCode != 0)
  539.         {
  540.             if (cntlCode == inThumb)
  541.             {
  542.                 oldVal = GetCtlValue(whichControl);
  543.                 
  544.                 TrackControl(whichControl,theEvent->where,0L);
  545.                 
  546.                 TE32KScroll((long) ((oldVal - GetCtlValue(whichControl)) * (**theTEH32K).lineHeight),0L,theTEH32K);
  547.             }
  548.             
  549.             else
  550.                 TrackControl(whichControl,theEvent->where,scrollProcUPP);
  551.         }
  552.         
  553.         else if (PtInRect(theEvent->where,&tempRect))
  554.         {
  555.             if (theEvent->modifiers & shiftKey)
  556.                 TE32KClick(theEvent->where,true,theTEH32K);
  557.             else
  558.                 TE32KClick(theEvent->where,false,theTEH32K);
  559.         }
  560.         
  561.         SetPort(oldPort);
  562.         
  563.         return(true);
  564.     }
  565.     
  566.     else
  567.         return(false);
  568. }
  569.  
  570.  
  571.  
  572.  
  573. UpdateWindow(whichWindow)
  574. WindowPtr    whichWindow;
  575. {
  576. GrafPtr            oldPort;
  577. Rect            tempRect;
  578. LongRect        tempLongRect;
  579. RgnHandle        updateRgn;
  580.  
  581.     if (whichWindow != theWPtr)
  582.         return(false);
  583.  
  584.     GetPort(&oldPort);
  585.     SetPort(whichWindow);
  586.     
  587.     PenNormal();
  588.     
  589.     BeginUpdate(whichWindow);
  590.     
  591.     tempRect = whichWindow->portRect;
  592.     EraseRect(&tempRect);
  593.     
  594.     if (whichWindow == theWPtr)
  595.     {
  596.         DrawGrowIcon(whichWindow);
  597.         DrawControls(whichWindow);
  598.         
  599.         updateRgn = ((WindowPeek) theWPtr)->updateRgn;
  600.         
  601.         tempLongRect.left = (**updateRgn).rgnBBox.left;
  602.         tempLongRect.top = (**updateRgn).rgnBBox.top;
  603.         tempLongRect.right = (**updateRgn).rgnBBox.right;
  604.         tempLongRect.bottom = (**updateRgn).rgnBBox.bottom;
  605.         
  606.         RectToLongRect(&tempRect,&tempLongRect);
  607.         TE32KUpdate(&tempLongRect,theTEH32K);
  608.     }
  609.     
  610.     EndUpdate(whichWindow);
  611.     
  612.     SetPort(oldPort);
  613.     
  614.     return(true);
  615. }
  616.  
  617.  
  618.  
  619.  
  620.  
  621. void MyClicker()
  622. {
  623. short            controlMax,controlMin,controlVal,lineHeight;
  624. Rect        viewRect;
  625. Point        mousePoshort;
  626. RgnHandle    saveClip;
  627. long        hDelta,vDelta;
  628.  
  629.     LongRectToRect(&((**theTEH32K).viewRect),&viewRect);
  630.     lineHeight = (**theTEH32K).lineHeight;
  631.  
  632.     hDelta = 0L;
  633.     vDelta = 0L;
  634.     
  635.     GetMouse(&mousePoshort);
  636.     
  637.     if (!PtInRect(mousePoshort,&viewRect))
  638.     {
  639.         controlMax = GetCtlMax(theVScroll);
  640.         controlMin = GetCtlMin(theVScroll);
  641.         controlVal = GetCtlValue(theVScroll);
  642.         
  643.         if (mousePoshort.v>viewRect.bottom && controlVal<controlMax)
  644.         {
  645.             vDelta = -lineHeight;
  646.             SetCtlValue(theVScroll,controlVal+1);
  647.         }
  648.         
  649.         else if (mousePoshort.v<viewRect.top && controlVal>controlMin)
  650.         {
  651.             vDelta = lineHeight;
  652.             SetCtlValue(theVScroll,controlVal-1);
  653.         }
  654.         
  655.         controlMax = GetCtlMax(theHScroll);
  656.         controlMin = GetCtlMin(theHScroll);
  657.         controlVal = GetCtlValue(theHScroll);
  658.         
  659.         if (mousePoshort.h>viewRect.right && controlVal<controlMax)
  660.         {
  661.             hDelta = -lineHeight;
  662.             SetCtlValue(theHScroll,controlVal+1);
  663.         }
  664.         
  665.         else if (mousePoshort.h<viewRect.left && controlVal>controlMin)
  666.         {
  667.             hDelta = lineHeight;
  668.             SetCtlValue(theHScroll,controlVal-1);
  669.         }
  670.     }
  671.     
  672.     if (hDelta || vDelta)
  673.     {
  674.         saveClip = NewRgn();
  675.         GetClip(saveClip);
  676.         ClipRect(&(theWPtr->portRect));
  677.         
  678.         TE32KScroll(hDelta,vDelta,theTEH32K);
  679.         
  680.         SetClip(saveClip);
  681.         DisposeRgn(saveClip);
  682.     }
  683. }
  684.  
  685.  
  686.  
  687.  
  688. void MyClickLoop()
  689. {
  690.     MyClicker();
  691. }
  692.  
  693.  
  694.  
  695.  
  696. DoShowWindow()
  697. {
  698. Rect            tempRect;
  699. FontInfo        theFontInfo;
  700. LongRect        tempLongRect;
  701.  
  702.     if (theWPtr)
  703.         SelectWindow(theWPtr);
  704.         
  705.     else
  706.     {
  707.         SetRect(&tempRect,20,40,500,320);
  708.         
  709.         theWPtr = NewWindow (0L,&tempRect,"\pUntitled",true,zoomDocProc,(WindowPtr) -1L,true,0L);
  710.         if (theWPtr==0L)
  711.         {
  712.             ErrorAlert("Insufficient memory to open window");
  713.             return;
  714.         }
  715.         
  716.         SetPort(theWPtr);
  717.         
  718.         TextFont(defaultFont);
  719.         TextSize(defaultFontSize);
  720.         TextFace(0);
  721.         TextMode(srcCopy);
  722.         
  723.         GetFontInfo(&theFontInfo);
  724.         
  725.         SetRect(&tempRect,(theWPtr)->portRect.right-15,(theWPtr)->portRect.top-1,(theWPtr)->portRect.right+1,(theWPtr)->portRect.bottom-14);
  726.         theVScroll = NewControl(theWPtr,&tempRect,"\p",true,0,0,0,scrollBarProc,0L);
  727.         
  728.         if (theVScroll==0L)
  729.         {
  730.             DisposeWindow(theWPtr);
  731.             theWPtr = 0L;
  732.             theVScroll = 0L;
  733.             ErrorAlert("Insufficient memory to open edit record");
  734.             return;
  735.         }
  736.         
  737.         SetRect(&tempRect,(theWPtr)->portRect.left-1,(theWPtr)->portRect.bottom+1-16,(theWPtr)->portRect.right-14,(theWPtr)->portRect.bottom+1);
  738.         theHScroll = NewControl(theWPtr,&tempRect,"\p",true,0,0,255,scrollBarProc,0L);
  739.         
  740.         if (theHScroll==0L)
  741.         {
  742.             DisposeWindow(theWPtr);
  743.             DisposeControl(theVScroll);
  744.             theWPtr = 0L;
  745.             theVScroll = 0L;
  746.             theHScroll = 0L;
  747.             ErrorAlert("Insufficient memory to open edit record");
  748.             return;
  749.         }
  750.         
  751.         SetRect(&(tempRect),(theWPtr)->portRect.left+INDENT,(theWPtr)->portRect.top+INDENT,(theWPtr)->portRect.right-15-INDENT,(theWPtr)->portRect.bottom-16-INDENT);
  752.         RectToLongRect(&tempRect,&tempLongRect);
  753.         theTEH32K = TE32KNew(&tempLongRect,&tempLongRect);
  754.     
  755.         if (theTEH32K==0L)
  756.         {
  757.             DisposeControl(theVScroll);
  758.             DisposeControl(theHScroll);
  759.             DisposeWindow(theWPtr);
  760.             theWPtr = 0L;
  761.             theVScroll = 0L;
  762.             theHScroll = 0L;
  763.             ErrorAlert("Insufficient memory to open edit record");
  764.             return;
  765.         }
  766.         
  767.         (**theTEH32K).destRect.right -= 10;
  768.         
  769.         TE32KFeatureFlag(te32KFOutlineHilite, TE32KBitSet, theTEH32K);
  770.         TE32KFeatureFlag(te32KFShowCarridgeReturns, TE32KBitSet, theTEH32K);
  771.         
  772.         TE32KFromScrap();
  773.         
  774.         (*theTEH32K)->destRect.bottom = (*theTEH32K)->destRect.top + (((*theTEH32K)->destRect.bottom - (*theTEH32K)->destRect.top)/(*theTEH32K)->lineHeight)*(*theTEH32K)->lineHeight;
  775.         (*theTEH32K)->viewRect.bottom = (*theTEH32K)->viewRect.top + (((*theTEH32K)->viewRect.bottom - (*theTEH32K)->viewRect.top)/(*theTEH32K)->lineHeight)*(*theTEH32K)->lineHeight;
  776.         
  777.         (**theTEH32K).clikLoop = (TE32KProcPtr) MyClickLoop;
  778.         
  779.         changed = false;
  780.         
  781.         mySFReply.good = false;
  782.     }
  783. }
  784.  
  785.  
  786.  
  787. DoKey(theChar)
  788. unsigned char    theChar;
  789. {
  790.     if (theWPtr && theWPtr == FrontWindow())
  791.     {
  792.         TE32KKey(theChar,theTEH32K);
  793.         
  794.         TE32KSelView(theTEH32K);
  795.         
  796.         changed = true;
  797.         
  798.         AdjustScrollBar();
  799.         
  800.         return(true);
  801.     }
  802.     
  803.     else
  804.         return(false);
  805. }
  806.  
  807.  
  808. DoIdle()
  809. {
  810.     if (theWPtr && theWPtr == FrontWindow())
  811.     {
  812.         TE32KIdle(theTEH32K);
  813.         
  814.         return(true);
  815.     }
  816.     
  817.     else
  818.         return(false);
  819. }
  820.  
  821.  
  822.  
  823.  
  824.  
  825. MashortainCursor()
  826. {
  827. Point        pt;
  828. GrafPtr        oldPort;
  829. Rect        tempRect;
  830.  
  831.     if (theWPtr && FrontWindow() == theWPtr)
  832.     {
  833.         GetPort(&oldPort);
  834.         SetPort(theWPtr);
  835.         
  836.         SetRect(&tempRect,(theWPtr)->portRect.left+INDENT,(theWPtr)->portRect.top+INDENT,(theWPtr)->portRect.right-15-INDENT,(theWPtr)->portRect.bottom-16-INDENT);
  837.         
  838.         GetMouse(&pt);
  839.         
  840.         if (PtInRect(pt,&tempRect))
  841.             SetCursor(&editCursor);
  842.         
  843.         else
  844.             SetCursor(&qd.arrow);
  845.         
  846.         return(true);
  847.         
  848.         SetPort(oldPort);
  849.     }
  850.     
  851.     return(false);
  852. }
  853.  
  854.  
  855.  
  856.  
  857. DoCut()
  858. {
  859.     if (theWPtr && FrontWindow() == theWPtr && theTEH32K)
  860.     {
  861.         SetCursor(&waitCursor);
  862.         TE32KCut(theTEH32K);
  863.         ZeroScrap();
  864.         TE32KToScrap();
  865.         InitCursor();
  866.         
  867.         changed = true;
  868.         
  869.         TE32KSelView(theTEH32K);
  870.         AdjustScrollBar();
  871.         
  872.         return(true);
  873.     }
  874.     
  875.     else
  876.         return(false);
  877. }
  878.  
  879.  
  880.  
  881. DoCopy()
  882. {
  883.     if (theWPtr && FrontWindow() == theWPtr && theTEH32K)
  884.     {
  885.         SetCursor(&waitCursor);
  886.         TE32KCopy(theTEH32K);
  887.         ZeroScrap();
  888.         TE32KToScrap();
  889.         InitCursor();
  890.         
  891.         return(true);
  892.     }
  893.     
  894.     else
  895.         return(false);
  896. }
  897.  
  898.  
  899.  
  900.  
  901. DoPaste()
  902. {
  903.     if (theWPtr && FrontWindow() == theWPtr && theTEH32K)
  904.     {
  905.         SetCursor(&waitCursor);
  906.         TE32KFromScrap();
  907.         TE32KPaste(theTEH32K);
  908.         InitCursor();
  909.         
  910.         changed = true;
  911.         
  912.         TE32KSelView(theTEH32K);
  913.         AdjustScrollBar();
  914.         
  915.         return(true);
  916.     }
  917.     
  918.     else
  919.         return(false);
  920. }
  921.  
  922.  
  923.  
  924.  
  925.  
  926. DoClear()
  927. {
  928.     if (theWPtr && FrontWindow() == theWPtr && theTEH32K)
  929.     {
  930.         SetCursor(&waitCursor);
  931.         TE32KDelete(theTEH32K);
  932.         InitCursor();
  933.         
  934.         changed = true;
  935.         
  936.         TE32KSelView(theTEH32K);
  937.         AdjustScrollBar();
  938.         
  939.         return(true);
  940.     }
  941.     
  942.     else
  943.         return(false);
  944. }
  945.  
  946.  
  947.  
  948. DoSelectAll()
  949. {
  950.     if (theWPtr && FrontWindow() == theWPtr && theTEH32K)
  951.     {
  952.         SetCursor(&waitCursor);
  953.         TE32KSetSelect(0L,(**theTEH32K).teLength,theTEH32K);
  954.         AdjustScrollBar();
  955.         InitCursor();
  956.         
  957.         return(true);
  958.     }
  959.     
  960.     else
  961.         return(false);
  962. }
  963.