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

  1. /* $XConsortium: sin.h,v 5.1 91/02/16 09:49:29 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 SIN_H_INCLUDED
  27. #define SIN_H_INCLUDED
  28.  
  29. #define SIN_TRUE    !0
  30. #define SIN_FALSE     0
  31.  
  32. typedef enum {
  33.     SIN_REQUEST,
  34.     SIN_REQUEST_PENDING,
  35.     SIN_EVENT,
  36.     SIN_SAMPLE
  37. } Sin_input_mode;
  38.  
  39. typedef enum {
  40.     SIN_LOCATOR  = 0,
  41.     SIN_PICK     = 1,
  42.     SIN_STROKE   = 2,
  43.     SIN_VALUATOR = 3,
  44.     SIN_CHOICE   = 4,
  45.     SIN_STRING   = 5
  46. } Sin_input_class;
  47.  
  48. typedef XPoint Sin_window_pt;
  49.  
  50. typedef struct {
  51.     Sin_window_pt   ll,
  52.                     ur;
  53. } Sin_window_rect;
  54.  
  55. typedef struct {
  56.     Wst_loc_type    type;
  57.     Sin_window_pt    cur_pos;
  58.     Sin_window_pt       init_pos;
  59.     Ppoint3        wc_pt;
  60.     int            view;
  61.     int            (*resolve)();
  62.     Pline_bundle    ln_bundl;
  63. } Sin_locator_device_data;
  64.  
  65. typedef struct {
  66.     Wst_pick_type    type;
  67.     Sin_window_pt       init_pos;
  68.     Sin_window_pt       cur_pos;
  69.     Ppick        init_pick;
  70.     Ppick        cur_pick;
  71.     caddr_t        client_data;
  72.     int            (*resolve)();
  73. } Sin_pick_device_data;
  74.  
  75. typedef struct {
  76.     Wst_stroke_type    type;
  77.     int            count;
  78.     int            init_count;
  79.     int            edit_pos;
  80.     int            buf_size;
  81.     Sin_window_pt    *init_pts;
  82.     Ppoint3        *wc_pts;
  83.     int            view;
  84.     int            (*resolve)();
  85.     Pline_bundle    ln_bundl;
  86.     Pmarker_bundle    mk_bundl;
  87. } Sin_stroke_device_data;
  88.  
  89. typedef struct {
  90.     Wst_val_type    type;
  91.     float        value;
  92.     float        init_value;
  93.     float        low, high;
  94.     char        *label;
  95.     char        *format;
  96.     char        *low_label;
  97.     char        *high_label;
  98. } Sin_valuator_device_data;
  99.  
  100. typedef struct {
  101.     Wst_choice_type    type;
  102.     int            init_choice;
  103.     int            cur_choice;    /* 0 ==> no choice */
  104.     int            count;        /* of choices */
  105.     union {
  106.     char            **strings;
  107.     Ppr_switch        *on_off;
  108.     }            choices;
  109. } Sin_choice_device_data;
  110.  
  111. typedef struct {
  112.     Wst_string_type    type;
  113.     int            buf_size;
  114.     int            edit_pos;
  115.     long        last_pos;
  116.     char        *init_string;
  117.     char        *string;
  118. } Sin_string_device_data;
  119.  
  120. typedef union {
  121.     Sin_locator_device_data    locator;
  122.     Sin_pick_device_data       pick;
  123.     Sin_stroke_device_data     stroke;
  124.     Sin_valuator_device_data   valuator;
  125.     Sin_choice_device_data     choice;
  126.     Sin_string_device_data     string;
  127. } Sin_device_data;
  128.  
  129. typedef struct {
  130.     caddr_t        client_data;
  131.     int                 pe_type;
  132.     Sin_window_rect     echo_area;
  133.     Sin_device_data     data;
  134. } Sin_dev_init_data;
  135.  
  136. typedef struct {
  137.     Sin_window_rect     echo_area;
  138.     union {
  139.     struct {
  140.         Sin_window_pt    init_pos;
  141.     } locator;
  142.     struct {
  143.         int            cnt;
  144.         Sin_window_pt    *init_pts;
  145.     } stroke;
  146.     }            data;
  147. } Sin_enable_data;
  148.  
  149. typedef struct {
  150.     Sin_input_class    class;
  151.     int            dev_num;
  152.     Sin_enable_data    *enable_data;
  153.     Sin_input_mode    mode;
  154.     int            echo;
  155. } Sin_set_mode_data;
  156.  
  157. typedef struct {
  158.     Widget      shell;
  159.     Widget      pane;
  160.     Widget      scrollbar;
  161.     Widget      value;
  162.     Widget      label;
  163.     Widget      low;
  164.     Widget      high;
  165. } Sin_valuator_handle;
  166.  
  167. typedef struct {
  168.     Widget      shell;
  169.     Widget      viewport;
  170.     Widget      list;
  171. } Sin_choice_handle;
  172.  
  173. typedef struct {
  174.     Widget      shell;
  175.     Widget      pane;
  176.     Widget      textw;
  177. } Sin_string_handle;
  178.  
  179. typedef union {
  180.     Widget              widget;
  181.     Window          window;
  182.     Sin_valuator_handle valuator;
  183.     Sin_choice_handle   choice;
  184.     Sin_string_handle   string;
  185. } Sin_item_handle;
  186.  
  187. typedef struct {
  188.     int        (*create)();
  189.     void    (*reset)();
  190.     void    (*enable)();
  191.     void    (*disable)();
  192.     int        (*init)();
  193.     void    (*sample)();
  194.     void    (*resize)();
  195.     void    (*repaint)();
  196.     void    (*destroy)();
  197. } Sin_device_ops;
  198.  
  199. typedef struct _Sin_input_ws    *Sin_handle;
  200.  
  201. typedef struct Sin_input_device {
  202.     int                 wsid;
  203.     Sin_handle          ws;
  204.     int                 num;
  205.     Sin_input_class     class;
  206.     Sin_input_mode      mode;
  207.     int                 pe_type;
  208.     int                 echo_sw;
  209.     Sin_window_rect     echo_area;
  210.     Sin_item_handle    item_handle;
  211.     Sin_device_data     data;
  212.     Sin_device_ops      dev_ops;
  213.     char        *client_data;
  214.     struct {
  215.     unsigned on: 1;
  216.     unsigned buffered : 1;
  217.     unsigned exists : 1;
  218.     unsigned been_up_yet : 1;
  219.     }                flags;
  220. } Sin_input_device;
  221.  
  222. typedef struct {
  223.     void    (*send_request)();
  224.     int        (*in_viewport)();
  225. } Sin_ws_ops;
  226.  
  227. typedef struct {
  228.     unsigned        flags;
  229. #define SIN_EVT_ACKNOWLEDGE    0x0001
  230.     int            count;
  231.     int            size;
  232.     Sin_input_device    **devs;
  233. } Sin_buf_data;
  234.  
  235. #define SIN_WS_RESET_EVENT_BUFFER( _ev ) \
  236.     (_ev)->flags = 0, (_ev)->count = 0
  237.  
  238. #define SIN_WS_SET_ACKNOWLEDGE( _ws ) \
  239.     (_ws)->event_buffer.flags |= SIN_EVT_ACKNOWLEDGE
  240.  
  241. typedef struct Sin_notify_data {
  242.     Window                      window;
  243.     caddr_t                     handle;
  244.     void                        (*notify)();
  245.     struct Sin_notify_data      *next;
  246. } Sin_notify_data;
  247.  
  248. #include "sin_q.h"
  249.  
  250. typedef struct _Sin_input_ws {
  251.     Err_handle        erh;
  252.     int                 wsid;
  253.     Ws_handle        wsh;
  254.     Wst_input_wsdt    *idt;
  255.     Sin_event_queue    *queue;
  256.     Sin_input_device    *break_device;
  257.     Display        *display;
  258.     Window              input_window;
  259.     Window              output_window;
  260.     Widget        shell;
  261.     Sin_ws_ops        ops;
  262.     Sin_buf_data    event_buffer;    /* holds simultaneous events */
  263.     Sin_notify_data    *notify_list;
  264.     Pnum_in        num_devs;
  265.     Sin_input_device    *devices[6];    /* pointers to arrays of devices */
  266.     struct Sin_window_table    *window_table;
  267. } Sin_input_ws;
  268.  
  269. typedef struct {
  270.     Sin_event_queue    *queue;
  271.     Display        *display;
  272.     Window              output_window;
  273.     Window              input_window;
  274.     Widget        shell;
  275.     Ws_handle        wsh;
  276.     Wst_input_wsdt    *idt;
  277.     void                (*send_request)();
  278.     int            (*in_viewport)();
  279. } Sin_desc;
  280.  
  281. /* The context id for Xt input devices. */
  282. extern XContext        phg_sin_device_context_id;
  283.  
  284. extern Sin_handle    phg_sin_create();
  285. extern void        phg_sin_close();
  286. extern void        phg_sin_dev_stop();
  287. extern void        phg_sin_init_device();
  288. extern void        phg_sin_set_mode();
  289. extern void        phg_sin_repaint();
  290. extern void        phg_sin_resize_dev();
  291. extern void        phg_sin_request();
  292. extern void        phg_sin_sample();
  293.  
  294. /* Xt action procs for input. */
  295. extern XtActionProc    phg_sin_xt_request_satisfied();
  296. extern XtActionProc    phg_sin_xt_string_event();
  297.  
  298. #define SIN_CLASS_INDEX( class) \
  299.     ((int)(class))
  300.  
  301. #define SIN_DEV( ws, class, num) \
  302.     (&(ws)->devices[SIN_CLASS_INDEX(class)][(num)-1])
  303.  
  304. #define SIN_TO_PHIGS_CLASS( _c ) \
  305.     ((_c) == SIN_LOCATOR ? PIN_LOC \
  306.     : (_c) == SIN_STROKE ? PIN_STROKE \
  307.         : (_c) == SIN_PICK ? PIN_PICK \
  308.         : (_c) == SIN_VALUATOR ? PIN_VAL \
  309.             : (_c) == SIN_CHOICE ? PIN_CHOICE : PIN_STRING)
  310.  
  311. #define SIN_PHIGS_TO_SIN_CLASS( _c ) \
  312.     ((_c) == PIN_LOC ? SIN_LOCATOR \
  313.     : (_c) == PIN_STROKE ? SIN_STROKE \
  314.         : (_c) == PIN_PICK ? SIN_PICK \
  315.         : (_c) == PIN_VAL ? SIN_VALUATOR \
  316.             : (_c) == PIN_CHOICE ? SIN_CHOICE : SIN_STRING)
  317.  
  318. #define SIN_DEV_EXISTS( _dev ) \
  319.     ((_dev) && (_dev)->flags.exists)
  320.  
  321. #define SIN_EA_WIDTH( _ea ) ((_ea)->ur.x - (_ea)->ll.x)
  322. #define SIN_EA_HEIGHT( _ea ) ((_ea)->ll.y - (_ea)->ur.y)
  323. #define SIN_EA_X( _ea ) ((_ea)->ll.x)
  324. #define SIN_EA_Y( _ea ) ((_ea)->ur.y)
  325.  
  326. #endif
  327.