#ifndef APPLPROG

#define DECHINTS

#ifndef WIDGETPROG
#include <string.h>
#include <ctype.h>
#endif

#ifdef VMS
#include <decw$include/Intrinsic.h>
#include <decw$include/Xlib.h>
#include <decw$include/Shell.h>
#else
#include <X++/Intrinsic.h>
#include <xt++/Shell.h>
#endif

/* these definitions are duplicates of stuff in DECwDwtWidgetProg.h */
/* but have different definitions to make certain data structures   */
/* opaque to the application programmer                             */


class DwtTextSourceRec;
typedef DwtTextSourceRec *DwtTextSource;

/* end of duplicate definitions */

#define APPLPROG


/*
 * toolkit constants
 */

/*
 *  Status codes
 */

#define DwtFail		     	0
#define DwtSuccess	  	1 
#define DwtTruncate 		2
#define DwtEndCS		3


/* cut and paste */

#define ClipboardFail     	0
#define ClipboardSuccess  	1 
#define ClipboardTruncate 	2
#define ClipboardLocked   	4
#define ClipboardNoData   	6


/* 
 * Enumerated constants and assocated resource manager stuff for
 * use with type converters
 */

#define DwtAlignmentCenter	    1
#define DwtAlignmentBeginning	    2
#define DwtAlignmentEnd		    3

#define DwtPixmap		    1
#define DwtCString                  2


/* togglebutton shapes */

#define DwtRectangular		    1
#define DwtOval			    2


/* orientations */

#define DwtOrientationVertical	    1
#define DwtOrientationHorizontal    2


/* resize modes */

#define DwtResizeFixed		    0		    /* can't change */
#define DwtResizeGrowOnly	    1		    /* grow but don't shrink */
#define DwtResizeShrinkWrap	    2		    /* grow & shrink */


/*  dialog styles */

#define DwtModal		    1
#define DwtModeless		    2
#define	DwtWorkarea		    3


/* menu types */

#define DwtMenuBarType		    0
#define DwtMenuWorkArea		    1
#define DwtMenuPulldown		    2
#define DwtMenuPopup		    3
#define DwtMenuOption		    5


/* menu packing styles */

#define DwtMenuPackingTight	0
#define DwtMenuPackingColumn	1
#define DwtMenuPackingNone	2


/* caution box */

#define DwtYesButton		0
#define DwtNoButton		1
#define DwtCancelButton		2


/* font unit positioning */

#define DwtFontUnits		0
#define DwtPixelUnits		1


/* help widget library type */

#define DwtTextLibrary		1


/*
 * duplicate definitions (identical Xt's) used by toolkit
 */

#define DwtNtranslations	"translations"
/*#define DwtNx		 	"x"                  see below */
/*#define DwtNy			"y"                  see below */
/*#define DwtNsensitive		"sensitive"          see below */
#define DwtCLabel		"Label"


/*
 * duplicate definitions not used by toolkit but for users
 * accessing intrinsic resources
 */

#define DwtNoverrideRedirect	"overrideRedirect"
#define DwtNbackgroundPixmap	"backgroundPixmap"
#define DwtNborderPixmap	"borderPixmap"
#define DwtNbackground		"background"
#define DwtNancestorSensitive	"ancestorSensitive"
#define DwtNdestroyCallback	"destroyCallback"
#define DwtNx		 	"x"
#define DwtNy			"y"
#define DwtNdepth		"depth"
#define DwtNborder		"borderColor"
#define DwtNsensitive		"sensitive"
#define DwtNmappedWhenManaged	"mappedWhenManaged"
#define DwtNscreen              "screen"
#define DwtCScreen              "Screen"
#define DwtCColormap		"Colormap"
#define DwtNcolormap		"colormap"
#define DwtNborderColor		"borderColor"
#define DwtCBorderColor		"BorderColor"
#define DwtCAccelerators        "Accelerators"


/* 
 * used by DRM only 
 */

#define DwtNcreateCallback	"createCallback"



/*
 * callback reasons 
 */

