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