home *** CD-ROM | disk | FTP | other *** search
/ ftp.cs.arizona.edu / ftp.cs.arizona.edu.tar / ftp.cs.arizona.edu / icon / historic / v941.tgz / icon.v941src.tar / icon.v941src / src / common / xwindow.c < prev    next >
C/C++ Source or Header  |  2001-12-12  |  5KB  |  179 lines

  1. /*
  2.  * xwindow.c - X Window System-specific routines
  3.  */
  4. #include "../h/define.h"
  5. #include "../h/config.h"
  6. #ifdef XWindows
  7.  
  8. typedef struct {
  9.   char *s;
  10.   int i;
  11. } stringint, *siptr;
  12.  
  13. #if !VMS
  14.    #undef VMS
  15. #endif                    /* VMS */
  16.  
  17. #if VMS
  18.    #undef UNIX
  19.    #ifdef XpmFormat
  20.       #include "../xpm/xpm.h"
  21.    #endif                /* XpmFormat */
  22.    #include "decw$include:Xlib.h"
  23.    #include "decw$include:Xutil.h"
  24.    #include "decw$include:Xos.h"
  25.    #include "decw$include:Xatom.h"
  26.    #include "decw$include:cursorfont.h"
  27.    #include "decw$include:keysym.h"
  28.    #define UNIX 0
  29. #else                    /* VMS */
  30.    #ifdef XpmFormat
  31.       #include "../xpm/xpm.h"
  32.    #else                /* XpmFormat */
  33.       #include <X11/Xlib.h>
  34.       #include <X11/Xutil.h>
  35.    #endif                /* XpmFormat */
  36.    #include <X11/Xos.h>
  37.    #include <X11/Xatom.h>
  38.    #include <X11/cursorfont.h>
  39.    #include <X11/keysym.h>
  40. #endif                    /* VMS */
  41.  
  42. int GraphicsHome  = XK_Home;
  43. int GraphicsLeft  = XK_Left;
  44. int GraphicsUp    = XK_Up;
  45. int GraphicsRight = XK_Right;
  46. int GraphicsDown  = XK_Down;
  47. int GraphicsPrior = XK_Prior;
  48. int GraphicsNext  = XK_Next;
  49. int GraphicsEnd   = XK_End;
  50.  
  51. /*
  52.  * Translate a key event.  Put ascii result if any in s.
  53.  * Return number of ascii (>0) if the key was "normal" and s is filled in.
  54.  * Return 0 if the key was strange and keysym should be returned.
  55.  * Return -1 if the key was a modifier key and should be dropped.
  56.  */
  57. int translate_key_event(event, s, k)
  58. XKeyEvent *event;
  59. char *s;
  60. KeySym *k;
  61. {
  62.    int i = XLookupString(event, s, 10, k, NULL);
  63.  
  64.    if (i > 0)
  65.       return i;            /* "normal" key */
  66.    else if (IsModifierKey(*k))
  67.       return -1;        /* modifier key */
  68.    else
  69.       return 0;            /* other (e.g. function key) */
  70. }
  71.  
  72. stringint drawops[] = {
  73.    { 0, 16},
  74.    {"and",        GXand},
  75.    {"andInverted",    GXandInverted},
  76.    {"andReverse",    GXandReverse},
  77.    {"clear",        GXclear},
  78.    {"copy",        GXcopy},
  79.    {"copyInverted",    GXcopyInverted},
  80.    {"equiv",        GXequiv},
  81.    {"invert",        GXinvert},
  82.    {"nand",        GXnand},
  83.    {"noop",        GXnoop},
  84.    {"nor",        GXnor},
  85.    {"or",        GXor},
  86.    {"orInverted",    GXorInverted},
  87.    {"orReverse",    GXorReverse},
  88.    {"set",        GXset},
  89.    {"xor",        GXxor},
  90. };
  91.  
  92. #define NUMCURSORSYMS    78
  93.  
  94. stringint cursorsyms[] = {
  95.   { 0, NUMCURSORSYMS},
  96.   {"X cursor",        XC_X_cursor},
  97.   {"arrow",        XC_arrow},
  98.   {"based arrow down",    XC_based_arrow_down},
  99.   {"based arrow up",    XC_based_arrow_up},
  100.   {"boat",        XC_boat},
  101.   {"bogosity",        XC_bogosity},
  102.   {"bottom left corner",XC_bottom_left_corner},
  103.   {"bottom right corner",XC_bottom_right_corner},
  104.   {"bottom side",    XC_bottom_side},
  105.   {"bottom tee",    XC_bottom_tee},
  106.   {"box spiral",    XC_box_spiral},
  107.   {"center ptr",    XC_center_ptr},
  108.   {"circle",        XC_circle},
  109.   {"clock",        XC_clock},
  110.   {"coffee mug",    XC_coffee_mug},
  111.   {"cross",        XC_cross},
  112.   {"cross reverse",    XC_cross_reverse},
  113.   {"crosshair",        XC_crosshair},
  114.   {"diamond cross",    XC_diamond_cross},
  115.   {"dot",        XC_dot},
  116.   {"dotbox",        XC_dotbox},
  117.   {"double arrow",    XC_double_arrow},
  118.   {"draft large",    XC_draft_large},
  119.   {"draft small",    XC_draft_small},
  120.   {"draped box",    XC_draped_box},
  121.   {"exchange",        XC_exchange},
  122.   {"fleur",        XC_fleur},
  123.   {"gobbler",        XC_gobbler},
  124.   {"gumby",        XC_gumby},
  125.   {"hand1",        XC_hand1},
  126.   {"hand2",        XC_hand2},
  127.   {"heart",        XC_heart},
  128.   {"icon",        XC_icon},
  129.   {"iron cross",    XC_iron_cross},
  130.   {"left ptr",        XC_left_ptr},
  131.   {"left side",        XC_left_side},
  132.   {"left tee",        XC_left_tee},
  133.   {"leftbutton",    XC_leftbutton},
  134.   {"ll angle",        XC_ll_angle},
  135.   {"lr angle",        XC_lr_angle},
  136.   {"man",        XC_man},
  137.   {"middlebutton",    XC_middlebutton},
  138.   {"mouse",        XC_mouse},
  139.   {"pencil",        XC_pencil},
  140.   {"pirate",        XC_pirate},
  141.   {"plus",        XC_plus},
  142.   {"question arrow",    XC_question_arrow},
  143.   {"right ptr",        XC_right_ptr},
  144.   {"right side",    XC_right_side},
  145.   {"right tee",        XC_right_tee},
  146.   {"rightbutton",    XC_rightbutton},
  147.   {"rtl logo",        XC_rtl_logo},
  148.   {"sailboat",        XC_sailboat},
  149.   {"sb down arrow",    XC_sb_down_arrow},
  150.   {"sb h double arrow",    XC_sb_h_double_arrow},
  151.   {"sb left arrow",    XC_sb_left_arrow},
  152.   {"sb right arrow",    XC_sb_right_arrow},
  153.   {"sb up arrow",    XC_sb_up_arrow},
  154.   {"sb v double arrow",    XC_sb_v_double_arrow},
  155.   {"shuttle",        XC_shuttle},
  156.   {"sizing",        XC_sizing},
  157.   {"spider",        XC_spider},
  158.   {"spraycan",        XC_spraycan},
  159.   {"star",        XC_star},
  160.   {"target",        XC_target},
  161.   {"tcross",        XC_tcross},
  162.   {"top left arrow",    XC_top_left_arrow},
  163.   {"top left corner",    XC_top_left_corner},
  164.   {"top right corner",    XC_top_right_corner},
  165.   {"top side",        XC_top_side},
  166.   {"top tee",        XC_top_tee},
  167.   {"trek",        XC_trek},
  168.   {"ul angle",        XC_ul_angle},
  169.   {"umbrella",        XC_umbrella},
  170.   {"ur angle",        XC_ur_angle},
  171.   {"watch",        XC_watch},
  172.   {"xterm",        XC_xterm},
  173.   {"num glyphs",    XC_num_glyphs},
  174. };
  175.  
  176. #else                    /* XWindows */
  177.   static char x;
  178. #endif                    /* XWindows */
  179.