summaryrefslogtreecommitdiff
path: root/specs/CH09.xml
diff options
context:
space:
mode:
authorThomas E. Dickey <dickey@invisible-island.net>2019-04-14 18:45:06 -0400
committerThomas E. Dickey <dickey@invisible-island.net>2019-04-16 18:47:10 -0400
commitaab9b50bb755d741ee54203f91bdfc464a95642f (patch)
tree1ea045c043e39dbccd3e6cf0a7fc0e6b4cad5696 /specs/CH09.xml
parentaa871eb5c087f3af40e49e77378a04fa872c7465 (diff)
use programlisting tag rather than workaround for literallayout font.
Signed-off-by: Thomas E. Dickey <dickey@invisible-island.net>
Diffstat (limited to 'specs/CH09.xml')
-rw-r--r--specs/CH09.xml254
1 files changed, 127 insertions, 127 deletions
diff --git a/specs/CH09.xml b/specs/CH09.xml
index 53eba83..822ee6a 100644
--- a/specs/CH09.xml
+++ b/specs/CH09.xml
@@ -46,17 +46,17 @@ The declaration for the
<function>XtResource</function>
structure is
</para>
-<literallayout>
-<code>typedef struct {</code>
-<code> String resource_name;</code>
-<code> String resource_class;</code>
-<code> String resource_type;</code>
-<code> Cardinal resource_size;</code>
-<code> Cardinal resource_offset;</code>
-<code> String default_type;</code>
-<code> XtPointer default_addr;</code>
-<code>} XtResource, *XtResourceList;</code>
-</literallayout>
+<programlisting>
+typedef struct {
+ String resource_name;
+ String resource_class;
+ String resource_type;
+ Cardinal resource_size;
+ Cardinal resource_offset;
+ String default_type;
+ XtPointer default_addr;
+} XtResource, *XtResourceList;
+</programlisting>
<para>
When the resource list is specified as the
<function>CoreClassPart</function>,
@@ -130,19 +130,19 @@ and all the other pixel entries a resource class of
Then, the resource file needs only two lines to
change all pixels to ivory or darkblue:
</para>
-<literallayout>
-<code>*Background: ivory</code>
-<code>*Foreground: darkblue</code>
-</literallayout>
+<programlisting>
+*Background: ivory
+*Foreground: darkblue
+</programlisting>
<para>
Similarly, a widget may have several font resources (such as normal and bold),
but all fonts should have the class Font.
Thus, changing all fonts simply requires only a single line in the
default resource file:
</para>
-<literallayout>
+<programlisting>
*Font: 6x13
-</literallayout>
+</programlisting>
<para>
By convention,
resource classes are always spelled starting with a capital letter
@@ -641,20 +641,20 @@ see <xref linkend='Obtaining_Widget_State' /> and
<para>
Here is an abbreviated version of a possible resource list for a Label widget:
</para>
-<literallayout>
-<code>/* Resources specific to Label */</code>
-<code>static XtResource resources[] = {</code>
-<code>{XtNforeground, XtCForeground, XtRPixel, sizeof(Pixel),</code>
-<code> XtOffsetOf(LabelRec, label.foreground), XtRString, XtDefaultForeground},</code>
-<code>{XtNfont, XtCFont, XtRFontStruct, sizeof(XFontStruct*),</code>
-<code> XtOffsetOf(LabelRec, label.font), XtRString, XtDefaultFont},</code>
-<code>{XtNlabel, XtCLabel, XtRString, sizeof(String),</code>
-<code> XtOffsetOf(LabelRec, label.label), XtRString, NULL},</code>
-<code> .</code>
-<code> .</code>
-<code> .</code>
-<code>}</code>
-</literallayout>
+<programlisting>
+/* Resources specific to Label */
+static XtResource resources[] = {
+{XtNforeground, XtCForeground, XtRPixel, sizeof(Pixel),
+ XtOffsetOf(LabelRec, label.foreground), XtRString, XtDefaultForeground},
+{XtNfont, XtCFont, XtRFontStruct, sizeof(XFontStruct*),
+ XtOffsetOf(LabelRec, label.font), XtRString, XtDefaultFont},
+{XtNlabel, XtCLabel, XtRString, sizeof(String),
+ XtOffsetOf(LabelRec, label.label), XtRString, NULL},
+ .
+ .
+ .
+}
+</programlisting>
<para>
The complete resource name for a field of a widget instance is the
concatenation of the application shell name (from
@@ -1759,12 +1759,12 @@ see <olink targetdoc='libX11' targetptr='Creating_and_Storing_Databases'>Section
<olink targetdoc='libX11' targetptr='libX11'>Xlib &mdash; C Language X Interface.</olink>)
for input and output values.
</para>
-<literallayout>
-<code>typedef struct {</code>
-<code> unsigned int size;</code>
-<code> XPointer addr;</code>
-<code>} XrmValue, *XrmValuePtr;</code>
-</literallayout>
+<programlisting>
+typedef struct {
+ unsigned int size;
+ XPointer addr;
+} XrmValue, *XrmValuePtr;
+</programlisting>
<para>
The <emphasis remap='I'>addr</emphasis> field specifies the address of the data, and the <emphasis remap='I'>size</emphasis>
field gives the total number of significant bytes in the data.
@@ -1942,72 +1942,72 @@ still required to inform the Intrinsics that the converted value is
a function of the particular display (and colormap).
</para>
-<literallayout>
-<code>#define done(type, value) \\</code>
-<code> { \\</code>
-<code> if (toVal-&gt;addr != NULL) { \\</code>
-<code> if (toVal-&gt;size &lt; sizeof(type)) { \\</code>
-<code> toVal-&gt;size = sizeof(type); \\</code>
-<code> return False; \\</code>
-<code> } \\</code>
-<code> *(type*)(toVal-&gt;addr) = (value); \\</code>
-<code> } \\</code>
-<code> else { \\</code>
-<code> static type static_val; \\</code>
-<code> static_val = (value); \\</code>
-<code> toVal-&gt;addr = (XPointer)&amp;static_val; \\</code>
-<code> } \\</code>
-<code> toVal-&gt;size = sizeof(type); \\</code>
-<code> return True; \\</code>
-<code> }</code>
-
-<code>static Boolean CvtStringToPixel(</code>
-<code> Display *dpy,</code>
-<code> XrmValue *args,</code>
-<code> Cardinal *num_args,</code>
-<code> XrmValue *fromVal,</code>
-<code> XrmValue *toVal,</code>
-<code> XtPointer *converter_data)</code>
-<code>{</code>
-<code> static XColor screenColor;</code>
-<code> XColor exactColor;</code>
-<code> Screen *screen;</code>
-<code> Colormap colormap;</code>
-<code> Status status;</code>
-
-<code> if (*num_args != 2)</code>
-<code> XtAppWarningMsg(XtDisplayToApplicationContext(dpy),</code>
-<code> "wrongParameters", "cvtStringToPixel", "XtToolkitError",</code>
-<code> "String to pixel conversion needs screen and colormap arguments",</code>
-<code> (String *)NULL, (Cardinal *)NULL);</code>
-<code> screen = *((Screen**) args[0].addr);</code>
-<code> colormap = *((Colormap *) args[1].addr);</code>
-<code> if (CompareISOLatin1(str, XtDefaultBackground) == 0) {</code>
-<code> *closure_ret = False;</code>
-<code> done(Pixel, WhitePixelOfScreen(screen));</code>
-<code> }</code>
-<code> if (CompareISOLatin1(str, XtDefaultForeground) == 0) {</code>
-<code> *closure_ret = False;</code>
-<code> done(Pixel, BlackPixelOfScreen(screen));</code>
-<code> }</code>
-<code> status = XAllocNamedColor(DisplayOfScreen(screen), colormap, (char*)fromVal-&gt;addr,</code>
-<code> &amp;screenColor, &amp;exactColor);</code>
-<code> if (status == 0) {</code>
-<code> String params[1];</code>
-<code> Cardinal num_params = 1;</code>
-<code> params[0] = (String)fromVal-&gt;addr;</code>
-<code> XtAppWarningMsg(XtDisplayToApplicationContext(dpy),</code>
-<code> "noColormap", "cvtStringToPixel", "XtToolkitError",</code>
-<code> "Cannot allocate colormap entry for \\"%s\\"",</code>
-<code> params, &amp;num_params);</code>
-<code> *converter_data = (char *) False;</code>
-<code> return False;</code>
-<code> } else {</code>
-<code> *converter_data = (char *) True;</code>
-<code> done(Pixel, &amp;screenColor.pixel);</code>
-<code> }</code>
-<code>}</code>
-</literallayout>
+<programlisting>
+#define done(type, value) \\
+ { \\
+ if (toVal-&gt;addr != NULL) { \\
+ if (toVal-&gt;size &lt; sizeof(type)) { \\
+ toVal-&gt;size = sizeof(type); \\
+ return False; \\
+ } \\
+ *(type*)(toVal-&gt;addr) = (value); \\
+ } \\
+ else { \\
+ static type static_val; \\
+ static_val = (value); \\
+ toVal-&gt;addr = (XPointer)&amp;static_val; \\
+ } \\
+ toVal-&gt;size = sizeof(type); \\
+ return True; \\
+ }
+
+static Boolean CvtStringToPixel(
+ Display *dpy,
+ XrmValue *args,
+ Cardinal *num_args,
+ XrmValue *fromVal,
+ XrmValue *toVal,
+ XtPointer *converter_data)
+{
+ static XColor screenColor;
+ XColor exactColor;
+ Screen *screen;
+ Colormap colormap;
+ Status status;
+
+ if (*num_args != 2)
+ XtAppWarningMsg(XtDisplayToApplicationContext(dpy),
+ "wrongParameters", "cvtStringToPixel", "XtToolkitError",
+ "String to pixel conversion needs screen and colormap arguments",
+ (String *)NULL, (Cardinal *)NULL);
+ screen = *((Screen**) args[0].addr);
+ colormap = *((Colormap *) args[1].addr);
+ if (CompareISOLatin1(str, XtDefaultBackground) == 0) {
+ *closure_ret = False;
+ done(Pixel, WhitePixelOfScreen(screen));
+ }
+ if (CompareISOLatin1(str, XtDefaultForeground) == 0) {
+ *closure_ret = False;
+ done(Pixel, BlackPixelOfScreen(screen));
+ }
+ status = XAllocNamedColor(DisplayOfScreen(screen), colormap, (char*)fromVal-&gt;addr,
+ &amp;screenColor, &amp;exactColor);
+ if (status == 0) {
+ String params[1];
+ Cardinal num_params = 1;
+ params[0] = (String)fromVal-&gt;addr;
+ XtAppWarningMsg(XtDisplayToApplicationContext(dpy),
+ "noColormap", "cvtStringToPixel", "XtToolkitError",
+ "Cannot allocate colormap entry for \\"%s\\"",
+ params, &amp;num_params);
+ *converter_data = (char *) False;
+ return False;
+ } else {
+ *converter_data = (char *) True;
+ done(Pixel, &amp;screenColor.pixel);
+ }
+}
+</programlisting>
<para>
All type converters should define some set of conversion values for which they
@@ -2221,9 +2221,9 @@ calls to the converter. Conversion cache control is specified
via an <function>XtCacheType</function>
argument. </para>
-<literallayout>
-<code>typedef int XtCacheType;</code>
-</literallayout>
+<programlisting>
+typedef int XtCacheType;
+</programlisting>
<para>
An <function>XtCacheType</function>
@@ -2513,24 +2513,24 @@ specify how each argument is derived.
These are defined in
<function>&lt;X11/Intrinsic.h&gt;</function>.
</para>
-<literallayout>
-<code>typedef enum {</code>
-<code> /* address mode parameter representation */</code>
-<code> XtAddress, /* address */</code>
-<code> XtBaseOffset, /* offset */</code>
-<code> XtImmediate, /* constant */</code>
-<code> XtResourceString, /* resource name string */</code>
-<code> XtResourceQuark, /* resource name quark */</code>
-<code> XtWidgetBaseOffset, /* offset */</code>
-<code> XtProcedureArg /* procedure to call */</code>
-<code>} XtAddressMode;</code>
-
-<code>typedef struct {</code>
-<code> XtAddressMode address_mode;</code>
-<code> XtPointer address_id;</code>
-<code> Cardinal size;</code>
-<code>} XtConvertArgRec, *XtConvertArgList;</code>
-</literallayout>
+<programlisting>
+typedef enum {
+ /* address mode parameter representation */
+ XtAddress, /* address */
+ XtBaseOffset, /* offset */
+ XtImmediate, /* constant */
+ XtResourceString, /* resource name string */
+ XtResourceQuark, /* resource name quark */
+ XtWidgetBaseOffset, /* offset */
+ XtProcedureArg /* procedure to call */
+} XtAddressMode;
+
+typedef struct {
+ XtAddressMode address_mode;
+ XtPointer address_id;
+ Cardinal size;
+} XtConvertArgRec, *XtConvertArgList;
+</programlisting>
<para>
The <emphasis remap='I'>size</emphasis> field specifies the length of the data in bytes.
The <emphasis remap='I'>address_mode</emphasis> field specifies how the <emphasis remap='I'>address_id</emphasis> field should be
@@ -2659,9 +2659,9 @@ To invoke explicit resource conversions, use
or
<xref linkend='XtCallConverter' xrefstyle='select: title'/>.
</para>
-<literallayout>
-<code>typedef XtPointer XtCacheRef;</code>
-</literallayout>
+<programlisting>
+typedef XtPointer XtCacheRef;
+</programlisting>
<funcsynopsis id='XtCallConverter'>
<funcprototype>