home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Source Code 1993 July / THE_SOURCE_CODE_CD_ROM.iso / languages / tcl / tk3.3b1 / doc / CrtSelHdlr.3 < prev    next >
Encoding:
Text File  |  1993-04-01  |  5.8 KB  |  136 lines

  1. '\"
  2. '\" Copyright (c) 1990-1992 The Regents of the University of California.
  3. '\" All rights reserved.
  4. '\"
  5. '\" Permission is hereby granted, without written agreement and without
  6. '\" license or royalty fees, to use, copy, modify, and distribute this
  7. '\" documentation for any purpose, provided that the above copyright
  8. '\" notice and the following two paragraphs appear in all copies.
  9. '\"
  10. '\" IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY
  11. '\" FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
  12. '\" ARISING OUT OF THE USE OF THIS DOCUMENTATION, EVEN IF THE UNIVERSITY OF
  13. '\" CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  14. '\"
  15. '\" THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES,
  16. '\" INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
  17. '\" AND FITNESS FOR A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS
  18. '\" ON AN "AS IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATION TO
  19. '\" PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
  20. '\" 
  21. '\" $Header: /user6/ouster/wish/man/RCS/CrtSelHdlr.3,v 1.7 93/04/01 09:41:16 ouster Exp $ SPRITE (Berkeley)
  22. '\" 
  23. .so man.macros
  24. .HS Tk_CreateSelHandler tkc
  25. .BS
  26. .SH NAME
  27. Tk_CreateSelHandler, Tk_DeleteSelHandler \- arrange to handle requests for the primary selection
  28. .SH SYNOPSIS
  29. .nf
  30. \fB#include <tk.h>\fR
  31. .sp
  32. \fBTk_CreateSelHandler\fR(\fItkwin, target, proc, clientData, format\fR)
  33. .sp
  34. \fBTk_DeleteSelHandler\fR(\fItkwin, target\fR)
  35. .SH ARGUMENTS
  36. .AS Tk_SelectionProc clientData
  37. .AP Tk_Window tkwin in
  38. Window for which \fIproc\fR will provide selection information.
  39. .AP Atom target in
  40. Form in which \fIproc\fR can provide the selection (e.g. STRING
  41. or FILE_NAME).  Corresponds to \fItype\fR arguments in \fBselection\fR
  42. commands.
  43. .AP Tk_SelectionProc *proc in
  44. Procedure to invoke whenever the selection is owned by \fItkwin\fR
  45. and the selection contents are requested in the format given by
  46. \fItarget\fR.
  47. .AP ClientData clientData in
  48. Arbitrary one-word value to pass to \fIproc\fR.
  49. .AP Atom format in
  50. If the selection requestor isn't in this process, \fIformat\fR determines
  51. the representation used to transmit the selection to its
  52. requestor.
  53. .BE
  54.  
  55. .SH DESCRIPTION
  56. .PP
  57. \fBTk_CreateSelHandler\fR arranges for a particular procedure
  58. (\fIproc\fR) to be called whenever the selection is owned by
  59. \fItkwin\fR and the selection contents are requested in the
  60. form given by \fItarget\fR.  \fITarget\fR should be one of
  61. the entries defined in the left column of Table 2 of the
  62. X Inter-Client Communication Conventions Manual (ICCCM) or
  63. any other form in which an application is willing to present
  64. the selection.  The most common form is STRING.
  65. .PP
  66. \fIProc\fR should have arguments and result that match the
  67. type \fBTk_SelectionProc\fR:
  68. .nf
  69. .RS
  70. typedef int Tk_SelectionProc(
  71. .RS
  72. ClientData \fIclientData\fR,
  73. int \fIoffset\fR,
  74. char *\fIbuffer\fR,
  75. int \fImaxBytes\fR);
  76. .RE
  77. .RE
  78. .fi
  79. The \fIclientData\fP parameter to \fIproc\fR is a copy of the
  80. \fIclientData\fP argument given to \fBTk_CreateSelHandler\fR.
  81. Typically, \fIclientData\fR points to a data
  82. structure containing application-specific information that is
  83. needed to retrieve the selection.  \fIOffset\fR specifies an
  84. offset position into the selection, \fIbuffer\fR specifies a
  85. location at which to copy information about the selection, and
  86. \fImaxBytes\fR specifies the amount of space available at
  87. \fIbuffer\fR.  \fIProc\fR should place a NULL-terminated string
  88. at \fIbuffer\fR containing \fImaxBytes\fR or fewer characters
  89. (not including the terminating NULL), and it should return a
  90. count of the number of non-NULL characters stored at
  91. \fIbuffer\fR.  If the selection no longer exists (e.g. it once
  92. existed but the user deleted the range of characters containing
  93. it), then \fIproc\fR should return -1.
  94. .PP
  95. When transferring large selections, Tk will break them up into
  96. smaller pieces (typically a few thousand bytes each) for more
  97. efficient transmision.  It will do this by calling \fIproc\fR
  98. one or more times, using successively higher values of \fIoffset\fR
  99. to retrieve successive portions of the selection.  If \fIproc\fR
  100. returns a count less than \fImaxBytes\fR it means that the entire
  101. remainder of the selection has been returned.  If \fIproc\fR's return
  102. value is \fImaxBytes\fR it means there may be additional information
  103. in the selection, so Tk must make another call to \fIproc\fR to
  104. retrieve the next portion.
  105. .PP
  106. \fIProc\fR always returns selection information in the form of a
  107. character string.  However, the ICCCM allows for information to
  108. be transmitted from the selection owner to the selection requestor
  109. in any of several formats, such as a string, an array of atoms, an
  110. array of integers, etc.  The \fIformat\fR argument to
  111. \fBTk_CreateSelHandler\fR indicates what format should be used to
  112. transmit the selection to its requestor (see the middle column of
  113. Table 2 of the ICCCM for examples).  If \fIformat\fR is not
  114. STRING, then Tk will take the value returned by \fIproc\fR and divided
  115. it into fields separated by white space.  If \fIformat\fR is ATOM,
  116. then Tk will return the selection as an array of atoms, with each
  117. field in \fIproc\fR's result treated as the name of one atom.  For
  118. any other value of \fIformat\fR, Tk will return the selection as an
  119. array of 32-bit values where each field of \fIproc\fR's result is
  120. treated as a number and translated to a 32-bit value.  In any event,
  121. the \fIformat\fR atom is returned to the selection requestor along
  122. with the contents of the selection.
  123. .PP
  124. If \fBTk_CreateSelHandler\fR is called when there already exists a
  125. handler for \fItarget\fR on \fItkwin\fR, then the existing handler
  126. is replaced with a new one.
  127. .PP
  128. \fBTk_DeleteSelHandler\fR removes the handler given by \fItkwin\fR
  129. .VS
  130. and \fItarget\fR, if such a handler exists.  If there is no such
  131. handler then it has no effect.
  132. .VE
  133.  
  134. .SH KEYWORDS
  135. format, handler, selection, target
  136.