/* This symbol must always be defined when compiling for Motif.  This is to
 * ensure that the correct set of Xt header files are used (ie those in
 * /usr/include/Xm rather than the X11 Release 4 ones in /usr/include/X11).
 * All the R4 Xt headers check for this symbol; if it is defined, they give
 * an error.
 */

#ifndef _MOTIF_XT
#define _MOTIF_XT
#endif

#ifdef REV_INFO
#ifndef lint
static char SCCSID[] = "OSF/Motif: @(#)XmP.h	1.2 89/09/13";
#endif /* lint */
#endif /* REV_INFO */
/******************************************************************************
*******************************************************************************
*
*  (c) Copyright 1989, OPEN SOFTWARE FOUNDATION, INC.
*  (c) Copyright 1987, 1988, 1989 HEWLETT-PACKARD COMPANY
*  ALL RIGHTS RESERVED
*  
*  	THIS SOFTWARE IS FURNISHED UNDER A LICENSE AND MAY BE USED
*  AND COPIED ONLY IN ACCORDANCE WITH THE TERMS OF SUCH LICENSE AND
*  WITH THE INCLUSION OF THE ABOVE COPYRIGHT NOTICE.  THIS SOFTWARE OR
*  ANY OTHER COPIES THEREOF MAY NOT BE PROVIDED OR OTHERWISE MADE
*  AVAILABLE TO ANY OTHER PERSON.  NO TITLE TO AND OWNERSHIP OF THE
*  SOFTWARE IS HEREBY TRANSFERRED.
*  
*  	THE INFORMATION IN THIS SOFTWARE IS SUBJECT TO CHANGE WITHOUT
*  NOTICE AND SHOULD NOT BE CONSTRUED AS A COMMITMENT BY OPEN SOFTWARE
*  FOUNDATION, INC. OR ITS THIRD PARTY SUPPLIERS  
*  
*  	OPEN SOFTWARE FOUNDATION, INC. AND ITS THIRD PARTY SUPPLIERS,
*  ASSUME NO RESPONSIBILITY FOR THE USE OR INABILITY TO USE ANY OF ITS
*  SOFTWARE .   OSF SOFTWARE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
*  KIND, AND OSF EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES, INCLUDING
*  BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
*  FITNESS FOR A PARTICULAR PURPOSE.
*  
*  Notice:  Notwithstanding any other lease or license that may pertain to,
*  or accompany the delivery of, this computer software, the rights of the
*  Government regarding its use, reproduction and disclosure are as set
*  forth in Section 52.227-19 of the FARS Computer Software-Restricted
*  Rights clause.
*  
*  (c) Copyright 1989, Open Software Foundation, Inc.  Unpublished - all
*  rights reserved under the Copyright laws of the United States.
*  
*  RESTRICTED RIGHTS NOTICE:  Use, duplication, or disclosure by the
*  Government is subject to the restrictions as set forth in subparagraph
*  (c)(1)(ii) of the Rights in Technical Data and Computer Software clause
*  at DFARS 52.227-7013.
*  
*  Open Software Foundation, Inc.
*  11 Cambridge Center
*  Cambridge, MA   02142
*  (617)621-8700
*  
*  RESTRICTED RIGHTS LEGEND:  This computer software is submitted with
*  "restricted rights."  Use, duplication or disclosure is subject to the
*  restrictions as set forth in NASA FAR SUP 18-52.227-79 (April 1985)
*  "Commercial Computer Software- Restricted Rights (April 1985)."  Open
*  Software Foundation, Inc., 11 Cambridge Center, Cambridge, MA  02142.  If
*  the contract contains the Clause at 18-52.227-74 "Rights in Data General"
*  then the "Alternate III" clause applies.
*  
*  (c) Copyright 1989, Open Software Foundation, Inc.
*  ALL RIGHTS RESERVED 
*  
*  
* Open Software Foundation is a trademark of The Open Software Foundation, Inc.
* OSF is a trademark of Open Software Foundation, Inc.
* OSF/Motif is a trademark of Open Software Foundation, Inc.
* Motif is a trademark of Open Software Foundation, Inc.
* DEC is a registered trademark of Digital Equipment Corporation
* DIGITAL is a registered trademark of Digital Equipment Corporation
* X Window System is a trademark of the Massachusetts Institute of Technology
*
*******************************************************************************
******************************************************************************/
/************************************<+>*************************************
 ****************************************************************************
 **
 **   File:        XmP.h
 **
 **   Description: This include file contains the class and instance record
 **                definitions for all meta classes.  It also contains externs
 **                for internally shared functions and defines for internally 
 **                shared values.
 **
 ****************************************************************************
 ************************************<+>*************************************/

