10568f49bSmrg<?xml version="1.0" encoding="UTF-8" ?> 20568f49bSmrg<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.3//EN" "http://www.oasis-open.org/docbook/xml/4.3/docbookx.dtd"> 30568f49bSmrg 49e7bcd65Smrg<chapter id='Widget_Instantiation'> 59e7bcd65Smrg<title>Widget Instantiation</title> 69e7bcd65Smrg<para> 79e7bcd65SmrgA hierarchy of widget instances constitutes a widget tree. 89e7bcd65SmrgThe shell widget returned by 99e7bcd65Smrg<xref linkend='XtAppCreateShell' xrefstyle='select: title'/> 109e7bcd65Smrgis the root of the widget tree instance. 119e7bcd65SmrgThe widgets with one or more children are the intermediate nodes of that tree, 129e7bcd65Smrgand the widgets with no children of any kind are the leaves of the widget tree. 139e7bcd65SmrgWith the exception of pop-up children (see <xref linkend='Pop_Up_Widgets' />), 149e7bcd65Smrgthis widget tree instance defines the associated X Window tree. 159e7bcd65Smrg</para> 169e7bcd65Smrg 179e7bcd65Smrg<para> 189e7bcd65SmrgWidgets can be either composite or primitive. 199e7bcd65SmrgBoth kinds of widgets can contain children, 209e7bcd65Smrgbut the Intrinsics provide a set of management mechanisms for constructing 219e7bcd65Smrgand interfacing between composite widgets, their children, and 229e7bcd65Smrgother clients. 239e7bcd65Smrg</para> 249e7bcd65Smrg 259e7bcd65Smrg<para> 269e7bcd65SmrgComposite widgets, that is, members of the class 279e7bcd65Smrg<function>compositeWidgetClass</function>, 289e7bcd65Smrgare containers for an arbitrary, 299e7bcd65Smrgbut widget implementation-defined, collection of children, 309e7bcd65Smrgwhich may be instantiated by the composite widget itself, 319e7bcd65Smrgby other clients, or by a combination of the two. 329e7bcd65SmrgComposite widgets also contain methods for managing the geometry (layout) 339e7bcd65Smrgof any child widget. 349e7bcd65SmrgUnder unusual circumstances, 359e7bcd65Smrga composite widget may have zero children, 369e7bcd65Smrgbut it usually has at least one. 379e7bcd65SmrgBy contrast, 389e7bcd65Smrgprimitive widgets that contain children typically instantiate 399e7bcd65Smrgspecific children of known classes themselves and do not expect external 409e7bcd65Smrgclients to do so. 419e7bcd65SmrgPrimitive widgets also do not have general geometry management methods. 429e7bcd65Smrg</para> 439e7bcd65Smrg 449e7bcd65Smrg<para> 459e7bcd65SmrgIn addition, 469e7bcd65Smrgthe Intrinsics recursively perform many operations 479e7bcd65Smrg(for example, realization and destruction) 489e7bcd65Smrgon composite widgets and all their children. 499e7bcd65SmrgPrimitive widgets that have children must be prepared 509e7bcd65Smrgto perform the recursive operations themselves on behalf of their children. 519e7bcd65Smrg</para> 529e7bcd65Smrg 539e7bcd65Smrg<para> 549e7bcd65SmrgA widget tree is manipulated by several Intrinsics functions. 559e7bcd65SmrgFor example, 569e7bcd65Smrg<xref linkend='XtRealizeWidget' xrefstyle='select: title'/> 579e7bcd65Smrgtraverses the tree downward and recursively realizes all 589e7bcd65Smrgpop-up widgets and children of composite widgets. 599e7bcd65Smrg<xref linkend='XtDestroyWidget' xrefstyle='select: title'/> 609e7bcd65Smrgtraverses the tree downward and destroys all pop-up widgets 619e7bcd65Smrgand children of composite widgets. 629e7bcd65SmrgThe functions that fetch and modify resources traverse the tree upward 639e7bcd65Smrgand determine the inheritance of resources from a widget's ancestors. 649e7bcd65Smrg<xref linkend='XtMakeGeometryRequest' xrefstyle='select: title'/> 659e7bcd65Smrgtraverses the tree up one level and calls the geometry manager 669e7bcd65Smrgthat is responsible for a widget child's geometry. 679e7bcd65Smrg</para> 689e7bcd65Smrg 699e7bcd65Smrg<para> 709e7bcd65SmrgTo facilitate upward traversal of the widget tree, 719e7bcd65Smrgeach widget has a pointer to its parent widget. 729e7bcd65SmrgThe 739e7bcd65SmrgShell 749e7bcd65Smrgwidget that 759e7bcd65Smrg<xref linkend='XtAppCreateShell' xrefstyle='select: title'/> 769e7bcd65Smrgreturns has a <emphasis remap='I'>parent</emphasis> pointer of NULL. 779e7bcd65Smrg</para> 789e7bcd65Smrg 799e7bcd65Smrg<para> 809e7bcd65SmrgTo facilitate downward traversal of the widget tree, 819e7bcd65Smrgthe <emphasis remap='I'>children</emphasis> field of 829e7bcd65Smrgeach composite widget is a pointer to an array of child widgets, 839e7bcd65Smrgwhich includes all normal children created, 849e7bcd65Smrgnot just the subset of children that are managed by the composite widget's 859e7bcd65Smrggeometry manager. 869e7bcd65SmrgPrimitive widgets 879e7bcd65Smrgthat instantiate children are entirely responsible for all operations 889e7bcd65Smrgthat require downward traversal below themselves. 899e7bcd65SmrgIn addition, 909e7bcd65Smrgevery widget has a pointer to an array of pop-up children. 919e7bcd65Smrg</para> 929e7bcd65Smrg 939e7bcd65Smrg<sect1 id="Initializing_the_tk"> 949e7bcd65Smrg<title>Initializing the X Toolkit</title> 959e7bcd65Smrg<para> 969e7bcd65SmrgBefore an application can call any Intrinsics function 979e7bcd65Smrgother than 989e7bcd65Smrg<function>XtSetLanguageProc</function> 999e7bcd65Smrgand 1009e7bcd65Smrg<xref linkend='XtToolkitThreadInitialize' xrefstyle='select: title'/>, 1019e7bcd65Smrgit must initialize the Intrinsics by using 1029e7bcd65Smrg</para> 1039e7bcd65Smrg<itemizedlist spacing='compact'> 1049e7bcd65Smrg <listitem> 1059e7bcd65Smrg <para> 1069e7bcd65Smrg<xref linkend='XtToolkitInitialize' xrefstyle='select: title'/>, 1079e7bcd65Smrgwhich initializes the Intrinsics internals 1089e7bcd65Smrg </para> 1099e7bcd65Smrg </listitem> 1109e7bcd65Smrg <listitem> 1119e7bcd65Smrg <para> 1129e7bcd65Smrg<xref linkend='XtCreateApplicationContext' xrefstyle='select: title'/>, 1139e7bcd65Smrgwhich initializes the per-application state 1149e7bcd65Smrg </para> 1159e7bcd65Smrg </listitem> 1169e7bcd65Smrg <listitem> 1179e7bcd65Smrg <para> 1189e7bcd65Smrg<xref linkend='XtDisplayInitialize' xrefstyle='select: title'/> 1199e7bcd65Smrgor 1209e7bcd65Smrg<xref linkend='XtOpenDisplay' xrefstyle='select: title'/>, 1219e7bcd65Smrgwhich initializes the per-display state 1229e7bcd65Smrg </para> 1239e7bcd65Smrg </listitem> 1249e7bcd65Smrg <listitem> 1259e7bcd65Smrg <para> 1269e7bcd65Smrg<xref linkend='XtAppCreateShell' xrefstyle='select: title'/>, 1279e7bcd65Smrgwhich creates the root of a widget tree 1289e7bcd65Smrg </para> 1299e7bcd65Smrg </listitem> 1309e7bcd65Smrg</itemizedlist> 1319e7bcd65Smrg<para> 1329e7bcd65SmrgOr an application can call the convenience procedure 1339e7bcd65Smrg<xref linkend='XtOpenApplication' xrefstyle='select: title'/>, 1349e7bcd65Smrgwhich combines the functions of the preceding procedures. 1359e7bcd65SmrgAn application wishing to use the ANSI C locale mechanism should call 1369e7bcd65Smrg<function>XtSetLanguageProc</function> 1379e7bcd65Smrgprior to calling 1389e7bcd65Smrg<xref linkend='XtDisplayInitialize' xrefstyle='select: title'/>, 1399e7bcd65Smrg<xref linkend='XtOpenDisplay' xrefstyle='select: title'/>, 1409e7bcd65Smrg<xref linkend='XtOpenApplication' xrefstyle='select: title'/>, 1419e7bcd65Smrgor 1429e7bcd65Smrg<xref linkend='XtAppInitialize' xrefstyle='select: title'/>. 1439e7bcd65Smrg</para> 1449e7bcd65Smrg 1459e7bcd65Smrg<para> 1469e7bcd65SmrgMultiple instances of X Toolkit applications may be implemented 1479e7bcd65Smrgin a single address space. 1489e7bcd65SmrgEach instance needs to be able to read 1499e7bcd65Smrginput and dispatch events independently of any other instance. 1509e7bcd65SmrgFurther, an application instance may need multiple display connections 1519e7bcd65Smrgto have widgets on multiple displays. 1529e7bcd65SmrgFrom the application's point of view, multiple display connections 1539e7bcd65Smrgusually are treated together as a single unit 1549e7bcd65Smrgfor purposes of event dispatching. 1559e7bcd65SmrgTo accommodate both requirements, 1569e7bcd65Smrgthe Intrinsics define application contexts, 1579e7bcd65Smrgeach of which provides the information needed to distinguish one application 1589e7bcd65Smrginstance from another. 1599e7bcd65SmrgThe major component of an application context is a list of one or more X 1609e7bcd65Smrg<function>Display</function> 1619e7bcd65Smrgpointers for that application. 1629e7bcd65SmrgThe Intrinsics handle all display connections within a single application 1639e7bcd65Smrgcontext simultaneously, handling input in a round-robin fashion. 1649e7bcd65SmrgThe application context type 1659e7bcd65Smrg<function>XtAppContext</function> 1669e7bcd65Smrgis opaque to clients. 1679e7bcd65Smrg</para> 1689e7bcd65Smrg 1699e7bcd65Smrg<para> 1709e7bcd65SmrgTo initialize the Intrinsics internals, use 1719e7bcd65Smrg<xref linkend='XtToolkitInitialize' xrefstyle='select: title'/>. 1729e7bcd65Smrg</para> 1739e7bcd65Smrg 1749e7bcd65Smrg<funcsynopsis id='XtToolkitInitialize'> 1759e7bcd65Smrg<funcprototype> 1769e7bcd65Smrg <funcdef>void <function>XtToolkitInitialize</function></funcdef> 1770568f49bSmrg <paramdef><parameter>void</parameter></paramdef> 1789e7bcd65Smrg</funcprototype> 1799e7bcd65Smrg</funcsynopsis> 1809e7bcd65Smrg 1819e7bcd65Smrg<para> 1829e7bcd65SmrgIf 1839e7bcd65Smrg<xref linkend='XtToolkitInitialize' xrefstyle='select: title'/> 1849e7bcd65Smrgwas previously called, it returns immediately. 1859e7bcd65SmrgWhen 1869e7bcd65Smrg<xref linkend='XtToolkitThreadInitialize' xrefstyle='select: title'/> 1879e7bcd65Smrgis called before 1889e7bcd65Smrg<xref linkend='XtToolkitInitialize' xrefstyle='select: title'/>, 1899e7bcd65Smrgthe latter is protected against 1909e7bcd65Smrgsimultaneous activation by multiple threads. 1919e7bcd65Smrg</para> 1929e7bcd65Smrg 1939e7bcd65Smrg<para> 1949e7bcd65SmrgTo create an application context, use 1959e7bcd65Smrg<xref linkend='XtCreateApplicationContext' xrefstyle='select: title'/>. 1969e7bcd65Smrg</para> 1979e7bcd65Smrg 1989e7bcd65Smrg<funcsynopsis id='XtCreateApplicationContext'> 1999e7bcd65Smrg<funcprototype> 2009e7bcd65Smrg <funcdef>XtAppContext <function>XtCreateApplicationContext</function></funcdef> 2010568f49bSmrg <paramdef><parameter>void</parameter></paramdef> 2029e7bcd65Smrg</funcprototype> 2039e7bcd65Smrg</funcsynopsis> 2049e7bcd65Smrg 2059e7bcd65Smrg 2069e7bcd65Smrg<para> 2079e7bcd65SmrgThe 2089e7bcd65Smrg<xref linkend='XtCreateApplicationContext' xrefstyle='select: title'/> 2099e7bcd65Smrgfunction returns an application context, 2109e7bcd65Smrgwhich is an opaque type. 2119e7bcd65SmrgEvery application must have at least one application context. 2129e7bcd65Smrg</para> 2139e7bcd65Smrg 2149e7bcd65Smrg<para> 2159e7bcd65SmrgTo destroy an application context and close any 2169e7bcd65Smrgremaining display connections in it, use 2179e7bcd65Smrg<xref linkend='XtDestroyApplicationContext' xrefstyle='select: title'/>. 2189e7bcd65Smrg</para> 2199e7bcd65Smrg 2209e7bcd65Smrg<funcsynopsis id='XtDestroyApplicationContext'> 2219e7bcd65Smrg<funcprototype> 2229e7bcd65Smrg <funcdef>void <function>XtDestroyApplicationContext</function></funcdef> 2239e7bcd65Smrg <paramdef>XtAppContext <parameter>app_context</parameter></paramdef> 2249e7bcd65Smrg</funcprototype> 2259e7bcd65Smrg</funcsynopsis> 2269e7bcd65Smrg 2279e7bcd65Smrg<variablelist> 2289e7bcd65Smrg <varlistentry> 2299e7bcd65Smrg <term> 2309e7bcd65Smrg <emphasis remap='I'>app_context</emphasis> 2319e7bcd65Smrg </term> 2329e7bcd65Smrg <listitem> 2339e7bcd65Smrg <para> 2349e7bcd65SmrgSpecifies the application context. 2359e7bcd65Smrg </para> 2369e7bcd65Smrg </listitem> 2379e7bcd65Smrg </varlistentry> 2389e7bcd65Smrg</variablelist> 2399e7bcd65Smrg 2409e7bcd65Smrg<para> 2419e7bcd65SmrgThe 2429e7bcd65Smrg<xref linkend='XtDestroyApplicationContext' xrefstyle='select: title'/> 2439e7bcd65Smrgfunction destroys the specified application context. 2449e7bcd65SmrgIf called from within an event dispatch (for example, in a callback procedure), 2459e7bcd65Smrg<xref linkend='XtDestroyApplicationContext' xrefstyle='select: title'/> 2469e7bcd65Smrgdoes not destroy the application context until the dispatch is complete. 2479e7bcd65Smrg</para> 2489e7bcd65Smrg 2499e7bcd65Smrg<para> 2509e7bcd65SmrgTo get the application context in which a given widget was created, use 2519e7bcd65Smrg<xref linkend='XtWidgetToApplicationContext' xrefstyle='select: title'/>. 2529e7bcd65Smrg</para> 2539e7bcd65Smrg 2549e7bcd65Smrg<funcsynopsis id='XtWidgetToApplicationContext'> 2559e7bcd65Smrg<funcprototype> 2569e7bcd65Smrg <funcdef>XtAppContext <function>XtWidgetToApplicationContext</function></funcdef> 2579e7bcd65Smrg <paramdef>Widget <parameter>w</parameter></paramdef> 2589e7bcd65Smrg</funcprototype> 2599e7bcd65Smrg</funcsynopsis> 2609e7bcd65Smrg 2619e7bcd65Smrg<variablelist> 2629e7bcd65Smrg <varlistentry> 2639e7bcd65Smrg <term> 2649e7bcd65Smrg <emphasis remap='I'>w</emphasis> 2659e7bcd65Smrg </term> 2669e7bcd65Smrg <listitem> 2679e7bcd65Smrg <para> 2689e7bcd65SmrgSpecifies the widget for which you want the application context. Must be of class Object or any subclass thereof. 2699e7bcd65Smrg </para> 2709e7bcd65Smrg </listitem> 2719e7bcd65Smrg </varlistentry> 2729e7bcd65Smrg</variablelist> 2739e7bcd65Smrg 2749e7bcd65Smrg<para> 2759e7bcd65SmrgThe 2769e7bcd65Smrg<xref linkend='XtWidgetToApplicationContext' xrefstyle='select: title'/> 2779e7bcd65Smrgfunction returns the application context for the specified widget. 2789e7bcd65Smrg</para> 2799e7bcd65Smrg 2809e7bcd65Smrg<para> 2819e7bcd65SmrgTo initialize a display and add it to an application context, use 2829e7bcd65Smrg<xref linkend='XtDisplayInitialize' xrefstyle='select: title'/>. 2839e7bcd65Smrg</para> 2849e7bcd65Smrg 2859e7bcd65Smrg<funcsynopsis id='XtDisplayInitialize'> 2869e7bcd65Smrg<funcprototype> 2879e7bcd65Smrg <funcdef>void <function>XtDisplayInitialize</function></funcdef> 2889e7bcd65Smrg <paramdef>XtAppContext <parameter>app_context</parameter></paramdef> 2899e7bcd65Smrg <paramdef>Display * <parameter>display</parameter></paramdef> 2900568f49bSmrg <paramdef>const char * <parameter>application_name</parameter></paramdef> 2910568f49bSmrg <paramdef>const char * <parameter>application_class</parameter></paramdef> 2929e7bcd65Smrg <paramdef>XrmOptionDescRec * <parameter>options</parameter></paramdef> 2939e7bcd65Smrg <paramdef>Cardinal <parameter>num_options</parameter></paramdef> 2949e7bcd65Smrg <paramdef>int * <parameter>argc</parameter></paramdef> 2950568f49bSmrg <paramdef>char ** <parameter>argv</parameter></paramdef> 2969e7bcd65Smrg</funcprototype> 2979e7bcd65Smrg</funcsynopsis> 2989e7bcd65Smrg 2999e7bcd65Smrg<variablelist> 3009e7bcd65Smrg <varlistentry> 3019e7bcd65Smrg <term> 3029e7bcd65Smrg <emphasis remap='I'>app_context</emphasis> 3039e7bcd65Smrg </term> 3049e7bcd65Smrg <listitem> 3059e7bcd65Smrg <para> 3069e7bcd65SmrgSpecifies the application context. 3079e7bcd65Smrg </para> 3089e7bcd65Smrg </listitem> 3099e7bcd65Smrg </varlistentry> 3109e7bcd65Smrg <varlistentry> 3119e7bcd65Smrg <term> 3129e7bcd65Smrg <emphasis remap='I'>display</emphasis> 3139e7bcd65Smrg </term> 3149e7bcd65Smrg <listitem> 3159e7bcd65Smrg <para> 3169e7bcd65SmrgSpecifies a previously opened display connection. Note that a single 3179e7bcd65Smrgdisplay connection can be in at most one application context. 3189e7bcd65Smrg </para> 3199e7bcd65Smrg </listitem> 3209e7bcd65Smrg </varlistentry> 3219e7bcd65Smrg <varlistentry> 3229e7bcd65Smrg <term> 3239e7bcd65Smrg <emphasis remap='I'>application_name</emphasis> 3249e7bcd65Smrg </term> 3259e7bcd65Smrg <listitem> 3269e7bcd65Smrg <para> 3279e7bcd65SmrgSpecifies the name of the application instance. 3289e7bcd65Smrg </para> 3299e7bcd65Smrg </listitem> 3309e7bcd65Smrg </varlistentry> 3319e7bcd65Smrg <varlistentry> 3329e7bcd65Smrg <term> 3339e7bcd65Smrg <emphasis remap='I'>application_class</emphasis> 3349e7bcd65Smrg </term> 3359e7bcd65Smrg <listitem> 3369e7bcd65Smrg <para> 3379e7bcd65SmrgSpecifies the class name of this application, 3389e7bcd65Smrgwhich is usually the generic name for all instances of this application. 3399e7bcd65Smrg </para> 3409e7bcd65Smrg </listitem> 3419e7bcd65Smrg </varlistentry> 3429e7bcd65Smrg <varlistentry> 3439e7bcd65Smrg <term> 3449e7bcd65Smrg <emphasis remap='I'>options</emphasis> 3459e7bcd65Smrg </term> 3469e7bcd65Smrg <listitem> 3479e7bcd65Smrg <para> 3489e7bcd65SmrgSpecifies how to parse the command line for any application-specific resources. 3499e7bcd65SmrgThe <emphasis remap='I'>options</emphasis> argument is passed as a parameter to 3509e7bcd65Smrg<function>XrmParseCommand</function>. 3519e7bcd65SmrgFor further information, 3520568f49bSmrgsee <olink targetdoc='libX11' targetptr='Parsing_Command_Line_Options'>Parsing Command Line Options</olink> in <olink targetdoc='libX11' targetptr='libX11'>Xlib — C Language X Interface</olink> and <xref linkend='Parsing_the_Command_Line' /> of this specification. 3539e7bcd65Smrg </para> 3549e7bcd65Smrg </listitem> 3559e7bcd65Smrg </varlistentry> 3569e7bcd65Smrg <varlistentry> 3579e7bcd65Smrg <term> 3589e7bcd65Smrg <emphasis remap='I'>num_options</emphasis> 3599e7bcd65Smrg </term> 3609e7bcd65Smrg <listitem> 3619e7bcd65Smrg <para> 3629e7bcd65SmrgSpecifies the number of entries in the options list. 3639e7bcd65Smrg </para> 3649e7bcd65Smrg </listitem> 3659e7bcd65Smrg </varlistentry> 3669e7bcd65Smrg <varlistentry> 3679e7bcd65Smrg <term> 3689e7bcd65Smrg <emphasis remap='I'>argc</emphasis> 3699e7bcd65Smrg </term> 3709e7bcd65Smrg <listitem> 3719e7bcd65Smrg <para> 3729e7bcd65SmrgSpecifies a pointer to the number of command line parameters. 3739e7bcd65Smrg </para> 3749e7bcd65Smrg </listitem> 3759e7bcd65Smrg </varlistentry> 3769e7bcd65Smrg <varlistentry> 3779e7bcd65Smrg <term> 3789e7bcd65Smrg <emphasis remap='I'>argv</emphasis> 3799e7bcd65Smrg </term> 3809e7bcd65Smrg <listitem> 3819e7bcd65Smrg <para> 3829e7bcd65SmrgSpecifies the list of command line parameters. 3839e7bcd65Smrg </para> 3849e7bcd65Smrg </listitem> 3859e7bcd65Smrg </varlistentry> 3869e7bcd65Smrg</variablelist> 3879e7bcd65Smrg 3889e7bcd65Smrg<para> 3899e7bcd65SmrgThe 3909e7bcd65Smrg<xref linkend='XtDisplayInitialize' xrefstyle='select: title'/> 3919e7bcd65Smrgfunction retrieves the language string to be 3929e7bcd65Smrgused for the specified display (see <xref linkend='Finding_File_Names' />), 3939e7bcd65Smrgcalls the language procedure (if set) with that language string, 3949e7bcd65Smrgbuilds the resource database for the default screen, calls the Xlib 3959e7bcd65Smrg<function>XrmParseCommand</function> 3969e7bcd65Smrgfunction to parse the command line, 3979e7bcd65Smrgand performs other per-display initialization. 3989e7bcd65SmrgAfter 3999e7bcd65Smrg<function>XrmParseCommand</function> 4009e7bcd65Smrghas been called, 4019e7bcd65Smrg<emphasis remap='I'>argc</emphasis> and <emphasis remap='I'>argv</emphasis> contain only those parameters that 4029e7bcd65Smrgwere not in the standard option table or in the table specified by the 4039e7bcd65Smrg<emphasis remap='I'>options</emphasis> argument. 4049e7bcd65SmrgIf the modified <emphasis remap='I'>argc</emphasis> is not zero, 4059e7bcd65Smrgmost applications simply print out the modified <emphasis remap='I'>argv</emphasis> along with a message 4069e7bcd65Smrglisting the allowable options. 4079e7bcd65SmrgOn POSIX-based systems, 4089e7bcd65Smrgthe application name is usually the final component of <emphasis remap='I'>argv</emphasis>[0]. 4099e7bcd65SmrgIf the synchronous resource is 4109e7bcd65Smrg<function>True</function>, 4119e7bcd65Smrg<xref linkend='XtDisplayInitialize' xrefstyle='select: title'/> 4129e7bcd65Smrgcalls the Xlib 4139e7bcd65Smrg<function>XSynchronize</function> 4149e7bcd65Smrgfunction to put Xlib into synchronous mode for this display connection 4159e7bcd65Smrgand any others currently open in the application context. 4169e7bcd65SmrgSee <xref linkend='Loading_the_Resource_Database' /> 4179e7bcd65Smrgand <xref linkend='Parsing_the_Command_Line' /> 4189e7bcd65Smrgfor details on the <emphasis remap='I'>application_name</emphasis>, 4199e7bcd65Smrg<emphasis remap='I'>application_class</emphasis>, <emphasis remap='I'>options</emphasis>, and <emphasis remap='I'>num_options</emphasis> arguments. 4209e7bcd65Smrg</para> 4219e7bcd65Smrg 4229e7bcd65Smrg<para> 4239e7bcd65Smrg<xref linkend='XtDisplayInitialize' xrefstyle='select: title'/> 4249e7bcd65Smrgcalls 4259e7bcd65Smrg<function>XrmSetDatabase</function> 4269e7bcd65Smrgto associate the resource database of the default screen with the 4279e7bcd65Smrgdisplay before returning. 4289e7bcd65Smrg</para> 4299e7bcd65Smrg 4309e7bcd65Smrg<para> 4319e7bcd65SmrgTo open a display, initialize it, and then 4329e7bcd65Smrgadd it to an application context, use 4339e7bcd65Smrg<xref linkend='XtOpenDisplay' xrefstyle='select: title'/>. 4349e7bcd65Smrg</para> 4359e7bcd65Smrg 4369e7bcd65Smrg<funcsynopsis id='XtOpenDisplay'> 4379e7bcd65Smrg<funcprototype> 4380568f49bSmrg <funcdef>Display *<function>XtOpenDisplay</function></funcdef> 4399e7bcd65Smrg <paramdef>XtAppContext <parameter>app_context</parameter></paramdef> 4400568f49bSmrg <paramdef>const char * <parameter>display_string</parameter></paramdef> 4410568f49bSmrg <paramdef>const char * <parameter>application_name</parameter></paramdef> 4420568f49bSmrg <paramdef>const char * <parameter>application_class</parameter></paramdef> 4439e7bcd65Smrg <paramdef>XrmOptionDescRec * <parameter>options</parameter></paramdef> 4449e7bcd65Smrg <paramdef>Cardinal <parameter>num_options</parameter></paramdef> 4459e7bcd65Smrg <paramdef>int * <parameter>argc</parameter></paramdef> 4460568f49bSmrg <paramdef>char ** <parameter>argv</parameter></paramdef> 4479e7bcd65Smrg</funcprototype> 4489e7bcd65Smrg</funcsynopsis> 4499e7bcd65Smrg 4509e7bcd65Smrg 4519e7bcd65Smrg 4529e7bcd65Smrg 4539e7bcd65Smrg<variablelist> 4549e7bcd65Smrg <varlistentry> 4559e7bcd65Smrg <term> 4569e7bcd65Smrg <emphasis remap='I'>app_context</emphasis> 4579e7bcd65Smrg </term> 4589e7bcd65Smrg <listitem> 4599e7bcd65Smrg <para> 4609e7bcd65SmrgSpecifies the application context. 4619e7bcd65Smrg </para> 4629e7bcd65Smrg </listitem> 4639e7bcd65Smrg </varlistentry> 4649e7bcd65Smrg <varlistentry> 4659e7bcd65Smrg <term> 4669e7bcd65Smrg <emphasis remap='I'>display_string</emphasis> 4679e7bcd65Smrg </term> 4689e7bcd65Smrg <listitem> 4699e7bcd65Smrg <para> 4709e7bcd65SmrgSpecifies the display string, or NULL. 4719e7bcd65Smrg </para> 4729e7bcd65Smrg </listitem> 4739e7bcd65Smrg </varlistentry> 4749e7bcd65Smrg <varlistentry> 4759e7bcd65Smrg <term> 4769e7bcd65Smrg <emphasis remap='I'>application_name</emphasis> 4779e7bcd65Smrg </term> 4789e7bcd65Smrg <listitem> 4799e7bcd65Smrg <para> 4809e7bcd65SmrgSpecifies the name of the application instance, or NULL. 4819e7bcd65Smrg </para> 4829e7bcd65Smrg </listitem> 4839e7bcd65Smrg </varlistentry> 4849e7bcd65Smrg <varlistentry> 4859e7bcd65Smrg <term> 4869e7bcd65Smrg <emphasis remap='I'>application_class</emphasis> 4879e7bcd65Smrg </term> 4889e7bcd65Smrg <listitem> 4899e7bcd65Smrg <para> 4909e7bcd65SmrgSpecifies the class name of this application, 4919e7bcd65Smrgwhich is usually the generic name for all instances of this application. 4929e7bcd65Smrg </para> 4939e7bcd65Smrg </listitem> 4949e7bcd65Smrg </varlistentry> 4959e7bcd65Smrg <varlistentry> 4969e7bcd65Smrg <term> 4979e7bcd65Smrg <emphasis remap='I'>options</emphasis> 4989e7bcd65Smrg </term> 4999e7bcd65Smrg <listitem> 5009e7bcd65Smrg <para> 5019e7bcd65SmrgSpecifies how to parse the command line for any application-specific resources. 5029e7bcd65SmrgThe options argument is passed as a parameter to 5039e7bcd65Smrg<function>XrmParseCommand</function>. 5049e7bcd65Smrg </para> 5059e7bcd65Smrg </listitem> 5069e7bcd65Smrg </varlistentry> 5079e7bcd65Smrg <varlistentry> 5089e7bcd65Smrg <term> 5099e7bcd65Smrg <emphasis remap='I'>num_options</emphasis> 5109e7bcd65Smrg </term> 5119e7bcd65Smrg <listitem> 5129e7bcd65Smrg <para> 5139e7bcd65SmrgSpecifies the number of entries in the options list. 5149e7bcd65Smrg </para> 5159e7bcd65Smrg </listitem> 5169e7bcd65Smrg </varlistentry> 5179e7bcd65Smrg <varlistentry> 5189e7bcd65Smrg <term> 5199e7bcd65Smrg <emphasis remap='I'>argc</emphasis> 5209e7bcd65Smrg </term> 5219e7bcd65Smrg <listitem> 5229e7bcd65Smrg <para> 5239e7bcd65SmrgSpecifies a pointer to the number of command line parameters. 5249e7bcd65Smrg </para> 5259e7bcd65Smrg </listitem> 5269e7bcd65Smrg </varlistentry> 5279e7bcd65Smrg <varlistentry> 5289e7bcd65Smrg <term> 5299e7bcd65Smrg <emphasis remap='I'>argv</emphasis> 5309e7bcd65Smrg </term> 5319e7bcd65Smrg <listitem> 5329e7bcd65Smrg <para> 5339e7bcd65SmrgSpecifies the list of command line parameters. 5349e7bcd65Smrg </para> 5359e7bcd65Smrg </listitem> 5369e7bcd65Smrg </varlistentry> 5379e7bcd65Smrg</variablelist> 5389e7bcd65Smrg 5399e7bcd65Smrg<para> 5409e7bcd65SmrgThe 5419e7bcd65Smrg<xref linkend='XtOpenDisplay' xrefstyle='select: title'/> 5429e7bcd65Smrgfunction calls 5439e7bcd65Smrg<function>XOpenDisplay</function> 5449e7bcd65Smrgwith the specified <emphasis remap='I'>display_string</emphasis>. 5459e7bcd65SmrgIf <emphasis remap='I'>display_string</emphasis> is NULL, 5469e7bcd65Smrg<xref linkend='XtOpenDisplay' xrefstyle='select: title'/> 5470568f49bSmrguses the current value of the -display option specified in <emphasis remap='I'>argv</emphasis>. 5489e7bcd65SmrgIf no display is specified in <emphasis remap='I'>argv</emphasis>, 5499e7bcd65Smrgthe user's default display is retrieved from the environment. 5509e7bcd65SmrgOn POSIX-based systems, 5519e7bcd65Smrgthis is the value of the 5529e7bcd65Smrg<emphasis role='strong'>DISPLAY</emphasis> 5539e7bcd65Smrgenvironment variable. 5549e7bcd65Smrg</para> 5559e7bcd65Smrg 5569e7bcd65Smrg<para> 5579e7bcd65SmrgIf this succeeds, 5589e7bcd65Smrg<xref linkend='XtOpenDisplay' xrefstyle='select: title'/> 5599e7bcd65Smrgthen calls 5609e7bcd65Smrg<xref linkend='XtDisplayInitialize' xrefstyle='select: title'/> 5619e7bcd65Smrgand passes it the opened display and 5620568f49bSmrgthe value of the -name option specified in <emphasis remap='I'>argv</emphasis> as the application name. 5630568f49bSmrgIf no -name option is specified 5649e7bcd65Smrgand <emphasis remap='I'>application_name</emphasis> is 5659e7bcd65Smrgnon-NULL, <emphasis remap='I'>application_name</emphasis> is passed to 5669e7bcd65Smrg<xref linkend='XtDisplayInitialize' xrefstyle='select: title'/>. 5679e7bcd65SmrgIf <emphasis remap='I'>application_name</emphasis> is NULL and if the environment variable 5689e7bcd65Smrg<emphasis role='strong'>RESOURCE_NAME</emphasis> 5699e7bcd65Smrgis set, the value of 5709e7bcd65Smrg<emphasis role='strong'>RESOURCE_NAME</emphasis> 5719e7bcd65Smrgis used. Otherwise, the application 5729e7bcd65Smrgname is the name used to invoke the program. On implementations that 5739e7bcd65Smrgconform to ANSI C Hosted Environment support, the application name will 5749e7bcd65Smrgbe <emphasis remap='I'>argv</emphasis>[0] less any directory and file type components, that is, the 5759e7bcd65Smrgfinal component of <emphasis remap='I'>argv</emphasis>[0], if specified. If <emphasis remap='I'>argv</emphasis>[0] does not exist or 5760568f49bSmrgis the empty string, the application name is “main”. 5779e7bcd65Smrg<xref linkend='XtOpenDisplay' xrefstyle='select: title'/> 5789e7bcd65Smrgreturns the newly opened display or NULL if it failed. 5799e7bcd65Smrg</para> 5809e7bcd65Smrg 5819e7bcd65Smrg<para> 5829e7bcd65SmrgSee <xref linkend='Using_the_Intrinsics_in_a_Multi_Threaded_Environment' /> 5839e7bcd65Smrgfor information regarding the use of 5849e7bcd65Smrg<xref linkend='XtOpenDisplay' xrefstyle='select: title'/> 5859e7bcd65Smrgin multiple threads. 5869e7bcd65Smrg</para> 5879e7bcd65Smrg 5889e7bcd65Smrg<para> 5899e7bcd65SmrgTo close a display and remove it from an application context, use 5909e7bcd65Smrg<xref linkend='XtCloseDisplay' xrefstyle='select: title'/>. 5919e7bcd65Smrg</para> 5929e7bcd65Smrg 5939e7bcd65Smrg<funcsynopsis id='XtCloseDisplay'> 5949e7bcd65Smrg<funcprototype> 5959e7bcd65Smrg <funcdef>void <function>XtCloseDisplay</function></funcdef> 5969e7bcd65Smrg <paramdef>Display * <parameter>display</parameter></paramdef> 5979e7bcd65Smrg</funcprototype> 5989e7bcd65Smrg</funcsynopsis> 5999e7bcd65Smrg 6009e7bcd65Smrg<variablelist> 6019e7bcd65Smrg <varlistentry> 6029e7bcd65Smrg <term> 6039e7bcd65Smrg <emphasis remap='I'>display</emphasis> 6049e7bcd65Smrg </term> 6059e7bcd65Smrg <listitem> 6069e7bcd65Smrg <para> 6079e7bcd65SmrgSpecifies the display. 6089e7bcd65Smrg </para> 6099e7bcd65Smrg </listitem> 6109e7bcd65Smrg </varlistentry> 6119e7bcd65Smrg</variablelist> 6129e7bcd65Smrg 6139e7bcd65Smrg<para> 6149e7bcd65SmrgThe 6159e7bcd65Smrg<xref linkend='XtCloseDisplay' xrefstyle='select: title'/> 6169e7bcd65Smrgfunction calls 6179e7bcd65Smrg<function>XCloseDisplay</function> 6189e7bcd65Smrgwith the specified <emphasis remap='I'>display</emphasis> as soon as it is safe to do so. 6199e7bcd65SmrgIf called from within an event dispatch (for example, a callback procedure), 6209e7bcd65Smrg<xref linkend='XtCloseDisplay' xrefstyle='select: title'/> 6219e7bcd65Smrgdoes not close the display until the dispatch is complete. 6229e7bcd65SmrgNote that applications need only call 6239e7bcd65Smrg<xref linkend='XtCloseDisplay' xrefstyle='select: title'/> 6249e7bcd65Smrgif they are to continue executing after closing the display; 6259e7bcd65Smrgotherwise, they should call 6269e7bcd65Smrg<xref linkend='XtDestroyApplicationContext' xrefstyle='select: title'/>. 6279e7bcd65Smrg</para> 6289e7bcd65Smrg 6299e7bcd65Smrg<para> 6309e7bcd65SmrgSee <xref linkend='Using_the_Intrinsics_in_a_Multi_Threaded_Environment' /> 6319e7bcd65Smrgfor information regarding the use of 6329e7bcd65Smrg<xref linkend='XtCloseDisplay' xrefstyle='select: title'/> 6339e7bcd65Smrgin multiple threads. 6349e7bcd65Smrg</para> 6359e7bcd65Smrg</sect1> 6369e7bcd65Smrg 6379e7bcd65Smrg<sect1 id="Establishing_the_Locale"> 6389e7bcd65Smrg<title>Establishing the Locale</title> 6399e7bcd65Smrg<para> 6409e7bcd65SmrgResource databases are specified to be created in the current process 6419e7bcd65Smrglocale. During display initialization prior to creating the 6429e7bcd65Smrgper-screen resource database, the Intrinsics will call out to a specified 6439e7bcd65Smrgapplication procedure to set the locale according to options found on 6449e7bcd65Smrgthe command line or in the per-display resource specifications. 6459e7bcd65Smrg</para> 6469e7bcd65Smrg 6479e7bcd65Smrg<para> 6489e7bcd65SmrgThe callout procedure provided by the application is of type 6499e7bcd65Smrg<function>XtLanguageProc</function>. 6509e7bcd65Smrg</para> 6519e7bcd65Smrg 6529e7bcd65Smrg<funcsynopsis> 6539e7bcd65Smrg<funcprototype> 6549e7bcd65Smrg <funcdef>typedef String <function>(*XtLanguageProc)</function></funcdef> 6559e7bcd65Smrg <paramdef>Display <parameter>display</parameter></paramdef> 6569e7bcd65Smrg <paramdef>String <parameter>language</parameter></paramdef> 6579e7bcd65Smrg <paramdef>XtPointer <parameter>client_data</parameter></paramdef> 6589e7bcd65Smrg</funcprototype> 6599e7bcd65Smrg</funcsynopsis> 6609e7bcd65Smrg 6619e7bcd65Smrg<variablelist> 6629e7bcd65Smrg <varlistentry> 6639e7bcd65Smrg <term> 6649e7bcd65Smrg <emphasis remap='I'>display</emphasis> 6659e7bcd65Smrg </term> 6669e7bcd65Smrg <listitem> 6679e7bcd65Smrg <para> 6689e7bcd65SmrgPasses the display. 6699e7bcd65Smrg </para> 6709e7bcd65Smrg </listitem> 6719e7bcd65Smrg </varlistentry> 6729e7bcd65Smrg <varlistentry> 6739e7bcd65Smrg <term> 6749e7bcd65Smrg <emphasis remap='I'>language</emphasis> 6759e7bcd65Smrg </term> 6769e7bcd65Smrg <listitem> 6779e7bcd65Smrg <para> 6789e7bcd65SmrgPasses the initial language value obtained from the command line 6799e7bcd65Smrgor server per-display resource specifications. 6809e7bcd65Smrg </para> 6819e7bcd65Smrg </listitem> 6829e7bcd65Smrg </varlistentry> 6839e7bcd65Smrg <varlistentry> 6849e7bcd65Smrg <term> 6859e7bcd65Smrg <emphasis remap='I'>client_data</emphasis> 6869e7bcd65Smrg </term> 6879e7bcd65Smrg <listitem> 6889e7bcd65Smrg <para> 6899e7bcd65SmrgPasses the additional client data specified in the call to 6909e7bcd65Smrg<function>XtSetLanguageProc</function>. 6919e7bcd65Smrg </para> 6929e7bcd65Smrg </listitem> 6939e7bcd65Smrg </varlistentry> 6949e7bcd65Smrg</variablelist> 6959e7bcd65Smrg<para> 6969e7bcd65SmrgThe language procedure allows an application to set the locale to 6979e7bcd65Smrgthe value of the language resource determined by 6989e7bcd65Smrg<xref linkend='XtDisplayInitialize' xrefstyle='select: title'/>. 6999e7bcd65SmrgThe function returns a new language string that 7009e7bcd65Smrgwill be subsequently used by 7019e7bcd65Smrg<xref linkend='XtDisplayInitialize' xrefstyle='select: title'/> 7029e7bcd65Smrgto establish the path for loading resource files. The returned 7039e7bcd65Smrgstring will be copied by the Intrinsics into new memory. 7049e7bcd65Smrg</para> 7059e7bcd65Smrg 7069e7bcd65Smrg<para> 7079e7bcd65SmrgInitially, no language procedure is set by the Intrinsics. 7089e7bcd65SmrgTo set the language procedure for use by 7099e7bcd65Smrg<xref linkend='XtDisplayInitialize' xrefstyle='select: title'/>, 7109e7bcd65Smrguse 7119e7bcd65Smrg<function>XtSetLanguageProc</function>. 7129e7bcd65Smrg</para> 7139e7bcd65Smrg 7149e7bcd65Smrg<funcsynopsis> 7159e7bcd65Smrg<funcprototype> 7169e7bcd65Smrg <funcdef>XtLanguageProc <function>XtSetLanguageProc</function></funcdef> 7179e7bcd65Smrg <paramdef>XtAppContext <parameter>app_context</parameter></paramdef> 7189e7bcd65Smrg <paramdef>XtLanguageProc <parameter>proc</parameter></paramdef> 7199e7bcd65Smrg <paramdef>XtPointer <parameter>client_data</parameter></paramdef> 7209e7bcd65Smrg</funcprototype> 7219e7bcd65Smrg</funcsynopsis> 7229e7bcd65Smrg 7239e7bcd65Smrg<variablelist> 7249e7bcd65Smrg <varlistentry> 7259e7bcd65Smrg <term> 7269e7bcd65Smrg <emphasis remap='I'>app_context</emphasis> 7279e7bcd65Smrg </term> 7289e7bcd65Smrg <listitem> 7299e7bcd65Smrg <para> 7309e7bcd65SmrgSpecifies the application context in which the language procedure is 7319e7bcd65Smrgto be used, or NULL. 7329e7bcd65Smrg </para> 7339e7bcd65Smrg </listitem> 7349e7bcd65Smrg </varlistentry> 7359e7bcd65Smrg <varlistentry> 7369e7bcd65Smrg <term> 7379e7bcd65Smrg <emphasis remap='I'>proc</emphasis> 7389e7bcd65Smrg </term> 7399e7bcd65Smrg <listitem> 7409e7bcd65Smrg <para> 7419e7bcd65SmrgSpecifies the language procedure. 7429e7bcd65Smrg </para> 7439e7bcd65Smrg </listitem> 7449e7bcd65Smrg </varlistentry> 7459e7bcd65Smrg <varlistentry> 7469e7bcd65Smrg <term> 7479e7bcd65Smrg <emphasis remap='I'>client_data</emphasis> 7489e7bcd65Smrg </term> 7499e7bcd65Smrg <listitem> 7509e7bcd65Smrg <para> 7519e7bcd65SmrgSpecifies additional client data to be passed to the language 7529e7bcd65Smrgprocedure when it is called. 7539e7bcd65Smrg </para> 7549e7bcd65Smrg </listitem> 7559e7bcd65Smrg </varlistentry> 7569e7bcd65Smrg</variablelist> 7579e7bcd65Smrg 7589e7bcd65Smrg<para> 7599e7bcd65Smrg<function>XtSetLanguageProc</function> 7609e7bcd65Smrgsets the language procedure that will be called from 7619e7bcd65Smrg<xref linkend='XtDisplayInitialize' xrefstyle='select: title'/> 7629e7bcd65Smrgfor all subsequent Displays initialized in the specified application 7639e7bcd65Smrgcontext. If <emphasis remap='I'>app_context</emphasis> is NULL, the specified language 7649e7bcd65Smrgprocedure is registered in all application contexts created by the 7659e7bcd65Smrgcalling process, including any future application contexts that may 7669e7bcd65Smrgbe created. If <emphasis remap='I'>proc</emphasis> is NULL, a default language procedure is 7679e7bcd65Smrgregistered. 7689e7bcd65Smrg<function>XtSetLanguageProc</function> 7699e7bcd65Smrgreturns the previously registered language procedure. 7709e7bcd65SmrgIf a language procedure has not yet been registered, the return value 7719e7bcd65Smrgis unspecified, but if this return value is used in a subsequent call to 7729e7bcd65Smrg<function>XtSetLanguageProc</function>, 7739e7bcd65Smrgit will cause the default language procedure to be registered. 7749e7bcd65Smrg</para> 7759e7bcd65Smrg 7769e7bcd65Smrg<para> 7779e7bcd65SmrgThe default language procedure does the following: 7789e7bcd65Smrg</para> 7799e7bcd65Smrg<itemizedlist spacing='compact'> 7809e7bcd65Smrg <listitem> 7819e7bcd65Smrg <para> 7829e7bcd65SmrgSets the locale according to the environment. On ANSI C-based 7839e7bcd65Smrgsystems this is done by calling 7849e7bcd65Smrg<function>setlocale</function>( 7859e7bcd65Smrg<function>LC_ALL</function>, 7869e7bcd65Smrg<emphasis remap='I'>language</emphasis> ). 7879e7bcd65SmrgIf an error is encountered, a warning message is issued with 7889e7bcd65Smrg<xref linkend='XtWarning' xrefstyle='select: title'/>. 7899e7bcd65Smrg </para> 7909e7bcd65Smrg </listitem> 7919e7bcd65Smrg <listitem> 7929e7bcd65Smrg <para> 7939e7bcd65SmrgCalls 7949e7bcd65Smrg<function>XSupportsLocale</function> 7959e7bcd65Smrgto verify that the current locale is supported. 7969e7bcd65SmrgIf the locale is not supported, a warning message is issued with 7979e7bcd65Smrg<xref linkend='XtWarning' xrefstyle='select: title'/> 7980568f49bSmrgand the locale is set to “C”. 7999e7bcd65Smrg </para> 8009e7bcd65Smrg </listitem> 8019e7bcd65Smrg <listitem> 8029e7bcd65Smrg <para> 8039e7bcd65SmrgCalls 8049e7bcd65Smrg<function>XSetLocaleModifiers</function> 8059e7bcd65Smrgspecifying the empty string. 8069e7bcd65Smrg </para> 8079e7bcd65Smrg </listitem> 8089e7bcd65Smrg <listitem> 8099e7bcd65Smrg <para> 8109e7bcd65SmrgReturns the value of the current locale. On ANSI C-based systems this 8119e7bcd65Smrgis the return value from a final call to 8129e7bcd65Smrg<function>setlocale</function>( 8139e7bcd65Smrg<function>LC_ALL</function>, 8149e7bcd65SmrgNULL ). 8159e7bcd65Smrg </para> 8169e7bcd65Smrg </listitem> 8179e7bcd65Smrg</itemizedlist> 8189e7bcd65Smrg<para> 8199e7bcd65SmrgA client wishing to use this mechanism to establish locale can do so 8209e7bcd65Smrgby calling 8219e7bcd65Smrg<function>XtSetLanguageProc</function> 8229e7bcd65Smrgprior to 8239e7bcd65Smrg<xref linkend='XtDisplayInitialize' xrefstyle='select: title'/>, 8249e7bcd65Smrgas in the following example. 8259e7bcd65Smrg</para> 8260568f49bSmrg<programlisting> 8279e7bcd65Smrg Widget top; 8289e7bcd65Smrg XtSetLanguageProc(NULL, NULL, NULL); 8299e7bcd65Smrg top = XtOpenApplication(...); 8309e7bcd65Smrg ... 8310568f49bSmrg</programlisting> 8329e7bcd65Smrg</sect1> 8339e7bcd65Smrg 8349e7bcd65Smrg<sect1 id="Loading_the_Resource_Database"> 8359e7bcd65Smrg<title>Loading the Resource Database</title> 8369e7bcd65Smrg<para> 8379e7bcd65SmrgThe 8389e7bcd65Smrg<xref linkend='XtDisplayInitialize' xrefstyle='select: title'/> 8399e7bcd65Smrgfunction first determines the language 8409e7bcd65Smrgstring to be used for the specified display. It then 8419e7bcd65Smrgcreates a resource database for the default screen of the display by 8429e7bcd65Smrgcombining the following sources in order, with the entries in the 8439e7bcd65Smrgfirst named source having highest precedence: 8449e7bcd65Smrg</para> 8459e7bcd65Smrg<itemizedlist spacing='compact'> 8469e7bcd65Smrg <listitem> 8479e7bcd65Smrg <para> 8489e7bcd65SmrgApplication command line (<emphasis remap='I'>argc</emphasis>, <emphasis remap='I'>argv</emphasis>). 8499e7bcd65Smrg </para> 8509e7bcd65Smrg </listitem> 8519e7bcd65Smrg <listitem> 8529e7bcd65Smrg <para> 8539e7bcd65SmrgPer-host user environment resource file on the local host. 8549e7bcd65Smrg </para> 8559e7bcd65Smrg </listitem> 8569e7bcd65Smrg <listitem> 8579e7bcd65Smrg <para> 8589e7bcd65SmrgPer-screen resource specifications from the server. 8599e7bcd65Smrg </para> 8609e7bcd65Smrg </listitem> 8619e7bcd65Smrg <listitem> 8629e7bcd65Smrg <para> 8639e7bcd65SmrgPer-display resource specifications from the server or from 8649e7bcd65Smrgthe user preference file on the local host. 8659e7bcd65Smrg </para> 8669e7bcd65Smrg </listitem> 8679e7bcd65Smrg <listitem> 8689e7bcd65Smrg <para> 8699e7bcd65SmrgApplication-specific user resource file on the local host. 8709e7bcd65Smrg </para> 8719e7bcd65Smrg </listitem> 8729e7bcd65Smrg <listitem> 8739e7bcd65Smrg <para> 8749e7bcd65SmrgApplication-specific class resource file on the local host. 8759e7bcd65Smrg </para> 8769e7bcd65Smrg </listitem> 8779e7bcd65Smrg</itemizedlist> 8789e7bcd65Smrg<para> 8799e7bcd65SmrgWhen the resource database for a particular screen on the display 8809e7bcd65Smrgis needed (either internally, or when 8819e7bcd65Smrg<xref linkend='XtScreenDatabase' xrefstyle='select: title'/> 8829e7bcd65Smrgis called), 8839e7bcd65Smrgit is created in the following manner using the sources listed 8849e7bcd65Smrgabove in the same order: 8859e7bcd65Smrg</para> 8869e7bcd65Smrg<itemizedlist spacing='compact'> 8879e7bcd65Smrg <listitem> 8889e7bcd65Smrg <para> 8890568f49bSmrgA temporary database, the “server resource database”, is 8909e7bcd65Smrgcreated from the string returned by 8919e7bcd65Smrg<function>XResourceManagerString</function> 8929e7bcd65Smrgor, if 8939e7bcd65Smrg<function>XResourceManagerString</function> 8949e7bcd65Smrgreturns NULL, the contents of a resource file in the user's home 8959e7bcd65Smrgdirectory. On POSIX-based systems, the usual name for this user 8969e7bcd65Smrgpreference resource file is $HOME/<function>.Xdefaults</function>. 8979e7bcd65Smrg </para> 8989e7bcd65Smrg </listitem> 8999e7bcd65Smrg <listitem> 9009e7bcd65Smrg <para> 9019e7bcd65SmrgIf a language procedure has been set, 9029e7bcd65Smrg<xref linkend='XtDisplayInitialize' xrefstyle='select: title'/> 9030568f49bSmrgfirst searches the command line for the option “-xnlLanguage”, or 9049e7bcd65Smrgfor a -xrm option that specifies the xnlLanguage/XnlLanguage resource, 9059e7bcd65Smrgas specified by Section 2.4. 9069e7bcd65SmrgIf such a resource is found, the value is assumed to be 9079e7bcd65Smrgentirely in XPCS, the X Portable Character Set. If neither option is 9089e7bcd65Smrgspecified on the command line, 9099e7bcd65Smrg<xref linkend='XtDisplayInitialize' xrefstyle='select: title'/> 9109e7bcd65Smrgqueries the server resource database (which is assumed to be entirely 9119e7bcd65Smrgin XPCS) for the resource 9129e7bcd65Smrg<emphasis remap='I'>name</emphasis><function>.xnlLanguage</function>, class <emphasis remap='I'>Class</emphasis><function>.XnlLanguage</function> 9139e7bcd65Smrgwhere <emphasis remap='I'>name</emphasis> 9149e7bcd65Smrgand <emphasis remap='I'>Class</emphasis> are the <emphasis remap='I'>application_name</emphasis> and 9159e7bcd65Smrg<emphasis remap='I'>application_class</emphasis> specified to 9169e7bcd65Smrg<xref linkend='XtDisplayInitialize' xrefstyle='select: title'/>. 9179e7bcd65SmrgThe language procedure is then invoked with 9189e7bcd65Smrgthe resource value if found, else the empty string. The 9199e7bcd65Smrgstring returned from the language procedure is saved for all future 9209e7bcd65Smrgreferences in the Intrinsics that require the per-display language string. 9219e7bcd65Smrg </para> 9229e7bcd65Smrg </listitem> 9239e7bcd65Smrg <listitem> 9249e7bcd65Smrg <para> 9259e7bcd65SmrgThe screen resource database is initialized by parsing the command 9269e7bcd65Smrgline in the manner specified by Section 2.4. 9279e7bcd65Smrg </para> 9289e7bcd65Smrg </listitem> 9299e7bcd65Smrg <listitem> 9309e7bcd65Smrg <para> 9319e7bcd65SmrgIf a language procedure has not been set, 9329e7bcd65Smrgthe initial database is then queried for the resource 9339e7bcd65Smrg<emphasis remap='I'>name</emphasis><function>.xnlLanguage</function>, class <emphasis remap='I'>Class</emphasis><function>.XnlLanguage</function> 9349e7bcd65Smrgas specified above. 9359e7bcd65SmrgIf this database query fails, the server resource database is 9369e7bcd65Smrgqueried; if this query also fails, the language is determined from 9379e7bcd65Smrgthe environment; on POSIX-based systems, this is done by retrieving the 9389e7bcd65Smrgvalue of the 9399e7bcd65Smrg<emphasis role='strong'>LANG</emphasis> 9409e7bcd65Smrgenvironment variable. If no language string is 9419e7bcd65Smrgfound, the empty string is used. 9429e7bcd65SmrgThis language string is saved for all future references in the Intrinsics 9439e7bcd65Smrgthat require the per-display language string. 9449e7bcd65Smrg </para> 9459e7bcd65Smrg </listitem> 9469e7bcd65Smrg <listitem> 9479e7bcd65Smrg <para> 9489e7bcd65SmrgAfter determining the language string, the user's environment resource 9499e7bcd65Smrgfile is then merged into the initial resource database if the file exists. 9509e7bcd65SmrgThis file is user-, host-, and process-specific and is expected to 9519e7bcd65Smrgcontain user preferences that are to override those specifications in 9529e7bcd65Smrgthe per-display and per-screen resources. 9539e7bcd65SmrgOn POSIX-based systems, the user's environment resource file name is 9549e7bcd65Smrgspecified by the value of the 9559e7bcd65Smrg<emphasis role='strong'>XENVIRONMENT</emphasis> 9569e7bcd65Smrgenvironment variable. 9579e7bcd65SmrgIf this environment variable does not exist, the user's home directory 9589e7bcd65Smrgis searched for a file named 9599e7bcd65Smrg<function>.Xdefaults-</function><emphasis>host</emphasis>, 9609e7bcd65Smrgwhere <emphasis remap='I'>host</emphasis> is the host name of the machine on which the 9619e7bcd65Smrgapplication is running. 9629e7bcd65Smrg </para> 9639e7bcd65Smrg </listitem> 9649e7bcd65Smrg <listitem> 9659e7bcd65Smrg <para> 9669e7bcd65SmrgThe per-screen resource specifications are then merged into the screen 9679e7bcd65Smrgresource database, if they exist. These specifications are the string 9689e7bcd65Smrgreturned by 9699e7bcd65Smrg<function>XScreenResourceString</function> 9709e7bcd65Smrgfor the respective screen and are owned entirely by the user. 9719e7bcd65Smrg </para> 9729e7bcd65Smrg </listitem> 9739e7bcd65Smrg <listitem> 9749e7bcd65Smrg <para> 9759e7bcd65SmrgNext, the server resource database created earlier is merged into the 9769e7bcd65Smrgscreen resource database. The server property, and corresponding user 9779e7bcd65Smrgpreference file, are owned and constructed entirely by the user. 9789e7bcd65Smrg </para> 9799e7bcd65Smrg </listitem> 9809e7bcd65Smrg <listitem> 9819e7bcd65Smrg <para> 9829e7bcd65SmrgThe application-specific user resource file from the local host is 9839e7bcd65Smrgthen merged into the screen resource database. 9849e7bcd65SmrgThis file contains user customizations and is stored 9859e7bcd65Smrgin a directory owned by the user. 9869e7bcd65SmrgEither the user or the application or both can store resource specifications 9879e7bcd65Smrgin the file. Each should be prepared to find and respect entries made 9889e7bcd65Smrgby the other. 9899e7bcd65SmrgThe file name is found by calling 9909e7bcd65Smrg<function>XrmSetDatabase</function> 9919e7bcd65Smrgwith the current screen resource database, after preserving the 9929e7bcd65Smrgoriginal display-associated database, then calling 9939e7bcd65Smrg<xref linkend='XtResolvePathname' xrefstyle='select: title'/> 9949e7bcd65Smrgwith the parameters 9959e7bcd65Smrg(<emphasis remap='I'>display</emphasis>, NULL, NULL, NULL, <emphasis remap='I'>path</emphasis>, NULL, 0, NULL), 9969e7bcd65Smrgwhere <emphasis remap='I'>path</emphasis> is defined in an operating-system-specific way. 9979e7bcd65SmrgOn POSIX-based systems, <emphasis remap='I'>path</emphasis> is defined to be the value 9989e7bcd65Smrgof the environment variable 9999e7bcd65Smrg<emphasis role='strong'>XUSERFILESEARCHPATH</emphasis> 10009e7bcd65Smrgif this is defined. If 10019e7bcd65Smrg<emphasis role='strong'>XUSERFILESEARCHPATH</emphasis> 10029e7bcd65Smrgis not defined, an implementation-dependent default value is used. 10039e7bcd65SmrgThis default value is constrained in the following manner: 10049e7bcd65Smrg </para> 10059e7bcd65Smrg <itemizedlist spacing='compact'> 10069e7bcd65Smrg <listitem> 10079e7bcd65Smrg <para> 10089e7bcd65SmrgIf the environment variable 10099e7bcd65Smrg<emphasis role='strong'>XAPPLRESDIR</emphasis> 10109e7bcd65Smrgis not defined, the default 10119e7bcd65Smrg<emphasis role='strong'>XUSERFILESEARCHPATH</emphasis> 10129e7bcd65Smrgmust contain at least six entries. These entries must contain 10139e7bcd65Smrg$HOME as the directory prefix, plus the following substitutions: 10149e7bcd65Smrg </para> 10150568f49bSmrg<programlisting> 10160568f49bSmrg1. %C, %N, %L or %C, %N, %l, %t, %c 10170568f49bSmrg2. %C, %N, %l 10180568f49bSmrg3. %C, %N 10190568f49bSmrg4. %N, %L or %N, %l, %t, %c 10200568f49bSmrg5. %N, %l 10210568f49bSmrg6. %N 10220568f49bSmrg</programlisting> 10239e7bcd65Smrg <para> 10249e7bcd65SmrgThe order of these six entries within the path must be as given above. 10259e7bcd65SmrgThe order and use of substitutions within a given entry are 10269e7bcd65Smrgimplementation-dependent. 10279e7bcd65Smrg </para> 10289e7bcd65Smrg </listitem> 10299e7bcd65Smrg <listitem> 10309e7bcd65Smrg <para> If 10319e7bcd65Smrg<emphasis role='strong'>XAPPLRESDIR</emphasis> 10329e7bcd65Smrgis defined, the default 10339e7bcd65Smrg<emphasis role='strong'>XUSERFILESEARCHPATH</emphasis> 10349e7bcd65Smrgmust contain at least seven entries. These entries must contain the 10359e7bcd65Smrgfollowing directory prefixes and substitutions: 10369e7bcd65Smrg </para> 10370568f49bSmrg<programlisting> 10380568f49bSmrg1. $XAPPLRESDIR with %C, %N, %L or %C, %N, %l, %t, %c 10390568f49bSmrg2. $XAPPLRESDIR with %C, %N, %l 10400568f49bSmrg3. $XAPPLRESDIR with %C, %N 10410568f49bSmrg4. $XAPPLRESDIR with %N, %L or %N, %l, %t, %c 10420568f49bSmrg5. $XAPPLRESDIR with %N, %l 10430568f49bSmrg6. $XAPPLRESDIR with %N 10440568f49bSmrg7. $HOME with %N 10450568f49bSmrg</programlisting> 10469e7bcd65Smrg <para> 10479e7bcd65SmrgThe order of these seven entries within the path must be as given above. 10489e7bcd65SmrgThe order and use of substitutions within a given entry are 10499e7bcd65Smrgimplementation-dependent. 10509e7bcd65Smrg </para> 10519e7bcd65Smrg </listitem> 10529e7bcd65Smrg </itemizedlist> 10539e7bcd65Smrg </listitem> 10549e7bcd65Smrg <listitem> 10559e7bcd65Smrg <para> 10569e7bcd65SmrgLast, the application-specific class resource file from the local 10579e7bcd65Smrghost is merged into the screen resource database. 10589e7bcd65SmrgThis file is owned by the application and is usually installed in 10599e7bcd65Smrga system directory when the application is installed. 10609e7bcd65SmrgIt may contain sitewide customizations specified by the system manager. 10619e7bcd65SmrgThe name of the application class resource file is found by calling 10629e7bcd65Smrg<xref linkend='XtResolvePathname' xrefstyle='select: title'/> 10639e7bcd65Smrgwith the parameters 10640568f49bSmrg(<emphasis remap='I'>display</emphasis>, “app-defaults”, NULL, NULL, NULL, NULL, 0, NULL). 10659e7bcd65SmrgThis file is expected to be provided by the developer of the application 10669e7bcd65Smrgand may be required for the application to function properly. 10679e7bcd65SmrgA simple application that wants to be assured of having a minimal 10689e7bcd65Smrgset of resources in the absence of its class resource file can declare 10699e7bcd65Smrgfallback resource specifications with 10709e7bcd65Smrg<xref linkend='XtAppSetFallbackResources' xrefstyle='select: title'/>. 10719e7bcd65SmrgNote that the customization substitution string is retrieved 10729e7bcd65Smrgdynamically by 10739e7bcd65Smrg<xref linkend='XtResolvePathname' xrefstyle='select: title'/> 10749e7bcd65Smrgso that the resolved file name of the application class resource file 10759e7bcd65Smrgcan be affected by any of the earlier sources for the screen resource 10769e7bcd65Smrgdatabase, even though the contents of the class resource file have 10779e7bcd65Smrglowest precedence. After calling 10789e7bcd65Smrg<xref linkend='XtResolvePathname' xrefstyle='select: title'/>, 10799e7bcd65Smrgthe original display-associated database is restored. 10809e7bcd65Smrg </para> 10819e7bcd65Smrg </listitem> 10829e7bcd65Smrg</itemizedlist> 10839e7bcd65Smrg 10849e7bcd65Smrg<para> 10859e7bcd65SmrgTo obtain the resource database for a particular screen, use 10869e7bcd65Smrg<xref linkend='XtScreenDatabase' xrefstyle='select: title'/>. 10879e7bcd65Smrg</para> 10889e7bcd65Smrg 10899e7bcd65Smrg<funcsynopsis id='XtScreenDatabase'> 10909e7bcd65Smrg<funcprototype> 10919e7bcd65Smrg <funcdef>XrmDatabase <function>XtScreenDatabase</function></funcdef> 10929e7bcd65Smrg <paramdef>Screen * <parameter>screen</parameter></paramdef> 10939e7bcd65Smrg</funcprototype> 10949e7bcd65Smrg</funcsynopsis> 10959e7bcd65Smrg 10969e7bcd65Smrg 10979e7bcd65Smrg<variablelist> 10989e7bcd65Smrg <varlistentry> 10999e7bcd65Smrg <term> 11009e7bcd65Smrg <emphasis remap='I'>screen</emphasis> 11019e7bcd65Smrg </term> 11029e7bcd65Smrg <listitem> 11039e7bcd65Smrg <para> 11049e7bcd65SmrgSpecifies the screen whose resource database is to be returned. 11059e7bcd65Smrg </para> 11069e7bcd65Smrg </listitem> 11079e7bcd65Smrg </varlistentry> 11089e7bcd65Smrg</variablelist> 11099e7bcd65Smrg 11109e7bcd65Smrg<para> 11119e7bcd65SmrgThe 11129e7bcd65Smrg<xref linkend='XtScreenDatabase' xrefstyle='select: title'/> 11139e7bcd65Smrgfunction returns the fully merged resource database as specified above, 11149e7bcd65Smrgassociated with the specified screen. If the specified <emphasis remap='I'>screen</emphasis> 11159e7bcd65Smrgdoes not belong to a 11169e7bcd65Smrg<function>Display</function> 11179e7bcd65Smrginitialized by 11189e7bcd65Smrg<xref linkend='XtDisplayInitialize' xrefstyle='select: title'/>, 11199e7bcd65Smrgthe results are undefined. 11209e7bcd65Smrg</para> 11219e7bcd65Smrg 11229e7bcd65Smrg<para> 11239e7bcd65SmrgTo obtain the default resource database associated with a particular display, use 11249e7bcd65Smrg<xref linkend='XtDatabase' xrefstyle='select: title'/>. 11259e7bcd65Smrg</para> 11269e7bcd65Smrg 11279e7bcd65Smrg 11289e7bcd65Smrg<funcsynopsis id='XtDatabase'> 11299e7bcd65Smrg<funcprototype> 11309e7bcd65Smrg <funcdef>XrmDatabase <function>XtDatabase</function></funcdef> 11319e7bcd65Smrg <paramdef>Display * <parameter>display</parameter></paramdef> 11329e7bcd65Smrg</funcprototype> 11339e7bcd65Smrg</funcsynopsis> 11349e7bcd65Smrg 11359e7bcd65Smrg 11369e7bcd65Smrg<variablelist> 11379e7bcd65Smrg <varlistentry> 11389e7bcd65Smrg <term> 11399e7bcd65Smrg <emphasis remap='I'>display</emphasis> 11409e7bcd65Smrg </term> 11419e7bcd65Smrg <listitem> 11429e7bcd65Smrg <para> 11439e7bcd65SmrgSpecifies the display. 11449e7bcd65Smrg </para> 11459e7bcd65Smrg </listitem> 11469e7bcd65Smrg </varlistentry> 11479e7bcd65Smrg</variablelist> 11489e7bcd65Smrg 11499e7bcd65Smrg<para> 11509e7bcd65SmrgThe 11519e7bcd65Smrg<xref linkend='XtDatabase' xrefstyle='select: title'/> 11529e7bcd65Smrgfunction is equivalent to 11539e7bcd65Smrg<function>XrmGetDatabase</function>. 11549e7bcd65SmrgIt returns the database associated with the specified display, or 11559e7bcd65SmrgNULL if a database has not been set. 11569e7bcd65Smrg</para> 11579e7bcd65Smrg 11589e7bcd65Smrg<para> 11599e7bcd65SmrgTo specify a default set of resource values that will be used to 11609e7bcd65Smrginitialize the resource database if no application-specific class 11619e7bcd65Smrgresource file is found (the last of the six sources listed above), 11629e7bcd65Smrguse 11639e7bcd65Smrg<xref linkend='XtAppSetFallbackResources' xrefstyle='select: title'/>. 11649e7bcd65Smrg</para> 11659e7bcd65Smrg 11669e7bcd65Smrg<funcsynopsis id='XtAppSetFallbackResources'> 11679e7bcd65Smrg<funcprototype> 11689e7bcd65Smrg <funcdef>void <function>XtAppSetFallbackResources</function></funcdef> 11690568f49bSmrg <paramdef>XtAppContext <parameter>app_context</parameter></paramdef> 11709e7bcd65Smrg <paramdef>String * <parameter>specification_list</parameter></paramdef> 11719e7bcd65Smrg</funcprototype> 11729e7bcd65Smrg</funcsynopsis> 11739e7bcd65Smrg 11749e7bcd65Smrg<variablelist> 11759e7bcd65Smrg <varlistentry> 11769e7bcd65Smrg <term> 11779e7bcd65Smrg <emphasis remap='I'>app_context</emphasis> 11789e7bcd65Smrg </term> 11799e7bcd65Smrg <listitem> 11809e7bcd65Smrg <para> 11819e7bcd65SmrgSpecifies the application context in which 11829e7bcd65Smrgthe fallback specifications will be used. 11839e7bcd65Smrg </para> 11849e7bcd65Smrg </listitem> 11859e7bcd65Smrg </varlistentry> 11869e7bcd65Smrg <varlistentry> 11879e7bcd65Smrg <term> 11889e7bcd65Smrg <emphasis remap='I'>specification_list</emphasis> 11899e7bcd65Smrg </term> 11909e7bcd65Smrg <listitem> 11919e7bcd65Smrg <para> 11929e7bcd65SmrgSpecifies a NULL-terminated list of 11939e7bcd65Smrgresource specifications to preload 11949e7bcd65Smrgthe database, or NULL. 11959e7bcd65Smrg </para> 11969e7bcd65Smrg </listitem> 11979e7bcd65Smrg </varlistentry> 11989e7bcd65Smrg</variablelist> 11999e7bcd65Smrg 12009e7bcd65Smrg<para> 12019e7bcd65SmrgEach entry in <emphasis remap='I'>specification_list</emphasis> points to a string in the format of 12029e7bcd65Smrg<function>XrmPutLineResource</function>. 12039e7bcd65SmrgFollowing a call to 12049e7bcd65Smrg<xref linkend='XtAppSetFallbackResources' xrefstyle='select: title'/>, 12059e7bcd65Smrgwhen a resource database is being created for a particular screen and 12069e7bcd65Smrgthe Intrinsics are not able 12079e7bcd65Smrgto find or read an application-specific class resource file according to the 12089e7bcd65Smrgrules given above and if <emphasis remap='I'>specification_list</emphasis> is not NULL, the 12099e7bcd65Smrgresource specifications in <emphasis remap='I'>specification_list</emphasis> will be merged 12109e7bcd65Smrginto the screen resource database in place of the application-specific 12119e7bcd65Smrgclass resource file. 12129e7bcd65Smrg<xref linkend='XtAppSetFallbackResources' xrefstyle='select: title'/> 12139e7bcd65Smrgis not 12149e7bcd65Smrgrequired to copy <emphasis remap='I'>specification_list</emphasis>; the caller must ensure that the 12159e7bcd65Smrgcontents of the list and of the strings addressed by the list remain 12169e7bcd65Smrgvalid until all displays are initialized or until 12179e7bcd65Smrg<xref linkend='XtAppSetFallbackResources' xrefstyle='select: title'/> 12189e7bcd65Smrgis called again. The value NULL for 12199e7bcd65Smrg<emphasis remap='I'>specification_list</emphasis> removes any previous fallback resource specification 12209e7bcd65Smrgfor the application context. The intended use for fallback resources 12219e7bcd65Smrgis to provide a minimal 12229e7bcd65Smrgnumber of resources that will make the application usable (or at 12239e7bcd65Smrgleast terminate with helpful diagnostic messages) when some problem 12249e7bcd65Smrgexists in finding and loading the application defaults file. 12259e7bcd65Smrg</para> 12269e7bcd65Smrg</sect1> 12279e7bcd65Smrg 12289e7bcd65Smrg<sect1 id="Parsing_the_Command_Line"> 12299e7bcd65Smrg<title>Parsing the Command Line</title> 12309e7bcd65Smrg<para> 12319e7bcd65SmrgThe 12329e7bcd65Smrg<xref linkend='XtOpenDisplay' xrefstyle='select: title'/> 12339e7bcd65Smrgfunction first parses the command line for the following options: 12349e7bcd65Smrg<variablelist> 12359e7bcd65Smrg <varlistentry> 12369e7bcd65Smrg <term>-display</term> 12379e7bcd65Smrg <listitem> 12389e7bcd65Smrg <para> 12399e7bcd65SmrgSpecifies the display name for 12409e7bcd65Smrg<function>XOpenDisplay</function>. 12419e7bcd65Smrg </para> 12429e7bcd65Smrg </listitem> 12439e7bcd65Smrg </varlistentry> 12449e7bcd65Smrg <varlistentry> 12459e7bcd65Smrg <term>-name</term> 12469e7bcd65Smrg <listitem> 12479e7bcd65Smrg <para> 12489e7bcd65SmrgSets the resource name prefix, 12499e7bcd65Smrgwhich overrides the application name passed to 12509e7bcd65Smrg<xref linkend='XtOpenDisplay' xrefstyle='select: title'/>. 12519e7bcd65Smrg </para> 12529e7bcd65Smrg </listitem> 12539e7bcd65Smrg </varlistentry> 12549e7bcd65Smrg <varlistentry> 12559e7bcd65Smrg <term>-xnllanguage</term> 12569e7bcd65Smrg <listitem> 12579e7bcd65Smrg <para> 12589e7bcd65SmrgSpecifies the initial language string for establishing locale 12599e7bcd65Smrgand for finding application class resource files. 12609e7bcd65Smrg </para> 12619e7bcd65Smrg </listitem> 12629e7bcd65Smrg </varlistentry> 12639e7bcd65Smrg</variablelist> 12649e7bcd65Smrg</para> 12659e7bcd65Smrg 12669e7bcd65Smrg<para> 12679e7bcd65Smrg<xref linkend='XtDisplayInitialize' xrefstyle='select: title'/> 12689e7bcd65Smrghas a table of standard command line options that are passed to 12699e7bcd65Smrg<function>XrmParseCommand</function> 12709e7bcd65Smrgfor adding resources to the resource database, 12719e7bcd65Smrgand it takes as a parameter additional 12729e7bcd65Smrgapplication-specific resource abbreviations. 12730568f49bSmrgThe format of this table is described in Section 15.9 in <emphasis remap='I'>Xlib — C Language X Interface</emphasis>. 12749e7bcd65Smrg</para> 12750568f49bSmrg<programlisting> 12769e7bcd65Smrgtypedef enum { 12770568f49bSmrg XrmoptionNoArg, /* Value is specified in OptionDescRec.value */ 12780568f49bSmrg XrmoptionIsArg, /* Value is the option string itself */ 12790568f49bSmrg XrmoptionStickyArg, /* Value is characters immediately following option */ 12800568f49bSmrg XrmoptionSepArg, /* Value is next argument in argv */ 12810568f49bSmrg XrmoptionResArg, /* Use the next argument as input to XrmPutLineResource*/ 12820568f49bSmrg XrmoptionSkipArg, /* Ignore this option and the next argument in argv */ 12830568f49bSmrg XrmoptionSkipNArgs, /* Ignore this option and the next */ 12840568f49bSmrg /* OptionDescRec.value arguments in argv */ 12850568f49bSmrg XrmoptionSkipLine /* Ignore this option and the rest of argv */ 12869e7bcd65Smrg} XrmOptionKind; 12870568f49bSmrg 12889e7bcd65Smrgtypedef struct { 12890568f49bSmrg char *option; /* Option name in argv */ 12900568f49bSmrg char *specifier; /* Resource name (without application name) */ 12910568f49bSmrg XrmOptionKind argKind; /* Location of the resource value */ 12920568f49bSmrg XPointer value; /* Value to provide if XrmoptionNoArg */ 12939e7bcd65Smrg} XrmOptionDescRec, *XrmOptionDescList; 12940568f49bSmrg</programlisting> 12959e7bcd65Smrg<para>The standard table contains the following entries:</para> 12969e7bcd65Smrg 12979e7bcd65Smrg<informaltable frame='topbot'> 12989e7bcd65Smrg <?dbfo keep-together="always" ?> 12999e7bcd65Smrg <tgroup cols='4' align='left' colsep='0' rowsep='0'> 13009e7bcd65Smrg <colspec colwidth='1.0*' colname='c1'/> 13019e7bcd65Smrg <colspec colwidth='1.0*' colname='c2'/> 13029e7bcd65Smrg <colspec colwidth='1.0*' colname='c3'/> 13039e7bcd65Smrg <colspec colwidth='1.0*' colname='c4'/> 13049e7bcd65Smrg <thead> 13059e7bcd65Smrg <row rowsep='1'> 13069e7bcd65Smrg <entry>Option String</entry> 13079e7bcd65Smrg <entry>Resource Name</entry> 13089e7bcd65Smrg <entry>Argument Kind</entry> 13099e7bcd65Smrg <entry>Resource Value</entry> 13109e7bcd65Smrg </row> 13119e7bcd65Smrg </thead> 13129e7bcd65Smrg <tbody> 13139e7bcd65Smrg <row> 13140568f49bSmrg <entry>-background</entry> 13159e7bcd65Smrg <entry>*background</entry> 13169e7bcd65Smrg <entry>SepArg</entry> 13179e7bcd65Smrg <entry>next argument</entry> 13189e7bcd65Smrg </row> 13199e7bcd65Smrg <row> 13200568f49bSmrg <entry>-bd</entry> 13219e7bcd65Smrg <entry>*borderColor</entry> 13229e7bcd65Smrg <entry>SepArg</entry> 13239e7bcd65Smrg <entry>next argument</entry> 13249e7bcd65Smrg </row> 13259e7bcd65Smrg <row> 13260568f49bSmrg <entry>-bg</entry> 13279e7bcd65Smrg <entry>*background</entry> 13289e7bcd65Smrg <entry>SepArg</entry> 13299e7bcd65Smrg <entry>next argument</entry> 13309e7bcd65Smrg </row> 13319e7bcd65Smrg <row> 13320568f49bSmrg <entry>-borderwidth</entry> 13339e7bcd65Smrg <entry>.borderWidth</entry> 13349e7bcd65Smrg <entry>SepArg</entry> 13359e7bcd65Smrg <entry>next argument</entry> 13369e7bcd65Smrg </row> 13379e7bcd65Smrg <row> 13380568f49bSmrg <entry>-bordercolor</entry> 13399e7bcd65Smrg <entry>*borderColor</entry> 13409e7bcd65Smrg <entry>SepArg</entry> 13419e7bcd65Smrg <entry>next argument</entry> 13429e7bcd65Smrg </row> 13439e7bcd65Smrg <row> 13440568f49bSmrg <entry>-bw</entry> 13459e7bcd65Smrg <entry>.borderWidth</entry> 13469e7bcd65Smrg <entry>SepArg</entry> 13479e7bcd65Smrg <entry>next argument</entry> 13489e7bcd65Smrg </row> 13499e7bcd65Smrg <row> 13500568f49bSmrg <entry>-display</entry> 13519e7bcd65Smrg <entry>.display</entry> 13529e7bcd65Smrg <entry>SepArg</entry> 13539e7bcd65Smrg <entry>next argument</entry> 13549e7bcd65Smrg </row> 13559e7bcd65Smrg <row> 13560568f49bSmrg <entry>-fg</entry> 13579e7bcd65Smrg <entry>*foreground</entry> 13589e7bcd65Smrg <entry>SepArg</entry> 13599e7bcd65Smrg <entry>next argument</entry> 13609e7bcd65Smrg </row> 13619e7bcd65Smrg <row> 13620568f49bSmrg <entry>-fn</entry> 13639e7bcd65Smrg <entry>*font</entry> 13649e7bcd65Smrg <entry>SepArg</entry> 13659e7bcd65Smrg <entry>next argument</entry> 13669e7bcd65Smrg </row> 13679e7bcd65Smrg <row> 13680568f49bSmrg <entry>-font</entry> 13699e7bcd65Smrg <entry>*font</entry> 13709e7bcd65Smrg <entry>SepArg</entry> 13719e7bcd65Smrg <entry>next argument</entry> 13729e7bcd65Smrg </row> 13739e7bcd65Smrg <row> 13740568f49bSmrg <entry>-foreground</entry> 13759e7bcd65Smrg <entry>*foreground</entry> 13769e7bcd65Smrg <entry>SepArg</entry> 13779e7bcd65Smrg <entry>next argument</entry> 13789e7bcd65Smrg </row> 13799e7bcd65Smrg <row> 13800568f49bSmrg <entry>-geometry</entry> 13819e7bcd65Smrg <entry>.geometry</entry> 13829e7bcd65Smrg <entry>SepArg</entry> 13839e7bcd65Smrg <entry>next argument</entry> 13849e7bcd65Smrg </row> 13859e7bcd65Smrg <row> 13860568f49bSmrg <entry>-iconic</entry> 13879e7bcd65Smrg <entry>.iconic</entry> 13889e7bcd65Smrg <entry>NoArg</entry> 13899e7bcd65Smrg <entry>"true"</entry> 13909e7bcd65Smrg </row> 13919e7bcd65Smrg <row> 13920568f49bSmrg <entry>-name</entry> 13939e7bcd65Smrg <entry>.name</entry> 13949e7bcd65Smrg <entry>SepArg</entry> 13959e7bcd65Smrg <entry>next argument</entry> 13969e7bcd65Smrg </row> 13979e7bcd65Smrg <row> 13980568f49bSmrg <entry>-reverse</entry> 13999e7bcd65Smrg <entry>.reverseVideo</entry> 14009e7bcd65Smrg <entry>NoArg</entry> 14019e7bcd65Smrg <entry>"on"</entry> 14029e7bcd65Smrg </row> 14039e7bcd65Smrg <row> 14040568f49bSmrg <entry>-rv</entry> 14059e7bcd65Smrg <entry>.reverseVideo</entry> 14069e7bcd65Smrg <entry>NoArg</entry> 14079e7bcd65Smrg <entry>"on"</entry> 14089e7bcd65Smrg </row> 14099e7bcd65Smrg <row> 14109e7bcd65Smrg <entry>+rv</entry> 14119e7bcd65Smrg <entry>.reverseVideo</entry> 14129e7bcd65Smrg <entry>NoArg</entry> 14139e7bcd65Smrg <entry>"off"</entry> 14149e7bcd65Smrg </row> 14159e7bcd65Smrg <row> 14160568f49bSmrg <entry>-selectionTimeout</entry> 14179e7bcd65Smrg <entry>.selectionTimeout</entry> 14189e7bcd65Smrg <entry>SepArg</entry> 14199e7bcd65Smrg <entry>next argument</entry> 14209e7bcd65Smrg </row> 14219e7bcd65Smrg <row> 14220568f49bSmrg <entry>-synchronous</entry> 14239e7bcd65Smrg <entry>.synchronous</entry> 14249e7bcd65Smrg <entry>NoArg</entry> 14259e7bcd65Smrg <entry>"on"</entry> 14269e7bcd65Smrg </row> 14279e7bcd65Smrg <row> 14289e7bcd65Smrg <entry>+synchronous</entry> 14299e7bcd65Smrg <entry>.synchronous</entry> 14309e7bcd65Smrg <entry>NoArg</entry> 14319e7bcd65Smrg <entry>"off"</entry> 14329e7bcd65Smrg </row> 14339e7bcd65Smrg <row> 14340568f49bSmrg <entry>-title</entry> 14359e7bcd65Smrg <entry>.title</entry> 14369e7bcd65Smrg <entry>SepArg</entry> 14379e7bcd65Smrg <entry>next argument</entry> 14389e7bcd65Smrg </row> 14399e7bcd65Smrg <row> 14400568f49bSmrg <entry>-xnllanguage</entry> 14419e7bcd65Smrg <entry>.xnlLanguage</entry> 14429e7bcd65Smrg <entry>SepArg</entry> 14439e7bcd65Smrg <entry>next argument</entry> 14449e7bcd65Smrg </row> 14459e7bcd65Smrg <row> 14460568f49bSmrg <entry>-xrm</entry> 14479e7bcd65Smrg <entry>next argument</entry> 14489e7bcd65Smrg <entry>ResArg</entry> 14499e7bcd65Smrg <entry>next argument</entry> 14509e7bcd65Smrg </row> 14519e7bcd65Smrg <row> 14520568f49bSmrg <entry>-xtsessionID</entry> 14539e7bcd65Smrg <entry>.sessionID</entry> 14549e7bcd65Smrg <entry>SepArg</entry> 14559e7bcd65Smrg <entry>next argument</entry> 14569e7bcd65Smrg </row> 14579e7bcd65Smrg </tbody> 14589e7bcd65Smrg </tgroup> 14599e7bcd65Smrg</informaltable> 14609e7bcd65Smrg 14619e7bcd65Smrg<para> 14629e7bcd65SmrgNote that any unique abbreviation for an option name in the standard table 14639e7bcd65Smrgor in the application table is accepted. 14649e7bcd65Smrg</para> 14659e7bcd65Smrg 14669e7bcd65Smrg<para> 14679e7bcd65SmrgIf reverseVideo is 14689e7bcd65Smrg<function>True</function>, 14699e7bcd65Smrgthe values of 14709e7bcd65Smrg<function>XtDefaultForeground</function> 14719e7bcd65Smrgand 14729e7bcd65Smrg<function>XtDefaultBackground</function> 14739e7bcd65Smrgare exchanged for all screens on the Display. 14749e7bcd65Smrg</para> 14759e7bcd65Smrg 14769e7bcd65Smrg<para> 14779e7bcd65SmrgThe value of the synchronous resource specifies whether or not 14789e7bcd65SmrgXlib is put into synchronous mode. If a value is found in the resource 14799e7bcd65Smrgdatabase during display initialization, 14809e7bcd65Smrg<xref linkend='XtDisplayInitialize' xrefstyle='select: title'/> 14819e7bcd65Smrgmakes a call to 14829e7bcd65Smrg<function>XSynchronize</function> 14839e7bcd65Smrgfor all display 14849e7bcd65Smrgconnections currently open in the application context. Therefore, 14859e7bcd65Smrgwhen multiple displays are initialized in the same application 14869e7bcd65Smrgcontext, the most recent value specified for the synchronous resource 14879e7bcd65Smrgis used for all displays in the application context. 14889e7bcd65Smrg</para> 14899e7bcd65Smrg 14909e7bcd65Smrg<para> 14919e7bcd65SmrgThe value of the selectionTimeout resource applies to all displays 14929e7bcd65Smrgopened in the same application context. When multiple displays are 14939e7bcd65Smrginitialized in the same application context, the most recent value 14949e7bcd65Smrgspecified is used for all displays in the application context. 14959e7bcd65Smrg</para> 14969e7bcd65Smrg 14979e7bcd65Smrg<para> 14989e7bcd65SmrgThe -xrm option provides a method of setting any resource in an application. 14999e7bcd65SmrgThe next argument should be a quoted string identical in format to a line in 15009e7bcd65Smrgthe user resource file. 15019e7bcd65SmrgFor example, 15029e7bcd65Smrgto give a red background to all command buttons in an application named 15039e7bcd65Smrg<function>xmh</function>, 15049e7bcd65Smrgyou can start it up as 15059e7bcd65Smrg</para> 15060568f49bSmrg<programlisting> 15079e7bcd65Smrgxmh -xrm 'xmh*Command.background: red' 15080568f49bSmrg</programlisting> 15099e7bcd65Smrg<para> 15109e7bcd65SmrgWhen it parses the command line, 15119e7bcd65Smrg<xref linkend='XtDisplayInitialize' xrefstyle='select: title'/> 15129e7bcd65Smrgmerges the application option table with the standard option table 15139e7bcd65Smrgbefore calling the Xlib 15149e7bcd65Smrg<function>XrmParseCommand</function> 15159e7bcd65Smrgfunction. 15169e7bcd65SmrgAn entry in the application table with the same name as an entry 15179e7bcd65Smrgin the standard table overrides the standard table entry. 15189e7bcd65SmrgIf an option name is a prefix of another option name, 15199e7bcd65Smrgboth names are kept in the merged table. 15209e7bcd65SmrgThe Intrinsics reserve all option names 15210568f49bSmrgbeginning with the characters “-xt” for future standard uses. 15229e7bcd65Smrg</para> 15239e7bcd65Smrg</sect1> 15249e7bcd65Smrg 15259e7bcd65Smrg<sect1 id="Creating_Widgets"> 15269e7bcd65Smrg<title>Creating Widgets</title> 15279e7bcd65Smrg<para> 15289e7bcd65SmrgThe creation of widget instances is a three-phase process: 15299e7bcd65Smrg</para> 15309e7bcd65Smrg 15319e7bcd65Smrg<orderedlist> 15329e7bcd65Smrg <listitem> 15339e7bcd65Smrg <para> 15349e7bcd65SmrgThe widgets are allocated and initialized with resources 15359e7bcd65Smrgand are optionally added to the managed subset of their parent. 15369e7bcd65Smrg </para> 15379e7bcd65Smrg </listitem> 15389e7bcd65Smrg <listitem> 15399e7bcd65Smrg <para> 15409e7bcd65SmrgAll composite widgets are notified of their managed children 15419e7bcd65Smrgin a bottom-up traversal of the widget tree. 15429e7bcd65Smrg </para> 15439e7bcd65Smrg </listitem> 15449e7bcd65Smrg <listitem> 15459e7bcd65Smrg <para> 15469e7bcd65SmrgThe widgets create X windows, which then are mapped. 15479e7bcd65Smrg </para> 15489e7bcd65Smrg </listitem> 15499e7bcd65Smrg</orderedlist> 15509e7bcd65Smrg<para> 15519e7bcd65SmrgTo start the first phase, 15529e7bcd65Smrgthe application calls 15539e7bcd65Smrg<xref linkend='XtCreateWidget' xrefstyle='select: title'/> 15549e7bcd65Smrgfor all its widgets and adds some (usually, most or all) of its widgets 15559e7bcd65Smrgto their respective parents' managed set by calling 15569e7bcd65Smrg<xref linkend='XtManageChild' xrefstyle='select: title'/>. 15579e7bcd65SmrgTo avoid an O(n<superscript>2</superscript>) creation process where each composite widget 15589e7bcd65Smrglays itself out each time a widget is created and managed, 15599e7bcd65Smrgparent widgets are not notified of changes in their managed set 15609e7bcd65Smrgduring this phase. 15619e7bcd65Smrg</para> 15629e7bcd65Smrg 15639e7bcd65Smrg<para> 15649e7bcd65SmrgAfter all widgets have been created, 15659e7bcd65Smrgthe application calls 15669e7bcd65Smrg<xref linkend='XtRealizeWidget' xrefstyle='select: title'/> 15679e7bcd65Smrgwith the top-level widget to execute the second and third phases. 15689e7bcd65Smrg<xref linkend='XtRealizeWidget' xrefstyle='select: title'/> 15699e7bcd65Smrgfirst recursively traverses the widget tree in a postorder (bottom-up) 15709e7bcd65Smrgtraversal and then notifies each composite widget with one 15719e7bcd65Smrgor more managed children by means of its change_managed procedure. 15729e7bcd65Smrg</para> 15739e7bcd65Smrg 15749e7bcd65Smrg<para> 15759e7bcd65SmrgNotifying a parent about its managed set involves geometry layout and 15769e7bcd65Smrgpossibly geometry negotiation. 15779e7bcd65SmrgA parent deals with constraints on its size imposed from above 15789e7bcd65Smrg(for example, when a user specifies the application window size) 15799e7bcd65Smrgand suggestions made from below (for example, 15809e7bcd65Smrgwhen a primitive child computes its preferred size). 15819e7bcd65SmrgOne difference between the two can cause geometry changes to ripple 15829e7bcd65Smrgin both directions through the widget tree. 15839e7bcd65SmrgThe parent may force some of its children to change size and position 15849e7bcd65Smrgand may issue geometry requests to its own parent in order to better 15859e7bcd65Smrgaccommodate all its children. 15869e7bcd65SmrgYou cannot predict where anything will go on the screen 15879e7bcd65Smrguntil this process finishes. 15889e7bcd65Smrg</para> 15899e7bcd65Smrg 15909e7bcd65Smrg<para> 15919e7bcd65SmrgConsequently, in the first and second phases, 15929e7bcd65Smrgno X windows are actually created, because it is likely 15939e7bcd65Smrgthat they will get moved around after creation. 15949e7bcd65SmrgThis avoids unnecessary requests to the X server. 15959e7bcd65Smrg</para> 15969e7bcd65Smrg 15979e7bcd65Smrg<para> 15989e7bcd65SmrgFinally, 15999e7bcd65Smrg<xref linkend='XtRealizeWidget' xrefstyle='select: title'/> 16009e7bcd65Smrgstarts the third phase by making a preorder (top-down) traversal 16019e7bcd65Smrgof the widget tree, allocates an X window to each widget by means of 16029e7bcd65Smrgits realize procedure, and finally maps the widgets that are managed. 16039e7bcd65Smrg</para> 16049e7bcd65Smrg 16059e7bcd65Smrg<sect2 id="Creating_and_Merging_Argument_Lists"> 16069e7bcd65Smrg<title>Creating and Merging Argument Lists</title> 16079e7bcd65Smrg<para> 16089e7bcd65SmrgMany Intrinsics functions may be passed pairs of resource names and 16099e7bcd65Smrgvalues. 16109e7bcd65SmrgThese are passed as an arglist, a pointer to an array of 16119e7bcd65Smrg<function>Arg</function> 16129e7bcd65Smrgstructures, which contains 16139e7bcd65Smrg</para> 16140568f49bSmrg<programlisting> 16159e7bcd65Smrgtypedef struct { 16169e7bcd65Smrg String name; 16179e7bcd65Smrg XtArgVal value; 16189e7bcd65Smrg} Arg, *ArgList; 16190568f49bSmrg</programlisting> 16209e7bcd65Smrg<para> 16219e7bcd65Smrgwhere 16229e7bcd65Smrg<function>XtArgVal</function> 16239e7bcd65Smrgis as defined in Section 1.5. 16249e7bcd65Smrg</para> 16259e7bcd65Smrg 16269e7bcd65Smrg<para> 16279e7bcd65SmrgIf the size of the resource is less than or equal to the size of an 16289e7bcd65Smrg<function>XtArgVal</function>, 16299e7bcd65Smrgthe resource value is stored directly in <emphasis remap='I'>value</emphasis>; 16309e7bcd65Smrgotherwise, a pointer to it is stored in <emphasis remap='I'>value</emphasis>. 16319e7bcd65Smrg</para> 16329e7bcd65Smrg 16339e7bcd65Smrg<para> 16349e7bcd65SmrgTo set values in an 16359e7bcd65Smrg<function>ArgList</function>, 16369e7bcd65Smrguse 16379e7bcd65Smrg<xref linkend='XtSetArg' xrefstyle='select: title'/>. 16389e7bcd65Smrg</para> 16399e7bcd65Smrg 16409e7bcd65Smrg<funcsynopsis id='XtSetArg'> 16419e7bcd65Smrg<funcprototype> 16429e7bcd65Smrg <funcdef>void <function>XtSetArg</function></funcdef> 16439e7bcd65Smrg <paramdef>Arg <parameter>arg</parameter></paramdef> 16449e7bcd65Smrg <paramdef>String <parameter>name</parameter></paramdef> 16459e7bcd65Smrg <paramdef>XtArgVal <parameter>value</parameter></paramdef> 16469e7bcd65Smrg</funcprototype> 16479e7bcd65Smrg</funcsynopsis> 16489e7bcd65Smrg 16499e7bcd65Smrg 16509e7bcd65Smrg<variablelist> 16519e7bcd65Smrg <varlistentry> 16529e7bcd65Smrg <term> 16539e7bcd65Smrg <emphasis remap='I'>arg</emphasis> 16549e7bcd65Smrg </term> 16559e7bcd65Smrg <listitem> 16569e7bcd65Smrg <para> 16579e7bcd65SmrgSpecifies the <emphasis remap='I'>name/value</emphasis> pair to set. 16589e7bcd65Smrg </para> 16599e7bcd65Smrg </listitem> 16609e7bcd65Smrg </varlistentry> 16619e7bcd65Smrg <varlistentry> 16629e7bcd65Smrg <term> 16639e7bcd65Smrg <emphasis remap='I'>name</emphasis> 16649e7bcd65Smrg </term> 16659e7bcd65Smrg <listitem> 16669e7bcd65Smrg <para> 16679e7bcd65SmrgSpecifies the name of the resource. 16689e7bcd65Smrg </para> 16699e7bcd65Smrg </listitem> 16709e7bcd65Smrg </varlistentry> 16719e7bcd65Smrg <varlistentry> 16729e7bcd65Smrg <term> 16739e7bcd65Smrg <emphasis remap='I'>value</emphasis> 16749e7bcd65Smrg </term> 16759e7bcd65Smrg <listitem> 16769e7bcd65Smrg <para> 16779e7bcd65SmrgSpecifies the value of the resource if it will fit in an 16789e7bcd65Smrg<function>XtArgVal</function>, 16799e7bcd65Smrgelse the address. 16809e7bcd65Smrg </para> 16819e7bcd65Smrg </listitem> 16829e7bcd65Smrg </varlistentry> 16839e7bcd65Smrg</variablelist> 16849e7bcd65Smrg 16859e7bcd65Smrg<para> 16869e7bcd65SmrgThe 16879e7bcd65Smrg<xref linkend='XtSetArg' xrefstyle='select: title'/> 16889e7bcd65Smrgfunction is usually used in a highly stylized manner to 16899e7bcd65Smrgminimize the probability of making a mistake; for example: 16909e7bcd65Smrg</para> 16910568f49bSmrg<programlisting> 16929e7bcd65SmrgArg args[20]; 16939e7bcd65Smrgint n; 16949e7bcd65Smrgn = 0; 16950568f49bSmrgXtSetArg(args[n], XtNheight, 100); n++; 16960568f49bSmrgXtSetArg(args[n], XtNwidth, 200); n++; 16979e7bcd65SmrgXtSetValues(widget, args, n); 16980568f49bSmrg</programlisting> 16999e7bcd65Smrg<para> 17009e7bcd65SmrgAlternatively, an application can statically declare the argument list 17019e7bcd65Smrgand use 17029e7bcd65Smrg<xref linkend='XtNumber' xrefstyle='select: title'/>: 17039e7bcd65Smrg</para> 17040568f49bSmrg<programlisting> 17059e7bcd65Smrgstatic Args args[] = { 17069e7bcd65Smrg {XtNheight, (XtArgVal) 100}, 17079e7bcd65Smrg {XtNwidth, (XtArgVal) 200}, 17089e7bcd65Smrg}; 17099e7bcd65SmrgXtSetValues(Widget, args, XtNumber(args)); 17100568f49bSmrg</programlisting> 17119e7bcd65Smrg<para> 17129e7bcd65SmrgNote that you should not use expressions with side effects such as 17139e7bcd65Smrgauto-increment or auto-decrement 17149e7bcd65Smrgwithin the first argument to 17159e7bcd65Smrg<xref linkend='XtSetArg' xrefstyle='select: title'/>. 17169e7bcd65Smrg<xref linkend='XtSetArg' xrefstyle='select: title'/> 17179e7bcd65Smrgcan be implemented as a macro that evaluates the first argument twice. 17189e7bcd65Smrg</para> 17199e7bcd65Smrg 17209e7bcd65Smrg<para> 17219e7bcd65SmrgTo merge two 17229e7bcd65Smrgarglist arrays, use 17239e7bcd65Smrg<xref linkend='XtMergeArgLists' xrefstyle='select: title'/>. 17249e7bcd65Smrg</para> 17259e7bcd65Smrg 17269e7bcd65Smrg<funcsynopsis id='XtMergeArgLists'> 17279e7bcd65Smrg<funcprototype> 17289e7bcd65Smrg <funcdef>ArgList <function>XtMergeArgLists</function></funcdef> 17299e7bcd65Smrg <paramdef>ArgList <parameter>args1</parameter></paramdef> 17309e7bcd65Smrg <paramdef>Cardinal <parameter>num_args1</parameter></paramdef> 17319e7bcd65Smrg <paramdef>ArgList <parameter>args2</parameter></paramdef> 17329e7bcd65Smrg <paramdef>Cardinal <parameter>num_args2</parameter></paramdef> 17339e7bcd65Smrg</funcprototype> 17349e7bcd65Smrg</funcsynopsis> 17359e7bcd65Smrg 17369e7bcd65Smrg 17379e7bcd65Smrg<variablelist> 17389e7bcd65Smrg <varlistentry> 17399e7bcd65Smrg <term> 17409e7bcd65Smrg <emphasis remap='I'>args1</emphasis> 17419e7bcd65Smrg </term> 17429e7bcd65Smrg <listitem> 17439e7bcd65Smrg <para> 17449e7bcd65SmrgSpecifies the first argument list. 17459e7bcd65Smrg </para> 17469e7bcd65Smrg </listitem> 17479e7bcd65Smrg </varlistentry> 17489e7bcd65Smrg <varlistentry> 17499e7bcd65Smrg <term> 17509e7bcd65Smrg <emphasis remap='I'>num_args1</emphasis> 17519e7bcd65Smrg </term> 17529e7bcd65Smrg <listitem> 17539e7bcd65Smrg <para> 17549e7bcd65SmrgSpecifies the number of entries in the first argument list. 17559e7bcd65Smrg </para> 17569e7bcd65Smrg </listitem> 17579e7bcd65Smrg </varlistentry> 17589e7bcd65Smrg <varlistentry> 17599e7bcd65Smrg <term> 17609e7bcd65Smrg <emphasis remap='I'>args2</emphasis> 17619e7bcd65Smrg </term> 17629e7bcd65Smrg <listitem> 17639e7bcd65Smrg <para> 17649e7bcd65SmrgSpecifies the second argument list. 17659e7bcd65Smrg </para> 17669e7bcd65Smrg </listitem> 17679e7bcd65Smrg </varlistentry> 17689e7bcd65Smrg <varlistentry> 17699e7bcd65Smrg <term> 17709e7bcd65Smrg <emphasis remap='I'>num_args2</emphasis> 17719e7bcd65Smrg </term> 17729e7bcd65Smrg <listitem> 17739e7bcd65Smrg <para> 17749e7bcd65SmrgSpecifies the number of entries in the second argument list. 17759e7bcd65Smrg </para> 17769e7bcd65Smrg </listitem> 17779e7bcd65Smrg </varlistentry> 17789e7bcd65Smrg</variablelist> 17799e7bcd65Smrg 17809e7bcd65Smrg<para> 17819e7bcd65SmrgThe 17829e7bcd65Smrg<xref linkend='XtMergeArgLists' xrefstyle='select: title'/> 17839e7bcd65Smrgfunction allocates enough storage to hold the combined 17849e7bcd65Smrgarglist arrays and copies them into it. 17859e7bcd65SmrgNote that it does not check for duplicate entries. 17869e7bcd65SmrgThe length of the returned list is the sum of the lengths of the 17879e7bcd65Smrgspecified lists. 17889e7bcd65SmrgWhen it is no longer needed, 17899e7bcd65Smrgfree the returned storage by using 17909e7bcd65Smrg<xref linkend='XtFree' xrefstyle='select: title'/>. 17919e7bcd65Smrg</para> 17929e7bcd65Smrg 17939e7bcd65Smrg<para> 17949e7bcd65SmrgAll Intrinsics interfaces that require 17959e7bcd65Smrg<function>ArgList</function> 17969e7bcd65Smrgarguments have analogs 17979e7bcd65Smrgconforming to the ANSI C variable argument list 17980568f49bSmrg(traditionally called “varargs”) 17999e7bcd65Smrgcalling convention. The name of the analog is formed by prefixing 18000568f49bSmrg“Va” to the name of the corresponding 18019e7bcd65Smrg<function>ArgList</function> 18029e7bcd65Smrgprocedure; e.g., 18039e7bcd65Smrg<xref linkend='XtVaCreateWidget' xrefstyle='select: title'/>. 18049e7bcd65SmrgEach procedure named <function>XtVa</function><emphasis remap='I'>something</emphasis> takes as its 18059e7bcd65Smrglast arguments, in place of the corresponding 18069e7bcd65Smrg<function>ArgList</function>/ 18079e7bcd65Smrg<function>Cardinal</function> 18089e7bcd65Smrgparameters, a variable parameter list of resource name and 18099e7bcd65Smrgvalue pairs where each name is of type 18109e7bcd65Smrg<function>String</function> 18119e7bcd65Smrgand each value is of type 18129e7bcd65Smrg<function>XtArgVal</function>. 18139e7bcd65SmrgThe end of the list is identified by a <emphasis remap='I'>name</emphasis> entry 18149e7bcd65Smrgcontaining NULL. Developers writing in the C language wishing to pass 18159e7bcd65Smrgresource name and value pairs to any of these interfaces may use the 18169e7bcd65Smrg<function>ArgList</function> 18179e7bcd65Smrgand varargs forms interchangeably. 18189e7bcd65Smrg</para> 18199e7bcd65Smrg 18209e7bcd65Smrg<para> 18219e7bcd65SmrgTwo special names are defined for use only in varargs lists: 18229e7bcd65Smrg<function>XtVaTypedArg</function> 18239e7bcd65Smrgand 18249e7bcd65Smrg<function>XtVaNestedList</function>. 18259e7bcd65Smrg</para> 18260568f49bSmrg<programlisting> 18279e7bcd65Smrg#define XtVaTypedArg "XtVaTypedArg" 18280568f49bSmrg</programlisting> 18299e7bcd65Smrg<para> 18309e7bcd65SmrgIf the name 18319e7bcd65Smrg<function>XtVaTypedArg</function> 18329e7bcd65Smrgis specified in place of a resource 18339e7bcd65Smrgname, then the following four arguments are interpreted as a 18349e7bcd65Smrg<emphasis remap='I'>name/type/value/size</emphasis> tuple <emphasis remap='I'>where</emphasis> name is of type 18359e7bcd65Smrg<function>String</function>, 18369e7bcd65Smrg<emphasis remap='I'>type</emphasis> is of type 18379e7bcd65Smrg<function>String</function>, 18389e7bcd65Smrg<emphasis remap='I'>value</emphasis> is of type 18399e7bcd65Smrg<function>XtArgVal</function>, 18409e7bcd65Smrgand <emphasis remap='I'>size</emphasis> is of type int. When a varargs list containing 18419e7bcd65Smrg<function>XtVaTypedArg</function> 18429e7bcd65Smrgis processed, a resource type 18439e7bcd65Smrgconversion (see <xref linkend='Resource_Conversions' />) is performed if necessary to convert the 18449e7bcd65Smrgvalue into the format required by the associated resource. If <emphasis remap='I'>type</emphasis> is 18459e7bcd65SmrgXtRString, then <emphasis remap='I'>value</emphasis> contains a pointer to the string and <emphasis remap='I'>size</emphasis> 18469e7bcd65Smrgcontains the number of bytes allocated, including the trailing null 18479e7bcd65Smrgbyte. If <emphasis remap='I'>type</emphasis> is not XtRString, then <emphasis remap='I'>if</emphasis> size is 18489e7bcd65Smrgless than or equal to 18499e7bcd65Smrg<function>sizeof</function>(<function>XtArgVal</function>), the value should be the data cast to the type 18509e7bcd65Smrg<function>XtArgVal</function>, 18519e7bcd65Smrgotherwise <emphasis remap='I'>value</emphasis> is a pointer to the data. If the type 18529e7bcd65Smrgconversion fails for any reason, a warning message is issued and the 18539e7bcd65Smrglist entry is skipped. 18549e7bcd65Smrg</para> 18550568f49bSmrg<programlisting> 18569e7bcd65Smrg#define XtVaNestedList "XtVaNestedList" 18570568f49bSmrg</programlisting> 18589e7bcd65Smrg<para> 18599e7bcd65SmrgIf the name 18609e7bcd65Smrg<function>XtVaNestedList</function> 18619e7bcd65Smrgis specified in place of a resource name, 18629e7bcd65Smrgthen the following argument is interpreted as an 18639e7bcd65Smrg<function>XtVarArgsList</function> 18649e7bcd65Smrgvalue, which specifies another 18659e7bcd65Smrgvarargs list that is logically inserted into the original list at the 18669e7bcd65Smrgpoint of declaration. The end of the nested list is identified with a 18679e7bcd65Smrgname entry containing NULL. Varargs lists may nest to any depth. 18689e7bcd65Smrg</para> 18699e7bcd65Smrg 18709e7bcd65Smrg<para> 18719e7bcd65SmrgTo dynamically allocate a varargs list for use with 18729e7bcd65Smrg<function>XtVaNestedList</function> 18739e7bcd65Smrgin multiple calls, use 18749e7bcd65Smrg<xref linkend='XtVaCreateArgsList' xrefstyle='select: title'/>. 18759e7bcd65Smrg</para> 18760568f49bSmrg<programlisting> 18779e7bcd65Smrgtypedef XtPointer XtVarArgsList; 18780568f49bSmrg</programlisting> 18799e7bcd65Smrg 18809e7bcd65Smrg<funcsynopsis id='XtVaCreateArgsList'> 18819e7bcd65Smrg<funcprototype> 18829e7bcd65Smrg <funcdef>XtVarArgsList <function>XtVaCreateArgsList</function></funcdef> 18839e7bcd65Smrg <paramdef>XtPointer <parameter>unused</parameter></paramdef> 18849e7bcd65Smrg <paramdef> <parameter>...</parameter></paramdef> 18859e7bcd65Smrg</funcprototype> 18869e7bcd65Smrg</funcsynopsis> 18879e7bcd65Smrg 18889e7bcd65Smrg<variablelist> 18899e7bcd65Smrg <varlistentry> 18909e7bcd65Smrg <term> 18919e7bcd65Smrg <emphasis remap='I'>unused</emphasis> 18929e7bcd65Smrg </term> 18939e7bcd65Smrg <listitem> 18949e7bcd65Smrg <para> 18959e7bcd65SmrgThis argument is not currently used and must be specified as NULL. 18969e7bcd65Smrg </para> 18979e7bcd65Smrg </listitem> 18989e7bcd65Smrg </varlistentry> 18999e7bcd65Smrg <varlistentry> 19009e7bcd65Smrg <term> 19019e7bcd65Smrg ... 19029e7bcd65Smrg </term> 19039e7bcd65Smrg <listitem> 19049e7bcd65Smrg <para> 19059e7bcd65SmrgSpecifies a variable parameter list of resource 19069e7bcd65Smrgname and value pairs. 19079e7bcd65Smrg </para> 19089e7bcd65Smrg </listitem> 19099e7bcd65Smrg </varlistentry> 19109e7bcd65Smrg</variablelist> 19119e7bcd65Smrg 19129e7bcd65Smrg<para> 19139e7bcd65SmrgThe 19149e7bcd65Smrg<xref linkend='XtVaCreateArgsList' xrefstyle='select: title'/> 19159e7bcd65Smrgfunction allocates memory and copies its arguments into a 19169e7bcd65Smrgsingle list pointer, which may be used with 19179e7bcd65Smrg<function>XtVaNestedList</function>. 19189e7bcd65SmrgThe end of 19199e7bcd65Smrgboth lists is identified by a <emphasis remap='I'>name</emphasis> entry containing NULL. Any entries 19209e7bcd65Smrgof type 19219e7bcd65Smrg<function>XtVaTypedArg</function> 19229e7bcd65Smrgare copied as specified without applying 19239e7bcd65Smrgconversions. Data passed by reference (including Strings) are not 19249e7bcd65Smrgcopied, only the pointers themselves; the caller must ensure that the 19259e7bcd65Smrgdata remain valid for the lifetime of the created varargs list. The 19269e7bcd65Smrglist should be freed using 19279e7bcd65Smrg<xref linkend='XtFree' xrefstyle='select: title'/> 19289e7bcd65Smrgwhen no longer needed. 19299e7bcd65Smrg</para> 19309e7bcd65Smrg 19319e7bcd65Smrg<para> 19329e7bcd65SmrgUse of resource files and of the resource database is generally 19339e7bcd65Smrgencouraged over lengthy arglist or varargs lists whenever possible in 19349e7bcd65Smrgorder to permit modification without recompilation. 19359e7bcd65Smrg</para> 19369e7bcd65Smrg</sect2> 19379e7bcd65Smrg 19389e7bcd65Smrg<sect2 id="Creating_a_Widget_Instance"> 19399e7bcd65Smrg<title>Creating a Widget Instance</title> 19409e7bcd65Smrg<para> 19419e7bcd65SmrgTo create an instance of a widget, use 19429e7bcd65Smrg<xref linkend='XtCreateWidget' xrefstyle='select: title'/>. 19439e7bcd65Smrg</para> 19449e7bcd65Smrg 19459e7bcd65Smrg<funcsynopsis id='XtCreateWidget'> 19469e7bcd65Smrg<funcprototype> 19479e7bcd65Smrg <funcdef>Widget <function>XtCreateWidget</function></funcdef> 19480568f49bSmrg <paramdef>const char * <parameter>name</parameter></paramdef> 19499e7bcd65Smrg <paramdef>WidgetClass <parameter>object_class</parameter></paramdef> 19509e7bcd65Smrg <paramdef>Widget <parameter>parent</parameter></paramdef> 19519e7bcd65Smrg <paramdef>ArgList <parameter>args</parameter></paramdef> 19529e7bcd65Smrg <paramdef>Cardinal <parameter>num_args</parameter></paramdef> 19539e7bcd65Smrg</funcprototype> 19549e7bcd65Smrg</funcsynopsis> 19559e7bcd65Smrg 19569e7bcd65Smrg 19579e7bcd65Smrg<variablelist> 19589e7bcd65Smrg <varlistentry> 19599e7bcd65Smrg <term> 19609e7bcd65Smrg <emphasis remap='I'>name</emphasis> 19619e7bcd65Smrg </term> 19629e7bcd65Smrg <listitem> 19639e7bcd65Smrg <para> 19649e7bcd65SmrgSpecifies the resource instance name for the created widget, 19659e7bcd65Smrgwhich is used for retrieving resources 19669e7bcd65Smrgand, for that reason, should not be the same as any other widget 19679e7bcd65Smrgthat is a child of the same parent. 19689e7bcd65Smrg </para> 19699e7bcd65Smrg </listitem> 19709e7bcd65Smrg </varlistentry> 19719e7bcd65Smrg <varlistentry> 19729e7bcd65Smrg <term> 19739e7bcd65Smrg <emphasis remap='I'>object_class</emphasis> 19749e7bcd65Smrg </term> 19759e7bcd65Smrg <listitem> 19769e7bcd65Smrg <para> 19779e7bcd65SmrgSpecifies the widget class pointer for the created object. Must be <emphasis role='strong'>objectClass</emphasis> or any subclass thereof. 19789e7bcd65Smrg </para> 19799e7bcd65Smrg </listitem> 19809e7bcd65Smrg </varlistentry> 19819e7bcd65Smrg <varlistentry> 19829e7bcd65Smrg <term> 19839e7bcd65Smrg <emphasis remap='I'>parent</emphasis> 19849e7bcd65Smrg </term> 19859e7bcd65Smrg <listitem> 19869e7bcd65Smrg <para> 19879e7bcd65SmrgSpecifies the parent widget. Must be of class Object or any subclass thereof. 19889e7bcd65Smrg </para> 19899e7bcd65Smrg </listitem> 19909e7bcd65Smrg </varlistentry> 19919e7bcd65Smrg <varlistentry> 19929e7bcd65Smrg <term> 19939e7bcd65Smrg <emphasis remap='I'>args</emphasis> 19949e7bcd65Smrg </term> 19959e7bcd65Smrg <listitem> 19969e7bcd65Smrg <para> 19979e7bcd65SmrgSpecifies the argument list to override any other resource specifications. 19989e7bcd65Smrg </para> 19999e7bcd65Smrg </listitem> 20009e7bcd65Smrg </varlistentry> 20019e7bcd65Smrg <varlistentry> 20029e7bcd65Smrg <term> 20039e7bcd65Smrg <emphasis remap='I'>num_args</emphasis> 20049e7bcd65Smrg </term> 20059e7bcd65Smrg <listitem> 20069e7bcd65Smrg <para> 20079e7bcd65SmrgSpecifies the number of entries in the argument list. 20089e7bcd65Smrg </para> 20099e7bcd65Smrg </listitem> 20109e7bcd65Smrg </varlistentry> 20119e7bcd65Smrg</variablelist> 20129e7bcd65Smrg 20139e7bcd65Smrg<para> 20149e7bcd65SmrgThe 20159e7bcd65Smrg<xref linkend='XtCreateWidget' xrefstyle='select: title'/> 20169e7bcd65Smrgfunction performs all the boilerplate operations of widget 20179e7bcd65Smrgcreation, doing the following in order: 20189e7bcd65Smrg</para> 20199e7bcd65Smrg<itemizedlist spacing='compact'> 20209e7bcd65Smrg <listitem> 20219e7bcd65Smrg <para> 20229e7bcd65SmrgChecks to see if the class_initialize procedure has been called for this class 20239e7bcd65Smrgand for all superclasses and, if not, calls those necessary in a 20249e7bcd65Smrgsuperclass-to-subclass order. 20259e7bcd65Smrg </para> 20269e7bcd65Smrg </listitem> 20279e7bcd65Smrg <listitem> 20289e7bcd65Smrg <para> 20299e7bcd65SmrgIf the specified class is not 20309e7bcd65Smrg<function>coreWidgetClass</function> 20319e7bcd65Smrgor a subclass thereof, 20329e7bcd65Smrgand the parent's class is a subclass of 20339e7bcd65Smrg<function>compositeWidgetClass</function> 20349e7bcd65Smrgand either no extension record in 20359e7bcd65Smrgthe parent's composite class part extension field exists with the 20369e7bcd65Smrg<emphasis remap='I'>record_type</emphasis> 20379e7bcd65Smrg<emphasis role='strong'>NULLQUARK</emphasis> 20389e7bcd65Smrgor the <emphasis remap='I'>accepts_objects</emphasis> field in the extension 20399e7bcd65Smrgrecord is 20409e7bcd65Smrg<function>False</function>, 20419e7bcd65Smrg<xref linkend='XtCreateWidget' xrefstyle='select: title'/> 20429e7bcd65Smrgissues a fatal error; see <xref linkend='Addition_of_Children_to_a_Composite_Widget_The_insert_child_Procedure' /> and <xref linkend='Nonwidget_Objects' />. 20439e7bcd65Smrg </para> 20449e7bcd65Smrg </listitem> 20459e7bcd65Smrg <listitem> 20469e7bcd65Smrg <para> 20479e7bcd65SmrgIf the specified class contains an extension record in the object class 20489e7bcd65Smrgpart <emphasis remap='I'>extension</emphasis> field with <emphasis remap='I'>record_type</emphasis> 20499e7bcd65Smrg<emphasis role='strong'>NULLQUARK</emphasis> 20509e7bcd65Smrgand the <emphasis remap='I'>allocate</emphasis> field is not NULL, 20519e7bcd65Smrgthe procedure is invoked to allocate memory 20529e7bcd65Smrgfor the widget instance. If the parent is a member of the class 20539e7bcd65Smrg<function>constraintWidgetClass</function>, 20549e7bcd65Smrgthe procedure also allocates memory for the 20559e7bcd65Smrgparent's constraints and stores the address of this memory into the 20569e7bcd65Smrg<emphasis remap='I'>constraints</emphasis> field. If no allocate procedure is found, the Intrinsics 20579e7bcd65Smrgallocate memory for the widget and, when applicable, the constraints, 20589e7bcd65Smrgand initializes the <emphasis remap='I'>constraints</emphasis> field. 20599e7bcd65Smrg </para> 20609e7bcd65Smrg </listitem> 20619e7bcd65Smrg <listitem> 20629e7bcd65Smrg <para> 20639e7bcd65SmrgInitializes the Core nonresource data fields 20649e7bcd65Smrg<emphasis remap='I'>self</emphasis>, <emphasis remap='I'>parent</emphasis>, <emphasis remap='I'>widget_class</emphasis>, <emphasis remap='I'>being_destroyed</emphasis>, 20659e7bcd65Smrg<emphasis remap='I'>name</emphasis>, <emphasis remap='I'>managed</emphasis>, <emphasis remap='I'>window</emphasis>, <emphasis remap='I'>visible</emphasis>, 20669e7bcd65Smrg<emphasis remap='I'>popup_list</emphasis>, and <emphasis remap='I'>num_popups</emphasis>. 20679e7bcd65Smrg </para> 20689e7bcd65Smrg </listitem> 20699e7bcd65Smrg <listitem> 20709e7bcd65Smrg <para> 20719e7bcd65SmrgInitializes the resource fields (for example, <emphasis remap='I'>background_pixel</emphasis>) 20729e7bcd65Smrgby using the 20739e7bcd65Smrg<function>CoreClassPart</function> 20749e7bcd65Smrgresource lists specified for this class and all superclasses. 20759e7bcd65Smrg </para> 20769e7bcd65Smrg </listitem> 20779e7bcd65Smrg <listitem> 20789e7bcd65Smrg <para> 20799e7bcd65SmrgIf the parent is a member of the class 20809e7bcd65Smrg<function>constraintWidgetClass</function>, 20819e7bcd65Smrginitializes the resource fields of the constraints record 20829e7bcd65Smrgby using the 20839e7bcd65Smrg<function>ConstraintClassPart</function> 20849e7bcd65Smrgresource lists specified for the parent's class 20859e7bcd65Smrgand all superclasses up to 20869e7bcd65Smrg<function>constraintWidgetClass</function>. 20879e7bcd65Smrg </para> 20889e7bcd65Smrg </listitem> 20899e7bcd65Smrg <listitem> 20909e7bcd65Smrg <para> 20919e7bcd65SmrgCalls the initialize procedures for the widget starting at the 20929e7bcd65SmrgObject 20939e7bcd65Smrginitialize procedure on down to the widget's initialize procedure. 20949e7bcd65Smrg </para> 20959e7bcd65Smrg </listitem> 20969e7bcd65Smrg <listitem> 20979e7bcd65Smrg <para> 20989e7bcd65SmrgIf the parent is a member of the class 20999e7bcd65Smrg<function>constraintWidgetClass</function>, 21009e7bcd65Smrgcalls the 21019e7bcd65Smrg<function>ConstraintClassPart</function> 21029e7bcd65Smrginitialize procedures, 21039e7bcd65Smrgstarting at 21049e7bcd65Smrg<function>constraintWidgetClass</function> 21059e7bcd65Smrgon down to the parent's 21069e7bcd65Smrg<function>ConstraintClassPart</function> 21079e7bcd65Smrginitialize procedure. 21089e7bcd65Smrg </para> 21099e7bcd65Smrg </listitem> 21109e7bcd65Smrg <listitem> 21119e7bcd65Smrg <para> 21129e7bcd65SmrgIf the parent is a member of the class 21139e7bcd65Smrg<function>compositeWidgetClass</function>, 21149e7bcd65Smrgputs the widget into its parent's children list by calling its parent's 21159e7bcd65Smrginsert_child procedure. 21169e7bcd65SmrgFor further information, 21179e7bcd65Smrgsee <xref linkend='Addition_of_Children_to_a_Composite_Widget_The_insert_child_Procedure' />. 21189e7bcd65Smrg </para> 21199e7bcd65Smrg </listitem> 21209e7bcd65Smrg</itemizedlist> 21219e7bcd65Smrg<para> 21229e7bcd65SmrgTo create an instance of a widget using varargs lists, use 21239e7bcd65Smrg<xref linkend='XtVaCreateWidget' xrefstyle='select: title'/>. 21249e7bcd65Smrg</para> 21259e7bcd65Smrg 21269e7bcd65Smrg<funcsynopsis id='XtVaCreateWidget'> 21279e7bcd65Smrg<funcprototype> 21289e7bcd65Smrg <funcdef>Widget <function>XtVaCreateWidget</function></funcdef> 21290568f49bSmrg <paramdef>const char * <parameter>name</parameter></paramdef> 21309e7bcd65Smrg <paramdef>WidgetClass <parameter>object_class</parameter></paramdef> 21319e7bcd65Smrg <paramdef>Widget <parameter>parent</parameter></paramdef> 21329e7bcd65Smrg <paramdef> <parameter>...</parameter></paramdef> 21339e7bcd65Smrg</funcprototype> 21349e7bcd65Smrg</funcsynopsis> 21359e7bcd65Smrg 21369e7bcd65Smrg 21379e7bcd65Smrg<variablelist> 21389e7bcd65Smrg <varlistentry> 21399e7bcd65Smrg <term> 21409e7bcd65Smrg <emphasis remap='I'>name</emphasis> 21419e7bcd65Smrg </term> 21429e7bcd65Smrg <listitem> 21439e7bcd65Smrg <para> 21449e7bcd65SmrgSpecifies the resource name for the created widget. 21459e7bcd65Smrg </para> 21469e7bcd65Smrg </listitem> 21479e7bcd65Smrg </varlistentry> 21489e7bcd65Smrg <varlistentry> 21499e7bcd65Smrg <term> 21509e7bcd65Smrg <emphasis remap='I'>object_class</emphasis> 21519e7bcd65Smrg </term> 21529e7bcd65Smrg <listitem> 21539e7bcd65Smrg <para> 21549e7bcd65SmrgSpecifies the widget class pointer for the created object. Must be <emphasis role='strong'>objectClass</emphasis> or any subclass thereof. 21559e7bcd65Smrg </para> 21569e7bcd65Smrg </listitem> 21579e7bcd65Smrg </varlistentry> 21589e7bcd65Smrg <varlistentry> 21599e7bcd65Smrg <term> 21609e7bcd65Smrg <emphasis remap='I'>parent</emphasis> 21619e7bcd65Smrg </term> 21629e7bcd65Smrg <listitem> 21639e7bcd65Smrg <para> 21649e7bcd65SmrgSpecifies the parent widget. Must be of class Object or any subclass thereof. 21659e7bcd65Smrg </para> 21669e7bcd65Smrg </listitem> 21679e7bcd65Smrg </varlistentry> 21689e7bcd65Smrg <varlistentry> 21699e7bcd65Smrg <term> 21709e7bcd65Smrg ... 21719e7bcd65Smrg </term> 21729e7bcd65Smrg <listitem> 21739e7bcd65Smrg <para> 21749e7bcd65SmrgSpecifies the variable argument list to override any other 21759e7bcd65Smrgresource specifications. 21769e7bcd65Smrg </para> 21779e7bcd65Smrg </listitem> 21789e7bcd65Smrg </varlistentry> 21799e7bcd65Smrg</variablelist> 21809e7bcd65Smrg 21819e7bcd65Smrg<para> 21829e7bcd65SmrgThe 21839e7bcd65Smrg<xref linkend='XtVaCreateWidget' xrefstyle='select: title'/> 21849e7bcd65Smrgprocedure is identical in function to 21859e7bcd65Smrg<xref linkend='XtCreateWidget' xrefstyle='select: title'/> 21869e7bcd65Smrgwith the <emphasis remap='I'>args</emphasis> and <emphasis remap='I'>num_args</emphasis> parameters replaced by a varargs list, 21879e7bcd65Smrgas described 21889e7bcd65Smrgin Section 2.5.1. 21899e7bcd65Smrg</para> 21909e7bcd65Smrg</sect2> 21919e7bcd65Smrg 21929e7bcd65Smrg<sect2 id="Creating_an_Application_Shell_Instance"> 21939e7bcd65Smrg<title>Creating an Application Shell Instance</title> 21949e7bcd65Smrg<para> 21959e7bcd65SmrgAn application can have multiple top-level widgets, each of which 21969e7bcd65Smrgspecifies a unique widget tree 21979e7bcd65Smrgthat can potentially be on different screens or displays. 21989e7bcd65SmrgAn application uses 21999e7bcd65Smrg<xref linkend='XtAppCreateShell' xrefstyle='select: title'/> 22009e7bcd65Smrgto create independent widget trees. 22019e7bcd65Smrg</para> 22029e7bcd65Smrg 22039e7bcd65Smrg<funcsynopsis id='XtAppCreateShell'> 22049e7bcd65Smrg<funcprototype> 22059e7bcd65Smrg <funcdef>Widget <function>XtAppCreateShell</function></funcdef> 22060568f49bSmrg <paramdef>const char * <parameter>name</parameter></paramdef> 22070568f49bSmrg <paramdef>const char * <parameter>application_class</parameter></paramdef> 22089e7bcd65Smrg <paramdef>WidgetClass <parameter>widget_class</parameter></paramdef> 22099e7bcd65Smrg <paramdef>Display * <parameter>display</parameter></paramdef> 22109e7bcd65Smrg <paramdef>ArgList <parameter>args</parameter></paramdef> 22119e7bcd65Smrg <paramdef>Cardinal <parameter>num_args</parameter></paramdef> 22129e7bcd65Smrg</funcprototype> 22139e7bcd65Smrg</funcsynopsis> 22149e7bcd65Smrg 22159e7bcd65Smrg 22169e7bcd65Smrg<variablelist> 22179e7bcd65Smrg <varlistentry> 22189e7bcd65Smrg <term> 22199e7bcd65Smrg <emphasis remap='I'>name</emphasis> 22209e7bcd65Smrg </term> 22219e7bcd65Smrg <listitem> 22229e7bcd65Smrg <para> 22239e7bcd65SmrgSpecifies the instance name of the shell widget. 22249e7bcd65SmrgIf <emphasis remap='I'>name</emphasis> is NULL, 22259e7bcd65Smrgthe application name passed to 22269e7bcd65Smrg<xref linkend='XtDisplayInitialize' xrefstyle='select: title'/> 22279e7bcd65Smrgis used. 22289e7bcd65Smrg </para> 22299e7bcd65Smrg </listitem> 22309e7bcd65Smrg </varlistentry> 22319e7bcd65Smrg <varlistentry> 22329e7bcd65Smrg <term> 22339e7bcd65Smrg <emphasis remap='I'>application_class</emphasis> 22349e7bcd65Smrg </term> 22359e7bcd65Smrg <listitem> 22369e7bcd65Smrg <para> 22379e7bcd65SmrgSpecifies the resource class string to be used in 22389e7bcd65Smrgplace of the widget <emphasis remap='I'>class_name</emphasis> string when 22399e7bcd65Smrg<emphasis remap='I'>widget_class</emphasis> is 22409e7bcd65Smrg<function>applicationShellWidgetClass</function> 22419e7bcd65Smrgor a subclass thereof. 22429e7bcd65Smrg </para> 22439e7bcd65Smrg </listitem> 22449e7bcd65Smrg </varlistentry> 22459e7bcd65Smrg <varlistentry> 22469e7bcd65Smrg <term> 22479e7bcd65Smrg <emphasis remap='I'>widget_class</emphasis> 22489e7bcd65Smrg </term> 22499e7bcd65Smrg <listitem> 22509e7bcd65Smrg <para> 22519e7bcd65SmrgSpecifies the widget class for the top-level widget (e.g., 22529e7bcd65Smrg<function>applicationShellWidgetClass ).</function> 22539e7bcd65Smrg </para> 22549e7bcd65Smrg </listitem> 22559e7bcd65Smrg </varlistentry> 22569e7bcd65Smrg <varlistentry> 22579e7bcd65Smrg <term> 22589e7bcd65Smrg <emphasis remap='I'>display</emphasis> 22599e7bcd65Smrg </term> 22609e7bcd65Smrg <listitem> 22619e7bcd65Smrg <para> 22629e7bcd65SmrgSpecifies the display for the default screen 22639e7bcd65Smrgand for the resource database used to retrieve 22649e7bcd65Smrgthe shell widget resources. 22659e7bcd65Smrg </para> 22669e7bcd65Smrg </listitem> 22679e7bcd65Smrg </varlistentry> 22689e7bcd65Smrg <varlistentry> 22699e7bcd65Smrg <term> 22709e7bcd65Smrg <emphasis remap='I'>args</emphasis> 22719e7bcd65Smrg </term> 22729e7bcd65Smrg <listitem> 22739e7bcd65Smrg <para> 22749e7bcd65SmrgSpecifies the argument list to override any other resource specifications. 22759e7bcd65Smrg </para> 22769e7bcd65Smrg </listitem> 22779e7bcd65Smrg </varlistentry> 22789e7bcd65Smrg <varlistentry> 22799e7bcd65Smrg <term> 22809e7bcd65Smrg <emphasis remap='I'>num_args</emphasis> 22819e7bcd65Smrg </term> 22829e7bcd65Smrg <listitem> 22839e7bcd65Smrg <para> 22849e7bcd65SmrgSpecifies the number of entries in the argument list. 22859e7bcd65Smrg </para> 22869e7bcd65Smrg </listitem> 22879e7bcd65Smrg </varlistentry> 22889e7bcd65Smrg</variablelist> 22899e7bcd65Smrg 22909e7bcd65Smrg<para> 22919e7bcd65SmrgThe 22929e7bcd65Smrg<xref linkend='XtAppCreateShell' xrefstyle='select: title'/> 22939e7bcd65Smrgfunction 22949e7bcd65Smrgcreates a new shell widget instance as the root of a widget tree. 22959e7bcd65SmrgThe screen resource for this widget is determined by first scanning 22969e7bcd65Smrg<emphasis remap='I'>args</emphasis> for the XtNscreen argument. If no XtNscreen argument is 22979e7bcd65Smrgfound, the resource database associated with the default screen of 22989e7bcd65Smrgthe specified display is queried for the resource <emphasis remap='I'>name</emphasis>.screen, 22999e7bcd65Smrgclass <emphasis remap='I'>Class</emphasis>.Screen where <emphasis remap='I'>Class</emphasis> is the specified 23009e7bcd65Smrg<emphasis remap='I'>application_class</emphasis> if <emphasis remap='I'>widget_class</emphasis> is 23019e7bcd65Smrg<function>applicationShellWidgetClass</function> 23029e7bcd65Smrgor a subclass thereof. If <emphasis remap='I'>widget_class</emphasis> is not 23030568f49bSmrg<function>applicationShellWidgetClass</function> 23049e7bcd65Smrgor a subclass, <emphasis remap='I'>Class</emphasis> is the <emphasis remap='I'>class_name</emphasis> 23059e7bcd65Smrgfield from the 23069e7bcd65Smrg<function>CoreClassPart</function> 23079e7bcd65Smrgof the specified <emphasis remap='I'>widget_class</emphasis>. 23089e7bcd65SmrgIf this query fails, the default 23099e7bcd65Smrgscreen of the specified display is used. Once the screen is determined, 23109e7bcd65Smrgthe resource database associated with that screen is used to retrieve 23119e7bcd65Smrgall remaining resources for the shell widget not specified in 23129e7bcd65Smrg<emphasis remap='I'>args</emphasis>. The widget name and <emphasis remap='I'>Class</emphasis> as determined above are 23139e7bcd65Smrgused as the leftmost (i.e., root) components in all fully qualified 23149e7bcd65Smrgresource names for objects within this widget tree. 23159e7bcd65Smrg</para> 23169e7bcd65Smrg 23179e7bcd65Smrg<para> 23189e7bcd65SmrgIf the specified widget class is a subclass of WMShell, the name and 23199e7bcd65Smrg<emphasis remap='I'>Class</emphasis> as determined above will be stored into the 23209e7bcd65Smrg<emphasis role='strong'>WM_CLASS</emphasis> 23219e7bcd65Smrgproperty on the widget's window when it becomes realized. 23229e7bcd65SmrgIf the specified <emphasis remap='I'>widget_class</emphasis> is 23239e7bcd65Smrg<function>applicationShellWidgetClass</function> 23249e7bcd65Smrgor a subclass thereof, the 23259e7bcd65Smrg<emphasis role='strong'>WM_COMMAND</emphasis> 23269e7bcd65Smrgproperty will also be set from the values of the XtNargv and 23279e7bcd65SmrgXtNargc resources. 23289e7bcd65Smrg</para> 23299e7bcd65Smrg 23309e7bcd65Smrg<para> 23319e7bcd65SmrgTo create multiple top-level shells within a single (logical) 23329e7bcd65Smrgapplication, 23339e7bcd65Smrgyou can use one of two methods: 23349e7bcd65Smrg</para> 23359e7bcd65Smrg<itemizedlist spacing='compact'> 23369e7bcd65Smrg <listitem> 23379e7bcd65Smrg <para> 23389e7bcd65SmrgDesignate one shell as the real top-level shell and 23399e7bcd65Smrgcreate the others as pop-up children of it by using 23409e7bcd65Smrg<xref linkend='XtCreatePopupShell' xrefstyle='select: title'/>. 23419e7bcd65Smrg </para> 23429e7bcd65Smrg </listitem> 23439e7bcd65Smrg <listitem> 23449e7bcd65Smrg <para> 23459e7bcd65SmrgHave all shells as pop-up children of an unrealized top-level shell. 23469e7bcd65Smrg </para> 23479e7bcd65Smrg </listitem> 23489e7bcd65Smrg</itemizedlist> 23499e7bcd65Smrg<para> 23509e7bcd65SmrgThe first method, 23519e7bcd65Smrgwhich is best used when there is a clear choice for what is the main window, 23529e7bcd65Smrgleads to resource specifications like the following: 23539e7bcd65Smrg</para> 23540568f49bSmrg<programlisting> 23550568f49bSmrgxmail.geometry:... (the main window) 23560568f49bSmrgxmail.read.geometry:... (the read window) 23570568f49bSmrgxmail.compose.geometry:... (the compose window) 23580568f49bSmrg</programlisting> 23599e7bcd65Smrg<para> 23609e7bcd65SmrgThe second method, 23619e7bcd65Smrgwhich is best if there is no main window, 23629e7bcd65Smrgleads to resource specifications like the following: 23639e7bcd65Smrg</para> 23640568f49bSmrg<programlisting> 23650568f49bSmrgxmail.headers.geometry:... (the headers window) 23660568f49bSmrgxmail.read.geometry:... (the read window) 23670568f49bSmrgxmail.compose.geometry:... (the compose window) 23680568f49bSmrg</programlisting> 23699e7bcd65Smrg<para> 23709e7bcd65SmrgTo create a top-level widget that is the root of a widget tree using 23719e7bcd65Smrgvarargs lists, use 23729e7bcd65Smrg<xref linkend='XtVaAppCreateShell' xrefstyle='select: title'/>. 23739e7bcd65Smrg</para> 23749e7bcd65Smrg 23759e7bcd65Smrg<funcsynopsis id='XtVaAppCreateShell'> 23769e7bcd65Smrg<funcprototype> 23779e7bcd65Smrg <funcdef>Widget <function>XtVaAppCreateShell</function></funcdef> 23780568f49bSmrg <paramdef>const char * <parameter>name</parameter></paramdef> 23790568f49bSmrg <paramdef>const char * <parameter>application_class</parameter></paramdef> 23809e7bcd65Smrg <paramdef>WidgetClass <parameter>widget_class</parameter></paramdef> 23819e7bcd65Smrg <paramdef>Display * <parameter>display</parameter></paramdef> 23820568f49bSmrg <paramdef>...</paramdef> 23839e7bcd65Smrg</funcprototype> 23849e7bcd65Smrg</funcsynopsis> 23859e7bcd65Smrg 23869e7bcd65Smrg<variablelist> 23879e7bcd65Smrg <varlistentry> 23889e7bcd65Smrg <term> 23899e7bcd65Smrg <emphasis remap='I'>name</emphasis> 23909e7bcd65Smrg </term> 23919e7bcd65Smrg <listitem> 23929e7bcd65Smrg <para> 23939e7bcd65SmrgSpecifies the instance name of the shell widget. 23949e7bcd65SmrgIf <emphasis remap='I'>name</emphasis> is NULL, 23959e7bcd65Smrgthe application name passed to 23969e7bcd65Smrg<xref linkend='XtDisplayInitialize' xrefstyle='select: title'/> 23979e7bcd65Smrgis used. 23989e7bcd65Smrg </para> 23999e7bcd65Smrg </listitem> 24009e7bcd65Smrg </varlistentry> 24019e7bcd65Smrg <varlistentry> 24029e7bcd65Smrg <term> 24039e7bcd65Smrg <emphasis remap='I'>application_class</emphasis> 24049e7bcd65Smrg </term> 24059e7bcd65Smrg <listitem> 24069e7bcd65Smrg <para> 24079e7bcd65SmrgSpecifies the resource class string to be used in 24089e7bcd65Smrgplace of the widget <emphasis remap='I'>class_name</emphasis> string when 24099e7bcd65Smrg<emphasis remap='I'>widget_class</emphasis> is 24109e7bcd65Smrg<function>applicationShellWidgetClass</function> 24119e7bcd65Smrgor a subclass thereof. 24129e7bcd65Smrg </para> 24139e7bcd65Smrg </listitem> 24149e7bcd65Smrg </varlistentry> 24159e7bcd65Smrg <varlistentry> 24169e7bcd65Smrg <term> 24179e7bcd65Smrg <emphasis remap='I'>widget_class</emphasis> 24189e7bcd65Smrg </term> 24199e7bcd65Smrg <listitem> 24209e7bcd65Smrg <para> 24219e7bcd65SmrgSpecifies the widget class for the top-level widget. 24229e7bcd65Smrg </para> 24239e7bcd65Smrg </listitem> 24249e7bcd65Smrg </varlistentry> 24259e7bcd65Smrg <varlistentry> 24269e7bcd65Smrg <term> 24279e7bcd65Smrg <emphasis remap='I'>display</emphasis> 24289e7bcd65Smrg </term> 24299e7bcd65Smrg <listitem> 24309e7bcd65Smrg <para> 24319e7bcd65SmrgSpecifies the display for the default screen 24329e7bcd65Smrgand for the resource database used to retrieve 24339e7bcd65Smrgthe shell widget resources. 24349e7bcd65Smrg </para> 24359e7bcd65Smrg </listitem> 24369e7bcd65Smrg </varlistentry> 24379e7bcd65Smrg <varlistentry> 24389e7bcd65Smrg <term> 24399e7bcd65Smrg ... 24409e7bcd65Smrg </term> 24419e7bcd65Smrg <listitem> 24429e7bcd65Smrg <para> 24439e7bcd65SmrgSpecifies the variable argument list to override any other 24449e7bcd65Smrgresource specifications. 24459e7bcd65Smrg </para> 24469e7bcd65Smrg </listitem> 24479e7bcd65Smrg </varlistentry> 24489e7bcd65Smrg</variablelist> 24499e7bcd65Smrg 24509e7bcd65Smrg<para> 24519e7bcd65SmrgThe 24529e7bcd65Smrg<xref linkend='XtVaAppCreateShell' xrefstyle='select: title'/> 24539e7bcd65Smrgprocedure is identical in function to 24549e7bcd65Smrg<xref linkend='XtAppCreateShell' xrefstyle='select: title'/> 24559e7bcd65Smrgwith the <emphasis remap='I'>args</emphasis> and <emphasis remap='I'>num_args</emphasis> parameters replaced by a varargs list, as 24569e7bcd65Smrgdescribed in Section 2.5.1. 24579e7bcd65Smrg</para> 24589e7bcd65Smrg</sect2> 24599e7bcd65Smrg 24609e7bcd65Smrg<sect2 id="Convenience_Procedure_to_Initialize_an_Application"> 24619e7bcd65Smrg<title>Convenience Procedure to Initialize an Application</title> 24629e7bcd65Smrg<para> 24639e7bcd65SmrgTo initialize the Intrinsics internals, create an application context, 24649e7bcd65Smrgopen and initialize a display, and create the initial root shell 24659e7bcd65Smrginstance, an application may use 24669e7bcd65Smrg<xref linkend='XtOpenApplication' xrefstyle='select: title'/> 24679e7bcd65Smrgor 24689e7bcd65Smrg<xref linkend='XtVaOpenApplication' xrefstyle='select: title'/>. 24699e7bcd65Smrg</para> 24709e7bcd65Smrg 24719e7bcd65Smrg<funcsynopsis id='XtOpenApplication'> 24729e7bcd65Smrg<funcprototype> 24739e7bcd65Smrg <funcdef>Widget <function>XtOpenApplication</function></funcdef> 24749e7bcd65Smrg <paramdef>XtAppContext * <parameter>app_context_return</parameter></paramdef> 24750568f49bSmrg <paramdef>const char * <parameter>application_class</parameter></paramdef> 24769e7bcd65Smrg <paramdef>XrmOptionDescList <parameter>options</parameter></paramdef> 24779e7bcd65Smrg <paramdef>Cardinal <parameter>num_options</parameter></paramdef> 24789e7bcd65Smrg <paramdef>int * <parameter>argc_in_out</parameter></paramdef> 24790568f49bSmrg <paramdef>char ** <parameter>argv_in_out</parameter></paramdef> 24809e7bcd65Smrg <paramdef>String * <parameter>fallback_resources</parameter></paramdef> 24819e7bcd65Smrg <paramdef>WidgetClass <parameter>widget_class</parameter></paramdef> 24829e7bcd65Smrg <paramdef>ArgList <parameter>args</parameter></paramdef> 24839e7bcd65Smrg <paramdef>Cardinal <parameter>num_args</parameter></paramdef> 24849e7bcd65Smrg</funcprototype> 24859e7bcd65Smrg</funcsynopsis> 24869e7bcd65Smrg 24879e7bcd65Smrg<variablelist> 24889e7bcd65Smrg <varlistentry> 24899e7bcd65Smrg <term> 24909e7bcd65Smrg <emphasis remap='I'>app_context_return</emphasis> 24919e7bcd65Smrg </term> 24929e7bcd65Smrg <listitem> 24939e7bcd65Smrg <para> 24949e7bcd65SmrgReturns the application context, if non-NULL. 24959e7bcd65Smrg </para> 24969e7bcd65Smrg </listitem> 24979e7bcd65Smrg </varlistentry> 24989e7bcd65Smrg <varlistentry> 24999e7bcd65Smrg <term> 25009e7bcd65Smrg <emphasis remap='I'>application_class</emphasis> 25019e7bcd65Smrg </term> 25029e7bcd65Smrg <listitem> 25039e7bcd65Smrg <para> 25049e7bcd65SmrgSpecifies the class name of the application. 25059e7bcd65Smrg </para> 25069e7bcd65Smrg </listitem> 25079e7bcd65Smrg </varlistentry> 25089e7bcd65Smrg <varlistentry> 25099e7bcd65Smrg <term> 25109e7bcd65Smrg <emphasis remap='I'>options</emphasis> 25119e7bcd65Smrg </term> 25129e7bcd65Smrg <listitem> 25139e7bcd65Smrg <para> 25149e7bcd65SmrgSpecifies the command line options table. 25159e7bcd65Smrg </para> 25169e7bcd65Smrg </listitem> 25179e7bcd65Smrg </varlistentry> 25189e7bcd65Smrg <varlistentry> 25199e7bcd65Smrg <term> 25209e7bcd65Smrg <emphasis remap='I'>num_options</emphasis> 25219e7bcd65Smrg </term> 25229e7bcd65Smrg <listitem> 25239e7bcd65Smrg <para> 25249e7bcd65SmrgSpecifies the number of entries in <emphasis remap='I'>options</emphasis>. 25259e7bcd65Smrg </para> 25269e7bcd65Smrg </listitem> 25279e7bcd65Smrg </varlistentry> 25289e7bcd65Smrg <varlistentry> 25299e7bcd65Smrg <term> 25309e7bcd65Smrg <emphasis remap='I'>argc_in_out</emphasis> 25319e7bcd65Smrg </term> 25329e7bcd65Smrg <listitem> 25339e7bcd65Smrg <para> 25349e7bcd65SmrgSpecifies a pointer to the number of command line arguments. 25359e7bcd65Smrg </para> 25369e7bcd65Smrg </listitem> 25379e7bcd65Smrg </varlistentry> 25389e7bcd65Smrg <varlistentry> 25399e7bcd65Smrg <term> 25409e7bcd65Smrg <emphasis remap='I'>argv_in_out</emphasis> 25419e7bcd65Smrg </term> 25429e7bcd65Smrg <listitem> 25439e7bcd65Smrg <para> 25449e7bcd65SmrgSpecifies a pointer to the command line arguments. 25459e7bcd65Smrg </para> 25469e7bcd65Smrg </listitem> 25479e7bcd65Smrg </varlistentry> 25489e7bcd65Smrg <varlistentry> 25499e7bcd65Smrg <term> 25509e7bcd65Smrg <emphasis remap='I'>fallback_resources</emphasis> 25519e7bcd65Smrg </term> 25529e7bcd65Smrg <listitem> 25539e7bcd65Smrg <para> 25549e7bcd65SmrgSpecifies resource values to be used if the application class resource 25559e7bcd65Smrgfile cannot be opened or read, or NULL. 25569e7bcd65Smrg </para> 25579e7bcd65Smrg </listitem> 25589e7bcd65Smrg </varlistentry> 25599e7bcd65Smrg <varlistentry> 25609e7bcd65Smrg <term> 25619e7bcd65Smrg <emphasis remap='I'>widget_class</emphasis> 25629e7bcd65Smrg </term> 25639e7bcd65Smrg <listitem> 25649e7bcd65Smrg <para> 25659e7bcd65SmrgSpecifies the class of the widget to be created. Must be shellWidgetClass 25669e7bcd65Smrgor a subclass. 25679e7bcd65Smrg </para> 25689e7bcd65Smrg </listitem> 25699e7bcd65Smrg </varlistentry> 25709e7bcd65Smrg <varlistentry> 25719e7bcd65Smrg <term> 25729e7bcd65Smrg <emphasis remap='I'>args</emphasis> 25739e7bcd65Smrg </term> 25749e7bcd65Smrg <listitem> 25759e7bcd65Smrg <para> 25769e7bcd65SmrgSpecifies the argument list to override any 25779e7bcd65Smrgother resource specifications for the created shell widget. 25789e7bcd65Smrg </para> 25799e7bcd65Smrg </listitem> 25809e7bcd65Smrg </varlistentry> 25819e7bcd65Smrg <varlistentry> 25829e7bcd65Smrg <term> 25839e7bcd65Smrg <emphasis remap='I'>num_args</emphasis> 25849e7bcd65Smrg </term> 25859e7bcd65Smrg <listitem> 25869e7bcd65Smrg <para> 25879e7bcd65SmrgSpecifies the number of entries in the argument list. 25889e7bcd65Smrg </para> 25899e7bcd65Smrg </listitem> 25909e7bcd65Smrg </varlistentry> 25919e7bcd65Smrg</variablelist> 25929e7bcd65Smrg 25939e7bcd65Smrg<para> 25949e7bcd65SmrgThe 25959e7bcd65Smrg<xref linkend='XtOpenApplication' xrefstyle='select: title'/> 25969e7bcd65Smrgfunction calls 25979e7bcd65Smrg<xref linkend='XtToolkitInitialize' xrefstyle='select: title'/> 25989e7bcd65Smrgfollowed by 25999e7bcd65Smrg<xref linkend='XtCreateApplicationContext' xrefstyle='select: title'/>, 26009e7bcd65Smrgthen calls 26019e7bcd65Smrg<xref linkend='XtOpenDisplay' xrefstyle='select: title'/> 26029e7bcd65Smrgwith <emphasis remap='I'>display_string</emphasis> NULL and 26039e7bcd65Smrg<emphasis remap='I'>application_name</emphasis> NULL, and finally calls 26049e7bcd65Smrg<xref linkend='XtAppCreateShell' xrefstyle='select: title'/> 26059e7bcd65Smrgwith <emphasis remap='I'>name</emphasis> NULL, the specified <emphasis remap='I'>widget_class</emphasis>, 26069e7bcd65Smrgan argument list and count, 26079e7bcd65Smrgand returns the created shell. 26089e7bcd65SmrgThe recommended <emphasis remap='I'>widget_class</emphasis> is 26099e7bcd65Smrg<function>sessionShellWidgetClass</function>. 26109e7bcd65SmrgThe argument list and count are created by merging 26119e7bcd65Smrgthe specified <emphasis remap='I'>args</emphasis> and <emphasis remap='I'>num_args</emphasis> with a list 26129e7bcd65Smrgcontaining the specified <emphasis remap='I'>argc</emphasis> and <emphasis remap='I'>argv</emphasis>. 26139e7bcd65SmrgThe modified <emphasis remap='I'>argc</emphasis> and <emphasis remap='I'>argv</emphasis> returned by 26149e7bcd65Smrg<xref linkend='XtDisplayInitialize' xrefstyle='select: title'/> 26159e7bcd65Smrgare returned in <emphasis remap='I'>argc_in_out</emphasis> and <emphasis remap='I'>argv_in_out</emphasis>. If 26169e7bcd65Smrg<emphasis remap='I'>app_context_return</emphasis> is not NULL, the created application context is 26179e7bcd65Smrgalso returned. If the display specified by the command line cannot be 26189e7bcd65Smrgopened, an error message is issued and 26199e7bcd65Smrg<xref linkend='XtOpenApplication' xrefstyle='select: title'/> 26209e7bcd65Smrgterminates the application. If <emphasis remap='I'>fallback_resources</emphasis> is non-NULL, 26219e7bcd65Smrg<xref linkend='XtAppSetFallbackResources' xrefstyle='select: title'/> 26229e7bcd65Smrgis called with the value prior to calling 26239e7bcd65Smrg<xref linkend='XtOpenDisplay' xrefstyle='select: title'/>. 26249e7bcd65Smrg</para> 26259e7bcd65Smrg 26269e7bcd65Smrg<funcsynopsis id='XtVaOpenApplication'> 26279e7bcd65Smrg<funcprototype> 26289e7bcd65Smrg <funcdef>Widget <function>XtVaOpenApplication</function></funcdef> 26299e7bcd65Smrg <paramdef>XtAppContext * <parameter>app_context_return</parameter></paramdef> 26300568f49bSmrg <paramdef>const char * <parameter>application_class</parameter></paramdef> 26319e7bcd65Smrg <paramdef>XrmOptionDescList <parameter>options</parameter></paramdef> 26329e7bcd65Smrg <paramdef>Cardinal <parameter>num_options</parameter></paramdef> 26339e7bcd65Smrg <paramdef>int * <parameter>argc_in_out</parameter></paramdef> 26340568f49bSmrg <paramdef>char ** <parameter>argv_in_out</parameter></paramdef> 26359e7bcd65Smrg <paramdef>String * <parameter>fallback_resources</parameter></paramdef> 26369e7bcd65Smrg <paramdef>WidgetClass <parameter>widget_class</parameter></paramdef> 26370568f49bSmrg <paramdef>...</paramdef> 26389e7bcd65Smrg</funcprototype> 26399e7bcd65Smrg</funcsynopsis> 26409e7bcd65Smrg 26419e7bcd65Smrg<variablelist> 26429e7bcd65Smrg <varlistentry> 26439e7bcd65Smrg <term> 26449e7bcd65Smrg <emphasis remap='I'>app_context_return</emphasis> 26459e7bcd65Smrg </term> 26469e7bcd65Smrg <listitem> 26479e7bcd65Smrg <para> 26489e7bcd65SmrgReturns the application context, if non-NULL. 26499e7bcd65Smrg </para> 26509e7bcd65Smrg </listitem> 26519e7bcd65Smrg </varlistentry> 26529e7bcd65Smrg <varlistentry> 26539e7bcd65Smrg <term> 26549e7bcd65Smrg <emphasis remap='I'>application_class</emphasis> 26559e7bcd65Smrg </term> 26569e7bcd65Smrg <listitem> 26579e7bcd65Smrg <para> 26589e7bcd65SmrgSpecifies the class name of the application. 26599e7bcd65Smrg </para> 26609e7bcd65Smrg </listitem> 26619e7bcd65Smrg </varlistentry> 26629e7bcd65Smrg <varlistentry> 26639e7bcd65Smrg <term> 26649e7bcd65Smrg <emphasis remap='I'>options</emphasis> 26659e7bcd65Smrg </term> 26669e7bcd65Smrg <listitem> 26679e7bcd65Smrg <para> 26689e7bcd65SmrgSpecifies the command line options table. 26699e7bcd65Smrg </para> 26709e7bcd65Smrg </listitem> 26719e7bcd65Smrg </varlistentry> 26729e7bcd65Smrg <varlistentry> 26739e7bcd65Smrg <term> 26749e7bcd65Smrg <emphasis remap='I'>num_options</emphasis> 26759e7bcd65Smrg </term> 26769e7bcd65Smrg <listitem> 26779e7bcd65Smrg <para> 26789e7bcd65SmrgSpecifies the number of entries in <emphasis remap='I'>options</emphasis>. 26799e7bcd65Smrg </para> 26809e7bcd65Smrg </listitem> 26819e7bcd65Smrg </varlistentry> 26829e7bcd65Smrg <varlistentry> 26839e7bcd65Smrg <term> 26849e7bcd65Smrg <emphasis remap='I'>argc_in_out</emphasis> 26859e7bcd65Smrg </term> 26869e7bcd65Smrg <listitem> 26879e7bcd65Smrg <para> 26889e7bcd65SmrgSpecifies a pointer to the number of command line arguments. 26899e7bcd65Smrg </para> 26909e7bcd65Smrg </listitem> 26919e7bcd65Smrg </varlistentry> 26929e7bcd65Smrg <varlistentry> 26939e7bcd65Smrg <term> 26949e7bcd65Smrg <emphasis remap='I'>argv_in_out</emphasis> 26959e7bcd65Smrg </term> 26969e7bcd65Smrg <listitem> 26979e7bcd65Smrg <para> 26989e7bcd65SmrgSpecifies the command line arguments array. 26999e7bcd65Smrg </para> 27009e7bcd65Smrg </listitem> 27019e7bcd65Smrg </varlistentry> 27029e7bcd65Smrg <varlistentry> 27039e7bcd65Smrg <term> 27049e7bcd65Smrg <emphasis remap='I'>fallback_resources</emphasis> 27059e7bcd65Smrg </term> 27069e7bcd65Smrg <listitem> 27079e7bcd65Smrg <para> 27089e7bcd65SmrgSpecifies resource values to be used if the application class 27099e7bcd65Smrgresource file cannot be opened, or NULL. 27109e7bcd65Smrg </para> 27119e7bcd65Smrg </listitem> 27129e7bcd65Smrg </varlistentry> 27139e7bcd65Smrg <varlistentry> 27149e7bcd65Smrg <term> 27159e7bcd65Smrg <emphasis remap='I'>widget_class</emphasis> 27169e7bcd65Smrg </term> 27179e7bcd65Smrg <listitem> 27189e7bcd65Smrg <para> 27199e7bcd65SmrgSpecifies the class of the widget to be created. Must be shellWidgetClass 27209e7bcd65Smrgor a subclass. 27219e7bcd65Smrg </para> 27229e7bcd65Smrg </listitem> 27239e7bcd65Smrg </varlistentry> 27249e7bcd65Smrg <varlistentry> 27259e7bcd65Smrg <term> 27269e7bcd65Smrg ... 27279e7bcd65Smrg </term> 27289e7bcd65Smrg <listitem> 27299e7bcd65Smrg <para> 27309e7bcd65SmrgSpecifies the variable argument list to override any other 27319e7bcd65Smrgresource specifications for the created shell. 27329e7bcd65Smrg </para> 27339e7bcd65Smrg </listitem> 27349e7bcd65Smrg </varlistentry> 27359e7bcd65Smrg</variablelist> 27369e7bcd65Smrg 27379e7bcd65Smrg<para> 27389e7bcd65SmrgThe 27399e7bcd65Smrg<xref linkend='XtVaOpenApplication' xrefstyle='select: title'/> 27409e7bcd65Smrgprocedure is identical in function to 27419e7bcd65Smrg<xref linkend='XtOpenApplication' xrefstyle='select: title'/> 27429e7bcd65Smrgwith the <emphasis remap='I'>args</emphasis> and <emphasis remap='I'>num_args</emphasis> parameters replaced by a varargs list, 27439e7bcd65Smrgas described 27449e7bcd65Smrgin Section 2.5.1. 27459e7bcd65Smrg</para> 27469e7bcd65Smrg</sect2> 27479e7bcd65Smrg 27489e7bcd65Smrg<sect2 id="Widget_Instance_Allocation_The_allocate_Procedure"> 27499e7bcd65Smrg<title>Widget Instance Allocation: The allocate Procedure</title> 27509e7bcd65Smrg<para> 27519e7bcd65SmrgA widget class may optionally provide an instance allocation procedure 27529e7bcd65Smrgin the 27539e7bcd65Smrg<function>ObjectClassExtension</function> 27549e7bcd65Smrgrecord. 27559e7bcd65Smrg</para> 27569e7bcd65Smrg 27579e7bcd65Smrg<para> 27589e7bcd65SmrgWhen the call to create a widget includes a varargs list containing 27599e7bcd65Smrg<function>XtVaTypedArg</function>, 27609e7bcd65Smrgthese arguments will be passed to the allocation procedure in an 27619e7bcd65Smrg<function>XtTypedArgList</function>. 27629e7bcd65Smrg</para> 27630568f49bSmrg<programlisting> 27649e7bcd65Smrgtypedef struct { 27659e7bcd65Smrg String name; 27669e7bcd65Smrg String type; 27679e7bcd65Smrg XtArgVal value; 27689e7bcd65Smrg int size; 27699e7bcd65Smrg} XtTypedArg, *XtTypedArgList; 27700568f49bSmrg</programlisting> 27719e7bcd65Smrg<para> 27729e7bcd65SmrgThe allocate procedure pointer in the 27739e7bcd65Smrg<function>ObjectClassExtension</function> 27749e7bcd65Smrgrecord is of type 27759e7bcd65Smrg<xref linkend='XtAllocateProc' xrefstyle='select: title'/>. 27769e7bcd65Smrg</para> 27779e7bcd65Smrg 27789e7bcd65Smrg<funcsynopsis id='XtAllocateProc'> 27799e7bcd65Smrg<funcprototype> 27800568f49bSmrg <funcdef>typedef void <function>(*XtAllocateProc)</function></funcdef> 27819e7bcd65Smrg <paramdef>WidgetClass <parameter>widget_class</parameter></paramdef> 27829e7bcd65Smrg <paramdef>Cardinal* <parameter>constraint_size</parameter></paramdef> 27839e7bcd65Smrg <paramdef>Cardinal* <parameter>more_bytes</parameter></paramdef> 27849e7bcd65Smrg <paramdef>ArgList <parameter>args</parameter></paramdef> 27859e7bcd65Smrg <paramdef>Cardinal* <parameter>num_args</parameter></paramdef> 27869e7bcd65Smrg <paramdef>XtTypedArgList <parameter>typed_args</parameter></paramdef> 27879e7bcd65Smrg <paramdef>Cardinal* <parameter>num_typed_args</parameter></paramdef> 27889e7bcd65Smrg <paramdef>Widget* <parameter>new_return</parameter></paramdef> 27899e7bcd65Smrg <paramdef>XtPointer* <parameter>more_bytes_return</parameter></paramdef> 27909e7bcd65Smrg</funcprototype> 27919e7bcd65Smrg</funcsynopsis> 27929e7bcd65Smrg 27939e7bcd65Smrg<variablelist> 27949e7bcd65Smrg <varlistentry> 27959e7bcd65Smrg <term> 27969e7bcd65Smrg <emphasis remap='I'>widget_class</emphasis> 27979e7bcd65Smrg </term> 27989e7bcd65Smrg <listitem> 27999e7bcd65Smrg <para> 28009e7bcd65SmrgSpecifies the widget class of the instance to allocate. 28019e7bcd65Smrg </para> 28029e7bcd65Smrg </listitem> 28039e7bcd65Smrg </varlistentry> 28049e7bcd65Smrg <varlistentry> 28059e7bcd65Smrg <term> 28069e7bcd65Smrg <emphasis remap='I'>constraint_size</emphasis> 28079e7bcd65Smrg </term> 28089e7bcd65Smrg <listitem> 28099e7bcd65Smrg <para> 28109e7bcd65SmrgSpecifies the size of the constraint record to allocate, or 0. 28119e7bcd65Smrg </para> 28129e7bcd65Smrg </listitem> 28139e7bcd65Smrg </varlistentry> 28149e7bcd65Smrg <varlistentry> 28159e7bcd65Smrg <term> 28169e7bcd65Smrg <emphasis remap='I'>more_bytes</emphasis> 28179e7bcd65Smrg </term> 28189e7bcd65Smrg <listitem> 28199e7bcd65Smrg <para> 28209e7bcd65SmrgSpecifies the number of auxiliary bytes of memory to allocate. 28219e7bcd65Smrg </para> 28229e7bcd65Smrg </listitem> 28239e7bcd65Smrg </varlistentry> 28249e7bcd65Smrg <varlistentry> 28259e7bcd65Smrg <term> 28269e7bcd65Smrg <emphasis remap='I'>args</emphasis> 28279e7bcd65Smrg </term> 28289e7bcd65Smrg <listitem> 28299e7bcd65Smrg <para> 28309e7bcd65SmrgSpecifies the argument list as given in the call to create the widget. 28319e7bcd65Smrg </para> 28329e7bcd65Smrg </listitem> 28339e7bcd65Smrg </varlistentry> 28349e7bcd65Smrg <varlistentry> 28359e7bcd65Smrg <term> 28369e7bcd65Smrg <emphasis remap='I'>num_args</emphasis> 28379e7bcd65Smrg </term> 28389e7bcd65Smrg <listitem> 28399e7bcd65Smrg <para> 28409e7bcd65SmrgSpecifies the number of arguments. 28419e7bcd65Smrg </para> 28429e7bcd65Smrg </listitem> 28439e7bcd65Smrg </varlistentry> 28449e7bcd65Smrg <varlistentry> 28459e7bcd65Smrg <term> 28469e7bcd65Smrg <emphasis remap='I'>typed_args</emphasis> 28479e7bcd65Smrg </term> 28489e7bcd65Smrg <listitem> 28499e7bcd65Smrg <para> 28509e7bcd65SmrgSpecifies the list of typed arguments given in the call to create the widget. 28519e7bcd65Smrg </para> 28529e7bcd65Smrg </listitem> 28539e7bcd65Smrg </varlistentry> 28549e7bcd65Smrg <varlistentry> 28559e7bcd65Smrg <term> 28569e7bcd65Smrg <emphasis remap='I'>num_typed_args</emphasis> 28579e7bcd65Smrg </term> 28589e7bcd65Smrg <listitem> 28599e7bcd65Smrg <para> 28609e7bcd65SmrgSpecifies the number of typed arguments. 28619e7bcd65Smrg </para> 28629e7bcd65Smrg </listitem> 28639e7bcd65Smrg </varlistentry> 28649e7bcd65Smrg <varlistentry> 28659e7bcd65Smrg <term> 28669e7bcd65Smrg <emphasis remap='I'>new_return</emphasis> 28679e7bcd65Smrg </term> 28689e7bcd65Smrg <listitem> 28699e7bcd65Smrg <para> 28709e7bcd65SmrgReturns a pointer to the newly allocated instance, or NULL in case of error. 28719e7bcd65Smrg </para> 28729e7bcd65Smrg </listitem> 28739e7bcd65Smrg </varlistentry> 28749e7bcd65Smrg <varlistentry> 28759e7bcd65Smrg <term> 28769e7bcd65Smrg <emphasis remap='I'>more_bytes_return</emphasis> 28779e7bcd65Smrg </term> 28789e7bcd65Smrg <listitem> 28799e7bcd65Smrg <para> 28809e7bcd65SmrgReturns the auxiliary memory if it was requested, or NULL 28819e7bcd65Smrgif requested and an error occurred; otherwise, unchanged. 28829e7bcd65Smrg </para> 28839e7bcd65Smrg </listitem> 28849e7bcd65Smrg </varlistentry> 28859e7bcd65Smrg</variablelist> 28869e7bcd65Smrg 28879e7bcd65Smrg<para> 28889e7bcd65SmrgAt widget allocation time, if an extension record with <emphasis remap='I'>record_type</emphasis> 28899e7bcd65Smrgequal to 28909e7bcd65Smrg<emphasis role='strong'>NULLQUARK</emphasis> 28919e7bcd65Smrgis located through the object class part <emphasis remap='I'>extension</emphasis> field 28929e7bcd65Smrgand the <emphasis remap='I'>allocate</emphasis> field is not NULL, the 28939e7bcd65Smrg<xref linkend='XtAllocateProc' xrefstyle='select: title'/> 28949e7bcd65Smrgwill be invoked to allocate memory for the widget. If no ObjectClassPart 28959e7bcd65Smrgextension record is declared with <emphasis remap='I'>record_type equal</emphasis> to 28969e7bcd65Smrg<emphasis role='strong'>NULLQUARK</emphasis>, 28979e7bcd65Smrgthen 28989e7bcd65Smrg<function>XtInheritAllocate</function> 28999e7bcd65Smrgand 29009e7bcd65Smrg<function>XtInheritDeallocate</function> 29019e7bcd65Smrgare assumed. 29029e7bcd65SmrgIf no 29039e7bcd65Smrg<xref linkend='XtAllocateProc' xrefstyle='select: title'/> 29049e7bcd65Smrgis found, the Intrinsics will allocate memory for the widget. 29059e7bcd65Smrg</para> 29069e7bcd65Smrg 29079e7bcd65Smrg<para> 29089e7bcd65SmrgAn 29099e7bcd65Smrg<xref linkend='XtAllocateProc' xrefstyle='select: title'/> 29109e7bcd65Smrgmust perform the following: 29119e7bcd65Smrg</para> 29129e7bcd65Smrg<itemizedlist spacing='compact'> 29139e7bcd65Smrg <listitem> 29149e7bcd65Smrg <para> 29159e7bcd65SmrgAllocate memory for the widget instance and return it in <emphasis remap='I'>new_return</emphasis>. 29169e7bcd65SmrgThe memory must be at least <emphasis remap='I'>wc->core_class.widget_size</emphasis> bytes in length, 29179e7bcd65Smrgdouble-word aligned. 29189e7bcd65Smrg </para> 29199e7bcd65Smrg </listitem> 29209e7bcd65Smrg <listitem> 29219e7bcd65Smrg <para> 29229e7bcd65SmrgInitialize the <emphasis remap='I'>core.constraints</emphasis> field in the instance record to NULL 29239e7bcd65Smrgor to point to a constraint record. If <emphasis remap='I'>constraint_size</emphasis> 29249e7bcd65Smrgis not 0, the procedure must allocate memory for the constraint record. 29259e7bcd65SmrgThe memory must be double-word aligned. 29269e7bcd65Smrg </para> 29279e7bcd65Smrg </listitem> 29289e7bcd65Smrg <listitem> 29299e7bcd65Smrg <para> 29309e7bcd65SmrgIf <emphasis remap='I'>more_bytes</emphasis> is not 0, then the address of a block of memory 29319e7bcd65Smrgat least <emphasis remap='I'>more_bytes</emphasis> in size, double-word aligned, must be 29329e7bcd65Smrgreturned in the <emphasis remap='I'>more_bytes_return</emphasis> parameter, 29339e7bcd65Smrgor NULL to indicate an error. 29349e7bcd65Smrg </para> 29359e7bcd65Smrg </listitem> 29369e7bcd65Smrg</itemizedlist> 29379e7bcd65Smrg<para> 29389e7bcd65SmrgA class allocation procedure that envelops the allocation procedure of a 29399e7bcd65Smrgsuperclass must rely on the enveloped procedure to perform the instance 29409e7bcd65Smrgand constraint allocation. 29419e7bcd65SmrgAllocation procedures should refrain from initializing fields in the 29429e7bcd65Smrgwidget record except to store pointers to newly allocated additional memory. 29439e7bcd65SmrgUnder no circumstances should an allocation procedure that envelopes 29449e7bcd65Smrgits superclass allocation procedure modify fields in the 29459e7bcd65Smrginstance part of any superclass. 29469e7bcd65Smrg</para> 29479e7bcd65Smrg</sect2> 29489e7bcd65Smrg 29499e7bcd65Smrg<sect2 id="Widget_Instance_Initialization_The_initialize_Procedure"> 29509e7bcd65Smrg<title>Widget Instance Initialization: The initialize Procedure</title> 29519e7bcd65Smrg<para> 29529e7bcd65SmrgThe initialize procedure pointer in a widget class is of type 29539e7bcd65Smrg<xref linkend='XtInitProc' xrefstyle='select: title'/>. 29549e7bcd65Smrg</para> 29559e7bcd65Smrg 29569e7bcd65Smrg<funcsynopsis id='XtInitProc'> 29579e7bcd65Smrg<funcprototype> 29589e7bcd65Smrg <funcdef>typedef void <function>(*XtInitProc)</function></funcdef> 29599e7bcd65Smrg <paramdef>Widget <parameter>request</parameter></paramdef> 29609e7bcd65Smrg <paramdef>Widget <parameter>new</parameter></paramdef> 29619e7bcd65Smrg <paramdef>ArgList <parameter>args</parameter></paramdef> 29629e7bcd65Smrg <paramdef>Cardinal * <parameter>num_args</parameter></paramdef> 29639e7bcd65Smrg</funcprototype> 29649e7bcd65Smrg</funcsynopsis> 29659e7bcd65Smrg 29669e7bcd65Smrg<variablelist> 29679e7bcd65Smrg <varlistentry> 29689e7bcd65Smrg <term> 29699e7bcd65Smrg <emphasis remap='I'>request</emphasis> 29709e7bcd65Smrg </term> 29719e7bcd65Smrg <listitem> 29729e7bcd65Smrg <para> 29739e7bcd65SmrgSpecifies a copy of the widget with resource values as requested by the 29749e7bcd65Smrgargument list, the resource database, and the widget defaults. 29759e7bcd65Smrg </para> 29769e7bcd65Smrg </listitem> 29779e7bcd65Smrg </varlistentry> 29789e7bcd65Smrg <varlistentry> 29799e7bcd65Smrg <term> 29809e7bcd65Smrg <emphasis remap='I'>new</emphasis> 29819e7bcd65Smrg </term> 29829e7bcd65Smrg <listitem> 29839e7bcd65Smrg <para> 29849e7bcd65SmrgSpecifies the widget with the new values, both resource and nonresource, 29859e7bcd65Smrgthat are actually allowed. 29869e7bcd65Smrg </para> 29879e7bcd65Smrg </listitem> 29889e7bcd65Smrg </varlistentry> 29899e7bcd65Smrg <varlistentry> 29909e7bcd65Smrg <term> 29919e7bcd65Smrg <emphasis remap='I'>args</emphasis> 29929e7bcd65Smrg </term> 29939e7bcd65Smrg <listitem> 29949e7bcd65Smrg <para> 29959e7bcd65SmrgSpecifies the argument list passed by the client, for 29969e7bcd65Smrgcomputing derived resource values. 29979e7bcd65SmrgIf the client created the widget using a varargs form, any resources 29989e7bcd65Smrgspecified via 29999e7bcd65Smrg<function>XtVaTypedArg</function> 30009e7bcd65Smrgare converted to the widget representation and the list is transformed 30019e7bcd65Smrginto the 30029e7bcd65Smrg<function>ArgList</function> 30039e7bcd65Smrgformat. 30049e7bcd65Smrg </para> 30059e7bcd65Smrg </listitem> 30069e7bcd65Smrg </varlistentry> 30079e7bcd65Smrg <varlistentry> 30089e7bcd65Smrg <term> 30099e7bcd65Smrg <emphasis remap='I'>num_args</emphasis> 30109e7bcd65Smrg </term> 30119e7bcd65Smrg <listitem> 30129e7bcd65Smrg <para> 30139e7bcd65SmrgSpecifies the number of entries in the argument list. 30149e7bcd65Smrg </para> 30159e7bcd65Smrg </listitem> 30169e7bcd65Smrg </varlistentry> 30179e7bcd65Smrg</variablelist> 30189e7bcd65Smrg 30199e7bcd65Smrg<para> 30209e7bcd65SmrgAn initialization procedure performs the following: 30219e7bcd65Smrg</para> 30229e7bcd65Smrg<itemizedlist spacing='compact'> 30239e7bcd65Smrg <listitem> 30249e7bcd65Smrg <para> 30259e7bcd65SmrgAllocates space for and copies any resources referenced by address 30269e7bcd65Smrgthat the client is allowed to free or modify 30279e7bcd65Smrgafter the widget has been created. 30289e7bcd65SmrgFor example, 30299e7bcd65Smrgif a widget has a field that is a 30309e7bcd65Smrg<function>String</function>, 30319e7bcd65Smrgit may choose not to 30329e7bcd65Smrgdepend on the characters at that address remaining constant 30339e7bcd65Smrgbut dynamically allocate space for the string and copy it to the new space. 30349e7bcd65SmrgWidgets that do not copy one or more resources referenced 30359e7bcd65Smrgby address should clearly so state in their user documentation. 30369e7bcd65Smrg<note><para> 30379e7bcd65SmrgIt is not necessary to allocate space for or to copy callback lists. 30389e7bcd65Smrg</para></note> 30399e7bcd65Smrg </para> 30409e7bcd65Smrg </listitem> 30419e7bcd65Smrg <listitem> 30429e7bcd65Smrg <para> 30439e7bcd65SmrgComputes values for unspecified resource fields. 30449e7bcd65SmrgFor example, if <emphasis remap='I'>width</emphasis> and <emphasis remap='I'>height</emphasis> are zero, 30459e7bcd65Smrgthe widget should compute an appropriate width and height 30469e7bcd65Smrgbased on its other resources. 30479e7bcd65Smrg<note><para> 30489e7bcd65SmrgA widget may directly assign only 30499e7bcd65Smrgits own <emphasis remap='I'>width</emphasis> and <emphasis remap='I'>height</emphasis> within the initialize, initialize_hook, 30509e7bcd65Smrgset_values, and 30519e7bcd65Smrgset_values_hook procedures; see <xref linkend='Geometry_Management' />. 30529e7bcd65Smrg</para></note> 30539e7bcd65Smrg </para> 30549e7bcd65Smrg </listitem> 30559e7bcd65Smrg <listitem> 30569e7bcd65Smrg <para> 30579e7bcd65SmrgComputes values for uninitialized nonresource fields that are derived from 30589e7bcd65Smrgresource fields. 30599e7bcd65SmrgFor example, graphics contexts (GCs) that the widget uses are derived from 30609e7bcd65Smrgresources like background, foreground, and font. 30619e7bcd65Smrg </para> 30629e7bcd65Smrg </listitem> 30639e7bcd65Smrg</itemizedlist> 30649e7bcd65Smrg<para> 30659e7bcd65SmrgAn initialization procedure also can check certain fields for 30669e7bcd65Smrginternal consistency. 30679e7bcd65SmrgFor example, it makes no sense to specify a colormap for a depth 30689e7bcd65Smrgthat does not support that colormap. 30699e7bcd65Smrg</para> 30709e7bcd65Smrg 30719e7bcd65Smrg<para> 30729e7bcd65SmrgInitialization procedures are called in superclass-to-subclass order 30739e7bcd65Smrgafter all fields specified in the resource lists have been 30749e7bcd65Smrginitialized. The initialize procedure does not need to examine 30759e7bcd65Smrg<emphasis remap='I'>args</emphasis> and <emphasis remap='I'>num_args</emphasis> 30769e7bcd65Smrgif all public resources are declared in the resource list. 30779e7bcd65SmrgMost of the initialization code for a specific widget class deals with fields 30789e7bcd65Smrgdefined in that class and not with fields defined in its superclasses. 30799e7bcd65Smrg</para> 30809e7bcd65Smrg 30819e7bcd65Smrg<para> 30829e7bcd65SmrgIf a subclass does not need an initialization procedure 30839e7bcd65Smrgbecause it does not need to perform any of the above operations, 30849e7bcd65Smrgit can specify NULL for the <emphasis remap='I'>initialize</emphasis> field in the class record. 30859e7bcd65Smrg</para> 30869e7bcd65Smrg 30879e7bcd65Smrg<para> 30889e7bcd65SmrgSometimes a subclass may want to overwrite values filled in by its 30899e7bcd65Smrgsuperclass. 30909e7bcd65SmrgIn particular, size calculations of a superclass often are 30919e7bcd65Smrgincorrect for a subclass, and in this case, 30929e7bcd65Smrgthe subclass must modify or recalculate fields declared 30939e7bcd65Smrgand computed by its superclass. 30949e7bcd65Smrg</para> 30959e7bcd65Smrg 30969e7bcd65Smrg<para> 30979e7bcd65SmrgAs an example, 30989e7bcd65Smrga subclass can visually surround its superclass display. 30999e7bcd65SmrgIn this case, the width and height calculated by the superclass initialize 31009e7bcd65Smrgprocedure are too small and need to be incremented by the size of the surround. 31019e7bcd65SmrgThe subclass needs to know if its superclass's size was calculated by the 31029e7bcd65Smrgsuperclass or was specified explicitly. 31039e7bcd65SmrgAll widgets must place themselves into whatever size is explicitly given, 31049e7bcd65Smrgbut they should compute a reasonable size if no size is requested. 31059e7bcd65Smrg</para> 31069e7bcd65Smrg 31079e7bcd65Smrg<para> 31089e7bcd65SmrgThe <emphasis remap='I'>request</emphasis> and <emphasis remap='I'>new</emphasis> arguments provide the necessary information for 31099e7bcd65Smrga subclass to determine the difference between an explicitly specified field 31109e7bcd65Smrgand a field computed by a superclass. 31119e7bcd65SmrgThe <emphasis remap='I'>request</emphasis> widget is a copy of the widget as initialized by the 31129e7bcd65Smrgarglist and resource database. 31139e7bcd65SmrgThe <emphasis remap='I'>new</emphasis> widget starts with the values in the request, 31149e7bcd65Smrgbut it has been updated by all superclass initialization procedures called 31159e7bcd65Smrgso far. 31169e7bcd65SmrgA subclass initialize procedure can compare these two to resolve 31179e7bcd65Smrgany potential conflicts. 31189e7bcd65Smrg</para> 31199e7bcd65Smrg 31209e7bcd65Smrg<para> 31219e7bcd65SmrgIn the above example, 31229e7bcd65Smrgthe subclass with the visual surround can see 31239e7bcd65Smrgif the <emphasis remap='I'>width</emphasis> and <emphasis remap='I'>height</emphasis> in the <emphasis remap='I'>request</emphasis> widget are zero. 31249e7bcd65SmrgIf so, 31259e7bcd65Smrgit adds its surround size to the <emphasis remap='I'>width</emphasis> and <emphasis remap='I'>height</emphasis> 31269e7bcd65Smrgfields in the <emphasis remap='I'>new</emphasis> widget. 31279e7bcd65SmrgIf not, it must make do with the size originally specified. 31289e7bcd65Smrg</para> 31299e7bcd65Smrg 31309e7bcd65Smrg<para> 31319e7bcd65SmrgThe <emphasis remap='I'>new</emphasis> widget will become the actual widget instance record. 31329e7bcd65SmrgTherefore, 31339e7bcd65Smrgthe initialization procedure should do all its work on the <emphasis remap='I'>new</emphasis> widget; 31349e7bcd65Smrgthe <emphasis remap='I'>request</emphasis> widget should never be modified. 31359e7bcd65SmrgIf the initialize procedure 31369e7bcd65Smrgneeds to call any routines that operate on a widget, 31379e7bcd65Smrgit should specify <emphasis remap='I'>new</emphasis> as the widget instance. 31389e7bcd65Smrg</para> 31399e7bcd65Smrg</sect2> 31409e7bcd65Smrg 31419e7bcd65Smrg<sect2 id="Constraint_Instance_Initialization_The_ConstraintClassPart_initialize_Procedure"> 31429e7bcd65Smrg<title>Constraint Instance Initialization: The ConstraintClassPart initialize Procedure</title> 31439e7bcd65Smrg<para> 31449e7bcd65SmrgThe constraint initialization procedure pointer, found in the 31459e7bcd65Smrg<function>ConstraintClassPart</function> 31469e7bcd65Smrg<emphasis remap='I'>initialize</emphasis> field of the widget class record, is of type 31479e7bcd65Smrg<xref linkend='XtInitProc' xrefstyle='select: title'/>. 31489e7bcd65SmrgThe values passed to the parent constraint initialization procedures 31499e7bcd65Smrgare the same as those passed to the child's class widget initialization 31509e7bcd65Smrgprocedures. 31519e7bcd65Smrg</para> 31529e7bcd65Smrg 31539e7bcd65Smrg<para> 31549e7bcd65SmrgThe <emphasis remap='I'>constraints</emphasis> field of the <emphasis remap='I'>request</emphasis> widget points to a copy of the 31559e7bcd65Smrgconstraints record as initialized by the arglist and resource database. 31569e7bcd65Smrg</para> 31579e7bcd65Smrg 31589e7bcd65Smrg<para> 31599e7bcd65SmrgThe constraint initialization procedure should compute any constraint fields 31609e7bcd65Smrgderived from constraint resources. 31619e7bcd65SmrgIt can make further changes to the <emphasis remap='I'>new</emphasis> widget to make the widget 31629e7bcd65Smrgand any other constraint fields 31639e7bcd65Smrgconform to the specified constraints, for example, 31649e7bcd65Smrgchanging the widget's size or position. 31659e7bcd65Smrg</para> 31669e7bcd65Smrg 31679e7bcd65Smrg<para> 31689e7bcd65SmrgIf a constraint class does not need a constraint initialization procedure, 31699e7bcd65Smrgit can specify NULL for the <emphasis remap='I'>initialize</emphasis> field of the 31709e7bcd65Smrg<function>ConstraintClassPart</function> 31719e7bcd65Smrgin the class record. 31729e7bcd65Smrg</para> 31739e7bcd65Smrg</sect2> 31749e7bcd65Smrg 31759e7bcd65Smrg<sect2 id="Nonwidget_Data_Initialization_The_initialize_hook_Procedure"> 31769e7bcd65Smrg<title>Nonwidget Data Initialization: The initialize_hook Procedure</title> 31779e7bcd65Smrg<note> 31789e7bcd65Smrg<para> 31799e7bcd65SmrgThe initialize_hook procedure is obsolete, as the same information 31809e7bcd65Smrgis now available to the initialize procedure. The procedure has been 31819e7bcd65Smrgretained for those widgets that used it in previous releases. 31829e7bcd65Smrg</para> 31839e7bcd65Smrg</note> 31849e7bcd65Smrg 31859e7bcd65Smrg<para> 31869e7bcd65SmrgThe initialize_hook procedure pointer is of type 31879e7bcd65Smrg<xref linkend='XtArgsProc' xrefstyle='select: title'/>: 31889e7bcd65Smrg</para> 31899e7bcd65Smrg 31909e7bcd65Smrg<funcsynopsis id='XtArgsProc'> 31919e7bcd65Smrg<funcprototype> 31920568f49bSmrg <funcdef>typedef void <function>(*XtArgsProc)</function></funcdef> 31939e7bcd65Smrg <paramdef>Widget <parameter>w</parameter></paramdef> 31949e7bcd65Smrg <paramdef>ArgList <parameter>args</parameter></paramdef> 31959e7bcd65Smrg <paramdef>Cardinal * <parameter>num_args</parameter></paramdef> 31969e7bcd65Smrg</funcprototype> 31979e7bcd65Smrg</funcsynopsis> 31989e7bcd65Smrg 31999e7bcd65Smrg<variablelist> 32009e7bcd65Smrg <varlistentry> 32019e7bcd65Smrg <term> 32029e7bcd65Smrg <emphasis remap='I'>w</emphasis> 32039e7bcd65Smrg </term> 32049e7bcd65Smrg <listitem> 32059e7bcd65Smrg <para> 32069e7bcd65SmrgSpecifies the widget. 32079e7bcd65Smrg </para> 32089e7bcd65Smrg </listitem> 32099e7bcd65Smrg </varlistentry> 32109e7bcd65Smrg <varlistentry> 32119e7bcd65Smrg <term> 32129e7bcd65Smrg <emphasis remap='I'>args</emphasis> 32139e7bcd65Smrg </term> 32149e7bcd65Smrg <listitem> 32159e7bcd65Smrg <para> 32169e7bcd65SmrgSpecifies the argument list passed by the client. 32179e7bcd65SmrgIf the client created the widget using a varargs form, any resources 32189e7bcd65Smrgspecified via 32199e7bcd65Smrg<function>XtVaTypedArg</function> 32209e7bcd65Smrgare converted to the widget representation and the list is transformed 32219e7bcd65Smrginto the 32229e7bcd65Smrg<function>ArgList</function> 32239e7bcd65Smrgformat. 32249e7bcd65Smrg </para> 32259e7bcd65Smrg </listitem> 32269e7bcd65Smrg </varlistentry> 32279e7bcd65Smrg <varlistentry> 32289e7bcd65Smrg <term> 32299e7bcd65Smrg <emphasis remap='I'>num_args</emphasis> 32309e7bcd65Smrg </term> 32319e7bcd65Smrg <listitem> 32329e7bcd65Smrg <para> 32339e7bcd65SmrgSpecifies the number of entries in the argument list. 32349e7bcd65Smrg </para> 32359e7bcd65Smrg </listitem> 32369e7bcd65Smrg </varlistentry> 32379e7bcd65Smrg</variablelist> 32389e7bcd65Smrg 32399e7bcd65Smrg<para> 32409e7bcd65SmrgIf this procedure is not NULL, 32419e7bcd65Smrgit is called immediately after the corresponding initialize 32429e7bcd65Smrgprocedure or in its place if the <emphasis remap='I'>initialize</emphasis> field is NULL. 32439e7bcd65Smrg</para> 32449e7bcd65Smrg 32459e7bcd65Smrg<para> 32469e7bcd65SmrgThe initialize_hook procedure allows a widget instance to initialize 32479e7bcd65Smrgnonresource data using information from the specified argument list 32489e7bcd65Smrgas if it were a resource. 32499e7bcd65Smrg</para> 32509e7bcd65Smrg</sect2> 32519e7bcd65Smrg</sect1> 32529e7bcd65Smrg 32539e7bcd65Smrg<sect1 id="Realizing_Widgets"> 32549e7bcd65Smrg<title>Realizing Widgets</title> 32559e7bcd65Smrg<para> 32569e7bcd65SmrgTo realize a widget instance, use 32579e7bcd65Smrg<xref linkend='XtRealizeWidget' xrefstyle='select: title'/>. 32589e7bcd65Smrg</para> 32599e7bcd65Smrg 32609e7bcd65Smrg<funcsynopsis id='XtRealizeWidget'> 32619e7bcd65Smrg<funcprototype> 32629e7bcd65Smrg <funcdef>void <function>XtRealizeWidget</function></funcdef> 32639e7bcd65Smrg <paramdef>Widget <parameter>w</parameter></paramdef> 32649e7bcd65Smrg</funcprototype> 32659e7bcd65Smrg</funcsynopsis> 32669e7bcd65Smrg 32679e7bcd65Smrg<variablelist> 32689e7bcd65Smrg <varlistentry> 32699e7bcd65Smrg <term> 32709e7bcd65Smrg <emphasis remap='I'>w</emphasis> 32719e7bcd65Smrg </term> 32729e7bcd65Smrg <listitem> 32739e7bcd65Smrg <para> 32749e7bcd65SmrgSpecifies the widget. Must be of class Core or any subclass thereof. 32759e7bcd65Smrg </para> 32769e7bcd65Smrg </listitem> 32779e7bcd65Smrg </varlistentry> 32789e7bcd65Smrg</variablelist> 32799e7bcd65Smrg 32809e7bcd65Smrg<para> 32819e7bcd65SmrgIf the widget is already realized, 32829e7bcd65Smrg<xref linkend='XtRealizeWidget' xrefstyle='select: title'/> 32839e7bcd65Smrgsimply returns. 32849e7bcd65SmrgOtherwise it performs the following: 32859e7bcd65Smrg</para> 32869e7bcd65Smrg<itemizedlist spacing='compact'> 32879e7bcd65Smrg <listitem> 32889e7bcd65Smrg <para> 32899e7bcd65SmrgBinds all action names in the widget's 32909e7bcd65Smrgtranslation table to procedures (see <xref linkend='Action_Names_to_Procedure_Translations' />). 32919e7bcd65Smrg </para> 32929e7bcd65Smrg </listitem> 32939e7bcd65Smrg <listitem> 32949e7bcd65Smrg <para> 32959e7bcd65SmrgMakes a postorder traversal of the widget tree rooted 32969e7bcd65Smrgat the specified widget and calls each non-NULL change_managed procedure 32979e7bcd65Smrgof all composite widgets that have one or more managed children. 32989e7bcd65Smrg </para> 32999e7bcd65Smrg </listitem> 33009e7bcd65Smrg <listitem> 33019e7bcd65Smrg <para> 33029e7bcd65SmrgConstructs an 33039e7bcd65Smrg<function>XSetWindowAttributes</function> 33049e7bcd65Smrgstructure filled in with information derived from the 33059e7bcd65SmrgCore 33069e7bcd65Smrgwidget fields and calls the realize procedure for the widget, 33079e7bcd65Smrgwhich adds any widget-specific attributes and creates the X window. 33089e7bcd65Smrg </para> 33099e7bcd65Smrg </listitem> 33109e7bcd65Smrg <listitem> 33119e7bcd65Smrg <para> 33129e7bcd65SmrgIf the widget is 33139e7bcd65Smrgnot a subclass of 33149e7bcd65Smrg<function>compositeWidgetClass</function>, 33159e7bcd65Smrg<xref linkend='XtRealizeWidget' xrefstyle='select: title'/> 33169e7bcd65Smrgreturns; otherwise it continues and performs the following: 33179e7bcd65Smrg </para> 33189e7bcd65Smrg <itemizedlist spacing='compact'> 33199e7bcd65Smrg <listitem> 33209e7bcd65Smrg <para> 33219e7bcd65SmrgDescends recursively to each of the widget's 33229e7bcd65Smrgmanaged children and calls the realize procedures. 33239e7bcd65SmrgPrimitive widgets that instantiate children are responsible for realizing 33249e7bcd65Smrgthose children themselves. 33259e7bcd65Smrg </para> 33269e7bcd65Smrg </listitem> 33279e7bcd65Smrg <listitem> 33289e7bcd65Smrg <para> 33299e7bcd65SmrgMaps all of the managed children windows that have <emphasis remap='I'>mapped_when_managed</emphasis> 33309e7bcd65Smrg<function>True</function>. 33319e7bcd65SmrgIf a widget is managed but <emphasis remap='I'>mapped_when_managed</emphasis> is 33329e7bcd65Smrg<function>False</function>, 33339e7bcd65Smrgthe widget is allocated visual space but is not displayed. 33349e7bcd65Smrg </para> 33359e7bcd65Smrg </listitem> 33369e7bcd65Smrg </itemizedlist> 33379e7bcd65Smrg </listitem> 33389e7bcd65Smrg</itemizedlist> 33399e7bcd65Smrg<para> 33409e7bcd65SmrgIf the widget is a top-level shell widget (that is, it has no parent), and 33419e7bcd65Smrg<emphasis remap='I'>mapped_when_managed</emphasis> is 33429e7bcd65Smrg<function>True</function>, 33439e7bcd65Smrg<xref linkend='XtRealizeWidget' xrefstyle='select: title'/> 33449e7bcd65Smrgmaps the widget window. 33459e7bcd65Smrg</para> 33469e7bcd65Smrg 33479e7bcd65Smrg<para> 33489e7bcd65Smrg<xref linkend='XtCreateWidget' xrefstyle='select: title'/>, 33499e7bcd65Smrg<xref linkend='XtVaCreateWidget' xrefstyle='select: title'/>, 33509e7bcd65Smrg<xref linkend='XtRealizeWidget' xrefstyle='select: title'/>, 33519e7bcd65Smrg<xref linkend='XtManageChildren' xrefstyle='select: title'/>, 33520568f49bSmrg<function>XtUnmanageChildren</function>, 33539e7bcd65Smrg<xref linkend='XtUnrealizeWidget' xrefstyle='select: title'/>, 33549e7bcd65Smrg<xref linkend='XtSetMappedWhenManaged' xrefstyle='select: title'/>, 33559e7bcd65Smrgand 33560568f49bSmrg<function>XtDestroyWidget</function> 33579e7bcd65Smrgmaintain the following invariants: 33589e7bcd65Smrg</para> 33599e7bcd65Smrg<itemizedlist spacing='compact'> 33609e7bcd65Smrg <listitem> 33619e7bcd65Smrg <para> 33629e7bcd65SmrgIf a composite widget is realized, then all its managed children are realized. 33639e7bcd65Smrg </para> 33649e7bcd65Smrg </listitem> 33659e7bcd65Smrg <listitem> 33669e7bcd65Smrg <para> 33679e7bcd65SmrgIf a composite widget is realized, then all its managed children that have 33689e7bcd65Smrg<emphasis remap='I'>mapped_when_managed</emphasis> 33699e7bcd65Smrg<function>True</function> 33709e7bcd65Smrgare mapped. 33719e7bcd65Smrg </para> 33729e7bcd65Smrg </listitem> 33739e7bcd65Smrg</itemizedlist> 33749e7bcd65Smrg<para> 33759e7bcd65SmrgAll Intrinsics functions and all widget routines should accept 33769e7bcd65Smrgeither realized or unrealized widgets. 33779e7bcd65SmrgWhen calling the realize or change_managed 33789e7bcd65Smrgprocedures for children of a composite 33799e7bcd65Smrgwidget, 33809e7bcd65Smrg<xref linkend='XtRealizeWidget' xrefstyle='select: title'/> 33819e7bcd65Smrgcalls the procedures in reverse order of 33829e7bcd65Smrgappearance in the 33839e7bcd65Smrg<function>CompositePart</function> 33849e7bcd65Smrg<emphasis remap='I'>children</emphasis> list. By default, this 33859e7bcd65Smrgordering of the realize procedures will 33869e7bcd65Smrgresult in the stacking order of any newly created subwindows being 33879e7bcd65Smrgtop-to-bottom in the order of appearance on the list, and the most 33889e7bcd65Smrgrecently created child will be at the bottom. 33899e7bcd65Smrg</para> 33909e7bcd65Smrg 33919e7bcd65Smrg<para> 33929e7bcd65SmrgTo check whether or not a widget has been realized, use 33939e7bcd65Smrg<xref linkend='XtIsRealized' xrefstyle='select: title'/>. 33949e7bcd65Smrg</para> 33959e7bcd65Smrg 33969e7bcd65Smrg<funcsynopsis id='XtIsRealized'> 33979e7bcd65Smrg<funcprototype> 33989e7bcd65Smrg <funcdef>Boolean <function>XtIsRealized</function></funcdef> 33999e7bcd65Smrg <paramdef>Widget <parameter>w</parameter></paramdef> 34009e7bcd65Smrg</funcprototype> 34019e7bcd65Smrg</funcsynopsis> 34029e7bcd65Smrg 34039e7bcd65Smrg<variablelist> 34049e7bcd65Smrg <varlistentry> 34059e7bcd65Smrg <term> 34069e7bcd65Smrg <emphasis remap='I'>w</emphasis> 34079e7bcd65Smrg </term> 34089e7bcd65Smrg <listitem> 34099e7bcd65Smrg <para> 34109e7bcd65SmrgSpecifies the widget. Must be of class Object or any subclass thereof. 34119e7bcd65Smrg </para> 34129e7bcd65Smrg </listitem> 34139e7bcd65Smrg </varlistentry> 34149e7bcd65Smrg</variablelist> 34159e7bcd65Smrg 34169e7bcd65Smrg<para> 34179e7bcd65SmrgThe 34189e7bcd65Smrg<xref linkend='XtIsRealized' xrefstyle='select: title'/> 34199e7bcd65Smrgfunction returns 34209e7bcd65Smrg<function>True</function> 34219e7bcd65Smrgif the widget has been realized, 34229e7bcd65Smrgthat is, if the widget has a nonzero window ID. 34239e7bcd65SmrgIf the specified object is not a widget, the state of the nearest 34249e7bcd65Smrgwidget ancestor is returned. 34259e7bcd65Smrg</para> 34269e7bcd65Smrg 34279e7bcd65Smrg<para> 34289e7bcd65SmrgSome widget procedures (for example, set_values) might wish to 34299e7bcd65Smrgoperate differently 34309e7bcd65Smrgafter the widget has been realized. 34319e7bcd65Smrg</para> 34329e7bcd65Smrg<sect2 id="Widget_Instance_Window_Creation_The_realize_Procedure"> 34339e7bcd65Smrg<title>Widget Instance Window Creation: The realize Procedure</title> 34349e7bcd65Smrg<para> 34359e7bcd65SmrgThe realize procedure pointer in a widget class is of type 34369e7bcd65Smrg<xref linkend='XtRealizeProc' xrefstyle='select: title'/>. 34379e7bcd65Smrg</para> 34389e7bcd65Smrg 34399e7bcd65Smrg<funcsynopsis id='XtRealizeProc'> 34409e7bcd65Smrg<funcprototype> 34419e7bcd65Smrg <funcdef>typedef void <function>(*XtRealizeProc)</function></funcdef> 34429e7bcd65Smrg <paramdef>Widget <parameter>w</parameter></paramdef> 34439e7bcd65Smrg <paramdef>XtValueMask <parameter>value_mask</parameter></paramdef> 34449e7bcd65Smrg <paramdef>XSetWindowAttributes <parameter>attributes</parameter></paramdef> 34459e7bcd65Smrg</funcprototype> 34469e7bcd65Smrg</funcsynopsis> 34479e7bcd65Smrg 34489e7bcd65Smrg<variablelist> 34499e7bcd65Smrg <varlistentry> 34509e7bcd65Smrg <term> 34519e7bcd65Smrg <emphasis remap='I'>w</emphasis> 34529e7bcd65Smrg </term> 34539e7bcd65Smrg <listitem> 34549e7bcd65Smrg <para> 34559e7bcd65SmrgSpecifies the widget. 34569e7bcd65Smrg </para> 34579e7bcd65Smrg </listitem> 34589e7bcd65Smrg </varlistentry> 34599e7bcd65Smrg <varlistentry> 34609e7bcd65Smrg <term> 34619e7bcd65Smrg <emphasis remap='I'>value_mask</emphasis> 34629e7bcd65Smrg </term> 34639e7bcd65Smrg <listitem> 34649e7bcd65Smrg <para> 34659e7bcd65SmrgSpecifies which fields in the <emphasis remap='I'>attributes</emphasis> structure are used. 34669e7bcd65Smrg </para> 34679e7bcd65Smrg </listitem> 34689e7bcd65Smrg </varlistentry> 34699e7bcd65Smrg <varlistentry> 34709e7bcd65Smrg <term> 34719e7bcd65Smrg <emphasis remap='I'>attributes</emphasis> 34729e7bcd65Smrg </term> 34739e7bcd65Smrg <listitem> 34749e7bcd65Smrg <para> 34759e7bcd65SmrgSpecifies the window attributes to use in the 34769e7bcd65Smrg<function>XCreateWindow</function> 34779e7bcd65Smrgcall. 34789e7bcd65Smrg </para> 34799e7bcd65Smrg </listitem> 34809e7bcd65Smrg </varlistentry> 34819e7bcd65Smrg</variablelist> 34829e7bcd65Smrg 34839e7bcd65Smrg<para> 34849e7bcd65SmrgThe realize procedure must create the widget's window. 34859e7bcd65Smrg</para> 34869e7bcd65Smrg 34879e7bcd65Smrg<para> 34889e7bcd65SmrgBefore calling the class realize procedure, the generic 34899e7bcd65Smrg<xref linkend='XtRealizeWidget' xrefstyle='select: title'/> 34909e7bcd65Smrgfunction fills in a mask and a corresponding 34919e7bcd65Smrg<function>XSetWindowAttributes</function> 34929e7bcd65Smrgstructure. 34939e7bcd65SmrgIt sets the following fields in <emphasis remap='I'>attributes</emphasis> and 34949e7bcd65Smrgcorresponding bits in <emphasis remap='I'>value_mask</emphasis> 34959e7bcd65Smrgbased on information in the widget 34969e7bcd65Smrgcore 34979e7bcd65Smrgstructure: 34989e7bcd65Smrg</para> 34999e7bcd65Smrg<itemizedlist spacing='compact'> 35009e7bcd65Smrg <listitem> 35019e7bcd65Smrg <para> 35029e7bcd65SmrgThe <emphasis remap='I'>background_pixmap</emphasis> (or <emphasis remap='I'>background_pixel</emphasis> if <emphasis remap='I'>background_pixmap</emphasis> is 35039e7bcd65Smrg<function>XtUnspecifiedPixmap</function>) 35049e7bcd65Smrgis filled in from the corresponding field. 35059e7bcd65Smrg </para> 35069e7bcd65Smrg </listitem> 35079e7bcd65Smrg <listitem> 35089e7bcd65Smrg <para> 35099e7bcd65SmrgThe <emphasis remap='I'>border_pixmap</emphasis> (or <emphasis remap='I'>border_pixel</emphasis> if <emphasis remap='I'>border_pixmap</emphasis> is 35109e7bcd65Smrg<function>XtUnspecifiedPixmap</function>) 35119e7bcd65Smrgis filled in from the corresponding field. 35129e7bcd65Smrg </para> 35139e7bcd65Smrg </listitem> 35149e7bcd65Smrg <listitem> 35159e7bcd65Smrg <para> 35169e7bcd65SmrgThe <emphasis remap='I'>colormap</emphasis> is filled in from the corresponding field. 35179e7bcd65Smrg </para> 35189e7bcd65Smrg </listitem> 35199e7bcd65Smrg <listitem> 35209e7bcd65Smrg <para> 35219e7bcd65SmrgThe <emphasis remap='I'>event_mask</emphasis> is filled in based on the event handlers registered, 35229e7bcd65Smrgthe event translations specified, whether the <emphasis remap='I'>expose</emphasis> field is non-NULL, 35239e7bcd65Smrgand whether <emphasis remap='I'>visible_interest</emphasis> is 35249e7bcd65Smrg<function>True</function>. 35259e7bcd65Smrg </para> 35269e7bcd65Smrg </listitem> 35279e7bcd65Smrg <listitem> 35289e7bcd65Smrg <para> 35299e7bcd65SmrgThe <emphasis remap='I'>bit_gravity</emphasis> is set to 35309e7bcd65Smrg<function>NorthWestGravity</function> 35319e7bcd65Smrgif the <emphasis remap='I'>expose</emphasis> field is NULL. 35329e7bcd65Smrg </para> 35339e7bcd65Smrg </listitem> 35349e7bcd65Smrg</itemizedlist> 35359e7bcd65Smrg<para> 35369e7bcd65SmrgThese or any other fields in attributes and the corresponding bits in 35379e7bcd65Smrg<emphasis remap='I'>value_mask</emphasis> can be set by the realize procedure. 35389e7bcd65Smrg</para> 35399e7bcd65Smrg 35409e7bcd65Smrg<para> 35419e7bcd65SmrgNote that because realize is not a chained operation, 35429e7bcd65Smrgthe widget class realize procedure must update the 35439e7bcd65Smrg<function>XSetWindowAttributes</function> 35449e7bcd65Smrgstructure with all the appropriate fields from 35459e7bcd65Smrgnon-Core 35469e7bcd65Smrgsuperclasses. 35479e7bcd65Smrg</para> 35489e7bcd65Smrg 35499e7bcd65Smrg<para> 35509e7bcd65SmrgA widget class can inherit its realize procedure from its superclass 35519e7bcd65Smrgduring class initialization. 35529e7bcd65SmrgThe realize procedure defined for 35539e7bcd65Smrg<function>coreWidgetClass</function> 35549e7bcd65Smrgcalls 35559e7bcd65Smrg<xref linkend='XtCreateWindow' xrefstyle='select: title'/> 35569e7bcd65Smrgwith the passed <emphasis remap='I'>value_mask</emphasis> and <emphasis remap='I'>attributes</emphasis> 35579e7bcd65Smrgand with <emphasis remap='I'>window_class</emphasis> and <emphasis remap='I'>visual</emphasis> set to 35589e7bcd65Smrg<function>CopyFromParent</function>. 35599e7bcd65SmrgBoth 35609e7bcd65Smrg<function>compositeWidgetClass</function> 35619e7bcd65Smrgand 35629e7bcd65Smrg<function>constraintWidgetClass</function> 35639e7bcd65Smrginherit this realize procedure, and most new widget subclasses 35649e7bcd65Smrgcan do the same (see <xref linkend='Inheritance_of_Superclass_Operations' />). 35659e7bcd65Smrg</para> 35669e7bcd65Smrg 35679e7bcd65Smrg<para> 35689e7bcd65SmrgThe most common noninherited realize procedures set <emphasis remap='I'>bit_gravity</emphasis> in the mask 35699e7bcd65Smrgand attributes to the appropriate value and then create the window. 35709e7bcd65SmrgFor example, depending on its justification, Label might set <emphasis remap='I'>bit_gravity</emphasis> to 35719e7bcd65Smrg<function>WestGravity</function>, 35729e7bcd65Smrg<function>CenterGravity</function>, 35739e7bcd65Smrgor 35749e7bcd65Smrg<function>EastGravity</function>. 35759e7bcd65SmrgConsequently, shrinking it would just move the bits appropriately, 35769e7bcd65Smrgand no 35779e7bcd65Smrgexposure 35789e7bcd65Smrgevent is needed for repainting. 35799e7bcd65Smrg</para> 35809e7bcd65Smrg 35819e7bcd65Smrg<para> 35829e7bcd65SmrgIf a composite widget's children should be realized in an order other 35839e7bcd65Smrgthan that specified 35849e7bcd65Smrg(to control the stacking order, for example), 35859e7bcd65Smrgit should call 35869e7bcd65Smrg<xref linkend='XtRealizeWidget' xrefstyle='select: title'/> 35879e7bcd65Smrgon its children itself in the appropriate order from within its own 35889e7bcd65Smrgrealize procedure. 35899e7bcd65Smrg</para> 35909e7bcd65Smrg 35919e7bcd65Smrg<para> 35929e7bcd65SmrgWidgets that have children and whose class is not a subclass of 35939e7bcd65Smrg<function>compositeWidgetClass</function> 35949e7bcd65Smrgare responsible for calling 35959e7bcd65Smrg<xref linkend='XtRealizeWidget' xrefstyle='select: title'/> 35969e7bcd65Smrgon their children, usually from within the realize procedure. 35979e7bcd65Smrg</para> 35989e7bcd65Smrg 35999e7bcd65Smrg<para> 36009e7bcd65SmrgRealize procedures cannot manage or unmanage their descendants. 36019e7bcd65Smrg</para> 36029e7bcd65Smrg</sect2> 36039e7bcd65Smrg 36049e7bcd65Smrg<sect2 id="Window_Creation_Convenience_Routine"> 36059e7bcd65Smrg<title>Window Creation Convenience Routine</title> 36069e7bcd65Smrg<para> 36079e7bcd65SmrgRather than call the Xlib 36089e7bcd65Smrg<function>XCreateWindow</function> 36099e7bcd65Smrgfunction explicitly, a realize procedure should normally call the Intrinsics analog 36109e7bcd65Smrg<xref linkend='XtCreateWindow' xrefstyle='select: title'/>, 36119e7bcd65Smrgwhich simplifies the creation of windows for widgets. 36129e7bcd65Smrg</para> 36139e7bcd65Smrg 36149e7bcd65Smrg<funcsynopsis id='XtCreateWindow'> 36159e7bcd65Smrg<funcprototype> 36169e7bcd65Smrg <funcdef>void <function>XtCreateWindow</function></funcdef> 36179e7bcd65Smrg <paramdef>Widget <parameter>w</parameter></paramdef> 36189e7bcd65Smrg <paramdef>unsigned int <parameter>window_class</parameter></paramdef> 36199e7bcd65Smrg <paramdef>Visual * <parameter>visual</parameter></paramdef> 36209e7bcd65Smrg <paramdef>XtValueMask <parameter>value_mask</parameter></paramdef> 36210568f49bSmrg <paramdef>XSetWindowAttributes * <parameter>attributes</parameter></paramdef> 36229e7bcd65Smrg</funcprototype> 36239e7bcd65Smrg</funcsynopsis> 36249e7bcd65Smrg 36259e7bcd65Smrg<variablelist> 36269e7bcd65Smrg <varlistentry> 36279e7bcd65Smrg <term> 36289e7bcd65Smrg <emphasis remap='I'>w</emphasis> 36299e7bcd65Smrg </term> 36309e7bcd65Smrg <listitem> 36319e7bcd65Smrg <para> 36329e7bcd65SmrgSpecifies the widget that defines the additional window attributed. Must be of class Core or any subclass thereof. 36339e7bcd65Smrg </para> 36349e7bcd65Smrg </listitem> 36359e7bcd65Smrg </varlistentry> 36369e7bcd65Smrg <varlistentry> 36379e7bcd65Smrg <term> 36389e7bcd65Smrg <emphasis remap='I'>window_class</emphasis> 36399e7bcd65Smrg </term> 36409e7bcd65Smrg <listitem> 36419e7bcd65Smrg <para> 36429e7bcd65SmrgSpecifies the Xlib window class (for example, 36439e7bcd65Smrg<function>InputOutput</function>, 36449e7bcd65Smrg<function>InputOnly</function>, 36459e7bcd65Smrgor 36469e7bcd65Smrg<function>CopyFromParent ).</function> 36479e7bcd65Smrg </para> 36489e7bcd65Smrg </listitem> 36499e7bcd65Smrg </varlistentry> 36509e7bcd65Smrg <varlistentry> 36519e7bcd65Smrg <term> 36529e7bcd65Smrg <emphasis remap='I'>visual</emphasis> 36539e7bcd65Smrg </term> 36549e7bcd65Smrg <listitem> 36559e7bcd65Smrg <para> 36569e7bcd65SmrgSpecifies the visual type (usually 36579e7bcd65Smrg<function>CopyFromParent ).</function> 36589e7bcd65Smrg </para> 36599e7bcd65Smrg </listitem> 36609e7bcd65Smrg </varlistentry> 36619e7bcd65Smrg <varlistentry> 36629e7bcd65Smrg <term> 36639e7bcd65Smrg <emphasis remap='I'>value_mask</emphasis> 36649e7bcd65Smrg </term> 36659e7bcd65Smrg <listitem> 36669e7bcd65Smrg <para> 36679e7bcd65SmrgSpecifies which fields in the <emphasis remap='I'>attributes</emphasis> structure are used. 36689e7bcd65Smrg </para> 36699e7bcd65Smrg </listitem> 36709e7bcd65Smrg </varlistentry> 36719e7bcd65Smrg <varlistentry> 36729e7bcd65Smrg <term> 36739e7bcd65Smrg <emphasis remap='I'>attributes</emphasis> 36749e7bcd65Smrg </term> 36759e7bcd65Smrg <listitem> 36769e7bcd65Smrg <para> 36779e7bcd65SmrgSpecifies the window attributes to use in the 36789e7bcd65Smrg<function>XCreateWindow</function> 36799e7bcd65Smrgcall. 36809e7bcd65Smrg </para> 36819e7bcd65Smrg </listitem> 36829e7bcd65Smrg </varlistentry> 36839e7bcd65Smrg</variablelist> 36849e7bcd65Smrg 36859e7bcd65Smrg<para> 36869e7bcd65SmrgThe 36879e7bcd65Smrg<xref linkend='XtCreateWindow' xrefstyle='select: title'/> 36889e7bcd65Smrgfunction calls the Xlib 36899e7bcd65Smrg<function>XCreateWindow</function> 36909e7bcd65Smrgfunction with values from the widget structure and the passed parameters. 36919e7bcd65SmrgThen, it assigns the created window to the widget's <emphasis remap='I'>window</emphasis> field. 36929e7bcd65Smrg</para> 36939e7bcd65Smrg 36949e7bcd65Smrg<para> 36959e7bcd65Smrg<xref linkend='XtCreateWindow' xrefstyle='select: title'/> 36969e7bcd65Smrgevaluates the following fields of the widget core 36979e7bcd65Smrgstructure: <emphasis remap='I'>depth</emphasis>, <emphasis remap='I'>screen</emphasis>, <emphasis remap='I'>parent->core.window</emphasis>, <emphasis remap='I'>x</emphasis>, 36989e7bcd65Smrg<emphasis remap='I'>y</emphasis>, <emphasis remap='I'>width</emphasis>, <emphasis remap='I'>height</emphasis>, and 36999e7bcd65Smrg<emphasis remap='I'>border_width</emphasis>. 37009e7bcd65Smrg</para> 37019e7bcd65Smrg</sect2> 37029e7bcd65Smrg</sect1> 37039e7bcd65Smrg 37049e7bcd65Smrg<sect1 id="Obtaining_Window_Information_from_a_Widget"> 37059e7bcd65Smrg<title>Obtaining Window Information from a Widget</title> 37069e7bcd65Smrg<para> 37079e7bcd65SmrgThe 37089e7bcd65SmrgCore 37099e7bcd65Smrgwidget class definition contains the screen and window ids. 37109e7bcd65SmrgThe <emphasis remap='I'>window</emphasis> field may be NULL for a while 37119e7bcd65Smrg(see <xref linkend='Creating_Widgets' /> and <xref linkend='Realizing_Widgets' />). 37129e7bcd65Smrg</para> 37139e7bcd65Smrg 37149e7bcd65Smrg<para> 37159e7bcd65SmrgThe display pointer, the parent widget, screen pointer, 37169e7bcd65Smrgand window of a widget are available to the widget writer by means of macros 37179e7bcd65Smrgand to the application writer by means of functions. 37189e7bcd65Smrg</para> 37199e7bcd65Smrg 37209e7bcd65Smrg<funcsynopsis> 37219e7bcd65Smrg<funcprototype> 37220568f49bSmrg <funcdef>Display * <function>XtDisplay</function></funcdef> 37239e7bcd65Smrg <paramdef>Widget <parameter>w</parameter></paramdef> 37249e7bcd65Smrg</funcprototype> 37259e7bcd65Smrg</funcsynopsis> 37269e7bcd65Smrg 37279e7bcd65Smrg<variablelist> 37289e7bcd65Smrg <varlistentry> 37299e7bcd65Smrg <term> 37309e7bcd65Smrg <emphasis remap='I'>w</emphasis> 37319e7bcd65Smrg </term> 37329e7bcd65Smrg <listitem> 37339e7bcd65Smrg <para> 37349e7bcd65SmrgSpecifies the widget. Must be of class Core or any subclass thereof. 37359e7bcd65Smrg </para> 37369e7bcd65Smrg </listitem> 37379e7bcd65Smrg </varlistentry> 37389e7bcd65Smrg</variablelist> 37399e7bcd65Smrg 37409e7bcd65Smrg<para> 37419e7bcd65Smrg<function>XtDisplay</function> 37429e7bcd65Smrgreturns the display pointer for the specified widget. 37439e7bcd65Smrg</para> 37449e7bcd65Smrg 37459e7bcd65Smrg<funcsynopsis> 37469e7bcd65Smrg<funcprototype> 37479e7bcd65Smrg <funcdef>Widget <function>XtParent</function></funcdef> 37489e7bcd65Smrg <paramdef>Widget <parameter>w</parameter></paramdef> 37499e7bcd65Smrg</funcprototype> 37509e7bcd65Smrg</funcsynopsis> 37519e7bcd65Smrg 37529e7bcd65Smrg<variablelist> 37539e7bcd65Smrg <varlistentry> 37549e7bcd65Smrg <term> 37559e7bcd65Smrg <emphasis remap='I'>w</emphasis> 37569e7bcd65Smrg </term> 37579e7bcd65Smrg <listitem> 37589e7bcd65Smrg <para> 37599e7bcd65SmrgSpecifies the widget. Must be of class Object or any subclass thereof. 37609e7bcd65Smrg </para> 37619e7bcd65Smrg </listitem> 37629e7bcd65Smrg </varlistentry> 37639e7bcd65Smrg</variablelist> 37649e7bcd65Smrg 37659e7bcd65Smrg<para> 37669e7bcd65Smrg<function>XtParent</function> 37679e7bcd65Smrgreturns the parent object for the specified widget. The returned object 37689e7bcd65Smrgwill be of class Object or a subclass. 37699e7bcd65Smrg</para> 37709e7bcd65Smrg 37719e7bcd65Smrg<funcsynopsis id='XtScreen'> 37729e7bcd65Smrg<funcprototype> 37730568f49bSmrg <funcdef>Screen *<function>XtScreen</function></funcdef> 37749e7bcd65Smrg <paramdef>Widget <parameter>w</parameter></paramdef> 37759e7bcd65Smrg</funcprototype> 37769e7bcd65Smrg</funcsynopsis> 37779e7bcd65Smrg 37789e7bcd65Smrg<variablelist> 37799e7bcd65Smrg <varlistentry> 37809e7bcd65Smrg <term> 37819e7bcd65Smrg <emphasis remap='I'>w</emphasis> 37829e7bcd65Smrg </term> 37839e7bcd65Smrg <listitem> 37849e7bcd65Smrg <para> 37859e7bcd65SmrgSpecifies the widget. Must be of class Core or any subclass thereof. 37869e7bcd65Smrg </para> 37879e7bcd65Smrg </listitem> 37889e7bcd65Smrg </varlistentry> 37899e7bcd65Smrg</variablelist> 37909e7bcd65Smrg 37919e7bcd65Smrg<para> 37929e7bcd65Smrg<xref linkend='XtScreen' xrefstyle='select: title'/> 37939e7bcd65Smrgreturns the screen pointer for the specified widget. 37949e7bcd65Smrg</para> 37959e7bcd65Smrg 37969e7bcd65Smrg<funcsynopsis id='XtWindow'> 37979e7bcd65Smrg<funcprototype> 37989e7bcd65Smrg <funcdef>Window <function>XtWindow</function></funcdef> 37999e7bcd65Smrg <paramdef>Widget <parameter>w</parameter></paramdef> 38009e7bcd65Smrg</funcprototype> 38019e7bcd65Smrg</funcsynopsis> 38029e7bcd65Smrg 38039e7bcd65Smrg<variablelist> 38049e7bcd65Smrg <varlistentry> 38059e7bcd65Smrg <term> 38069e7bcd65Smrg <emphasis remap='I'>w</emphasis> 38079e7bcd65Smrg </term> 38089e7bcd65Smrg <listitem> 38099e7bcd65Smrg <para> 38109e7bcd65SmrgSpecifies the widget. Must be of class Core or any subclass thereof. 38119e7bcd65Smrg </para> 38129e7bcd65Smrg </listitem> 38139e7bcd65Smrg </varlistentry> 38149e7bcd65Smrg</variablelist> 38159e7bcd65Smrg 38169e7bcd65Smrg<para> 38179e7bcd65Smrg<xref linkend='XtWindow' xrefstyle='select: title'/> 38189e7bcd65Smrgreturns the window of the specified widget. 38199e7bcd65Smrg</para> 38209e7bcd65Smrg 38219e7bcd65Smrg<para> 38229e7bcd65SmrgThe display pointer, screen pointer, and window of a widget or 38239e7bcd65Smrgof the closest widget ancestor of a nonwidget object are available 38249e7bcd65Smrgby means of 38259e7bcd65Smrg<xref linkend='XtDisplayOfObject' xrefstyle='select: title'/>, 38269e7bcd65Smrg<xref linkend='XtScreenOfObject' xrefstyle='select: title'/>, 38279e7bcd65Smrgand 38289e7bcd65Smrg<xref linkend='XtWindowOfObject' xrefstyle='select: title'/>. 38299e7bcd65Smrg</para> 38309e7bcd65Smrg 38319e7bcd65Smrg<funcsynopsis id='XtDisplayOfObject'> 38329e7bcd65Smrg<funcprototype> 38330568f49bSmrg <funcdef>Display *<function>XtDisplayOfObject</function></funcdef> 38349e7bcd65Smrg <paramdef>Widget <parameter>w</parameter></paramdef> 38359e7bcd65Smrg</funcprototype> 38369e7bcd65Smrg</funcsynopsis> 38379e7bcd65Smrg 38389e7bcd65Smrg<variablelist> 38399e7bcd65Smrg <varlistentry> 38409e7bcd65Smrg <term> 38419e7bcd65Smrg <emphasis remap='I'>object</emphasis> 38429e7bcd65Smrg </term> 38439e7bcd65Smrg <listitem> 38449e7bcd65Smrg <para> 38459e7bcd65SmrgSpecifies the object. Must be of class Object or any subclass thereof. 38469e7bcd65Smrg </para> 38479e7bcd65Smrg </listitem> 38489e7bcd65Smrg </varlistentry> 38499e7bcd65Smrg</variablelist> 38509e7bcd65Smrg 38519e7bcd65Smrg<para> 38529e7bcd65Smrg<xref linkend='XtDisplayOfObject' xrefstyle='select: title'/> 38539e7bcd65Smrgis identical in function to 38549e7bcd65Smrg<function>XtDisplay</function> 38559e7bcd65Smrgif the object is a widget; otherwise 38569e7bcd65Smrg<xref linkend='XtDisplayOfObject' xrefstyle='select: title'/> 38579e7bcd65Smrgreturns the display 38589e7bcd65Smrgpointer for the nearest ancestor of <emphasis remap='I'>object</emphasis> that is of class 38599e7bcd65SmrgWidget or a subclass thereof. 38609e7bcd65Smrg</para> 38619e7bcd65Smrg 38629e7bcd65Smrg<funcsynopsis id='XtScreenOfObject'> 38639e7bcd65Smrg<funcprototype> 38640568f49bSmrg <funcdef>Screen *<function>XtScreenOfObject</function></funcdef> 38659e7bcd65Smrg <paramdef>Widget <parameter>object</parameter></paramdef> 38669e7bcd65Smrg</funcprototype> 38679e7bcd65Smrg</funcsynopsis> 38689e7bcd65Smrg 38699e7bcd65Smrg 38709e7bcd65Smrg<variablelist> 38719e7bcd65Smrg <varlistentry> 38729e7bcd65Smrg <term> 38739e7bcd65Smrg <emphasis remap='I'>object</emphasis> 38749e7bcd65Smrg </term> 38759e7bcd65Smrg <listitem> 38769e7bcd65Smrg <para> 38779e7bcd65SmrgSpecifies the object. Must be of class Object or any subclass thereof. 38789e7bcd65Smrg </para> 38799e7bcd65Smrg </listitem> 38809e7bcd65Smrg </varlistentry> 38819e7bcd65Smrg</variablelist> 38829e7bcd65Smrg 38839e7bcd65Smrg<para> 38849e7bcd65Smrg<xref linkend='XtScreenOfObject' xrefstyle='select: title'/> 38859e7bcd65Smrgis identical in function to 38869e7bcd65Smrg<xref linkend='XtScreen' xrefstyle='select: title'/> 38879e7bcd65Smrgif the object is a widget; otherwise 38889e7bcd65Smrg<xref linkend='XtScreenOfObject' xrefstyle='select: title'/> 38899e7bcd65Smrgreturns the screen pointer 38909e7bcd65Smrgfor the nearest ancestor of <emphasis remap='I'>object</emphasis> that is of class 38919e7bcd65SmrgWidget or a subclass thereof. 38929e7bcd65Smrg</para> 38939e7bcd65Smrg 38949e7bcd65Smrg<funcsynopsis id='XtWindowOfObject'> 38959e7bcd65Smrg<funcprototype> 38969e7bcd65Smrg <funcdef>Window <function>XtWindowOfObject</function></funcdef> 38979e7bcd65Smrg <paramdef>Widget <parameter>object</parameter></paramdef> 38989e7bcd65Smrg</funcprototype> 38999e7bcd65Smrg</funcsynopsis> 39009e7bcd65Smrg 39019e7bcd65Smrg<variablelist> 39029e7bcd65Smrg <varlistentry> 39039e7bcd65Smrg <term> 39049e7bcd65Smrg <emphasis remap='I'>object</emphasis> 39059e7bcd65Smrg </term> 39069e7bcd65Smrg <listitem> 39079e7bcd65Smrg <para> 39089e7bcd65SmrgSpecifies the object. Must be of class Object or any subclass thereof. 39099e7bcd65Smrg </para> 39109e7bcd65Smrg </listitem> 39119e7bcd65Smrg </varlistentry> 39129e7bcd65Smrg</variablelist> 39139e7bcd65Smrg 39149e7bcd65Smrg<para> 39159e7bcd65Smrg<xref linkend='XtWindowOfObject' xrefstyle='select: title'/> 39169e7bcd65Smrgis identical in function to 39179e7bcd65Smrg<xref linkend='XtWindow' xrefstyle='select: title'/> 39189e7bcd65Smrgif the object is a widget; otherwise 39199e7bcd65Smrg<xref linkend='XtWindowOfObject' xrefstyle='select: title'/> 39209e7bcd65Smrgreturns the window for the nearest ancestor of <emphasis remap='I'>object</emphasis> that is of class 39219e7bcd65SmrgWidget or a subclass thereof. 39229e7bcd65Smrg</para> 39239e7bcd65Smrg 39249e7bcd65Smrg<para> 39259e7bcd65SmrgTo retrieve the instance name of an object, use 39269e7bcd65Smrg<xref linkend='XtName' xrefstyle='select: title'/>. 39279e7bcd65Smrg</para> 39289e7bcd65Smrg 39299e7bcd65Smrg<funcsynopsis id='XtName'> 39309e7bcd65Smrg<funcprototype> 39319e7bcd65Smrg <funcdef>String <function>XtName</function></funcdef> 39329e7bcd65Smrg <paramdef>Widget <parameter>object</parameter></paramdef> 39339e7bcd65Smrg</funcprototype> 39349e7bcd65Smrg</funcsynopsis> 39359e7bcd65Smrg 39369e7bcd65Smrg<variablelist> 39379e7bcd65Smrg <varlistentry> 39389e7bcd65Smrg <term> 39399e7bcd65Smrg <emphasis remap='I'>object</emphasis> 39409e7bcd65Smrg </term> 39419e7bcd65Smrg <listitem> 39429e7bcd65Smrg <para> 39439e7bcd65SmrgSpecifies the object whose name is desired. Must be of class Object or any subclass thereof. 39449e7bcd65Smrg </para> 39459e7bcd65Smrg </listitem> 39469e7bcd65Smrg </varlistentry> 39479e7bcd65Smrg</variablelist> 39489e7bcd65Smrg 39499e7bcd65Smrg<para> 39509e7bcd65Smrg<xref linkend='XtName' xrefstyle='select: title'/> 39519e7bcd65Smrgreturns a pointer to the instance name of the specified object. 39529e7bcd65SmrgThe storage is owned by the Intrinsics and must not be modified. The 39539e7bcd65Smrgname is not qualified by the names of any of the object's ancestors. 39549e7bcd65Smrg</para> 39559e7bcd65Smrg 39569e7bcd65Smrg<para> 39579e7bcd65SmrgSeveral window attributes are locally cached in the widget instance. 39589e7bcd65SmrgThus, they can be set by the resource manager and 39599e7bcd65Smrg<xref linkend='XtSetValues' xrefstyle='select: title'/> 39609e7bcd65Smrgas well as used by routines that derive structures from these values 39619e7bcd65Smrg(for example, <emphasis remap='I'>depth</emphasis> for deriving pixmaps, 39629e7bcd65Smrg<emphasis remap='I'>background_pixel</emphasis> for deriving GCs, and so on) or in the 39639e7bcd65Smrg<xref linkend='XtCreateWindow' xrefstyle='select: title'/> 39649e7bcd65Smrgcall. 39659e7bcd65Smrg</para> 39669e7bcd65Smrg 39679e7bcd65Smrg<para> 39689e7bcd65SmrgThe <emphasis remap='I'>x</emphasis>, <emphasis remap='I'>y</emphasis>, <emphasis remap='I'>width</emphasis>, <emphasis remap='I'>height</emphasis>, and <emphasis remap='I'>border_width</emphasis> 39699e7bcd65Smrgwindow attributes are available to 39709e7bcd65Smrggeometry managers. 39719e7bcd65SmrgThese fields are maintained synchronously inside the Intrinsics. 39729e7bcd65SmrgWhen an 39739e7bcd65Smrg<function>XConfigureWindow</function> 39749e7bcd65Smrgis issued by the Intrinsics on the widget's window (on request of its parent), 39759e7bcd65Smrgthese values are updated immediately rather than some time later 39769e7bcd65Smrgwhen the server generates a 39779e7bcd65Smrg<function>ConfigureNotify</function> 39789e7bcd65Smrgevent. 39799e7bcd65Smrg(In fact, most widgets do not select 39809e7bcd65Smrg<function>SubstructureNotify</function> 39819e7bcd65Smrgevents.) 39829e7bcd65SmrgThis ensures that all geometry calculations are based on the internally 39839e7bcd65Smrgconsistent toolkit world rather than on either 39849e7bcd65Smrgan inconsistent world updated by asynchronous 39859e7bcd65Smrg<function>ConfigureNotify</function> 39869e7bcd65Smrgevents or a consistent, but slow, world in which geometry managers 39879e7bcd65Smrgask the server 39889e7bcd65Smrgfor window sizes whenever they need to lay out their managed children 39899e7bcd65Smrg(see <xref linkend='Geometry_Management' />). 39909e7bcd65Smrg</para> 39919e7bcd65Smrg<sect2 id="Unrealizing_Widgets"> 39929e7bcd65Smrg<title>Unrealizing Widgets</title> 39939e7bcd65Smrg<para> 39949e7bcd65SmrgTo destroy the windows associated with a widget and its 39959e7bcd65Smrgnon-pop-up descendants, use 39969e7bcd65Smrg<xref linkend='XtUnrealizeWidget' xrefstyle='select: title'/>. 39979e7bcd65Smrg</para> 39989e7bcd65Smrg 39999e7bcd65Smrg<funcsynopsis id='XtUnrealizeWidget'> 40009e7bcd65Smrg<funcprototype> 40019e7bcd65Smrg <funcdef>void <function>XtUnrealizeWidget</function></funcdef> 40029e7bcd65Smrg <paramdef>Widget <parameter>w</parameter></paramdef> 40039e7bcd65Smrg</funcprototype> 40049e7bcd65Smrg</funcsynopsis> 40059e7bcd65Smrg 40069e7bcd65Smrg<variablelist> 40079e7bcd65Smrg <varlistentry> 40089e7bcd65Smrg <term> 40099e7bcd65Smrg <emphasis remap='I'>w</emphasis> 40109e7bcd65Smrg </term> 40119e7bcd65Smrg <listitem> 40129e7bcd65Smrg <para> 40139e7bcd65SmrgSpecifies the widget. Must be of class Core or any subclass thereof. 40149e7bcd65Smrg </para> 40159e7bcd65Smrg </listitem> 40169e7bcd65Smrg </varlistentry> 40179e7bcd65Smrg</variablelist> 40189e7bcd65Smrg 40199e7bcd65Smrg<para> 40209e7bcd65SmrgIf the widget is currently unrealized, 40219e7bcd65Smrg<xref linkend='XtUnrealizeWidget' xrefstyle='select: title'/> 40229e7bcd65Smrgsimply returns. Otherwise it performs the following: 40239e7bcd65Smrg</para> 40249e7bcd65Smrg<itemizedlist spacing='compact'> 40259e7bcd65Smrg <listitem> 40269e7bcd65Smrg <para> 40279e7bcd65SmrgUnmanages the widget if the widget is managed. 40289e7bcd65Smrg </para> 40299e7bcd65Smrg </listitem> 40309e7bcd65Smrg <listitem> 40319e7bcd65Smrg <para> 40329e7bcd65SmrgMakes a postorder (child-to-parent) traversal of the widget tree 40339e7bcd65Smrgrooted at the specified widget and, for each widget that has 40340568f49bSmrgdeclared a callback list resource named “unrealizeCallback”, executes the 40359e7bcd65Smrgprocedures on the 40369e7bcd65SmrgXtNunrealizeCallback 40379e7bcd65Smrglist. 40389e7bcd65Smrg </para> 40399e7bcd65Smrg </listitem> 40409e7bcd65Smrg <listitem> 40419e7bcd65Smrg <para> 40429e7bcd65SmrgDestroys the widget's window and any subwindows by calling 40439e7bcd65Smrg<function>XDestroyWindow</function> 40449e7bcd65Smrgwith the specified widget's <emphasis remap='I'>window</emphasis> field. 40459e7bcd65Smrg </para> 40469e7bcd65Smrg </listitem> 40479e7bcd65Smrg</itemizedlist> 40489e7bcd65Smrg<para> 40499e7bcd65SmrgAny events in the queue or which arrive following a call to 40509e7bcd65Smrg<xref linkend='XtUnrealizeWidget' xrefstyle='select: title'/> 40519e7bcd65Smrgwill be dispatched as if the window(s) of the 40529e7bcd65Smrgunrealized widget(s) had never existed. 40539e7bcd65Smrg</para> 40549e7bcd65Smrg</sect2> 40559e7bcd65Smrg</sect1> 40569e7bcd65Smrg 40579e7bcd65Smrg<sect1 id="Destroying_Widgets"> 40589e7bcd65Smrg<title>Destroying Widgets</title> 40599e7bcd65Smrg<para> 40609e7bcd65SmrgThe Intrinsics provide support 40619e7bcd65Smrg</para> 40629e7bcd65Smrg<itemizedlist spacing='compact'> 40639e7bcd65Smrg <listitem> 40649e7bcd65Smrg <para> 40659e7bcd65SmrgTo destroy all the pop-up children of the widget being destroyed 40669e7bcd65Smrgand destroy all children of composite widgets. 40679e7bcd65Smrg </para> 40689e7bcd65Smrg </listitem> 40699e7bcd65Smrg <listitem> 40709e7bcd65Smrg <para> 40719e7bcd65SmrgTo remove (and unmap) the widget from its parent. 40729e7bcd65Smrg </para> 40739e7bcd65Smrg </listitem> 40749e7bcd65Smrg <listitem> 40759e7bcd65Smrg <para> 40769e7bcd65SmrgTo call the callback procedures that have been registered to trigger 40779e7bcd65Smrgwhen the widget is destroyed. 40789e7bcd65Smrg </para> 40799e7bcd65Smrg </listitem> 40809e7bcd65Smrg <listitem> 40819e7bcd65Smrg <para> 40829e7bcd65SmrgTo minimize the number of things a widget has to deallocate when destroyed. 40839e7bcd65Smrg </para> 40849e7bcd65Smrg </listitem> 40859e7bcd65Smrg <listitem> 40869e7bcd65Smrg <para> 40879e7bcd65SmrgTo minimize the number of 40889e7bcd65Smrg<function>XDestroyWindow</function> 40899e7bcd65Smrgcalls when destroying a widget tree. 40909e7bcd65Smrg </para> 40919e7bcd65Smrg </listitem> 40929e7bcd65Smrg</itemizedlist> 40939e7bcd65Smrg<para> 40949e7bcd65SmrgTo destroy a widget instance, use 40959e7bcd65Smrg<xref linkend='XtDestroyWidget' xrefstyle='select: title'/>. 40969e7bcd65Smrg</para> 40979e7bcd65Smrg 40989e7bcd65Smrg 40999e7bcd65Smrg<funcsynopsis id='XtDestroyWidget'> 41009e7bcd65Smrg<funcprototype> 41019e7bcd65Smrg <funcdef>void <function>XtDestroyWidget</function></funcdef> 41029e7bcd65Smrg <paramdef>Widget <parameter>w</parameter></paramdef> 41039e7bcd65Smrg</funcprototype> 41049e7bcd65Smrg</funcsynopsis> 41059e7bcd65Smrg 41069e7bcd65Smrg<variablelist> 41079e7bcd65Smrg <varlistentry> 41089e7bcd65Smrg <term> 41099e7bcd65Smrg <emphasis remap='I'>w</emphasis> 41109e7bcd65Smrg </term> 41119e7bcd65Smrg <listitem> 41129e7bcd65Smrg <para> 41139e7bcd65SmrgSpecifies the widget. Must be of class Object or any subclass thereof. 41149e7bcd65Smrg </para> 41159e7bcd65Smrg </listitem> 41169e7bcd65Smrg </varlistentry> 41179e7bcd65Smrg</variablelist> 41189e7bcd65Smrg 41199e7bcd65Smrg<para> 41209e7bcd65SmrgThe 41219e7bcd65Smrg<xref linkend='XtDestroyWidget' xrefstyle='select: title'/> 41229e7bcd65Smrgfunction provides the only method of destroying a widget, 41239e7bcd65Smrgincluding widgets that need to destroy themselves. 41249e7bcd65SmrgIt can be called at any time, 41259e7bcd65Smrgincluding from an application callback routine of the widget being destroyed. 41269e7bcd65SmrgThis requires a two-phase destroy process in order to avoid dangling 41279e7bcd65Smrgreferences to destroyed widgets. 41289e7bcd65Smrg</para> 41299e7bcd65Smrg 41309e7bcd65Smrg<para> 41319e7bcd65SmrgIn phase 1, 41329e7bcd65Smrg<xref linkend='XtDestroyWidget' xrefstyle='select: title'/> 41339e7bcd65Smrgperforms the following: 41349e7bcd65Smrg</para> 41359e7bcd65Smrg<itemizedlist spacing='compact'> 41369e7bcd65Smrg <listitem> 41379e7bcd65Smrg <para> 41389e7bcd65SmrgIf the <emphasis remap='I'>being_destroyed</emphasis> field of the widget is 41399e7bcd65Smrg<function>True</function>, 41409e7bcd65Smrgit returns immediately. 41419e7bcd65Smrg </para> 41429e7bcd65Smrg </listitem> 41439e7bcd65Smrg <listitem> 41449e7bcd65Smrg <para> 41459e7bcd65SmrgRecursively descends the widget tree and 41469e7bcd65Smrgsets the <emphasis remap='I'>being_destroyed</emphasis> field to 41479e7bcd65Smrg<function>True</function> 41489e7bcd65Smrgfor the widget and all normal and pop-up children. 41499e7bcd65Smrg </para> 41509e7bcd65Smrg </listitem> 41519e7bcd65Smrg <listitem> 41529e7bcd65Smrg <para> 41539e7bcd65SmrgAdds the widget to a list of widgets (the destroy list) that should be 41549e7bcd65Smrgdestroyed when it is safe to do so. 41559e7bcd65Smrg </para> 41569e7bcd65Smrg </listitem> 41579e7bcd65Smrg</itemizedlist> 41589e7bcd65Smrg<para> 41599e7bcd65SmrgEntries on the destroy list satisfy the invariant that 41609e7bcd65Smrgif w2 occurs after w1 on the destroy list, then w2 is not a descendent, 41619e7bcd65Smrgeither normal or pop-up, of w1. 41629e7bcd65Smrg</para> 41639e7bcd65Smrg 41649e7bcd65Smrg<para> 41659e7bcd65SmrgPhase 2 occurs when all procedures that should execute as a result of 41669e7bcd65Smrgthe current event have been called, including all procedures registered with 41679e7bcd65Smrgthe event and translation managers, 41689e7bcd65Smrgthat is, when the current invocation of 41699e7bcd65Smrg<xref linkend='XtDispatchEvent' xrefstyle='select: title'/> 41709e7bcd65Smrgis about to return, or immediately if not in 41719e7bcd65Smrg<xref linkend='XtDispatchEvent' xrefstyle='select: title'/>. 41729e7bcd65Smrg</para> 41739e7bcd65Smrg 41749e7bcd65Smrg<para> 41759e7bcd65SmrgIn phase 2, 41769e7bcd65Smrg<xref linkend='XtDestroyWidget' xrefstyle='select: title'/> 41779e7bcd65Smrgperforms the following on each entry in the destroy list in the order 41789e7bcd65Smrgspecified: 41799e7bcd65Smrg</para> 41809e7bcd65Smrg<itemizedlist spacing='compact'> 41819e7bcd65Smrg <listitem> 41829e7bcd65Smrg <para> 41839e7bcd65SmrgIf the widget is not a pop-up child and the widget's parent is a subclass of 41840568f49bSmrg<function>compositeWidgetClass</function>, 41859e7bcd65Smrgand if the parent is not being destroyed, 41869e7bcd65Smrgit calls 41879e7bcd65Smrg<xref linkend='XtUnmanageChild' xrefstyle='select: title'/> 41889e7bcd65Smrgon the widget and then calls the widget's parent's delete_child procedure 41899e7bcd65Smrg(see <xref linkend='Deletion_of_Children_The_delete_child_Procedure' />). 41909e7bcd65Smrg </para> 41919e7bcd65Smrg </listitem> 41929e7bcd65Smrg <listitem> 41939e7bcd65Smrg <para> 41949e7bcd65SmrgCalls the destroy callback procedures registered on the widget 41959e7bcd65Smrgand all normal and pop-up descendants in postorder (it calls child 41969e7bcd65Smrgcallbacks before parent callbacks). 41979e7bcd65Smrg </para> 41989e7bcd65Smrg </listitem> 41999e7bcd65Smrg</itemizedlist> 42009e7bcd65Smrg<para> 42019e7bcd65SmrgThe 42029e7bcd65Smrg<xref linkend='XtDestroyWidget' xrefstyle='select: title'/> 42039e7bcd65Smrgfunction then makes second traversal of the widget and all normal 42049e7bcd65Smrgand pop-up descendants to perform the following three items on each 42059e7bcd65Smrgwidget in postorder: 42069e7bcd65Smrg</para> 42079e7bcd65Smrg<itemizedlist spacing='compact'> 42089e7bcd65Smrg <listitem> 42099e7bcd65Smrg <para> 42109e7bcd65SmrgIf the widget is not a pop-up child and the widget's parent is a subclass of 42110568f49bSmrg<function>constraintWidgetClass</function>, 42129e7bcd65Smrgit calls the 42139e7bcd65Smrg<function>ConstraintClassPart</function> 42149e7bcd65Smrgdestroy procedure for the parent, 42159e7bcd65Smrgthen for the parent's superclass, 42169e7bcd65Smrguntil finally it calls the 42179e7bcd65Smrg<function>ConstraintClassPart</function> 42189e7bcd65Smrgdestroy procedure for 42199e7bcd65Smrg<function>constraintWidgetClass</function>. 42209e7bcd65Smrg </para> 42219e7bcd65Smrg </listitem> 42229e7bcd65Smrg <listitem> 42239e7bcd65Smrg <para> 42249e7bcd65SmrgCalls the 42259e7bcd65Smrg<function>CoreClassPart</function> 42269e7bcd65Smrgdestroy procedure declared in the widget class, 42279e7bcd65Smrgthen the destroy procedure declared in its superclass, 42289e7bcd65Smrguntil finally it calls the destroy procedure declared in the Object 42299e7bcd65Smrgclass record. Callback lists are deallocated. 42309e7bcd65Smrg </para> 42319e7bcd65Smrg </listitem> 42329e7bcd65Smrg <listitem> 42339e7bcd65Smrg <para> 42349e7bcd65SmrgIf the widget class object class part contains an 42359e7bcd65Smrg<function>ObjectClassExtension</function> 42369e7bcd65Smrgrecord with the record_type 42379e7bcd65Smrg<emphasis role='strong'>NULLQUARK</emphasis> 42389e7bcd65Smrgand the <emphasis remap='I'>deallocate</emphasis> field is not NULL, 42399e7bcd65Smrgcalls the deallocate procedure to deallocate the instance and if one 42409e7bcd65Smrgexists, the constraint record. Otherwise, the Intrinsics will deallocate 42419e7bcd65Smrgthe widget instance record and if one exists, the constraint record. 42429e7bcd65Smrg </para> 42439e7bcd65Smrg </listitem> 42449e7bcd65Smrg <listitem> 42459e7bcd65Smrg <para> 42469e7bcd65SmrgCalls 42479e7bcd65Smrg<function>XDestroyWindow</function> 42489e7bcd65Smrgif the specified widget is realized (that is, has an X window). 42499e7bcd65SmrgThe server recursively destroys all normal descendant windows. 42509e7bcd65Smrg(Windows of realized pop-up Shell children, and their 42519e7bcd65Smrgdescendants, are destroyed by a shell class destroy procedure.) 42529e7bcd65Smrg </para> 42539e7bcd65Smrg </listitem> 42549e7bcd65Smrg</itemizedlist> 42559e7bcd65Smrg<sect2 id="Adding_and_Removing_Destroy_Callbacks"> 42569e7bcd65Smrg<title>Adding and Removing Destroy Callbacks</title> 42579e7bcd65Smrg<para> 42589e7bcd65SmrgWhen an application needs to perform additional processing during the 42599e7bcd65Smrgdestruction of a widget, 42609e7bcd65Smrgit should register a destroy callback procedure for the widget. 42619e7bcd65SmrgThe destroy callback procedures use the mechanism described in 42629e7bcd65Smrg<xref linkend='Callbacks' />. 42639e7bcd65SmrgThe destroy callback list is identified by the resource name 42649e7bcd65SmrgXtNdestroyCallback. 42659e7bcd65Smrg</para> 42669e7bcd65Smrg 42679e7bcd65Smrg<para> 42689e7bcd65SmrgFor example, the following adds an application-supplied destroy callback 42699e7bcd65Smrgprocedure <emphasis remap='I'>ClientDestroy</emphasis> with client data to a widget by calling 42709e7bcd65Smrg<xref linkend='XtAddCallback' xrefstyle='select: title'/>. 42719e7bcd65Smrg</para> 42729e7bcd65Smrg 42730568f49bSmrg<programlisting> 42749e7bcd65SmrgXtAddCallback(<emphasis remap='I'>w</emphasis>, XtNdestroyCallback, <emphasis remap='I'>ClientDestroy</emphasis>, <emphasis remap='I'>client_data</emphasis>) 42750568f49bSmrg</programlisting> 42769e7bcd65Smrg 42779e7bcd65Smrg<para> 42789e7bcd65SmrgSimilarly, the following removes the application-supplied destroy callback 42799e7bcd65Smrgprocedure <emphasis remap='I'>ClientDestroy</emphasis> by calling 42809e7bcd65Smrg<xref linkend='XtRemoveCallback' xrefstyle='select: title'/>. 42819e7bcd65Smrg</para> 42829e7bcd65Smrg 42830568f49bSmrg<programlisting> 42849e7bcd65SmrgXtRemoveCallback(<emphasis remap='I'>w</emphasis>, XtNdestroyCallback, <emphasis remap='I'>ClientDestroy</emphasis>, <emphasis remap='I'>client_data</emphasis>) 42850568f49bSmrg</programlisting> 42869e7bcd65Smrg<para> 42879e7bcd65SmrgThe <emphasis remap='I'>ClientDestroy</emphasis> argument is of type 42889e7bcd65Smrg<xref linkend='XtCallbackProc' xrefstyle='select: title'/>; 42899e7bcd65Smrgsee <xref linkend='Using_Callback_Procedure_and_Callback_List_Definitions' />. 42909e7bcd65Smrg</para> 42919e7bcd65Smrg</sect2> 42929e7bcd65Smrg 42939e7bcd65Smrg<sect2 id="Dynamic_Data_Deallocation_The_destroy_Procedure"> 42949e7bcd65Smrg<title>Dynamic Data Deallocation: The destroy Procedure</title> 42959e7bcd65Smrg<para> 42969e7bcd65SmrgThe destroy procedure pointers in the 42979e7bcd65Smrg<function>ObjectClassPart</function>, 42989e7bcd65Smrg<function>RectObjClassPart</function>, 42999e7bcd65Smrgand 43009e7bcd65Smrg<function>CoreClassPart</function> 43019e7bcd65Smrgstructures are of type 43029e7bcd65Smrg<xref linkend='XtWidgetProc' xrefstyle='select: title'/>. 43039e7bcd65Smrg</para> 43049e7bcd65Smrg 43059e7bcd65Smrg<funcsynopsis id='XtWidgetProc'> 43069e7bcd65Smrg<funcprototype> 43079e7bcd65Smrg <funcdef>typedef void <function>XtWidgetProc</function></funcdef> 43089e7bcd65Smrg <paramdef>Widget <parameter>w</parameter></paramdef> 43099e7bcd65Smrg</funcprototype> 43109e7bcd65Smrg</funcsynopsis> 43119e7bcd65Smrg 43129e7bcd65Smrg<variablelist> 43139e7bcd65Smrg <varlistentry> 43149e7bcd65Smrg <term> 43159e7bcd65Smrg <emphasis remap='I'>w</emphasis> 43169e7bcd65Smrg </term> 43179e7bcd65Smrg <listitem> 43189e7bcd65Smrg <para> 43199e7bcd65SmrgSpecifies the widget being destroyed. 43209e7bcd65Smrg </para> 43219e7bcd65Smrg </listitem> 43229e7bcd65Smrg </varlistentry> 43239e7bcd65Smrg</variablelist> 43249e7bcd65Smrg 43259e7bcd65Smrg<para> 43269e7bcd65SmrgThe destroy procedures are called in subclass-to-superclass order. 43279e7bcd65SmrgTherefore, a widget's destroy procedure should deallocate only storage 43289e7bcd65Smrgthat is specific to the subclass and should ignore the storage 43299e7bcd65Smrgallocated by any of its superclasses. 43309e7bcd65SmrgThe destroy procedure should deallocate only resources that have been 43319e7bcd65Smrgexplicitly created by the subclass. 43329e7bcd65SmrgAny resource that was obtained from the resource database 43339e7bcd65Smrgor passed in an argument list was not created by the widget 43349e7bcd65Smrgand therefore should not be destroyed by it. 43359e7bcd65SmrgIf a widget does not need to deallocate any storage, 43369e7bcd65Smrgthe destroy procedure entry in its class record can be NULL. 43379e7bcd65Smrg</para> 43389e7bcd65Smrg 43399e7bcd65Smrg<para> 43409e7bcd65SmrgDeallocating storage includes, but is not limited to, 43419e7bcd65Smrgthe following steps: 43429e7bcd65Smrg</para> 43439e7bcd65Smrg<itemizedlist spacing='compact'> 43449e7bcd65Smrg <listitem> 43459e7bcd65Smrg <para> 43469e7bcd65SmrgCalling 43479e7bcd65Smrg<xref linkend='XtFree' xrefstyle='select: title'/> 43489e7bcd65Smrgon dynamic storage allocated with 43499e7bcd65Smrg<xref linkend='XtMalloc' xrefstyle='select: title'/>, 43509e7bcd65Smrg<xref linkend='XtCalloc' xrefstyle='select: title'/>, 43519e7bcd65Smrgand so on. 43529e7bcd65Smrg </para> 43539e7bcd65Smrg </listitem> 43549e7bcd65Smrg <listitem> 43559e7bcd65Smrg <para> 43569e7bcd65SmrgCalling 43579e7bcd65Smrg<function>XFreePixmap</function> 43589e7bcd65Smrgon pixmaps created with direct X calls. 43599e7bcd65Smrg </para> 43609e7bcd65Smrg </listitem> 43619e7bcd65Smrg <listitem> 43629e7bcd65Smrg <para> 43639e7bcd65SmrgCalling 43649e7bcd65Smrg<xref linkend='XtReleaseGC' xrefstyle='select: title'/> 43659e7bcd65Smrgon GCs allocated with 43669e7bcd65Smrg<xref linkend='XtGetGC' xrefstyle='select: title'/>. 43679e7bcd65Smrg </para> 43689e7bcd65Smrg </listitem> 43699e7bcd65Smrg <listitem> 43709e7bcd65Smrg <para> 43719e7bcd65SmrgCalling 43729e7bcd65Smrg<function>XFreeGC</function> 43739e7bcd65Smrgon GCs allocated with direct X calls. 43749e7bcd65Smrg </para> 43759e7bcd65Smrg </listitem> 43769e7bcd65Smrg <listitem> 43779e7bcd65Smrg <para> 43789e7bcd65SmrgCalling 43799e7bcd65Smrg<xref linkend='XtRemoveEventHandler' xrefstyle='select: title'/> 43809e7bcd65Smrgon event handlers added to other widgets. 43819e7bcd65Smrg </para> 43829e7bcd65Smrg </listitem> 43839e7bcd65Smrg <listitem> 43849e7bcd65Smrg <para> 43859e7bcd65SmrgCalling 43869e7bcd65Smrg<xref linkend='XtRemoveTimeOut' xrefstyle='select: title'/> 43879e7bcd65Smrgon timers created with 43889e7bcd65Smrg<xref linkend='XtAppAddTimeOut' xrefstyle='select: title'/>. 43899e7bcd65Smrg </para> 43909e7bcd65Smrg </listitem> 43919e7bcd65Smrg <listitem> 43929e7bcd65Smrg <para> 43939e7bcd65SmrgCalling 43949e7bcd65Smrg<xref linkend='XtDestroyWidget' xrefstyle='select: title'/> 43959e7bcd65Smrgfor each child if the widget has children 43969e7bcd65Smrgand is not a subclass of 43979e7bcd65Smrg<function>compositeWidgetClass</function>. 43989e7bcd65Smrg </para> 43999e7bcd65Smrg </listitem> 44009e7bcd65Smrg</itemizedlist> 44019e7bcd65Smrg<para> 44029e7bcd65SmrgDuring destroy phase 2 for each widget, the Intrinsics remove the widget 44039e7bcd65Smrgfrom the modal cascade, unregister all event handlers, remove all key, 44049e7bcd65Smrgkeyboard, button, and pointer grabs and remove all callback procedures 44059e7bcd65Smrgregistered on the widget. Any outstanding selection transfers will time out. 44069e7bcd65Smrg</para> 44079e7bcd65Smrg</sect2> 44089e7bcd65Smrg 44099e7bcd65Smrg<sect2 id="Dynamic_Constraint_Data_Deallocation_The_ConstraintClassPart_destroy_Procedure"> 44109e7bcd65Smrg<title>Dynamic Constraint Data Deallocation: The ConstraintClassPart destroy Procedure</title> 44119e7bcd65Smrg<para> 44129e7bcd65SmrgThe constraint destroy procedure identified in the 44139e7bcd65Smrg<function>ConstraintClassPart</function> 44149e7bcd65Smrg<function>constraintWidgetClass</function>. 44159e7bcd65SmrgThis constraint destroy procedure pointer is of type 44169e7bcd65Smrg<xref linkend='XtWidgetProc' xrefstyle='select: title'/>. 44179e7bcd65SmrgThe constraint destroy procedures are called in subclass-to-superclass order, 44189e7bcd65Smrgstarting at the class of the widget's parent and ending at 44190568f49bSmrg<function>constraintWidgetClass</function>. 44209e7bcd65SmrgTherefore, a parent's constraint destroy procedure should deallocate only 44219e7bcd65Smrgstorage that is specific to the constraint subclass 44229e7bcd65Smrgand not storage allocated by any of its superclasses. 44239e7bcd65Smrg</para> 44249e7bcd65Smrg 44259e7bcd65Smrg<para> 44269e7bcd65SmrgIf a parent does not need to deallocate any constraint storage, 44279e7bcd65Smrgthe constraint destroy procedure entry 44289e7bcd65Smrgin its class record can be NULL. 44299e7bcd65Smrg</para> 44309e7bcd65Smrg</sect2> 44319e7bcd65Smrg 44329e7bcd65Smrg<sect2 id="Widget_Instance_Deallocation_The_deallocate_Procedure"> 44339e7bcd65Smrg<title>Widget Instance Deallocation: The deallocate Procedure</title> 44349e7bcd65Smrg<para> 44359e7bcd65SmrgThe deallocate procedure pointer in the 44369e7bcd65Smrg<function>ObjectClassExtension</function> 44379e7bcd65Smrgrecord is of type 44389e7bcd65Smrg<function>XtDeallocateProc</function>. 44399e7bcd65Smrg</para> 44409e7bcd65Smrg 44419e7bcd65Smrg<funcsynopsis> 44429e7bcd65Smrg<funcprototype> 44439e7bcd65Smrg <funcdef>typedef void <function>(*XtDeallocateProc)</function></funcdef> 44449e7bcd65Smrg <paramdef>Widget <parameter>widget</parameter></paramdef> 44459e7bcd65Smrg <paramdef>XtPointer <parameter>more_bytes</parameter></paramdef> 44469e7bcd65Smrg</funcprototype> 44479e7bcd65Smrg</funcsynopsis> 44489e7bcd65Smrg 44499e7bcd65Smrg<variablelist> 44509e7bcd65Smrg <varlistentry> 44519e7bcd65Smrg <term> 44529e7bcd65Smrg <emphasis remap='I'>widget</emphasis> 44539e7bcd65Smrg </term> 44549e7bcd65Smrg <listitem> 44559e7bcd65Smrg <para> 44569e7bcd65SmrgSpecifies the widget being destroyed. 44579e7bcd65Smrg </para> 44589e7bcd65Smrg </listitem> 44599e7bcd65Smrg </varlistentry> 44609e7bcd65Smrg <varlistentry> 44619e7bcd65Smrg <term> 44629e7bcd65Smrg <emphasis remap='I'>more_bytes</emphasis> 44639e7bcd65Smrg </term> 44649e7bcd65Smrg <listitem> 44659e7bcd65Smrg <para> 44669e7bcd65SmrgSpecifies the auxiliary memory received from the corresponding allocator 44679e7bcd65Smrgalong with the widget, or NULL. 44689e7bcd65Smrg </para> 44699e7bcd65Smrg </listitem> 44709e7bcd65Smrg </varlistentry> 44719e7bcd65Smrg</variablelist> 44729e7bcd65Smrg 44739e7bcd65Smrg<para> 44749e7bcd65SmrgWhen a widget is destroyed, if an 44759e7bcd65Smrg<function>ObjectClassExtension</function> 44769e7bcd65Smrgrecord exists in the object class part <emphasis remap='I'>extension</emphasis> field 44779e7bcd65Smrgwith <emphasis remap='I'>record_type</emphasis> 44789e7bcd65Smrg<emphasis role='strong'>NULLQUARK</emphasis> 44799e7bcd65Smrgand the <emphasis remap='I'>deallocate</emphasis> field is not NULL, the 44809e7bcd65Smrg<function>XtDeallocateProc</function> 44819e7bcd65Smrgwill be called. 44829e7bcd65SmrgIf no ObjectClassPart extension record is declared with <emphasis remap='I'>record_type</emphasis> 44839e7bcd65Smrgequal to 44849e7bcd65Smrg<emphasis role='strong'>NULLQUARK</emphasis>, 44859e7bcd65Smrgthen 44869e7bcd65Smrg<function>XtInheritAllocate</function> 44879e7bcd65Smrgand 44889e7bcd65Smrg<function>XtInheritDeallocate</function> 44899e7bcd65Smrgare assumed. 44909e7bcd65SmrgThe responsibilities of the deallocate procedure are to deallocate the 44919e7bcd65Smrgmemory specified by <emphasis remap='I'>more_bytes</emphasis> if it is not NULL, 44929e7bcd65Smrgto deallocate the constraints record as specified by the 44939e7bcd65Smrgwidget's <emphasis remap='I'>core.constraints</emphasis> field if it is 44949e7bcd65Smrgnot NULL, and to deallocate the widget instance itself. 44959e7bcd65Smrg</para> 44969e7bcd65Smrg 44979e7bcd65Smrg<para> 44989e7bcd65SmrgIf no 44999e7bcd65Smrg<function>XtDeallocateProc</function> 45009e7bcd65Smrgis found, it is assumed that the Intrinsics 45019e7bcd65Smrgoriginally allocated the memory and is responsible for freeing it. 45029e7bcd65Smrg</para> 45039e7bcd65Smrg</sect2> 45049e7bcd65Smrg</sect1> 45059e7bcd65Smrg 45069e7bcd65Smrg<sect1 id="Exiting_from_an_Application"> 45079e7bcd65Smrg<title>Exiting from an Application</title> 45089e7bcd65Smrg<para> 45099e7bcd65SmrgAll X Toolkit applications should terminate 45109e7bcd65Smrgby calling 45119e7bcd65Smrg<xref linkend='XtDestroyApplicationContext' xrefstyle='select: title'/> 45129e7bcd65Smrgand then exiting 45139e7bcd65Smrgusing the 45149e7bcd65Smrgstandard method for their operating system (typically, by calling 45159e7bcd65Smrg<function>exit</function> 45169e7bcd65Smrgfor POSIX-based systems). 45179e7bcd65SmrgThe quickest way to make the windows disappear while exiting is to call 45189e7bcd65Smrg<xref linkend='XtUnmapWidget' xrefstyle='select: title'/> 45199e7bcd65Smrgon each top-level shell widget. 45209e7bcd65SmrgThe Intrinsics have no resources beyond those in the program image, 45219e7bcd65Smrgand the X server will free its resources when its connection 45229e7bcd65Smrgto the application is broken. 45239e7bcd65Smrg</para> 45249e7bcd65Smrg 45259e7bcd65Smrg<para> 45269e7bcd65SmrgDepending upon the widget set in use, it may be necessary to explicitly 45279e7bcd65Smrgdestroy individual widgets or widget trees with 45289e7bcd65Smrg<xref linkend='XtDestroyWidget' xrefstyle='select: title'/> 45299e7bcd65Smrgbefore calling 45309e7bcd65Smrg<xref linkend='XtDestroyApplicationContext' xrefstyle='select: title'/> 45319e7bcd65Smrgin order to ensure that any 45329e7bcd65Smrgrequired widget cleanup is properly executed. The application developer 45339e7bcd65Smrgmust refer to the widget documentation to learn if a widget needs to 45349e7bcd65Smrgperform cleanup beyond that performed automatically by the 45359e7bcd65Smrgoperating system. If the client is a session participant 45369e7bcd65Smrg(see <xref linkend='Session_Participation' />), then the client may wish to resign from the session 45379e7bcd65Smrgbefore exiting. See <xref linkend='Resigning_from_a_Session' /> for details. 45389e7bcd65Smrg</para> 45399e7bcd65Smrg</sect1> 45409e7bcd65Smrg</chapter> 4541