/*	XToolbar.h
 *
 *		This encapsulates the functionality of a toolbar; this contains
 *	just an array of buttons which can be drawn and that dispatches menu
 *	items through the application. The buttons are basically shortcuts
 *	for menu items, though the items in the buttons don't have to
 *	be in the menu 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 PandaWave_XTOOLBAR
#define PandaWave_XTOOLBAR

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

/************************************************************************/
/*																		*/
/*	Toolbar View														*/
/*																		*/
/************************************************************************/

/*$	XGToolbarView
 *
 *		This draws a toolbar with an array of buttons which can be
 *	used to control different features
 */

class XGToolbarView : public XGView {
	public:
#if OPT_WINOS
								XGToolbarView(short resID);
#endif

								XGToolbarView(XGView *par, XGArgStream &s);
		virtual					~XGToolbarView();

		void					ChangeToolbar(short resID);
#if OPT_WINOS
		void					ChangeToolMenu(short resID);
#endif

		/*
		 *	Draw this thing
		 */
		
		void					DoDrawView(XRect);
		bool					DoMouseDown(XPoint,short);
		void					DoMouseMove(XPoint,short);
		void					DoMouseUp(XPoint,short);
		void					DoMouseLeave();
		
		DECLAREDISPATCH
		long					DoPeriodic(long,void *);

	private:
		void					SendMenuCommand(long);
		char					GetMenuStatus(long);
		XRect					CalcButton(long);
		void					DrawButton(XGDraw &,XRect,long,unsigned char);
		
		void					OutlineButton(long);
		
		short					GetToolLength(void);
		short					GetItemIcon(long);
		short					GetItemCommand(long);
		void					GetItemHelp(long,char *);
		long					GetItemOffset(long);

		short					fResID;
		XGHandle				fToolbar;
		XGHandle				fStatus;

		long					fOverTool;
		
		XRect					fHitWhere;
		long					fHitWhat;
		bool					fHitStatus;
		char					fHitMode;
		
		enum {
			kEnable = 0x08,
			kCheck = 0x04,
			kSkip = 0x02,
			kDown = 0x01
		};
};


#endif // PandaWave_XTOOLBAR
