home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Source Code / C / Libraries / stdwin / Ports / x11 / cursor.c < prev    next >
Encoding:
C/C++ Source or Header  |  1990-10-18  |  5.1 KB  |  156 lines  |  [TEXT/????]

  1. /* This was copied from the standard X11R4 client twm and then changed */
  2.  
  3. /*
  4.  * Copyright 1989 Massachusetts Institute of Technology
  5.  *
  6.  * Permission to use, copy, modify, and distribute this software and its
  7.  * documentation for any purpose and without fee is hereby granted, provided
  8.  * that the above copyright notice appear in all copies and that both that
  9.  * copyright notice and this permission notice appear in supporting
  10.  * documentation, and that the name of M.I.T. not be used in advertising
  11.  * or publicity pertaining to distribution of the software without specific,
  12.  * written prior permission.  M.I.T. makes no representations about the
  13.  * suitability of this software for any purpose.  It is provided "as is"
  14.  * without express or implied warranty.
  15.  *
  16.  * M.I.T. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
  17.  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL M.I.T.
  18.  * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  19.  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
  20.  * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 
  21.  * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  22.  */
  23.  
  24. /***********************************************************************
  25.  *
  26.  * $XConsortium: cursor.c,v 1.10 89/12/14 14:52:23 jim Exp $
  27.  *
  28.  * cursor creation code
  29.  *
  30.  * 05-Apr-89 Thomas E. LaStrange    File created
  31.  *
  32.  ***********************************************************************/
  33.  
  34. #include "x11.h"
  35.  
  36. static struct _CursorName {
  37.     char        *name;
  38.     unsigned int    shape;
  39.     Cursor        cursor;
  40. } cursor_names[] = {
  41.  
  42. {"X_cursor",        XC_X_cursor,        None},
  43. {"arrow",        XC_arrow,        None},
  44. {"based_arrow_down",    XC_based_arrow_down,    None},
  45. {"based_arrow_up",    XC_based_arrow_up,      None},
  46. {"boat",        XC_boat,        None},
  47. {"bogosity",        XC_bogosity,        None},
  48. {"bottom_left_corner",    XC_bottom_left_corner,  None},
  49. {"bottom_right_corner",    XC_bottom_right_corner, None},
  50. {"bottom_side",        XC_bottom_side,        None},
  51. {"bottom_tee",        XC_bottom_tee,        None},
  52. {"box_spiral",        XC_box_spiral,        None},
  53. {"center_ptr",        XC_center_ptr,        None},
  54. {"circle",        XC_circle,        None},
  55. {"clock",        XC_clock,        None},
  56. {"coffee_mug",        XC_coffee_mug,        None},
  57. {"cross",        XC_cross,        None},
  58. {"cross_reverse",    XC_cross_reverse,       None},
  59. {"crosshair",        XC_crosshair,        None},
  60. {"diamond_cross",    XC_diamond_cross,       None},
  61. {"dot",            XC_dot,            None},
  62. {"dotbox",        XC_dotbox,        None},
  63. {"double_arrow",    XC_double_arrow,    None},
  64. {"draft_large",        XC_draft_large,        None},
  65. {"draft_small",        XC_draft_small,        None},
  66. {"draped_box",        XC_draped_box,        None},
  67. {"exchange",        XC_exchange,        None},
  68. {"fleur",        XC_fleur,        None},
  69. {"gobbler",        XC_gobbler,        None},
  70. {"gumby",        XC_gumby,        None},
  71. {"hand1",        XC_hand1,        None},
  72. {"hand2",        XC_hand2,        None},
  73. {"heart",        XC_heart,        None},
  74. {"ibeam",        XC_xterm,        None}, /* Mac stdwin compat */
  75. {"icon",        XC_icon,        None},
  76. {"iron_cross",        XC_iron_cross,        None},
  77. {"left_ptr",        XC_left_ptr,        None},
  78. {"left_side",        XC_left_side,        None},
  79. {"left_tee",        XC_left_tee,        None},
  80. {"leftbutton",        XC_leftbutton,        None},
  81. {"ll_angle",        XC_ll_angle,        None},
  82. {"lr_angle",        XC_lr_angle,        None},
  83. {"man",            XC_man,            None},
  84. {"middlebutton",    XC_middlebutton,    None},
  85. {"mouse",        XC_mouse,        None},
  86. {"pencil",        XC_pencil,        None},
  87. {"pirate",        XC_pirate,        None},
  88. {"plus",        XC_plus,        None},
  89. {"question_arrow",    XC_question_arrow,    None},
  90. {"right_ptr",        XC_right_ptr,        None},
  91. {"right_side",        XC_right_side,        None},
  92. {"right_tee",        XC_right_tee,        None},
  93. {"rightbutton",        XC_rightbutton,        None},
  94. {"rtl_logo",        XC_rtl_logo,        None},
  95. {"sailboat",        XC_sailboat,        None},
  96. {"sb_down_arrow",    XC_sb_down_arrow,       None},
  97. {"sb_h_double_arrow",    XC_sb_h_double_arrow,   None},
  98. {"sb_left_arrow",    XC_sb_left_arrow,       None},
  99. {"sb_right_arrow",    XC_sb_right_arrow,      None},
  100. {"sb_up_arrow",        XC_sb_up_arrow,        None},
  101. {"sb_v_double_arrow",    XC_sb_v_double_arrow,   None},
  102. {"shuttle",        XC_shuttle,        None},
  103. {"sizing",        XC_sizing,        None},
  104. {"spider",        XC_spider,        None},
  105. {"spraycan",        XC_spraycan,        None},
  106. {"star",        XC_star,        None},
  107. {"target",        XC_target,        None},
  108. {"tcross",        XC_tcross,        None},
  109. {"top_left_arrow",    XC_top_left_arrow,      None},
  110. {"top_left_corner",    XC_top_left_corner,    None},
  111. {"top_right_corner",    XC_top_right_corner,    None},
  112. {"top_side",        XC_top_side,        None},
  113. {"top_tee",        XC_top_tee,        None},
  114. {"trek",        XC_trek,        None},
  115. {"ul_angle",        XC_ul_angle,        None},
  116. {"umbrella",        XC_umbrella,        None},
  117. {"ur_angle",        XC_ur_angle,        None},
  118. {"watch",        XC_watch,        None},
  119. {"xterm",        XC_xterm,        None},
  120. };
  121.  
  122. static
  123. NewFontCursor (dpy, cp, str)
  124.     Display *dpy;
  125.     Cursor *cp;
  126.     char *str;
  127. {
  128.     int i;
  129.  
  130.     for (i = 0; i < sizeof(cursor_names)/sizeof(struct _CursorName); i++)
  131.     {
  132.     if (strcmp(str, cursor_names[i].name) == 0)
  133.     {
  134.         if (cursor_names[i].cursor == None)
  135.         cursor_names[i].cursor = XCreateFontCursor(dpy,
  136.             cursor_names[i].shape);
  137.         *cp = cursor_names[i].cursor;
  138.         return;
  139.     }
  140.     }
  141.     _wwarning("NewFontCursor: unable to find font cursor \"%s\"", str);
  142.     *cp = None;
  143. }
  144.  
  145. CURSOR *
  146. wfetchcursor(name)
  147.     char *name;
  148. {
  149.     Cursor c;
  150.     NewFontCursor(_wd, &c, name);
  151.     if (c == None)
  152.         return NULL;
  153.     else
  154.         return (CURSOR *)c;
  155. }
  156.