OSDN Git Service

touched all tk files to ease next import
[pf3gnuchains/pf3gnuchains4x.git] / tk / doc / Tk_Main.3
1 '\"
2 '\" Copyright (c) 1994 The Regents of the University of California.
3 '\" Copyright (c) 1994-1996 Sun Microsystems, Inc.
4 '\"
5 '\" See the file "license.terms" for information on usage and redistribution
6 '\" of this file, and for a DISCLAIMER OF ALL WARRANTIES.
7 '\" 
8 '\" RCS: @(#) $Id$
9 '\" 
10 .so man.macros
11 .TH Tk_Main 3 4.0 Tk "Tk Library Procedures"
12 .BS
13 .SH NAME
14 Tk_Main \- main program for Tk-based applications
15 .SH SYNOPSIS
16 .nf
17 \fB#include <tk.h>\fR
18 .sp
19 \fBTk_Main\fR(\fIargc, argv, appInitProc\fR)
20 .SH ARGUMENTS
21 .AS Tcl_AppInitProc *appInitProc
22 .AP int argc in
23 Number of elements in \fIargv\fR.
24 .AP char *argv[] in
25 Array of strings containing command-line arguments.
26 .AP Tcl_AppInitProc *appInitProc in
27 Address of an application-specific initialization procedure.
28 The value for this argument is usually \fBTcl_AppInit\fR.
29 .BE
30
31 .SH DESCRIPTION
32 .PP
33 \fBTk_Main\fR acts as the main program for most Tk-based applications.
34 Starting with Tk 4.0 it is not called \fBmain\fR anymore because it 
35 is part of the Tk library and having a function \fBmain\fR
36 in a library (particularly a shared library) causes problems on many
37 systems.
38 Having \fBmain\fR in the Tk library would also make it hard to use
39 Tk in C++ programs, since C++ programs must have special C++
40 \fBmain\fR functions.
41 .PP
42 Normally each application contains a small \fBmain\fR function that does
43 nothing but invoke \fBTk_Main\fR.
44 \fBTk_Main\fR then does all the work of creating and running a
45 \fBwish\fR-like application.
46 .PP
47 When it is has finished its own initialization, but before
48 it processes commands, \fBTk_Main\fR calls the procedure given by
49 the \fIappInitProc\fR argument.  This procedure provides a ``hook''
50 for the application to perform its own initialization, such as defining
51 application-specific commands.  The procedure must have an interface
52 that matches the type \fBTcl_AppInitProc\fR:
53 .CS
54 typedef int Tcl_AppInitProc(Tcl_Interp *\fIinterp\fR);
55 .CE
56 \fIAppInitProc\fR is almost always a pointer to \fBTcl_AppInit\fR;
57 for more details on this procedure, see the documentation
58 for \fBTcl_AppInit\fR.
59
60 .SH KEYWORDS
61 application-specific initialization, command-line arguments, main program
62