| 1 |
# Copyright (c) 1990 The Regents of the University of California. |
| 2 |
# Copyright (c) 1994-1996 Sun Microsystems, Inc. |
| 3 |
# See the file "license.terms" for information on usage and redistribution |
| 4 |
# of this file, and for a DISCLAIMER OF ALL WARRANTIES. |
| 5 |
# |
| 6 |
# @(#) CrtWindow.c 1.21 96/11/01 09:42:20 |
| 7 |
# |
| 8 |
|
| 9 |
=head1 NAME |
| 10 |
|
| 11 |
Tk_CreateWindow, Tk_CreateWindowFromPath, Tk_DestroyWindow, Tk_MakeWindowExist - create or delete window |
| 12 |
|
| 13 |
=for category C Programming |
| 14 |
|
| 15 |
=head1 SYNOPSIS |
| 16 |
|
| 17 |
B<#include E<lt>tk.hE<gt>> |
| 18 |
|
| 19 |
Tk_Window |
| 20 |
B<Tk_CreateWindow>(I<interp, parent, name, topLevScreen>) |
| 21 |
|
| 22 |
Tk_Window |
| 23 |
B<Tk_CreateWindowFromPath>(I<interp, tkwin, pathName, topLevScreen>) |
| 24 |
|
| 25 |
B<Tk_DestroyWindow>(I<tkwin>) |
| 26 |
|
| 27 |
B<Tk_MakeWindowExist>(I<tkwin>) |
| 28 |
|
| 29 |
=head1 ARGUMENTS |
| 30 |
|
| 31 |
=over 4 |
| 32 |
|
| 33 |
=item Tcl_Interp *interp (out) |
| 34 |
|
| 35 |
Tcl interpreter to use for error reporting. If no error occurs, |
| 36 |
then I<*interp> isn't modified. |
| 37 |
|
| 38 |
=item Tk_Window parent (in) |
| 39 |
|
| 40 |
Token for the window that is to serve as the logical parent of |
| 41 |
the new window. |
| 42 |
|
| 43 |
=item char *name (in) |
| 44 |
|
| 45 |
Name to use for this window. Must be unique among all children of |
| 46 |
the same I<parent>. |
| 47 |
|
| 48 |
=item char *topLevScreen (in) |
| 49 |
|
| 50 |
Has same format as I<screenName>. If NULL, then new window is |
| 51 |
created as an internal window. If non-NULL, new window is created as |
| 52 |
a top-level window on screen I<topLevScreen>. If I<topLevScreen> |
| 53 |
is an empty string (``'') then new |
| 54 |
window is created as top-level window of I<parent>'s screen. |
| 55 |
|
| 56 |
=item Tk_Window tkwin (in) |
| 57 |
|
| 58 |
Token for window. |
| 59 |
|
| 60 |
=item char *pathName (in) |
| 61 |
|
| 62 |
Name of new window, specified as path name within application |
| 63 |
(e.g. B<.a.b.c>). |
| 64 |
|
| 65 |
=back |
| 66 |
|
| 67 |
=head1 DESCRIPTION |
| 68 |
|
| 69 |
The procedures B<Tk_CreateWindow> |
| 70 |
and B<Tk_CreateWindowFromPath> |
| 71 |
are used to create new windows for |
| 72 |
use in Tk-based applications. Each of the procedures returns a token |
| 73 |
that can be used to manipulate the window in other calls to the Tk |
| 74 |
library. If the window couldn't be created successfully, then NULL |
| 75 |
is returned and I<interp-E<gt>result> is modified to hold an error |
| 76 |
message. |
| 77 |
|
| 78 |
Tk supports two different kinds of windows: internal |
| 79 |
windows and top-level windows. |
| 80 |
An internal window is an interior window of a Tk application, such as a |
| 81 |
scrollbar or menu bar or button. A top-level window is one that is |
| 82 |
created as a child of a screen's root window, rather than as an |
| 83 |
interior window, but which is logically part of some existing main |
| 84 |
window. Examples of top-level windows are pop-up menus and dialog boxes. |
| 85 |
|
| 86 |
New windows may be created by calling |
| 87 |
B<Tk_CreateWindow>. If the I<topLevScreen> argument is |
| 88 |
NULL, then the new window will be an internal window. If |
| 89 |
I<topLevScreen> is non-NULL, then the new window will be a |
| 90 |
top-level window: I<topLevScreen> indicates the name of |
| 91 |
a screen and the new window will be created as a child of the |
| 92 |
root window of I<topLevScreen>. In either case Tk will |
| 93 |
consider the new window to be the logical child of I<parent>: |
| 94 |
the new window's path name will reflect this fact, options may |
| 95 |
be specified for the new window under this assumption, and so on. |
| 96 |
The only difference is that new X window for a top-level window |
| 97 |
will not be a child of I<parent>'s X window. For example, a pull-down |
| 98 |
menu's I<parent> would be the button-like window used to invoke it, |
| 99 |
which would in turn be a child of the menu bar window. A dialog box might |
| 100 |
have the application's main window as its parent. |
| 101 |
|
| 102 |
B<Tk_CreateWindowFromPath> offers an alternate way of specifying |
| 103 |
new windows. In B<Tk_CreateWindowFromPath> the new |
| 104 |
window is specified with a token for any window in the target |
| 105 |
application (I<tkwin>), plus a path name for the new window. |
| 106 |
It produces the same effect as B<Tk_CreateWindow> and allows |
| 107 |
both top-level and internal windows to be created, depending on |
| 108 |
the value of I<topLevScreen>. In calls to B<Tk_CreateWindowFromPath>, |
| 109 |
as in calls to B<Tk_CreateWindow>, the parent of the new window |
| 110 |
must exist at the time of the call, but the new window must not |
| 111 |
already exist. |
| 112 |
|
| 113 |
The window creation procedures don't |
| 114 |
actually issue the command to X to create a window. |
| 115 |
Instead, they create a local data structure associated with |
| 116 |
the window and defer the creation of the X window. |
| 117 |
The window will actually be created by the first call to |
| 118 |
B<Tk_MapWindow>. Deferred window creation allows various |
| 119 |
aspects of the window (such as its size, background color, |
| 120 |
etc.) to be modified after its creation without incurring |
| 121 |
any overhead in the X server. When the window is finally |
| 122 |
mapped all of the window attributes can be set while creating |
| 123 |
the window. |
| 124 |
|
| 125 |
The value returned by a window-creation procedure is not the |
| 126 |
X token for the window (it can't be, since X hasn't been |
| 127 |
asked to create the window yet). Instead, it is a token |
| 128 |
for Tk's local data structure for the window. Most |
| 129 |
of the Tk library procedures take Tk_Window tokens, rather |
| 130 |
than X identifiers. The actual |
| 131 |
X window identifier can be retrieved from the local |
| 132 |
data structure using the B<Tk_WindowId> macro; see |
| 133 |
the manual entry for B<Tk_WindowId> for details. |
| 134 |
|
| 135 |
B<Tk_DestroyWindow> deletes a window and all the data |
| 136 |
structures associated with it, including any event handlers |
| 137 |
created with B<Tk_CreateEventHandler>. In addition, |
| 138 |
B<Tk_DestroyWindow> will delete any children of I<tkwin> |
| 139 |
recursively (where children are defined in the Tk sense, consisting |
| 140 |
of all windows that were created with the given window as I<parent>). |
| 141 |
If I<tkwin> was created by B<Tk_CreateInternalWindow> then event |
| 142 |
handlers interested in destroy events |
| 143 |
are invoked immediately. If I<tkwin> is a top-level or main window, |
| 144 |
then the event handlers will be invoked later, after X has seen |
| 145 |
the request and returned an event for it. |
| 146 |
|
| 147 |
If a window has been created |
| 148 |
but hasn't been mapped, so no X window exists, it is |
| 149 |
possible to force the creation of the X window by |
| 150 |
calling B<Tk_MakeWindowExist>. This procedure issues |
| 151 |
the X commands to instantiate the window given by I<tkwin>. |
| 152 |
|
| 153 |
=head1 KEYWORDS |
| 154 |
|
| 155 |
create, deferred creation, destroy, display, internal window, |
| 156 |
screen, top-level window, window |