#ifndef	_MESSAGES_H
#define	_MESSAGES_H

#ifndef	_SUPPORT_DEFS_H
#include <SupportDefs.h>
#endif

#ifdef __cplusplus
extern	"C" {
#endif

#define MAX_MSG_SIZE 1024

/*--------------------------------------------------------------*/

/* This is a structure the server uses to send certain kinds of messages */
typedef	struct message
{
	int32	what;
	int32	parm1;
	int32	parm2;
	int32	parm3;
	int32	parm4;
	int32	parm5;
	int32	parm6;
	int32	parm7;
	int32	parm8;
	int32	parm9;
	int32	parm10;
	int32	parm11;
	int32	parm12;
	int32	parm13;
	bigtime_t	the_time;
} message;

/*--------------------------------------------------------------*/

/*	It is not well defined over what ports these messages get sent. */
enum GeneralMessages {
	HELLO				=	1000, /* send to picasso to get the server port id */
	NEW_TERM			=	1001, /* server port msg		 */
	COUT				=	1002, /* terminal port message	*/ 
	NEW_MW				=	1003, /* server port msg		 */
	LINE				=	1004,
	TITLE				=	1005,
	DEATH_CERTIFICATE	=	1006,
	ANY_SCREENS			=	1007,
	INIT_SESSION		=	0x1009,
	GR_GET_VERSION		=	0x100A,
	GR_CLOSEAPP			=	0x100b,
	UPDATE				=	0x100c,
	SET_ORIGIN			=	0x100d,
	CLOSE				=	0x100e,
	ROUTE_EVENTS		=	0x100f
};

/*--------------------------------------------------------------*/

/*	Messages that go through the server port.  These deal with
	non-window specific resources/operations and globally scoped
	server-side objects, like pictures and bitmaps. */

enum ServerMessages {
	GR_CREATE_WINDOW = 0xec0,
	GR_NEW_BITMAP,
	GR_SET_BITS,
	GR_DELETE_BITMAP,
	GR_NEW_APP,
	GR_CREATE_OFF_WINDOW,
	GR_SET_RECT_TRACK,
	GR_FIND_WINDOW,
	GR_SET_BITS_24,
	GR_SET_BITS_24_TST,
	GR_SET_DRAG,
	GR_GET_SCS,
	GR_SET_DRAG_BM,

	GR_SHOW_CURSOR,
	GR_HIDE_CURSOR,
	GR_OBSCURE_CURSOR,

	GR_ZOOM,

	GR_IMPORT_PICTURE,
	GR_CLONE_PICTURE,
	GR_DELETE_PICTURE,
	GR_GET_PICTURE_SIZE,
	GR_GET_PICTURE_DATA,

	GR_SET_TEAM_ID,
	GR_SET_FONT_SET,
	GR_GET_FONT_SET,
	GR_COUNT_SETS,

	GR_IS_CURSOR_HIDDEN,
	GR_SET_CURSOR2,
	GR_TRUNCATE_STRINGS,

	GR_LOCK_SCREEN,
	GR_UNLOCK_SCREEN,

	GR_GET_DESKTOP_COLOR,
	GR_SET_DESKTOP_COLOR,

	GR_ACTIVATE_TEAM,
	GR_COUNT_WS,
	GR_SET_WS_COUNT,
	GR_CURRENT_WS,
	GR_SELECT_WS,

	GR_SET_SCREEN_RES,
	GR_SET_SCREEN_RATE,
	GR_SET_SCREEN_POS,

	GR_PROPOSE_DISPLAY_MODE,
	GR_GET_DISPLAY_MODE_LIST,
	GR_SET_DISPLAY_MODE,
	GR_GET_DISPLAY_MODE,
	GR_GET_FRAME_BUFFER_CONFIG,
	GR_GET_ACCELERANT_DEVICE_INFO,
	GR_GET_PIXEL_CLOCK_LIMITS,
	GR_GET_TIMING_CONSTRAINTS,
	GR_GET_DPMS_CAPABILITIES,
	GR_GET_DPMS_STATE,
	GR_SET_DPMS_STATE,

	GR_GET_ACCELERANT_IMAGE_PATH,
	GR_GET_ACCELERANT_CLONE_INFO,
	GR_ACCELERANT_PERFORM_HACK,
	GR_GET_DISPLAY_DEVICE_PATH,

	GR_GET_SCROLL_BAR_INFO,
	GR_SET_SCROLL_BAR_INFO,

	GR_CTRL_GRAPHICS_CARD,
	GR_GET_SCREEN_BITMAP,
	GR_LOCK_DIRECT_SCREEN,
	GR_GET_CLONE_INFO,
	GR_SET_STANDARD_SPACE,	
	GR_GET_DRIVER_INFO,
	GR_GET_SYNC_INFO,
	GR_GET_RETRACE_SEMAPHORE,
		
	GR_OPEN_INPUT_CHANNEL,
	GR_CLOSE_INPUT_CHANNEL,
	GR_SET_INPUT_CHANNEL,
	GR_GET_INPUT_CHANNEL,
	GR_SET_DRAG_PIXEL,
	
	GR_GET_FAMILY_LIST,
	GR_GET_STYLE_LIST,
	GR_GET_TUNED_FONT_LIST,
	GR_FONT_CHANGE_TIME,
	GR_STRING_WIDTH,
	GR_GET_ESCAPEMENTS,
	GR_GET_EDGES,
	GR_GET_HEIGHT,
	GR_GET_FONT_IDS,
	GR_GET_FONT_NAMES,
	
	GR_SET_CURSOR,
	
	GR_GET_STANDARD_FONTS,
	GR_SET_STANDARD_FONTS,
	GR_GET_FONT_CACHE_SETTINGS,
	GR_SET_FONT_CACHE_SETTINGS,
	GR_REMOVE_FONT_DIR,
	GR_CHANGE_FONT_DIR_STATUS,
	GR_CHANGE_FONT_FILE_STATUS,
	GR_GET_FONT_DIR_LIST,
	GR_GET_FONT_FILE_LIST,
	GR_SAVE_FONT_CACHE,
	GR_FONT_SET_CONTROL,
	GR_SAVE_TUNED_FONT_SET,
	
	GR_COUNT_WINDOWS,
	GR_GET_WINDOW_INFO,
	GR_DO_WINDOW_ACTION,

	// GR_SET_KEY_MODE obsolete, use GR_SET_FOCUS_FOLLOWS_MOUSE

	GR_GET_TOKEN_LIST,
	GR_DO_MINI_TEAM,
	GR_DO_ACTIVATE_TEAM,
	
	GR_GET_UI_SETTINGS,
	GR_SET_UI_SETTINGS,
	GR_SET_MOUSE_POSITION,
	GR_SELECT_WS_ASYNC,
	GR_SET_COLOR_MAP,

	GR_GET_IDLE_TIME,
	GR_GET_SCREEN_INFO,
	GR_SET_FOCUS_FOLLOWS_MOUSE,	// HL 1/15/98
	GR_GET_FOCUS_FOLLOWS_MOUSE,	// HL 1/15/98
	GR_DIRECT_WINDOW_INFO,		// PRR 1/27/98

	GR_GET_SERVER_HEAP_AREA,	// GEH 5/17/98
	GR_GET_FONT_GLYPHS,			// PRR 8/6/98
	GR_GET_FONT_FLAGS_INFO,		// PRR 8/19/98
	GR_GET_FONT_BBOX,			// PRR 9/3/98
	GR_GET_FONT_BLOCKS,			// PRR 9/3/98
	GR_GET_GLYPHS_BBOX,			// PRR 9/3/98
	GR_GET_STRINGS_BBOX,		// PRR 9/3/98
	GR_GET_HAS_GLYPHS,			// PRR 9/3/98

	GR_SET_MINI_ICON,			// GEH 9/??/98
	GR_GET_UNBLOCKED_SCREEN,	// PRR 9/14/98
	GR_OLD_SET_WINDOW_DECOR,	// GEH 9/??/98 -- no longer used
	GR_GET_OVERLAY_RESTRICTIONS,// GEH 5/19/99
	GR_NEW_CURSOR, 				// GEH 8/10/99
	GR_DELETE_CURSOR, 			// GEH 8/10/99

	GR_FREEZEDRY_BITMAP, 		// GEH 11/8/00
	GR_UPLOAD_BITMAP, 			// GEH 11/8/00
	
	GR_SET_WINDOW_DECOR,		// DKH 11/30/00
	GR_GET_WINDOW_DECOR,		// DKH 11/30/00
	
	GR_SET_INT32_SETTING,		// DKH 12/14/00
	GR_GET_INT32_SETTING,		// DKH 12/14/00

	GR_NEW_LBX,					// MAG 12/6/00
	GR_DELETE_LBX,				// MAG 12/6/00
	GR_SELECT_LBX_BITMAP,		// MAG 12/6/00
};

/*--------------------------------------------------------------*/

/*	Codes for GR_SET_INT32_SETTING and GR_GET_INT32_SETTING */

enum {
	AS_ANTIALIASING_SETTING = 0,	// DKH 12/14/00
	AS_ALIASING_MIN_LIMIT_SETTING,	// DKH 12/14/00
	AS_ALIASING_MAX_LIMIT_SETTING,	// DKH 12/14/00
	AS_HINTING_MAX_LIMIT_SETTING,	// DKH 12/14/00
};

/*--------------------------------------------------------------*/

/*	Messages that go through the window port.  These deal with
	window specific resources/operations. */

enum WindowMessages {
/* Client-side view manipulation/queries */
	GR_ADD_VIEW = 0x500,
	GR_MOVE_VIEW,
	GR_MOVETO_VIEW,
	GR_SIZE_VIEW,
	GR_SIZETO_VIEW,
	GR_REMOVE_VIEW,
	GR_FIND_VIEW,
	GR_GET_VIEW_BOUND,
	GR_VIEW_FLAGS,
	GR_VIEW_SET_EVENT_MASK,
	GR_VIEW_AUGMENT_EVENT_MASK,
	GR_SCREWED_UP_MOVETO_VIEW,
	GR_SET_VIEW_CURSOR,
	GR_SET_VIEW_DOUBLE_BUFFER,

/* Window manipulation/queries */
	GR_MOVE_WINDOW = 0x580,
	GR_MOVETO_WINDOW,
	GR_SIZE_WINDOW,
	GR_SIZETO_WINDOW,
	GR_SELECT_WINDOW,
	GR_CLOSE_WINDOW,
	GR_WGET_TITLE,
	GR_WSET_TITLE,
	GR_WGET_BOX,
	GR_WIS_FRONT,
	GR_SEND_TO_BACK,
	GR_WGET_BOUND,
	GR_HIDE,
	GR_SHOW,
	GR_WINDOW_LIMITS,
	GR_IS_ACTIVE,
	GR_MINIMIZE,
	GR_MAXIMIZE,
	GR_SHOW_SYNC,
	GR_SET_WINDOW_FLAGS,
	GR_SEND_BEHIND,
	GR_ADD_SUBWINDOW,
	GR_REMOVE_SUBWINDOW,
	GR_SET_WINDOW_ALIGNMENT,
	GR_GET_WINDOW_ALIGNMENT,
	GR_GET_BASE_POINTER,
	GR_PICK_VIEW,
	GR_SET_WINDOW_PICTURE,
	GR_WGET_DECOR_STATE,
	GR_WSET_DECOR_STATE,
	GR_ADD_WINDOW_CHILD,
	GR_REMOVE_WINDOW_CHILD,
	
/* Drawing commands... anything that potentially could
   write pixels should be in here, please. */
	GR_MOVETO = 0x600,
	GR_MOVEBY,
	GR_LINE,
	GR_LINETO,

	GR_RECTFRAME,
	GR_RECTFILL,

	GR_ARC_INSCRIBE_STROKE,
	GR_ARC_INSCRIBE_FILL,
	GR_ARC_STROKE,
	GR_ARC_FILL,

	GR_ROUND_RECT_FRAME,
	GR_ROUND_RECT_FILL,

	GR_FRAME_REGION,
	GR_FILL_REGION,

	GR_POLYFRAME,
	GR_POLYFILL,

	GR_DRAW_BEZIER,
	GR_FILL_BEZIER,

	GR_ELLIPSE_INSCRIBE_STROKE,
	GR_ELLIPSE_INSCRIBE_FILL,
	GR_ELLIPSE_STROKE,
	GR_ELLIPSE_FILL,

	GR_DRAW_BITMAP,
	GR_SCALE_BITMAP,
	GR_SCALE_BITMAP1,

	GR_DRAW_BITMAP_A,
	GR_SCALE_BITMAP_A,
	GR_SCALE_BITMAP1_A,

	GR_DRAW_STRING,

	GR_MOVE_BITS,
	GR_RECT_INVERT,

	GR_START_VARRAY,
	GR_PLAY_PICTURE,

	GR_STROKE_SHAPE,
	GR_FILL_SHAPE,

/* Drawing context setting */
	GR_SET_DRAW_MODE = 0x700,
	GR_VIEW_SET_ORIGIN,
	GR_SET_PEN_SIZE,
	GR_SET_VIEW_COLOR,
	GR_SET_LINE_MODE,
	GR_SET_FONT_CONTEXT,
	GR_FORE_COLOR,
	GR_BACK_COLOR,
	GR_NO_CLIP,
	GR_SET_CLIP,
	GR_SET_SCALE,
	GR_SET_ORIGIN,
	GR_PUSH_STATE,
	GR_POP_STATE,
	GR_SET_PATTERN,
	GR_SET_VIEW_BITMAP,
	GR_SET_FONT_FLAGS,
	GR_CLIP_TO_SHAPE,
	GR_SET_BLENDING_MODE,
	GR_SET_TRANSFORM,

/* Drawing context querying */
	GR_GET_PEN_SIZE = 0x780,
	GR_GET_FORE_COLOR,
	GR_GET_BACK_COLOR,
	GR_GET_PEN_LOC,
	GR_GET_LOCATION,
	GR_GET_DRAW_MODE,
	GR_GET_CLIP,
	GR_GET_CAP_MODE,
	GR_GET_JOIN_MODE,
	GR_GET_MITER_LIMIT,
	GR_GET_ORIGIN,
	GR_GET_BLENDING_MODE,
	GR_GET_FONT_CONTEXT,
	GR_GET_SCREWED_UP_LOCATION,
	GR_GET_TRANSFORM,

/* Manipulation of server-side views */
	GR_ADD_SCROLLBAR = 0x800,
	GR_SCROLLBAR_SET_VALUE,
	GR_SCROLLBAR_SET_RANGE,
	GR_SCROLLBAR_SET_STEPS,
	GR_SCROLLBAR_SET_PROPORTION,

/* Translation/input query functions */
	GR_PT_TO_SCREEN = 0x830,
	GR_PT_FROM_SCREEN,
	GR_RECT_TO_SCREEN,
	GR_RECT_FROM_SCREEN,
	GR_GET_VIEW_MOUSE,

/* Controlling/querying the update mechanism */
	GR_INVAL = 0x840,
	GR_UPDATE_OFF,
	GR_UPDATE_ON,
	GR_NEED_UPDATE,
	GR_GET_UPDATE_STATE,
	GR_SYNC,
	GR_OPEN_VIEW_TRANSACTION,
	GR_CLOSE_VIEW_TRANSACTION,
	GR_INVAL_REGION,

/* Picture construction and use */
	GR_START_PICTURE = 0x850,
	GR_RESTART_PICTURE,
	GR_END_PICTURE,

/* Workspace fiddling */
	GR_WORKSPACE = 0x860,
	GR_SET_WS,

/* Er... misc? */
	GR_DATA = 0x870,
	GET_DROP,
	
/* Direct window messages */
	GR_INIT_DIRECTWINDOW = 0x880,
	GR_SET_FULLSCREEN,
	
/* New messages, to be sorted later */
	GR_EXPERIMENTAL_MESSAGES = 0x4000,
	GR_START_DISK_PICTURE,	/* BGS 5/27/98 */
	GR_LOOPER_THREAD,		/* PRR 5/27/98 */
	GR_PLAY_DISK_PICTURE,	/* BGS 5/28/98 */
	
/* Private update synchronization messages */
	E_START_DRAW_WIND = 0x8000,
	E_END_DRAW_WIND,
	E_DRAW_VIEW,
	E_END_DRAW_VIEW,
	E_DRAW_VIEWS,
	E_START_DRAW_VIEW
};

#define	GR_END_VARRAY			0x65728218

/*--------------------------------------------------------------*/

#ifdef __cplusplus
}
#endif

#endif
