1<?xml version="1.0" encoding="UTF-8" ?> 2<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.3//EN" "http://www.oasis-open.org/docbook/xml/4.3/docbookx.dtd"> 3 4<chapter id='Resource_Management'> 5<title>Resource Management</title> 6<para> 7A resource is a field in the widget record with a corresponding 8resource entry in the <emphasis remap='I'>resources</emphasis> list of the widget or any of its 9superclasses. 10This means that the field is 11settable by 12<xref linkend='XtCreateWidget' xrefstyle='select: title'/> 13(by naming the field in the argument list), by an 14entry in a resource file (by using either the name or class), and by 15<xref linkend='XtSetValues' xrefstyle='select: title'/>. 16In addition, it is readable by 17<xref linkend='XtGetValues' xrefstyle='select: title'/>. 18Not all fields in a widget record are resources. 19Some are for bookkeeping use by the 20generic routines (like <emphasis remap='I'>managed</emphasis> and <emphasis remap='I'>being_destroyed</emphasis>). 21Others can be for local bookkeeping, 22and still others are derived from resources 23(many graphics contexts and pixmaps). 24</para> 25 26<para> 27Widgets typically need to obtain a large set of resources at widget 28creation time. 29Some of the resources come from the argument list supplied in the call to 30<xref linkend='XtCreateWidget' xrefstyle='select: title'/>, 31some from the resource database, 32and some from the internal defaults specified by the widget. 33Resources are obtained first from the argument list, 34then from the resource database for all resources not specified 35in the argument list, 36and last, from the internal default, if needed. 37</para> 38<sect1 id="Resource_Lists"> 39<title>Resource Lists</title> 40<para> 41A resource entry specifies a field in the widget, 42the textual name and class of the field that argument lists 43and external resource files use to refer to the field, 44and a default value that the field should get if no value is specified. 45The declaration for the 46<function>XtResource</function> 47structure is 48</para> 49<programlisting> 50typedef struct { 51 String resource_name; 52 String resource_class; 53 String resource_type; 54 Cardinal resource_size; 55 Cardinal resource_offset; 56 String default_type; 57 XtPointer default_addr; 58} XtResource, *XtResourceList; 59</programlisting> 60<para> 61When the resource list is specified as the 62<function>CoreClassPart</function>, 63<function>ObjectClassPart</function>, 64<function>RectObjClassPart</function>, 65or 66<function>ConstraintClassPart</function> 67<emphasis remap='I'>resources</emphasis> field, the strings pointed to by <emphasis remap='I'>resource_name</emphasis>, 68<emphasis remap='I'>resource_class</emphasis>, <emphasis remap='I'>resource_type</emphasis>, and <emphasis remap='I'>default_type</emphasis> must 69be permanently allocated prior to or during the execution of the class 70initialization procedure and must not be subsequently deallocated. 71</para> 72 73<para> 74The <emphasis remap='I'>resource_name</emphasis> field contains the name used by clients to access the field 75in the widget. 76By convention, it starts with a lowercase letter 77and is spelled exactly like the field name, 78except all underscores (_) are deleted and the next letter is replaced by its 79uppercase counterpart. 80For example, the resource name for background_pixel becomes backgroundPixel. 81Resource names beginning with the two-character 82sequence “xt”, and resource classes beginning with the two-character 83sequence “Xt” are reserved to the Intrinsics for future standard and 84implementation-dependent uses. 85Widget header files typically contain a symbolic name for each resource name. 86All resource names, classes, and types used by the Intrinsics are named in 87<filename class="headerfile"><X11/StringDefs.h></filename>. 88The Intrinsics's symbolic resource names begin with 89“XtN” 90and are followed by the string name (for example, XtNbackgroundPixel 91for backgroundPixel). 92</para> 93 94<para> 95The <emphasis remap='I'>resource_class</emphasis> field contains the class string used in resource 96specification files to identify the field. 97A resource class provides two functions: 98</para> 99<itemizedlist spacing='compact'> 100 <listitem> 101 <para> 102It isolates an application from different representations that widgets 103can use for a similar resource. 104 </para> 105 </listitem> 106 <listitem> 107 <para> 108It lets you specify values for several actual resources with a single name. 109A resource class should be chosen to span a group of closely related fields. 110 </para> 111 </listitem> 112</itemizedlist> 113<para> 114For example, 115a widget can have several pixel resources: background, foreground, 116border, block cursor, pointer cursor, and so on. 117Typically, the background defaults to white 118and everything else to black. 119The resource class for each of these resources in the resource list 120should be chosen so that it takes the minimal number of entries 121in the resource database to make the background ivory 122and everything else darkblue. 123</para> 124 125<para> 126In this case, the background pixel should have a resource class of 127“Background” 128and all the other pixel entries a resource class of 129“Foreground”. 130Then, the resource file needs only two lines to 131change all pixels to ivory or darkblue: 132</para> 133<programlisting> 134*Background: ivory 135*Foreground: darkblue 136</programlisting> 137<para> 138Similarly, a widget may have several font resources (such as normal and bold), 139but all fonts should have the class Font. 140Thus, changing all fonts simply requires only a single line in the 141default resource file: 142</para> 143<programlisting> 144*Font: 6x13 145</programlisting> 146<para> 147By convention, 148resource classes are always spelled starting with a capital letter 149to distinguish them from resource names. 150Their symbolic names are preceded with 151“XtC” 152(for example, XtCBackground). 153</para> 154 155<para> 156The <emphasis remap='I'>resource_type</emphasis> field gives the physical representation type of the resource 157and also encodes information about the specific usage of the field. 158By convention, it starts with an uppercase letter and is 159spelled identically to the type name of the field. 160The resource type is used when resources are fetched to 161convert from the resource database format (usually 162<function>String</function>) 163or the format of the resource default value 164(almost anything, but often 165<function>String</function>) 166to the desired 167physical representation (see <xref linkend='Resource_Conversions' />). 168The Intrinsics define the following resource types: 169</para> 170 171<informaltable frame='topbot'> 172 <?dbfo keep-together="auto" ?> 173 <tgroup cols='2' align='left' colsep='0' rowsep='0'> 174 <colspec colwidth='1.0*' colname='c1'/> 175 <colspec colwidth='1.0*' colname='c2'/> 176 <thead> 177 <row rowsep='1'> 178 <entry>Resource Type</entry> 179 <entry>Structure or Field Type</entry> 180 </row> 181 </thead> 182 <tbody> 183 <row> 184 <entry><function>XtRAcceleratorTable</function></entry> 185 <entry>XtAccelerators</entry> 186 </row> 187 <row> 188 <entry><function>XtRAtom</function></entry> 189 <entry>Atom</entry> 190 </row> 191 <row> 192 <entry><function>XtRBitmap</function></entry> 193 <entry>Pixmap, depth=1</entry> 194 </row> 195 <row> 196 <entry><function>XtRBoolean</function></entry> 197 <entry>Boolean</entry> 198 </row> 199 <row> 200 <entry><function>XtRBool</function></entry> 201 <entry>Bool</entry> 202 </row> 203 <row> 204 <entry><function>XtRCallback</function></entry> 205 <entry>XtCallbackList</entry> 206 </row> 207 <row> 208 <entry><function>XtRCardinal</function></entry> 209 <entry>Cardinal</entry> 210 </row> 211 <row> 212 <entry><function>XtRColor</function></entry> 213 <entry>XColor</entry> 214 </row> 215 <row> 216 <entry><function>XtRColormap</function></entry> 217 <entry>Colormap</entry> 218 </row> 219 <row> 220 <entry><function>XtRCommandArgArray</function></entry> 221 <entry>String*</entry> 222 </row> 223 <row> 224 <entry><function>XtRCursor</function></entry> 225 <entry>Cursor</entry> 226 </row> 227 <row> 228 <entry><function>XtRDimension</function></entry> 229 <entry>Dimension</entry> 230 </row> 231 <row> 232 <entry><function>XtRDirectoryString</function></entry> 233 <entry>String</entry> 234 </row> 235 <row> 236 <entry><function>XtRDisplay</function></entry> 237 <entry>Display*</entry> 238 </row> 239 <row> 240 <entry><function>XtREnum</function></entry> 241 <entry>XtEnum</entry> 242 </row> 243 <row> 244 <entry><function>XtREnvironmentArray</function></entry> 245 <entry>String*</entry> 246 </row> 247 <row> 248 <entry><function>XtRFile</function></entry> 249 <entry>FILE*</entry> 250 </row> 251 <row> 252 <entry><function>XtRFloat</function></entry> 253 <entry>float</entry> 254 </row> 255 <row> 256 <entry><function>XtRFont</function></entry> 257 <entry>Font</entry> 258 </row> 259 <row> 260 <entry><function>XtRFontSet</function></entry> 261 <entry>XFontSet</entry> 262 </row> 263 <row> 264 <entry><function>XtRFontStruct</function></entry> 265 <entry>XFontStruct*</entry> 266 </row> 267 <row> 268 <entry><function>XtRFunction</function></entry> 269 <entry>(*)(Widget)</entry> 270 </row> 271 <row> 272 <entry><function>XtRGeometry</function></entry> 273 <entry>char*, format as defined by 274 <function>XParseGeometry</function></entry> 275 </row> 276 <row> 277 <entry><function>XtRGravity</function></entry> 278 <entry>int</entry> 279 </row> 280 <row> 281 <entry><function>XtRInitialState</function></entry> 282 <entry>int</entry> 283 </row> 284 <row> 285 <entry><function>XtRInt</function></entry> 286 <entry>int</entry> 287 </row> 288 <row> 289 <entry><function>XtRLongBoolean</function></entry> 290 <entry>long</entry> 291 </row> 292 <row> 293 <entry><function>XtRObject</function></entry> 294 <entry>Object</entry> 295 </row> 296 <row> 297 <entry><function>XtRPixel</function></entry> 298 <entry>Pixel</entry> 299 </row> 300 <row> 301 <entry><function>XtRPixmap</function></entry> 302 <entry>Pixmap</entry> 303 </row> 304 <row> 305 <entry><function>XtRPointer</function></entry> 306 <entry>XtPointer</entry> 307 </row> 308 <row> 309 <entry><function>XtRPosition</function></entry> 310 <entry>Position</entry> 311 </row> 312 <row> 313 <entry><function>XtRRestartStyle</function></entry> 314 <entry>unsigned char</entry> 315 </row> 316 <row> 317 <entry><function>XtRScreen</function></entry> 318 <entry>Screen*</entry> 319 </row> 320 <row> 321 <entry><function>XtRShort</function></entry> 322 <entry>short</entry> 323 </row> 324 <row> 325 <entry><function>XtRSmcConn</function></entry> 326 <entry>XtPointer</entry> 327 </row> 328 <row> 329 <entry><function>XtRString</function></entry> 330 <entry>String</entry> 331 </row> 332 <row> 333 <entry><function>XtRStringArray</function></entry> 334 <entry>String*</entry> 335 </row> 336 <row> 337 <entry><function>XtRStringTable</function></entry> 338 <entry>String*</entry> 339 </row> 340 <row> 341 <entry><function>XtRTranslationTable</function></entry> 342 <entry>XtTranslations</entry> 343 </row> 344 <row> 345 <entry><function>XtRUnsignedChar</function></entry> 346 <entry>unsigned char</entry> 347 </row> 348 <row> 349 <entry><function>XtRVisual</function></entry> 350 <entry>Visual*</entry> 351 </row> 352 <row> 353 <entry><function>XtRWidget</function></entry> 354 <entry>Widget</entry> 355 </row> 356 <row> 357 <entry><function>XtRWidgetClass</function></entry> 358 <entry>WidgetClass</entry> 359 </row> 360 <row> 361 <entry><function>XtRWidgetList</function></entry> 362 <entry>WidgetList</entry> 363 </row> 364 <row> 365 <entry><function>XtRWindow</function></entry> 366 <entry>Window</entry> 367 </row> 368 </tbody> 369 </tgroup> 370</informaltable> 371 372<para> 373<filename class="headerfile"><X11/StringDefs.h></filename> 374also defines the following resource types as a 375convenience for widgets, although they do not have any corresponding 376data type assigned: 377<function>XtREditMode</function>, 378<function>XtRJustify</function>, 379and 380<function>XtROrientation</function>. 381</para> 382 383<para> 384The <emphasis remap='I'>resource_size</emphasis> field is the size of the physical representation in bytes; 385you should specify it as 386<function>sizeof</function>(type) so that the 387compiler fills in the value. 388The <emphasis remap='I'>resource_offset</emphasis> field is the offset in bytes of the field 389within the widget. 390You should use the 391<xref linkend='XtOffsetOf' xrefstyle='select: title'/> 392macro to retrieve this value. 393The <emphasis remap='I'>default_type</emphasis> field is the representation type of the default 394resource value. 395If <emphasis remap='I'>default_type</emphasis> is different from <emphasis remap='I'>resource_type</emphasis> and the default value 396is needed, 397the resource manager invokes a conversion procedure from <emphasis remap='I'>default_type</emphasis> 398to <emphasis remap='I'>resource_type</emphasis>. 399Whenever possible, 400the default type should be identical to the resource type in order 401to minimize widget creation time. 402However, there are sometimes no values of the type that the program 403can easily specify. 404In this case, 405it should be a value for which the converter is guaranteed to work (for example, 406<function>XtDefaultForeground</function> 407for a pixel resource). 408The <emphasis remap='I'>default_addr</emphasis> field specifies the address of the default resource value. 409As a special case, if <emphasis remap='I'>default_type</emphasis> is 410<function>XtRString</function>, 411then the value in the <emphasis remap='I'>default_addr</emphasis> field is the pointer to 412the string rather than a pointer to the pointer. 413The default is used if a resource is not specified in the argument list 414or in the resource database or if the conversion from the representation 415type stored in the resource database fails, 416which can happen for various reasons (for example, a misspelled entry in a 417resource file). 418</para> 419 420<para> 421Two special representation types 422(XtRImmediate 423and 424XtRCallProc) 425are usable only as default resource types. 426XtRImmediate 427indicates that the value in the <emphasis remap='I'>default_addr</emphasis> field is the actual value of 428the resource rather than the address of the value. 429The value must be in the correct representation type for the resource, 430coerced to an 431<function>XtPointer</function>. 432No conversion is possible, since there is no source representation type. 433XtRCallProc 434indicates that the value in the <emphasis remap='I'>default_addr</emphasis> field is a procedure 435pointer. 436This procedure is automatically invoked with the widget, 437<emphasis remap='I'>resource_offset</emphasis>, and a pointer to an 438<function>XrmValue</function> 439in which to store the result. 440XtRCallProc 441procedure pointers are of type 442<xref linkend='XtResourceDefaultProc' xrefstyle='select: title'/>. 443</para> 444 445<funcsynopsis id='XtResourceDefaultProc'> 446<funcprototype> 447<funcdef>typedef void <function>(*XtResourceDefaultProc)</function></funcdef> 448 <paramdef>Widget <parameter>w</parameter></paramdef> 449 <paramdef>int <parameter>offset</parameter></paramdef> 450 <paramdef>XrmValue *<parameter>value</parameter></paramdef> 451</funcprototype> 452</funcsynopsis> 453 454<variablelist> 455 <varlistentry> 456 <term> 457 <emphasis remap='I'>w</emphasis> 458 </term> 459 <listitem> 460 <para> 461Specifies the widget whose resource value is to be obtained. 462 </para> 463 </listitem> 464 </varlistentry> 465 <varlistentry> 466 <term> 467 <emphasis remap='I'>offset</emphasis> 468 </term> 469 <listitem> 470 <para> 471Specifies the offset of the field in the widget record. 472 </para> 473 </listitem> 474 </varlistentry> 475 <varlistentry> 476 <term> 477 <emphasis remap='I'>value</emphasis> 478 </term> 479 <listitem> 480 <para> 481Specifies the resource value descriptor to return. 482 </para> 483 </listitem> 484 </varlistentry> 485</variablelist> 486 487<para> 488The 489<xref linkend='XtResourceDefaultProc' xrefstyle='select: title'/> 490procedure should fill in the <emphasis remap='I'>value->addr</emphasis> field with a pointer 491to the resource value in its correct representation type. 492</para> 493 494<para> 495To get the resource list structure for a particular class, use 496<xref linkend='XtGetResourceList' xrefstyle='select: title'/>. 497</para> 498 499<funcsynopsis id='XtGetResourceList'> 500<funcprototype> 501<funcdef>void <function>XtGetResourceList</function></funcdef> 502 503 <paramdef>WidgetClass <parameter>class</parameter></paramdef> 504 <paramdef>XtResourceList *<parameter>resources_return</parameter></paramdef> 505 <paramdef>Cardinal *<parameter>num_resources_return</parameter></paramdef> 506</funcprototype> 507</funcsynopsis> 508 509<variablelist> 510 <varlistentry> 511 <term> 512 <emphasis remap='I'>class</emphasis> 513 </term> 514 <listitem> 515 <para> 516Specifies the object class to be queried. It must be 517<function>objectClass</function> 518or any subclass thereof. 519 </para> 520 </listitem> 521 </varlistentry> 522 <varlistentry> 523 <term> 524 <emphasis remap='I'>resources_return</emphasis> 525 </term> 526 <listitem> 527 <para> 528Returns the resource list. 529 </para> 530 </listitem> 531 </varlistentry> 532 <varlistentry> 533 <term> 534 <emphasis remap='I'>num_resources_return</emphasis> 535 </term> 536 <listitem> 537 <para> 538Returns the number of entries in the resource list. 539 </para> 540 </listitem> 541 </varlistentry> 542</variablelist> 543 544<para> 545If 546<xref linkend='XtGetResourceList' xrefstyle='select: title'/> 547is called before the class is initialized, 548it returns the resource list as specified in the class record. 549If it is called after the class has been initialized, 550<xref linkend='XtGetResourceList' xrefstyle='select: title'/> 551returns a merged resource list that includes the resources 552for all superclasses. 553The list returned by 554<xref linkend='XtGetResourceList' xrefstyle='select: title'/> 555should be freed using 556<xref linkend='XtFree' xrefstyle='select: title'/> 557when it is no longer needed. 558</para> 559 560<para> 561To get the constraint resource list structure for a particular widget 562class, use 563<xref linkend='XtGetConstraintResourceList' xrefstyle='select: title'/>. 564</para> 565 566<funcsynopsis id='XtGetConstraintResourceList'> 567<funcprototype> 568<funcdef>void <function>XtGetConstraintResourceList</function></funcdef> 569 <paramdef>WidgetClass <parameter>class</parameter></paramdef> 570 <paramdef>XtResourceList *<parameter>resources_return</parameter></paramdef> 571 <paramdef>Cardinal *<parameter>num_resources_return</parameter></paramdef> 572</funcprototype> 573</funcsynopsis> 574 575<variablelist> 576 <varlistentry> 577 <term> 578 <emphasis remap='I'>class</emphasis> 579 </term> 580 <listitem> 581 <para> 582Specifies the object class to be queried. It must be 583<function>objectClass</function> 584or any subclass thereof. 585 </para> 586 </listitem> 587 </varlistentry> 588 <varlistentry> 589 <term> 590 <emphasis remap='I'>resources_return</emphasis> 591 </term> 592 <listitem> 593 <para> 594Returns the constraint resource list. 595 </para> 596 </listitem> 597 </varlistentry> 598 <varlistentry> 599 <term> 600 <emphasis remap='I'>num_resources_return</emphasis> 601 </term> 602 <listitem> 603 <para> 604Returns the number of entries in the constraint resource list. 605 </para> 606 </listitem> 607 </varlistentry> 608</variablelist> 609 610<para> 611If 612<xref linkend='XtGetConstraintResourceList' xrefstyle='select: title'/> 613is called before the widget class is 614initialized, the resource list as specified in the widget 615class Constraint part is returned. If 616<xref linkend='XtGetConstraintResourceList' xrefstyle='select: title'/> 617is called after the widget class has been initialized, the merged 618resource list for the class and all Constraint superclasses is 619returned. If the 620specified class is not a subclass of 621<function>constraintWidgetClass</function>, 622*<emphasis remap='I'>resources_return</emphasis> is set to NULL 623and *<emphasis remap='I'>num_resources_return</emphasis> is set to zero. 624The list returned by 625<xref linkend='XtGetConstraintResourceList' xrefstyle='select: title'/> 626should be freed using 627<xref linkend='XtFree' xrefstyle='select: title'/> 628when it is no longer needed. 629</para> 630 631<para> 632The routines 633<xref linkend='XtSetValues' xrefstyle='select: title'/> 634and 635<xref linkend='XtGetValues' xrefstyle='select: title'/> 636also use the resource list to set and get widget state; 637see <xref linkend='Obtaining_Widget_State' /> and 638<xref linkend='Setting_Widget_State' />. 639</para> 640 641<para> 642Here is an abbreviated version of a possible resource list for a Label widget: 643</para> 644<programlisting> 645/* Resources specific to Label */ 646static XtResource resources[] = { 647{XtNforeground, XtCForeground, XtRPixel, sizeof(Pixel), 648 XtOffsetOf(LabelRec, label.foreground), XtRString, XtDefaultForeground}, 649{XtNfont, XtCFont, XtRFontStruct, sizeof(XFontStruct*), 650 XtOffsetOf(LabelRec, label.font), XtRString, XtDefaultFont}, 651{XtNlabel, XtCLabel, XtRString, sizeof(String), 652 XtOffsetOf(LabelRec, label.label), XtRString, NULL}, 653 . 654 . 655 . 656} 657</programlisting> 658<para> 659The complete resource name for a field of a widget instance is the 660concatenation of the application shell name (from 661<function>XtAppCreateShell</function>), 662the instance names of all the widget's parents up to the 663top of the widget tree, 664the instance name of the widget itself, 665and the resource name of the specified field of the widget. 666Similarly, 667the full resource class of a field of a widget instance is the 668concatenation of the application class (from 669<function>XtAppCreateShell</function>), 670the widget class names of all the widget's parents up to the 671top of the widget tree, 672the widget class name of the widget itself, 673and the resource class of the specified field of the widget. 674</para> 675</sect1> 676 677<sect1 id="Byte_Offset_Calculations"> 678<title>Byte Offset Calculations</title> 679<para> 680To determine the byte offset of a field within a structure type, use 681<xref linkend='XtOffsetOf' xrefstyle='select: title'/>. 682</para> 683 684<funcsynopsis id='XtOffsetOf'> 685<funcprototype> 686<funcdef>Cardinal <function>XtOffsetOf</function></funcdef> 687 <paramdef>Type <parameter>structure_type</parameter></paramdef> 688 <paramdef>Field <parameter>field_name</parameter></paramdef> 689</funcprototype> 690</funcsynopsis> 691 692 693 694<variablelist> 695 <varlistentry> 696 <term> 697 <emphasis remap='I'>structure_type</emphasis> 698 </term> 699 <listitem> 700 <para> 701Specifies a type that is declared as a structure. 702 </para> 703 </listitem> 704 </varlistentry> 705 <varlistentry> 706 <term> 707 <emphasis remap='I'>field_name</emphasis> 708 </term> 709 <listitem> 710 <para> 711Specifies the name of a member within the structure. 712 </para> 713 </listitem> 714 </varlistentry> 715</variablelist> 716 717<para> 718The 719<xref linkend='XtOffsetOf' xrefstyle='select: title'/> 720macro expands to a constant expression that gives the 721offset in bytes to the specified structure member from the beginning 722of the structure. It is normally used to statically initialize 723resource lists and is more portable than 724<xref linkend='XtOffset' xrefstyle='select: title'/>, 725which serves the same function. 726</para> 727 728<para> 729To determine the byte offset of a field within a structure pointer type, use 730<xref linkend='XtOffset' xrefstyle='select: title'/>. 731</para> 732 733<funcsynopsis id='XtOffset'> 734<funcprototype> 735<funcdef>Cardinal <function>XtOffset</function></funcdef> 736 <paramdef>Type <parameter> pointer_type</parameter></paramdef> 737 <paramdef>Field <parameter> field_name</parameter></paramdef> 738</funcprototype> 739</funcsynopsis> 740 741<variablelist> 742 <varlistentry> 743 <term> 744 <emphasis remap='I'>pointer_type</emphasis> 745 </term> 746 <listitem> 747 <para> 748Specifies a type that is declared as a pointer to a structure. 749 </para> 750 </listitem> 751 </varlistentry> 752 <varlistentry> 753 <term> 754 <emphasis remap='I'>field_name</emphasis> 755 </term> 756 <listitem> 757 <para> 758Specifies the name of a member within the structure. 759 </para> 760 </listitem> 761 </varlistentry> 762</variablelist> 763 764<para> 765The 766<xref linkend='XtOffset' xrefstyle='select: title'/> 767macro expands to a constant expression that gives the 768offset in bytes to the specified structure member from the beginning 769of the structure. It may be used to statically initialize 770resource lists. 771<xref linkend='XtOffset' xrefstyle='select: title'/> 772is less portable than 773<xref linkend='XtOffsetOf' xrefstyle='select: title'/>. 774</para> 775</sect1> 776 777<sect1 id="Superclass_to_Subclass_Chaining_of_Resource_Lists"> 778<title>Superclass-to-Subclass Chaining of Resource Lists</title> 779<para> 780The 781<xref linkend='XtCreateWidget' xrefstyle='select: title'/> 782function gets resources as a superclass-to-subclass chained operation. 783That is, the resources specified in the 784<function>objectClass</function> 785resource list are fetched, 786then those in 787<function>rectObjClass</function>, 788and so on down to the resources specified 789for this widget's class. Within a class, resources are fetched in the order 790they are declared. 791</para> 792 793<para> 794In general, if a widget resource field is declared in a superclass, 795that field is included in the superclass's resource list and need not be 796included in the subclass's resource list. 797For example, the 798Core 799class contains a resource entry for <emphasis remap='I'>background_pixel</emphasis>. 800Consequently, 801the implementation of Label need not also have a resource entry 802for <emphasis remap='I'>background_pixel</emphasis>. 803However, a subclass, 804by specifying a resource entry for that field in its own resource list, 805can override the resource entry for any field declared in a superclass. 806This is most often done to override the defaults provided in the 807superclass with new ones. 808At class initialization time, 809resource lists for that class are scanned from the superclass down 810to the class to look for resources with the same offset. 811A matching resource in a subclass will be reordered to override 812the superclass entry. 813If reordering is necessary, a copy of the superclass resource list is made to 814avoid affecting other subclasses of the superclass. 815</para> 816 817<para> 818Also at class initialization time, the Intrinsics produce an 819internal representation of the resource list to optimize access time 820when creating widgets. In order to save memory, the Intrinsics may 821overwrite the storage allocated for the resource list in the class 822record; therefore, widgets must allocate resource lists in writable 823storage and must not access the list contents directly after the 824class_initialize procedure has returned. 825</para> 826</sect1> 827 828<sect1 id="Subresources"> 829<title>Subresources</title> 830<para> 831A widget does not do anything to retrieve its own resources; 832instead, 833<xref linkend='XtCreateWidget' xrefstyle='select: title'/> 834does this automatically before calling the class initialize procedure. 835</para> 836 837<para> 838Some widgets have subparts that are not widgets but for which the widget 839would like to fetch resources. 840Such widgets call 841<xref linkend='XtGetSubresources' xrefstyle='select: title'/> 842to accomplish this. 843</para> 844 845<funcsynopsis id='XtGetSubresources'> 846<funcprototype> 847<funcdef>void <function>XtGetSubresources</function></funcdef> 848 <paramdef>Widget <parameter>w</parameter></paramdef> 849 <paramdef>XtPointer <parameter>base</parameter></paramdef> 850 <paramdef>const char * <parameter>name</parameter></paramdef> 851 <paramdef>const char * <parameter>class</parameter></paramdef> 852 <paramdef>XtResourceList <parameter>resources</parameter></paramdef> 853 <paramdef>Cardinal <parameter>num_resources</parameter></paramdef> 854 <paramdef>ArgList <parameter>args</parameter></paramdef> 855 <paramdef>Cardinal <parameter>num_args</parameter></paramdef> 856</funcprototype> 857</funcsynopsis> 858 859<variablelist> 860 <varlistentry> 861 <term> 862 <emphasis remap='I'>w</emphasis> 863 </term> 864 <listitem> 865 <para> 866Specifies the object used to qualify the subpart resource name and 867class. Must be of class Object or any subclass thereof. 868 </para> 869 </listitem> 870 </varlistentry> 871 <varlistentry> 872 <term> 873 <emphasis remap='I'>base</emphasis> 874 </term> 875 <listitem> 876 <para> 877Specifies the base address of the subpart data structure into which the 878resources will be written. 879 </para> 880 </listitem> 881 </varlistentry> 882 <varlistentry> 883 <term> 884 <emphasis remap='I'>name</emphasis> 885 </term> 886 <listitem> 887 <para> 888Specifies the name of the subpart. 889 </para> 890 </listitem> 891 </varlistentry> 892 <varlistentry> 893 <term> 894 <emphasis remap='I'>class</emphasis> 895 </term> 896 <listitem> 897 <para> 898Specifies the class of the subpart. 899 </para> 900 </listitem> 901 </varlistentry> 902 <varlistentry> 903 <term> 904 <emphasis remap='I'>resources</emphasis> 905 </term> 906 <listitem> 907 <para> 908Specifies the resource list for the subpart. 909 </para> 910 </listitem> 911 </varlistentry> 912 <varlistentry> 913 <term> 914 <emphasis remap='I'>num_resources</emphasis> 915 </term> 916 <listitem> 917 <para> 918Specifies the number of entries in the resource list. 919 </para> 920 </listitem> 921 </varlistentry> 922 <varlistentry> 923 <term> 924 <emphasis remap='I'>args</emphasis> 925 </term> 926 <listitem> 927 <para> 928Specifies the argument list to override any other resource specifications. 929 </para> 930 </listitem> 931 </varlistentry> 932 <varlistentry> 933 <term> 934 <emphasis remap='I'>num_args</emphasis> 935 </term> 936 <listitem> 937 <para> 938Specifies the number of entries in the argument list. 939 </para> 940 </listitem> 941 </varlistentry> 942</variablelist> 943 944<para> 945The 946<xref linkend='XtGetSubresources' xrefstyle='select: title'/> 947function constructs a name and class list from the application name and class, 948the names and classes of all the object's ancestors, and the object itself. 949Then it appends to this list the <emphasis remap='I'>name</emphasis> and <emphasis remap='I'>class</emphasis> pair passed in. 950The resources are fetched from the argument list, the resource database, 951or the default values in the resource list. 952Then they are copied into the subpart record. 953If <emphasis remap='I'>args</emphasis> is NULL, 954<emphasis remap='I'>num_args</emphasis> must be zero. 955However, if <emphasis remap='I'>num_args</emphasis> is zero, 956the argument list is not referenced. 957</para> 958 959<para> 960<xref linkend='XtGetSubresources' xrefstyle='select: title'/> 961may overwrite the specified resource list with an 962equivalent representation in an internal format, which optimizes access 963time if the list is used repeatedly. The resource list must be 964allocated in writable storage, and the caller must not modify the list 965contents after the call if the same list is to be used again. 966Resources fetched by 967<xref linkend='XtGetSubresources' xrefstyle='select: title'/> 968are reference-counted as 969if they were referenced by the specified object. Subresources might 970therefore be freed from the conversion cache and destroyed 971when the object is destroyed, but not before then. 972</para> 973 974<para> 975To fetch resources for widget subparts using varargs lists, use 976<xref linkend='XtVaGetSubresources' xrefstyle='select: title'/>. 977</para> 978 979<funcsynopsis id='XtVaGetSubresources'> 980<funcprototype> 981<funcdef>void <function>XtVaGetSubresources</function></funcdef> 982 <paramdef>Widget <parameter>w</parameter></paramdef> 983 <paramdef>XtPointer <parameter>base</parameter></paramdef> 984 <paramdef>const char * <parameter>name</parameter></paramdef> 985 <paramdef>const char * <parameter>class</parameter></paramdef> 986 <paramdef>XtResourceList <parameter>resources</parameter></paramdef> 987 <paramdef>Cardinal <parameter>num_resources</parameter></paramdef> 988 <paramdef>...</paramdef> 989</funcprototype> 990</funcsynopsis> 991 992<variablelist> 993 <varlistentry> 994 <term> 995 <emphasis remap='I'>w</emphasis> 996 </term> 997 <listitem> 998 <para> 999Specifies the object used to qualify the subpart resource name and 1000class. Must be of class Object or any subclass thereof. 1001 </para> 1002 </listitem> 1003 </varlistentry> 1004 <varlistentry> 1005 <term> 1006 <emphasis remap='I'>base</emphasis> 1007 </term> 1008 <listitem> 1009 <para> 1010Specifies the base address of the subpart data structure into which the 1011resources will be written. 1012 </para> 1013 </listitem> 1014 </varlistentry> 1015 <varlistentry> 1016 <term> 1017 <emphasis remap='I'>name</emphasis> 1018 </term> 1019 <listitem> 1020 <para> 1021Specifies the name of the subpart. 1022 </para> 1023 </listitem> 1024 </varlistentry> 1025 <varlistentry> 1026 <term> 1027 <emphasis remap='I'>class</emphasis> 1028 </term> 1029 <listitem> 1030 <para> 1031Specifies the class of the subpart. 1032 </para> 1033 </listitem> 1034 </varlistentry> 1035 <varlistentry> 1036 <term> 1037 <emphasis remap='I'>resources</emphasis> 1038 </term> 1039 <listitem> 1040 <para> 1041Specifies the resource list for the subpart. 1042 </para> 1043 </listitem> 1044 </varlistentry> 1045 <varlistentry> 1046 <term> 1047 <emphasis remap='I'>num_resources</emphasis> 1048 </term> 1049 <listitem> 1050 <para> 1051Specifies the number of entries in the resource list. 1052 </para> 1053 </listitem> 1054 </varlistentry> 1055 <varlistentry> 1056 <term> 1057 ... 1058 </term> 1059 <listitem> 1060 <para> 1061Specifies the variable argument list to override any other 1062resource specifications. 1063 </para> 1064 </listitem> 1065 </varlistentry> 1066</variablelist> 1067 1068<para> 1069<xref linkend='XtVaGetSubresources' xrefstyle='select: title'/> 1070is identical in function to 1071<xref linkend='XtGetSubresources' xrefstyle='select: title'/> 1072with the <emphasis remap='I'>args</emphasis> and <emphasis remap='I'>num_args</emphasis> parameters replaced by a varargs list, as 1073described in Section 2.5.1. 1074</para> 1075</sect1> 1076 1077<sect1 id="Obtaining_Application_Resources"> 1078<title>Obtaining Application Resources</title> 1079<para> 1080To retrieve resources that are not specific to a widget 1081but apply to the overall application, use 1082<xref linkend='XtGetApplicationResources' xrefstyle='select: title'/>. 1083</para> 1084 1085<funcsynopsis id='XtGetApplicationResources'> 1086<funcprototype> 1087<funcdef>void <function>XtGetApplicationResources</function></funcdef> 1088 <paramdef>Widget <parameter>w</parameter></paramdef> 1089 <paramdef>XtPointer <parameter>base</parameter></paramdef> 1090 <paramdef>XtResourceList <parameter>resources</parameter></paramdef> 1091 <paramdef>Cardinal <parameter>num_resources</parameter></paramdef> 1092 <paramdef>ArgList <parameter>args</parameter></paramdef> 1093 <paramdef>Cardinal <parameter>num_args</parameter></paramdef> 1094</funcprototype> 1095</funcsynopsis> 1096 1097<variablelist> 1098 <varlistentry> 1099 <term> 1100 <emphasis remap='I'>w</emphasis> 1101 </term> 1102 <listitem> 1103 <para> 1104Specifies the object that identifies the resource database to search 1105(the database is that associated with the display for this object). Must be of class Object or any subclass thereof. 1106 </para> 1107 </listitem> 1108 </varlistentry> 1109 <varlistentry> 1110 <term> 1111 <emphasis remap='I'>base</emphasis> 1112 </term> 1113 <listitem> 1114 <para> 1115Specifies the base address into which 1116the resource values will be written. 1117 </para> 1118 </listitem> 1119 </varlistentry> 1120 <varlistentry> 1121 <term> 1122 <emphasis remap='I'>resources</emphasis> 1123 </term> 1124 <listitem> 1125 <para> 1126Specifies the resource list. 1127 </para> 1128 </listitem> 1129 </varlistentry> 1130 <varlistentry> 1131 <term> 1132 <emphasis remap='I'>num_resources</emphasis> 1133 </term> 1134 <listitem> 1135 <para> 1136Specifies the number of entries in the resource list. 1137 </para> 1138 </listitem> 1139 </varlistentry> 1140 <varlistentry> 1141 <term> 1142 <emphasis remap='I'>args</emphasis> 1143 </term> 1144 <listitem> 1145 <para> 1146Specifies the argument list to override any other resource specifications. 1147 </para> 1148 </listitem> 1149 </varlistentry> 1150 <varlistentry> 1151 <term> 1152 <emphasis remap='I'>num_args</emphasis> 1153 </term> 1154 <listitem> 1155 <para> 1156Specifies the number of entries in the argument list. 1157 </para> 1158 </listitem> 1159 </varlistentry> 1160</variablelist> 1161 1162<para> 1163The 1164<xref linkend='XtGetApplicationResources' xrefstyle='select: title'/> 1165function first uses the passed object, 1166which is usually an application shell widget, 1167to construct a resource name and class list. 1168The full name and class of the specified object (that is, including its 1169ancestors, if any) is logically added to the 1170front of each resource name and class. 1171Then it retrieves the resources from the argument list, 1172the resource database, or the resource list default values. 1173After adding base to each address, 1174<xref linkend='XtGetApplicationResources' xrefstyle='select: title'/> 1175copies the resources into the addresses 1176obtained by adding <emphasis remap='I'>base</emphasis> to each <emphasis remap='I'>offset</emphasis> in the resource list. 1177If <emphasis remap='I'>args</emphasis> is NULL, 1178<emphasis remap='I'>num_args</emphasis> must be zero. 1179However, if <emphasis remap='I'>num_args</emphasis> is zero, 1180the argument list is not referenced. 1181The portable way to specify application resources is to declare them 1182as members of a structure and pass the address of the structure 1183as the <emphasis remap='I'>base</emphasis> argument. 1184</para> 1185 1186<para> 1187<xref linkend='XtGetApplicationResources' xrefstyle='select: title'/> 1188may overwrite the specified resource list 1189with an equivalent representation in an internal format, which 1190optimizes access time if the list is used repeatedly. The resource 1191list must be allocated in writable storage, and the caller must not 1192modify the list contents after the call if the same list is to be 1193used again. Any per-display resources fetched by 1194<xref linkend='XtGetApplicationResources' xrefstyle='select: title'/> 1195will not be freed from the resource cache until the display is closed. 1196</para> 1197 1198<para> 1199To retrieve resources for the overall application using varargs lists, use 1200<xref linkend='XtVaGetApplicationResources' xrefstyle='select: title'/>. 1201</para> 1202 1203<funcsynopsis id='XtVaGetApplicationResources'> 1204<funcprototype> 1205<funcdef>void <function>XtVaGetApplicationResources</function></funcdef> 1206 <paramdef>Widget <parameter>w</parameter></paramdef> 1207 <paramdef>XtPointer <parameter>base</parameter></paramdef> 1208 <paramdef>XtResourceList <parameter>resources</parameter></paramdef> 1209 <paramdef>Cardinal <parameter>num_resources</parameter></paramdef> 1210 <paramdef>...</paramdef> 1211</funcprototype> 1212</funcsynopsis> 1213 1214<variablelist> 1215 <varlistentry> 1216 <term> 1217 <emphasis remap='I'>w</emphasis> 1218 </term> 1219 <listitem> 1220 <para> 1221Specifies the object that identifies the resource database to search 1222(the database is that associated with the display for this object). Must be of class Object or any subclass thereof. 1223 </para> 1224 </listitem> 1225 </varlistentry> 1226 <varlistentry> 1227 <term> 1228 <emphasis remap='I'>base</emphasis> 1229 </term> 1230 <listitem> 1231 <para> 1232Specifies the base address into which 1233the resource values will be written. 1234 </para> 1235 </listitem> 1236 </varlistentry> 1237 <varlistentry> 1238 <term> 1239 <emphasis remap='I'>resources</emphasis> 1240 </term> 1241 <listitem> 1242 <para> 1243Specifies the resource list for the subpart. 1244 </para> 1245 </listitem> 1246 </varlistentry> 1247 <varlistentry> 1248 <term> 1249 <emphasis remap='I'>num_resources</emphasis> 1250 </term> 1251 <listitem> 1252 <para> 1253Specifies the number of entries in the resource list. 1254 </para> 1255 </listitem> 1256 </varlistentry> 1257 <varlistentry> 1258 <term> 1259 ... 1260 </term> 1261 <listitem> 1262 <para> 1263Specifies the variable argument list to override any other 1264resource specifications. 1265 </para> 1266 </listitem> 1267 </varlistentry> 1268</variablelist> 1269 1270<para> 1271<xref linkend='XtVaGetApplicationResources' xrefstyle='select: title'/> 1272is identical in function to 1273<xref linkend='XtGetApplicationResources' xrefstyle='select: title'/> 1274with the <emphasis remap='I'>args</emphasis> and <emphasis remap='I'>num_args</emphasis> parameters 1275replaced by a varargs list, as described in Section 2.5.1. 1276</para> 1277</sect1> 1278 1279<sect1 id="Resource_Conversions"> 1280<title>Resource Conversions</title> 1281<para> 1282The Intrinsics provide a mechanism for registering representation converters that 1283are automatically invoked by the resource-fetching routines. 1284The Intrinsics additionally provide and register several commonly used converters. 1285This resource conversion mechanism serves several purposes: 1286</para> 1287<itemizedlist spacing='compact'> 1288 <listitem> 1289 <para> 1290It permits user and application resource files to contain textual 1291representations of nontextual values. 1292 </para> 1293 </listitem> 1294 <listitem> 1295 <para> 1296It allows textual or other representations of default resource values that 1297are dependent on the display, screen, or colormap, and thus must be 1298computed at runtime. 1299 </para> 1300 </listitem> 1301 <listitem> 1302 <para> 1303It caches conversion source and result data. 1304Conversions that require much computation or space 1305(for example, string-to-translation-table) 1306or that require round-trips to the server 1307(for example, string-to-font or string-to-color) are performed only once. 1308 </para> 1309 </listitem> 1310</itemizedlist> 1311<sect2 id="Predefined_Resource_Converters"> 1312<title>Predefined Resource Converters</title> 1313<para> 1314The Intrinsics define all the representations used in the 1315Object, 1316RectObj, 1317Core, 1318Composite, 1319Constraint, 1320and 1321Shell 1322widget classes. 1323The Intrinsics register the following resource converters that accept 1324input values of representation type 1325<function>XtRString</function>. 1326</para> 1327 1328<informaltable frame='topbot'> 1329 <?dbfo keep-together="auto" ?> 1330 <tgroup cols='3' align='left' rowsep='0' colsep='0'> 1331 <colspec colwidth='0.7*' colname='c1'/> 1332 <colspec colwidth='1.0*' colname='c2'/> 1333 <colspec colwidth='0.6*' colname='c3'/> 1334 <thead> 1335 <row rowsep='1'> 1336 <entry>Target Representation</entry> 1337 <entry>Converter Name</entry> 1338 <entry>Additional Args</entry> 1339 </row> 1340 </thead> 1341 <tbody> 1342 <row> 1343 <entry><function>XtRAcceleratorTable</function></entry> 1344 <entry><function>XtCvtStringToAcceleratorTable</function></entry> 1345 </row> 1346 <row> 1347 <entry><function>XtRAtom</function></entry> 1348 <entry><function>XtCvtStringToAtom</function></entry> 1349 <entry>Display*</entry> 1350 </row> 1351 <row> 1352 <entry><function>XtRBoolean</function></entry> 1353 <entry><function>XtCvtStringToBoolean</function></entry> 1354 </row> 1355 <row> 1356 <entry><function>XtRBool</function></entry> 1357 <entry><function>XtCvtStringToBool</function></entry> 1358 </row> 1359 <row> 1360 <entry><function>XtRCommandArgArray</function></entry> 1361 <entry><function>XtCvtStringToCommandArgArray</function></entry> 1362 </row> 1363 <row> 1364 <entry><function>XtRCursor</function></entry> 1365 <entry><function>XtCvtStringToCursor</function></entry> 1366 <entry>Display*</entry> 1367 </row> 1368 <row> 1369 <entry><function>XtRDimension</function></entry> 1370 <entry><function>XtCvtStringToDimension</function></entry> 1371 </row> 1372 <row> 1373 <entry><function>XtRDirectoryString</function></entry> 1374 <entry><function>XtCvtStringToDirectoryString</function></entry> 1375 </row> 1376 <row> 1377 <entry><function>XtRDisplay</function></entry> 1378 <entry><function>XtCvtStringToDisplay</function></entry> 1379 </row> 1380 <row> 1381 <entry><function>XtRFile</function></entry> 1382 <entry><function>XtCvtStringToFile</function></entry> 1383 </row> 1384 <row> 1385 <entry><function>XtRFloat</function></entry> 1386 <entry><function>XtCvtStringToFloat</function></entry> 1387 </row> 1388 <row> 1389 <entry><function>XtRFont</function></entry> 1390 <entry><function>XtCvtStringToFont</function></entry> 1391 <entry>Display*</entry> 1392 </row> 1393 <row> 1394 <entry><function>XtRFontSet</function></entry> 1395 <entry><function>XtCvtStringToFontSet</function></entry> 1396 <entry>Display*, String <emphasis remap='I'>locale</emphasis></entry> 1397 </row> 1398 <row> 1399 <entry><function>XtRFontStruct</function></entry> 1400 <entry><function>XtCvtStringToFontStruct</function></entry> 1401 <entry>Display*</entry> 1402 </row> 1403 <row> 1404 <entry><function>XtRGravity</function></entry> 1405 <entry><function>XtCvtStringToGravity</function></entry> 1406 </row> 1407 <row> 1408 <entry><function>XtRInitialState</function></entry> 1409 <entry><function>XtCvtStringToInitialState</function></entry> 1410 </row> 1411 <row> 1412 <entry><function>XtRInt</function></entry> 1413 <entry><function>XtCvtStringToInt</function></entry> 1414 </row> 1415 <row> 1416 <entry><function>XtRPixel</function></entry> 1417 <entry><function>XtCvtStringToPixel</function></entry> 1418 <entry><function>colorConvertArgs</function></entry> 1419 </row> 1420 <row> 1421 <entry><function>XtRPosition</function></entry> 1422 <entry><function>XtCvtStringToPosition</function></entry> 1423 </row> 1424 <row> 1425 <entry><function>XtRRestartStyle</function></entry> 1426 <entry><function>XtCvtStringToRestartStyle</function></entry> 1427 </row> 1428 <row> 1429 <entry><function>XtRShort</function></entry> 1430 <entry><function>XtCvtStringToShort</function></entry> 1431 </row> 1432 <row> 1433 <entry><function>XtRTranslationTable</function></entry> 1434 <entry><function>XtCvtStringToTranslationTable</function></entry> 1435 </row> 1436 <row> 1437 <entry><function>XtRUnsignedChar</function></entry> 1438 <entry><function>XtCvtStringToUnsignedChar</function></entry> 1439 </row> 1440 <row> 1441 <entry><function>XtRVisual</function></entry> 1442 <entry><function>XtCvtStringToVisual</function></entry> 1443 <entry>Screen*, Cardinal <emphasis remap='I'>depth</emphasis></entry> 1444 </row> 1445 </tbody> 1446 </tgroup> 1447</informaltable> 1448 1449<para> 1450The String-to-Pixel conversion has two predefined constants that are 1451guaranteed to work and contrast with each other: 1452<function>XtDefaultForeground</function> 1453and 1454<function>XtDefaultBackground</function>. 1455They evaluate to the black and white pixel values of the widget's screen, 1456respectively. 1457If the application resource reverseVideo is 1458<function>True</function>, 1459they evaluate to the white and black pixel values of the widget's screen, 1460respectively. 1461Similarly, the String-to-Font and String-to-FontStruct converters recognize 1462the constant 1463<function>XtDefaultFont</function> 1464and evaluate this in the following manner: 1465</para> 1466<itemizedlist spacing='compact'> 1467 <listitem> 1468 <para> 1469Query the resource database for the resource whose full name 1470is “xtDefaultFont”, class “XtDefaultFont” (that is, no widget 1471name/class prefixes), and use a type 1472<function>XtRString</function> 1473value returned as the font name or a type 1474<function>XtRFont</function> 1475or 1476<function>XtRFontStruct</function> 1477value directly as the resource value. 1478 </para> 1479 </listitem> 1480 <listitem> 1481 <para> 1482If the resource database does not contain a value for xtDefaultFont, 1483class XtDefaultFont, or if the returned font name cannot be 1484successfully opened, an implementation-defined font in ISO8859-1 1485character set encoding is opened. (One possible algorithm is to 1486perform an 1487<function>XListFonts</function> 1488using a wildcard font name and use the first 1489font in the list. This wildcard font name should be as broad as 1490possible to maximize the probability of locating a usable font; 1491for example, “<code>-*-*-*-R-*-*-*-120-*-*-*-*-ISO8859-1</code>”.) 1492 </para> 1493 </listitem> 1494 <listitem> 1495 <para> 1496If no suitable ISO8859-1 font can be found, issue a warning message 1497and return 1498<function>False</function>. 1499 </para> 1500 </listitem> 1501</itemizedlist> 1502<para> 1503The String-to-FontSet converter recognizes the constant 1504<function>XtDefaultFontSet</function> 1505and evaluate this in the following manner: 1506</para> 1507<itemizedlist spacing='compact'> 1508 <listitem> 1509 <para> 1510Query the resource database for the resource whose full name 1511is “xtDefaultFontSet”, class “XtDefaultFontSet” (that is, no widget 1512name/class prefixes), and use a type 1513<function>XtRString</function> 1514value returned as the base font name list or a type 1515<function>XtRFontSet</function> 1516value directly as the resource value. 1517 </para> 1518 </listitem> 1519 <listitem> 1520 <para> 1521If the resource database does not contain a value for xtDefaultFontSet, 1522class XtDefaultFontSet, or if a font set cannot be 1523successfully created from this resource, 1524an implementation-defined font set is created. 1525(One possible algorithm is to 1526perform an 1527<function>XCreateFontSet</function> 1528using a wildcard base font name. 1529This wildcard base font name should be as broad as 1530possible to maximize the probability of locating a usable font; 1531for example, “<code>-*-*-*-R-*-*-*-120-*-*-*-*</code>”.) 1532 </para> 1533 </listitem> 1534 <listitem> 1535 <para> 1536If no suitable font set can be created, issue a warning message 1537and return 1538<function>False</function>. 1539 </para> 1540 </listitem> 1541</itemizedlist> 1542<para> 1543If a font set is created but <emphasis remap='I'>missing_charset_list</emphasis> is not 1544empty, a warning is issued and the partial font set is returned. 1545The Intrinsics register the String-to-FontSet converter with 1546a conversion argument list that extracts the current process 1547locale at the time the converter is invoked. This ensures 1548that the converter is invoked again if the same conversion 1549is required in a different locale. 1550</para> 1551 1552<para> 1553The String-to-Gravity conversion accepts string values that are the 1554names of window and bit gravities and their numerical equivalents, 1555as defined in <emphasis remap='I'>Xlib — C Language X Interface</emphasis>: 1556<function>ForgetGravity</function>, 1557<function>UnmapGravity</function>, 1558<function>NorthWestGravity</function>, 1559<function>NorthGravity</function>, 1560<function>NorthEastGravity</function>, 1561<function>WestGravity</function>, 1562<function>CenterGravity</function>, 1563<function>EastGravity</function>, 1564<function>SouthWestGravity</function>, 1565<function>SouthGravity</function>, 1566<function>SouthEastGravity</function>, 1567and 1568<function>StaticGravity</function>. 1569Alphabetic case is not significant in the conversion. 1570</para> 1571 1572<para> 1573The String-to-CommandArgArray conversion parses a String into an 1574array of strings. 1575White space characters separate elements of the command line. 1576The converter recognizes the backslash character “\” as an escape 1577character to allow the following white space character to be part of the 1578array element. 1579</para> 1580 1581<para> 1582The String-to-DirectoryString conversion recognizes the 1583string “XtCurrentDirectory” and returns the result of a call 1584to the operating system to get the current directory. 1585</para> 1586 1587<para> 1588The String-to-RestartStyle conversion accepts the values 1589<function>RestartIfRunning</function>, 1590<function>RestartAnyway</function>, 1591<function>RestartImmediately</function>, 1592and 1593<function>RestartNever</function> 1594as defined by the <emphasis remap='I'>X Session Management Protocol</emphasis>. 1595</para> 1596 1597<para> 1598The String-to-InitialState conversion accepts the values 1599<function>NormalState</function> 1600or 1601<function>IconicState</function> 1602as defined by the <emphasis remap='I'>Inter-Client Communication Conventions Manual</emphasis>. 1603</para> 1604 1605<para> 1606The String-to-Visual conversion calls 1607<function>XMatchVisualInfo</function> 1608using the 1609<emphasis remap='I'>screen</emphasis> and <emphasis remap='I'>depth</emphasis> fields from the core part and returns the first 1610matching Visual on the list. The widget resource list must be certain 1611to specify any resource of type 1612<function>XtRVisual</function> 1613after the depth resource. 1614The allowed string values are the visual class names defined in <emphasis remap='I'>X Window System Protocol</emphasis>, 1615Section 8; 1616<function>StaticGray</function>, 1617<function>StaticColor</function>, 1618<function>TrueColor</function>, 1619<function>GrayScale</function>, 1620<function>PseudoColor</function>, 1621and 1622<function>DirectColor</function>. 1623</para> 1624 1625<para> 1626The Intrinsics register the following resource converter that accepts 1627an input value of representation type 1628<function>XtRColor</function>. 1629</para> 1630 1631<informaltable frame='topbot'> 1632 <?dbfo keep-together="auto" ?> 1633 <tgroup cols='3' align='left' rowsep='0' colsep='0'> 1634 <colspec colwidth='1.0*' colname='c1'/> 1635 <colspec colwidth='1.0*' colname='c2'/> 1636 <colspec colwidth='1.0*' colname='c3'/> 1637 <thead> 1638 <row rowsep='1'> 1639 <entry>Target Representation</entry> 1640 <entry>Converter Name</entry> 1641 <entry>Additional Args</entry> 1642 </row> 1643 </thead> 1644 <tbody> 1645 <row> 1646 <entry><function>XtRPixel</function></entry> 1647 <entry><function>XtCvtColorToPixel</function></entry> 1648 </row> 1649 </tbody> 1650 </tgroup> 1651</informaltable> 1652 1653<para> 1654The Intrinsics register the following resource converters that accept 1655input values of representation type 1656<function>XtRInt</function>. 1657</para> 1658 1659<informaltable frame='topbot'> 1660 <?dbfo keep-together="auto" ?> 1661 <tgroup cols='3' align='left' rowsep='0' colsep='0'> 1662 <colspec colwidth='1.0*' colname='c1'/> 1663 <colspec colwidth='1.0*' colname='c2'/> 1664 <colspec colwidth='1.0*' colname='c3'/> 1665 <thead> 1666 <row rowsep='1'> 1667 <entry>Target Representation</entry> 1668 <entry>Converter Name</entry> 1669 <entry>Additional Args</entry> 1670 </row> 1671 </thead> 1672 <tbody> 1673 <row> 1674 <entry><function>XtRBoolean</function></entry> 1675 <entry><function>XtCvtIntToBoolean</function></entry> 1676 </row> 1677 <row> 1678 <entry><function>XtRBool</function></entry> 1679 <entry><function>XtCvtIntToBool</function></entry> 1680 </row> 1681 <row> 1682 <entry><function>XtRColor</function></entry> 1683 <entry><function>XtCvtIntToColor</function></entry> 1684 <entry><function>colorConvertArgs</function></entry> 1685 </row> 1686 <row> 1687 <entry><function>XtRDimension</function></entry> 1688 <entry><function>XtCvtIntToDimension</function></entry> 1689 </row> 1690 <row> 1691 <entry><function>XtRFloat</function></entry> 1692 <entry><function>XtCvtIntToFloat</function></entry> 1693 </row> 1694 <row> 1695 <entry><function>XtRFont</function></entry> 1696 <entry><function>XtCvtIntToFont</function></entry> 1697 </row> 1698 <row> 1699 <entry><function>XtRPixel</function></entry> 1700 <entry><function>XtCvtIntToPixel</function></entry> 1701 </row> 1702 <row> 1703 <entry><function>XtRPixmap</function></entry> 1704 <entry><function>XtCvtIntToPixmap</function></entry> 1705 </row> 1706 <row> 1707 <entry><function>XtRPosition</function></entry> 1708 <entry><function>XtCvtIntToPosition</function></entry> 1709 </row> 1710 <row> 1711 <entry><function>XtRShort</function></entry> 1712 <entry><function>XtCvtIntToShort</function></entry> 1713 </row> 1714 <row> 1715 <entry><function>XtRUnsignedChar</function></entry> 1716 <entry><function>XtCvtIntToUnsignedChar</function></entry> 1717 </row> 1718 </tbody> 1719 </tgroup> 1720</informaltable> 1721 1722<para> 1723The Intrinsics register the following resource converter that accepts 1724an input value of representation type 1725<function>XtRPixel</function>. 1726</para> 1727 1728<informaltable frame='topbot'> 1729 <?dbfo keep-together="auto" ?> 1730 <tgroup cols='3' align='left' rowsep='0' colsep='0'> 1731 <colspec colwidth='1.0*' colname='c1'/> 1732 <colspec colwidth='1.0*' colname='c2'/> 1733 <colspec colwidth='1.0*' colname='c3'/> 1734 <thead> 1735 <row rowsep='1'> 1736 <entry>Target Representation</entry> 1737 <entry>Converter Name</entry> 1738 <entry>Additional Args</entry> 1739 </row> 1740 </thead> 1741 <tbody> 1742 <row> 1743 <entry><function>XtRColor</function></entry> 1744 <entry><function>XtCvtPixelToColor</function></entry> 1745 </row> 1746 </tbody> 1747 </tgroup> 1748</informaltable> 1749</sect2> 1750 1751<sect2 id="New_Resource_Converters"> 1752<title>New Resource Converters</title> 1753<para> 1754Type converters use pointers to 1755<function>XrmValue</function> 1756structures (defined in 1757<filename class="headerfile"><X11/Xresource.h>;</filename> 1758see <olink targetdoc='libX11' targetptr='Creating_and_Storing_Databases'>Section 15.4</olink> in 1759<olink targetdoc='libX11' targetptr='libX11'>Xlib — C Language X Interface</olink>) 1760for input and output values. 1761</para> 1762<programlisting> 1763typedef struct { 1764 unsigned int size; 1765 XPointer addr; 1766} XrmValue, *XrmValuePtr; 1767</programlisting> 1768<para> 1769The <emphasis remap='I'>addr</emphasis> field specifies the address of the data, and the <emphasis remap='I'>size</emphasis> 1770field gives the total number of significant bytes in the data. 1771For values of type 1772<function>String</function>, 1773<emphasis remap='I'>addr</emphasis> is the address of the first character and <emphasis remap='I'>size</emphasis> 1774includes the NULL-terminating byte. 1775</para> 1776 1777<para> 1778A resource converter procedure pointer is of type 1779<xref linkend='XtTypeConverter' xrefstyle='select: title'/>. 1780</para> 1781 1782<funcsynopsis id='XtTypeConverter'> 1783<funcprototype> 1784<funcdef>typedef Boolean <function>(*XtTypeConverter)</function></funcdef> 1785 <paramdef>Display *<parameter>display</parameter></paramdef> 1786 <paramdef>XrmValue *<parameter>args</parameter></paramdef> 1787 <paramdef>Cardinal *<parameter>num_args</parameter></paramdef> 1788 <paramdef>XrmValue *<parameter>from</parameter></paramdef> 1789 <paramdef>XrmValue *<parameter>to</parameter></paramdef> 1790 <paramdef>XtPointer *<parameter>converter_data</parameter></paramdef> 1791</funcprototype> 1792</funcsynopsis> 1793 1794<variablelist> 1795 <varlistentry> 1796 <term> 1797 <emphasis remap='I'>display</emphasis> 1798 </term> 1799 <listitem> 1800 <para> 1801Specifies the display connection with which this conversion is associated. 1802 </para> 1803 </listitem> 1804 </varlistentry> 1805 <varlistentry> 1806 <term> 1807 <emphasis remap='I'>args</emphasis> 1808 </term> 1809 <listitem> 1810 <para> 1811Specifies a list of additional 1812<function>XrmValue</function> 1813arguments to the converter if additional context is needed 1814to perform the conversion, or NULL. 1815For example, the String-to-Font converter needs the widget's <emphasis remap='I'>display</emphasis>, 1816and the String-to-Pixel converter needs the widget's <emphasis remap='I'>screen</emphasis> and <emphasis remap='I'>colormap</emphasis>. 1817 </para> 1818 </listitem> 1819 </varlistentry> 1820 <varlistentry> 1821 <term> 1822 <emphasis remap='I'>num_args</emphasis> 1823 </term> 1824 <listitem> 1825 <para> 1826Specifies the number of entries in <emphasis remap='I'>args</emphasis>. 1827 </para> 1828 </listitem> 1829 </varlistentry> 1830 <varlistentry> 1831 <term> 1832 <emphasis remap='I'>from</emphasis> 1833 </term> 1834 <listitem> 1835 <para> 1836Specifies the value to convert. 1837 </para> 1838 </listitem> 1839 </varlistentry> 1840 <varlistentry> 1841 <term> 1842 <emphasis remap='I'>to</emphasis> 1843 </term> 1844 <listitem> 1845 <para> 1846Specifies a descriptor for a location into which to store the converted value. 1847 </para> 1848 </listitem> 1849 </varlistentry> 1850 <varlistentry> 1851 <term> 1852 <emphasis remap='I'>converter_data</emphasis> 1853 </term> 1854 <listitem> 1855 <para> 1856Specifies a location into which the converter may 1857store converter-specific data associated 1858with this conversion. 1859 </para> 1860 </listitem> 1861 </varlistentry> 1862</variablelist> 1863 1864<para> 1865The <emphasis remap='I'>display</emphasis> argument is normally used only when generating error 1866messages, to identify the application context (with the function 1867<function>XtDisplayToApplicationContext ).</function> 1868</para> 1869 1870<para> 1871The <emphasis remap='I'>to</emphasis> argument specifies the size and location into which the 1872converter should store the converted value. If the <emphasis remap='I'>addr</emphasis> field is NULL, 1873the converter should allocate appropriate storage and store the size 1874and location into the <emphasis remap='I'>to</emphasis> descriptor. If the type converter allocates 1875the storage, it remains under the ownership of the converter and must 1876not be modified by the caller. The type converter is permitted to use 1877static storage for this purpose, and therefore the caller must 1878immediately copy the data upon return from the converter. If the 1879<emphasis remap='I'>addr</emphasis> field is not NULL, the converter must check the <emphasis remap='I'>size</emphasis> field to 1880ensure that sufficient space has been allocated before storing the 1881converted value. If insufficient space is specified, the converter 1882should update the <emphasis remap='I'>size</emphasis> field with the number of bytes required and 1883return 1884<function>False</function> 1885without modifying the data at the specified location. 1886If sufficient space was allocated by the caller, the converter should 1887update the <emphasis remap='I'>size</emphasis> field with the number of bytes actually occupied by the 1888converted value. For converted values of type 1889<function>XtRString</function>, 1890the size should 1891include the NULL-terminating byte, if any. 1892The converter may store any value in the location specified 1893in <emphasis remap='I'>converter_data</emphasis>; this value will be passed to the destructor, if any, 1894when the resource is freed by the Intrinsics. 1895</para> 1896 1897<para> 1898The converter must return 1899<function>True</function> 1900if the conversion was successful and 1901<function>False</function> 1902otherwise. If the conversion cannot be performed because of an 1903improper source value, a warning message should also be issued with 1904<xref linkend='XtAppWarningMsg' xrefstyle='select: title'/>. 1905</para> 1906 1907<para> 1908Most type converters just take the data described by the specified <emphasis remap='I'>from</emphasis> 1909argument and return data by writing into the location specified in 1910the <emphasis remap='I'>to</emphasis> argument. 1911A few need other information, which is available in <emphasis remap='I'>args</emphasis>. 1912A type converter can invoke another type converter, 1913which allows differing sources that may convert into a common intermediate 1914result to make maximum use of the type converter cache. 1915</para> 1916 1917<para> 1918Note that if an address is written into <emphasis remap='I'>to->addr</emphasis>, it cannot be that 1919of a local variable of the converter because the data will not be 1920valid after the converter returns. Static variables may be used, 1921as in the following example. 1922If the converter modifies the resource database, 1923the changes affect any in-progress widget creation, 1924<xref linkend='XtGetApplicationResources' xrefstyle='select: title'/>, 1925or 1926<xref linkend='XtGetSubresources' xrefstyle='select: title'/> 1927in an implementation-defined manner; however, insertion of new entries 1928or changes to existing entries is allowed and will not directly cause 1929an error. 1930</para> 1931 1932<para> 1933The following is an example of a converter that takes a 1934<function>string</function> 1935and converts it to a 1936<function>Pixel</function>. 1937Note that the <emphasis remap='I'>display</emphasis> parameter is 1938used only to generate error messages; the 1939<function>Screen</function> 1940conversion argument is 1941still required to inform the Intrinsics that the converted value is 1942a function of the particular display (and colormap). 1943</para> 1944 1945<programlisting> 1946#define done(type, value) \ 1947 { \ 1948 if (toVal->addr != NULL) { \ 1949 if (toVal->size < sizeof(type)) { \ 1950 toVal->size = sizeof(type); \ 1951 return False; \ 1952 } \ 1953 *(type*)(toVal->addr) = (value); \ 1954 } \ 1955 else { \ 1956 static type static_val; \ 1957 static_val = (value); \ 1958 toVal->addr = (XPointer)&static_val; \ 1959 } \ 1960 toVal->size = sizeof(type); \ 1961 return True; \ 1962 } 1963 1964static Boolean CvtStringToPixel( 1965 Display *dpy, 1966 XrmValue *args, 1967 Cardinal *num_args, 1968 XrmValue *fromVal, 1969 XrmValue *toVal, 1970 XtPointer *converter_data) 1971{ 1972 static XColor screenColor; 1973 XColor exactColor; 1974 Screen *screen; 1975 Colormap colormap; 1976 Status status; 1977 1978 if (*num_args != 2) 1979 XtAppWarningMsg(XtDisplayToApplicationContext(dpy), 1980 "wrongParameters", "cvtStringToPixel", "XtToolkitError", 1981 "String to pixel conversion needs screen and colormap arguments", 1982 (String *)NULL, (Cardinal *)NULL); 1983 screen = *((Screen**) args[0].addr); 1984 colormap = *((Colormap *) args[1].addr); 1985 if (CompareISOLatin1(str, XtDefaultBackground) == 0) { 1986 *closure_ret = False; 1987 done(Pixel, WhitePixelOfScreen(screen)); 1988 } 1989 if (CompareISOLatin1(str, XtDefaultForeground) == 0) { 1990 *closure_ret = False; 1991 done(Pixel, BlackPixelOfScreen(screen)); 1992 } 1993 status = XAllocNamedColor(DisplayOfScreen(screen), 1994 colormap, (char*)fromVal->addr, 1995 &screenColor, &exactColor); 1996 if (status == 0) { 1997 String params[1]; 1998 Cardinal num_params = 1; 1999 params[0] = (String)fromVal->addr; 2000 XtAppWarningMsg(XtDisplayToApplicationContext(dpy), 2001 "noColormap", 2002 "cvtStringToPixel", 2003 "XtToolkitError", 2004 "Cannot allocate colormap entry for \"%s\"", 2005 params, &num_params); 2006 *converter_data = (char *) False; 2007 return False; 2008 } else { 2009 *converter_data = (char *) True; 2010 done(Pixel, &screenColor.pixel); 2011 } 2012} 2013</programlisting> 2014 2015<para> 2016All type converters should define some set of conversion values for which they 2017are guaranteed to succeed so these can be used in the resource defaults. 2018This issue arises only with conversions, such as fonts and colors, 2019where there is no string representation that all server implementations 2020will necessarily recognize. 2021For resources like these, 2022the converter should define a symbolic constant 2023in the same manner as 2024<function>XtDefaultForeground</function>, 2025<function>XtDefaultBackground</function>, 2026and 2027<function>XtDefaultFont</function>. 2028</para> 2029 2030<para> 2031To allow the Intrinsics to deallocate resources produced by type 2032converters, a resource destructor procedure may also be provided. 2033</para> 2034 2035<para> 2036A resource destructor procedure pointer is of type 2037<xref linkend='XtDestructor' xrefstyle='select: title'/>. 2038</para> 2039 2040<funcsynopsis id='XtDestructor'> 2041<funcprototype> 2042 <funcdef>typedef void <function>(*XtDestructor)</function></funcdef> 2043 <paramdef>XtAppContext <parameter>app</parameter></paramdef> 2044 <paramdef>XrmValue *<parameter>to</parameter></paramdef> 2045 <paramdef>XtPointer <parameter>converter_data</parameter></paramdef> 2046 <paramdef>XrmValue *<parameter>args</parameter></paramdef> 2047 <paramdef>Cardinal *<parameter>num_args</parameter></paramdef> 2048</funcprototype> 2049</funcsynopsis> 2050 2051<variablelist> 2052 <varlistentry> 2053 <term> 2054 <emphasis remap='I'>app</emphasis> 2055 </term> 2056 <listitem> 2057 <para> 2058Specifies an application context in which the resource is being freed. 2059 </para> 2060 </listitem> 2061 </varlistentry> 2062 <varlistentry> 2063 <term> 2064 <emphasis remap='I'>to</emphasis> 2065 </term> 2066 <listitem> 2067 <para> 2068Specifies a descriptor for the resource produced by the type converter. 2069 </para> 2070 </listitem> 2071 </varlistentry> 2072 <varlistentry> 2073 <term> 2074 <emphasis remap='I'>converter_data</emphasis> 2075 </term> 2076 <listitem> 2077 <para> 2078Specifies the converter-specific data returned by the type converter. 2079 </para> 2080 </listitem> 2081 </varlistentry> 2082 <varlistentry> 2083 <term> 2084 <emphasis remap='I'>args</emphasis> 2085 </term> 2086 <listitem> 2087 <para> 2088Specifies the additional converter arguments as passed 2089to the type converter when the conversion was performed. 2090 </para> 2091 </listitem> 2092 </varlistentry> 2093 <varlistentry> 2094 <term> 2095 <emphasis remap='I'>num_args</emphasis> 2096 </term> 2097 <listitem> 2098 <para> 2099Specifies the number of entries in <emphasis remap='I'>args</emphasis>. 2100 </para> 2101 </listitem> 2102 </varlistentry> 2103</variablelist> 2104 2105<para> 2106The destructor procedure is responsible for freeing the resource 2107specified by the <emphasis remap='I'>to</emphasis> argument, including any auxiliary storage 2108associated with that resource, but not the memory directly addressed 2109by the size and location in the <emphasis remap='I'>to</emphasis> argument or the memory specified 2110by <emphasis remap='I'>args</emphasis>. 2111</para> 2112</sect2> 2113 2114<sect2 id="Issuing_Conversion_Warnings"> 2115<title>Issuing Conversion Warnings</title> 2116<para> 2117The 2118<xref linkend='XtDisplayStringConversionWarning' xrefstyle='select: title'/> 2119procedure is a convenience routine for resource type converters 2120that convert from string values. 2121</para> 2122 2123<funcsynopsis id='XtDisplayStringConversionWarning'> 2124<funcprototype> 2125<funcdef>void <function>XtDisplayStringConversionWarning</function></funcdef> 2126 <paramdef>Display *<parameter>display</parameter></paramdef> 2127 <paramdef>const char * <parameter>from_value</parameter></paramdef> 2128 <paramdef>const char * <parameter>to_type</parameter></paramdef> 2129</funcprototype> 2130</funcsynopsis> 2131 2132<variablelist> 2133 <varlistentry> 2134 <term> 2135 <emphasis remap='I'>display</emphasis> 2136 </term> 2137 <listitem> 2138 <para> 2139Specifies the display connection with which the conversion is associated. 2140 </para> 2141 </listitem> 2142 </varlistentry> 2143 <varlistentry> 2144 <term> 2145 <emphasis remap='I'>from_value</emphasis> 2146 </term> 2147 <listitem> 2148 <para> 2149Specifies the string that could not be converted. 2150 </para> 2151 </listitem> 2152 </varlistentry> 2153 <varlistentry> 2154 <term> 2155 <emphasis remap='I'>to_type</emphasis> 2156 </term> 2157 <listitem> 2158 <para> 2159Specifies the target representation type requested. 2160 </para> 2161 </listitem> 2162 </varlistentry> 2163</variablelist> 2164 2165<para> 2166The 2167<xref linkend='XtDisplayStringConversionWarning' xrefstyle='select: title'/> 2168procedure issues a warning message using 2169<xref linkend='XtAppWarningMsg' xrefstyle='select: title'/> 2170with <emphasis remap='I'>name</emphasis> “conversionError”, 2171<emphasis remap='I'>type</emphasis> “string”, <emphasis remap='I'>class</emphasis> “XtToolkitError”, and the default message 2172“Cannot convert "<emphasis remap='I'>from_value</emphasis>" to type <emphasis remap='I'>to_type</emphasis>”. 2173</para> 2174 2175<para> 2176To issue other types of warning or error messages, the type converter 2177should use 2178<xref linkend='XtAppWarningMsg' xrefstyle='select: title'/> 2179or 2180<xref linkend='XtAppErrorMsg' xrefstyle='select: title'/>. 2181</para> 2182 2183<para> 2184To retrieve the application context associated with a given 2185display connection, use 2186<xref linkend='XtDisplayToApplicationContext' xrefstyle='select: title'/>. 2187</para> 2188 2189<funcsynopsis id='XtDisplayToApplicationContext'> 2190<funcprototype> 2191<funcdef>XtAppContext <function>XtDisplayToApplicationContext</function></funcdef> 2192 <paramdef>Display *<parameter>display</parameter></paramdef> 2193</funcprototype> 2194</funcsynopsis> 2195 2196<variablelist> 2197 <varlistentry> 2198 <term> 2199 <emphasis remap='I'>display</emphasis> 2200 </term> 2201 <listitem> 2202 <para> 2203Specifies an open and initialized display connection. 2204 </para> 2205 </listitem> 2206 </varlistentry> 2207</variablelist> 2208 2209<para> 2210The 2211<xref linkend='XtDisplayToApplicationContext' xrefstyle='select: title'/> 2212function returns the application 2213context in which the specified <emphasis remap='I'>display</emphasis> was initialized. If the 2214display is not known to the Intrinsics, an error message is issued. 2215</para> 2216</sect2> 2217 2218<sect2 id="Registering_a_New_Resource_Converter"> 2219<title>Registering a New Resource Converter</title> 2220<para> 2221When registering a resource converter, the client must specify the 2222manner in which the conversion cache is to be used when there are multiple 2223calls to the converter. Conversion cache control is specified 2224via an <function>XtCacheType</function> 2225argument. </para> 2226 2227<programlisting> 2228typedef int XtCacheType; 2229</programlisting> 2230 2231<para> 2232An <function>XtCacheType</function> 2233field may contain one of the following values: 2234</para> 2235 2236<para> 2237<function>XtCacheNone</function> 2238</para> 2239<itemizedlist spacing='compact'> 2240 <listitem> 2241 <para> 2242Specifies that the results of a previous conversion 2243may not be reused to satisfy any other resource 2244requests; the specified converter will be called 2245each time the converted value is required. 2246 </para> 2247 </listitem> 2248</itemizedlist> 2249<para> 2250<function>XtCacheAll</function> 2251</para> 2252<itemizedlist spacing='compact'> 2253 <listitem> 2254 <para> 2255Specifies that the results of a previous conversion 2256should be reused for any resource request that depends 2257upon the same source value and conversion arguments. 2258 </para> 2259 </listitem> 2260</itemizedlist> 2261<para> 2262<function>XtCacheByDisplay</function> 2263</para> 2264<itemizedlist spacing='compact'> 2265 <listitem> 2266 <para> 2267Specifies that the results of a previous conversion 2268should be used as for 2269<function>XtCacheAll</function> 2270but the destructor will be called, if specified, if 2271<xref linkend='XtCloseDisplay' xrefstyle='select: title'/> 2272is called 2273for the display connection associated with the converted value, and 2274the value will be removed from the conversion cache. 2275 </para> 2276 </listitem> 2277</itemizedlist> 2278<para> 2279The qualifier 2280<function>XtCacheRefCount</function> 2281may be ORed with any of the above values. If 2282<function>XtCacheRefCount</function> 2283is specified, calls to 2284<xref linkend='XtCreateWidget' xrefstyle='select: title'/>, 2285<xref linkend='XtCreateManagedWidget' xrefstyle='select: title'/>, 2286<xref linkend='XtGetApplicationResources' xrefstyle='select: title'/>, 2287and 2288<xref linkend='XtGetSubresources' xrefstyle='select: title'/> 2289that use the converted value will be counted. When a widget using the 2290converted value is destroyed, the count is decremented, and, if the 2291count reaches zero, the destructor procedure will be called and the 2292converted value will be removed from the conversion cache. 2293</para> 2294 2295<para> 2296To register a type converter for all application contexts in a 2297process, use 2298<xref linkend='XtSetTypeConverter' xrefstyle='select: title'/>, 2299and to register a type converter in a single application context, use 2300<xref linkend='XtAppSetTypeConverter' xrefstyle='select: title'/>. 2301</para> 2302 2303<funcsynopsis id='XtSetTypeConverter'> 2304<funcprototype> 2305<funcdef>void <function>XtSetTypeConverter</function></funcdef> 2306 <paramdef>const char * <parameter>from_type</parameter></paramdef> 2307 <paramdef>const char * <parameter>to_type</parameter></paramdef> 2308 <paramdef>XtTypeConverter <parameter>converter</parameter></paramdef> 2309 <paramdef>XtConvertArgList <parameter>convert_args</parameter></paramdef> 2310 <paramdef>Cardinal <parameter>num_args</parameter></paramdef> 2311 <paramdef>XtCacheType <parameter>cache_type</parameter></paramdef> 2312 <paramdef>XtDestructor <parameter>destructor</parameter></paramdef> 2313</funcprototype> 2314</funcsynopsis> 2315 2316<variablelist> 2317 <varlistentry> 2318 <term> 2319 <emphasis remap='I'>from_type</emphasis> 2320 </term> 2321 <listitem> 2322 <para> 2323Specifies the source type. 2324 </para> 2325 </listitem> 2326 </varlistentry> 2327 <varlistentry> 2328 <term> 2329 <emphasis remap='I'>to_type</emphasis> 2330 </term> 2331 <listitem> 2332 <para> 2333Specifies the destination type. 2334 </para> 2335 </listitem> 2336 </varlistentry> 2337 <varlistentry> 2338 <term> 2339 <emphasis remap='I'>converter</emphasis> 2340 </term> 2341 <listitem> 2342 <para> 2343Specifies the resource type converter procedure. 2344 </para> 2345 </listitem> 2346 </varlistentry> 2347 <varlistentry> 2348 <term> 2349 <emphasis remap='I'>convert_args</emphasis> 2350 </term> 2351 <listitem> 2352 <para> 2353Specifies additional conversion arguments, or NULL. 2354 </para> 2355 </listitem> 2356 </varlistentry> 2357 <varlistentry> 2358 <term> 2359 <emphasis remap='I'>num_args</emphasis> 2360 </term> 2361 <listitem> 2362 <para> 2363Specifies the number of entries in <emphasis remap='I'>convert_args</emphasis>. 2364 </para> 2365 </listitem> 2366 </varlistentry> 2367 <varlistentry> 2368 <term> 2369 <emphasis remap='I'>cache_type</emphasis> 2370 </term> 2371 <listitem> 2372 <para> 2373Specifies whether or not resources produced by this 2374converter are shareable or display-specific and when 2375they should be freed. 2376 </para> 2377 </listitem> 2378 </varlistentry> 2379 <varlistentry> 2380 <term> 2381 <emphasis remap='I'>destructor</emphasis> 2382 </term> 2383 <listitem> 2384 <para> 2385Specifies a destroy procedure for resources produced by 2386this conversion, or NULL if no additional action is 2387required to deallocate resources produced by the converter. 2388 </para> 2389 </listitem> 2390 </varlistentry> 2391</variablelist> 2392 2393 2394<funcsynopsis id='XtAppSetTypeConverter'> 2395<funcprototype> 2396<funcdef>void <function>XtAppSetTypeConverter</function></funcdef> 2397 <paramdef>XtAppContext <parameter>app_context</parameter></paramdef> 2398 <paramdef>const char * <parameter>from_type</parameter></paramdef> 2399 <paramdef>const char * <parameter>to_type</parameter></paramdef> 2400 <paramdef>XtTypeConverter <parameter>converter</parameter></paramdef> 2401 <paramdef>XtConvertArgList <parameter>convert_args</parameter></paramdef> 2402 <paramdef>Cardinal <parameter>num_args</parameter></paramdef> 2403 <paramdef>XtCacheType <parameter>cache_type</parameter></paramdef> 2404 <paramdef>XtDestructor <parameter>destructor</parameter></paramdef> 2405</funcprototype> 2406</funcsynopsis> 2407 2408<variablelist> 2409 <varlistentry> 2410 <term> 2411 <emphasis remap='I'>app_context</emphasis> 2412 </term> 2413 <listitem> 2414 <para> 2415Specifies the application context. 2416 </para> 2417 </listitem> 2418 </varlistentry> 2419 <varlistentry> 2420 <term> 2421 <emphasis remap='I'>from_type</emphasis> 2422 </term> 2423 <listitem> 2424 <para> 2425Specifies the source type. 2426 </para> 2427 </listitem> 2428 </varlistentry> 2429 <varlistentry> 2430 <term> 2431 <emphasis remap='I'>to_type</emphasis> 2432 </term> 2433 <listitem> 2434 <para> 2435Specifies the destination type. 2436 </para> 2437 </listitem> 2438 </varlistentry> 2439 <varlistentry> 2440 <term> 2441 <emphasis remap='I'>converter</emphasis> 2442 </term> 2443 <listitem> 2444 <para> 2445Specifies the resource type converter procedure. 2446 </para> 2447 </listitem> 2448 </varlistentry> 2449 <varlistentry> 2450 <term> 2451 <emphasis remap='I'>convert_args</emphasis> 2452 </term> 2453 <listitem> 2454 <para> 2455Specifies additional conversion arguments, or NULL. 2456 </para> 2457 </listitem> 2458 </varlistentry> 2459 <varlistentry> 2460 <term> 2461 <emphasis remap='I'>num_args</emphasis> 2462 </term> 2463 <listitem> 2464 <para> 2465Specifies the number of entries in <emphasis remap='I'>convert_args</emphasis>. 2466 </para> 2467 </listitem> 2468 </varlistentry> 2469 <varlistentry> 2470 <term> 2471 <emphasis remap='I'>cache_type</emphasis> 2472 </term> 2473 <listitem> 2474 <para> 2475Specifies whether or not resources produced by this 2476converter are shareable or display-specific and when 2477they should be freed. 2478 </para> 2479 </listitem> 2480 </varlistentry> 2481 <varlistentry> 2482 <term> 2483 <emphasis remap='I'>destructor</emphasis> 2484 </term> 2485 <listitem> 2486 <para> 2487Specifies a destroy procedure for resources produced by 2488this conversion, or NULL if no additional action is 2489required to deallocate resources produced by the converter. 2490 </para> 2491 </listitem> 2492 </varlistentry> 2493</variablelist> 2494 2495<para> 2496<xref linkend='XtSetTypeConverter' xrefstyle='select: title'/> 2497registers the specified type converter and 2498destructor in all application contexts created by the calling process, 2499including any future application contexts that may be created. 2500<xref linkend='XtAppSetTypeConverter' xrefstyle='select: title'/> 2501registers the specified type converter in the 2502single application context specified. If the same <emphasis remap='I'>from_type</emphasis> and 2503<emphasis remap='I'>to_type</emphasis> are specified in multiple calls to either function, the most 2504recent overrides the previous ones. 2505</para> 2506 2507<para> 2508For the few type converters that need additional arguments, 2509the Intrinsics conversion mechanism provides a method of specifying 2510how these arguments should be computed. 2511The enumerated type 2512<function>XtAddressMode</function> 2513and the structure 2514<function>XtConvertArgRec</function> 2515specify how each argument is derived. 2516These are defined in 2517<filename class="headerfile"><X11/Intrinsic.h></filename>. 2518</para> 2519<programlisting> 2520typedef enum { 2521 /* address mode parameter representation */ 2522 XtAddress, /* address */ 2523 XtBaseOffset, /* offset */ 2524 XtImmediate, /* constant */ 2525 XtResourceString, /* resource name string */ 2526 XtResourceQuark, /* resource name quark */ 2527 XtWidgetBaseOffset, /* offset */ 2528 XtProcedureArg /* procedure to call */ 2529} XtAddressMode; 2530 2531typedef struct { 2532 XtAddressMode address_mode; 2533 XtPointer address_id; 2534 Cardinal size; 2535} XtConvertArgRec, *XtConvertArgList; 2536</programlisting> 2537<para> 2538The <emphasis remap='I'>size</emphasis> field specifies the length of the data in bytes. 2539The <emphasis remap='I'>address_mode</emphasis> field specifies how the <emphasis remap='I'>address_id</emphasis> field should be 2540interpreted. 2541<function>XtAddress</function> 2542causes <emphasis remap='I'>address_id</emphasis> to be interpreted as the address of the data. 2543<function>XtBaseOffset</function> 2544causes <emphasis remap='I'>address_id</emphasis> to be interpreted as the offset from the widget base. 2545<function>XtImmediate</function> 2546causes <emphasis remap='I'>address_id</emphasis> to be interpreted as a constant. 2547<function>XtResourceString</function> 2548causes <emphasis remap='I'>address_id</emphasis> to be interpreted as the name of a resource 2549that is to be converted into an offset from the widget base. 2550<function>XtResourceQuark</function> 2551causes <emphasis remap='I'>address_id</emphasis> to be interpreted as the result of an 2552<function>XrmStringToQuark</function> 2553conversion on the name of a resource, 2554which is to be converted into an offset from the widget base. 2555<function>XtWidgetBaseOffset</function> 2556is similar to 2557<function>XtBaseOffset</function> 2558except that it 2559searches for the closest windowed ancestor if the object is not 2560of a subclass of 2561Core 2562(see <xref linkend='Nonwidget_Objects' />). 2563<function>XtProcedureArg</function> 2564specifies that <emphasis remap='I'>address_id</emphasis> is a pointer to a procedure to 2565be invoked to return the conversion argument. If 2566<function>XtProcedureArg</function> 2567is specified, <emphasis remap='I'>address_id</emphasis> must contain 2568the address of a function of type 2569<xref linkend='XtConvertArgProc' xrefstyle='select: title'/>. 2570</para> 2571 2572<funcsynopsis id='XtConvertArgProc'> 2573<funcprototype> 2574<funcdef>typedef void <function>(*XtConvertArgProc)</function></funcdef> 2575 <paramdef>Widget <parameter>object</parameter></paramdef> 2576 <paramdef>Cardinal *<parameter>size</parameter></paramdef> 2577 <paramdef>XrmValue *<parameter>value</parameter></paramdef> 2578</funcprototype> 2579</funcsynopsis> 2580 2581<variablelist> 2582 <varlistentry> 2583 <term> 2584 <emphasis remap='I'>object</emphasis> 2585 </term> 2586 <listitem> 2587 <para> 2588Passes the object for which the resource is being 2589converted, or NULL if the converter was invoked by 2590<xref linkend='XtCallConverter' xrefstyle='select: title'/> or 2591<xref linkend='XtDirectConvert' xrefstyle='select: title'/>. 2592 </para> 2593 </listitem> 2594 </varlistentry> 2595 <varlistentry> 2596 <term> 2597 <emphasis remap='I'>size</emphasis> 2598 </term> 2599 <listitem> 2600 <para> 2601Passes a pointer to the size field from the XtConvertArgRec. 2602 </para> 2603 </listitem> 2604 </varlistentry> 2605 <varlistentry> 2606 <term> 2607 <emphasis remap='I'>value</emphasis> 2608 </term> 2609 <listitem> 2610 <para> 2611Passes a pointer to a descriptor into which the procedure must store the 2612conversion argument. 2613 </para> 2614 </listitem> 2615 </varlistentry> 2616</variablelist> 2617<para> 2618When invoked, the <function>XtConvertArgProc</function> procedure must derive a 2619conversion argument and store the address and size of the 2620argument in the location pointed to by value. 2621</para> 2622<para> 2623In order to permit reentrancy, the <function>XtConvertArgProc</function> should 2624return the address of storage whose lifetime is no shorter 2625than the lifetime of object. 2626If object is NULL, 2627the lifetime of the conversion argument must be no shorter than the 2628lifetime of the resource with which the conversion argument 2629is associated. The Intrinsics do not guarantee to copy this 2630storage but do guarantee not to reference it if the resource 2631is removed from the conversion cache. 2632</para> 2633<para> 2634The following example illustrates how to register the 2635<function>CvtStringToPixel</function> 2636routine given earlier: 2637</para> 2638<programlisting> 2639static XtConvertArgRec colorConvertArgs[] = { 2640 {XtWidgetBaseOffset, 2641 (XtPointer)XtOffset(Widget, core.screen), 2642 sizeof(Screen*)}, 2643 {XtWidgetBaseOffset, 2644 (XtPointer)XtOffset(Widget, core.colormap), 2645 sizeof(Colormap)} 2646}; 2647 2648XtSetTypeConverter(XtRString, 2649 XtRPixel, 2650 CvtStringToPixel, 2651 colorConvertArgs, 2652 XtNumber(colorConvertArgs), 2653 XtCacheByDisplay, NULL); 2654</programlisting> 2655<para> 2656The conversion argument descriptors colorConvertArgs and 2657screenConvertArg are predefined by the Intrinsics. Both 2658take the values from the closest windowed ancestor if the 2659object is not of a subclass of Core. The screenConvertArg 2660descriptor puts the widget’s screen field into args[0]. The 2661colorConvertArgs descriptor puts the widget’s screen field 2662into args[0], and the widget’s colormap field into args[1]. 2663</para> 2664<para> 2665Conversion routines should not just put a descriptor for the 2666address of the base of the widget into args[0], and use that 2667in the routine. They should pass in the actual values on 2668which the conversion depends. By keeping the dependencies 2669of the conversion procedure specific, it is more likely that 2670subsequent conversions will find what they need in the conversion cache. 2671This way the cache is smaller and has fewer 2672and more widely applicable entries. 2673</para> 2674<para> 2675If any conversion arguments of type 2676<type>XtBaseOffset</type>, 2677<type>XtResourceString</type>, 2678<type>XtResourceQuark</type>, 2679and 2680<type>XtWidgetBaseOffset</type> 2681are 2682specified for conversions performed by 2683<type>XtGetApplicationResources</type>, 2684<type>XtGetSubresources</type>, 2685<type>XtVaGetApplicationResources</type>, 2686or 2687<type>XtVaGetSubresources</type>, 2688the arguments are computed with respect 2689to the specified widget, not the base address or resource 2690list specified in the call. 2691</para> 2692<para> 2693If the <function>XtConvertArgProc</function> modifies the resource database, the 2694changes affect any in-progress widget creation, 2695<xref linkend='XtGetApplicationResources' xrefstyle='select: title'/>, 2696or 2697<xref linkend='XtGetSubresources' xrefstyle='select: title'/> 2698in an implementation-defined manner; 2699however, insertion of new entries or changes 2700to existing entries are allowed and will not directly cause 2701an error. 2702</para> 2703</sect2> 2704 2705<sect2 id="Resource_Converter_Invocation"> 2706<title>Resource Converter Invocation</title> 2707<para> 2708All resource-fetching routines (for example, 2709<xref linkend='XtGetSubresources' xrefstyle='select: title'/>, 2710<xref linkend='XtGetApplicationResources' xrefstyle='select: title'/>, 2711and so on) call resource converters if the resource database or 2712varargs list specifies a value 2713that has a different representation from the desired representation or if the 2714widget's default resource value representation is different from the desired 2715representation. 2716</para> 2717 2718<para> 2719To invoke explicit resource conversions, use 2720<xref linkend='XtConvertAndStore' xrefstyle='select: title'/> 2721or 2722<xref linkend='XtCallConverter' xrefstyle='select: title'/>. 2723</para> 2724<programlisting> 2725typedef XtPointer XtCacheRef; 2726</programlisting> 2727 2728<funcsynopsis id='XtCallConverter'> 2729<funcprototype> 2730<funcdef>Boolean <function>XtCallConverter</function></funcdef> 2731 <paramdef>Display* <parameter>display</parameter></paramdef> 2732 <paramdef>XtTypeConverter <parameter>converter</parameter></paramdef> 2733 <paramdef>XrmValuePtr <parameter>conversion_args</parameter></paramdef> 2734 <paramdef>Cardinal <parameter>num_args</parameter></paramdef> 2735 <paramdef>XrmValuePtr <parameter>from</parameter></paramdef> 2736 <paramdef>XrmValuePtr <parameter>to_in_out</parameter></paramdef> 2737 <paramdef>XtCacheRef *<parameter>cache_ref_return</parameter></paramdef> 2738</funcprototype> 2739</funcsynopsis> 2740 2741<variablelist> 2742 <varlistentry> 2743 <term> 2744 <emphasis remap='I'>display</emphasis> 2745 </term> 2746 <listitem> 2747 <para> 2748Specifies the display with which the conversion is to be associated. 2749 </para> 2750 </listitem> 2751 </varlistentry> 2752 <varlistentry> 2753 <term> 2754 <emphasis remap='I'>converter</emphasis> 2755 </term> 2756 <listitem> 2757 <para> 2758Specifies the conversion procedure to be called. 2759 </para> 2760 </listitem> 2761 </varlistentry> 2762 <varlistentry> 2763 <term> 2764 <emphasis remap='I'>conversion_args</emphasis> 2765 </term> 2766 <listitem> 2767 <para> 2768Specifies the additional conversion arguments needed 2769to perform the conversion, or NULL. 2770 </para> 2771 </listitem> 2772 </varlistentry> 2773 <varlistentry> 2774 <term> 2775 <emphasis remap='I'>num_args</emphasis> 2776 </term> 2777 <listitem> 2778 <para> 2779Specifies the number of entries in <emphasis remap='I'>conversion_args</emphasis>. 2780 </para> 2781 </listitem> 2782 </varlistentry> 2783 <varlistentry> 2784 <term> 2785 <emphasis remap='I'>from</emphasis> 2786 </term> 2787 <listitem> 2788 <para> 2789Specifies a descriptor for the source value. 2790 </para> 2791 </listitem> 2792 </varlistentry> 2793 <varlistentry> 2794 <term> 2795 <emphasis remap='I'>to_in_out</emphasis> 2796 </term> 2797 <listitem> 2798 <para> 2799Returns the converted value. 2800 </para> 2801 </listitem> 2802 </varlistentry> 2803 <varlistentry> 2804 <term> 2805 <emphasis remap='I'>cache_ref_return</emphasis> 2806 </term> 2807 <listitem> 2808 <para> 2809Returns a conversion cache id. 2810 </para> 2811 </listitem> 2812 </varlistentry> 2813</variablelist> 2814 2815<para> 2816The 2817<xref linkend='XtCallConverter' xrefstyle='select: title'/> 2818function looks up the 2819specified type converter in the application context associated with 2820the display and, if the converter was not registered or was registered 2821with cache type 2822<function>XtCacheAll</function> 2823or 2824<function>XtCacheByDisplay</function>, 2825looks in the conversion cache to see if this conversion procedure 2826has been called with the specified conversion arguments. If so, it 2827checks the success status of the prior call, and if 2828the conversion failed, 2829<xref linkend='XtCallConverter' xrefstyle='select: title'/> 2830returns 2831<function>False</function> 2832immediately; 2833otherwise it checks the size specified in the <emphasis remap='I'>to</emphasis> argument, and, if it is 2834greater than or equal to the size stored in the cache, copies the 2835information stored in the cache into the location specified by 2836<emphasis remap='I'>to->addr</emphasis>, stores the cache size into <emphasis remap='I'>to->size</emphasis>, and returns 2837<function>True</function>. 2838If the size specified in the <emphasis remap='I'>to</emphasis> argument is smaller than the size stored 2839in the cache, 2840<xref linkend='XtCallConverter' xrefstyle='select: title'/> 2841copies the cache size into <emphasis remap='I'>to->size</emphasis> and returns 2842<function>False</function>. 2843If the converter was registered with cache type 2844<function>XtCacheNone</function> 2845or no value was found in the conversion cache, 2846<xref linkend='XtCallConverter' xrefstyle='select: title'/> 2847calls the converter, and if it was not registered with cache type 2848<function>XtCacheNone</function>, 2849enters the result in the cache. 2850<xref linkend='XtCallConverter' xrefstyle='select: title'/> 2851then returns what the converter returned. 2852</para> 2853 2854<para> 2855The <emphasis remap='I'>cache_ref_return</emphasis> field specifies storage allocated by the caller in which 2856an opaque value will be stored. If the type converter has been 2857registered with the 2858<function>XtCacheRefCount</function> 2859modifier and if the value returned 2860in <emphasis remap='I'>cache_ref_return</emphasis> is non-NULL, then the caller should store the 2861<emphasis remap='I'>cache_ref_return</emphasis> value in order to decrement the reference count when 2862the converted value is no longer required. The <emphasis remap='I'>cache_ref_return</emphasis> 2863argument should be 2864NULL if the caller is unwilling or unable to store the 2865value. 2866</para> 2867 2868<para> 2869To explicitly decrement the reference counts for resources obtained 2870from 2871<xref linkend='XtCallConverter' xrefstyle='select: title'/>, 2872use 2873<xref linkend='XtAppReleaseCacheRefs' xrefstyle='select: title'/>. 2874</para> 2875 2876<funcsynopsis id='XtAppReleaseCacheRefs'> 2877<funcprototype> 2878<funcdef>void <function>XtAppReleaseCacheRefs</function></funcdef> 2879 <paramdef>XtAppContext <parameter>app_context</parameter></paramdef> 2880 <paramdef>XtCacheRef *<parameter>refs</parameter></paramdef> 2881</funcprototype> 2882</funcsynopsis> 2883 2884<variablelist> 2885 <varlistentry> 2886 <term> 2887 <emphasis remap='I'>app_context</emphasis> 2888 </term> 2889 <listitem> 2890 <para> 2891Specifies the application context. 2892 </para> 2893 </listitem> 2894 </varlistentry> 2895 <varlistentry> 2896 <term> 2897 <emphasis remap='I'>refs</emphasis> 2898 </term> 2899 <listitem> 2900 <para> 2901Specifies the list of cache references to be released. 2902 </para> 2903 </listitem> 2904 </varlistentry> 2905</variablelist> 2906 2907<para> 2908<xref linkend='XtAppReleaseCacheRefs' xrefstyle='select: title'/> 2909decrements the reference count for the 2910conversion entries identified by the <emphasis remap='I'>refs</emphasis> argument. 2911This argument is a 2912pointer to a NULL-terminated list of 2913<function>XtCacheRef</function> 2914values. If any reference 2915count reaches zero, the destructor, if any, will be called and 2916the resource removed from the conversion cache. 2917</para> 2918 2919<para> 2920As a convenience to clients needing to explicitly decrement reference 2921counts via a callback function, the Intrinsics define two callback 2922procedures, 2923<xref linkend='XtCallbackReleaseCacheRef' xrefstyle='select: title'/> 2924and 2925<xref linkend='XtCallbackReleaseCacheRefList' xrefstyle='select: title'/>. 2926</para> 2927 2928<funcsynopsis id='XtCallbackReleaseCacheRef'> 2929<funcprototype> 2930<funcdef>void <function>XtCallbackReleaseCacheRef</function></funcdef> 2931 <paramdef>Widget <parameter>object</parameter></paramdef> 2932 <paramdef>XtPointer <parameter>client_data</parameter></paramdef> 2933 <paramdef>XtPointer <parameter>call_data</parameter></paramdef> 2934</funcprototype> 2935</funcsynopsis> 2936 2937<variablelist> 2938 <varlistentry> 2939 <term> 2940 <emphasis remap='I'>object</emphasis> 2941 </term> 2942 <listitem> 2943 <para> 2944Specifies the object with which the resource is associated. 2945 </para> 2946 </listitem> 2947 </varlistentry> 2948 <varlistentry> 2949 <term> 2950 <emphasis remap='I'>client_data</emphasis> 2951 </term> 2952 <listitem> 2953 <para> 2954Specifies the conversion cache entry to be released. 2955 </para> 2956 </listitem> 2957 </varlistentry> 2958 <varlistentry> 2959 <term> 2960 <emphasis remap='I'>call_data</emphasis> 2961 </term> 2962 <listitem> 2963 <para> 2964Is ignored. 2965 </para> 2966 </listitem> 2967 </varlistentry> 2968</variablelist> 2969 2970<para> 2971This callback procedure may be added to a callback list to release a 2972previously returned 2973<function>XtCacheRef</function> 2974value. When adding the callback, the 2975callback <emphasis remap='I'>client_data</emphasis> argument must be specified as the value of the 2976<function>XtCacheRef</function> 2977data cast to type 2978<function>XtPointer</function>. 2979</para> 2980 2981<funcsynopsis id='XtCallbackReleaseCacheRefList'> 2982<funcprototype> 2983<funcdef>void <function>XtCallbackReleaseCacheRefList</function></funcdef> 2984 <paramdef>Widget <parameter>object</parameter></paramdef> 2985 <paramdef>XtPointer <parameter>client_data</parameter></paramdef> 2986 <paramdef>XtPointer <parameter>call_data</parameter></paramdef> 2987</funcprototype> 2988</funcsynopsis> 2989 2990<variablelist> 2991 <varlistentry> 2992 <term> 2993 <emphasis remap='I'>object</emphasis> 2994 </term> 2995 <listitem> 2996 <para> 2997Specifies the object with which the resources are associated. 2998 </para> 2999 </listitem> 3000 </varlistentry> 3001 <varlistentry> 3002 <term> 3003 <emphasis remap='I'>client_data</emphasis> 3004 </term> 3005 <listitem> 3006 <para> 3007Specifies the conversion cache entries to be released. 3008 </para> 3009 </listitem> 3010 </varlistentry> 3011 <varlistentry> 3012 <term> 3013 <emphasis remap='I'>call_data</emphasis> 3014 </term> 3015 <listitem> 3016 <para> 3017Is ignored. 3018 </para> 3019 </listitem> 3020 </varlistentry> 3021</variablelist> 3022 3023<para> 3024This callback procedure may be added to a callback list to release a 3025list of previously returned 3026<function>XtCacheRef</function> 3027values. When adding the 3028callback, the callback <emphasis remap='I'>client_data</emphasis> argument must be specified as a 3029pointer to a NULL-terminated list of 3030<function>XtCacheRef</function> 3031values. 3032</para> 3033 3034<para> 3035To lookup and call a resource converter, copy the resulting value, 3036and free a cached resource when a widget is destroyed, use 3037<xref linkend='XtConvertAndStore' xrefstyle='select: title'/>. 3038</para> 3039 3040<funcsynopsis id='XtConvertAndStore'> 3041<funcprototype> 3042<funcdef>Boolean <function>XtConvertAndStore</function></funcdef> 3043 <paramdef>Widget <parameter>object</parameter></paramdef> 3044 <paramdef>const char * <parameter>from_type</parameter></paramdef> 3045 <paramdef>XrmValuePtr <parameter>from</parameter></paramdef> 3046 <paramdef>const char * <parameter>to_type</parameter></paramdef> 3047 <paramdef>XrmValuePtr <parameter>to_in_out</parameter></paramdef> 3048</funcprototype> 3049</funcsynopsis> 3050 3051<variablelist> 3052 <varlistentry> 3053 <term> 3054 <emphasis remap='I'>object</emphasis> 3055 </term> 3056 <listitem> 3057 <para> 3058Specifies the object to use for additional arguments, if any are needed, 3059and the destroy callback list. Must be of class Object or any subclass thereof. 3060 </para> 3061 </listitem> 3062 </varlistentry> 3063 <varlistentry> 3064 <term> 3065 <emphasis remap='I'>from_type</emphasis> 3066 </term> 3067 <listitem> 3068 <para> 3069Specifies the source type. 3070 </para> 3071 </listitem> 3072 </varlistentry> 3073 <varlistentry> 3074 <term> 3075 <emphasis remap='I'>from</emphasis> 3076 </term> 3077 <listitem> 3078 <para> 3079Specifies the value to be converted. 3080 </para> 3081 </listitem> 3082 </varlistentry> 3083 <varlistentry> 3084 <term> 3085 <emphasis remap='I'>to_type</emphasis> 3086 </term> 3087 <listitem> 3088 <para> 3089Specifies the destination type. 3090 </para> 3091 </listitem> 3092 </varlistentry> 3093 <varlistentry> 3094 <term> 3095 <emphasis remap='I'>to_in_out</emphasis> 3096 </term> 3097 <listitem> 3098 <para> 3099Specifies a descriptor for storage into which the converted value 3100will be returned. 3101 </para> 3102 </listitem> 3103 </varlistentry> 3104</variablelist> 3105 3106<para> 3107The 3108<xref linkend='XtConvertAndStore' xrefstyle='select: title'/> 3109function looks up the type converter registered 3110to convert <emphasis remap='I'>from_type</emphasis> to <emphasis remap='I'>to_type</emphasis>, computes any additional arguments 3111needed, and then calls 3112<xref linkend='XtCallConverter' xrefstyle='select: title'/> 3113(or 3114<xref linkend='XtDirectConvert' xrefstyle='select: title'/> 3115if an old-style converter was registered with 3116<xref linkend='XtAddConverter' xrefstyle='select: title'/> 3117or 3118<xref linkend='XtAppAddConverter' xrefstyle='select: title'/>; 3119see Appendix C) with the <emphasis remap='I'>from</emphasis> and <emphasis remap='I'>to_in_out</emphasis> arguments. The 3120<emphasis remap='I'>to_in_out</emphasis> argument specifies the size and location into which the 3121converted value will be stored and is passed directly to the 3122converter. If the location is specified as NULL, it will be replaced 3123with a pointer to private storage and the size will be returned in the 3124descriptor. The caller is expected to copy this private storage 3125immediately and must not modify it in any way. If a non-NULL location 3126is specified, the caller must allocate sufficient storage to hold the 3127converted value and must also specify the size of that storage in the 3128descriptor. 3129The <emphasis remap='I'>size</emphasis> field will be modified on return to indicate the actual 3130size of the converted data. 3131If the conversion succeeds, 3132<xref linkend='XtConvertAndStore' xrefstyle='select: title'/> 3133returns 3134<function>True</function>; 3135otherwise, it returns 3136<function>False</function>. 3137</para> 3138 3139<para> 3140<xref linkend='XtConvertAndStore' xrefstyle='select: title'/> 3141adds 3142<xref linkend='XtCallbackReleaseCacheRef' xrefstyle='select: title'/> 3143to the destroyCallback list of the specified object if the conversion 3144returns an 3145<function>XtCacheRef</function> 3146value. The resulting resource should not be referenced 3147after the object has been destroyed. 3148</para> 3149 3150<para> 3151<xref linkend='XtCreateWidget' xrefstyle='select: title'/> 3152performs processing equivalent to 3153<xref linkend='XtConvertAndStore' xrefstyle='select: title'/> 3154when initializing the object instance. Because there is extra memory 3155overhead required to implement reference counting, clients may 3156distinguish those objects that are never destroyed before the 3157application exits from those that may be destroyed and whose 3158resources should be deallocated. 3159</para> 3160 3161<para> 3162To specify whether reference counting is to be enabled for the 3163resources of a particular object when the object is created, the 3164client can specify a value for the 3165<function>Boolean</function> 3166resource 3167XtNinitialResourcesPersistent, 3168class 3169XtCInitialResourcesPersistent. 3170</para> 3171 3172<para> 3173When 3174<xref linkend='XtCreateWidget' xrefstyle='select: title'/> 3175is called, if this resource is not specified as 3176<function>False</function> 3177in either the arglist or the resource database, then the 3178resources referenced by this object are not reference-counted, regardless of 3179how the type converter may have been registered. The effective 3180default value is 3181<function>True</function>; 3182thus clients that expect to destroy one or 3183more objects and want resources deallocated must explicitly specify 3184<function>False</function> 3185for 3186XtNinitialResourcesPersistent. 3187</para> 3188 3189<para> 3190The resources are still freed and destructors called when 3191<xref linkend='XtCloseDisplay' xrefstyle='select: title'/> 3192is called if the conversion was registered as 3193<function>XtCacheByDisplay</function>. 3194</para> 3195</sect2> 3196</sect1> 3197 3198<sect1 id="Reading_and_Writing_Widget_State"> 3199<title>Reading and Writing Widget State</title> 3200<para> 3201Any resource field in a widget can be read or written by a client. 3202On a write operation, 3203the widget decides what changes it will actually allow and updates all 3204derived fields appropriately. 3205</para> 3206<sect2 id="Obtaining_Widget_State"> 3207<title>Obtaining Widget State</title> 3208<para> 3209To retrieve the current values of resources associated with a 3210widget instance, use 3211<xref linkend='XtGetValues' xrefstyle='select: title'/>. 3212</para> 3213 3214<funcsynopsis id='XtGetValues'> 3215<funcprototype> 3216<funcdef>void <function>XtGetValues</function></funcdef> 3217 <paramdef>Widget <parameter>object</parameter></paramdef> 3218 <paramdef>ArgList <parameter>args</parameter></paramdef> 3219 <paramdef>Cardinal <parameter>num_args</parameter></paramdef> 3220</funcprototype> 3221</funcsynopsis> 3222 3223<variablelist> 3224 <varlistentry> 3225 <term> 3226 <emphasis remap='I'>object</emphasis> 3227 </term> 3228 <listitem> 3229 <para> 3230Specifies the object whose resource values are to be returned. Must be of class Object or any subclass thereof. 3231 </para> 3232 </listitem> 3233 </varlistentry> 3234 <varlistentry> 3235 <term> 3236 <emphasis remap='I'>args</emphasis> 3237 </term> 3238 <listitem> 3239 <para> 3240Specifies the argument list of name/address pairs that contain the 3241resource names and the addresses into which the resource values are to 3242be stored. 3243The resource names are widget-dependent. 3244 </para> 3245 </listitem> 3246 </varlistentry> 3247 <varlistentry> 3248 <term> 3249 <emphasis remap='I'>num_args</emphasis> 3250 </term> 3251 <listitem> 3252 <para> 3253Specifies the number of entries in the argument list. 3254 </para> 3255 </listitem> 3256 </varlistentry> 3257</variablelist> 3258 3259<para> 3260The 3261<xref linkend='XtGetValues' xrefstyle='select: title'/> 3262function starts with the resources specified for the Object class 3263and proceeds down the subclass chain to the class of the object. 3264The <emphasis remap='I'>value</emphasis> field of a passed argument list must contain the 3265address into which to copy the contents of the corresponding 3266object instance field. If the field is a pointer type, the lifetime 3267of the pointed-to data is defined by the object class. For the 3268Intrinsics-defined resources, the following lifetimes apply: 3269</para> 3270<itemizedlist spacing='compact'> 3271 <listitem> 3272 <para> 3273Not valid following any operation that modifies the resource: 3274 </para> 3275 <itemizedlist spacing='compact'> 3276 <listitem> 3277 <para> 3278XtNchildren resource of composite widgets. 3279 </para> 3280 </listitem> 3281 <listitem> 3282 <para> 3283All resources of representation type XtRCallback. 3284 </para> 3285 </listitem> 3286 </itemizedlist> 3287 </listitem> 3288 <listitem> 3289 <para> 3290Remain valid at least until the widget is destroyed: 3291 </para> 3292 <itemizedlist spacing='compact'> 3293 <listitem> 3294 <para> 3295XtNaccelerators, XtNtranslations. 3296 </para> 3297 </listitem> 3298 </itemizedlist> 3299 </listitem> 3300 <listitem> 3301 <para> 3302Remain valid until the Display is closed: 3303 </para> 3304 <itemizedlist spacing='compact'> 3305 <listitem> 3306 <para> 3307XtNscreen. 3308 </para> 3309 </listitem> 3310 </itemizedlist> 3311 </listitem> 3312</itemizedlist> 3313<para> 3314It is the caller's responsibility 3315to allocate and deallocate storage for the copied data 3316according to the size of the 3317resource representation type used within the object. 3318</para> 3319 3320<para> 3321If the class of the object's parent is a subclass of 3322<function>constraintWidgetClass</function>, 3323<xref linkend='XtGetValues' xrefstyle='select: title'/> 3324then fetches the values for any constraint resources requested. 3325It starts with the constraint resources specified for 3326<function>constraintWidgetClass</function> 3327and proceeds down the subclass chain to the parent's constraint resources. 3328If the argument list contains a resource name that is not found in any of the 3329resource lists searched, 3330the value at the corresponding address is not modified. 3331If any get_values_hook procedures in the 3332object's class or superclass records are non-NULL, 3333they are called in superclass-to-subclass order after 3334all the resource values have been fetched by 3335<xref linkend='XtGetValues' xrefstyle='select: title'/>. 3336Finally, if the object's parent is a 3337subclass of 3338<function>constraintWidgetClass</function>, 3339and if any of the parent's class or 3340superclass records have declared 3341<function>ConstraintClassExtension</function> 3342records in 3343the Constraint class part <emphasis remap='I'>extension</emphasis> field with a record type of 3344<emphasis role='strong'>NULLQUARK</emphasis>, 3345and if the <emphasis remap='I'>get_values_hook</emphasis> field in the extension record is non-NULL, 3346<xref linkend='XtGetValues' xrefstyle='select: title'/> 3347calls the get_values_hook procedures in superclass-to-subclass order. 3348This permits a Constraint parent to provide 3349nonresource data via 3350<xref linkend='XtGetValues' xrefstyle='select: title'/>. 3351</para> 3352 3353<para> 3354Get_values_hook procedures may modify the data stored at the 3355location addressed by the <emphasis remap='I'>value</emphasis> field, including (but not 3356limited to) making a copy of data whose resource representation is a 3357pointer. None of the Intrinsics-defined object classes copy 3358data in this manner. Any operation that modifies the queried 3359object resource may invalidate the pointed-to data. 3360</para> 3361 3362<para> 3363To retrieve the current values of resources associated with a widget 3364instance using varargs lists, use 3365<xref linkend='XtVaGetValues' xrefstyle='select: title'/>. 3366</para> 3367 3368<funcsynopsis id='XtVaGetValues'> 3369<funcprototype> 3370<funcdef>void <function>XtVaGetValues</function></funcdef> 3371 <paramdef>Widget <parameter>object</parameter></paramdef> 3372 <paramdef><parameter>...</parameter></paramdef> 3373</funcprototype> 3374</funcsynopsis> 3375 3376<variablelist> 3377 <varlistentry> 3378 <term> 3379 <emphasis remap='I'>object</emphasis> 3380 </term> 3381 <listitem> 3382 <para> 3383Specifies the object whose resource values are to be returned. Must be of class Object or any subclass thereof. 3384 </para> 3385 </listitem> 3386 </varlistentry> 3387 <varlistentry> 3388 <term> 3389 ... 3390 </term> 3391 <listitem> 3392 <para> 3393Specifies the variable argument list for the resources to 3394be returned. 3395 </para> 3396 </listitem> 3397 </varlistentry> 3398</variablelist> 3399 3400<para> 3401<xref linkend='XtVaGetValues' xrefstyle='select: title'/> 3402is identical in function to 3403<xref linkend='XtGetValues' xrefstyle='select: title'/> 3404with the <emphasis remap='I'>args</emphasis> 3405and <emphasis remap='I'>num_args</emphasis> parameters replaced by a varargs list, as described in 3406Section 2.5.1. All value entries in the list must specify pointers to 3407storage allocated by the caller to which the resource value will be 3408copied. It is the caller's responsibility to ensure that sufficient 3409storage is allocated. If 3410<function>XtVaTypedArg</function> 3411is specified, the <emphasis remap='I'>type</emphasis> argument 3412specifies the representation desired by the caller and <emphasis remap='I'>the</emphasis> size argument 3413specifies the number of bytes allocated to store the result of the 3414conversion. If the size is insufficient, a warning message is issued 3415and the list entry is skipped. 3416</para> 3417<sect3 id="Widget_Subpart_Resource_Data_The_get_values_hook_Procedure"> 3418<title>Widget Subpart Resource Data: The get_values_hook Procedure</title> 3419<para> 3420Widgets that have subparts can return resource values from them through 3421<xref linkend='XtGetValues' xrefstyle='select: title'/> 3422by supplying a get_values_hook procedure. 3423The get_values_hook procedure pointer is of type 3424<xref linkend='XtArgsProc' xrefstyle='select: title'/>. 3425</para> 3426 3427<funcsynopsis id='_XtArgsProc'> 3428<funcprototype> 3429<funcdef>typedef void <function>(*XtArgsProc)</function></funcdef> 3430 3431 <paramdef>Widget <parameter>w</parameter></paramdef> 3432 <paramdef>ArgList <parameter>args</parameter></paramdef> 3433 <paramdef>Cardinal *<parameter>num_args</parameter></paramdef> 3434</funcprototype> 3435</funcsynopsis> 3436 3437<variablelist> 3438 <varlistentry> 3439 <term> 3440 <emphasis remap='I'>w</emphasis> 3441 </term> 3442 <listitem> 3443 <para> 3444Specifies the widget whose subpart resource values are to be retrieved. 3445 </para> 3446 </listitem> 3447 </varlistentry> 3448 <varlistentry> 3449 <term> 3450 <emphasis remap='I'>args</emphasis> 3451 </term> 3452 <listitem> 3453 <para> 3454Specifies the argument list that was passed to 3455<xref linkend='XtGetValues' xrefstyle='select: title'/> 3456or the transformed varargs list passed to 3457<xref linkend='XtVaGetValues' xrefstyle='select: title'/>. 3458 </para> 3459 </listitem> 3460 </varlistentry> 3461 <varlistentry> 3462 <term> 3463 <emphasis remap='I'>num_args</emphasis> 3464 </term> 3465 <listitem> 3466 <para> 3467Specifies the number of entries in the argument list. 3468 </para> 3469 </listitem> 3470 </varlistentry> 3471</variablelist> 3472 3473<para> 3474The widget with subpart resources should call 3475<xref linkend='XtGetSubvalues' xrefstyle='select: title'/> 3476in the get_values_hook procedure 3477and pass in its subresource list and the <emphasis remap='I'>args</emphasis> and <emphasis remap='I'>num_args</emphasis> parameters. 3478</para> 3479</sect3> 3480<sect3 id="Widget_Subpart_State"> 3481<title>Widget Subpart State</title> 3482<para> 3483To retrieve the current values of subpart resource data associated with a 3484widget instance, use 3485<xref linkend='XtGetSubvalues' xrefstyle='select: title'/>. 3486For a discussion of subpart resources, 3487see <xref linkend='Subresources' />. 3488</para> 3489 3490<funcsynopsis id='XtGetSubvalues'> 3491<funcprototype> 3492<funcdef>void <function>XtGetSubvalues</function></funcdef> 3493 <paramdef>XtPointer <parameter>base</parameter></paramdef> 3494 <paramdef>XtResourceList <parameter>resources</parameter></paramdef> 3495 <paramdef>Cardinal <parameter>num_resources</parameter></paramdef> 3496 <paramdef>ArgList <parameter>args</parameter></paramdef> 3497 <paramdef>Cardinal <parameter>num_args</parameter></paramdef> 3498</funcprototype> 3499</funcsynopsis> 3500 3501<variablelist> 3502 <varlistentry> 3503 <term> 3504 <emphasis remap='I'>base</emphasis> 3505 </term> 3506 <listitem> 3507 <para> 3508Specifies the base address of the subpart data structure for which the 3509resources should be retrieved. 3510 </para> 3511 </listitem> 3512 </varlistentry> 3513 <varlistentry> 3514 <term> 3515 <emphasis remap='I'>resources</emphasis> 3516 </term> 3517 <listitem> 3518 <para> 3519Specifies the subpart resource list. 3520 </para> 3521 </listitem> 3522 </varlistentry> 3523 <varlistentry> 3524 <term> 3525 <emphasis remap='I'>num_resources</emphasis> 3526 </term> 3527 <listitem> 3528 <para> 3529Specifies the number of entries in the resource list. 3530 </para> 3531 </listitem> 3532 </varlistentry> 3533 <varlistentry> 3534 <term> 3535 <emphasis remap='I'>args</emphasis> 3536 </term> 3537 <listitem> 3538 <para> 3539Specifies the argument list of name/address pairs that contain the 3540resource names and the addresses into which the resource values are to 3541be stored. 3542 </para> 3543 </listitem> 3544 </varlistentry> 3545 <varlistentry> 3546 <term> 3547 <emphasis remap='I'>num_args</emphasis> 3548 </term> 3549 <listitem> 3550 <para> 3551Specifies the number of entries in the argument list. 3552 </para> 3553 </listitem> 3554 </varlistentry> 3555</variablelist> 3556 3557<para> 3558The 3559<xref linkend='XtGetSubvalues' xrefstyle='select: title'/> 3560function obtains resource values from the structure identified by <emphasis remap='I'>base</emphasis>. 3561The <emphasis remap='I'>value</emphasis> field in each argument entry must contain the address into 3562which to store the corresponding resource value. It is the caller's 3563responsibility to allocate and deallocate this storage according to 3564the size of the resource representation type used within the subpart. 3565If the argument list contains a resource name that is not found in the 3566resource list, the value at the corresponding address is not modified. 3567</para> 3568 3569<para> 3570To retrieve the current values of subpart resources associated with 3571a widget instance using varargs lists, use 3572<xref linkend='XtVaGetSubvalues' xrefstyle='select: title'/>. 3573</para> 3574 3575<funcsynopsis id='XtVaGetSubvalues'> 3576<funcprototype> 3577<funcdef>void <function>XtVaGetSubvalues</function></funcdef> 3578 <paramdef>XtPointer <parameter>base</parameter></paramdef> 3579 <paramdef>XtResourceList <parameter>resources</parameter></paramdef> 3580 <paramdef>Cardinal <parameter>num_resources</parameter></paramdef> 3581 <paramdef> <parameter>...</parameter></paramdef> 3582</funcprototype> 3583</funcsynopsis> 3584 3585<variablelist> 3586 <varlistentry> 3587 <term> 3588 <emphasis remap='I'>base</emphasis> 3589 </term> 3590 <listitem> 3591 <para> 3592Specifies the base address of the subpart data structure for which the 3593resources should be retrieved. 3594 </para> 3595 </listitem> 3596 </varlistentry> 3597 <varlistentry> 3598 <term> 3599 <emphasis remap='I'>resources</emphasis> 3600 </term> 3601 <listitem> 3602 <para> 3603Specifies the subpart resource list. 3604 </para> 3605 </listitem> 3606 </varlistentry> 3607 <varlistentry> 3608 <term> 3609 <emphasis remap='I'>num_resources</emphasis> 3610 </term> 3611 <listitem> 3612 <para> 3613Specifies the number of entries in the resource list. 3614 </para> 3615 </listitem> 3616 </varlistentry> 3617 <varlistentry> 3618 <term> 3619 ... 3620 </term> 3621 <listitem> 3622 <para> 3623Specifies a variable argument list of name/address pairs that 3624contain the resource names and the addresses into which the resource 3625values are to be stored. 3626 </para> 3627 </listitem> 3628 </varlistentry> 3629</variablelist> 3630 3631<para> 3632<xref linkend='XtVaGetSubvalues' xrefstyle='select: title'/> 3633is identical in function to 3634<xref linkend='XtGetSubvalues' xrefstyle='select: title'/> 3635with the 3636<emphasis remap='I'>args</emphasis> and <emphasis remap='I'>num_args</emphasis> parameters replaced by a varargs list, as described 3637in Section 2.5.1. 3638<function>XtVaTypedArg</function> 3639is not supported for 3640<xref linkend='XtVaGetSubvalues' xrefstyle='select: title'/>. 3641If 3642<function>XtVaTypedArg</function> 3643is specified in the list, a warning message is issued 3644and the entry is then ignored. 3645</para> 3646</sect3> 3647</sect2> 3648 3649<sect2 id="Setting_Widget_State"> 3650<title>Setting Widget State</title> 3651<para> 3652To modify the current values of resources associated with a widget 3653instance, use 3654<xref linkend='XtSetValues' xrefstyle='select: title'/>. 3655</para> 3656 3657<funcsynopsis id='XtSetValues'> 3658<funcprototype> 3659<funcdef>void <function>XtSetValues</function></funcdef> 3660 <paramdef>Widget <parameter>object</parameter></paramdef> 3661 <paramdef>ArgList <parameter>args</parameter></paramdef> 3662 <paramdef>Cardinal <parameter>num_args</parameter></paramdef> 3663</funcprototype> 3664</funcsynopsis> 3665 3666<variablelist> 3667 <varlistentry> 3668 <term> 3669 <emphasis remap='I'>object</emphasis> 3670 </term> 3671 <listitem> 3672 <para> 3673Specifies the object whose resources are to be modified. Must be of class Object or any subclass thereof. 3674 </para> 3675 </listitem> 3676 </varlistentry> 3677 <varlistentry> 3678 <term> 3679 <emphasis remap='I'>args</emphasis> 3680 </term> 3681 <listitem> 3682 <para> 3683Specifies the argument list of name/value pairs that contain the 3684resources to be modified and their new values. 3685 </para> 3686 </listitem> 3687 </varlistentry> 3688 <varlistentry> 3689 <term> 3690 <emphasis remap='I'>num_args</emphasis> 3691 </term> 3692 <listitem> 3693 <para> 3694Specifies the number of entries in the argument list. 3695 </para> 3696 </listitem> 3697 </varlistentry> 3698</variablelist> 3699 3700<para> 3701The 3702<xref linkend='XtSetValues' xrefstyle='select: title'/> 3703function starts with the resources specified for the 3704Object 3705class fields and proceeds down the subclass chain to the object. 3706At each stage, it replaces the <emphasis remap='I'>object</emphasis> resource fields with any values 3707specified in the argument list. 3708<xref linkend='XtSetValues' xrefstyle='select: title'/> 3709then calls the set_values procedures for the object in superclass-to-subclass 3710order. 3711If the object has any non-NULL <emphasis remap='I'>set_values_hook</emphasis> fields, 3712these are called immediately after the 3713corresponding set_values procedure. 3714This procedure permits subclasses to set subpart data via 3715<xref linkend='XtSetValues' xrefstyle='select: title'/>. 3716</para> 3717 3718<para> 3719If the class of the object's parent is a subclass of 3720<function>constraintWidgetClass</function>, 3721<xref linkend='XtSetValues' xrefstyle='select: title'/> 3722also updates the object's constraints. 3723It starts with the constraint resources specified for 3724<function>constraintWidgetClass</function> 3725and proceeds down the subclass chain to the parent's class. 3726At each stage, it replaces the constraint resource fields with any 3727values specified in the argument list. 3728It then calls the constraint set_values procedures from 3729<function>constraintWidgetClass</function> 3730down to the parent's class. 3731The constraint set_values procedures are called with widget arguments, 3732as for all set_values procedures, not just the constraint records, 3733so that they can make adjustments to the desired values based 3734on full information about the widget. Any arguments specified that 3735do not match a resource list entry are silently ignored. 3736</para> 3737 3738<para> 3739If the object is of a subclass of 3740RectObj, 3741<xref linkend='XtSetValues' xrefstyle='select: title'/> 3742determines if a geometry request is needed by comparing the old object to 3743the new object. 3744If any geometry changes are required, 3745<xref linkend='XtSetValues' xrefstyle='select: title'/> 3746restores the original geometry and makes the request on behalf of the widget. 3747If the geometry manager returns 3748<function>XtGeometryYes</function>, 3749<xref linkend='XtSetValues' xrefstyle='select: title'/> 3750calls the object's resize procedure. 3751If the geometry manager returns 3752<function>XtGeometryDone</function>, 3753<xref linkend='XtSetValues' xrefstyle='select: title'/> 3754continues, as the object's resize procedure should have been called 3755by the geometry manager. 3756If the geometry manager returns 3757<function>XtGeometryNo</function>, 3758<xref linkend='XtSetValues' xrefstyle='select: title'/> 3759ignores the geometry request and continues. 3760If the geometry manager returns 3761<function>XtGeometryAlmost</function>, 3762<xref linkend='XtSetValues' xrefstyle='select: title'/> 3763calls the set_values_almost procedure, 3764which determines what should be done. 3765<xref linkend='XtSetValues' xrefstyle='select: title'/> 3766then repeats this process, 3767deciding once more whether the geometry manager should be called. 3768</para> 3769 3770<para> 3771Finally, if any of the set_values procedures returned 3772<function>True</function>, 3773and the widget is realized, 3774<xref linkend='XtSetValues' xrefstyle='select: title'/> 3775causes the widget's expose procedure to be invoked by calling 3776<function>XClearArea</function> 3777on the widget's window. 3778</para> 3779 3780<para> 3781To modify the current values of resources associated with a widget 3782instance using varargs lists, use 3783<xref linkend='XtVaSetValues' xrefstyle='select: title'/>. 3784</para> 3785 3786<funcsynopsis id='XtVaSetValues'> 3787<funcprototype> 3788<funcdef>void <function>XtVaSetValues</function></funcdef> 3789 <paramdef>Widget <parameter>object</parameter></paramdef> 3790 <paramdef> <parameter>...</parameter></paramdef> 3791</funcprototype> 3792</funcsynopsis> 3793 3794<variablelist> 3795 <varlistentry> 3796 <term> 3797 <emphasis remap='I'>object</emphasis> 3798 </term> 3799 <listitem> 3800 <para> 3801Specifies the object whose resources are to be modified. Must be of class Object or any subclass thereof. 3802 </para> 3803 </listitem> 3804 </varlistentry> 3805 <varlistentry> 3806 <term> 3807 ... 3808 </term> 3809 <listitem> 3810 <para> 3811Specifies the variable argument list of name/value pairs that 3812contain the resources to be modified and their new values. 3813 </para> 3814 </listitem> 3815 </varlistentry> 3816</variablelist> 3817 3818<para> 3819<xref linkend='XtVaSetValues' xrefstyle='select: title'/> 3820is identical in function to 3821<xref linkend='XtSetValues' xrefstyle='select: title'/> 3822with the <emphasis remap='I'>args</emphasis> and <emphasis remap='I'>num_args</emphasis> parameters replaced by a varargs list, as 3823described in Section 2.5.1. 3824</para> 3825<sect3 id="Widget_State_The_set_values_Procedure"> 3826<title>Widget State: The set_values Procedure</title> 3827<para> 3828The set_values procedure pointer in a widget class is of type 3829<xref linkend='XtSetValuesFunc' xrefstyle='select: title'/>. 3830</para> 3831 3832<funcsynopsis id='XtSetValuesFunc'> 3833<funcprototype> 3834<funcdef>typedef Boolean <function>(*XtSetValuesFunc)</function></funcdef> 3835 3836 <paramdef>Widget <parameter>current</parameter></paramdef> 3837 <paramdef>Widget <parameter>request</parameter></paramdef> 3838 <paramdef>Widget <parameter>new</parameter></paramdef> 3839 <paramdef>ArgList <parameter>args</parameter></paramdef> 3840 <paramdef>Cardinal *<parameter>num_args</parameter></paramdef> 3841</funcprototype> 3842</funcsynopsis> 3843 3844<variablelist> 3845 <varlistentry> 3846 <term> 3847 <emphasis remap='I'>current</emphasis> 3848 </term> 3849 <listitem> 3850 <para> 3851Specifies a copy of the widget as it was before the 3852<xref linkend='XtSetValues' xrefstyle='select: title'/> 3853call. 3854 </para> 3855 </listitem> 3856 </varlistentry> 3857 <varlistentry> 3858 <term> 3859 <emphasis remap='I'>request</emphasis> 3860 </term> 3861 <listitem> 3862 <para> 3863Specifies a copy of the widget with all values changed as asked for by the 3864<xref linkend='XtSetValues' xrefstyle='select: title'/> 3865call before any class set_values procedures have been called. 3866 </para> 3867 </listitem> 3868 </varlistentry> 3869 <varlistentry> 3870 <term> 3871 <emphasis remap='I'>new</emphasis> 3872 </term> 3873 <listitem> 3874 <para> 3875Specifies the widget with the new values that are actually allowed. 3876 </para> 3877 </listitem> 3878 </varlistentry> 3879 <varlistentry> 3880 <term> 3881 <emphasis remap='I'>args</emphasis> 3882 </term> 3883 <listitem> 3884 <para> 3885Specifies the argument list passed to 3886<xref linkend='XtSetValues' xrefstyle='select: title'/> 3887or the transformed argument list passed to 3888<xref linkend='XtVaSetValues' xrefstyle='select: title'/>. 3889 </para> 3890 </listitem> 3891 </varlistentry> 3892 <varlistentry> 3893 <term> 3894 <emphasis remap='I'>num_args</emphasis> 3895 </term> 3896 <listitem> 3897 <para> 3898Specifies the number of entries in the argument list. 3899 </para> 3900 </listitem> 3901 </varlistentry> 3902</variablelist> 3903 3904<para> 3905The set_values procedure should recompute any field 3906derived from resources that are changed 3907(for example, many GCs depend on foreground and background pixels). 3908If no recomputation is necessary, and if none of the resources specific to a 3909subclass require the window to be redisplayed when their values are changed, 3910you can specify NULL for the <emphasis remap='I'>set_values</emphasis> field in the class record. 3911</para> 3912 3913<para> 3914Like the initialize procedure, 3915set_values mostly deals only with the fields defined in the subclass, 3916but it has to resolve conflicts with its superclass, 3917especially conflicts over width and height. 3918</para> 3919 3920<para> 3921Sometimes a subclass may want to overwrite values filled in by its 3922superclass. 3923In particular, size calculations of a superclass are often 3924incorrect for a subclass, and, in this case, 3925the subclass must modify or recalculate fields declared 3926and computed by its superclass. 3927</para> 3928 3929<para> 3930As an example, 3931a subclass can visually surround its superclass display. 3932In this case, the width and height calculated by the superclass set_values 3933procedure are too small and need to be incremented by the size of the surround. 3934The subclass needs to know if its superclass's size was calculated by the 3935superclass or was specified explicitly. 3936All widgets must place themselves into whatever size is explicitly given, 3937but they should compute a reasonable size if no size is requested. 3938How does a subclass know the difference between a specified size 3939and a size computed by a superclass? 3940</para> 3941 3942<para> 3943The <emphasis remap='I'>request</emphasis> and <emphasis remap='I'>new</emphasis> parameters provide the necessary information. 3944The <emphasis remap='I'>request</emphasis> widget is a copy of the widget, updated as originally requested. 3945The <emphasis remap='I'>new</emphasis> widget starts with the values in the request, 3946but it has additionally been updated by all superclass set_values 3947procedures called so far. 3948A subclass set_values procedure can compare these two to resolve 3949any potential conflicts. 3950The set_values procedure need not refer to the <emphasis remap='I'>request</emphasis> widget 3951unless it must resolve conflicts between the <emphasis remap='I'>current</emphasis> and <emphasis remap='I'>new</emphasis> widgets. 3952Any changes the widget needs to make, including geometry changes, 3953should be made in the <emphasis remap='I'>new</emphasis> widget. 3954</para> 3955 3956<para> 3957In the above example, 3958the subclass with the visual surround can see 3959if the <emphasis remap='I'>width</emphasis> and <emphasis remap='I'>height</emphasis> in the <emphasis remap='I'>request</emphasis> widget are zero. 3960If so, 3961it adds its surround size to the <emphasis remap='I'>width</emphasis> and 3962<emphasis remap='I'>height</emphasis> fields in the <emphasis remap='I'>new</emphasis> widget. 3963If not, it must make do with the size originally specified. 3964In this case, zero is a special value defined by the class to permit 3965the application to invoke this behavior. 3966</para> 3967 3968<para> 3969The <emphasis remap='I'>new</emphasis> widget is the actual widget instance record. 3970Therefore, 3971the set_values procedure should do all its work on the <emphasis remap='I'>new</emphasis> widget; 3972the <emphasis remap='I'>request</emphasis> widget should never be modified. 3973If the set_values procedure needs to call any routines that operate on 3974a widget, it should specify <emphasis remap='I'>new</emphasis> as the widget instance. 3975</para> 3976 3977<para> 3978Before calling the set_values procedures, the Intrinsics modify the 3979resources of the <emphasis remap='I'>request</emphasis> widget according to the contents of the arglist; 3980if the widget names all its resources in the class resource list, it is 3981never necessary to examine the contents of <emphasis remap='I'>args</emphasis>. 3982</para> 3983 3984<para> 3985Finally, the set_values procedure must return a Boolean that indicates whether 3986the widget needs to be redisplayed. 3987Note that a change in the geometry fields alone does not require 3988the set_values procedure to return 3989<function>True</function>; 3990the X server will eventually generate an 3991<function>Expose</function> 3992event, if necessary. 3993After calling all the set_values procedures, 3994<xref linkend='XtSetValues' xrefstyle='select: title'/> 3995forces a redisplay by calling 3996<function>XClearArea</function> 3997if any of the set_values procedures returned 3998<function>True</function>. 3999Therefore, a set_values procedure should not try to do its own redisplaying. 4000</para> 4001 4002<para> 4003Set_values procedures should not do any work in response to changes in 4004geometry because 4005<xref linkend='XtSetValues' xrefstyle='select: title'/> 4006eventually will perform a geometry request, and that request might be denied. 4007If the widget actually changes size in response to a 4008call to 4009<xref linkend='XtSetValues' xrefstyle='select: title'/>, 4010its resize procedure is called. 4011Widgets should do any geometry-related work in their resize procedure. 4012</para> 4013 4014<para> 4015Note that it is permissible to call 4016<xref linkend='XtSetValues' xrefstyle='select: title'/> 4017before a widget is realized. 4018Therefore, the set_values procedure must not assume that the widget is realized. 4019</para> 4020</sect3> 4021<sect3 id="Widget_State_The_set_values_almost_Procedure"> 4022<title>Widget State: The set_values_almost Procedure</title> 4023<para> 4024The set_values_almost procedure pointer in the widget class record is of type 4025<xref linkend='XtAlmostProc' xrefstyle='select: title'/>. 4026</para> 4027 4028<funcsynopsis id='XtAlmostProc'> 4029<funcprototype> 4030<funcdef>typedef void <function>(*XtAlmostProc)</function></funcdef> 4031 4032 <paramdef>Widget <parameter>old</parameter></paramdef> 4033 <paramdef>Widget <parameter>new</parameter></paramdef> 4034 <paramdef>XtWidgetGeometry *<parameter>request</parameter></paramdef> 4035 <paramdef>XtWidgetGeometry *<parameter>reply</parameter></paramdef> 4036</funcprototype> 4037</funcsynopsis> 4038 4039<variablelist> 4040 <varlistentry> 4041 <term> 4042 <emphasis remap='I'>old</emphasis> 4043 </term> 4044 <listitem> 4045 <para> 4046Specifies a copy of the object as it was before the 4047<xref linkend='XtSetValues' xrefstyle='select: title'/> 4048call. 4049 </para> 4050 </listitem> 4051 </varlistentry> 4052 <varlistentry> 4053 <term> 4054 <emphasis remap='I'>new</emphasis> 4055 </term> 4056 <listitem> 4057 <para> 4058Specifies the object instance record. 4059 </para> 4060 </listitem> 4061 </varlistentry> 4062 <varlistentry> 4063 <term> 4064 <emphasis remap='I'>request</emphasis> 4065 </term> 4066 <listitem> 4067 <para> 4068Specifies the original geometry request that was sent to the geometry 4069manager that caused 4070<function>XtGeometryAlmost</function> 4071to be returned. 4072 </para> 4073 </listitem> 4074 </varlistentry> 4075 <varlistentry> 4076 <term> 4077 <emphasis remap='I'>reply</emphasis> 4078 </term> 4079 <listitem> 4080 <para> 4081Specifies the compromise geometry that was returned by the geometry 4082manager with 4083<function>XtGeometryAlmost</function>. 4084 </para> 4085 </listitem> 4086 </varlistentry> 4087</variablelist> 4088 4089<para> 4090Most classes inherit the set_values_almost procedure from their superclass by 4091specifying 4092<function>XtInheritSetValuesAlmost</function> 4093in the class initialization. 4094The 4095set_values_almost procedure in 4096<function>rectObjClass</function> 4097accepts the compromise suggested. 4098</para> 4099 4100<para> 4101The set_values_almost procedure is called when a client tries to set a widget's 4102geometry by means of a call to 4103<xref linkend='XtSetValues' xrefstyle='select: title'/> 4104and the geometry manager cannot 4105satisfy the request but instead returns 4106<function>XtGeometryNo</function> 4107or 4108<function>XtGeometryAlmost</function> 4109and a compromise geometry. 4110The <emphasis remap='I'>new</emphasis> object is the actual instance record. The <emphasis remap='I'>x</emphasis>, <emphasis remap='I'>y</emphasis>, 4111<emphasis remap='I'>width</emphasis>, <emphasis remap='I'>height</emphasis>, 4112and <emphasis remap='I'>border_width</emphasis> fields contain the original values as they were 4113before the 4114<xref linkend='XtSetValues' xrefstyle='select: title'/> 4115call, and all other fields contain the new 4116values. The <emphasis remap='I'>request</emphasis> parameter contains the new geometry request that 4117was made to the parent. The <emphasis remap='I'>reply</emphasis> parameter contains 4118<emphasis remap='I'>reply->request_mode</emphasis> equal to zero if the parent returned 4119<function>XtGeometryNo</function> 4120and contains the parent's compromise geometry otherwise. The 4121set_values_almost procedure takes the original geometry and the 4122compromise geometry and determines if the compromise is 4123acceptable or whether 4124to try a different compromise. 4125It returns its results in the <emphasis remap='I'>request</emphasis> parameter, 4126which is then sent back to the geometry manager for another try. 4127To accept the compromise, the procedure must copy the contents 4128of the <emphasis remap='I'>reply</emphasis> geometry into the <emphasis remap='I'>request</emphasis> geometry; to attempt an 4129alternative geometry, the procedure may modify any part of the <emphasis remap='I'>request</emphasis> 4130argument; to terminate the geometry negotiation and retain the 4131original geometry, the procedure must set <emphasis remap='I'>request->request_mode</emphasis> to 4132zero. The geometry fields of the <emphasis remap='I'>old</emphasis> and <emphasis remap='I'>new</emphasis> instances must not be modified 4133directly. 4134</para> 4135</sect3> 4136<sect3 id="Widget_State_The_ConstraintClassPart_set_values_Procedure"> 4137<title>Widget State: The ConstraintClassPart set_values Procedure</title> 4138<para> 4139The constraint set_values procedure pointer is of type 4140<xref linkend='XtSetValuesFunc' xrefstyle='select: title'/>. 4141The values passed to the parent's constraint set_values procedure 4142are the same as those passed to the child's class 4143set_values procedure. 4144A class can specify NULL for the <emphasis remap='I'>set_values</emphasis> field of the 4145<function>ConstraintPart</function> 4146if it need not compute anything. 4147</para> 4148 4149<para> 4150The constraint set_values procedure should recompute any constraint fields 4151derived from constraint resources that are changed. 4152Furthermore, it may modify other widget fields as appropriate. 4153For example, if a constraint for the maximum height of a widget is changed 4154to a value smaller than the widget's current height, 4155the constraint set_values procedure may reset the <emphasis remap='I'>height</emphasis> field in the 4156widget. 4157</para> 4158</sect3> 4159<sect3 id='Widget_Subpart_State_2'> 4160<title>Widget Subpart State</title> 4161<para> 4162To set the current values of subpart resources associated with a 4163widget instance, use 4164<xref linkend='XtSetSubvalues' xrefstyle='select: title'/>. 4165For a discussion of subpart resources, 4166see <xref linkend='Subresources' />. 4167</para> 4168 4169<funcsynopsis id='XtSetSubvalues'> 4170<funcprototype> 4171<funcdef>void <function>XtSetSubvalues</function></funcdef> 4172 <paramdef>XtPointer <parameter>base</parameter></paramdef> 4173 <paramdef>XtResourceList <parameter>resources</parameter></paramdef> 4174 <paramdef>Cardinal <parameter>num_resources</parameter></paramdef> 4175 <paramdef>ArgList <parameter>args</parameter></paramdef> 4176 <paramdef>Cardinal <parameter>num_args</parameter></paramdef> 4177</funcprototype> 4178</funcsynopsis> 4179 4180<variablelist> 4181 <varlistentry> 4182 <term> 4183 <emphasis remap='I'>base</emphasis> 4184 </term> 4185 <listitem> 4186 <para> 4187Specifies the base address of the subpart data structure into which the 4188resources should be written. 4189 </para> 4190 </listitem> 4191 </varlistentry> 4192 <varlistentry> 4193 <term> 4194 <emphasis remap='I'>resources</emphasis> 4195 </term> 4196 <listitem> 4197 <para> 4198Specifies the subpart resource list. 4199 </para> 4200 </listitem> 4201 </varlistentry> 4202 <varlistentry> 4203 <term> 4204 <emphasis remap='I'>num_resources</emphasis> 4205 </term> 4206 <listitem> 4207 <para> 4208Specifies the number of entries in the resource list. 4209 </para> 4210 </listitem> 4211 </varlistentry> 4212 <varlistentry> 4213 <term> 4214 <emphasis remap='I'>args</emphasis> 4215 </term> 4216 <listitem> 4217 <para> 4218Specifies the argument list of name/value pairs that contain the 4219resources to be modified and their new values. 4220 </para> 4221 </listitem> 4222 </varlistentry> 4223 <varlistentry> 4224 <term> 4225 <emphasis remap='I'>num_args</emphasis> 4226 </term> 4227 <listitem> 4228 <para> 4229Specifies the number of entries in the argument list. 4230 </para> 4231 </listitem> 4232 </varlistentry> 4233</variablelist> 4234 4235<para> 4236The 4237<xref linkend='XtSetSubvalues' xrefstyle='select: title'/> 4238function updates the resource fields of the structure identified by 4239<emphasis remap='I'>base</emphasis>. Any specified arguments that do not match an entry in the 4240resource list are silently ignored. 4241</para> 4242 4243<para> 4244To set the current values of subpart resources associated with 4245a widget instance using varargs lists, use 4246<xref linkend='XtVaSetSubvalues' xrefstyle='select: title'/>. 4247</para> 4248 4249<funcsynopsis id='XtVaSetSubvalues'> 4250<funcprototype> 4251<funcdef>void <function>XtVaSetSubvalues</function></funcdef> 4252 <paramdef>XtPointer <parameter>base</parameter></paramdef> 4253 <paramdef>XtResourceList <parameter>resources</parameter></paramdef> 4254 <paramdef>Cardinal <parameter>num_resources</parameter></paramdef> 4255 <paramdef>...</paramdef> 4256</funcprototype> 4257</funcsynopsis> 4258 4259<variablelist> 4260 <varlistentry> 4261 <term> 4262 <emphasis remap='I'>base</emphasis> 4263 </term> 4264 <listitem> 4265 <para> 4266Specifies the base address of the subpart data structure into which the 4267resources should be written. 4268 </para> 4269 </listitem> 4270 </varlistentry> 4271 <varlistentry> 4272 <term> 4273 <emphasis remap='I'>resources</emphasis> 4274 </term> 4275 <listitem> 4276 <para> 4277Specifies the subpart resource list. 4278 </para> 4279 </listitem> 4280 </varlistentry> 4281 <varlistentry> 4282 <term> 4283 <emphasis remap='I'>num_resources</emphasis> 4284 </term> 4285 <listitem> 4286 <para> 4287Specifies the number of entries in the resource list. 4288 </para> 4289 </listitem> 4290 </varlistentry> 4291 <varlistentry> 4292 <term> 4293 ... 4294 </term> 4295 <listitem> 4296 <para> 4297Specifies the variable argument list of name/value pairs that 4298contain the resources to be modified and their new values. 4299 </para> 4300 </listitem> 4301 </varlistentry> 4302</variablelist> 4303 4304<para> 4305<xref linkend='XtVaSetSubvalues' xrefstyle='select: title'/> 4306is identical in function to 4307<xref linkend='XtSetSubvalues' xrefstyle='select: title'/> 4308with the <emphasis remap='I'>args</emphasis> and <emphasis remap='I'>num_args</emphasis> parameters replaced by a varargs list, as 4309described in Section 2.5.1. 4310<function>XtVaTypedArg</function> 4311is not supported for 4312<xref linkend='XtVaSetSubvalues' xrefstyle='select: title'/>. 4313If an entry containing 4314<function>XtVaTypedArg</function> 4315is specified in the list, a warning message is issued 4316and the entry is ignored. 4317</para> 4318</sect3> 4319 4320<sect3 id='Widget_Subpart_Resource_Data_The_set_values_hook_Procedure'> 4321<title>Widget Subpart Resource Data: The set_values_hook Procedure</title> 4322<note><para> 4323The set_values_hook procedure is obsolete, as the same information 4324is now available to the set_values procedure. The procedure has been 4325retained for those widgets that used it in versions prior to Release 4. 4326</para> 4327</note> 4328<para> 4329Widgets that have a subpart can set the subpart resource values through 4330<xref linkend='XtSetValues' xrefstyle='select: title'/> 4331by supplying a set_values_hook procedure. 4332The set_values_hook procedure pointer in a widget class is of type 4333<xref linkend='XtArgsFunc' xrefstyle='select: title'/>. 4334</para> 4335 4336<funcsynopsis id='XtArgsFunc'> 4337<funcprototype> 4338<funcdef>typedef Boolean <function>(*XtArgsFunc)</function></funcdef> 4339 <paramdef>Widget <parameter>w</parameter></paramdef> 4340 <paramdef>Arglist <parameter>args</parameter></paramdef> 4341 <paramdef>Cardinal *<parameter>num_args</parameter></paramdef> 4342</funcprototype> 4343</funcsynopsis> 4344 4345<variablelist> 4346 <varlistentry> 4347 <term> 4348 <emphasis remap='I'>w</emphasis> 4349 </term> 4350 <listitem> 4351 <para> 4352Specifies the widget whose subpart resource values are to be changed. 4353 </para> 4354 </listitem> 4355 </varlistentry> 4356 <varlistentry> 4357 <term> 4358 <emphasis remap='I'>args</emphasis> 4359 </term> 4360 <listitem> 4361 <para> 4362Specifies the argument list that was passed to 4363<xref linkend='XtSetValues' xrefstyle='select: title'/> 4364or the transformed varargs list passed to 4365<xref linkend='XtVaSetValues' xrefstyle='select: title'/>. 4366 </para> 4367 </listitem> 4368 </varlistentry> 4369 <varlistentry> 4370 <term> 4371 <emphasis remap='I'>num_args</emphasis> 4372 </term> 4373 <listitem> 4374 <para> 4375Specifies the number of entries in the argument list. 4376 </para> 4377 </listitem> 4378 </varlistentry> 4379</variablelist> 4380 4381<para> 4382The widget with subpart resources may call 4383<xref linkend='XtSetValues' xrefstyle='select: title'/> 4384from the set_values_hook procedure 4385and pass in its subresource list and the 4386<emphasis remap='I'>args</emphasis> and <emphasis remap='I'>num_args</emphasis> parameters. 4387</para> 4388</sect3> 4389</sect2> 4390</sect1> 4391</chapter> 4392