/* 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: @(#)SelectionI.h	1.1 89/07/19";
#endif /* lint */
#endif /* REV_INFO */
/******************************************************************************
*******************************************************************************
*
*  (c) Copyright 1989, OPEN SOFTWARE FOUNDATION, INC.
*  (c) Copyright 1989, DIGITAL EQUIPMENT CORPORATION, MAYNARD, MASS.
*  (c) Copyright 1987, 1988, 1989 HEWLETT-PACKARD COMPANY
*  (c) Copyright 1988 MASSACHUSETTS INSTITUTE OF TECHNOLOGY 
*  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
*
*******************************************************************************
******************************************************************************/

#ifndef _XtselectionI_h
#define _XtselectionI_h

#ifndef _XtIntrinsic_h
#include "Intrinsic.h"
#endif
#ifndef _Selection_h
#include "Selection.h"
#endif

#define BYTELENGTH(length, format) ((length)*((format)>>3))
#define NUMELEM(bytelength, format) ((bytelength)/((format)>>3))

/* incremental interface -- lots of these aren't really used. */

typedef void (*XtLoseSelectionIncrProc) (); 
	/* widget, selection, closure) */
	/*	Widget	widget,*/
	/*	Atom	*selection,*/
	/*	Opaque	closure*/	/* selection owner specified */

typedef void (*XtSelectionDoneIncrProc) ();
/* widget, selection, target, receiver_id, closure */
	/*	Widget	widget,*/
	/*	Atom	*selection,*/
	/*	Atom	*target,*/
	/*	Opaque	receiver_id */
	/*	Opaque	closure */

typedef Boolean (*XtConvertSelectionIncrProc)();
 /* widget, selection, target, type, value, length,
    format, max_length, closure, receiver_id */
	/*	Widget	widget,*/
	/*	Atom	*selection,*/
	/*	Atom	*target,*/
	/*	Atom	*type, */
	/*	caddr_t	*value, */
	/*	unsigned long	*length, */
	/*	int	*format */	 
	/*	unsigned long	max_length,*/
	/*	Opaque	closure,*/
	/*	Opaque	receiver_id,*/

typedef void (*XtCancelSelectionCallbackProc)();
/* widget, selection, target, closure */
	/*	Widget	widget,*/
	/*	Atom	*selection,*/
	/*	Opaque	closure*/

typedef void (*XtCancelConvertSelectionProc)();
/* widget, selection, target, closure */
	/*	Widget	widget,*/
	/*	Atom	*selection,*/
	/*	Atom	*target, */
	/*	Opaque	receiver_id*/
	/*	Opaque	closure*/

typedef void (*XtSelectionIncrCallbackProc) ();
/* widget, closure, selection, type, value, length, format */
	/*	Widget	widget,*/
	/*	Opaque	closure, */
	/*	Atom	*selection,*/
	/*	Atom	*type,*/
	/*	caddr_t	value,*/
	/*	unsigned long	*length,*/
	/*	int	*format  */

typedef struct _IncrementalRec *Incremental;

typedef struct _IncrementalRec {
   Window requestor;
   Atom type;
   Atom property;
   int format;
   Incremental next, prev;
   Boolean incr_callback;
   XtConvertSelectionIncrProc convert;
   XtCancelSelectionCallbackProc owner_cancel;
   Opaque owner_closure;
   char *value;
   int bytelength;
   int offset;
} IncrementalRec;


typedef struct {
    Atom selection; 			/* constant */
    Display *dpy; 			/* constant */
    Widget widget;
    Time time;
    int refcount;
    XtConvertSelectionProc convert;
    XtLoseSelectionProc loses;
    XtSelectionDoneProc notify;
    XtCancelSelectionCallbackProc owner_cancel;
    Incremental incrList;
    Boolean incremental;
    Opaque owner_closure;
    Atom incremental_atom; 		/* constant */
    Atom indirect_atom; 		/* constant */
} SelectRec, *Select;

typedef struct {
    XtSelectionCallbackProc callback;
    Opaque *req_closure;
    Atom property;
    Atom *target;
    XtIntervalId timeout;
    XtEventHandler proc;
    Widget widget;
    Time time;
    Select ctx;
    Boolean incremental;
    XtCancelConvertSelectionProc req_cancel;
} CallBackInfoRec, *CallBackInfo;

typedef struct {
  Atom target;
  Atom property;
} IndirectPair;

#define IndirectPairWordSize 2

typedef struct {
   Select ctx;
   XtSelectionDoneProc notify;
   Atom target;
   Atom property;
   Window window;
   Widget widget;
   Boolean allSent;
   XtIntervalId timeout;
} PropGoneRec, *PropGone;

 typedef struct {
  Atom prop;
  Boolean avail;
} SelectionPropRec, *SelectionProp;

typedef struct {
  int propCount;
  SelectionProp list;
} PropListRec, *PropList;

#define MAX_SELECTION_INCR(dpy) (((65536 < dpy->max_request_size) ? \
	(65536 << 2)  : (dpy->max_request_size << 2))-100)

#define MATCH_SELECT(event, info) ((event->time == info->time) && \
	    (event->requestor == XtWindow(info->widget)) && \
	    ((event->target == *info->target) || \
	     ((event->target == info->ctx->incremental_atom) && \
	      (event->property == info->property))))


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