/*	XDrawData.h
 *
 *		Common data structurs used by the View Manager code and
 *	elsewhere.
 */

/*  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_XDRAWDATA
#define PandaWave_XDRAWDATA

#include <XConfig.h>

/************************************************************************/
/*																		*/
/*	Common Structures													*/
/*																		*/
/************************************************************************/

/*	Point
 *
 *		My point structure. Declared as it is on the Macintosh.
 */

#if (OPT_WINOS == 1) || (OPT_XWIN == 1)

struct Point {
	short	v;
	short	h;
};

#endif

/*	Rect
 *
 *		My rectangle structure. Defined for X windows, and equated
 *	to the RECT structure on Windows
 */

#if OPT_WINOS == 1

typedef RECT Rect;

#endif

#if OPT_XWIN == 1

struct Rect {
	short	left;
	short	top;
	short	right;
	short	bottom;
};

#endif

/*
 *	Support Routines (Macintosh versions, to simplify my life)
 */

#if (OPT_WINOS == 1) || (OPT_XWIN == 1)
#ifdef __cplusplus

extern void SetRect(Rect *, short, short, short, short);
extern void InsetRect(Rect *, short, short);
extern bool EmptyRect(Rect *);
extern bool EqualRect(Rect *, Rect *);
extern bool SectRect(Rect *, Rect *, Rect *out);
extern void UnionRect(Rect *, Rect *, Rect *out);
extern bool PtInRect(Point,Rect *);
extern void PtToRect(Point,Point,Rect *);

#if OPT_XWIN
extern void OffsetRect(Rect *, short, short);
#endif

#endif
#endif


/************************************************************************/
/*																		*/
/*	Color model															*/
/*																		*/
/************************************************************************/

/*	Color
 *
 *		This is how I store color in a structure. This uses the
 *	Microsoft Windows color model:
 *
 *		0x00bbggaa
 *
 *		(On Microsoft Windows, this *is* a COLORREF.)
 */

#if OPT_WINOS == 1
	typedef COLORREF Color;
#else
	typedef long Color;
#endif

/*	Color macros
 *
 *		This defines the various color creation/extraction macros
 *	which are exactly those from MS Windows
 */

#if (OPT_MACOS == 1) || (OPT_XWIN == 1)

#define	RGB(r,g,b)			((((unsigned long)(unsigned char)r)) |		\
							 (((unsigned long)(unsigned char)g) << 8) |	\
							 (((unsigned long)(unsigned char)b) << 16))

#define GetRValue(c)		((unsigned char)((c & 0x000000FF)))
#define GetGValue(c)		((unsigned char)((c & 0x0000FF00) >> 8))
#define GetBValue(c)		((unsigned char)((c & 0x00FF0000) >> 16))

#endif // (OPT_MACOS == 1) || (OPT_XWIN == 1)

#define GetColorFlag(c)		((unsigned char)((c & 0xFF000000) >> 24))
#define PaletteColor(c)		(0x10000000 | (unsigned long)(unsigned short)(c))

/*
 *	Predefined colors
 */

#define	KXGColorBlack		PaletteColor(0)
#define KXGColorWhite		PaletteColor(1)
#define KXGColorBtnText		PaletteColor(2)
#define KXGColorBtnHilite	PaletteColor(3)
#define KXGColorBtnFace		PaletteColor(4)
#define KXGColorBtnShadow	PaletteColor(5)
#define KXGColorHilite		PaletteColor(6)
#define KXGColorHiliteText	PaletteColor(7)
#define KXGColorMHilite		PaletteColor(8)
#define KXGColorMHiliteText	PaletteColor(9)

#endif // PandaWave_XDRAWDATA
