home *** CD-ROM | disk | FTP | other *** search
/ IRIX Base Documentation 2002 November / SGI IRIX Base Documentation 2002 November.iso / usr / share / catman / u_man / cat3 / Tk / getcursor.z / getcursor
Encoding:
Text File  |  2002-10-03  |  14.3 KB  |  265 lines

  1.  
  2.  
  3.  
  4. TTTTkkkk____GGGGeeeettttCCCCuuuurrrrssssoooorrrr((((3333TTTTkkkk))))                                            TTTTkkkk____GGGGeeeettttCCCCuuuurrrrssssoooorrrr((((3333TTTTkkkk))))
  5.  
  6.  
  7.  
  8. NNNNAAAAMMMMEEEE
  9.      Tk_GetCursor, Tk_GetCursorFromData, Tk_NameOfCursor, Tk_FreeCursor -
  10.      maintain database of cursors
  11.  
  12. SSSSYYYYNNNNOOOOPPPPSSSSIIIISSSS
  13.      ####iiiinnnncccclllluuuuddddeeee <<<<ttttkkkk....hhhh>>>>
  14.  
  15.      Cursor
  16.      TTTTkkkk____GGGGeeeettttCCCCuuuurrrrssssoooorrrr((((_i_n_t_e_r_p, _t_k_w_i_n, _n_a_m_e_I_d))))
  17.  
  18.      Cursor
  19.      TTTTkkkk____GGGGeeeettttCCCCuuuurrrrssssoooorrrrFFFFrrrroooommmmDDDDaaaattttaaaa((((_i_n_t_e_r_p, _t_k_w_i_n, _s_o_u_r_c_e, _m_a_s_k, _w_i_d_t_h, _h_e_i_g_h_t,
  20.       _x_H_o_t, _y_H_o_t, _f_g, _b_g))))
  21.  
  22.      char *
  23.      TTTTkkkk____NNNNaaaammmmeeeeOOOOffffCCCCuuuurrrrssssoooorrrr((((_d_i_s_p_l_a_y, _c_u_r_s_o_r))))
  24.  
  25.      TTTTkkkk____FFFFrrrreeeeeeeeCCCCuuuurrrrssssoooorrrr((((_d_i_s_p_l_a_y, _c_u_r_s_o_r))))
  26.  
  27. AAAARRRRGGGGUUUUMMMMEEEENNNNTTTTSSSS
  28.      Tcl_Interp      *_i_n_t_e_r_p     (in)      Interpreter to use for error
  29.                                            reporting.
  30.  
  31.      Tk_Window       _t_k_w_i_n       (in)      Token for window in which the
  32.                                            cursor will be used.
  33.  
  34.      Tk_Uid          _n_a_m_e_I_d      (in)      Description of cursor;  see below
  35.                                            for possible values.
  36.  
  37.      char            *_s_o_u_r_c_e     (in)      Data for cursor bitmap, in standard
  38.                                            bitmap format.
  39.  
  40.      char            *_m_a_s_k       (in)      Data for mask bitmap, in standard
  41.                                            bitmap format.
  42.  
  43.      int             _w_i_d_t_h       (in)      Width of _s_o_u_r_c_e and _m_a_s_k.          |
  44.  
  45.      int             _h_e_i_g_h_t      (in)      Height of _s_o_u_r_c_e and _m_a_s_k.         |
  46.  
  47.      int             _x_H_o_t        (in)      X-location of cursor hot-spot.     |
  48.  
  49.      int             _y_H_o_t        (in)      Y-location of cursor hot-spot.     |
  50.  
  51.      Tk_Uid          _f_g          (in)      Textual description of foreground
  52.                                            color for cursor.
  53.  
  54.      Tk_Uid          _b_g          (in)      Textual description of background
  55.                                            color for cursor.
  56.  
  57.      Display         *_d_i_s_p_l_a_y    (in)      Display for which _c_u_r_s_o_r was
  58.                                            allocated.
  59.  
  60.  
  61.  
  62.  
  63.                                                                         PPPPaaaaggggeeee 1111
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70. TTTTkkkk____GGGGeeeettttCCCCuuuurrrrssssoooorrrr((((3333TTTTkkkk))))                                            TTTTkkkk____GGGGeeeettttCCCCuuuurrrrssssoooorrrr((((3333TTTTkkkk))))
  71.  
  72.  
  73.  
  74.      Cursor          _c_u_r_s_o_r      (in)      X identifier for cursor.  If passed
  75.                                            toTTTTkkkk____FFFFrrrreeeeeeeeCCCCuuuurrrrssssoooorrrr, must have been
  76.                                            returned by some previous call to
  77.                                            TTTTkkkk____GGGGeeeettttCCCCuuuurrrrssssoooorrrr or
  78.                                            TTTTkkkk____GGGGeeeettttCCCCuuuurrrrssssoooorrrrFFFFrrrroooommmmDDDDaaaattttaaaa.
  79.  
  80.  
  81. DDDDEEEESSSSCCCCRRRRIIIIPPPPTTTTIIIIOOOONNNN
  82.      These procedures manage a collection of cursors being used by an
  83.      application.  The procedures allow cursors to be re-used efficiently,
  84.      thereby avoiding server overhead, and also allow cursors to be named with
  85.      character strings (actually Tk_Uids).
  86.  
  87.      TTTTkkkk____GGGGeeeettttCCCCuuuurrrrssssoooorrrr takes as argument a Tk_Uid describing a cursor, and returns
  88.      the X identifier for a cursor corresponding to the description.  It re-
  89.      uses an existing cursor if possible and creates a new one otherwise.
  90.      _N_a_m_e_I_d must be a standard Tcl list with one of the following forms:
  91.  
  92.      _n_a_m_e  [_f_g_C_o_l_o_r  [_b_g_C_o_l_o_r]]
  93.           _N_a_m_e is the name of a cursor in the standard X cursor font, i.e.,
  94.           any of the names defined in ccccuuuurrrrssssoooorrrrffffoooonnnntttt....hhhh, without the XXXXCCCC____.  Some
  95.           example values are XXXX____ccccuuuurrrrssssoooorrrr, hhhhaaaannnndddd2222, or lllleeeefffftttt____ppppttttrrrr.  Appendix B of
  96.           ``The X Window System'' by Scheifler & Gettys has illustrations
  97.           showing what each of these cursors looks like.  If _f_g_C_o_l_o_r and
  98.           _b_g_C_o_l_o_r are both specified, they give the foreground and background
  99.           colors to use for the cursor (any of the forms acceptable to
  100.           TTTTkkkk____GGGGeeeettttCCCCoooolllloooorrrr may be used).  If only _f_g_C_o_l_o_r is specified, then there
  101.           will be no background color:  the background will be transparent.
  102.           If no colors are specified, then the cursor will use black for its
  103.           foreground color and white for its background color.
  104.  
  105.      @@@@_s_o_u_r_c_e_N_a_m_e  _m_a_s_k_N_a_m_e  _f_g_C_o_l_o_r  _b_g_C_o_l_o_r
  106.           In this form, _s_o_u_r_c_e_N_a_m_e and _m_a_s_k_N_a_m_e are the names of files
  107.           describing bitmaps for the cursor's source bits and mask.  Each file
  108.           must be in standard X11 or X10 bitmap format.  _F_g_C_o_l_o_r and _b_g_C_o_l_o_r
  109.           indicate the colors to use for the cursor, in any of the forms
  110.           acceptable to TTTTkkkk____GGGGeeeettttCCCCoooolllloooorrrr.
  111.  
  112.      @@@@_s_o_u_r_c_e_N_a_m_e  _f_g_C_o_l_o_r
  113.           This form is similar to the one above, except that the source is
  114.           used as mask also.  This means that the cursor's background is
  115.           transparent.
  116.  
  117.      TTTTkkkk____GGGGeeeettttCCCCuuuurrrrssssoooorrrrFFFFrrrroooommmmDDDDaaaattttaaaa allows cursors to be created from in-memory
  118.      descriptions of their source and mask bitmaps.  _S_o_u_r_c_e points to standard
  119.      bitmap data for the cursor's source bits, and _m_a_s_k points to standard
  120.      bitmap data describing which pixels of _s_o_u_r_c_e are to be drawn and which
  121.      are to be considered transparent.  _W_i_d_t_h and _h_e_i_g_h_t give the dimensions
  122.      of the cursor, _x_H_o_t and _y_H_o_t indicate the location of the cursor's hot-
  123.      spot (the point that is reported when an event occurs), and _f_g and _b_g
  124.      describe the cursor's foreground and background colors textually (any of
  125.      the forms suitable for TTTTkkkk____GGGGeeeettttCCCCoooolllloooorrrr may be used).  Typically, the
  126.  
  127.  
  128.  
  129.                                                                         PPPPaaaaggggeeee 2222
  130.  
  131.  
  132.  
  133.  
  134.  
  135.  
  136. TTTTkkkk____GGGGeeeettttCCCCuuuurrrrssssoooorrrr((((3333TTTTkkkk))))                                            TTTTkkkk____GGGGeeeettttCCCCuuuurrrrssssoooorrrr((((3333TTTTkkkk))))
  137.  
  138.  
  139.  
  140.      arguments to TTTTkkkk____GGGGeeeettttCCCCuuuurrrrssssoooorrrrFFFFrrrroooommmmDDDDaaaattttaaaa are created by including a cursor file
  141.      directly into the source code for a program, as in the following example:
  142.           Cursor cursor;
  143.           #include "source.cursor"
  144.           #include "mask.cursor"
  145.           cursor = Tk_GetCursorFromData(interp, tkwin, source_bits,
  146.                           mask_bits, source_width, source_height, source_x_hot,
  147.                           source_y_hot, Tk_GetUid("red"), Tk_GetUid("blue"));
  148.  
  149.      Under normal conditions, TTTTkkkk____GGGGeeeettttCCCCuuuurrrrssssoooorrrr and TTTTkkkk____GGGGeeeettttCCCCuuuurrrrssssoooorrrrFFFFrrrroooommmmDDDDaaaattttaaaa will
  150.      return an identifier for the requested cursor.  If an error occurs in
  151.      creating the cursor, such as when _n_a_m_e_I_d refers to a non-existent file,
  152.      then NNNNoooonnnneeee is returned and an error message will be stored in _i_n_t_e_r_p-
  153.      >_r_e_s_u_l_t.
  154.  
  155.      TTTTkkkk____GGGGeeeettttCCCCuuuurrrrssssoooorrrr and TTTTkkkk____GGGGeeeettttCCCCuuuurrrrssssoooorrrrFFFFrrrroooommmmDDDDaaaattttaaaa maintain a database of all the
  156.      cursors they have created.  Whenever possible, a call to TTTTkkkk____GGGGeeeettttCCCCuuuurrrrssssoooorrrr or
  157.      TTTTkkkk____GGGGeeeettttCCCCuuuurrrrssssoooorrrrFFFFrrrroooommmmDDDDaaaattttaaaa will return an existing cursor rather than creating
  158.      a new one.  This approach can substantially reduce server overhead, so
  159.      the Tk procedures should generally be used in preference to Xlib
  160.      procedures like XXXXCCCCrrrreeeeaaaatttteeeeFFFFoooonnnnttttCCCCuuuurrrrssssoooorrrr or XXXXCCCCrrrreeeeaaaatttteeeePPPPiiiixxxxmmmmaaaappppCCCCuuuurrrrssssoooorrrr, which create a
  161.      new cursor on each call.
  162.  
  163.      The procedure TTTTkkkk____NNNNaaaammmmeeeeOOOOffffCCCCuuuurrrrssssoooorrrr is roughly the inverse of TTTTkkkk____GGGGeeeettttCCCCuuuurrrrssssoooorrrr.  If
  164.      its _c_u_r_s_o_r argument was created by TTTTkkkk____GGGGeeeettttCCCCuuuurrrrssssoooorrrr, then the return value is
  165.      the _n_a_m_e_I_d argument that was passed to TTTTkkkk____GGGGeeeettttCCCCuuuurrrrssssoooorrrr to create the cursor.
  166.      If _c_u_r_s_o_r was created by a call to TTTTkkkk____GGGGeeeettttCCCCuuuurrrrssssoooorrrrFFFFrrrroooommmmDDDDaaaattttaaaa, or by any other
  167.      mechanism, then the return value is a hexadecimal string giving the X
  168.      identifier for the cursor.  Note:  the string returned by TTTTkkkk____NNNNaaaammmmeeeeOOOOffffCCCCuuuurrrrssssoooorrrr
  169.      is only guaranteed to persist until the next call to TTTTkkkk____NNNNaaaammmmeeeeOOOOffffCCCCuuuurrrrssssoooorrrr.
  170.  
  171.      When a cursor returned by TTTTkkkk____GGGGeeeettttCCCCuuuurrrrssssoooorrrr or TTTTkkkk____GGGGeeeettttCCCCuuuurrrrssssoooorrrrFFFFrrrroooommmmDDDDaaaattttaaaa is no
  172.      longer needed, TTTTkkkk____FFFFrrrreeeeeeeeCCCCuuuurrrrssssoooorrrr should be called to release it.  There
  173.      should be exactly one call to TTTTkkkk____FFFFrrrreeeeeeeeCCCCuuuurrrrssssoooorrrr for each call to TTTTkkkk____GGGGeeeettttCCCCuuuurrrrssssoooorrrr
  174.      or TTTTkkkk____GGGGeeeettttCCCCuuuurrrrssssoooorrrrFFFFrrrroooommmmDDDDaaaattttaaaa.  When a cursor is no longer in use anywhere
  175.      (i.e. it has been freed as many times as it has been gotten)
  176.      TTTTkkkk____FFFFrrrreeeeeeeeCCCCuuuurrrrssssoooorrrr will release it to the X server and remove it from the
  177.      database.
  178.  
  179.  
  180. BBBBUUUUGGGGSSSS
  181.      In determining whether an existing cursor can be used to satisfy a new
  182.      request, TTTTkkkk____GGGGeeeettttCCCCuuuurrrrssssoooorrrr and TTTTkkkk____GGGGeeeettttCCCCuuuurrrrssssoooorrrrFFFFrrrroooommmmDDDDaaaattttaaaa consider only the
  183.      immediate values of their arguments.  For example, when a file name is
  184.      passed to TTTTkkkk____GGGGeeeettttCCCCuuuurrrrssssoooorrrr, TTTTkkkk____GGGGeeeettttCCCCuuuurrrrssssoooorrrr will assume it is safe to re-use an
  185.      existing cursor created from the same file name:  it will not check to
  186.      see whether the file itself has changed, or whether the current directory
  187.      has changed, thereby causing the name to refer to a different file.
  188.      Similarly, TTTTkkkk____GGGGeeeettttCCCCuuuurrrrssssoooorrrrFFFFrrrroooommmmDDDDaaaattttaaaa assumes that if the same _s_o_u_r_c_e pointer
  189.      is used in two different calls, then the pointers refer to the same data;
  190.      it does not check to see if the actual data values have changed.
  191.  
  192.  
  193.  
  194.  
  195.                                                                         PPPPaaaaggggeeee 3333
  196.  
  197.  
  198.  
  199.  
  200.  
  201.  
  202. TTTTkkkk____GGGGeeeettttCCCCuuuurrrrssssoooorrrr((((3333TTTTkkkk))))                                            TTTTkkkk____GGGGeeeettttCCCCuuuurrrrssssoooorrrr((((3333TTTTkkkk))))
  203.  
  204.  
  205.  
  206. KKKKEEEEYYYYWWWWOOOORRRRDDDDSSSS
  207.      cursor
  208.  
  209.  
  210.  
  211.  
  212.  
  213.  
  214.  
  215.  
  216.  
  217.  
  218.  
  219.  
  220.  
  221.  
  222.  
  223.  
  224.  
  225.  
  226.  
  227.  
  228.  
  229.  
  230.  
  231.  
  232.  
  233.  
  234.  
  235.  
  236.  
  237.  
  238.  
  239.  
  240.  
  241.  
  242.  
  243.  
  244.  
  245.  
  246.  
  247.  
  248.  
  249.  
  250.  
  251.  
  252.  
  253.  
  254.  
  255.  
  256.  
  257.  
  258.  
  259.  
  260.  
  261.                                                                         PPPPaaaaggggeeee 4444
  262.  
  263.  
  264.  
  265.