/*	XButtons.h
 *
 *		This contains the definition of my various buttons. This defines
 *	three buttons: command buttons, check boxes and radio buttons
 */

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

  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_XBUTTONS
#define PandaWave_XBUTTONS

#include <XConfig.h>
#include <XControls.h>

/************************************************************************/
/*																		*/
/*	Class forwards														*/
/*																		*/
/************************************************************************/

class XGFont;

/************************************************************************/
/*																		*/
/*	Abstractions														*/
/*																		*/
/************************************************************************/

/*$	XGButton
 *
 *		The command button base object. This knows how to handle
 *	the three standard buttons.
 */

class XGButton : public XGControl {
	public:
								XGButton(XGView *, XGArgStream &);
		virtual					~XGButton();
		
		/*
		 *	Control values
		 */
		
		virtual long			GetValue();
		virtual void			SetValue(long);
		void					PushButton();
		
		/*
		 *	Event overrides
		 */
		
		void					DoDrawView(XRect);
		void					DoActivate(bool);

		bool					DoMouseDown(XPoint,short);
		void					DoMouseMove(XPoint,short);
		void					DoMouseUp(XPoint,short);
		
		void					GetTitle(char *) const;
		void					SetTitle(const char *);
		
		void					DoSizeView();
		void					DoMoveView();
		void					DoShowHide();
		void					DoEnable();
		
#if OPT_WINOS
		void					SetFocus();
#endif

		/*
		 *	Event management
		 */
		
#if OPT_WINOS
		DECLAREDISPATCH
		long					DoWInternal(long,void *);
#endif

	protected:
		XGFont					*fFont;

#if OPT_MACOS
		ControlHandle			fControl;
#endif

#if OPT_WINOS
		HWND					fControl;
#endif

#if OPT_XWIN
		bool					fDown;
		long					fValue;
		char					fName[256];
		
		virtual void			DrawControl(bool) = 0;
#endif
};

/************************************************************************/
/*																		*/
/*	Implementation														*/
/*																		*/
/************************************************************************/

/*$	XGCommandButton
 *
 *		This is the command button
 */

class XGCommandButton : public XGButton {
	public:
								XGCommandButton(XGView *, XGArgStream &);
		virtual					~XGCommandButton();
		
		enum {
			kClassID = 'pbtn'
		};
		
		/*
		 *	Control event overrides
		 */
		
#if OPT_MACOS
		void					DoDrawView(XRect);
#endif

		void					DoShowHide(void);
		void					DoMoveView();
		void					SetDefault(bool);
	protected:
		bool					fDefault;

#if OPT_MACOS || OPT_WINOS
		void					InitControl(char *);
#endif

#if OPT_XWIN
		void					DrawControl(bool);
#endif
};

/*$	XGCheckButton
 *
 *		This is the check button
 */

class XGCheckButton : public XGButton {
	public:
								XGCheckButton(XGView *, XGArgStream &);
		virtual					~XGCheckButton();
		
		enum {
			kClassID = 'chkb'
		};
		
		/*
		 *	Control event overrides
		 */

	protected:
#if OPT_MACOS || OPT_WINOS
		void					InitControl(char *, long);
#endif

#if OPT_XWIN
		void					DrawControl(bool);
#endif
};

/*$	XGRadioButton
 *
 *		This is the radio button
 */

class XGRadioButton : public XGButton {
	public:
								XGRadioButton(XGView *, XGArgStream &);
		virtual					~XGRadioButton();
		
		enum {
			kClassID = 'radb'
		};
		
		/*
		 *	Control event overrides
		 */

	protected:
#if OPT_MACOS || OPT_WINOS
		void					InitControl(char *, long);
#endif

#if OPT_XWIN
		void					DrawControl(bool);
#endif
};

#endif // PandaWave_XBUTTONS