#ifndef _XmP_h
#define _XmP_h


#ifndef _Xm_h
#include "Xm.h"
#endif
#ifndef _XtintrinsicP_h
#include "IntrinsicP.h"
#endif



/***************************************************************************
 *  Macros replacing toolkit macros so that gadgets are handled properly. 
 ***************************************************************************/

#ifdef XtName
#undef XtName
#endif
#define XtName(widget) XrmQuarkToString (((Object)(widget))->object.xrm_name)

#ifdef XtDisplay
#undef XtDisplay
#endif
#define XtDisplay(widget)						\
   (XtIsWindowObject(widget)         ?					\
      ((Widget)(widget))->core.screen->display :			\
      ((Object)(widget))->object.parent->core.screen->display)

#ifdef XtScreen
#undef XtScreen
#endif
#define XtScreen(widget) (XtIsWindowObject(widget)  ?		\
			 ((Widget)(widget))->core.screen   :	\
			 ((Object)(widget))->object.parent->core.screen)

#ifdef XtWindow
#undef XtWindow
#endif
#define XtWindow(widget) (XtIsWindowObject(widget)  ?			\
			 ((Widget)(widget))->core.window   :		\
			 ((Object)(widget))->object.parent->core.window)

#ifdef XtClass
#undef XtClass
#endif
#define XtClass(widget)	(((Object)(widget))->object.widget_class)

#ifdef XtSuperclass
#undef XtSuperclass
#endif
#define XtSuperclass(widget) (XtClass(widget)->core_class.superclass)


#ifdef XtIsRealized
#undef XtIsRealized
#endif
#define XtIsRealized(widget) 					\
   (XtIsWindowObject(widget)  ?					\
      ((Widget)(widget))->core.window != NULL  :		\
      ((Object)(widget))->object.parent->core.window != NULL)

#ifdef XtIsManaged
#undef XtIsManaged
#endif
#define XtIsManaged(widget) (((RectObj)(widget))->rectangle.managed)


#ifdef XtIsSensitive
#undef XtIsSensitive
#endif
#define XtIsSensitive(widget) 					\
   (((RectObj)(widget))->rectangle.sensitive && 		\
    ((RectObj)(widget))->rectangle.ancestor_sensitive)

#ifdef XtParent
#undef XtParent
#endif
#define XtParent(widget) (((Object)(widget))->object.parent)


/************************************************************************
 *
 *  Extern for XmWarning
 *
 ************************************************************************/

extern void _XmWarning();


/***********************************************************************
 *
 * Resolution independence functions
 *
 ***********************************************************************/

extern int _XmToHorizontalPixels();
extern int _XmToVerticalPixels();
extern void _XmFromHorizontalPixels();
extern void _XmFromVerticalPixels();


/***********************************************************************
 *
 * Miscellaneous Private Defines
 *
 ***********************************************************************/

#define XmStrlen(s)      ((s) ? strlen(s) : 0)

#define XmPRIMITIVE	0
#define XmMANAGER	1


/* Defines used by geometry manager utilities */

#define XmGET_ACTUAL_SIZE    1
#define XmGET_PREFERRED_SIZE 2


/* General purpose macros */

#ifndef MAX
#define MAX(x,y)	((x) > (y) ? (x) : (y))
#endif

#define XtX(w)		 ((w)->core.x)
#define XtY(w)		 ((w)->core.y)
#define XtWidth(w)	 ((w)->core.width)
#define XtHeight(w)	 ((w)->core.height)
#define XtBorderWidth(w) ((w)->core.border_width)
#define XtBackground(w)	 ((w)->core.background_pixel)
#define XtSensitive(w)	 ((w)->core.sensitive && (w)->core.ancestor_sensitive) 

#define RX(r)		    (((RectObj) r)->rectangle.x)
#define RY(r)		    (((RectObj) r)->rectangle.y)
#define RWidth(r)	    (((RectObj) r)->rectangle.width)
#define RHeight(r)	    (((RectObj) r)->rectangle.height)
#define RBorder(r)	    (((RectObj) r)->rectangle.border_width)

#define GMode(g)	    ((g)->request_mode)
#define IsX(g)		    (GMode (g) & CWX)
#define IsY(g)		    (GMode (g) & CWY)
#define IsWidth(g)	    (GMode (g) & CWWidth)
#define IsHeight(g)	    (GMode (g) & CWHeight)
#define IsBorder(g)	    (GMode (g) & CWBorderWidth)
#define IsWidthHeight(g)    ((GMode (g) & CWWidth) || (GMode (g) & CWHeight))

