home *** CD-ROM | disk | FTP | other *** search
/ NeXTSTEP 3.0 / NeXTSTEP3.0.iso / NextDeveloper / Headers / dpsclient / dpsNeXT.h < prev    next >
Text File  |  1992-02-22  |  12KB  |  359 lines

  1. /*
  2.     dpsNeXT.h
  3.     
  4.     This file describes the interface to the DPS routines specific to the
  5.     NeXT implementation of the DPS library.
  6.     
  7.     Copyright (c) 1988 NeXT, Inc. as an unpublished work.
  8.     All rights reserved.
  9. */
  10.  
  11. #ifndef DPSNEXT_H
  12. #define DPSNEXT_H
  13.  
  14. #ifndef EVENT_H
  15. #include "event.h"
  16. #endif EVENT_H
  17.  
  18. #ifndef DPSCLIENT_H
  19. #include "dpsclient.h"
  20. #endif DPSCLIENT_H
  21.  
  22. #ifndef ERROR_H
  23. #include <objc/error.h>
  24. #endif ERROR_H
  25.  
  26. #import <stdio.h>
  27. #import <mach/port.h>
  28. #import <mach/message.h>
  29. #import <streams/streams.h>
  30. #import <objc/zone.h>
  31.  
  32. /*=== CONSTANTS ===*/
  33.  
  34. #define NX_CLEAR    0    /* composite operators */
  35. #define NX_COPY        1
  36. #define NX_SOVER    2
  37. #define NX_SIN        3
  38. #define NX_SOUT        4
  39. #define NX_SATOP    5
  40. #define NX_DOVER    6
  41. #define NX_DIN        7
  42. #define NX_DOUT        8
  43. #define NX_DATOP    9
  44. #define NX_XOR        10
  45. #define NX_PLUSD    11
  46. #define NX_HIGHLIGHT    12
  47. #define NX_PLUSL    13        /* not implemented for 1.0 */
  48. #define NX_PLUS        NX_PLUSD    /* for back compatibility. NX_PLUSD
  49.                      * is preferred */
  50.  
  51. #define NX_DATA        1    /* special values for alpha */
  52. #define NX_ONES        2
  53.  
  54. #define NX_RETAINED    0    /* A complete offscreen buffer holds */
  55.                 /* the obscured parts of the window */
  56. #define NX_NONRETAINED    1    /* Only the screen parts exist */
  57. #define NX_BUFFERED    2    /* Complete offscreen copy exists, */
  58.                 /* holds entire contents */
  59.  
  60. #define    NX_ABOVE    1    /* Place window above reference window */
  61. #define    NX_BELOW    (-1)    /* Place window below reference window */
  62. #define    NX_OUT        0    /* Remove it from screen and window List */
  63.  
  64. #define NX_FOREVER    (6307200000.0)    /* 200 years of seconds */
  65.  
  66. #define DPS_ALLCONTEXTS    ((DPSContext)-1) /* refers to all existing contexts */
  67.  
  68.  
  69. typedef e&D_DPSNumberFormat {
  70. #ifdef __BIG_ENDIAN__
  71.     dps_float = 48,
  72.     dps_long = 0,
  73.     dps_short = 32
  74. #else
  75.     dps_float = 48+128,
  76.     dps_long = 0+128,
  77.     dps_short = 32+128
  78. #endif
  79. } DPSNumberFormat;
  80.   /* Constants for DPSDoUserPath describing what type of coordinates are
  81.      being used.  Other legal values are:
  82.  
  83.      For 32-bit fixed point numbers, use dps_long plus the number of bits
  84.      in the fractional part.
  85.  
  86.      For 16-bit fixed point numbers, use dps_short plus the number of bits
  87.      in the fractional part.
  88.   */
  89.  
  90. typedef enum _DPSUserPathOp {
  91.     dps_setbbox = 0,
  92.     dps_moveto,
  93.     dps_rmoveto,
  94.     dps_lineto,
  95.     dps_rlineto,
  96.     dps_curveto,
  97.     dps_rcurveto,
  98.     dps_arc,
  99.     dps_arcn,
  100.     dps_arct,
  101.     dps_closepath,
  102.     dps_ucache
  103. } DPSUserPathOp;
  104.   /* Constants for constructing operator array parameter of DPSDoUserPath. */
  105.  
  106. typedef enum _DPSUserPathAction {
  107.     dps_uappend = 176,
  108.     dps_ufill = 179,
  109.     dps_ueofill = 178,
  110.     dps_ustroke = 183,
  111.     dps_ustrokepath = 364,
  112.     dps_inufill = 93,
  113.     dps_inueofill = 92,
  114.     dps_inustroke = 312,
  115.     dps_def = 51,
  116.     dps_put = 120
  117. } DPSUserPathAction;
  118.   /* Constants for the action of DPSDoUserPath.  In addition to these, any
  119.      other system name index may be used.
  120.    */
  121.  
  122.  
  123. /*=== TYPES ===*/
  124.  
  125. typedef int (*DPSEventFilterFunc)( NXEvent *ev );
  126.   /* Callback proc for filtering events of a context.  It is passed the
  127.      event just read from the context before it is put in the global
  128.      event queue.  If the proc returns TRUE, the event will be inserted
  129.      into the queue as usual, otherwise it not put in the queue.
  130.   */
  131.  
  132. typedef void (*DPSPortProc)( msg_header_t *msg, void *userData );
  133.   /* Callback proc for ports registered by DPSAddPort. */
  134.  
  135. typedef struct __DPSTimedEntry *DPSTimedEntry;
  136.  
  137. typedef void (*DPSTimedEntryProc)(
  138.     DPSTimedEntry te,
  139.     double now,
  140.     void *userData );
  141.   /* Callback proc for timed entries registered by DPSAddTimedEntry. */
  142.  
  143. typedef void (*DPSFDProc)( int fd, void *userData );
  144.   /* Callback proc for fds registered by DPSAddFD. */
  145.  
  146. typedef struct _DPSTaggedMsg {
  147.     msg_header_t header;
  148.     msg_type_t type;
  149.     int values[2];
  150. } DPSTaggedMsg;
  151.   /* Start of a message passed to DPSSendTaggedMsg. */
  152.  
  153. typedef void (*DPSPingProc)(DPSContext ctxt, void *userData);
  154.   /* Callback proc for DPSAsynchronousWaitContext. */
  155.  
  156. exter&Did DPSAsynchronousWaitContext(DPSContext ctxt, DPSPingProc handler, void *userData);
  157.   /* Calls handler when all PS code has been processed for this context. */
  158.  
  159. /*=== PROCEDURES ===*/
  160.  
  161. extern DPSContext DPSCreateContext(
  162.     const char *hostName,
  163.     const char *serverName,
  164.     DPSTextProc textProc,
  165.     DPSErrorProc errorProc );
  166.   /* Creates a connection to the window server with default timeout. */
  167.  
  168. extern DPSContext DPSCreateContextWithTimeoutFromZone(
  169.     const char *hostName,
  170.     const char *serverName,
  171.     DPSTextProc textProc,
  172.     DPSErrorProc errorProc,
  173.     int timeout,
  174.     NXZone *zone );
  175.   /* Creates a connection to the window server with specified ms timeout. */
  176.  
  177. extern DPSContext DPSCreateNonsecureContext(
  178.     const char *hostName,
  179.     const char *serverName,
  180.     DPSTextProc textProc,
  181.     DPSErrorProc errorProc,
  182.     int timeout,
  183.     NXZone *zone );
  184.   /* Creates a non secure connection to the window server. */
  185.  
  186. extern DPSContext DPSCreateStreamContext(
  187.     NXStream *st,
  188.     int debugging,
  189.     DPSProgramEncoding progEnc,
  190.     DPSNameEncoding nameEnc,
  191.     DPSErrorProc errorProc );
  192.   /* Creates a context that writes to a NXStream. */
  193.  
  194. #define DPSFlush()    DPSFlushContext(DPSGetCurrentContext())
  195.   /* Flushes the current connection */
  196.  
  197. extern int DPSSetTracking( int flag );
  198.   /* Enables or disables the coalescing of mouse events. */
  199.  
  200. extern void DPSStartWaitCursorTimer(void);
  201.   /* Starts the wait cursor timeout.  To be used before a time-consuming
  202.      operations that is NOT initiated by a user event.
  203.    */
  204.  
  205. extern void DPSAddPort(
  206.     port_t newPort,
  207.     DPSPortProc handler,
  208.     int maxSize,
  209.     void *userData,
  210.     int priority );
  211.   /* Adds a MACH port to be listened to. */
  212.  
  213. extern void DPSRemovePort( port_t port );
  214.   /* Removes a MACH port previously added. */
  215.  
  216. extern void DPSAddNotifyPortProc(DPSPortProc handler, void *userData);
  217.   /* register handler to be called for any messages on the notify port */
  218.  
  219. extern void DPSRemoveNotifyPortProc(DPSPortProc handler);
  220.   /* unregister handler for notify messages */
  221.  
  222. extern DPSTimedEntry DPSAddTimedEntry(
  223.     double period,
  224.     DPSTimedEntryProc handler,
  225.     void *userData,
  226.     int priority );
  227.   /* Creates a timed entry. */
  228.  
  229. extern void DPSRemoveTimedEntry( DPSTimedEntry te );
  230.   /* Destroys a timed entry. */
  231.  
  232. extern void DPSAddFD(
  233.     int fd,
  234.     DPSFDProc rout&D    
  235.     void *data,
  236.     int priority );
  237.   /* Adds a file descriptor to be listened to. */
  238.  
  239. extern void DPSRemoveFD( int fd );
  240.   /* Removes a file descriptor previously added. */
  241.  
  242. extern void DPSSetDeadKeysEnabled(DPSContext ctxt, int flag);
  243.   /* Enables and disabled dead key processing for a context's events. */
  244.  
  245. extern DPSEventFilterFunc DPSSetEventFunc(
  246.     DPSContext ctxt,
  247.     DPSEventFilterFunc func );
  248.   /* Installs a function to filter events from a given context. */
  249.  
  250. extern int _DPSGetOrPeekEvent( DPSContext ctxt, NXEvent *eventStorage,
  251.             int mask, double wait, int threshold, int peek );
  252. #define DPSGetEvent( ctxt, evPtr, mask, timeout, thresh )    \
  253.     _DPSGetOrPeekEvent( (ctxt), (evPtr), (mask), (timeout), (thresh), 0 )
  254.   /* Finds a matching event, removing it from the queue. */
  255.  
  256. #define DPSPeekEvent( ctxt, evPtr, mask, timeout, thresh )    \
  257.     _DPSGetOrPeekEvent( (ctxt), (evPtr), (mask), (timeout), (thresh), 1 )
  258.   /* Finds a matching event, but does not remove it from the queue. */
  259.  
  260. extern int DPSPostEvent( NXEvent *event, int atStart );
  261.   /* Posts an event to the front or back of the client side event queue. */
  262.  
  263. extern void DPSDiscardEvents( DPSContext ctxt, int mask );
  264.   /* Removes matching events from the event queue.  DPS_ALLCONTEXTS can
  265.      be used as the first argument to match to all contexts.
  266.    */
  267.  
  268. extern int DPSTraceContext( DPSContext ctxt, int flag );
  269.   /* Turns on and off debugging tracing of a context's input and output.
  270.      DPS_ALLCONTEXTS can be used as the first argument to match to
  271.      all contexts.
  272.    */
  273.  
  274. void DPSTraceEvents(DPSContext ctxt, int flag);
  275.   /* Turns on and off debugging tracing of the events a context receives.
  276.      DPS_ALLCONTEXTS can be used as the first argument to match to
  277.      all contexts.
  278.    */
  279.  
  280. extern void DPSPrintError( FILE *fp, const DPSBinObjSeqRec *error );
  281.   /* Prints out a binary encoded error to the fp. */
  282.  
  283. extern void DPSPrintErrorToStream( NXStream *st, const DPSBinObjSeqRec *error );
  284.   /* Prints our a binary encoded error to the stream. */
  285.  
  286. extern const char *DPSNameFromTypeAndIndex( short type, int index );
  287.   /* This routine returns the text for the user name with the given index of
  288.      the given type.  Type 0 is for usernames, and type -1 is for systems
  289.      names.  The string returned is owned by the library (treat it as readonly).
  290.    */
  291.  
  292. extern int DPSDefineUserObject( int index );
  293.   /* Maps a PostScript object to a user object index.  If index is 0, a new
  294.      userobject index is allocated;  otherwise the supplied index is used.
  295.      In either case, the new index for th&Dject is returned.  This index
  296.      can be passed to a pswrap generated function taking a "userobject"
  297.      parameter.  This routine should be called with the object that is
  298.      to be indexed on the top of the operand stack.
  299.   */
  300.  
  301. extern void DPSUndefineUserObject( int index );
  302.   /* Unmaps a previously created user object. */
  303.  
  304. extern void DPSDoUserPath(  
  305.     void *coords,
  306.     int numCoords,
  307.     DPSNumberFormat numType,
  308.     unsigned char *ops,
  309.     int numOps,
  310.     void *bbox,
  311.     int action);
  312.   /* Sends a user path to the window server and one other operator.  See DPS
  313.      extensions documentation on encoded user paths and homogeneous number
  314.      arrays.  Coords is an array of numbers, which combined with the bbox,
  315.      will form the first strings of the encoded user path.  numCoords is the
  316.      number of elements in the coords array.  numType describes the type
  317.      of numbers in the coords array (see the DPSNumberFormat enum).  ops
  318.      is a character array of the operands to be applied to the coords in
  319.      building the user path (see the DPSUserPathOp enum).  This becomes
  320.      the second string of the encoded user path.  "dps_setbbox" will
  321.      be inserted if needed into this list when it is sent to the window
  322.      server.  numOps is the size of the ops array you pass.  bbox
  323.      is an array of numbers of the same type as described by numType that
  324.      holds the minimum x, minimum y, maximum x, and maximum y values of the
  325.      user path.  This data is prepended to the coords array to comprise the
  326.      first string in the encoded user path.  action is the system named index
  327.      of an operator to be executed immediately after the userpath is places
  328.      on the stack (See DPSUserPathAction).
  329.   */
  330.  
  331. extern void DPSDoUserPathWithMatrix(  
  332.     void *coords,
  333.     int numCoords,
  334.     DPSNumberFormat numType,
  335.     unsigned char *ops,
  336.     int numOps,
  337.     void *bbox,
  338.     int action,
  339.     float matrix[6]);
  340.   /* Same as DPSDoUserPath except it takes an additional matrix argument which
  341.      represents the optional matrix argument used by the ustroke, inustroke and
  342.      ustrokepath operators.  If matrix is NULL, it is ignored.
  343.    */
  344.  
  345. extern int DPSSendTaggedMsg(DPSContext ctxt, DPSTaggedMsg *msg);
  346.   /* Sends a tagged message to the Window Server.  Returns tag number to pass
  347.      to some PS operator which accepts the messag&Dta as an argument.
  348.    */
  349.  
  350. extern int DPSSendPort(DPSContext ctxt, port_t port, int sendAllRights);
  351.   /* sends a single port in a tagged message.  Returns tag number to pass to
  352.      some PS operator which accepts the port as an argument.
  353.    */
  354.  
  355. void DPSSendEOF(DPSContext ctxtArg);
  356.   /* sends an EOF marker to the context */
  357.  
  358. #endif DPSNEXT_H
  359.