#define DwtCRUnitInc	 		0
#define DwtCRUnitDec	 		1
#define DwtCRPageInc     		2
#define DwtCRPageDec     		3
#define DwtCRScrollStart 		4
#define DwtCRDrag        		5
#define DwtCRScrollEnd   		6
#define DwtCRToTop       		7
#define DwtCRToBottom    		8
#define DwtCRCancel      		9
#define DwtCRActivate			10
#define DwtCRArm			11
#define DwtCRDisarm			12
#define DwtCRValueChanged 		13
#define DwtCRNo         		14
#define DwtCRToPosition 		15
#define DwtCRMap        		16
#define DwtCRUnmap  			17
#define DwtCRPullDown   		18
#define DwtCRFocus      		19
#define DwtCRSingle	 		20
#define DwtCRSingleConfirm		21
#define DwtCRExtend			22
#define DwtCRExtendConfirm		23
#define DwtCRCommandEntered		24
#define DwtCRCreate			25
#define DwtCRHelpRequested   		26
#define DwtCRHelp            		26
#define DwtCRSelection       		27
#define DwtCRClipboardDataRequest	28
#define DwtCRClipboardDataDelete	29
#define DwtCRYes			30
#define DwtCRExpose			31
#define DwtCRNoMatch			32
#define DwtCRLostFocus      		33



/*
 * typedefs and other DECw support structs
 */

typedef void (*VoidProc) ();
typedef char *DwtCompString;
typedef long DwtTextPosition;

#ifndef Byte
#define Byte unsigned char
#endif


/*
 * the callback structure
 */

typedef void (*DwtCallbackProc) (Widget, Opaque, Opaque);

struct DwtCallback {
    DwtCallbackProc	proc;
    int			tag;
/*
  public:
    DwtCallback() {};
    DwtCallback(VoidProc p, int t) { proc = p; tag = t; }
*/
};
typedef     DwtCallback *DwtCallbackPtr;

class DwtCallbackStruct;
typedef DwtCallbackStruct *DwtCallbackStructPtr;

/* definition for cut and paste */

class  DwtClipboardPendingRec;
typedef  DwtClipboardPendingRec *DwtClipboardPendingList;
class  DwtClipboardPendingRec {
    int DataId;
    int PrivateId;
};
 
/*
 * Compound String Context
 */

class DwtCompStringContext {
  char *cs;
  long offset;
};
 
/*
 * Font list definition.
 */
class  DwtFontRec;
typedef  DwtFontRec *DwtFontList;
class  DwtFontRec {

        XFontStruct  *font;
        long    char_set_id;

};

 
/*
 * Render mask definition
 */
class DwtRendMaskRec;
typedef DwtRendMaskRec *DwtRendMask;
class DwtRendMaskRec {
  long mask[4];
};

#define DwtRendMaskNone 	(DwtRendMask)0
#define DwtLanguageNotSpecified	0

/*
 * the application is returned these structs on callbacks
 */


class DwtAnyCallbackStruct {
/* All callbacks return at least these two fields  */
    int     reason;
    XEvent  *event;
};

class DwtMenuCallbackStruct : public DwtAnyCallbackStruct {
/* returned by menu */
    Widget  s_widget;
    char    *s_tag;
    char    *s_callbackstruct;
};



class  DwtScrollBarCallbackStruct : public DwtAnyCallbackStruct {
/* returned by scroll bar */
    int value;
    int pixel;
public:
    int Value() { return value; }
    int Pixel() { return pixel; }
};


class DwtTogglebuttonCallbackStruct : public DwtAnyCallbackStruct {
/* returned by toggle button */
    int value;
};

class DwtWindowCallbackStruct : public DwtAnyCallbackStruct {
/* returned by window widget */
    Window	 w;
};


class DwtScaleCallbackStruct : public DwtAnyCallbackStruct {
/* Returned by scroll bar */
    int value;
};

class  DwtListBoxCallbackStruct : public DwtAnyCallbackStruct {
/* returned by list box */
    DwtCompString item;
    int  	   item_length;
    int  	   item_number;
};

class  DwtRadioBoxCallbackStruct : public DwtAnyCallbackStruct {
/* returned by radio box */
    Widget  s_widget;
    char    *s_tag;
    char    *s_callbackstruct;
};


class  DwtSelectionCallbackStruct : public DwtAnyCallbackStruct {
/* returned by select */
    DwtCompString value;
    int   	   value_len;
};

class DwtFileSelectionCallbackStruct : public DwtAnyCallbackStruct {
/* returned by file select */
    DwtCompString value;
    int  	   value_len;
    DwtCompString dirmask;
    int  	   dirmask_len;
};

class  DwtCommandWindowCallbackStruct : public DwtAnyCallbackStruct {
/* returned by command box */
    int length;
    char * value;
};

typedef enum _DwtAttachmentType {
    DwtAttachNone,		/* Do not attach this edge */
    DwtAttachAdb,		/* Attach this edge to an edge of a adb */
    DwtAttachWidget,		/* Attach this edge to the edge of a widget */
    DwtAttachPosition,		/* Attach this edge to a point in the adb */
    DwtAttachSelf,		/* Attach this edge to its initial position */
    DwtAttachOppWidget,		/* Attach to opposite edge of widget */
    DwtAttachOppAdb,		/* Attach to opposite edge of adb */
} DwtAttachmentType;