#ifndef XtParent
#define XtParent(w)	 ((w)->core.parent)
#endif

#define XtCoreProc(w,proc) ((w)->core.widget_class->core_class.proc)


/************************************************************************
 *
 *  Resource definition function and structure used by Primitive, Gadget
 *  and Manager to define there get values hook processing lists
 *
 ************************************************************************/

typedef void (*XmGetValuesProc)();
/* Widget widget         */
/* int resource_quark    */
/* caddr_t value         */
/* caddr_t return_ value */

typedef struct _XmGetValueResource
{
   String   resource_name;
   Cardinal resource_size;
   Cardinal resource_offset;
   XmGetValuesProc convert_proc;
} XmGetValueResource;



/************************************************************************
 *
 *  Primitive class and instance definitions.  Primitive #defines
 *  and internally used exported functions.
 *
 ************************************************************************/

typedef struct _XmPrimitiveClassPart
{
   XtWidgetProc         border_highlight;
   XtWidgetProc         border_unhighlight;
   XtTranslations       translations;
   XtActionProc         arm_and_activate;
   XmGetValueResource * get_resources;   
   int                  num_get_resources;   
   caddr_t              extension;
} XmPrimitiveClassPart;

typedef struct _XmPrimitiveClassRec
{
    CoreClassPart        core_class;
    XmPrimitiveClassPart primitive_class;
} XmPrimitiveClassRec;

extern XmPrimitiveClassRec xmPrimitiveClassRec;


/*  The Primitive instance record  */

typedef struct _XmPrimitivePart
{
   Pixel   foreground;

   short   shadow_thickness;
   Pixel   top_shadow_color;
   Pixmap  top_shadow_pixmap;
   Pixel   bottom_shadow_color;
   Pixmap  bottom_shadow_pixmap;

   short   highlight_thickness;
   Pixel   highlight_color;
   Pixmap  highlight_pixmap;

   XtCallbackList help_callback;
   caddr_t        user_data;

   Boolean traversal_on;
   Boolean highlight_on_enter;
   Boolean have_traversal;

   unsigned char unit_type;

   Boolean highlight_drawn;
   Boolean highlighted;

   GC      highlight_GC;
   GC      top_shadow_GC;
   GC      bottom_shadow_GC;
} XmPrimitivePart;

typedef struct _XmPrimitiveRec
{
   CorePart        core;
   XmPrimitivePart primitive;
} XmPrimitiveRec;

/* Access Macros */
#define Prim_ShadowThickness(w) (((XmPrimitiveWidget)(w))->primitive.shadow_thickness)
#define Prim_HaveTraversal(w) (((XmPrimitiveWidget)(w))->primitive.have_traversal)


/*  Functions exported by gadget  */

extern void _XmEnterGadget();
extern void _XmLeaveGadget();


/*  Functions exported by primitive  */

extern void _XmHighlightBorder();
extern void _XmUnhighlightBorder();

extern void _XmPrimitiveEnter();
extern void _XmPrimitiveLeave();
extern void _XmPrimitiveFocusIn();
extern void _XmPrimitiveFocusOut();
extern void _XmPrimitiveFocusInInternal();
extern void _XmPrimitiveVisibility();
extern void _XmPrimitiveUnmap();

extern void _XmTraverseNext();
extern void _XmTraversePrev();
extern void _XmTraverseHome();
extern void _XmTraverseNextTabGroup();
extern void _XmTraversePrevTabGroup();


/*  Externs and defines for traversal handling functions incorporated  */
/*  into all primitive widgets.                                        */

extern void     _XmMgrTraversal();
extern void     _XmSetFocusPath();
extern void     _XmProcessTraversal();
extern void     _XmSetInputFocus();
extern Boolean  _XmFocusIsHere();
extern Widget   _XmGetTabGroup();
extern Widget   _XmFindTabGroup();
extern Boolean  _XmGrabTheFocus();
extern void     _XmFocusModelChanged();
extern unsigned char _XmGetFocusPolicy();

extern void    _XmSendFakeLeaveNotify();


/*  Structure used for terminating keyboard actions  */

typedef struct 
{
   Boolean * keyIsPressed;
   void (*handler)();
} _XmTerminateData;


/*  Traversal direction defines  */

