Reference Guide > W Routines > WtInit Function
  

WtInit Function
Initializes the Widget Toolbox and the Xt toolkit, opens the display, and creates the first top-level shell.
Usage
topshell = WtInit(app_name, appclass_name[, Xserverargs ...])
Parameters
app_name — A string containing the name of the application as used in the resource file.
appclass_name — A string containing the application class name (name of the resource file).
Xserverargs — (optional) String containing X server arguments (font, display, synchronize, etc.). See the OSF/Motif Programmer’s Reference for more information.
Returned Value
topshell — Returns the widget ID of the top application shell.
Keywords
Colors — (Motif only) The maximum number of color table indices to be used. Otherwise, PV‑WAVE uses all of the available color indices. On Windows platforms, PV‑WAVE uses all available color indices.
ConfirmClose — A string containing the name of the procedure called when the user selects the Close or Quit menu button from the window manager menu.
Context — Specifies application context handle created in an Xt Intrinsics-based application statically linked with PV‑WAVE. If this keyword is specified, the Topshell keyword is also required.
ResourceSpecifies a resource file to load into the resource manager database. The resources are used to set attributes of the top-level shell created by WtInit. The defaults are as follows:
(UNIX) WAVE_DIR/bin/Wave.ad
(WIN) WAVE_DIR\bin\wave.ad
Where WAVE_DIR is the main PV‑WAVE directory.
Topshell — Specifies top-level shell handle of the main application shell created in an Xt Intrinsics-based application statically linked with PV‑WAVE. If this is specified, the Context keyword is also required.
 
note
The Context and Topshell keywords are not supported on Windows platforms.
UserData — A variable. If the ConfirmClose keyword is specified, the value of this variable is passed to the Close or Quit callback.
Discussion
Call this routine before the first use of any Widget Toolbox routines, or to reinitialize Widget Toolbox after closing the top-level shells.
 
note
Rogue Wave has ported a subset of the Widget Toolbox (Wt) functionality that is available for Motif to Microsoft Windows. Because the Widget Toolbox under Windows is not a complete implementation, we recommend that Windows developers use the PV‑WAVE Widgets (Ww) layer or the VDA Tools when developing GUI applications.
The ConfirmClose keyword lets you control what happens when users select Close or Quit from the window manager menu. Normally, the window from which the menu item was selected is destroyed; however, you might want to display a confirmation dialog box or take another action instead of simply allowing the window to be destroyed. The callback procedure specified by ConfirmClose destroys the window when appropriate.
The ConfirmClose procedure you specify accepts two parameters: wid and user_data, where:
*wid — The widget ID of the top-level shell of the application.
*user_data — The variable specified via the User_Data keyword. If User_Data is not specified, 0 (zero) is passed to the ConfirmClose routine.
If specified, your ConfirmClose routine must close the top-level shell of the application. An example of a simple ConfirmClose routine which just closes the shell is:
PRO MyConfirmClose, wid, user_data
s = WwSetValue(wid, /Close)
END
If ConfirmClose is not specified, then the shell is simply closed.
Example
This example creates a Motif button labeled Done. When you select the button, the widget is destroyed. To run the example, enter the callback and the example procedures in a file and run them with .RUN.
Callback Procedure Example: Motif
PRO CancelHelp, wid, data, npar, reason, event, count
   COMMON block, top
   status=WtClose(top)
END
Example Procedure
PRO example
   COMMON block, top
   @wtxmclasses.pro
   top=WtInit('wt_ex3', 'Examples')
   widget=WtCreate('Done', xmPushButtonWidgetClass, top)
   status=WtAddCallback(widget, 'activateCallback', $
      'CancelHelp')
   status=WtSet(top, /Realize)
   WtLoop
END
See Also
For detailed information on GUI development, refer to the PV‑WAVE Application Developer’s Guide.
For more information about how to write an application program based on the PV‑WAVE Widget Toolbox, refer to Using the Widget Toolbox in the PV‑WAVE Application Developer’s Guide.

Version 2017.1
Copyright © 2019, Rogue Wave Software, Inc. All Rights Reserved.