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

/*  YAAF - Yet another application framework
 *  Copyright (C) 1997, 1998 William Edward Woody
 *  
 *  This library is free software; you can redistribute it
 *  and/or modify it under the terms of the GNU Library
 *  General Public License as published by the Free Software
 *  Foundation; either version 2 of the License, or any
 *  later version.
 *  
 *  This library is distributed in the hope that it will be
 *  useful, but WITHOUT ANY WARRANTY; without even the implied
 *  warranty of MERCHANTABIILITY or FITNESS FOR A PARTICULAR
 *  PURPOSE. See the GNU Library General Public License for
 *  more details.
 *  
 *  You should have received a copy of the GNU Library General
 *  Public License along with this library; if not, write to the
 *  Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 *  Boston, MA 02111-1307, USA.
 *  
 *  To contact the author, either e-mail me at woody@pandawave.com, 
 *	or write to
 *  
 *          William Edward Woody
 *          In Phase Consulting
 *          1545 Ard Eevin Avenue
 *          Glendale, CA 91202
 *
 *	Or visit us on the web at http://www.pandawave.com
 */

#ifndef PandaWave_XBUTTONS
#define PandaWave_XBUTTONS

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

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

class XGFont;

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

/*	@C"XGButton"
 *	@D"XGControl"
 *	@H"XButtons.h"
 *	@I
 *
 *		The command button base object. This knows how to handle
 *	the three standard buttons.
 */

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

		bool					DoMouseDown(Point,short);
		void					DoMouseMove(Point,short);
		void					DoMouseUp(Point,short);
		
		void					GetTitle(char *) const;
		void					SetTitle(const char *);
		
		void					DoSizeView();
		void					DoMoveView();
		void					DoShowHide();
		void					DoEnable();
		
#if OPT_WINOS
		bool					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														*/
/*																		*/
/************************************************************************/

/*	@C"XGCommandButton"
 *	@D"XGButton"
 *	@H"XButtons.h"
 *	@I
 *
 *		This is the command button
 */

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

		void					DoMoveView();
		void					SetDefault(bool);

	protected:
		bool					fDefault;

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

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

/*	@C"XGCheckButton"
 *	@D"XGButton"
 *	@H"XButtons.h"
 *	@I
 *
 *		This is the check button
 */

class XGCheckButton : public XGButton {
	public:
								XGCheckButton(XGOwner *, 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
};

/*	@C"XGRadioButton"
 *	@D"XGButton"
 *	@H"XButtons.h"
 *	@I
 *
 *		This is the radio button
 */

class XGRadioButton : public XGButton {
	public:
								XGRadioButton(XGOwner *, 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