#define XmTRAVERSE_CURRENT            0
#define XmTRAVERSE_NEXT               1
#define XmTRAVERSE_PREV               2
#define XmTRAVERSE_HOME               3
#define XmTRAVERSE_NEXT_TAB_GROUP     4
#define XmTRAVERSE_PREV_TAB_GROUP     5
#define XmTRAVERSE_UP                 6
#define XmTRAVERSE_DOWN               7
#define XmTRAVERSE_LEFT               8
#define XmTRAVERSE_RIGHT              9




/************************************************************************
 *
 *  Gadget class and instance definitions.  Gadget #defines
 *  and internally used exported functions.
 *
 ************************************************************************/

/*  Gadget class structure  */

typedef Boolean (*XmVisualChangeProc)();  /* returns TRUE if redisplay */
/* XmGadget child           */
/* XmManagerWidget current  */
/* XmManagerWidget new      */

typedef struct _XmGadgetClassPart
{
   XtWidgetProc         border_highlight;
   XtWidgetProc         border_unhighlight;
   XtProc               arm_and_activate;
   XtWidgetProc         input_dispatch;
   XmVisualChangeProc   visual_change;
   XmGetValueResource * get_resources;   
   int                  num_get_resources;   
   caddr_t            extension;
} XmGadgetClassPart;


/*  Full class record declaration for Gadget class  */

typedef struct _XmGadgetClassRec
{
   RectObjClassPart  rect_class;
   XmGadgetClassPart gadget_class;
} XmGadgetClassRec;

extern XmGadgetClassRec xmGadgetClassRec;


/*  The Gadget instance record  */

typedef struct _XmGadgetPart
{
   short shadow_thickness;
   short highlight_thickness;

   XtCallbackList help_callback;
   caddr_t        user_data;

   Boolean traversal_on;
   Boolean highlight_on_enter;
   Boolean have_traversal;

   unsigned char unit_type;

   Boolean highlight_drawn;
   Boolean highlighted;
   Boolean visible;

   Mask event_mask;
} XmGadgetPart;


/*  Full instance record declaration  */

typedef struct _XmGadgetRec
{
   ObjectPart   object;
   RectObjPart  rectangle;
   XmGadgetPart gadget;
} XmGadgetRec;


/*  Masks to define input the gadget is interested in  */

#define XmNO_EVENT		0x00
#define XmENTER_EVENT		0x01
#define XmLEAVE_EVENT		0x02
#define XmFOCUS_IN_EVENT	0x04
#define XmFOCUS_OUT_EVENT	0x08
#define XmMOTION_EVENT		0x10
#define XmARM_EVENT		0x20
#define XmACTIVATE_EVENT	0x40
#define XmHELP_EVENT		0x80
#define XmALL_EVENT		0xFF


/*  Gadget utility functions referenced by gadget, managers  */

extern void _XmConfigureObject();
extern void _XmResizeObject();
extern void _XmMoveObject();
extern void _XmRedisplayGadgets();
extern XmGadget _XmInputInGadget();
extern void _XmDispatchGadgetInput();

/* Gadget access Macros */
#define G_ShadowThickness(g) \
	(((XmGadget)(g))->gadget.shadow_thickness)
#define G_HighlightThickness(g) \
	(((XmGadget)(g))->gadget.highlight_thickness)



/************************************************************************
 *
 *  Manager class, instance and constraint definitions.  Manager #defines
 *  and internally used exported functions.
 *
 ************************************************************************/

/*  Traversal procedure definition  */

typedef void (*XmTraversalProc)();
/* Widget widget */
/* XPoint ul, lr */
/* int    dir    */


/*  Structure used for storing accelerator and mnemonic information.  */

typedef struct 
{
   unsigned int eventType;
   KeySym       keysym;
   KeyCode      key;
   unsigned int modifiers;
   Widget       component;
   Boolean      needGrab;
   Boolean      isMnemonic;
} XmKeyboardData;


/*  The class definition  */

typedef struct _XmManagerClassPart
{
   XtTranslations       translations;
   XmGetValueResource * get_resources;   
   int                  num_get_resources;   
   XmGetValueResource * get_constraint_resources;   
   int                  num_get_constraint_resources;   
   caddr_t              extension;
} XmManagerClassPart;

typedef struct _XmManagerClassRec
{
    CoreClassPart       core_class;
    CompositeClassPart  composite_class;
    ConstraintClassPart constraint_class;
    XmManagerClassPart  manager_class;
} XmManagerClassRec;

extern XmManagerClassRec xmManagerClassRec;


/*  The instance definition  */

