CH1.xml revision 994689c1
1<chapter id="athena_widgets_and_the_intrinsics"> 2<title>Athena Widgets and The Intrinsics</title> 3<para> 4The X Toolkit is made up of two distinct pieces, the Xt Intrinsics and a 5widget set. The Athena widget set is a sample implementation of a 6widget set built upon the Intrinsics. In the X Toolkit, a widget is the 7combination of an X window or subwindow and its associated input and 8output semantics. 9</para> 10<para> 11Because the Intrinsics provide the same basic functionality to all widget 12sets it may be possible to use widgets from the Athena widget set with 13other widget sets based upon the Intrinsics. Since widget sets may also 14implement private protocols, all functionality may not be available when 15mixing and matching widget sets. For information about the Intrinsics, see 16the <emphasis remap='I'>X Toolkit Intrinsics - C Language Interface</emphasis>. 17</para> 18<para> 19The Athena widget set is a library package layered on top of the Intrinsics 20and Xlib that provides a set of user interface tools sufficient to build 21a wide variety of applications. This layer extends the basic 22abstractions provided by X and provides the next layer of functionality 23primarily by supplying a cohesive set of sample widgets. Although the 24Intrinsics are a Consortium standard, there is no standard widget set. 25</para> 26 27<para> 28To the extent possible, the Intrinsics are "policy-free". The application 29environment and widget set, not the Intrinsics, define, implement, and 30enforce: 31</para> 32 33<itemizedlist> 34 <listitem><para>Policy</para></listitem> 35 <listitem><para>Consistency</para></listitem> 36 <listitem><para>Style</para></listitem> 37</itemizedlist> 38 39<para> 40Each individual widget implementation defines its own policy. The X Toolkit 41design allows for, but does not necessarily encourage, the free mixing 42of radically differing widget implementations. 43</para> 44 45<sect1 id="Introduction_to_the_tk"> 46<title>Introduction to the X Toolkit</title> 47<para> 48<!-- .LP --> 49<!-- .XS --> 50<!-- Introduction to the X Toolkit --> 51<!-- .XE --> 52<!-- .IN "introduction" "" "@DEF@" --> 53The X Toolkit provides tools that simplify the design of 54application user interfaces in the X Window System programming environment. 55It assists application programmers by providing a set of common 56underlying user-interface functions. It also lets widget programmers 57modify existing widgets, by subclassing, or add new widgets. By using 58the X Toolkit in their applications, programmers can present a similar 59user interface across applications to all workstation users. 60</para> 61<para> 62<!-- .LP --> 63The X Toolkit consists of: 64</para> 65<itemizedlist> 66 <listitem> 67 <para> 68A set of Intrinsics functions for building widgets 69 </para> 70 </listitem> 71 <listitem> 72 <para> 73An architectural model for constructing widgets 74 </para> 75 </listitem> 76 <listitem> 77 <para> 78A widget set for application programming 79 </para> 80 </listitem> 81</itemizedlist> 82<para> 83<!-- .LP --> 84While the majority of the Intrinsics functions are intended 85for the widget programmer, 86a subset of the Intrinsics functions are to be used by application programmers 87(see <emphasis remap='I'>X Toolkit Intrinsics - C Language Interface</emphasis>). 88The architectural model lets the widget programmer design new widgets 89by using the Intrinsics and by combining other widgets. 90The application interface layers built on top of the X Toolkit include a 91coordinated set of widgets and composition policies. 92Some of these widgets and policies are specific to a single 93application domain, and others are common to a variety of 94applications. 95</para> 96<para> 97<!-- .LP --> 98The remainder of this chapter discusses the X Toolkit and Athena widget set: 99</para> 100<itemizedlist> 101 <listitem> 102 <para> 103Terminology 104 </para> 105 </listitem> 106 <listitem> 107 <para> 108Model 109 </para> 110 </listitem> 111 <listitem> 112 <para> 113Conventions used in this manual 114 </para> 115 </listitem> 116 <listitem> 117 <para> 118Format of the Widget Reference Chapters 119 </para> 120 </listitem> 121</itemizedlist> 122</sect1> 123<sect1 id="Terminology"> 124<title>Terminology</title> 125<para> 126<!-- .LP --> 127<!-- .XS --> 128<!-- Terminology --> 129<!-- .XE --> 130</para> 131<para> 132<!-- .LP --> 133In addition to the terms already defined for X programming (see 134<emphasis remap='I'>Xlib - C Language Interface</emphasis>), 135the following terms are specific to the Intrinsics and Athena widget set 136and used throughout this document. 137</para> 138<para> 139<!-- .LP --> 140<function>Application programmer</function> 141<!-- .IN "application programmer" "" "@DEF@" --> 142</para> 143<itemizedlist> 144 <listitem> 145 <para> 146A programmer who uses the X Toolkit to produce an application user interface. 147 </para> 148 </listitem> 149</itemizedlist> 150<para> 151<!-- .LP --> 152<function>Child</function> 153<!-- .IN "child" "" "@DEF" --> 154</para> 155<itemizedlist> 156 <listitem> 157 <para> 158A widget that is contained within another "parent" widget. 159 </para> 160 </listitem> 161</itemizedlist> 162<para> 163<!-- .LP --> 164<function>Class</function> 165<!-- .IN "class" "" "@DEF@" --> 166</para> 167<itemizedlist> 168 <listitem> 169 <para> 170The general group to which a specific object belongs. 171 </para> 172 </listitem> 173</itemizedlist> 174<para> 175<!-- .LP --> 176<function>Client</function> 177<!-- .IN "client" "" "@DEF@" --> 178</para> 179<itemizedlist> 180 <listitem> 181 <para> 182A function that uses a widget in an application or for composing 183other widgets. 184 </para> 185 </listitem> 186</itemizedlist> 187<para> 188<!-- .LP --> 189<function>FullName</function> 190<!-- .IN "FullName" "" "@DEF" --> 191</para> 192<itemizedlist> 193 <listitem> 194 <para> 195The name of a widget instance appended to the full name of its parent. 196 </para> 197 </listitem> 198</itemizedlist> 199<para> 200<!-- .LP --> 201<function>Instance</function> 202<!-- .IN "instance" "" "@DEF@" --> 203</para> 204<itemizedlist> 205 <listitem> 206 <para> 207A specific widget object as opposed to a general widget class. 208 </para> 209 </listitem> 210</itemizedlist> 211<para> 212<!-- .LP --> 213<function>Method</function> 214<!-- .IN "method" "" "@DEF@" --> 215</para> 216<itemizedlist> 217 <listitem> 218 <para> 219A function or procedure implemented by a widget class. 220 </para> 221 </listitem> 222</itemizedlist> 223<para> 224<!-- .LP --> 225<function>Name</function> 226<!-- .IN "name" "widget" "@DEF@" --> 227</para> 228<itemizedlist> 229 <listitem> 230 <para> 231The name that is specific to an instance of a widget for a given client. 232This name is specified at creation time and cannot be modified. 233 </para> 234 </listitem> 235</itemizedlist> 236<para> 237<!-- .LP --> 238<function>Object</function> 239<!-- .IN "object" "" "@DEF@" --> 240</para> 241<itemizedlist> 242 <listitem> 243 <para> 244A data abstraction consisting of private data and private and public 245functions that operate on the private data. 246Users of the abstraction can interact with the object only through calls 247to the object's public functions. 248In the X Toolkit, 249some of the object's public functions are called directly by the application, 250while others are called indirectly when the application calls the common 251Intrinsics functions. 252In general, if a function is common to all widgets, 253an application uses a single Intrinsics function to invoke the function for all 254types of widgets. 255If a function is unique to a single widget type, 256the widget exports the function. 257 </para> 258 </listitem> 259</itemizedlist> 260<para> 261<!-- .LP --> 262<function>Parent</function> 263<!-- .IN "parent" "" "@DEF@" --> 264</para> 265<itemizedlist> 266 <listitem> 267 <para> 268A widget that contains at least one other ("child") widget. 269A parent widget is also known as a composite widget. 270 </para> 271 </listitem> 272</itemizedlist> 273<para> 274<!-- .LP --> 275<function>Resource</function> 276<!-- .IN "resource" "" "@DEF@" --> 277</para> 278<itemizedlist> 279 <listitem> 280 <para> 281A named piece of data in a widget that can be set by a client, 282by an application, or by user defaults. 283 </para> 284 </listitem> 285</itemizedlist> 286<para> 287<!-- .LP --> 288<function>Superclass</function> 289<!-- .IN "superclass" "" "@DEF@" --> 290</para> 291<itemizedlist> 292 <listitem> 293 <para> 294A larger class of which a specific class is a member. 295All members of a class are also members of the superclass. 296 </para> 297 </listitem> 298</itemizedlist> 299<para> 300<!-- .LP --> 301<function>User</function> 302<!-- .IN "user" "" "@DEF@" --> 303</para> 304<itemizedlist> 305 <listitem> 306 <para> 307A person interacting with a workstation. 308 </para> 309 </listitem> 310</itemizedlist> 311<para> 312<!-- .LP --> 313<function>Widget</function> 314<!-- .IN "widget" "" "@DEF@" --> 315</para> 316<itemizedlist> 317 <listitem> 318 <para> 319An object providing a user-interface abstraction (for example, a Scrollbar 320widget). 321 </para> 322 </listitem> 323</itemizedlist> 324<para> 325<!-- .LP --> 326<function>Widget class</function> 327<!-- .IN "widget class" "" "@DEF@" --> 328</para> 329<itemizedlist> 330 <listitem> 331 <para> 332The general group to which a specific widget belongs, 333otherwise known as the type of the widget. 334 </para> 335 </listitem> 336</itemizedlist> 337<para> 338<!-- .LP --> 339<function>Widget programmer</function> 340<!-- .IN "widget programmer" "" "@DEF@" --> 341</para> 342<itemizedlist> 343 <listitem> 344 <para> 345A programmer who adds new widgets to the X Toolkit. 346 </para> 347 </listitem> 348</itemizedlist> 349</sect1> 350<sect1 id="Underlying_Model"> 351<title>Underlying Model</title> 352<para> 353<!-- .LP --> 354<!-- .XS --> 355<!-- Underlying Model --> 356<!-- .XE --> 357<!-- .IN "underlying model" "" "@DEF@" --> 358The underlying architectural model is based on the following premises: 359<!-- .KS --> 360</para> 361<itemizedlist> 362 <listitem> 363 <para> 364 </para> 365 </listitem> 366 <listitem> 367 <para> 368Every user-interface widget is associated with an X window. 369The X window ID for a widget is readily available from the widget. 370Standard Xlib calls can be used by widgets for many of their input and 371output operations. 372<!-- .KE --> 373<!-- .KS --> 374 </para> 375 </listitem> 376 <listitem> 377 <para> 378 </para> 379 </listitem> 380 <listitem> 381 <para> 382The data for every widget is private to the widget and its subclasses. 383That is, the data is neither directly accessible 384nor visible outside of the module implementing the widget. 385All program interaction with the widget is performed by a set of operations 386(methods) that are defined for the widget. 387<!-- .KE --> 388<!-- .KS --> 389 </para> 390 </listitem> 391 <listitem> 392 <para> 393 </para> 394 </listitem> 395 <listitem> 396 <para> 397Widget semantics are clearly separated from widget layout geometry. 398Widgets are concerned with implementing specific user-interface 399semantics. They have little control over issues such as their size or 400placement relative to other widget peers. Mechanisms are provided for 401associating geometric managers with widgets and for widgets to make 402suggestions about their own geometry. 403<!-- .KE --> 404 </para> 405 </listitem> 406</itemizedlist> 407</sect1> 408<sect1 id="Conventions_Used_in_this_Manual"> 409<title>Conventions Used in this Manual</title> 410<itemizedlist> 411 <listitem> 412 <para> 413<!-- .IN "conventions" "used in manual" "@DEF@" --> 414All resources available to the widgets are listed with each widget. Many 415of these are available to more than one widget class due to the object 416oriented nature of the Intrinsics. The new resources for each widget are 417listed in bold text, and the inherited resources are listed in plain text. 418 </para> 419 </listitem> 420 <listitem> 421 <para> 422Global symbols are printed in <function>bold</function> and can be function names, 423symbols defined in include files, or structure names. Arguments are 424printed in <emphasis remap='I'>italics</emphasis>. 425 </para> 426 </listitem> 427 <listitem> 428 <para> 429Each function is introduced by a general discussion that distinguishes 430it from other functions. The function declaration itself follows, and 431each argument is specifically explained. General discussion of the 432function, if any is required, follows the arguments. Where 433applicable, the last paragraph of the explanation lists the return values 434of the function. 435 </para> 436 </listitem> 437 <listitem> 438 <para> 439To eliminate any ambiguity between those arguments that you pass and 440those that a function returns to you, the explanations for all 441arguments that you pass start with the word <emphasis remap='I'>specifies</emphasis> or, in the 442case of multiple arguments, the word <emphasis remap='I'>specify</emphasis>. The explanations 443for all arguments that are returned to you start with the word 444<emphasis remap='I'>returns</emphasis> or, in the case of multiple arguments, the word 445<emphasis remap='I'>return</emphasis>. The explanations for all arguments that you can pass 446and are returned start with the words <emphasis remap='I'>specifies and returns</emphasis>. 447 </para> 448 </listitem> 449 <listitem> 450 <para> 451Any pointer to a structure that is used to return a value is 452designated as such by the <emphasis remap='I'>_return</emphasis> suffix as part of its name. 453All other pointers passed to these functions are used for reading 454only. A few arguments use pointers to structures that are used for 455both input and output and are indicated by using the <emphasis remap='I'>_in_out</emphasis> 456suffix. 457<!-- .IN "_return" "" "@DEF@" --> 458<!-- .IN "_in_out" "" "@DEF@" --> 459 </para> 460 </listitem> 461</itemizedlist> 462</sect1> 463<sect1 id="Format_of_the_Widget_Reference_Chapters"> 464<title>Format of the Widget Reference Chapters</title> 465<para> 466<!-- .LP --> 467<!-- .IN "conventions" "chapter format" "@DEF@" --> 468<!-- .IN "chapter format" "" "@DEF@" --> 469The majority of this document is a reference guide for the Athena 470widget set. Chapters three through six give the programmer all 471information necessary to use the widgets. The layout of the chapters 472follows a specific pattern to allow the programmer to easily find the 473desired information. 474</para> 475<para> 476<!-- .LP --> 477The first few pages of every chapter give an overview of the widgets 478in that section. Widgets are grouped into chapters by functionality. 479<variablelist> 480 <varlistentry> 481 <term> 482 "Chapter <!-- xref --> 483 </term> 484 <listitem> 485 <para> 486Simple Widgets 487 </para> 488 </listitem> 489 </varlistentry> 490 <varlistentry> 491 <term> 492 "Chapter <!-- xref --> 493 </term> 494 <listitem> 495 <para> 496Menus 497 </para> 498 </listitem> 499 </varlistentry> 500 <varlistentry> 501 <term> 502 "Chapter <!-- xref --> 503 </term> 504 <listitem> 505 <para> 506Text Widgets 507 </para> 508 </listitem> 509 </varlistentry> 510 <varlistentry> 511 <term> 512 "Chapter <!-- xref --> 513 </term> 514 <listitem> 515 <para> 516Composite and Constraint Widget 517 </para> 518 </listitem> 519 </varlistentry> 520</variablelist> 521</para> 522<para> 523<!-- .LP --> 524Following the introduction will be a description of each widget in that 525chapter. When no functional grouping is obvious the widgets are listed 526in alphabetical order, such as in chapters three and six. 527</para> 528<para> 529<!-- .LP --> 530The first section of each widget's description is a table that 531contains general information about this widget class. Here is the 532table for the Box widget, and an explanation of all the entries. 533<literallayout class="monospaced"> 534<!-- .TA 2.0i --> 535<!-- .ta 2.0i --> 536<!-- .sp --> 537Application Header file <X11/Xaw/Box.h> 538Class Header file <X11/Xaw/BoxP.h> 539Class boxWidgetClass 540Class Name Box 541Superclass Composite 542<!-- .sp --> 543</literallayout> 544<variablelist> 545 <varlistentry> 546 <term> 547 <function>Application Header File</function> 548 </term> 549 <listitem> 550 <para> 551<!-- .IN "application header file" "" "@DEF@" --> 552This file must be included when an application uses this widget. 553It usually contains the class definition, and some resource macros. 554This is often called the ``public'' header file. 555<!-- .IN "class header file" "" "@DEF@" --> 556 </para> 557 </listitem> 558 </varlistentry> 559 <varlistentry> 560 <term> 561 <function>Class Header File</function> 562 </term> 563 <listitem> 564 <para> 565This file will only be used by widget programmers. It will need to be 566included by any widget that subclasses this widget. This is often 567called the ``private'' header file. 568<!-- .IN "class" "" "@DEF@" --> 569 </para> 570 </listitem> 571 </varlistentry> 572 <varlistentry> 573 <term> 574 <function>Class</function> 575 </term> 576 <listitem> 577 <para> 578This is the widget class of this widget. This global symbol is passed to 579<function>XtCreateWidget</function> so that the Intrinsics will know which type of widget 580to create. 581<!-- .IN "class name" "" "@DEF@" --> 582 </para> 583 </listitem> 584 </varlistentry> 585 <varlistentry> 586 <term> 587 <function>Class Name</function> 588 </term> 589 <listitem> 590 <para> 591This is the resource name of this class. This name can be used in 592a resource file to match any widget of this class. 593<!-- .IN "superclass" "" --> 594 </para> 595 </listitem> 596 </varlistentry> 597 <varlistentry> 598 <term> 599 <function>Superclass</function> 600 </term> 601 <listitem> 602 <para> 603This is the superclass that this widget class is descended from. If 604you understand how the superclass works it will allow you to more quickly 605understand what this widget does, since much of its functionality may be 606inherited from its superclass. 607<!-- .sp --> 608 </para> 609 </listitem> 610 </varlistentry> 611</variablelist> 612</para> 613<para> 614<!-- .LP --> 615After this table follows a general description of the default behavior of 616this widget, as seen by the user. In many cases this functionality 617may be overridden by the application programmer, or by the user. 618</para> 619<para> 620<!-- .LP --> 621The next section is a table showing the 622name, class, type and default value of each resource that is available 623to this widget. There is also a column containing notes describing 624special restrictions placed upon individual resources. 625<!-- .IN "notes" "" "@DEF@" --> 626<!-- .IN "A, note" "" "@DEF@" --> 627<!-- .IN "D, note" "" "@DEF@" --> 628<!-- .IN "C, note" "" "@DEF@" --> 629<!-- .IN "R, note" "" "@DEF@" --> 630<variablelist> 631 <varlistentry> 632 <term> 633 A 634 </term> 635 <listitem> 636 <para> 637This resource may be automatically adjusted when another 638resource is changed. 639 </para> 640 </listitem> 641 </varlistentry> 642 <varlistentry> 643 <term> 644 C 645 </term> 646 <listitem> 647 <para> 648This resource is only settable at widget creation time, and may not 649be modified with <function>XtSetValues</function>. 650 </para> 651 </listitem> 652 </varlistentry> 653 <varlistentry> 654 <term> 655 D 656 </term> 657 <listitem> 658 <para> 659Do not modify this resource. While setting this resource will 660work, it can cause unexpected behavior. When this symbol appears 661there is another, preferred, interface provided by the X Toolkit. 662 </para> 663 </listitem> 664 </varlistentry> 665 <varlistentry> 666 <term> 667 R 668 </term> 669 <listitem> 670 <para> 671This resource is READ-ONLY, and may not be modified. 672 </para> 673 </listitem> 674 </varlistentry> 675</variablelist> 676</para> 677<para> 678<!-- .LP --> 679After the resource table is a detailed description of every resource 680available to that widget. Many of these are redundant, but printing 681them with each widget saves page flipping. The names of the resources 682that are inherited are printed in plain text, while the names of the 683resources that are new to this class are printed in <function>bold</function>. 684If you have already read the description of the superclass you need 685only pay attention to the resources printed in bold. 686</para> 687<para> 688<!-- .LP --> 689For each composite widget there is a section on layout semantics that 690follows the resource description. This section will describe the 691effect of constraint resources on the layout of the children, as well 692as a general description of where it prefers to place its children. 693</para> 694<para> 695<!-- .LP --> 696Descriptions of default translations and action routines come next, for 697widgets to which they apply. The last item in each widget's 698documentation is the description of all convenience routines provided by 699the widget. 700</para> 701</sect1> 702<sect1 id="Input_Focus"> 703<title>Input Focus</title> 704<!-- .XS --> 705<!-- Input Focus --> 706<!-- .XE --> 707<!-- .IN "input focus" "" "@DEF@" --> 708<!-- .IN "input" "" "@DEF@" --> 709<!-- .IN "XtNinput" "" "@DEF@" --> 710<para> 711<!-- .LP --> 712The Intrinsics define a resource on all Shell widgets that interact with 713the window manager called <function>input</function>. This resource requests the 714assistance of window manager in acquiring the input focus. The 715resource defaults to <function>False</function> in the Intrinsics, but is redefined to 716default to <function>True</function> when an application is using the Athena widget 717set. An application programmer may override this default and set the 718resource back to <function>False</function> if the application does not need the window 719manager to give it the input focus. See the 720<emphasis remap='I'>X Toolkit Intrinsics - C Language Interface</emphasis> for details 721on the <emphasis remap='I'>input</emphasis> resource. 722 723</para> 724</sect1> 725</chapter> 726