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

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

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

#include <XConfig.h>
#include <XTypes.h>

/************************************************************************/
/*																		*/
/*	Rectangle Support													*/
/*																		*/
/************************************************************************/

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

extern void SetRect(XRect *, long, long, long, long);
extern void InsetRect(XRect *, long, long);
extern bool EmptyRect(XRect *);
extern bool EqualRect(XRect *, XRect *);
extern bool SectRect(XRect *, XRect *, XRect *out);
extern void UnionRect(XRect *, XRect *, XRect *out);
extern bool PtInRect(XPoint,XRect *);
extern void Pt2Rect(XPoint,XPoint,XRect *);

#if !OPT_WINOS
extern void OffsetRect(XRect *, long, long);
#endif

#endif


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

/**@name Support--Color Macro Support
 *
 *		These macros define the various colors and processing that are
 *	supported by YAAF. This is exactly the same as the color model used
 *	by Microsoft Windows.
 */

//@{

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

/*$	RGB
 *
 *		This creates a Color object from the red, green and blue
 *	components. The values for red, green and blue range from 0 (for
 *	black) to 255 (for fully on).
 */

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

/*$	GetRValue
 *
 *		Extracts the red value from a Color record.
 */

#define GetRValue(c)		((unsigned char)((c & 0x000000FF)))

/*$	GetRValue
 *
 *		Extracts the red value from a Color record.
 */

#define GetGValue(c)		((unsigned char)((c & 0x0000FF00) >> 8))

/*$	GetRValue
 *
 *		Extracts the red value from a Color record.
 */

#define GetBValue(c)		((unsigned char)((c & 0x00FF0000) >> 16))

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

/*$	GetColorFlag
 *
 *		Returns the top 8 bits of a Color object. These top 8 bits
 *	are set to 0 if this is an RGB value, or 1 if this is a predefined
 *	palette.
 */

#define GetColorFlag(c)		((unsigned char)((c & 0xFF000000) >> 24))

/*$	PaletteColor
 *
 *		Given a palette index, this creates a Color object which has
 *	the high 8 bits set to 1, and puts the palette color in the lower
 *	24 bits.
 */

#define PaletteColor(c)		(0x10000000 | (unsigned long)(unsigned short)(c))

/*
 *	Predefined colors
 */

/// Predefined black color
#define	KXGColorBlack		PaletteColor(0)
/// Predefined white color
#define KXGColorWhite		PaletteColor(1)
/// Predefined button text color. This is the color of the button label
#define KXGColorBtnText		PaletteColor(2)
/// Predefined button hilite color. This is the color of the light border
#define KXGColorBtnHilite	PaletteColor(3)
/// PRedefined button face color. This is the color of the flat face of a button
#define KXGColorBtnFace		PaletteColor(4)
/// Predefined button shadow. This is the dark color of the shadow of a button
#define KXGColorBtnShadow	PaletteColor(5)
/// Predefined hilite color. This is the color of the text selection hilite
#define KXGColorHilite		PaletteColor(6)
/// Predefined hilite text color. This is the color of selected text in a hilite
#define KXGColorHiliteText	PaletteColor(7)
/// Predefined menu hilite color. This is the color of a hilited menu item
#define KXGColorMHilite		PaletteColor(8)
/// PRedefined menu hilite text. This is the color of the text in a hilited menu item
#define KXGColorMHiliteText	PaletteColor(9)
/// Predefine tooltip box color. This is the color of a popup tool tip window
#define KXGColorToolTip		PaletteColor(10)
/// Predefined tooltip text color. This is the color of the text in a popup tip window
#define KXGColorToolTipText	PaletteColor(11)

//@}

#endif // PandaWave_XDRAWDATA
