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

  1. '\"
  2. '\" Copyright (c) 1990 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/CrtMainWin.3,v 1.13 93/04/01 09:41:14 ouster Exp $ SPRITE (Berkeley)
  22. '\" 
  23. .so man.macros
  24. .HS Tk_CreateMainWindow tkc
  25. .BS
  26. .SH NAME
  27. Tk_CreateMainWindow, Tk_CreateWindow, Tk_CreateWindowFromPath, Tk_DestroyWindow, Tk_MakeWindowExist \- create or delete window
  28. .SH SYNOPSIS
  29. .nf
  30. \fB#include <tk.h>\fR
  31. .sp
  32. Tk_Window
  33. \fBTk_CreateMainWindow\fR(\fIinterp, screenName, baseName\fR)
  34. .sp
  35. Tk_Window
  36. \fBTk_CreateWindow\fR(\fIinterp, parent, name, topLevScreen\fR)
  37. .sp
  38. Tk_Window
  39. \fBTk_CreateWindowFromPath\fR(\fIinterp, tkwin, pathName, topLevScreen\fR)
  40. .sp
  41. \fBTk_DestroyWindow\fR(\fItkwin\fR)
  42. .sp
  43. \fBTk_MakeWindowExist\fR(\fItkwin\fR)
  44. .SH ARGUMENTS
  45. .AS Tcl_Interp *topLevScreen
  46. .AP Tcl_Interp *interp out
  47. Tcl interpreter to use for error reporting.  If no error occurs,
  48. then \fI*interp\fR isn't modified.  For \fBTk_CreateMainWindow\fR,
  49. this interpreter is associated permanently with the created window,
  50. and Tk-related commands are bound into the interpeter.
  51. .AP char *screenName in
  52. String name of screen on which to create window.  Has the form
  53. \fIdisplayName\fB.\fIscreenNum\fR, where \fIdisplayName\fR is the
  54. name of a display and \fIscreenNum\fR is a screen number.  If
  55. the dot and \fIscreenNum\fR are omitted, the screen number defaults
  56. to 0.  If \fIscreenName\fR is NULL or empty string, defaults to
  57. contents of DISPLAY environment variable.
  58. .AP char *baseName in
  59. Name to use for this main window.  See below for details.
  60. .AP Tk_Window parent in
  61. Token for the window that is to serve as the logical parent of
  62. the new window.
  63. .AP char *name in
  64. Name to use for this window.  Must be unique among all children of
  65. the same \fIparent\fR.
  66. .AP char *topLevScreen in
  67. Has same format as \fIscreenName\fR.  If NULL, then new window is
  68. created as an internal window.  If non-NULL, new window is created as
  69. a top-level window on screen \fItopLevScreen\fR.  If \fItopLevScreen\fR
  70. is an empty string (``'') then new
  71. window is created as top-level window of \fIparent\fR's screen.
  72. .AP Tk_Window tkwin in
  73. Token for window.
  74. .AP char *pathName in
  75. Name of new window, specified as path name within application
  76. (e.g. \fB.a.b.c\fR).
  77. .BE
  78.  
  79. .SH DESCRIPTION
  80. .PP
  81. The three procedures \fBTk_CreateMainWindow\fR, \fBTk_CreateWindow\fR,
  82. and \fBTk_CreateWindowFromPath\fR are used to create new windows for
  83. use in Tk-based applications.  Each of the procedures returns a token
  84. that can be used to manipulate the window in other calls to the Tk
  85. library.  If the window couldn't be created successfully, then NULL
  86. is returned and \fIinterp->result\fR is modified to hold an error
  87. message.
  88. .PP
  89. Tk supports three different kinds of windows:  main windows, internal
  90. windows, and top-level windows.
  91. A main window is the outermost window corresponding to an application.
  92. Main windows correspond to the independent units of an application,
  93. such as a view on a file that is part of an editor, or a clock, or
  94. a terminal emulator.  A main window is created as a child of the root
  95. window of the screen indicated by the \fIscreenName\fR.  Each main
  96. window, and all its descendants, are typically associated with a
  97. single Tcl command interpreter, given by the \fIinterp\fR argument
  98. to \fBTk_CreateMainWindow\fR.  \fBTk_CreateMainWindow\fR adds all the
  99. Tk-related commands to those already defined for \fIinterp\fR.
  100. .PP
  101. \fBTk_CreateMainWindow\fR also registers \fIinterp\fR so that it
  102. can be accessed remotely by other Tk applications using the \fBsend\fR
  103. command and the name \fIbaseName\fR.  Normally, \fIbaseName\fR consists
  104. of the name of the application followed by a space and an identifier for this
  105. particular main window (if such an identifier is relevant).  For example,
  106. an editor named \fBmx\fR displaying the file \fBfoo.c\fR would use
  107. ``mx foo.c'' as the basename.  An application that doesn't usually
  108. have multiple instances, such as a clock program, would just use the
  109. name of the application, e.g. ``xclock''.  If \fIbaseName\fR is already
  110. in use by some other registered interpreter, then \fBTk_CreateMainWindow\fR
  111. extends \fIbaseName\fR with a number to produce a unique name like
  112. ``mx foo.c #2'' or ``xclock #12''.  This name is used both as the name
  113. of the window (returned by \fBTk_Name\fR) and as the registered name
  114. of the interpreter.
  115. .PP
  116. An internal window is an interior window of a Tk application, such as a
  117. scrollbar or menu bar or button.  A top-level window is one that is
  118. created as a child of a screen's root window, rather than as an
  119. interior window, but which is logically part of some existing main
  120. window.  Examples of top-level windows are pop-up menus and dialog boxes.
  121. .PP
  122. Either internal or top-level windows may be created by calling
  123. \fBTk_CreateWindow\fR.  If the \fItopLevScreen\fR argument is
  124. NULL, then the new window will be an internal window.  If
  125. \fItopLevScreen\fR is non-NULL, then the new window will be a
  126. top-level window: \fItopLevScreen\fR indicates the name of
  127. a screen and the new window will be created as a child of the
  128. root window of \fItopLevScreen\fR.  In either case Tk will
  129. consider the new window to be the logical child of \fIparent\fR:
  130. the new window's path name will reflect this fact, options may
  131. be specified for the new window under this assumption, and so on.
  132. The only difference is that new X window for a top-level window
  133. will not be a child of \fIparent\fR's X window.  For example, a pull-down
  134. menu's \fIparent\fR would be the button-like window used to invoke it,
  135. which would in turn be a child of the menu bar window.  A dialog box might
  136. have the application's main window as its parent.  This approach
  137. means that all the windows of an application fall into a hierarchical
  138. arrangement with a single logical root:  the application's main window.
  139. .PP
  140. \fBTk_CreateWindowFromPath\fR offers an alternate way of specifying
  141. new windows.  In \fBTk_CreateWindowFromPath\fR the new
  142. window is specified with a token for any window in the target
  143. application (\fItkwin\fR), plus a path name for the new window.
  144. It produces the same effect as \fBTk_CreateWindow\fR and allows
  145. both top-level and internal windows to be created, depending on
  146. the value of \fItopLevScreen\fR.  In calls to \fBTk_CreateWindowFromPath\fR,
  147. as in calls to \fBTk_CreateWindow\fR, the parent of the new window
  148. must exist at the time of the call, but the new window must not
  149. already exist.
  150. .PP
  151. In truth, the window-creation procedures don't
  152. actually issue the command to X to create a window.
  153. Instead, they create a local data structure associated with
  154. the window and defer issuing the command to X.  The
  155. window will actually be created by the first call to
  156. \fBTk_MapWindow\fR.  Deferred window creation allows various
  157. aspects of the window (such as its size, background color,
  158. etc.) to be modified after its creation without incurring
  159. any overhead in the X server.  When the window is finally
  160. mapped all of the window attributes can be set while creating
  161. the window.
  162. .PP
  163. The value returned by a window-creation procedure is not the
  164. X token for the window (it can't be, since X hasn't been
  165. asked to create the window yet).  Instead, it is a token
  166. for Tk's local data structure for the window.  Most
  167. of the Tk library procedures take Tk_Window tokens, rather
  168. than X identifiers.  The actual
  169. X window identifier can be retrieved from the local
  170. data structure using the \fBTk_WindowId\fR macro;  see
  171. the manual entry for \fBTk_WindowId\fR for details.
  172. .PP
  173. \fBTk_DestroyWindow\fR deletes a window and all the data
  174. strutures associated with it, including any event handlers
  175. created with \fBTk_CreateEventHandler\fR.  In addition,
  176. \fBTk_DestroyWindow\fR will delete any children of \fItkwin\fR
  177. recursively (where children are defined in the Tk sense, consisting
  178. of all windows that were created with the given window as \fIparent\fR).
  179. If \fItkwin\fR was created by \fBTk_CreateInternalWindow\fR then event
  180. handlers interested in destroy events
  181. are invoked immediately.  If \fItkwin\fR is a top-level or main window,
  182. then the event handlers will be invoked later, after X has seen
  183. the request and returned an event for it.
  184. .PP
  185. If a window has been created
  186. but hasn't been mapped, so no X window exists, it is
  187. possible to force the creation of the X window by
  188. calling \fBTk_MakeWindowExist\fR.  This procedure issues
  189. the X commands to instantiate the window given by \fItkwin\fR.
  190.  
  191. .SH KEYWORDS
  192. create, deferred creation, destroy, display, internal window, main window,
  193. register, screen, top-level window, window
  194.