//  BackWindow.m
//
//  You may freely copy, distribute, and reuse the code in this example.
//  NeXT disclaims any warranty of any kind, expressed or  implied, as to its
//  fitness for any particular use.

#import "BackWindow.h"
#import "SpaceView.h"

#import <appkit/appkit.h>

// This class supplies a borderless window as big as the screen.  It
// makes an assumption that all screens are the same size as the main
// screen, which I don't like, so we'll just have to see if it still
// works if and when we get a bunch of screens of different sizes.
// (minor Yuck) -sam

@implementation BackWindow
NXRect getBoundsForAllScreens(void)
{
  static NXRect fullFrame={{0.0, 0.0},{0.0,0.0}};
  const NXScreen *myScreens;
  int count;
  
  if (fullFrame.size.width==0)
  {  
		[NXApp getScreens:&myScreens count:&count];
		fullFrame = myScreens[0].screenBounds;
		printf("There seem to be %d screens\n", count);
		while(count--)
		{
			NXRect thisScreen = myScreens[count].screenBounds;
			printf("Screen %d's size is:{{%f,%f},{%f,%f}}\n", count,
				thisScreen.origin.x, thisScreen.origin.y,
				thisScreen.size.width, thisScreen.size.height);
			NXUnionRect(&thisScreen, &fullFrame);
		}
		printf("Computed full screen size to be:{{%f,%f},{%f,%f}}\n",
			fullFrame.origin.x, fullFrame.origin.y, fullFrame.size.width,
			fullFrame.size.height);
  }
  return fullFrame;
}

+ getFrameRect:(NXRect *)fRect forContentRect:(const NXRect *)cRect
	 style:(int)aStyle
{
  *fRect=getBoundsForAllScreens();
  return self;
}

+ getContentRect:(NXRect *)cRect forFrameRect:(const NXRect *)fRect
	   style:(int)aStyle
{
  *cRect=getBoundsForAllScreens();
  return self;
}

+ (NXCoord)minFrameWidth:(const char *)aTitle forStyle:(int)aStyle
	      buttonMask:(int)aMask;
{
  return getBoundsForAllScreens().size.width;
}


@end
