home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The World of Computer Software
/
World_Of_Computer_Software-02-385-Vol-1of3.iso
/
m
/
master12.zip
/
mastering
/
compstr.c
< prev
next >
Wrap
C/C++ Source or Header
|
1992-08-18
|
2KB
|
84 lines
#include <Xm/BulletinB.h>
#include <Xm/Label.h>
/* Global Variables */
Display *display;
void main(argc, argv)
int argc;
char **argv;
{
Widget toplevel;
Widget BBoard1;
Widget Label1;
Arg args[20];
int n;
XFontStruct *font1, *font2, *font3;
XmFontList fontlist1;
Display *display;
XtAppContext app_context;
XmString part1, part2, part3, parts12, whole;
/* initialize toolkit */
toplevel = XtAppInitialize(&app_context, "Compstr", NULL, 0, &argc,
argv, NULL, args,
0);
/* Create bulletin board widget */
n = 0;
BBoard1 = XmCreateBulletinBoard(toplevel, "BBoard1", args, n);
XtManageChild(BBoard1);
/* Create the compound strings and set up font and fontlist */
font1 = XLoadQueryFont(XtDisplay(toplevel),"vgi-20");
if (!font1)
printf ("Unable to load font vgi-20");
else
{
fontlist1 = XmFontListCreate(font1, "chset1");
part1 = XmStringCreateLtoR("How Now ", "chset1");
}
font2 = XLoadQueryFont(XtDisplay(toplevel), "iso1.20");
if (!font2)
printf ("Unable to load font iso1.16b");
else
{
fontlist1 = XmFontListAdd(fontlist1, font2, "chset2");
part2 = XmStringCreateLtoR("Brown ", "chset2");
}
font3 = XLoadQueryFont(XtDisplay(toplevel),"iso1.20b");
if (!font3)
printf ("Unable to load font iso1.16");
else
{
fontlist1 = XmFontListAdd(fontlist1, font3, "chset3");
part3 = XmStringCreateLtoR("Cow", "chset3");
}
/* Combine the compound strings into one */
parts12 = XmStringConcat (part1, part2);
whole = XmStringConcat (parts12, part3);
/* Create the Label widget */
n = 0;
XtSetArg (args[n], XmNfontList, fontlist1); n++;
XtSetArg (args[n], XmNlabelString, whole); n++;
XtSetArg (args[n], XmNx, 10); n++;
XtSetArg (args[n], XmNy, 10); n++;
Label1 = XmCreateLabel(BBoard1, "Label1", args, n);
XtManageChild(Label1);
/* Free the memory used by the compound string parts */
XmStringFree (part1);
XmStringFree (part2);
XmStringFree (part3);
XmStringFree (parts12);
XmStringFree (whole);
XmFontListFree (fontlist1);
/* Realize widgets and loop */
XtRealizeWidget(toplevel);
XtAppMainLoop(app_context);
}