typedef struct _XmManagerPart
{
   Pixel   foreground;

   short   shadow_thickness;
   Pixel   top_shadow_color;
   Pixmap  top_shadow_pixmap;
   Pixel   bottom_shadow_color;
   Pixmap  bottom_shadow_pixmap;

   Pixel   highlight_color;
   Pixmap  highlight_pixmap;

   XtCallbackList help_callback;
   caddr_t        user_data;

   Boolean traversal_on;
   unsigned char unit_type;
   
   Boolean event_handler_added;
   Widget  active_child;
   Widget  highlighted_widget;
   Widget  accelerator_widget;

   XmKeyboardData * keyboard_list;
   short num_keyboard_entries;
   short size_keyboard_list;

   XmGadget selected_gadget;

   GC      background_GC;
   GC      highlight_GC;
   GC      top_shadow_GC;
   GC      bottom_shadow_GC;
} XmManagerPart;

typedef struct _XmManagerRec
{
   CorePart       core;
   CompositePart  composite;
   ConstraintPart constraint;
   XmManagerPart  manager;
} XmManagerRec;


/*  The constraint definition  */

typedef struct _XmManagerConstraintPart
{
   int unused;
} XmManagerConstraintPart;

typedef struct _XmManagerConstraintRec
{
   XmManagerConstraintPart manager;
} XmManagerConstraintRec, * XmManagerConstraintPtr;


/*  Define for the traversal handler inheritance  */

#define XtInheritTraversalProc ((XmTraversalProc) _XtInherit)


/*  Manager exported functions  */

extern void     _XmManagerEnter();         /* start traversal               */
extern void     _XmManagerLeave();         /* end traversal                 */
extern void     _XmManagerFocusIn();       /* focus management              */
extern void     _XmManagerFocusOut();      /* focus management              */
extern void     _XmManagerVisibility();	   /* more focus management         */
extern void     _XmManagerUnmap();         /* even more focus management    */
extern Boolean  _XmFindTraversablePrim();  /* traversal checking routine    */
extern void     _XmReManageChildren();     /* rebuild Managed Children List */
extern Boolean  _XmGetFocusResetFlag();
extern void     _XmSetFocusResetFlag();
extern Boolean  _XmGetTransientFlag();
extern void     _XmSetTransientFlag();
extern void 	_XmDrawShadowType();
extern void 	_XmClearShadowType();
extern void 	_XmDestroyParentCallback();

/* Access macros */

#define MGR_KeyboardList(m)        (((XmManagerRec *) (m))->manager.keyboard_list)
#define MGR_NumKeyboardEntries(m)  (((XmManagerRec *) (m))->manager.num_keyboard_entries)
#define MGR_SizeKeyboardList(m)    (((XmManagerRec *) (m))->manager.size_keyboard_list)
#define MGR_ShadowThickness(m)    (((XmManagerRec *) (m))->manager.shadow_thickness)


/*  GC access macros  */

#define XmParentTopShadowGC(w) (((XmManagerWidget)			\
	(((XmGadget)(w))->object.parent))->manager.top_shadow_GC)

#define XmParentBottomShadowGC(w) (((XmManagerWidget)			\
	(((XmGadget)(w))->object.parent))->manager.bottom_shadow_GC)

#define XmParentHighlightGC(w) (((XmManagerWidget)			\
	(((XmGadget)(w))->object.parent))->manager.highlight_GC)



/*
 * used by parents of gadgets to allow geometry treatment independently
 * of whether the kid is a widget or gadget
 */

typedef struct _XmKidGeometryRec
{
    Widget   kid;				/* ptr to kid */
    XtWidgetGeometry	box;			/* kid geo box */
} XmKidGeometryRec, *XmKidGeometry;


/***********************************************************************
 *
 * Resolution independence functions
 *
 ***********************************************************************/

extern XtGeometryResult _XmMakeGeometryRequest();
extern XmKidGeometry _XmGetKidGeo();
extern void _XmSetKidGeo();
extern void _XmSetInstigatorGeo();


typedef void (*XmVoidProc)();


/* Various useful constant and macro definitions */
/* from /usr/include/X11/Misc.h */

/* LAST(Dimension) */
#define MAXDIMENSION	((1 << 31)-1)

#define Max(x, y)	(((x) > (y)) ? (x) : (y))
#define Min(x, y)	(((x) < (y)) ? (x) : (y))
#define AssignMax(x, y)	if ((y) > (x)) x = (y)
#define AssignMin(x, y)	if ((y) < (x)) x = (y)

/****************
 *
 * XmString structures
 *
 ****************/

typedef unsigned char UChar;
typedef unsigned short UShort;




/*
 * these are the structures which make up the internal version of the TCS.
 */

