home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 4 / Apprentice-Release4.iso / Languages / MacGofer 0.22d / MacGofer Sources / mac_utils.c < prev    next >
Encoding:
Text File  |  1994-03-31  |  6.0 KB  |  61 lines  |  [TEXT/MPS ]

  1. /*****************************************************************************
  2.  
  3.   mac_undo.c:  Copyright (c) Kevin Hammond 1993.   All rights reserved.
  4.   
  5.   Utility Functions.
  6.   
  7. *****************************************************************************/
  8.  
  9.  
  10. #include "mac.h"
  11.  
  12. #pragma segment Utils
  13.  
  14. extern pascal Boolean AutoScroll();
  15.  
  16. extern jmp_buf      catch_error;
  17. extern CursHandle   watchcurs, gccurs;    /* Watch and GC cursors */
  18. extern CCrsrHandle  gccursc;        /* Colour version of GC cursor */
  19. extern Boolean      CCAvailable;    /* Are colour cursors available */
  20. extern Boolean      inForeground;    /* Are we in the background? */
  21.  
  22. /* 
  23.   See if a trap is available.
  24.   Non-available traps all have the same unique address.
  25. */
  26.  
  27. #define Unimplemented 0xA89F          /* Unimplemented trap */
  28.  
  29.  
  30. Boolean TrapAvailable (trap,type)
  31. short trap, type;
  32. {
  33.   return(NGetTrapAddress(trap, type) != GetTrapAddress(Unimplemented));
  34. }
  35.  
  36. /*
  37.    NB: A Macintosh TN says TextEdit may fail if the size of the 
  38.    viewrect (?destrect?) is greater than 32767 pixels in area. 
  39.    BEWARE: I do not check this!
  40. */
  41.   
  42. /* Defined to make TE handling a little cleaner -- HSL */
  43. #define TE_RECT_INSET    4
  44. #define    TE_RECT_WIDTH    1024
  45.  
  46. void CalculateTERects(Rect *theViewR, Rect *theDestR, short theLineHeight,int fittovr)
  47. /* Calculates the view and destination rectangles for a TE */
  48. /* Assumes that the current port is set to the TE's port */
  49. {
  50.   Rect pr = qd.thePort->portRect;
  51.   short roundedViewHeight;
  52.   short te_rect_width = qd.screenBits.bounds.right > TE_RECT_WIDTH?
  53.                         qd.screenBits.bounds.right: TE_RECT_WIDTH;
  54.  
  55. //  if((pr.right - (SCROLLBARWIDTH - 1))*(pr.bottom - (SCROLLBARWIDTH - 1)) > 32767)
  56. //   AbortError("Internal","View Rectangle too large for TextEdit to handle");
  57.    
  58.   SetRect(theViewR, 0, 0, pr.right - (SCROLLBARWIDTH - 1), pr.bottom - (SCROLLBARWIDTH - 1));
  59.   InsetRect(theViewR, TE_RECT_INSET, TE_RECT_INSET);
  60.   roundedViewHeight = ((theViewR->bottom - theViewR->top) / theLineHeight) * theLineHeight;
  61.   theViewR->bottom = theViewR->top