summaryrefslogtreecommitdiffstats
path: root/doc/Name.3
blob: 73b09b1ddea22772b815721d802002795b0c6ecf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
'\"
'\" Copyright (c) 1990 The Regents of the University of California.
'\" Copyright (c) 1994-1997 Sun Microsystems, Inc.
'\"
'\" See the file "license.terms" for information on usage and redistribution
'\" of this file, and for a DISCLAIMER OF ALL WARRANTIES.
'\" 
.so man.macros
.TH Tk_Name 3 "" Tk "Tk Library Procedures"
.BS
.SH NAME
Tk_Name, Tk_PathName, Tk_NameToWindow \- convert between names and window tokens
.SH SYNOPSIS
.nf
\fB#include <tk.h>\fR
.sp
Tk_Uid
\fBTk_Name\fR(\fItkwin\fR)
.sp
char *
\fBTk_PathName\fR(\fItkwin\fR)
.sp
Tk_Window
\fBTk_NameToWindow\fR(\fIinterp, pathName, tkwin\fR)
.SH ARGUMENTS
.AS Tcl_Interp *pathName
.AP Tk_Window tkwin in
Token for window.
.AP Tcl_Interp *interp out
Interpreter to use for error reporting.
.AP "const char" *pathName in
Character string containing path name of window.
.BE

.SH DESCRIPTION
.PP
Each window managed by Tk has two names, a short name that identifies
a window among children of the same parent, and a path name that
identifies the window uniquely among all the windows belonging to the
same main window.  The path name is used more often in Tk than the
short name;  many commands, like \fBbind\fR, expect path names as
arguments.
.PP
The \fBTk_Name\fR macro returns a window's
short name, which is the same as the \fIname\fR argument
passed to \fBTk_CreateWindow\fR when
the window was created.  The value is returned
as a Tk_Uid, which may be used just like a string pointer but also has
the properties of a unique identifier (see the manual entry for
\fBTk_GetUid\fR for details).
.PP
The \fBTk_PathName\fR macro returns a
hierarchical name for \fItkwin\fR.
Path names have a structure similar to file names in Unix but with
dots between elements instead of slashes:  the main window for
an application has the path name
.QW . ;
its children have names like
.QW .a
and
.QW .b ;
their children have names like
.QW .a.aa
and
.QW .b.bb ;
and so on.  A window is considered to be a child of
another window for naming purposes if the second window was named
as the first window's \fIparent\fR when the first window was created.
This is not always the same as the X window hierarchy.  For
example, a pop-up
is created as a child of the root window, but its logical parent will
usually be a window within the application.
.PP
The procedure \fBTk_NameToWindow\fR returns the token for a window
given its path name (the \fIpathName\fR argument) and another window
belonging to the same main window (\fItkwin\fR).  It normally
returns a token for the named window, but if no such window exists
\fBTk_NameToWindow\fR leaves an error message in \fIinterp->result\fR
and returns NULL.  The \fItkwin\fR argument to \fBTk_NameToWindow\fR
is needed because path names are only unique within a single
application hierarchy.  If, for example, a single process has opened
two main windows, each will have a separate naming hierarchy and the
same path name might appear in each of the hierarchies.  Normally
\fItkwin\fR is the main window of the desired hierarchy, but this
need not be the case:  any window in the desired hierarchy may be used.