typedef struct
{
    char	*charset;		/* name of charset */
    short	font_index;		/* index of font to use */
    short	char_count;		/* octet count for this segment */
    char	*text;			/* ptr to octets. If RtoL then */
					/* is a local flipped copy */
    XmStringDirection direction;	/* octet order of this segment */
    Dimension	pixel_width;		/* width of segment */
    Dimension	pixel_height;		/* height "   "     */
}
    _XmStringSegmentRec, *_XmStringSegment;


typedef struct 
{
    short		segment_count;	/* segments in this line */
    _XmStringSegment 	segment;	/* array of segments */
}
    _XmStringLineRec, *_XmStringLine;


typedef struct 
{
    short	line_count;		/* lines in this _XmString */
    _XmStringLine line;			/* array of lines */
}
    _XmStringRec, *_XmString;


/****************
 *
 *  Private functions defined in XmString.c
 *
 ****************/
extern Boolean			_XmFontListSearch ();
extern Boolean			_XmSearchFontList ();

extern Dimension		_XmStringWidth ();
extern Dimension		_XmStringHeight ();
extern void			_XmStringExtent ();
extern Dimension		_XmStringBaseline ();
extern int			_XmStringLineCount ();
extern Boolean			_XmStringEmpty ();

extern void			_XmStringDraw ();
extern void			_XmStringDrawImage ();
extern void			_XmStringDrawUnderline ();

extern _XmString		_XmStringCreate ();
extern void 			_XmStringFree ();
extern void 			_XmStringUpdate ();
extern _XmString		_XmStringCopy ();
extern Boolean			_XmStringByteCompare ();



/************************************************************************
 *
 *  Fast subclassing macros and definitions
 *
 ************************************************************************/

#define _XmFastSubclassInit(wc, bit_field) \
   (wc->core_class.extension = (caddr_t)   \
    (((unsigned int) wc->core_class.extension) | bit_field))


#define XmARROW_BUTTON_BIT		0
#define XmARROW_BUTTON_GADGET_BIT	0
#define XmBULLETIN_BOARD_BIT		(1<<0)
#define XmCASCADE_BUTTON_BIT		(1<<1)
#define XmCASCADE_BUTTON_GADGET_BIT	(1<<2)
#define XmCOMMAND_BOX_BIT		(1<<3)
#define XmDIALOG_SHELL_BIT		(1<<4)
#define XmDRAWING_AREA_BIT		0
#define XmDRAWN_BUTTON_BIT		0
#define XmFILE_SELECTION_BOX_BIT	(1<<5)
#define XmFORM_BIT			(1<<6)
#define XmFRAME_BIT			(1<<7)
#define XmGADGET_BIT			(1<<8)
#define XmLABEL_BIT			(1<<9)
#define XmLABEL_GADGET_BIT		(1<<10)
#define XmLIST_BIT			0
#define XmMAIN_WINDOW_BIT		(1<<11)
#define XmMANAGER_BIT			(1<<12)
#define XmMENU_SHELL_BIT		(1<<13)
#define XmMESSAGE_BOX_BIT		(1<<14)
#define XmPRIMITIVE_BIT			(1<<15)
#define XmPUSH_BUTTON_BIT		(1<<16)
#define XmPUSH_BUTTON_GADGET_BIT	(1<<17)
#define XmROW_COLUMN_BIT		(1<<18)
#define XmSASH_BIT			0
#define XmSCALE_BIT			0
#define XmSCROLLBAR_BIT			(1<<19)
#define XmSCROLLED_WINDOW_BIT		(1<<20)
#define XmSELECTION_BOX_BIT		(1<<21)
#define XmSEPARATOR_BIT			(1<<22)
#define XmSEPARATOR_GADGET_BIT		(1<<23)
#define XmTEXT_BIT			(1<<24)
#define XmTOGGLE_BUTTON_BIT		(1<<25)
#define XmTOGGLE_BUTTON_GADGET_BIT	(1<<26)
#define XmVPANED_BIT			0


#undef XmIsBulletinBoard
#define XmIsBulletinBoard(w)  \
  ((unsigned int) XtClass(w)->core_class.extension & XmBULLETIN_BOARD_BIT)

#undef XmIsCascadeButton
#define XmIsCascadeButton(w)  \
  ((unsigned int) XtClass(w)->core_class.extension & XmCASCADE_BUTTON_BIT)

#undef XmIsCascadeButtonGadget
#define XmIsCascadeButtonGadget(w)  \
  ((unsigned int) XtClass(w)->core_class.extension & XmCASCADE_BUTTON_GADGET_BIT)

