summaryrefslogtreecommitdiff
path: root/specs/CH09.xml
diff options
context:
space:
mode:
Diffstat (limited to 'specs/CH09.xml')
-rw-r--r--specs/CH09.xml164
1 files changed, 83 insertions, 81 deletions
diff --git a/specs/CH09.xml b/specs/CH09.xml
index 913e734..12229b5 100644
--- a/specs/CH09.xml
+++ b/specs/CH09.xml
@@ -45,13 +45,13 @@ structure is
</para>
<literallayout >
typedef struct {
- String resource_name;
- String resource_class;
- String resource_type;
- Cardinal resource_size;
- Cardinal resource_offset;
- String default_type;
- XtPointer default_addr;
+ String resource_name;
+ String resource_class;
+ String resource_type;
+ Cardinal resource_size;
+ Cardinal resource_offset;
+ String default_type;
+ XtPointer default_addr;
} XtResource, *XtResourceList;
</literallayout>
<para>
@@ -128,8 +128,8 @@ Then, the resource file needs only two lines to
change all pixels to ivory or darkblue:
</para>
<literallayout >
-*Background: ivory
-*Foreground: darkblue
+*Background: ivory
+*Foreground: darkblue
</literallayout>
<para>
Similarly, a widget may have several font resources (such as normal and bold),
@@ -138,7 +138,7 @@ Thus, changing all fonts simply requires only a single line in the
default resource file:
</para>
<literallayout >
-*Font: 6x13
+*Font: 6x13
</literallayout>
<para>
By convention,
@@ -647,9 +647,9 @@ static XtResource resources[] = {
XtOffsetOf(LabelRec, label.font), XtRString, XtDefaultFont},
{XtNlabel, XtCLabel, XtRString, sizeof(String),
XtOffsetOf(LabelRec, label.label), XtRString, NULL},
- .
- .
- .
+ .
+ .
+ .
}
</literallayout>
<para>
@@ -1941,66 +1941,68 @@ a function of the particular display (and colormap).
<literallayout >
#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(dpy, args, num_args, fromVal, toVal, converter_data)
- Display *dpy;
- XrmValue *args;
- Cardinal *num_args;
- XrmValue *fromVal;
- XrmValue *toVal;
- XtPointer *converter_data;
+ { \\
+ 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;
+ 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 {
+ } else {
*converter_data = (char *) True;
- done(Pixel, &amp;screenColor.pixel);
- }
+ done(Pixel, &amp;screenColor.pixel);
+ }
}
</literallayout>
@@ -2510,20 +2512,20 @@ These are defined in
</para>
<literallayout >
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 */
+ /* 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;
+ XtAddressMode address_mode;
+ XtPointer address_id;
+ Cardinal size;
} XtConvertArgRec, *XtConvertArgList;
</literallayout>
<para>