CrtSelHdlr.3
上传用户:rrhhcc
上传日期:2015-12-11
资源大小:54129k
文件大小:5k
- '"
- '" Copyright (c) 1990-1994 The Regents of the University of California.
- '" Copyright (c) 1994-1996 Sun Microsystems, Inc.
- '"
- '" See the file "license.terms" for information on usage and redistribution
- '" of this file, and for a DISCLAIMER OF ALL WARRANTIES.
- '"
- '" RCS: @(#) $Id: CrtSelHdlr.3,v 1.2 1998/09/14 18:22:47 stanton Exp $
- '"
- .so man.macros
- .TH Tk_CreateSelHandler 3 4.0 Tk "Tk Library Procedures"
- .BS
- .SH NAME
- Tk_CreateSelHandler, Tk_DeleteSelHandler - arrange to handle requests for a selection
- .SH SYNOPSIS
- .nf
- fB#include <tk.h>fR
- .sp
- fBTk_CreateSelHandlerfR(fItkwin, selection, target, proc, clientData, formatfR)
- .sp
- fBTk_DeleteSelHandlerfR(fItkwin, selection, targetfR)
- .SH ARGUMENTS
- .AS Tk_SelectionProc clientData
- .AP Tk_Window tkwin in
- Window for which fIprocfR will provide selection information.
- .AP Atom selection in
- The name of the selection for which fIprocfR will provide
- selection information.
- .AP Atom target in
- Form in which fIprocfR can provide the selection (e.g. STRING
- or FILE_NAME). Corresponds to fItypefR arguments in fBselectionfR
- commands.
- .AP Tk_SelectionProc *proc in
- Procedure to invoke whenever the selection is owned by fItkwinfR
- and the selection contents are requested in the format given by
- fItargetfR.
- .AP ClientData clientData in
- Arbitrary one-word value to pass to fIprocfR.
- .AP Atom format in
- If the selection requestor isn't in this process, fIformatfR determines
- the representation used to transmit the selection to its
- requestor.
- .BE
- .SH DESCRIPTION
- .PP
- fBTk_CreateSelHandlerfR arranges for a particular procedure
- (fIprocfR) to be called whenever fIselectionfR is owned by
- fItkwinfR and the selection contents are requested in the
- form given by fItargetfR.
- fITargetfR should be one of
- the entries defined in the left column of Table 2 of the
- X Inter-Client Communication Conventions Manual (ICCCM) or
- any other form in which an application is willing to present
- the selection. The most common form is STRING.
- .PP
- fIProcfR should have arguments and result that match the
- type fBTk_SelectionProcfR:
- .CS
- typedef int Tk_SelectionProc(
- ClientData fIclientDatafR,
- int fIoffsetfR,
- char *fIbufferfR,
- int fImaxBytesfR);
- .CE
- The fIclientDatafR parameter to fIprocfR is a copy of the
- fIclientDatafR argument given to fBTk_CreateSelHandlerfR.
- Typically, fIclientDatafR points to a data
- structure containing application-specific information that is
- needed to retrieve the selection. fIOffsetfR specifies an
- offset position into the selection, fIbufferfR specifies a
- location at which to copy information about the selection, and
- fImaxBytesfR specifies the amount of space available at
- fIbufferfR. fIProcfR should place a NULL-terminated string
- at fIbufferfR containing fImaxBytesfR or fewer characters
- (not including the terminating NULL), and it should return a
- count of the number of non-NULL characters stored at
- fIbufferfR. If the selection no longer exists (e.g. it once
- existed but the user deleted the range of characters containing
- it), then fIprocfR should return -1.
- .PP
- When transferring large selections, Tk will break them up into
- smaller pieces (typically a few thousand bytes each) for more
- efficient transmission. It will do this by calling fIprocfR
- one or more times, using successively higher values of fIoffsetfR
- to retrieve successive portions of the selection. If fIprocfR
- returns a count less than fImaxBytesfR it means that the entire
- remainder of the selection has been returned. If fIprocfR's return
- value is fImaxBytesfR it means there may be additional information
- in the selection, so Tk must make another call to fIprocfR to
- retrieve the next portion.
- .PP
- fIProcfR always returns selection information in the form of a
- character string. However, the ICCCM allows for information to
- be transmitted from the selection owner to the selection requestor
- in any of several formats, such as a string, an array of atoms, an
- array of integers, etc. The fIformatfR argument to
- fBTk_CreateSelHandlerfR indicates what format should be used to
- transmit the selection to its requestor (see the middle column of
- Table 2 of the ICCCM for examples). If fIformatfR is not
- STRING, then Tk will take the value returned by fIprocfR and divided
- it into fields separated by white space. If fIformatfR is ATOM,
- then Tk will return the selection as an array of atoms, with each
- field in fIprocfR's result treated as the name of one atom. For
- any other value of fIformatfR, Tk will return the selection as an
- array of 32-bit values where each field of fIprocfR's result is
- treated as a number and translated to a 32-bit value. In any event,
- the fIformatfR atom is returned to the selection requestor along
- with the contents of the selection.
- .PP
- If fBTk_CreateSelHandlerfR is called when there already exists a
- handler for fIselectionfR and fItargetfR on fItkwinfR, then the
- existing handler is replaced with a new one.
- .PP
- fBTk_DeleteSelHandlerfR removes the handler given by fItkwinfR,
- fIselectionfR, and fItargetfR, if such a handler exists.
- If there is no such handler then it has no effect.
- .SH KEYWORDS
- format, handler, selection, target