.SH KEYWORDS
name, path name, token, window
n> * Declarations of types shared among the files that implement * selection support. * * Copyright (c) 1995 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: tkSelect.h,v 1.4 1999/05/25 20:40:54 stanton Exp $ */ #ifndef _TKSELECT #define _TKSELECT /* * When a selection is owned by a window on a given display, one of the * following structures is present on a list of current selections in the * display structure. The structure is used to record the current owner of * a selection for use in later retrieval requests. There is a list of * such structures because a display can have multiple different selections * active at the same time. */ typedef struct TkSelectionInfo { Atom selection; /* Selection name, e.g. XA_PRIMARY. */ Tk_Window owner; /* Current owner of this selection. */ int serial; /* Serial number of last XSelectionSetOwner * request made to server for this * selection (used to filter out redundant * SelectionClear events). */ Time time; /* Timestamp used to acquire selection. */ Tk_LostSelProc *clearProc; /* Procedure to call when owner loses * selection. */ ClientData clearData; /* Info to pass to clearProc. */ struct TkSelectionInfo *nextPtr; /* Next in list of current selections on * this display. NULL means end of list */ } TkSelectionInfo; /* * One of the following structures exists for each selection handler * created for a window by calling Tk_CreateSelHandler. The handlers * are linked in a list rooted in the TkWindow structure. */ typedef struct TkSelHandler { Atom selection; /* Selection name, e.g. XA_PRIMARY */ Atom target; /* Target type for selection * conversion, such as TARGETS or * STRING. */ Atom format; /* Format in which selection * info will be returned, such * as STRING or ATOM. */ Tk_SelectionProc *proc; /* Procedure to generate selection * in this format. */ ClientData clientData; /* Argument to pass to proc. */ int size; /* Size of units returned by proc * (8 for STRING, 32 for almost * anything else). */ struct TkSelHandler *nextPtr; /* Next selection handler associated * with same window (NULL for end of * list). */ } TkSelHandler; /* * When the selection is being retrieved, one of the following * structures is present on a list of pending selection retrievals. * The structure is used to communicate between the background * procedure that requests the selection and the foreground * event handler that processes the events in which the selection * is returned. There is a list of such structures so that there * can be multiple simultaneous selection retrievals (e.g. on * different displays). */ typedef struct TkSelRetrievalInfo { Tcl_Interp *interp; /* Interpreter for error reporting. */ TkWindow *winPtr; /* Window used as requestor for * selection. */ Atom selection; /* Selection being requested. */ Atom property; /* Property where selection will appear. */ Atom target; /* Desired form for selection. */ int (*proc) _ANSI_ARGS_((ClientData clientData, Tcl_Interp *interp, char *portion)); /* Procedure to call to handle pieces * of selection. */ ClientData clientData; /* Argument for proc. */ int result; /* Initially -1. Set to a Tcl * return value once the selection * has been retrieved. */ Tcl_TimerToken timeout; /* Token for current timeout procedure. */ int idleTime; /* Number of seconds that have gone by * without hearing anything from the * selection owner. */ Tcl_EncodingState encState; /* Holds intermediate state during translations * of data that cross buffer boundaries. */ int encFlags; /* Encoding translation state flags. */ Tcl_DString buf; /* Buffer to hold translation data. */ struct TkSelRetrievalInfo *nextPtr; /* Next in list of all pending * selection retrievals. NULL means * end of list. */ } TkSelRetrievalInfo; /* * The clipboard contains a list of buffers of various types and formats. * All of the buffers of a given type will be returned in sequence when the * CLIPBOARD selection is retrieved. All buffers of a given type on the * same clipboard must have the same format. The TkClipboardTarget structure * is used to record the information about a chain of buffers of the same * type. */ typedef struct TkClipboardBuffer { char *buffer; /* Null terminated data buffer. */ long length; /* Length of string in buffer. */ struct TkClipboardBuffer *nextPtr; /* Next in list of buffers. NULL * means end of list . */ } TkClipboardBuffer; typedef struct TkClipboardTarget { Atom type; /* Type conversion supported. */ Atom format; /* Representation used for data. */ TkClipboardBuffer *firstBufferPtr; /* First in list of data buffers. */ TkClipboardBuffer *lastBufferPtr; /* Last in list of clipboard buffers. * Used to speed up appends. */ struct TkClipboardTarget *nextPtr; /* Next in list of targets on * clipboard. NULL means end of * list. */ } TkClipboardTarget; /* * It is possible for a Tk_SelectionProc to delete the handler that it * represents. If this happens, the code that is retrieving the selection * needs to know about it so it doesn't use the now-defunct handler * structure. One structure of the following form is created for each * retrieval in progress, so that the retriever can find out if its * handler is deleted. All of the pending retrievals (if there are more * than one) are linked into a list. */ typedef struct TkSelInProgress { TkSelHandler *selPtr; /* Handler being executed. If this handler * is deleted, the field is set to NULL. */ struct TkSelInProgress *nextPtr; /* Next higher nested search. */ } TkSelInProgress; /* * Chunk size for retrieving selection. It's defined both in * words and in bytes; the word size is used to allocate * buffer space that's guaranteed to be word-aligned and that * has an extra character for the terminating NULL. */ #define TK_SEL_BYTES_AT_ONCE 4000 #define TK_SEL_WORDS_AT_ONCE 1001 /* * Declarations for procedures that are used by the selection-related files * but shouldn't be used anywhere else in Tk (or by Tk clients): */ extern TkSelInProgress * TkSelGetInProgress _ANSI_ARGS_((void)); extern void TkSelSetInProgress _ANSI_ARGS_(( TkSelInProgress *pendingPtr)); extern void TkSelClearSelection _ANSI_ARGS_((Tk_Window tkwin, XEvent *eventPtr)); extern int TkSelDefaultSelection _ANSI_ARGS_(( TkSelectionInfo *infoPtr, Atom target, char *buffer, int maxBytes, Atom *typePtr)); extern int TkSelGetSelection _ANSI_ARGS_((Tcl_Interp *interp, Tk_Window tkwin, Atom selection, Atom target, Tk_GetSelProc *proc, ClientData clientData)); #ifndef TkSelUpdateClipboard extern void TkSelUpdateClipboard _ANSI_ARGS_((TkWindow *winPtr, TkClipboardTarget *targetPtr)); #endif #endif /* _TKSELECT */