CH10.xml revision 9e7bcd65
1<chapter id='Translation_Management'>
2<title>Translation Management</title>
3<para>
4Except under unusual circumstances,
5widgets do not hardwire the mapping of user events into widget behavior
6by using the event manager.
7Instead, they provide a default mapping of events into behavior
8that you can override.
9</para>
10
11<para>
12The translation manager provides an interface to specify and manage the
13mapping of X event sequences into widget-supplied functionality,
14for example, calling procedure <emphasis remap='I'>Abc</emphasis> when the <emphasis remap='I'>y</emphasis> key
15is pressed.
16</para>
17
18<para>
19The translation manager uses two kinds of tables to perform translations:
20</para>
21<itemizedlist spacing='compact'>
22  <listitem>
23    <para>
24The action tables, which are in the widget class structure,
25specify the mapping of externally available procedure name strings
26to the corresponding procedure implemented by the widget class.
27    </para>
28  </listitem>
29  <listitem>
30    <para>
31A translation table, which is in the widget class structure,
32specifies the mapping of event sequences to procedure name strings.
33    </para>
34  </listitem>
35</itemizedlist>
36<para>
37You can override the translation table in the class structure
38for a specific widget instance by supplying a different translation table
39for the widget instance.  The resources
40XtNtranslations and XtNbaseTranslations are used to modify the class
41default translation table; see <xref linkend='Translation_Table_Management' />.
42</para>
43<sect1 id="Action_Tables">
44<title>Action Tables</title>
45<para>
46All widget class records contain an action table,
47an array of
48<function>XtActionsRec</function>
49entries.
50In addition,
51an application can register its own action tables with the translation manager
52so that the translation tables it provides to widget instances can access
53application functionality directly.
54The translation action procedure pointer is of type
55<xref linkend='XtActionProc' xrefstyle='select: title'/>.
56</para>
57
58<funcsynopsis id='XtActionProc'>
59<funcprototype>
60<funcdef>typedef void <function>(*XtActionProc)</function></funcdef>
61   <paramdef>Widget <parameter>w</parameter></paramdef>
62   <paramdef>XEvent *<parameter>event</parameter></paramdef>
63   <paramdef>String *<parameter>params</parameter></paramdef>
64   <paramdef>Cardinal *<parameter>num_params</parameter></paramdef>
65</funcprototype>
66</funcsynopsis>
67
68<variablelist>
69  <varlistentry>
70    <term>
71      <emphasis remap='I'>w</emphasis>
72    </term>
73    <listitem>
74      <para>
75Specifies the widget that caused the action to be called.
76      </para>
77    </listitem>
78  </varlistentry>
79  <varlistentry>
80    <term>
81      <emphasis remap='I'>event</emphasis>
82    </term>
83    <listitem>
84      <para>
85Specifies the event that caused the action to be called.
86If the action is called after a sequence of events,
87then the last event in the sequence is used.
88      </para>
89    </listitem>
90  </varlistentry>
91  <varlistentry>
92    <term>
93      <emphasis remap='I'>params</emphasis>
94    </term>
95    <listitem>
96      <para>
97Specifies a pointer to the list of strings that were specified
98in the translation table as arguments to the action, or NULL.
99      </para>
100    </listitem>
101  </varlistentry>
102  <varlistentry>
103    <term>
104      <emphasis remap='I'>num_params</emphasis>
105    </term>
106    <listitem>
107      <para>
108Specifies the number of entries in <emphasis remap='I'>params</emphasis>.
109    </para>
110  </listitem>
111  </varlistentry>
112</variablelist>
113
114<literallayout >
115typedef struct _XtActionsRec {
116	String string;
117	XtActionProc proc;
118} XtActionsRec, *XtActionList;
119</literallayout>
120<para>
121The <emphasis remap='I'>string</emphasis> field is the name used in translation tables to access
122the procedure.
123The <emphasis remap='I'>proc</emphasis> field is a pointer to a procedure that implements
124the functionality.
125</para>
126
127<para>
128When the action list is specified as the
129<function>CoreClassPart</function>
130<emphasis remap='I'>actions</emphasis> field, the string pointed to by <emphasis remap='I'>string</emphasis> must be
131permanently allocated prior to or during the execution of the class
132initialization procedure and must not be subsequently deallocated.
133</para>
134
135<para>
136Action procedures should not assume that the widget in which they
137are invoked is realized; an accelerator specification can cause
138an action procedure to be called for a widget that does not yet
139have a window.  Widget writers should also note which of a widget's
140callback lists are invoked from action procedures and warn clients
141not to assume the widget is realized in those callbacks.
142</para>
143
144<para>
145For example, a Pushbutton widget has procedures to take the following actions:
146</para>
147<itemizedlist spacing='compact'>
148  <listitem>
149    <para>
150Set the button to indicate it is activated.
151    </para>
152  </listitem>
153  <listitem>
154    <para>
155Unset the button back to its normal mode.
156    </para>
157  </listitem>
158  <listitem>
159    <para>
160Highlight the button borders.
161    </para>
162  </listitem>
163  <listitem>
164    <para>
165Unhighlight the button borders.
166    </para>
167  </listitem>
168  <listitem>
169    <para>
170Notify any callbacks that the button has been activated.
171    </para>
172  </listitem>
173</itemizedlist>
174<para>
175The action table for the Pushbutton widget class makes these functions
176available to translation tables written for Pushbutton or any subclass.
177The string entry is the name used in translation tables.
178The procedure entry (usually spelled identically to the string)
179is the name of the C procedure that implements that function:
180</para>
181<literallayout >
182XtActionsRec actionTable[] = {
183	{"Set",	Set},
184	{"Unset",	Unset},
185	{"Highlight",	Highlight},
186	{"Unhighlight",	Unhighlight}
187	{"Notify",	Notify},
188};
189</literallayout>
190<para>
191The Intrinsics reserve all action names and parameters starting with
192the characters ``Xt'' for future standard enhancements.  Users,
193applications, and widgets should not declare action names or pass
194parameters starting with these characters except to invoke specified
195built-in Intrinsics functions.
196</para>
197<sect2 id="Action_Table_Registration">
198<title>Action Table Registration</title>
199<para>
200The <emphasis remap='I'>actions</emphasis> and <emphasis remap='I'>num_actions</emphasis> fields of
201<function>CoreClassPart</function>
202specify the actions implemented by a widget class.  These are
203automatically registered with the Intrinsics when the class is initialized
204and must be allocated in writable storage prior to Core class_part
205initialization, and never deallocated.  To save memory and optimize
206access, the Intrinsics may overwrite the storage in order to compile the
207list into an internal representation.
208</para>
209
210<para>
211To declare an action table within an application
212and register it with the translation manager, use
213<xref linkend='XtAppAddActions' xrefstyle='select: title'/>.
214</para>
215
216<funcsynopsis id='XtAppAddActions'>
217<funcprototype>
218<funcdef>void <function>XtAppAddActions</function></funcdef>
219   <paramdef>XtAppContext <parameter>app_context</parameter></paramdef>
220   <paramdef>XtActionList <parameter>actions</parameter></paramdef>
221   <paramdef>Cardinal <parameter>num_actions</parameter></paramdef>
222</funcprototype>
223</funcsynopsis>
224
225<variablelist>
226  <varlistentry>
227    <term>
228      <emphasis remap='I'>app_context</emphasis>
229    </term>
230    <listitem>
231      <para>
232Specifies the application context.
233      </para>
234    </listitem>
235  </varlistentry>
236  <varlistentry>
237    <term>
238      <emphasis remap='I'>actions</emphasis>
239    </term>
240    <listitem>
241      <para>
242Specifies the action table to register.
243      </para>
244    </listitem>
245  </varlistentry>
246  <varlistentry>
247    <term>
248      <emphasis remap='I'>num_actions</emphasis>
249    </term>
250    <listitem>
251      <para>
252Specifies the number of entries in this action table.
253    </para>
254  </listitem>
255  </varlistentry>
256</variablelist>
257
258<para>
259If more than one action is registered with the same name,
260the most recently registered action is used.
261If duplicate actions exist in an action table,
262the first is used.
263The Intrinsics register an action table containing
264<xref linkend='XtMenuPopup' xrefstyle='select: title'/>
265and
266<xref linkend='XtMenuPopdown' xrefstyle='select: title'/>
267as part of
268<xref linkend='XtCreateApplicationContext' xrefstyle='select: title'/>.
269</para>
270</sect2>
271
272<sect2 id="Action_Names_to_Procedure_Translations">
273<title>Action Names to Procedure Translations</title>
274<para>
275The translation manager uses a simple algorithm to resolve the name of
276a procedure specified in a translation table into the
277actual procedure specified
278in an action table.
279When the widget
280is realized, the translation manager
281performs a search for the name in the following tables, in order:
282</para>
283<itemizedlist spacing='compact'>
284  <listitem>
285    <para>
286The widget's class and all superclass action tables, in subclass-to-superclass
287order.
288    </para>
289  </listitem>
290  <listitem>
291    <para>
292The parent's class and all superclass action tables, in subclass-to-superclass
293order, then on up the ancestor tree.
294    </para>
295  </listitem>
296  <listitem>
297    <para>
298The action tables registered with
299<xref linkend='XtAppAddActions' xrefstyle='select: title'/>
300and
301<xref linkend='XtAddActions' xrefstyle='select: title'/>
302from the most recently added table to the oldest table.
303    </para>
304  </listitem>
305</itemizedlist>
306<para>
307As soon as it finds a name,
308the translation manager stops the search.
309If it cannot find a name,
310the translation manager generates a warning message.
311</para>
312</sect2>
313
314<sect2 id="Action_Hook_Registration">
315<title>Action Hook Registration</title>
316<para>
317An application can specify a procedure that will be called just before
318every action routine is dispatched by the translation manager.  To do
319so, the application supplies a procedure pointer of type
320<xref linkend='XtActionHookProc' xrefstyle='select: title'/>.
321</para>
322
323<funcsynopsis id='XtActionHookProc'>
324<funcprototype>
325<funcdef>typedef void <function>(*XtActionHookProc)</function></funcdef>
326   <paramdef>Widget <parameter>w</parameter></paramdef>
327   <paramdef>XtPointer <parameter>client_data</parameter></paramdef>
328   <paramdef>String <parameter>action_name</parameter></paramdef>
329   <paramdef>XEvent* <parameter>event</parameter></paramdef>
330   <paramdef>String* <parameter>params</parameter></paramdef>
331   <paramdef>Cardinal* <parameter>num_params</parameter></paramdef>
332</funcprototype>
333</funcsynopsis>
334
335
336
337<variablelist>
338  <varlistentry>
339    <term>
340      <emphasis remap='I'>w</emphasis>
341    </term>
342    <listitem>
343      <para>
344Specifies the widget whose action is about to be dispatched.
345      </para>
346    </listitem>
347  </varlistentry>
348  <varlistentry>
349    <term>
350      <emphasis remap='I'>client_data</emphasis>
351    </term>
352    <listitem>
353      <para>
354Specifies the application-specific closure that was passed to
355<function>XtAppAddActionHook.</function>
356      </para>
357    </listitem>
358  </varlistentry>
359  <varlistentry>
360    <term>
361      <emphasis remap='I'>action_name</emphasis>
362    </term>
363    <listitem>
364      <para>
365Specifies the name of the action to be dispatched.
366      </para>
367    </listitem>
368  </varlistentry>
369  <varlistentry>
370    <term>
371      <emphasis remap='I'>event</emphasis>
372    </term>
373    <listitem>
374      <para>
375Specifies the event argument that will be passed to the action routine.
376      </para>
377    </listitem>
378  </varlistentry>
379  <varlistentry>
380    <term>
381      <emphasis remap='I'>params</emphasis>
382    </term>
383    <listitem>
384      <para>
385Specifies the action parameters that will be passed to the action routine.
386      </para>
387    </listitem>
388  </varlistentry>
389  <varlistentry>
390    <term>
391      <emphasis remap='I'>num_params</emphasis>
392    </term>
393    <listitem>
394      <para>
395Specifies the number of entries in <emphasis remap='I'>params</emphasis>.
396    </para>
397  </listitem>
398  </varlistentry>
399</variablelist>
400
401<para>
402Action hooks should not modify any of the data pointed to by the
403arguments other than the <emphasis remap='I'>client_data</emphasis> argument.
404</para>
405
406<para>
407To add an action hook, use
408<xref linkend='XtAppAddActionHook' xrefstyle='select: title'/>.
409</para>
410
411<funcsynopsis id='XtAppAddActionHook'>
412<funcprototype>
413<funcdef>XtActionHookId <function>XtAppAddActionHook</function></funcdef>
414   <paramdef>XtAppContext <parameter>app</parameter></paramdef>
415   <paramdef>XtActionHookProc <parameter>proc</parameter></paramdef>
416   <paramdef>XtPointer <parameter>client_data</parameter></paramdef>
417</funcprototype>
418</funcsynopsis>
419
420<variablelist>
421  <varlistentry>
422    <term>
423      <emphasis remap='I'>app</emphasis>
424    </term>
425    <listitem>
426      <para>
427Specifies the application context.
428      </para>
429    </listitem>
430  </varlistentry>
431  <varlistentry>
432    <term>
433      <emphasis remap='I'>proc</emphasis>
434    </term>
435    <listitem>
436      <para>
437Specifies the action hook procedure.
438      </para>
439    </listitem>
440  </varlistentry>
441  <varlistentry>
442    <term>
443      <emphasis remap='I'>client_data</emphasis>
444    </term>
445    <listitem>
446      <para>
447Specifies application-specific data to be passed to the action hook.
448    </para>
449  </listitem>
450  </varlistentry>
451</variablelist>
452
453<para>
454<xref linkend='XtAppAddActionHook' xrefstyle='select: title'/>
455adds the specified procedure to the front of a list
456maintained in the application context.  In the future, when an action
457routine is about to be invoked for any widget in this application
458context, either through the translation manager or via
459<xref linkend='XtCallActionProc' xrefstyle='select: title'/>,
460the action hook procedures will be called in reverse
461order of registration just prior to invoking the action routine.
462</para>
463
464<para>
465Action hook procedures are removed automatically and the
466<function>XtActionHookId is</function>
467destroyed when the application context in which
468they were added is destroyed.
469</para>
470
471<para>
472To remove an action hook procedure without destroying the application
473context, use
474<xref linkend='XtRemoveActionHook' xrefstyle='select: title'/>.
475</para>
476
477<funcsynopsis id='XtRemoveActionHook'>
478<funcprototype>
479<funcdef>void <function>XtRemoveActionHook</function></funcdef>
480   <paramdef>XtActionHookId <parameter>id</parameter></paramdef>
481</funcprototype>
482</funcsynopsis>
483
484<variablelist>
485  <varlistentry>
486    <term>
487      <emphasis remap='I'>id</emphasis>
488    </term>
489    <listitem>
490      <para>
491Specifies the action hook id returned by
492<xref linkend='XtAppAddActionHook' xrefstyle='select: title'/>.
493    </para>
494  </listitem>
495  </varlistentry>
496</variablelist>
497
498<para>
499<xref linkend='XtRemoveActionHook' xrefstyle='select: title'/>
500removes the specified action hook procedure from
501the list in which it was registered.
502</para>
503</sect2>
504</sect1>
505
506<sect1 id="Translation_Tables">
507<title>Translation Tables</title>
508<para>
509All widget instance records contain a translation table,
510which is a resource with a default value specified elsewhere in the
511class record.
512A translation table specifies what action procedures are invoked for
513an event or a sequence of events.
514A translation table
515is a string containing a list of translations from an event sequence
516into one or more action procedure calls.
517The translations are separated from one another by newline characters
518(ASCII LF).
519The complete syntax of translation tables is specified in Appendix B.
520</para>
521
522<para>
523As an example, the default behavior of Pushbutton is
524</para>
525<itemizedlist spacing='compact'>
526  <listitem>
527    <para>
528Highlight on enter window.
529    </para>
530  </listitem>
531  <listitem>
532    <para>
533Unhighlight on exit window.
534    </para>
535  </listitem>
536  <listitem>
537    <para>
538Invert on left button down.
539    </para>
540  </listitem>
541  <listitem>
542    <para>
543Call callbacks and reinvert on left button up.
544    </para>
545  </listitem>
546</itemizedlist>
547<para>
548The following illustrates Pushbutton's default translation table:
549</para>
550<literallayout >
551static String defaultTranslations =
552	"&lt;EnterWindow&gt;:	Highlight()\\n\\
553	&lt;LeaveWindow&gt;:	Unhighlight()\\n\\
554	&lt;Btn1Down&gt;:	Set()\\n\\
555	&lt;Btn1Up&gt;:	Notify() Unset()";
556</literallayout>
557<para>
558The <emphasis remap='I'>tm_table</emphasis> field of the
559<function>CoreClassPart</function>
560should be filled in at class initialization time with
561the string containing the class's default translations.
562If a class wants to inherit its superclass's translations,
563it can store the special value
564<function>XtInheritTranslations</function>
565into <emphasis remap='I'>tm_table</emphasis>.
566In Core's class part initialization procedure,
567the Intrinsics compile this translation table into an efficient internal form.
568Then, at widget creation time,
569this default translation table is
570combined with the XtNtranslations
571and XtNbaseTranslations resources; see
572<xref linkend='Translation_Table_Management' />.
573</para>
574
575<para>
576The resource conversion mechanism automatically compiles
577string translation tables that are specified in the resource database.
578If a client uses translation tables that are not retrieved via a
579resource conversion,
580it must compile them itself using
581<xref linkend='XtParseTranslationTable' xrefstyle='select: title'/>.
582</para>
583
584<para>
585The Intrinsics use the compiled form of the translation table to register the
586necessary events with the event manager.
587Widgets need do nothing other than specify the action and translation tables
588for events to be processed by the translation manager.
589</para>
590<sect2 id="Event_Sequences">
591<title>Event Sequences</title>
592<para>
593An event sequence is a comma-separated list of X event descriptions
594that describes a specific sequence of X events to map to a set of
595program actions.
596Each X event description consists of three parts:
597The X event type, a prefix consisting of the X modifier bits, and
598an event-specific suffix.
599</para>
600
601<para>
602Various abbreviations are supported to make translation tables easier
603to read.  The events must match incoming events in left-to-right order
604to trigger the action sequence.
605</para>
606</sect2>
607
608<sect2 id="Action_Sequences">
609<title>Action Sequences</title>
610<para>
611Action sequences specify what program or widget actions to take in response to
612incoming X events. An action sequence consists of space-separated
613action procedure call specifications.
614Each action procedure call consists of the name of an action procedure and a
615parenthesized list of zero or more comma-separated
616string parameters to pass to that procedure.
617The actions are invoked in left-to-right order as specified in the
618action sequence.
619</para>
620</sect2>
621
622<sect2 id="Multi_Click_Time">
623<title>Multi-Click Time</title>
624<para>
625Translation table entries may specify actions that are taken when two
626or more identical events occur consecutively within a short time
627interval, called the multi-click time.  The multi-click time value may
628be specified as an application resource with name ``multiClickTime'' and
629class ``MultiClickTime'' and may also be modified dynamically by the
630application.  The multi-click time is unique for each Display value and
631is retrieved from the resource database by
632<xref linkend='XtDisplayInitialize' xrefstyle='select: title'/>.
633If no value is specified, the initial value is 200 milliseconds.
634</para>
635
636<para>
637To set the multi-click time dynamically, use
638<xref linkend='XtSetMultiClickTime' xrefstyle='select: title'/>.
639</para>
640
641<funcsynopsis id='XtSetMultiClickTime'>
642<funcprototype>
643<funcdef>void <function>XtSetMultiClickTime</function></funcdef>
644   <paramdef>Display *<parameter>display</parameter></paramdef>
645   <paramdef>int <parameter>time</parameter></paramdef>
646</funcprototype>
647</funcsynopsis>
648
649<variablelist>
650  <varlistentry>
651    <term>
652      <emphasis remap='I'>display</emphasis>
653    </term>
654    <listitem>
655      <para>
656Specifies the display connection.
657      </para>
658    </listitem>
659  </varlistentry>
660  <varlistentry>
661    <term>
662      <emphasis remap='I'>time</emphasis>
663    </term>
664    <listitem>
665      <para>
666Specifies the multi-click time in milliseconds.
667    </para>
668  </listitem>
669  </varlistentry>
670</variablelist>
671
672<para>
673<xref linkend='XtSetMultiClickTime' xrefstyle='select: title'/>
674sets the time interval used by the translation
675manager to determine when multiple events are interpreted as a
676repeated event.  When a repeat count is specified in a translation
677entry, the interval between the timestamps in each pair of repeated
678events (e.g., between two
679<function>ButtonPress</function>
680events) must be less than the
681multi-click time in order for the translation actions to be taken.
682</para>
683
684<para>
685To read the multi-click time, use
686<xref linkend='XtGetMultiClickTime' xrefstyle='select: title'/>.
687</para>
688
689<funcsynopsis id='XtGetMultiClickTime'>
690<funcprototype>
691<funcdef>int <function>XtGetMultiClickTime</function></funcdef>
692   <paramdef>Display *<parameter>display</parameter></paramdef>
693</funcprototype>
694</funcsynopsis>
695
696<variablelist>
697  <varlistentry>
698    <term>
699      <emphasis remap='I'>display</emphasis>
700    </term>
701    <listitem>
702      <para>
703Specifies the display connection.
704    </para>
705  </listitem>
706  </varlistentry>
707</variablelist>
708
709<para>
710<xref linkend='XtGetMultiClickTime' xrefstyle='select: title'/>
711returns the time in milliseconds that the
712translation manager uses to determine if multiple events are to be
713interpreted as a repeated event for purposes of matching a translation
714entry containing a repeat count.
715</para>
716</sect2>
717</sect1>
718
719<sect1 id="Translation_Table_Management">
720<title>Translation Table Management</title>
721<para>
722Sometimes an application needs to merge
723its own translations with a widget's translations.
724For example, a window manager provides functions to move a window.
725The window manager wishes to bind this operation to a specific
726pointer button in the title bar without the possibility of user
727override and bind it to other buttons that may be overridden by the user.
728</para>
729
730<para>
731To accomplish this,
732the window manager should first create the title bar
733and then should merge the two translation tables into
734the title bar's translations.
735One translation table contains the translations that the window manager
736wants only if the user has not specified a translation for a particular event
737or event sequence (i.e., those that may be overridden).
738The other translation table contains the translations that the
739window manager wants regardless of what the user has specified.
740</para>
741
742<para>
743Three Intrinsics functions support this merging:
744</para>
745
746<variablelist>
747  <varlistentry>
748    <term>
749      <emphasis remap='I'>XtParseTranslationTable</emphasis>
750    </term>
751    <listitem>
752      <para>Compiles a translation table.</para>
753    </listitem>
754  </varlistentry>
755  <varlistentry>
756    <term>
757      <emphasis remap='I'>XtAugmentTranslations</emphasis>
758    </term>
759    <listitem>
760      <para>Merges a compiled translation table into a widget's
761      compiled translation table, ignoring any new translations that
762      conflict with existing translations.
763      </para>
764    </listitem>
765  </varlistentry>
766  <varlistentry>
767    <term>
768      <emphasis remap='I'>XtOverrideTranslations</emphasis>
769    </term>
770    <listitem>
771      <para>Merges a compiled translation table into a widget's
772      compiled translation table, replacing any existing translations that
773      conflict with new translations.
774      </para>
775    </listitem>
776  </varlistentry>
777</variablelist>
778
779<para>
780To compile a translation table, use
781<xref linkend='XtParseTranslationTable' xrefstyle='select: title'/>.
782</para>
783
784<funcsynopsis id='XtParseTranslationTable'>
785<funcprototype>
786<funcdef>XtTranslations <function>XtParseTranslationTable</function></funcdef>
787   <paramdef>String <parameter>table</parameter></paramdef>
788</funcprototype>
789</funcsynopsis>
790
791<variablelist>
792  <varlistentry>
793    <term>
794      <emphasis remap='I'>table</emphasis>
795    </term>
796    <listitem>
797      <para>
798Specifies the translation table to compile.
799    </para>
800  </listitem>
801  </varlistentry>
802</variablelist>
803
804<para>
805The
806<xref linkend='XtParseTranslationTable' xrefstyle='select: title'/>
807function compiles the translation table, provided in the format given
808in Appendix B, into an opaque internal representation
809of type
810<function>XtTranslations</function>.
811Note that if an empty translation table is required for any purpose,
812one can be obtained by calling
813<xref linkend='XtParseTranslationTable' xrefstyle='select: title'/>
814and passing an empty string.
815</para>
816
817<para>
818To merge additional translations into an existing translation table, use
819<xref linkend='XtAugmentTranslations' xrefstyle='select: title'/>.
820</para>
821
822<funcsynopsis id='XtAugmentTranslations'>
823<funcprototype>
824<funcdef>void <function>XtAugmentTranslations</function></funcdef>
825   <paramdef>Widget <parameter>w</parameter></paramdef>
826   <paramdef>XtTranslations <parameter>translations</parameter></paramdef>
827</funcprototype>
828</funcsynopsis>
829
830<variablelist>
831  <varlistentry>
832    <term>
833      <emphasis remap='I'>w</emphasis>
834    </term>
835    <listitem>
836      <para>
837Specifies the widget into which the new translations are to be merged.  Must be of class Core or any subclass thereof.
838      </para>
839    </listitem>
840  </varlistentry>
841  <varlistentry>
842    <term>
843      <emphasis remap='I'>translations</emphasis>
844    </term>
845    <listitem>
846      <para>
847Specifies the compiled translation table to merge in.
848    </para>
849  </listitem>
850  </varlistentry>
851</variablelist>
852
853<para>
854The
855<xref linkend='XtAugmentTranslations' xrefstyle='select: title'/>
856function merges the new translations into the existing widget
857translations, ignoring any
858<function>#replace</function>,
859<function>#augment</function>,
860or
861<function>#override</function>
862directive that may have been specified
863in the translation string.  The translation table specified by
864<emphasis remap='I'>translations</emphasis> is not altered by this process.
865<xref linkend='XtAugmentTranslations' xrefstyle='select: title'/>
866logically appends the string representation of the new translations to
867the string representation of the widget's current translations and reparses
868the result with no warning messages about duplicate left-hand sides, then
869stores the result back into the widget instance; i.e.,
870if the new translations contain an event or event sequence that
871already exists in the widget's translations,
872the new translation is ignored.
873</para>
874
875<para>
876To overwrite existing translations with new translations, use
877<xref linkend='XtOverrideTranslations' xrefstyle='select: title'/>.
878</para>
879
880<funcsynopsis id='XtOverrideTranslations'>
881<funcprototype>
882<funcdef>void <function>XtOverrideTranslations</function></funcdef>
883   <paramdef>Widget <parameter>w</parameter></paramdef>
884   <paramdef>XtTranslations <parameter>translations</parameter></paramdef>
885</funcprototype>
886</funcsynopsis>
887
888<variablelist>
889  <varlistentry>
890    <term>
891      <emphasis remap='I'>w</emphasis>
892    </term>
893    <listitem>
894      <para>
895Specifies the widget into which the new translations are to be merged. Must be of class Core or any subclass thereof.
896      </para>
897    </listitem>
898  </varlistentry>
899  <varlistentry>
900    <term>
901      <emphasis remap='I'>translations</emphasis>
902    </term>
903    <listitem>
904      <para>
905Specifies the compiled translation table to merge in.
906    </para>
907  </listitem>
908  </varlistentry>
909</variablelist>
910
911<para>
912The
913<xref linkend='XtOverrideTranslations' xrefstyle='select: title'/>
914function merges the new translations into the existing widget
915translations, ignoring any
916<function>#replace</function>,
917<function>#augment</function>,
918or
919<function>#override</function>
920directive that may have been
921specified in the translation string.  The translation table
922specified by <emphasis remap='I'>translations</emphasis> is not altered by this process.
923<xref linkend='XtOverrideTranslations' xrefstyle='select: title'/>
924logically appends the string representation of the widget's current
925translations to the string representation of the new translations and
926reparses the result with no warning messages about duplicate left-hand
927sides, then stores the result back into the widget instance; i.e.,
928if the new translations contain an event or event sequence that
929already exists in the widget's translations,
930the new translation overrides the widget's translation.
931</para>
932
933<para>
934To replace a widget's translations completely, use
935<xref linkend='XtSetValues' xrefstyle='select: title'/>
936on the XtNtranslations resource and specify a compiled translation table
937as the value.
938</para>
939
940<para>
941To make it possible for users to easily modify translation tables in their
942resource files,
943the string-to-translation-table resource type converter
944allows the string to specify whether the table should replace,
945augment, or override any
946existing translation table in the widget.
947To specify this,
948a pound sign (#) is given as the first character of the table
949followed by one of the keywords ``replace'', ``augment'', or
950``override'' to indicate
951whether to replace, augment, or override the existing table.
952The replace or merge
953operation is performed during the
954Core
955instance initialization.
956Each merge operation produces a new
957translation resource value; if the original tables were shared by
958other widgets, they are unaffected.  If no directive is
959specified, ``#replace'' is assumed.
960</para>
961
962<para>
963At instance initialization
964the XtNtranslations resource is first fetched.  Then, if it was
965not specified or did not contain ``#replace'', the
966resource database is searched for the resource XtNbaseTranslations.
967If XtNbaseTranslations is found, it is merged into the widget class
968translation table.  Then the widget <emphasis remap='I'>translations</emphasis> field is
969merged into the result or into the class translation table if
970XtNbaseTranslations was not found.  This final table is then
971stored into the widget <emphasis remap='I'>translations</emphasis> field.  If the XtNtranslations
972resource specified ``#replace'', no merge is done.
973If neither XtNbaseTranslations or XtNtranslations are specified,
974the class translation table is copied into the widget instance.
975</para>
976
977<para>
978To completely remove existing translations, use
979<xref linkend='XtUninstallTranslations' xrefstyle='select: title'/>.
980</para>
981
982<funcsynopsis id='XtUninstallTranslations'>
983<funcprototype>
984<funcdef>void <function>XtUninstallTranslations</function></funcdef>
985   <paramdef>Widget <parameter>w</parameter></paramdef>
986</funcprototype>
987</funcsynopsis>
988
989<variablelist>
990  <varlistentry>
991    <term>
992      <emphasis remap='I'>w</emphasis>
993    </term>
994    <listitem>
995      <para>
996Specifies the widget from which the translations are to be removed.   Must be of class Core or any subclass thereof.
997    </para>
998  </listitem>
999  </varlistentry>
1000</variablelist>
1001
1002<para>
1003The
1004<xref linkend='XtUninstallTranslations' xrefstyle='select: title'/>
1005function causes the entire translation table for the widget to be removed.
1006</para>
1007</sect1>
1008
1009<sect1 id="Using_Accelerators">
1010<title>Using Accelerators</title>
1011<para>
1012It is often desirable to be able to bind events in one widget to actions in
1013another.
1014In particular,
1015it is often useful to be able to invoke menu actions from the keyboard.
1016The Intrinsics provide a facility, called accelerators, that lets you
1017accomplish this.
1018An accelerator table is a translation table that is bound with its
1019actions in the context of a particular widget, the <emphasis remap='I'>source</emphasis> widget.
1020The accelerator table can then be installed on one or more <emphasis remap='I'>destination</emphasis> widgets.
1021When an event sequence in the destination widget would cause an
1022accelerator action to be taken, and if the source widget is sensitive,
1023the actions are executed as though triggered by the same event sequence
1024in the accelerator source
1025widget.  The event is
1026passed to the action procedure without modification.  The action
1027procedures used within accelerators must not assume that the source
1028widget is realized nor that any fields of the event are in reference
1029to the source widget's window if the widget is realized.
1030</para>
1031
1032<para>
1033Each widget instance contains that widget's exported accelerator table
1034as a resource.
1035Each class of widget exports a method that takes a
1036displayable string representation of the accelerators
1037so that widgets can display their current accelerators.
1038The representation is the accelerator table in canonical
1039translation table form (see Appendix B).
1040The display_accelerator procedure pointer is of type
1041<xref linkend='XtStringProc' xrefstyle='select: title'/>.
1042</para>
1043
1044<funcsynopsis id='XtStringProc'>
1045<funcprototype>
1046<funcdef>typedef void <function>(*XtStringProc)</function></funcdef>
1047   <paramdef>Widget <parameter>w</parameter></paramdef>
1048   <paramdef>String <parameter>string</parameter></paramdef>
1049</funcprototype>
1050</funcsynopsis>
1051
1052<variablelist>
1053  <varlistentry>
1054    <term>
1055      <emphasis remap='I'>w</emphasis>
1056    </term>
1057    <listitem>
1058      <para>
1059Specifies the source widget that supplied the accelerators.
1060      </para>
1061    </listitem>
1062  </varlistentry>
1063  <varlistentry>
1064    <term>
1065      <emphasis remap='I'>string</emphasis>
1066    </term>
1067    <listitem>
1068      <para>
1069Specifies the string representation of the accelerators for this widget.
1070    </para>
1071  </listitem>
1072  </varlistentry>
1073</variablelist>
1074
1075<para>
1076Accelerators can be specified in resource files,
1077and the string representation is the same as for a translation table.
1078However,
1079the interpretation of the
1080<function>#augment</function>
1081and
1082<function>#override</function>
1083directives applies to
1084what will happen when the accelerator is installed;
1085that is, whether or not the accelerator translations will override the
1086translations in the destination widget.
1087The default is
1088<function>#augment</function>,
1089which means that the accelerator translations have lower priority
1090than the destination translations.
1091The
1092<function>#replace</function>
1093directive is ignored for accelerator tables.
1094</para>
1095
1096<para>
1097To parse an accelerator table, use
1098<xref linkend='XtParseAcceleratorTable' xrefstyle='select: title'/>.
1099</para>
1100
1101<funcsynopsis id='XtParseAcceleratorTable'>
1102<funcprototype>
1103<funcdef>XtAccelerators <function>XtParseAcceleratorTable</function></funcdef>
1104   <paramdef>String <parameter>source</parameter></paramdef>
1105</funcprototype>
1106</funcsynopsis>
1107
1108<variablelist>
1109  <varlistentry>
1110    <term>
1111      <emphasis remap='I'>source</emphasis>
1112    </term>
1113    <listitem>
1114      <para>
1115Specifies the accelerator table to compile.
1116    </para>
1117  </listitem>
1118  </varlistentry>
1119</variablelist>
1120
1121<para>
1122The
1123<xref linkend='XtParseAcceleratorTable' xrefstyle='select: title'/>
1124function compiles the accelerator table into an opaque internal representation.
1125The client
1126should set the XtNaccelerators resource of
1127each widget that is to be activated by these translations
1128to the returned value.
1129</para>
1130
1131<para>
1132To install accelerators from a widget on another widget, use
1133<xref linkend='XtInstallAccelerators' xrefstyle='select: title'/>.
1134</para>
1135
1136<funcsynopsis id='XtInstallAccelerators'>
1137<funcprototype>
1138<funcdef>void <function>XtInstallAccelerators</function></funcdef>
1139   <paramdef>Widget <parameter>destination</parameter></paramdef>
1140   <paramdef>Widget <parameter>source</parameter></paramdef>
1141</funcprototype>
1142</funcsynopsis>
1143
1144<variablelist>
1145  <varlistentry>
1146    <term>
1147      <emphasis remap='I'>destination</emphasis>
1148    </term>
1149    <listitem>
1150      <para>
1151Specifies the widget on which the accelerators are to be installed.  Must be of class Core or any subclass thereof.
1152      </para>
1153    </listitem>
1154  </varlistentry>
1155  <varlistentry>
1156    <term>
1157      <emphasis remap='I'>source</emphasis>
1158    </term>
1159    <listitem>
1160      <para>
1161Specifies the widget from which the accelerators are to come.  Must be of class Core or any subclass thereof.
1162    </para>
1163  </listitem>
1164  </varlistentry>
1165</variablelist>
1166
1167<para>
1168The
1169<xref linkend='XtInstallAccelerators' xrefstyle='select: title'/>
1170function installs the <emphasis remap='I'>accelerators</emphasis> resource value from
1171<emphasis remap='I'>source</emphasis> onto <emphasis remap='I'>destination</emphasis>
1172by merging the source accelerators into the destination translations.
1173If the source <emphasis remap='I'>display_accelerator</emphasis> field is non-NULL,
1174<xref linkend='XtInstallAccelerators' xrefstyle='select: title'/>
1175calls it with the source widget and a string representation
1176of the accelerator table,
1177which indicates that its accelerators have been installed
1178and that it should display them appropriately.
1179The string representation of the accelerator table is its
1180canonical translation table representation.
1181</para>
1182
1183<para>
1184As a convenience for installing all accelerators from a widget and all its
1185descendants onto one destination, use
1186<xref linkend='XtInstallAllAccelerators' xrefstyle='select: title'/>.
1187</para>
1188
1189<funcsynopsis id='XtInstallAllAccelerators'>
1190<funcprototype>
1191<funcdef>void <function>XtInstallAllAccelerators</function></funcdef>
1192   <paramdef>Widget <parameter>destination</parameter></paramdef>
1193   <paramdef>Widget <parameter>source</parameter></paramdef>
1194</funcprototype>
1195</funcsynopsis>
1196
1197<variablelist>
1198  <varlistentry>
1199    <term>
1200      <emphasis remap='I'>destination</emphasis>
1201    </term>
1202    <listitem>
1203      <para>
1204Specifies the widget on which the accelerators are to be installed.  Must be of class Core or any subclass thereof.
1205      </para>
1206    </listitem>
1207  </varlistentry>
1208  <varlistentry>
1209    <term>
1210      <emphasis remap='I'>source</emphasis>
1211    </term>
1212    <listitem>
1213      <para>
1214Specifies the root widget of the widget tree
1215from which the accelerators are to come.  Must be of class Core or any subclass thereof.
1216    </para>
1217  </listitem>
1218  </varlistentry>
1219</variablelist>
1220
1221<para>
1222The
1223<xref linkend='XtInstallAllAccelerators' xrefstyle='select: title'/>
1224function recursively descends the widget tree rooted at <emphasis remap='I'>source</emphasis>
1225and installs the accelerators resource value
1226of each widget encountered onto <emphasis remap='I'>destination</emphasis>.
1227A common use is to call
1228<xref linkend='XtInstallAllAccelerators' xrefstyle='select: title'/>
1229and pass the application main window as the source.
1230</para>
1231</sect1>
1232
1233<sect1 id="KeyCode_to_KeySym_Conversions">
1234<title>KeyCode-to-KeySym Conversions</title>
1235<para>
1236The translation manager provides support for automatically translating
1237KeyCodes in incoming key events into KeySyms.
1238KeyCode-to-KeySym translator procedure pointers are of type
1239<xref linkend='XtKeyProc' xrefstyle='select: title'/>.
1240</para>
1241
1242<funcsynopsis id='XtKeyProc'>
1243<funcprototype>
1244<funcdef>typedef void <function>(*XtKeyProc)</function></funcdef>
1245   <paramdef>Display *<parameter>display</parameter></paramdef>
1246   <paramdef>KeyCode <parameter>keycode</parameter></paramdef>
1247   <paramdef>Modifiers <parameter>modifiers</parameter></paramdef>
1248   <paramdef>Modifiers *<parameter>modifiers_return</parameter></paramdef>
1249   <paramdef>KeySym *<parameter>keysym_return</parameter></paramdef>
1250</funcprototype>
1251</funcsynopsis>
1252
1253<variablelist>
1254  <varlistentry>
1255    <term>
1256      <emphasis remap='I'>display</emphasis>
1257    </term>
1258    <listitem>
1259      <para>
1260Specifies the display that the KeyCode is from.
1261      </para>
1262    </listitem>
1263  </varlistentry>
1264  <varlistentry>
1265    <term>
1266      <emphasis remap='I'>keycode</emphasis>
1267    </term>
1268    <listitem>
1269      <para>
1270Specifies the KeyCode to translate.
1271      </para>
1272    </listitem>
1273  </varlistentry>
1274  <varlistentry>
1275    <term>
1276      <emphasis remap='I'>modifiers</emphasis>
1277    </term>
1278    <listitem>
1279      <para>
1280Specifies the modifiers to the KeyCode.
1281      </para>
1282    </listitem>
1283  </varlistentry>
1284  <varlistentry>
1285    <term>
1286      <emphasis remap='I'>modifiers_return</emphasis>
1287    </term>
1288    <listitem>
1289      <para>
1290Specifies a location in which to store
1291a mask that indicates the subset of all
1292modifiers that are examined by the key translator for the specified keycode.
1293      </para>
1294    </listitem>
1295  </varlistentry>
1296  <varlistentry>
1297    <term>
1298      <emphasis remap='I'>keysym_return</emphasis>
1299    </term>
1300    <listitem>
1301      <para>
1302Specifies a location in which to store the resulting KeySym.
1303    </para>
1304  </listitem>
1305  </varlistentry>
1306</variablelist>
1307
1308<para>
1309This procedure takes a KeyCode and modifiers and produces a KeySym.
1310For any given key translator function and keyboard encoding,
1311<emphasis remap='I'>modifiers_return</emphasis> will be a constant per KeyCode that indicates
1312the subset of all modifiers that are examined by the key translator
1313for that KeyCode.
1314</para>
1315
1316<para>
1317The KeyCode-to-KeySym translator procedure
1318must be implemented such that multiple calls with the same
1319<emphasis remap='I'>display</emphasis>, <emphasis remap='I'>keycode</emphasis>, and <emphasis remap='I'>modifiers</emphasis> return the same
1320result until either a new case converter, an
1321<xref linkend='XtCaseProc' xrefstyle='select: title'/>,
1322is installed or a
1323<function>MappingNotify</function>
1324event is received.
1325</para>
1326
1327<para>
1328The Intrinsics maintain tables internally to map KeyCodes to KeySyms
1329for each open display.  Translator procedures and other clients may
1330share a single copy of this table to perform the same mapping.
1331</para>
1332
1333<para>
1334To return a pointer to the KeySym-to-KeyCode mapping table for a
1335particular display, use
1336<xref linkend='XtGetKeysymTable' xrefstyle='select: title'/>.
1337</para>
1338
1339<funcsynopsis id='XtGetKeysymTable'>
1340<funcprototype>
1341<funcdef>KeySym *<function>XtGetKeysymTable</function></funcdef>
1342   <paramdef>Display *<parameter>display</parameter></paramdef>
1343   <paramdef>KeyCode *<parameter>min_keycode_return</parameter></paramdef>
1344   <paramdef>int *<parameter>keysyms_per_keycode_return</parameter></paramdef>
1345</funcprototype>
1346</funcsynopsis>
1347
1348<variablelist>
1349  <varlistentry>
1350    <term>
1351      <emphasis remap='I'>display</emphasis>
1352    </term>
1353    <listitem>
1354      <para>
1355Specifies the display whose table is required.
1356      </para>
1357    </listitem>
1358  </varlistentry>
1359  <varlistentry>
1360    <term>
1361      <emphasis remap='I'>min_keycode_return</emphasis>
1362    </term>
1363    <listitem>
1364      <para>
1365Returns the minimum KeyCode valid for the display.
1366      </para>
1367    </listitem>
1368  </varlistentry>
1369  <varlistentry>
1370    <term>
1371      <emphasis remap='I'>keysyms_per_keycode_return</emphasis>
1372    </term>
1373    <listitem>
1374      <para>
1375Returns the number of KeySyms stored for each KeyCode.
1376    </para>
1377  </listitem>
1378  </varlistentry>
1379</variablelist>
1380
1381<para>
1382<xref linkend='XtGetKeysymTable' xrefstyle='select: title'/>
1383returns a pointer to the Intrinsics' copy of the
1384server's KeyCode-to-KeySym table.  This table must not be modified.
1385There are <emphasis remap='I'>keysyms_per_keycode_return</emphasis> KeySyms associated with each
1386KeyCode, located in the table with indices starting at index
1387</para>
1388<literallayout>
1389    (test_keycode - min_keycode_return) * keysyms_per_keycode_return
1390</literallayout>
1391<para>
1392for KeyCode <emphasis remap='I'>test_keycode</emphasis>.  Any entries that have no KeySyms associated
1393with them contain the value
1394<function>NoSymbol</function>.
1395Clients should not cache the KeySym table but should call
1396<xref linkend='XtGetKeysymTable' xrefstyle='select: title'/>
1397each time the value is
1398needed, as the table may change prior to dispatching each event.
1399</para>
1400
1401<para>
1402For more information on this table, see
1403<olink targetdoc='libX11' targetptr='Manipulating_the_Keyboard_Encoding'>Section 12.7</olink> in
1404<olink targetdoc='libX11' targetptr='libX11'>Xlib — C Language X Interface.</olink>.
1405</para>
1406
1407<para>
1408To register a key translator, use
1409<xref linkend='XtSetKeyTranslator' xrefstyle='select: title'/>.
1410</para>
1411
1412<funcsynopsis id='XtSetKeyTranslator'>
1413<funcprototype>
1414<funcdef>void <function>XtSetKeyTranslator</function></funcdef>
1415   <paramdef>Display *<parameter>display</parameter></paramdef>
1416   <paramdef>XtKeyProc <parameter>proc</parameter></paramdef>
1417</funcprototype>
1418</funcsynopsis>
1419
1420<variablelist>
1421  <varlistentry>
1422    <term>
1423      <emphasis remap='I'>display</emphasis>
1424    </term>
1425    <listitem>
1426      <para>
1427Specifies the display from which to translate the events.
1428      </para>
1429    </listitem>
1430  </varlistentry>
1431  <varlistentry>
1432    <term>
1433      <emphasis remap='I'>proc</emphasis>
1434    </term>
1435    <listitem>
1436      <para>
1437Specifies the procedure to perform key translations.
1438    </para>
1439  </listitem>
1440  </varlistentry>
1441</variablelist>
1442
1443<para>
1444The
1445<xref linkend='XtSetKeyTranslator' xrefstyle='select: title'/>
1446function sets the specified procedure as the current key translator.
1447The default translator is
1448<function>XtTranslateKey</function>,
1449an
1450<xref linkend='XtKeyProc' xrefstyle='select: title'/>
1451that uses the Shift, Lock, numlock, and group modifiers
1452with the interpretations defined in <emphasis remap='I'>X Window System Protocol</emphasis>, Section 5.
1453It is provided so that new translators can call it to get default
1454KeyCode-to-KeySym translations and so that the default translator
1455can be reinstalled.
1456</para>
1457
1458<para>
1459To invoke the currently registered KeyCode-to-KeySym translator,
1460use
1461<xref linkend='XtTranslateKeycode' xrefstyle='select: title'/>.
1462</para>
1463
1464<funcsynopsis id='XtTranslateKeycode'>
1465<funcprototype>
1466<funcdef>void <function>XtTranslateKeycode</function></funcdef>
1467   <paramdef>Display *<parameter>display</parameter></paramdef>
1468   <paramdef>KeyCode <parameter>keycode</parameter></paramdef>
1469   <paramdef>Modifiers <parameter>modifiers</parameter></paramdef>
1470   <paramdef>Modifiers *<parameter>modifiers_return</parameter></paramdef>
1471   <paramdef>KeySym *<parameter>keysym_return</parameter></paramdef>
1472</funcprototype>
1473</funcsynopsis>
1474
1475<variablelist>
1476  <varlistentry>
1477    <term>
1478      <emphasis remap='I'>display</emphasis>
1479    </term>
1480    <listitem>
1481      <para>
1482Specifies the display that the KeyCode is from.
1483      </para>
1484    </listitem>
1485  </varlistentry>
1486  <varlistentry>
1487    <term>
1488      <emphasis remap='I'>keycode</emphasis>
1489    </term>
1490    <listitem>
1491      <para>
1492Specifies the KeyCode to translate.
1493      </para>
1494    </listitem>
1495  </varlistentry>
1496  <varlistentry>
1497    <term>
1498      <emphasis remap='I'>modifiers</emphasis>
1499    </term>
1500    <listitem>
1501      <para>
1502Specifies the modifiers to the KeyCode.
1503      </para>
1504    </listitem>
1505  </varlistentry>
1506  <varlistentry>
1507    <term>
1508      <emphasis remap='I'>modifiers_return</emphasis>
1509    </term>
1510    <listitem>
1511      <para>
1512Returns a mask that indicates the modifiers actually used
1513to generate the KeySym.
1514      </para>
1515    </listitem>
1516  </varlistentry>
1517  <varlistentry>
1518    <term>
1519      <emphasis remap='I'>keysym_return</emphasis>
1520    </term>
1521    <listitem>
1522      <para>
1523Returns the resulting KeySym.
1524    </para>
1525  </listitem>
1526  </varlistentry>
1527</variablelist>
1528
1529<para>
1530The
1531<xref linkend='XtTranslateKeycode' xrefstyle='select: title'/>
1532function passes the specified arguments
1533directly to the currently registered KeyCode-to-KeySym translator.
1534</para>
1535
1536<para>
1537To handle capitalization of nonstandard KeySyms, the Intrinsics allow
1538clients to register case conversion routines.
1539Case converter procedure pointers are of type
1540<xref linkend='XtCaseProc' xrefstyle='select: title'/>.
1541</para>
1542
1543<funcsynopsis id='XtCaseProc'>
1544<funcprototype>
1545<funcdef>typedef void <function>(*XtCaseProc)</function></funcdef>
1546   <paramdef>Display *<parameter>display</parameter></paramdef>
1547   <paramdef>KeySym <parameter>keysym</parameter></paramdef>
1548   <paramdef>KeySym *<parameter>lower_return</parameter></paramdef>
1549   <paramdef>KeySym *<parameter>upper_return</parameter></paramdef>
1550</funcprototype>
1551</funcsynopsis>
1552
1553<variablelist>
1554  <varlistentry>
1555    <term>
1556      <emphasis remap='I'>display</emphasis>
1557    </term>
1558    <listitem>
1559      <para>
1560Specifies the display connection for which the conversion is required.
1561      </para>
1562    </listitem>
1563  </varlistentry>
1564  <varlistentry>
1565    <term>
1566      <emphasis remap='I'>keysym</emphasis>
1567    </term>
1568    <listitem>
1569      <para>
1570Specifies the KeySym to convert.
1571      </para>
1572    </listitem>
1573  </varlistentry>
1574  <varlistentry>
1575    <term>
1576      <emphasis remap='I'>lower_return</emphasis>
1577    </term>
1578    <listitem>
1579      <para>
1580Specifies a location into which to store the lowercase equivalent for
1581the KeySym.
1582      </para>
1583    </listitem>
1584  </varlistentry>
1585  <varlistentry>
1586    <term>
1587      <emphasis remap='I'>upper_return</emphasis>
1588    </term>
1589    <listitem>
1590      <para>
1591Specifies a location into which to store the uppercase equivalent for
1592the KeySym.
1593    </para>
1594  </listitem>
1595  </varlistentry>
1596</variablelist>
1597
1598<para>
1599If there is no case distinction,
1600this procedure should store the KeySym into both return values.
1601</para>
1602
1603<para>
1604To register a case converter, use
1605<xref linkend='XtRegisterCaseConverter' xrefstyle='select: title'/>.
1606</para>
1607
1608<funcsynopsis id='XtRegisterCaseConverter'>
1609<funcprototype>
1610<funcdef>void <function>XtRegisterCaseConverter</function></funcdef>
1611   <paramdef>Display *<parameter>display</parameter></paramdef>
1612   <paramdef>XtCaseProc <parameter>proc</parameter></paramdef>
1613   <paramdef>KeySym <parameter>start</parameter></paramdef>
1614   <paramdef>KeySym <parameter>stop</parameter></paramdef>
1615</funcprototype>
1616</funcsynopsis>
1617
1618<variablelist>
1619  <varlistentry>
1620    <term>
1621      <emphasis remap='I'>display</emphasis>
1622    </term>
1623    <listitem>
1624      <para>
1625Specifies the display from which the key events are to come.
1626      </para>
1627    </listitem>
1628  </varlistentry>
1629  <varlistentry>
1630    <term>
1631      <emphasis remap='I'>proc</emphasis>
1632    </term>
1633    <listitem>
1634      <para>
1635Specifies the
1636<xref linkend='XtCaseProc' xrefstyle='select: title'/>
1637to do the conversions.
1638      </para>
1639    </listitem>
1640  </varlistentry>
1641  <varlistentry>
1642    <term>
1643      <emphasis remap='I'>start</emphasis>
1644    </term>
1645    <listitem>
1646      <para>
1647Specifies the first KeySym for which this converter is valid.
1648      </para>
1649    </listitem>
1650  </varlistentry>
1651  <varlistentry>
1652    <term>
1653      <emphasis remap='I'>stop</emphasis>
1654    </term>
1655    <listitem>
1656      <para>
1657Specifies the last KeySym for which this converter is valid.
1658    </para>
1659  </listitem>
1660  </varlistentry>
1661</variablelist>
1662
1663<para>
1664The
1665<xref linkend='XtRegisterCaseConverter' xrefstyle='select: title'/>
1666registers the specified case converter.
1667The <emphasis remap='I'>start</emphasis> and <emphasis remap='I'>stop</emphasis> arguments provide the inclusive range of KeySyms
1668for which this converter is to be called.
1669The new converter overrides any previous converters for KeySyms in that range.
1670No interface exists to remove converters;
1671you need to register an identity converter.
1672When a new converter is registered,
1673the Intrinsics  refresh the keyboard state if necessary.
1674The default converter understands case conversion for all
1675Latin KeySyms defined in <emphasis remap='I'>X Window System Protocol</emphasis>, Appendix A.
1676</para>
1677
1678<para>
1679To determine uppercase and lowercase equivalents for a KeySym, use
1680<xref linkend='XtConvertCase' xrefstyle='select: title'/>.
1681</para>
1682
1683<funcsynopsis id='XtConvertCase'>
1684<funcprototype>
1685<funcdef>void <function>XtConvertCase</function></funcdef>
1686   <paramdef>Display *<parameter>display</parameter></paramdef>
1687   <paramdef>KeySym <parameter>keysym</parameter></paramdef>
1688   <paramdef>KeySym *<parameter>lower_return</parameter></paramdef>
1689   <paramdef>KeySym *<parameter>upper_return</parameter></paramdef>
1690</funcprototype>
1691</funcsynopsis>
1692
1693<variablelist>
1694  <varlistentry>
1695    <term>
1696      <emphasis remap='I'>display</emphasis>
1697    </term>
1698    <listitem>
1699      <para>
1700Specifies the display that the KeySym came from.
1701      </para>
1702    </listitem>
1703  </varlistentry>
1704  <varlistentry>
1705    <term>
1706      <emphasis remap='I'>keysym</emphasis>
1707    </term>
1708    <listitem>
1709      <para>
1710Specifies the KeySym to convert.
1711      </para>
1712    </listitem>
1713  </varlistentry>
1714  <varlistentry>
1715    <term>
1716      <emphasis remap='I'>lower_return</emphasis>
1717    </term>
1718    <listitem>
1719      <para>
1720Returns the lowercase equivalent of the KeySym.
1721      </para>
1722    </listitem>
1723  </varlistentry>
1724  <varlistentry>
1725    <term>
1726      <emphasis remap='I'>upper_return</emphasis>
1727    </term>
1728    <listitem>
1729      <para>
1730Returns the uppercase equivalent of the KeySym.
1731    </para>
1732  </listitem>
1733  </varlistentry>
1734</variablelist>
1735
1736<para>
1737The
1738<xref linkend='XtConvertCase' xrefstyle='select: title'/>
1739function calls the appropriate converter and returns the results.
1740A user-supplied
1741<xref linkend='XtKeyProc' xrefstyle='select: title'/>
1742may need to use this function.
1743</para>
1744</sect1>
1745
1746<sect1 id="Obtaining_a_KeySym_in_an_Action_Procedure">
1747<title>Obtaining a KeySym in an Action Procedure</title>
1748<para>
1749When an action procedure is invoked on a
1750<function>KeyPress</function>
1751or
1752<function>KeyRelease</function>
1753event, it often has a need to retrieve the KeySym and modifiers
1754corresponding to the event that caused it to be invoked.  In order to
1755avoid repeating the processing that was just performed by the
1756Intrinsics to match the translation entry, the KeySym and modifiers
1757are stored for the duration of the action procedure and are made
1758available to the client.
1759</para>
1760
1761<para>
1762To retrieve the KeySym and modifiers that matched the final event
1763specification in the translation table entry, use
1764<xref linkend='XtGetActionKeysym' xrefstyle='select: title'/>.
1765</para>
1766
1767<funcsynopsis id='XtGetActionKeysym'>
1768<funcprototype>
1769<funcdef>KeySym <function>XtGetActionKeysym</function></funcdef>
1770   <paramdef>XEvent *<parameter>event</parameter></paramdef>
1771   <paramdef>Modifiers *<parameter>modifiers_return</parameter></paramdef>
1772</funcprototype>
1773</funcsynopsis>
1774
1775<variablelist>
1776  <varlistentry>
1777    <term>
1778      <emphasis remap='I'>event</emphasis>
1779    </term>
1780    <listitem>
1781      <para>
1782Specifies the event pointer passed to the action procedure by the Intrinsics.
1783      </para>
1784    </listitem>
1785  </varlistentry>
1786  <varlistentry>
1787    <term>
1788      <emphasis remap='I'>modifiers_return</emphasis>
1789    </term>
1790    <listitem>
1791      <para>
1792Returns the modifiers that caused the match, if non-NULL.
1793    </para>
1794  </listitem>
1795  </varlistentry>
1796</variablelist>
1797
1798<para>
1799If
1800<xref linkend='XtGetActionKeysym' xrefstyle='select: title'/>
1801is called after an action procedure has been
1802invoked by the Intrinsics and before that action procedure returns, and
1803if the event pointer has the same value as the event pointer passed to
1804that action routine, and if the event is a
1805<function>KeyPress</function>
1806or
1807<function>KeyRelease</function>
1808event, then
1809<xref linkend='XtGetActionKeysym' xrefstyle='select: title'/>
1810returns the KeySym that matched the final
1811event specification in the translation table and, if <emphasis remap='I'>modifiers_return</emphasis>
1812is non-NULL, the modifier state actually used to generate this KeySym;
1813otherwise, if the event is a
1814<function>KeyPress</function>
1815or
1816<function>KeyRelease</function>
1817event, then
1818<xref linkend='XtGetActionKeysym' xrefstyle='select: title'/>
1819calls
1820<xref linkend='XtTranslateKeycode' xrefstyle='select: title'/>
1821and returns the results;
1822else it returns
1823<function>NoSymbol</function>
1824and does not examine <emphasis remap='I'>modifiers_return</emphasis>.
1825</para>
1826
1827<para>
1828Note that if an action procedure invoked by the Intrinsics
1829invokes a subsequent action procedure (and so on) via
1830<xref linkend='XtCallActionProc' xrefstyle='select: title'/>,
1831the nested action procedure may also call
1832<xref linkend='XtGetActionKeysym' xrefstyle='select: title'/>
1833to retrieve the Intrinsics' KeySym and modifiers.
1834</para>
1835</sect1>
1836
1837<sect1 id="KeySym_to_KeyCode_Conversions">
1838<title>KeySym-to-KeyCode Conversions</title>
1839<para>
1840To return the list of KeyCodes that map to a particular KeySym in
1841the keyboard mapping table maintained by the Intrinsics, use
1842<xref linkend='XtKeysymToKeycodeList' xrefstyle='select: title'/>.
1843</para>
1844
1845<funcsynopsis id='XtKeysymToKeycodeList'>
1846<funcprototype>
1847<funcdef>void <function>XtKeysymToKeycodeList</function></funcdef>
1848   <paramdef>Display *<parameter>display</parameter></paramdef>
1849   <paramdef>KeySym <parameter>keysym</parameter></paramdef>
1850   <paramdef>KeyCode **<parameter>keycodes_return</parameter></paramdef>
1851   <paramdef>Cardinal *<parameter>keycount_return</parameter></paramdef>
1852</funcprototype>
1853</funcsynopsis>
1854
1855<variablelist>
1856  <varlistentry>
1857    <term>
1858      <emphasis remap='I'>display</emphasis>
1859    </term>
1860    <listitem>
1861      <para>
1862Specifies the display whose table is required.
1863      </para>
1864    </listitem>
1865  </varlistentry>
1866  <varlistentry>
1867    <term>
1868      <emphasis remap='I'>keysym</emphasis>
1869    </term>
1870    <listitem>
1871      <para>
1872Specifies the KeySym for which to search.
1873      </para>
1874    </listitem>
1875  </varlistentry>
1876  <varlistentry>
1877    <term>
1878      <emphasis remap='I'>keycodes_return</emphasis>
1879    </term>
1880    <listitem>
1881      <para>
1882Returns a list of KeyCodes that have <emphasis remap='I'>keysym</emphasis>
1883associated with them, or NULL if <emphasis remap='I'>keycount_return</emphasis> is 0.
1884      </para>
1885    </listitem>
1886  </varlistentry>
1887  <varlistentry>
1888    <term>
1889      <emphasis remap='I'>keycount_return</emphasis>
1890    </term>
1891    <listitem>
1892      <para>
1893Returns the number of KeyCodes in the keycode list.
1894    </para>
1895  </listitem>
1896  </varlistentry>
1897</variablelist>
1898
1899<para>
1900The
1901<xref linkend='XtKeysymToKeycodeList' xrefstyle='select: title'/>
1902procedure returns all the KeyCodes that have <emphasis remap='I'>keysym</emphasis>
1903in their entry for the keyboard mapping table associated with <emphasis remap='I'>display</emphasis>.
1904For each entry in the
1905table, the first four KeySyms (groups 1 and 2) are interpreted as
1906specified by <emphasis remap='I'>X Window System Protocol</emphasis>, Section 5.  If no KeyCodes map to the
1907specified KeySym, <emphasis remap='I'>keycount_return</emphasis> is zero and *<emphasis remap='I'>keycodes_return</emphasis> is NULL.
1908</para>
1909
1910<para>
1911The caller should free the storage pointed to by <emphasis remap='I'>keycodes_return</emphasis> using
1912<xref linkend='XtFree' xrefstyle='select: title'/>
1913when it is no longer useful.  If the caller needs to examine
1914the KeyCode-to-KeySym table for a particular KeyCode, it should call
1915<xref linkend='XtGetKeysymTable' xrefstyle='select: title'/>.
1916</para>
1917</sect1>
1918
1919<sect1 id="Registering_Button_and_Key_Grabs_for_Actions">
1920<title>Registering Button and Key Grabs for Actions</title>
1921<para>
1922To register button and key grabs for a widget's window according to the
1923event bindings in the widget's translation table, use
1924<xref linkend='XtRegisterGrabAction' xrefstyle='select: title'/>.
1925</para>
1926
1927<funcsynopsis id='XtRegisterGrabAction'>
1928<funcprototype>
1929<funcdef>void <function>XtRegisterGrabAction</function></funcdef>
1930   <paramdef>XtActionProc <parameter>action_proc</parameter></paramdef>
1931   <paramdef>Boolean <parameter>owner_events</parameter></paramdef>
1932   <paramdef>unsigned int <parameter>event_mask</parameter></paramdef>
1933   <paramdef>int <parameter>pointer_mode</parameter></paramdef>
1934</funcprototype>
1935</funcsynopsis>
1936
1937<variablelist>
1938  <varlistentry>
1939    <term>
1940      <emphasis remap='I'>action_proc</emphasis>
1941    </term>
1942    <listitem>
1943      <para>
1944Specifies the action procedure to search for in translation tables.
1945      </para>
1946    </listitem>
1947  </varlistentry>
1948  <varlistentry>
1949    <term>
1950      <emphasis remap='I'>owner_events</emphasis>
1951    </term>
1952    <listitem>
1953      <para></para>
1954      
1955    </listitem>
1956  </varlistentry>
1957  <varlistentry>
1958    <term>
1959      <emphasis remap='I'>event_mask</emphasis>
1960    </term>
1961    <listitem>
1962      <para></para>
1963      
1964    </listitem>
1965  </varlistentry>
1966  <varlistentry>
1967    <term>
1968      <emphasis remap='I'>pointer_mode</emphasis>
1969    </term>
1970    <listitem>
1971      <para></para>
1972    </listitem>
1973  </varlistentry>
1974  <varlistentry>
1975    <term>
1976      <emphasis remap='I'>keyboard_mode</emphasis>
1977    </term>
1978    <listitem>
1979      <para>
1980Specify arguments to
1981<xref linkend='XtGrabButton' xrefstyle='select: title'/>
1982or
1983<xref linkend='XtGrabKey' xrefstyle='select: title'/>.
1984    </para>
1985  </listitem>
1986  </varlistentry>
1987</variablelist>
1988
1989<para>
1990<xref linkend='XtRegisterGrabAction' xrefstyle='select: title'/>
1991adds the specified <emphasis remap='I'>action_proc</emphasis> to a list known to
1992the translation manager.  When a widget is realized, or when the
1993translations of a realized widget or the accelerators installed on a
1994realized widget are modified, its translation table and any installed
1995accelerators are scanned for action procedures on this list.
1996If any are invoked on
1997<function>ButtonPress</function>
1998or
1999<function>KeyPress</function>
2000events as the only or final event
2001in a sequence, the Intrinsics will call
2002<xref linkend='XtGrabButton' xrefstyle='select: title'/>
2003or
2004<xref linkend='XtGrabKey' xrefstyle='select: title'/>
2005for the widget with every button or KeyCode which maps to the
2006event detail field, passing the specified <emphasis remap='I'>owner_events</emphasis>, <emphasis remap='I'>event_mask</emphasis>,
2007<emphasis remap='I'>pointer_mode</emphasis>, and <emphasis remap='I'>keyboard_mode</emphasis>.  For
2008<function>ButtonPress</function>
2009events, the modifiers
2010specified in the grab are determined directly from the translation
2011specification and <emphasis remap='I'>confine_to</emphasis> and <emphasis remap='I'>cursor</emphasis> are specified as
2012<function>None</function>.
2013For
2014<function>KeyPress</function>
2015events, if the translation table entry specifies colon (:) in
2016the modifier list, the modifiers are determined by calling the key
2017translator procedure registered for the display and calling
2018<xref linkend='XtGrabKey' xrefstyle='select: title'/>
2019for every combination of standard modifiers which map the KeyCode to
2020the specified event detail KeySym, and ORing any modifiers specified in
2021the translation table entry, and <emphasis remap='I'>event_mask</emphasis> is ignored.  If the
2022translation table entry does not specify colon in the modifier list,
2023the modifiers specified in the grab are those specified in the
2024translation table entry only.  For both
2025<function>ButtonPress</function>
2026and
2027<function>KeyPress</function>
2028events, don't-care modifiers are ignored unless the translation entry
2029explicitly specifies ``Any'' in the <emphasis remap='I'>modifiers</emphasis> field.
2030</para>
2031
2032<para>
2033If the specified <emphasis remap='I'>action_proc</emphasis> is already registered for the calling
2034process, the new values will replace the previously specified values
2035for any widgets that become realized following the call, but existing
2036grabs are not altered on currently realized widgets.
2037</para>
2038
2039<para>
2040When translations or installed accelerators are modified for a
2041realized widget, any previous key or button grabs registered
2042as a result of the old bindings are released if they do not appear in
2043the new bindings and are not explicitly grabbed by the client with
2044<xref linkend='XtGrabKey' xrefstyle='select: title'/>
2045or
2046<xref linkend='XtGrabButton' xrefstyle='select: title'/>.
2047</para>
2048</sect1>
2049
2050<sect1 id="Invoking_Actions_Directly">
2051<title>Invoking Actions Directly</title>
2052<para>
2053Normally action procedures are invoked by the Intrinsics when an
2054event or event sequence arrives for a widget. To
2055invoke an action procedure directly, without generating
2056(or synthesizing) events, use
2057<xref linkend='XtCallActionProc' xrefstyle='select: title'/>.
2058</para>
2059
2060<funcsynopsis id='XtCallActionProc'>
2061<funcprototype>
2062<funcdef>void <function>XtCallActionProc</function></funcdef>
2063   <paramdef>Widget <parameter>widget</parameter></paramdef>
2064   <paramdef>String <parameter>action</parameter></paramdef>
2065   <paramdef>XEvent *<parameter>event</parameter></paramdef>
2066   <paramdef>String *<parameter>params</parameter></paramdef>
2067   <paramdef>Cardinal <parameter>num_params</parameter></paramdef>
2068</funcprototype>
2069</funcsynopsis>
2070
2071<variablelist>
2072  <varlistentry>
2073    <term>
2074      <emphasis remap='I'>widget</emphasis>
2075    </term>
2076    <listitem>
2077      <para>
2078Specifies the widget in which the action is to be invoked.  Must be of class Core or any subclass thereof.
2079      </para>
2080    </listitem>
2081  </varlistentry>
2082  <varlistentry>
2083    <term>
2084      <emphasis remap='I'>action</emphasis>
2085    </term>
2086    <listitem>
2087      <para>
2088Specifies the name of the action routine.
2089      </para>
2090    </listitem>
2091  </varlistentry>
2092  <varlistentry>
2093    <term>
2094      <emphasis remap='I'>event</emphasis>
2095    </term>
2096    <listitem>
2097      <para>
2098Specifies the contents of the <emphasis remap='I'>event</emphasis> passed to the action routine.
2099      </para>
2100    </listitem>
2101  </varlistentry>
2102  <varlistentry>
2103    <term>
2104      <emphasis remap='I'>params</emphasis>
2105    </term>
2106    <listitem>
2107      <para>
2108Specifies the contents of the <emphasis remap='I'>params</emphasis> passed to the action routine.
2109      </para>
2110    </listitem>
2111  </varlistentry>
2112  <varlistentry>
2113    <term>
2114      <emphasis remap='I'>num_params</emphasis>
2115    </term>
2116    <listitem>
2117      <para>
2118Specifies the number of entries in <emphasis remap='I'>params</emphasis>.
2119    </para>
2120  </listitem>
2121  </varlistentry>
2122</variablelist>
2123
2124<para>
2125<xref linkend='XtCallActionProc' xrefstyle='select: title'/>
2126searches for the named action routine in the same
2127manner and order as translation tables are bound, as described in
2128Section 10.1.2, except that application action tables are searched, if
2129necessary, as of the time of the call to
2130<xref linkend='XtCallActionProc' xrefstyle='select: title'/>.
2131If found,
2132the action routine is invoked with the specified widget, event pointer,
2133and parameters.  It is the responsibility of the caller to ensure that
2134the contents of the <emphasis remap='I'>event</emphasis>, <emphasis remap='I'>params</emphasis>, and <emphasis remap='I'>num_params</emphasis> arguments are
2135appropriate for the specified action routine and, if necessary, that
2136the specified widget is realized or sensitive.  If the named action
2137routine cannot be found,
2138<xref linkend='XtCallActionProc' xrefstyle='select: title'/>
2139generates a warning message and returns.
2140</para>
2141</sect1>
2142
2143<sect1 id="Obtaining_a_Widget_s_Action_List">
2144<title>Obtaining a Widget's Action List</title>
2145<para>
2146Occasionally a subclass will require the pointers to one or more of
2147its superclass's action procedures.  This would be needed, for
2148example, in order to envelop the superclass's action.  To retrieve
2149the list of action procedures registered in the superclass's
2150<emphasis remap='I'>actions</emphasis> field, use
2151<xref linkend='XtGetActionList' xrefstyle='select: title'/>.
2152</para>
2153
2154<funcsynopsis id='XtGetActionList'>
2155<funcprototype>
2156<funcdef>void <function>XtGetActionList</function></funcdef>
2157   <paramdef>WidgetClass <parameter>widget_class</parameter></paramdef>
2158   <paramdef>XtActionList *<parameter>actions_return</parameter></paramdef>
2159   <paramdef>Cardinal *<parameter>num_actions_return</parameter></paramdef>
2160</funcprototype>
2161</funcsynopsis>
2162
2163<variablelist>
2164  <varlistentry>
2165    <term>
2166      <emphasis remap='I'>widget_class</emphasis>
2167    </term>
2168    <listitem>
2169      <para>
2170Specifies the widget class whose actions are to be returned.
2171      </para>
2172    </listitem>
2173  </varlistentry>
2174  <varlistentry>
2175    <term>
2176      <emphasis remap='I'>actions_return</emphasis>
2177    </term>
2178    <listitem>
2179      <para>
2180Returns the action list.
2181      </para>
2182    </listitem>
2183  </varlistentry>
2184  <varlistentry>
2185    <term>
2186      <emphasis remap='I'>num_actions_return</emphasis>
2187    </term>
2188    <listitem>
2189      <para>
2190Returns the number of action procedures declared by the class.
2191    </para>
2192  </listitem>
2193  </varlistentry>
2194</variablelist>
2195
2196<para>
2197<xref linkend='XtGetActionList' xrefstyle='select: title'/>
2198returns the action table defined by the specified
2199widget class.  This table does not include actions defined by the
2200superclasses.  If <emphasis remap='I'>widget_class</emphasis> is not initialized, or is not
2201<function>coreWidgetClass</function>
2202or a subclass thereof, or if the class does not define any actions,
2203*<emphasis remap='I'>actions_return</emphasis> will be NULL and *<emphasis remap='I'>num_actions_return</emphasis>
2204will be zero.
2205If *<emphasis remap='I'>actions_return</emphasis> is non-NULL the client is responsible for freeing
2206the table using
2207<xref linkend='XtFree' xrefstyle='select: title'/>
2208when it is no longer needed.
2209</para>
2210</sect1>
2211</chapter>
2212