#undef XmIsCommandBox
#define XmIsCommandBox(w)  \
  ((unsigned int) XtClass(w)->core_class.extension & XmCOMMAND_BOX_BIT)

#undef XmIsDialogShell
#define XmIsDialogShell(w)  \
  ((unsigned int) XtClass(w)->core_class.extension & XmDIALOG_SHELL_BIT)

#undef XmIsFileSelectionBox
#define XmIsFileSelectionBox(w)  \
  ((unsigned int) XtClass(w)->core_class.extension & XmFILE_SELECTION_BOX_BIT)

#undef XmIsForm
#define XmIsForm(w)  \
  ((unsigned int) XtClass(w)->core_class.extension & XmFORM_BIT)

#undef XmIsFrame
#define XmIsFrame(w)  \
  ((unsigned int) XtClass(w)->core_class.extension & XmFRAME_BIT)

#undef XmIsGadget
#define XmIsGadget(w)  \
  ((unsigned int) XtClass(w)->core_class.extension & XmGADGET_BIT)

#undef XmIsLabel
#define XmIsLabel(w)  \
  ((unsigned int) XtClass(w)->core_class.extension & XmLABEL_BIT)

#undef XmIsLabelGadget
#define XmIsLabelGadget(w)  \
  ((unsigned int) XtClass(w)->core_class.extension & XmLABEL_GADGET_BIT)

#undef XmIsMainWindow
#define XmIsMainWindow(w)  \
  ((unsigned int) XtClass(w)->core_class.extension & XmMAIN_WINDOW_BIT)

#undef XmIsManager
#define XmIsManager(w)  \
  ((unsigned int) XtClass(w)->core_class.extension & XmMANAGER_BIT)

#undef XmIsMenuShell
#define XmIsMenuShell(w)  \
  ((unsigned int) XtClass(w)->core_class.extension & XmMENU_SHELL_BIT)

#undef XmIsPrimitive
#define XmIsPrimitive(w)  \
  ((unsigned int) XtClass(w)->core_class.extension & XmPRIMITIVE_BIT)

#undef XmIsPushButton
#define XmIsPushButton(w)  \
  ((unsigned int) XtClass(w)->core_class.extension & XmPUSH_BUTTON_BIT)

#undef XmIsPushButtonGadget
#define XmIsPushButtonGadget(w)  \
  ((unsigned int) XtClass(w)->core_class.extension & XmPUSH_BUTTON_GADGET_BIT)

#undef XmIsRowColumn
#define XmIsRowColumn(w)  \
  ((unsigned int) XtClass(w)->core_class.extension & XmROW_COLUMN_BIT)

#undef XmIsScrolledWindow
#define XmIsScrolledWindow(w)  \
  ((unsigned int) XtClass(w)->core_class.extension & XmSCROLLED_WINDOW_BIT)

#undef XmIsScrollBar
#define XmIsScrollBar(w)  \
  ((unsigned int) XtClass(w)->core_class.extension & XmSCROLL_BAR_BIT)

#undef XmIsSeparator
#define XmIsSeparator(w)  \
  ((unsigned int) XtClass(w)->core_class.extension & XmSEPARATOR_BIT)

#undef XmIsSeparatorGadget
#define XmIsSeparatorGadget(w)  \
  ((unsigned int) XtClass(w)->core_class.extension & XmSEPARATOR_GADGET_BIT)

#undef XmIsText
#define XmIsText(w)  \
  ((unsigned int) XtClass(w)->core_class.extension & XmTEXT_BIT)

#undef XmIsToggleButton
#define XmIsToggleButton(w)  \
  ((unsigned int) XtClass(w)->core_class.extension & XmTOGGLE_BUTTON_BIT)

#undef XmIsToggleButtonGadget
#define XmIsToggleButtonGadget(w)  \
  ((unsigned int) XtClass(w)->core_class.extension & XmTOGGLE_BUTTON_GADGET_BIT)



/************************************************************************
 *
 *  Defines and macros for the XmResolvePart function
 *
 ************************************************************************/

/*  Widget class indices used with XmPartOffset and XmField macros  */

#define XmObjectIndex 		0
#define XmRectObjIndex		(XmObjectIndex + 1)
#define XmWindowObjIndex	(XmRectObjIndex + 1)
#define XmCoreIndex 		0
#define XmCompositeIndex 	(XmWindowObjIndex + 2)
#define XmConstraintIndex 	(XmCompositeIndex + 1)
#define XmGadgetIndex	 	(XmRectObjIndex + 1)
#define XmPrimitiveIndex 	(XmWindowObjIndex + 2)
#define XmManagerIndex	 	(XmConstraintIndex + 1)

