home *** CD-ROM | disk | FTP | other *** search
/ CICA 1995 May / cica_0595_4.zip / cica_0595_4 / UTIL / GPT34SRC / EPSVIEWE.M < prev    next >
Text File  |  1993-05-11  |  3KB  |  87 lines

  1. #ifndef lint
  2. static char *RCSid = "$Id: epsviewe.m%v 3.38.2.117 1993/04/15 02:30:21 woo Exp woo $";
  3. #endif
  4.  
  5.  
  6. #import "epsviewe.h"
  7. #import <appkit/OpenPanel.h>
  8. #import <appkit/View.h>
  9.  
  10. @implementation EpsViewer
  11.  
  12. - windowCreate:(NXCoord) width Height:(NXCoord) height
  13. {
  14.     NXRect rect = {{0.0,0.0},{width,height}};
  15.     
  16.     /* create the new window, in a good place */
  17.     theNewWin = [Window
  18.         newContent:[self nextRectForWidth:width Height:height]
  19.         style:NX_TITLEDSTYLE
  20.         backing:NX_RETAINED
  21.         buttonMask:(NX_CLOSEBUTTONMASK | NX_MINIATURIZEBUTTONMASK)
  22.         defer:NO];
  23.     /* we need to receive windowDidBecomeMain: and windowDidResignMain: */
  24.     [theNewWin setDelegate:self];
  25.     /*
  26.          * create a new View, make it the contentView of our new window,
  27.      * and destroy the window's old contentView 
  28.      */
  29.         [[theNewWin setContentView:[[View alloc] init]] free];
  30.         /* display the window, and bring it forth */
  31.     [theNewWin display];
  32.     [theNewWin makeKeyAndOrderFront:self];    
  33. /*    [theNewWin orderBack:self];            */
  34.     /* show the frame */
  35.     return self;
  36. }
  37.  
  38. /***************************************************************************/
  39. /* nextRectForWidth:Height: - return the next good content rectangle       */
  40. /*  from Carl F. Sutter's wonderful ViewGif2 'Controller' method...        */
  41. /***************************************************************************/
  42. /* nextTopLeft - return the next good top left window position           */
  43. /***************************************************************************/
  44.  
  45. - (NXRect *)nextRectForWidth:(NXCoord)width Height:(NXCoord)height
  46. {
  47. #define OFFSET 10.0
  48. #define MAX_STEPS 20
  49. #define INITIAL_X 356.0
  50. #define INITIAL_Y 241.0
  51.     NXPoint         nxpTopLeft;
  52.     NXRect          nxrTemp;    /* used to find window height     */
  53.     NXRect          nxrWinHeight;    /* bounds of enclosing window     */
  54.     NXSize          nxsScreen;    /* size of screen         */
  55.     static NXRect   nxrResult;    /* the Answer!             */
  56.     static int      nCurStep = 0;
  57.  
  58.     /* find a good top-left coord */
  59.     nxpTopLeft.x = INITIAL_X + nCurStep * OFFSET;
  60.     nxpTopLeft.y = INITIAL_Y + nCurStep * OFFSET;
  61.     if (++nCurStep > MAX_STEPS)
  62.         nCurStep = 0;
  63.     /* find window height using nxrTemp */
  64.     nxrTemp.size.width = width;
  65.     nxrTemp.size.height = height;
  66.     nxrTemp.origin.x = nxrTemp.origin.y = 0;
  67.     [Window getFrameRect:&nxrWinHeight forContentRect:&nxrTemp
  68.      style:NX_TITLEDSTYLE];
  69.     [NXApp getScreenSize:&nxsScreen];
  70.     /* find the lower-left coord */
  71.     nxrResult.origin.x = nxpTopLeft.x;
  72.     nxrResult.origin.y = nxsScreen.height - nxrWinHeight.size.height - nxpTopLeft.y;
  73.     nxrResult.size.width = width;
  74.     nxrResult.size.height = height;
  75.     return (&nxrResult);
  76. }
  77.  
  78.  
  79. // Keep compiler quiet
  80. - (const char *) rcsid
  81. {
  82.     return RCSid;
  83. }
  84.  
  85. @end
  86.  
  87.