home *** CD-ROM | disk | FTP | other *** search
/ ftp.mactech.com 2010 / ftp.mactech.com.tar / ftp.mactech.com / online / source / c / compilers / Tickle-4.0.sit.hqx / Tickle-4.0 / src / windows.c < prev    next >
Text File  |  1993-10-25  |  3KB  |  128 lines

  1.  
  2. #pragma segment Windows
  3.  
  4. #include <types.h>
  5. #include <quickdraw.h>
  6. #include <windows.h>
  7. #include <dialogs.h>
  8.  
  9. /* *************************** FOCUS / DEBUG Stuff    *****************     */
  10. #define gFStacklimit    20
  11. #define    aStackUnder        500
  12. #define    aStackOver        501
  13.  
  14. static GrafPtr    gFStack[gFStacklimit+1];    /* FOCUS stack, array of saveport pointers                                */
  15. static int        gFStackindex;                /* The array index to the currently focused port        */
  16.  
  17. /* *************************** BlowUp/Down Constants *****************     */
  18. #define numExpand        15
  19. #define numSteps        20
  20.  
  21. BlowUpWindow(wRect, startRect)
  22. Rect        *wRect, *startRect;
  23. {
  24. Rect        myrect, midrect, oldrect;
  25. int            i, dh, dv, dleft, dtop, dright, dbottom, sV, sH, wH, wV;
  26. GrafPtr        blowport;
  27.     GetWMgrPort(&blowport);
  28.     focus(blowport);
  29.     PenMode(patXor);
  30.     wH = wRect->right - wRect->left;
  31.     sH = startRect->right - startRect->left;
  32.     wV = wRect->bottom - wRect->top;
  33.     sV = startRect->bottom - startRect->top;
  34.     if (wH > 16)
  35.         midrect.left = wRect->left + ((wH >> 1) - 8);
  36.         else midrect.left = wRect->left;
  37.     if (wV > 16)
  38.         midrect.top = wRect->top + ((wV >> 1) - 8);
  39.         else midrect.left = wRect->left;
  40.     midrect.bottom = midrect.top + 16;
  41.     midrect.right = midrect.left + 16;
  42.     dleft = (midrect.left - startRect->left) / numSteps;
  43.     dtop = (midrect.top - startRect->top) / numSteps;
  44.     dright = (midrect.right - startRect->right) / numSteps;
  45.     dbottom = (midrect.bottom - startRect->bottom) / numSteps;
  46.     myrect = *startRect; FrameRect(&myrect); 
  47.     for(i=numSteps; i; i--) {
  48.         oldrect = myrect;
  49.         myrect.left += dleft; myrect.top += dtop;
  50.         myrect.right += dright; myrect.bottom += dbottom;
  51.         FrameRect(&myrect); FrameRect(&oldrect);
  52.         }
  53.     dh = -(((wH - 16) >> 1) / numExpand);
  54.     dv = -(((wV - 16) >> 1) / numExpand);
  55.     for(i=numExpand; i; i--)    {
  56.         oldrect = myrect;
  57.         InsetRect(&myrect, dh, dv);
  58.         FrameRect(&myrect); FrameRect(&oldrect);
  59.         }
  60.     FrameRect(&myrect);
  61.     PenNormal();
  62.     unfocus();
  63.     }
  64.  
  65. BlowDownWindow(wRect, endRect)
  66. Rect        *wRect, *endRect;
  67. {
  68. Rect        myrect, oldrect;
  69. int            i, dh, dv, dleft, dtop, dright, dbottom, sV, sH, wH, wV;
  70. GrafPtr        blowport;
  71.     GetWMgrPort(&blowport);
  72.     focus(blowport);
  73.     PenMode(patXor);
  74.     wH = wRect->right - wRect->left;
  75.     sH = endRect->right - endRect->left;
  76.     wV = wRect->bottom - wRect->top;
  77.     sV = endRect->bottom - endRect->top;
  78.     dh = ((wH - 16) >> 1) / numExpand;
  79.     dv = ((wV - 16) >> 1) / numExpand;
  80.     myrect = *wRect; FrameRect(&myrect);
  81.     for(i=numExpand; i; i--)    {
  82.         oldrect = myrect;
  83.         InsetRect(&myrect, dh, dv);
  84.         FrameRect(&myrect); FrameRect(&oldrect);
  85.         }
  86.     dleft = (endRect->left - myrect.left) / numSteps;
  87.     dtop = (endRect->top - myrect.top) / numSteps;
  88.     dright = (endRect->right - myrect.right) / numSteps;
  89.     dbottom = (endRect->bottom - myrect.bottom) / numSteps;
  90.     for(i=numSteps; i; i--) {
  91.         oldrect = myrect;
  92.         myrect.left += dleft; myrect.top += dtop;
  93.         myrect.right += dright; myrect.bottom += dbottom;
  94.         FrameRect(&myrect); FrameRect(&oldrect);
  95.         }
  96.     FrameRect(&myrect);
  97.     PenNormal();
  98.     unfocus();
  99.     }
  100.  
  101. InitFocus()
  102. {
  103.     gFStackindex = 0;
  104.     }
  105.  
  106. focus(focport)
  107. GrafPtr        focport;
  108. {
  109.     gFStackindex++;
  110. #if DEBUG > 0
  111.     if (gFStackindex > gFStacklimit)
  112.         { Alert(aStackOver, NULL); gFStackindex--; }
  113. #endif
  114.     GetPort(&gFStack[gFStackindex]);
  115.     SetPort(focport); SetOrigin(0,0);
  116.     ClipRect(&focport->portRect);
  117.     }
  118.  
  119. unfocus()
  120. {
  121.     gFStackindex--;
  122. #if DEBUG > 0
  123.     if (gFStackindex < 0)
  124.         { Alert(aStackUnder, NULL); gFStackindex++; }
  125. #endif
  126.     SetPort(gFStack[gFStackindex]);
  127.     }
  128.