/*	XContainer.h
 *
 *		This contains a number of XView declarations which take advantage of the
 *	min/max/suggested size parameters in order to do automatic layout of views.
 *	This permits me to quickly construct dialog boxes and the like without
 *	having to know the size of various objects inside of me
 */

/**********************************************************************

  YAAF is Copyright 1997-1999 by William Woody.

  Redistribution and use in source and binary forms, with or without 
  modification, are permitted provided that the following conditions 
  are met:

  Redistributions of source code must retain the above copyright notice, 
  this list of conditions and the following disclaimer.

  Neither the name of the copyright holder or other contributors may
  be used to promote products derived from this software without
  specific written prior permission.

  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 
  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 
  OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 
  NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 
  BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 
  ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 
  CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 
  SOFTWARE.
  
  Contact:   woody@alumni.caltech.edu
  Web page:  http://www.pandawave.com/yaaf/

**********************************************************************/

#ifndef PandaWave_XCONTAINER
#define PandaWave_XCONTAINER

/************************************************************************/
/*																		*/
/*	View Definition														*/
/*																		*/
/************************************************************************/

/*	XGContainer
 *
 *		This is the root of my container views; this contains some
 *	primitives for asserting what's going on.
 */

class XGContainer : public XGView {
	public:
								XGContainer(XGView *parent, XGArgStream &init);
		virtual					~XGContainer();
		
		/*
		 *	Drawing overrides
		 */
		
		void					DoDrawView(XRect);
		
		/*
		 *	Size overrides
		 */
		
		virtual XPoint			GetMinSize();
		virtual XPoint			GetMaxSize();
		virtual short			GetRecommendXSize();
		virtual short			GetRecommendYSize(short xsize);
		
	private:
		XPoint					fMinSize;		/* Recommended min size */
		XPoint					fMaxSize;		/* Recommended max size */
};

/************************************************************************/
/*																		*/
/*	Dialog layout support												*/
/*																		*/
/************************************************************************/

/*	XGDialogButtonsBottom
 *
 *		This automatically arranges the buttons along the bottom of the
 *	view in the way which is recommended for laying out Macintosh alerts
 *	and dialog boxes.
 *
 *		The layout is as follows:
 *
 *			Area 1:  top area
 *			Area 2:  first button
 *			Area 3:  second button
 *			...
 *			Area N:  n'th button
 *
 *		Options:
 *
 *			Optional flag indicates if the n'th button is to be set
 *		aside with it's own size parameter; if it is, it's also sized
 *		with it's own size.
 */

class XGDialogButtonsBottom : public XGContainer {
	public:
								XGDialogButtonsBottom(XGView *parent, XGArgStream &init);
		virtual					~XGDialogButtonsBottom();
		
		enum {
			kClassID = 'dbtb'
		};
		
		/*
		 *	Location overrides
		 */
		
		XRect					CalcChildPos(XGView *view);
		
		/*
		 *	Size calculations
		 */
		
		XPoint					GetMinSize();
		XPoint					GetMaxSize();
		short					GetRecommendedXSize();
		short					GetRecommendedYSize(short xsize);
};


/*	XGDialogButtonsRight
 *
 *		This automatically arranges the buttons along the bottom of the
 *	view in the way which is recommended for laying out Macintosh alerts
 *	and dialog boxes.
 *
 *		The layout is as follows:
 *
 *			Area 1:  left area
 *			Area 2:  first button
 *			Area 3:  second button
 *			...
 *			Area N:  n'th button
 *
 *		Options:
 *
 *			Optional flag indicates if the n'th button is to be set
 *		aside with it's own size parameter; if it is, it's also sized
 *		with it's own size.
 */

class XGDialogButtonsRight : public XGContainer {
	public:
								XGDialogButtonsRight(XGView *parent, XGArgStream &init);
		virtual					~XGDialogButtonsRight();
		
		enum {
			kClassID = 'dbtr'
		};
		
		/*
		 *	Location overrides
		 */
		
		XRect					CalcChildPos(XGView *view);
		
		/*
		 *	Size calculations
		 */
		
		XPoint					GetMinSize();
		XPoint					GetMaxSize();
		short					GetRecommendedXSize();
		short					GetRecommendedYSize(short xsize);
};

/*	XGTableLayout
 *
 *		Table layout object; this allows me to lay out a grid of
 *	X by Y items of fixed size. The size will be calculated based
 *	on the size of the items
 */

class XGTableLayout : public XGContainer {
	public:
								XGTableLayout(XGView *parent, XGArgStream &stream);
		virtual					~XGTableLayout();
		
		enum {
			kClassID = 'tlay'
		};
		
		/*
		 *	Location overrides
		 */
		
		XRect					CalcChildPos(XGView *view);
		
		/*
		 *	Size calculations
		 */
		
		XPoint					GetMinSize();
		XPoint					GetMaxSize();
		short					GetRecommendedXSize();
		short					GetRecommendedYSize(short xsize);
};

/*	XGVerticalLayout
 *
 *		handle vertical layout; this splits things horizontally
 */

class XGVerticalLayout : public XGContainer {
	public:
								XGVerticalLayout(XGView *parent, XGArgStream &stream);
		virtual					~XGVerticalLayout();
		
		enum {
			kClassID = 'vlay'
		};
		
		/*
		 *	Location overrides
		 */
		
		XRect					CalcChildPos(XGView *view);
		
		/*
		 *	Size calculations
		 */
		
		XPoint					GetMinSize();
		XPoint					GetMaxSize();
		short					GetRecommendedXSize();
		short					GetRecommendedYSize(short xsize);
};

/*	XGHorizontalLayout
 *
 *		handle horizontal layout; this splits things vertically
 */

class XGHorizontalLayout : public XGContainer {
	public:
								XGVerticalLayout(XGView *parent, XGArgStream &stream);
		virtual					~XGVerticalLayout();
		
		enum {
			kClassID = 'hlay'
		};
		
		/*
		 *	Location overrides
		 */
		
		XRect					CalcChildPos(XGView *view);
		
		/*
		 *	Size calculations
		 */
		
		XPoint					GetMinSize();
		XPoint					GetMaxSize();
		short					GetRecommendedXSize();
		short					GetRecommendedYSize(short xsize);
};

/*	XGBorderLayout
 *
 *		Handle laying out this thing with regions along various borders.
 *	This is similar to the Java 'java.awt.BorderLayout' class
 */

class XGBorderLayout : public XGContainer {
	public:
								XGBorderLayout(XGView *parent, XGArgStream &stream);
		virtual					~XGBorderLayout();
		
		enum {
			kClassID = 'blay'
		};
		
		/*
		 *	Location overrides
		 */
		
		XRect					CalcChildPos(XGView *view);
		
		/*
		 *	Size calculations
		 */
		
		XPoint					GetMinSize();
		XPoint					GetMaxSize();
		short					GetRecommendedXSize();
		short					GetRecommendedYSize(short xsize);
};

#endif // PandaWave_XCONTAINER
