/*
 *	(c) 1998-99 Sassafras Software Inc.
 *
 *	Simple bottom-of-window status bar.
 */

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

  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 SS_FOOTERBAR
#define SS_FOOTERBAR

#include <XHandle.h>
#include <XView.h>

/************************************************************************/
/*																		*/
/*	Events																*/
/*																		*/
/************************************************************************/

#define KFooterBarSelect		'stss'

/************************************************************************/
/*																		*/
/*	Structures															*/
/*																		*/
/************************************************************************/


struct XGFooterBarInitRecord {
	XGSViewInitRecord	v;
	short				trays;			/* initial number of trays */
	short				resID;			/* resource ID of label string list */
	bool				leaveroom;		/* leave room for scrollbar */
	bool				clickable;		/* trays can be selected */
	bool				removable;		/* trays can be removed (NYI) */
};

struct XGFooterBarPositionRecord {
	short left;
	short hilited;
};

/************************************************************************/
/*																		*/
/*	Status Bar View Class													*/
/*																		*/
/************************************************************************/


class XGFooterBar : public XGView {
	public:
								XGFooterBar(XGView *parent, XGArgStream &init);
								XGFooterBar(XGView *parent, XGFooterBarInitRecord &init);
		virtual					~XGFooterBar();

		enum {
			kClassID = 'stsb'
		};

		/*
		 *	Configuration routines
		 */
		void					SetTrayLabel (long, char *);
		long					GrowTrayWidth (long, long, bool shift = true);
		long					SetTrayWidth (long, long, bool shift = true);
		long					GetTrayWidth (long);
		void					GetTrayBox (long, XRect *);

		short					GetTrayHilite (long);
		void					SetTrayHilite (long, short);

		long					InsertTray (long before = -1);
		void					DeleteTray (long);

		/*
		 *	Standard behaviour routines
		 */
		void					DoDrawView (XRect);
		virtual void			DrawTray (XGDraw &, XRect &, long, short);

		bool					DoMouseDown (XPoint, short);
		void					DoMouseMove (XPoint, short);
		void					DoMouseUp (XPoint, short);

		void					RecalcAutoLocation (XGView *below = NULL, XGView *beside = NULL, XRect *r = NULL);
		virtual long			GetHeight (void);

	private:
		short					fTrays;
		short					fResID;
		bool					fLeaveRoom;
		bool					fClickable;
		XGStringList			fLabels;
		XGSDynArray<XGFooterBarPositionRecord>		fPositions;

		long					fLastState;
		long					fLastCol;
		long					fLastSlop;

		long					InTray (XPoint);
		void					IInitView (void);

};

#endif	// SS_FOOTERBAR
