home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Source Code / C / Frameworks / TransSkel 3.18 / Source / Positioning Stuff / SkelGetRefRect.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-02-19  |  1.7 KB  |  62 lines  |  [TEXT/KAHL]

  1. /*
  2.  * Get a reference rectangle for window positioning.
  3.  *
  4.  * Reference rect for position types:
  5.  *    skelPositionNone -- no reference rect
  6.  *    skelPositionOnMainDevice -- usable area on main device
  7.  *    skelPositionOnParentWindow -- content rect of frontmost visible window
  8.  *    skelPositionOnParentDevice -- usable area on screen of frontmost visible window
  9.  *
  10.  * If there's no frontmost window, positions that use it default to
  11.  * skelPositionOnMainDevice.
  12.  *
  13.  * Result for position skelPositionNone is same as for skelPositionOnMainDevice
  14.  * just so that result isn't undefined, but caller would be better off to handle
  15.  * skelPositionNone case itself.
  16.  *
  17.  * 18 Feb 94
  18.  * - Return structure rect rather than content rect of parent window when
  19.  * position type is skelPositionOnParentWindow.
  20.  */
  21.  
  22. # include    "TransSkel.h"
  23.  
  24.  
  25. pascal void
  26. SkelGetReferenceRect (Rect *r, short positionType)
  27. {
  28. WindowPtr    frontWind = FrontWindow ();
  29. GrafPtr    tmpPort;
  30. Rect    floatRect, refRect;
  31.  
  32.     /*
  33.      * Assume default positioning will be with reference to main device.
  34.      * This will also be used as the fallback for positionings that use
  35.      * FrontWindow() if FrontWindow() is nil.
  36.      */
  37.  
  38.     SkelGetMainDeviceRect (r);
  39.  
  40.     if (positionType == skelPositionNone)    /* leave window as is */
  41.         return;
  42.  
  43.     /*
  44.      * Find frontmost visible window
  45.      */
  46.     frontWind = FrontWindow ();
  47.     while (frontWind != (WindowPtr) nil && !((WindowPeek) frontWind)->visible)
  48.         frontWind = (WindowPtr) ((WindowPeek) frontWind)->nextWindow;
  49.  
  50.     switch (positionType)
  51.     {
  52.     case skelPositionOnParentWindow:
  53.         if (frontWind != (WindowPtr) nil)
  54.             SkelGetWindStructureRect (frontWind, r);
  55.         break;
  56.     case skelPositionOnParentDevice:
  57.         if (frontWind != (WindowPtr) nil)
  58.             (void) SkelGetWindowDevice (frontWind, (GDHandle *) nil, r);
  59.         break;
  60.     }
  61. }
  62.