#define XmArrowBIndex		(XmPrimitiveIndex + 1)
#define XmLabelIndex		(XmPrimitiveIndex + 1)
#define XmListIndex		(XmPrimitiveIndex + 1)
#define XmScrollBarIndex	(XmPrimitiveIndex + 1)
#define XmSeparatorIndex	(XmPrimitiveIndex + 1)
#define XmTextIndex		(XmPrimitiveIndex + 1)

#define XmCascadeBIndex		(XmLabelIndex + 1)
#define XmDrawnBIndex		(XmLabelIndex + 1)
#define XmPushBIndex		(XmLabelIndex + 1)
#define XmToggleBIndex		(XmLabelIndex + 1)

#define XmArrowBGIndex		(XmGadgetIndex + 1)
#define XmLabelGIndex		(XmGadgetIndex + 1)
#define XmSeparatoGIndex	(XmGadgetIndex + 1)

#define XmCascadeBGIndex	(XmLabelGIndex + 1)
#define XmPushBGIndex		(XmLabelGIndex + 1)
#define XmToggleBGIndex		(XmLabelGIndex + 1)

#define XmBulletinBIndex	(XmManagerIndex + 1)
#define XmDrawingAIndex		(XmManagerIndex + 1)
#define XmFrameIndex		(XmManagerIndex + 1)
#define XmPanedWIndex		(XmManagerIndex + 1)
#define XmRowColumnIndex	(XmManagerIndex + 1)
#define XmScaleIndex		(XmManagerIndex + 1)
#define XmScrolledWIndex	(XmManagerIndex + 1)

#define XmFormIndex		(XmBulletinBIndex + 1)
#define XmMessageBIndex		(XmBulletinBIndex + 1)
#define XmSelectioBIndex	(XmBulletinBIndex + 1)

#define XmMainWIndex		(XmScrolledWIndex + 1)

#define XmCommandIndex		(XmSelectioBIndex + 1)
#define XmFileSBIndex		(XmSelectioBIndex + 1)

#define XmShellIndex 		(XmCompositeIndex + 1)
#define XmOverrideShellIndex 	(XmShellIndex + 1)
#define XmWMShellIndex	 	(XmShellIndex + 1)
#define XmVendorShellIndex 	(XmWMShellIndex + 1)
#define XmTransientShellIndex	(XmVendorShellIndex + 1)
#define XmTopLevelShellIndex 	(XmVendorShellIndex + 1)
#define XmApplicationShellIndex (XmTopLevelShellIndex + 1)

#define XmDialogSIndex		(XmTransientShellIndex + 1)
#define XmMenuShellIndex	(XmOverrideShellIndex + 1)


#define XmLONGBITS (sizeof(long) * 8)
#define XmHALFLONGBITS (XmLONGBITS/2)

typedef struct _XmPartResource {
    String     resource_name;	/* Resource name			    */
    String     resource_class;	/* Resource class			    */
    String     resource_type;	/* Representation type desired		    */
    Cardinal   resource_size;	/* Size in bytes of representation	    */
    Cardinal   resource_offset;	/* Index within & offset within part 	    */
    String     default_type;	/* representation type of specified default */
    caddr_t    default_addr;   	/* Address of default resource		    */
} XmPartResource;


typedef long XmOffset;
typedef XmOffset *XmOffsetPtr;

#define XmPartOffset(part, variable) \
        ((Xm/**/part/**/Index) << XmHALFLONGBITS) + XtOffset(part/**/Part *, variable)

#define XmGetPartOffset(r, offset) \
       ((r)->resource_offset & 0xff) + (*(offset))[ (r)->resource_offset >> XmHALFLONGBITS]

#define XmField(widget, offsetrecord, part, variable, type) \
	(*(type *)(((char *) (widget)) + offsetrecord[Xm/**/part/**/Index] + \
		XtOffset(part/**/Part *, variable)))

extern void XmResolvePartOffsets();
/* WidgetClass class; */
/* XmOffsetPtr *offset; */

/* this suffix is added to dialog shells created by Xm convenience routines */
/* so that, for example, a call to create a form dialog named f generates a */
/* dialog shell named f_popup in addition to a form named f */
#define DIALOG_SUFFIX "_popup"
#define DIALOG_SUFFIX_SIZE 6

#endif /* _XmP_h */
/* DON'T ADD STUFF AFTER THIS #endif */
