home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 5 / Apprentice-Release5.iso / Source Code / C / Frameworks / TransSkel 3.24 / Source / SkelGetWindRect.c < prev    next >
Encoding:
C/C++ Source or Header  |  1996-01-17  |  2.0 KB  |  67 lines  |  [TEXT/CWIE]

  1. /*
  2.  * Calculate content or structure rectangle for a window. These are
  3.  * core routines because they are called by other core routines,
  4.  * e.g., SkelGetWindowDevice() and SkelGetWindTitleHeight ().
  5.  */
  6.  
  7. # include    "TransSkel.h"
  8.  
  9. # define    kTranslate    0x4000
  10.  
  11.  
  12. /*
  13.  * Get content rectangle and convert it to global coordinates
  14.  */
  15.  
  16. pascal void
  17. SkelGetWindContentRect (WindowPtr w, Rect *rp)
  18. {
  19. GrafPtr    oldPort;
  20.  
  21.     GetPort (&oldPort);
  22.     SetPort (w);
  23.     *rp = w->portRect;
  24.     LocalToGlobal (&topLeft (*rp));
  25.     LocalToGlobal (&botRight (*rp));
  26.     SetPort (oldPort);
  27. }
  28.  
  29.  
  30. /*
  31.  * Get structure rectangle.  This is already in global coordinates, but the
  32.  * tricky part is that it isn't valid if the window is invisible.
  33.  *
  34.  * If window's visible, the structure region's valid, so get the bounding box.
  35.  *
  36.  * If the window's not visible, fling it out into space, make it visible, get
  37.  * the structure region bounding box, make it invisible again and restore it to
  38.  * its normal position.  Use ShowHide() for this since  it doesn't change the
  39.  * window's hiliting or position in the stacking order.  The rectangle
  40.  * calculated this way has to be moved back, too, since it's obtained when the
  41.  * window is in flung position.
  42.  *
  43.  * I have seen similar code that also saves and restored the window's userState,
  44.  * but Inside Macintosh (Toolbox Essentials, p. 4-70) explicitly states that
  45.  * the userState isn't modified when you just move a window, so I don't see the
  46.  * point.
  47.  */
  48.  
  49. pascal void
  50. SkelGetWindStructureRect (WindowPtr w, Rect *rp)
  51. {
  52. Rect    content;
  53.  
  54.     if (((WindowPeek) w)->visible)
  55.         *rp = (**(* (WindowPeek) w).strucRgn).rgnBBox;
  56.     else
  57.     {
  58.         SkelGetWindContentRect (w, &content);                /* get upper-left coords */
  59.         MoveWindow (w, kTranslate, content.top, false);        /* fling window */
  60.         ShowHide (w, true);
  61.         *rp = (**(* (WindowPeek) w).strucRgn).rgnBBox;
  62.         ShowHide (w, false);
  63.         MoveWindow (w, content.left, content.top, false);    /* unfling window */
  64.         OffsetRect (rp, content.left - kTranslate, 0);        /* unfling struct rect */
  65.     }
  66. }
  67.