home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Source Code 1993 July / THE_SOURCE_CODE_CD_ROM.iso / X / mit / extensions / lib / PEX / include / cpa.h < prev    next >
Encoding:
C/C++ Source or Header  |  1991-02-17  |  7.3 KB  |  200 lines

  1. /* $XConsortium: cpa.h,v 5.2 91/02/18 11:16:05 rws Exp $ */
  2.  
  3. /***********************************************************
  4. Copyright 1989, 1990, 1991 by Sun Microsystems, Inc. and the X Consortium.
  5.  
  6.                         All Rights Reserved
  7.  
  8. Permission to use, copy, modify, and distribute this software and its 
  9. documentation for any purpose and without fee is hereby granted, 
  10. provided that the above copyright notice appear in all copies and that
  11. both that copyright notice and this permission notice appear in 
  12. supporting documentation, and that the names of Sun Microsystems,
  13. the X Consortium, and MIT not be used in advertising or publicity 
  14. pertaining to distribution of the software without specific, written 
  15. prior permission.  
  16.  
  17. SUN MICROSYSTEMS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, 
  18. INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT 
  19. SHALL SUN MICROSYSTEMS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL 
  20. DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
  21. WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
  22. ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
  23. SOFTWARE.
  24. ******************************************************************/
  25.  
  26. #ifndef PHG_CPA_H_INCLUDED
  27. #define PHG_CPA_H_INCLUDED
  28.  
  29. /* Types for PHIGS/PEX CPA module. */
  30.  
  31. #ifdef DEBUG
  32. #define CPA_STRUCT_HASH_SIZE    10
  33. #else
  34. #define CPA_STRUCT_HASH_SIZE    100
  35. #endif
  36.  
  37. /* This value is the base structure id used in the encoding of the PEX
  38.  * structure ids.  It is added to the application's structure ids during
  39.  * the encoding.  This leaves the values below it available for ids not
  40.  * associated with structures.
  41.  */
  42. #define CPA_STRUCT_BASE_ID    100000
  43.  
  44. typedef struct Cpa_struct_data {
  45.     Pint            sid;
  46.     XID                xid;
  47.     struct Cpa_struct_data    *next;
  48. } Cpa_struct_data;
  49.  
  50. /* Structures are accessed by both the client and the PM.
  51.  * The client creates and deletes the structures, the PM just queries them
  52.  * and maps them to and from the application's structure ids.  In order to
  53.  * perform the translation correctly, the PM needs the resource shift and
  54.  * resource base of the display used by the client to create the
  55.  * structures.
  56.  */
  57. typedef struct { /* Data internal to the CPA module */
  58.     long        dpy_resource_base;    /* of the controlling dpy */
  59.     int            dpy_resource_shift;    /* of the controlling dpy */
  60.     Cpa_struct_data    *struct_lists[CPA_STRUCT_HASH_SIZE];
  61.     struct {
  62.     unsigned flush: 1;    /* must flush PEX buffer before returning */
  63.     }                flags;
  64.     Phg_scratch        scratch;
  65.     Widget        top_level;    /* only in PM */
  66.     struct {
  67.     XID    search_context;
  68.     XID    nrm_incl_filter;
  69.     XID    nrm_excl_filter;
  70.     XID    inv_incl_filter;
  71.     XID    inv_excl_filter;
  72.     }            iss_resources; /* to prevent always re-creating them */
  73. } Cp_a;
  74.  
  75. /* Then structure id encoding macros.  Note that they assume the
  76.  * application's structure id is positive.  A violation of this assumption
  77.  * isn't catastrophic, it will just put the PEX structure id outside the
  78.  * range reserved for them.
  79.  */
  80. #define CPA_ENCODE_STRUCT_ID( _css_srvr, _sid ) \
  81.     ((_css_srvr)->model.a.dpy_resource_base + ((CPA_STRUCT_BASE_ID + \
  82.     (_sid)) << (_css_srvr)->model.a.dpy_resource_shift))
  83.  
  84. #define CPA_DECODE_STRUCT_ID( _css_srvr, _xsid ) \
  85.     ((((_xsid) - (_css_srvr)->model.a.dpy_resource_base) >> \
  86.     (_css_srvr)->model.a.dpy_resource_shift) - CPA_STRUCT_BASE_ID) 
  87.  
  88. #define CPA_FIRST_STRUCT_ID( _css_srvr ) \
  89.     CPA_ENCODE_STRUCT_ID((_css_srvr), 0)
  90.  
  91. #define CPA_FOR_ALL_STRUCTS( _s, _st ) \
  92.     { register int _i; \
  93.     for ( (_i) = 0; (_i) < CPA_STRUCT_HASH_SIZE; (_i)++ ) { \
  94.     for ( (_st) = (_s)->model.a.struct_lists[_i]; \
  95.         (_st); (_st) = (_st)->next ) {
  96. #define CPA_END_FOR_ALL_STRUCTS    }}}
  97.  
  98. #define CPA_ALLOC_STRUCT(_sp) \
  99.     (_sp = (Cpa_struct_data*)calloc(1,sizeof(Cpa_struct_data)))
  100.  
  101. #define CPA_CREATE_OPEN_STRUCT( _cph, _css_srvr ) \
  102.     phg_cpa_create_struct( _cph, _css_srvr, (_cph)->psl->open_struct, \
  103.     &(_cph)->psl->edit_mode, (Pint)0 )
  104.  
  105. /* Request buffering:  There are two levels, workstation and server.  If
  106.  * a workstation is in WAIT/NIVE mode then strictly workstation-related
  107.  * requests can be buffered.  If all workstations on a server are in
  108.  * WAIT/NIVE mode then other requests can be buffered too.
  109.  */
  110. #define CPA_FLUSH( _css_srvr ) \
  111.     if ( (_css_srvr)->model.a.flags.flush ){_XFlush( (_css_srvr)->display );}
  112.  
  113. #define CPA_BUFFERING( _css_srvr ) ((_css_srvr)->model.a.flags.flush)
  114. #define CPA_WS_BUFFERING( _ws ) ((_ws)->flags.flush)
  115.  
  116. #define CPA_STRUCT_OP_CHECK    0
  117. #define CPA_STRUCT_OP_CREATE    1
  118. #define CPA_STRUCT_OP_REMOVE    2
  119. #define CPA_STRUCT_OP_DESTROY    3
  120.  
  121. /* CPA vector functions */
  122. extern    void        phg_cpa_add_el();
  123. extern    void        phg_cpa_ar_archive();
  124. extern  int        phg_cpa_check_struct_exists();
  125. extern    void        phg_cpa_change_struct_id();
  126. extern    void        phg_cpa_change_struct_refs();
  127. extern    void        phg_cpa_change_struct_idrefs();
  128. extern    void        phg_cpa_close();
  129. extern    void        phg_cpa_close_struct();
  130. extern    void        phg_cpa_close_ws();
  131. extern    void        phg_cpa_copy_all_els();
  132. extern    void        phg_cpa_delete_struct();
  133. extern    void        phg_cpa_delete_all_structs();
  134. extern    void        phg_cpa_delete_el();
  135. extern    void        phg_cpa_delete_struct_net();
  136. extern    void        phg_cpa_destroy();
  137. extern    void        phg_cpa_el_search();
  138. extern    void        phg_cpa_inc_spa_search();
  139. extern    void        phg_cpa_inq_colr_map_meth_st();
  140. extern    void        phg_cpa_inq_disp_update_state();
  141. extern    void        phg_cpa_inq_el_content();
  142. extern    void        phg_cpa_inq_el_type_size();
  143. extern    void        phg_cpa_inq_el_ptr();
  144. extern    void        phg_cpa_inq_filter();
  145. extern    void        phg_cpa_inq_hierarchy();
  146. extern    void        phg_cpa_inq_hlhsr_mode();
  147. extern    void        phg_cpa_inq_indices();
  148. extern    void        phg_cpa_inq_posted();
  149. extern    void        phg_cpa_inq_rep();
  150. extern    void        phg_cpa_inq_struct_status();
  151. extern    void        phg_cpa_inq_struct_ids();
  152. extern    void        phg_cpa_inq_text_extent();
  153. extern    void        phg_cpa_inq_view_rep();
  154. extern    void        phg_cpa_inq_win_info();
  155. extern    void        phg_cpa_inq_ws_xform();
  156. extern    void        phg_cpa_inq_wss_posted_to();
  157. extern    void        phg_cpa_open_struct();
  158. extern    Ws_handle    phg_cpa_open_ws();
  159. extern    void        phg_cpa_post_struct();
  160. extern    void        phg_cpa_ws_redraw_all();
  161. extern    void        phg_cpa_set_disp_state();
  162. extern    void        phg_cpa_set_edit_mode();
  163. extern    void        phg_cpa_set_el_ptr();
  164. extern    void        phg_cpa_set_filter();
  165. extern    void        phg_cpa_set_hlhsr_mode();
  166. extern    void        phg_cpa_set_rep();
  167. extern    void        phg_cpa_set_view_input_priority();
  168. extern    void        phg_cpa_set_ws_win();
  169. extern    void        phg_cpa_set_ws_vp();
  170. extern    void        phg_cpa_unpost_all();
  171. extern    void        phg_cpa_unpost_struct();
  172. extern    void        phg_cpa_ws_update();
  173. extern    void        phg_cpa_ws_drawable_pick();
  174. extern    void        phg_cpa_ws_map_points();
  175. extern    void        phg_cpa_ws_redraw_regions();
  176. extern    void        phg_cpa_ws_map_points();
  177. extern    void        phg_cpa_ws_synch();
  178.  
  179. /* PM functions */
  180. extern void        phg_cpa_pm_destroy();
  181. extern Ws_handle    phg_cpa_pm_open_ws();
  182. extern void        phg_cpa_pm_close_ws();
  183. extern    void        phg_cpa_pm_set_filter();
  184. extern    void        phg_cpa_pm_message();
  185.  
  186.  
  187. /* Structure and element utilities. */
  188. extern void        phg_cpa_free_structure_lists();
  189. extern void        phg_cpa_destroy_attached_structures();
  190. extern int        phg_cpa_build_struct_id_list();
  191. extern Cpa_struct_data*    phg_cpa_struct_exists();
  192. extern Cpa_struct_data*    phg_cpa_open_struct_in_list();
  193. extern int        phg_cpa_struct_list_empty();
  194. extern void        phg_cpa_link_struct();
  195. extern Cpa_struct_data*    phg_cpa_create_struct();
  196. extern int        phg_cpa_load_structures();
  197. extern int        phg_cpa_copy_struct_to_server();
  198.  
  199. #endif
  200.