/*
 *  Macros to support the writing of upward compatible widgets
 */

/*
 *  Widget class indices used with DwtPartOffset and DwtField macros
 */

#define DwtObjectIndex 		0
#define DwtRectObjIndex		(DwtObjectIndex + 1)
#define DwtWindowObjIndex	(DwtRectObjIndex + 1)
#define DwtCoreIndex 		0
#define DwtCompositeIndex 	(DwtWindowObjIndex + 2)
#define DwtConstraintIndex 	(DwtCompositeIndex + 1)
#define DwtDwtCommonIndex 	(DwtCompositeIndex + 1)
#define DwtShellIndex 		(DwtCompositeIndex + 1)
#define DwtDwthelpIndex 	(DwtDwtCommonIndex + 1)
#define DwtLabelIndex 		(DwtDwtCommonIndex + 1)
#define DwtMainWindowIndex 	(DwtDwtCommonIndex + 1)
#define DwtMenuIndex 		(DwtDwtCommonIndex + 1)
#define DwtScaleIndex 		(DwtDwtCommonIndex + 1)
#define DwtScrollIndex 		(DwtDwtCommonIndex + 1)
#define DwtScrollWindowIndex 	(DwtDwtCommonIndex + 1)
#define DwtWindowIndex 		(DwtDwtCommonIndex + 1)
#define DwtPulldownIndex 	(DwtLabelIndex + 1)
#define DwtPushbuttonIndex 	(DwtLabelIndex + 1)
#define DwtSeparatorIndex 	(DwtLabelIndex + 1)
#define DwtTogglebuttonIndex	(DwtLabelIndex + 1)
#define DwtDialogIndex 		(DwtConstraintIndex + 1)
#define DwtCommandIndex 	(DwtDialogIndex + 1)
#define DwtMessageIndex 	(DwtDialogIndex + 1)
#define DwtSelectionIndex 	(DwtDialogIndex + 1)
#define DwtAttacheddbIndex 	(DwtDialogIndex + 1)
#define DwtFileSelectionIndex 	(DwtSelectionIndex + 1)
#define DwtOverrideShellIndex 	(DwtShellIndex + 1)
#define DwtWMShellIndex 	(DwtShellIndex + 1)
#define DwtMenuPopupIndex 	(DwtOverrideShellIndex + 1)
#define DwtVendorShellIndex 	(DwtWMShellIndex + 1)
#define DwtTopLevelShellIndex 	(DwtVendorShellIndex + 1)
#define DwtApplicationShellIndex (DwtTopLevelShellIndex + 1)
#define DwtHelpShellIndex 	(DwtTopLevelShellIndex + 1)
#define DwtHiddenShellIndex 	(DwtTopLevelShellIndex + 1)
#define DwtListBoxIndex 	(DwtScrollWindowIndex + 1)

#ifdef NOT_VMS_V1
#define LONGBITS (sizeof(long) * 8)
#define HALFLONGBITS (LONGBITS/2)
#endif

class DwtPartResource {
    String     resource_name;	/* Resource name			    */
    String     resource_class;	/* Resource class			    */
    String     resource_type;	/* Representation type desired		    */
    Cardinal   resource_size;	/* Size in bytes of representation	    */
#ifdef NOT_VMS_V1
    Cardinal   resource_offset;	/* Index within & offset within part 	    */
#else
    short      resource_part;	/* Index of resource part		    */
    short      resource_offset;	/* Offset within part to put resource value */
#endif
    String     default_type;	/* representation type of specified default */
    caddr_t    default_addr;   	/* Address of default resource		    */
};

typedef long DwtOffset;
typedef DwtOffset *DwtOffsetPtr;

#ifdef NOT_VMS_V1
#define DwtPartOffset(part, variable) \
        ((Dwt/**/part/**/Index) << HALFLONGBITS) + XtOffset(part/**/Part *, variable)

#define GetDwtPartOffset(r, offset) \
       ((r)->resource_offset & 0xff) + (*(offset))[ (r)->resource_offset >> HALFLONGBITS]
;
#else
#define DwtPartOffset(part, variable) \
	Dwt/**/part/**/Index, XtOffset(part/**/Part *, variable)
#endif

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

void DwtResolvePartOffsets();
	/* WidgetClass class; */
	/* DwtOffsetPtr *offset; */

#endif /* APPLPROG */
