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 >
C/C++ Source or Header  |  1992-08-18  |  2KB  |  84 lines

  1. #include <Xm/BulletinB.h>
  2. #include <Xm/Label.h>
  3.  
  4. /*  Global Variables  */
  5. Display  *display;
  6.  
  7. void main(argc, argv)
  8. int argc;
  9. char **argv;
  10. {
  11.   Widget      toplevel;
  12.   Widget BBoard1;
  13.   Widget Label1;
  14.   Arg args[20];
  15.   int n;
  16.   XFontStruct *font1, *font2, *font3;
  17.   XmFontList fontlist1;
  18.   Display    *display;
  19.   XtAppContext  app_context;
  20.   XmString part1, part2, part3, parts12, whole;
  21.  
  22.   /* initialize toolkit */
  23.   toplevel = XtAppInitialize(&app_context, "Compstr", NULL, 0, &argc,
  24.                              argv, NULL, args,
  25.   0);
  26.  
  27.   /* Create bulletin board widget */
  28.   n = 0;
  29.   BBoard1 = XmCreateBulletinBoard(toplevel, "BBoard1", args, n);
  30.   XtManageChild(BBoard1);
  31.  
  32.   /* Create the compound strings and set up font and fontlist */
  33.   font1 = XLoadQueryFont(XtDisplay(toplevel),"vgi-20");
  34.   if (!font1)
  35.     printf ("Unable to load font vgi-20");
  36.   else
  37.   {
  38.     fontlist1 = XmFontListCreate(font1, "chset1");
  39.     part1 = XmStringCreateLtoR("How Now ", "chset1");
  40.   }
  41.  
  42.   font2 = XLoadQueryFont(XtDisplay(toplevel), "iso1.20");
  43.   if  (!font2)
  44.     printf ("Unable to load font iso1.16b");
  45.   else
  46.   {
  47.   fontlist1 = XmFontListAdd(fontlist1, font2, "chset2");
  48.   part2 = XmStringCreateLtoR("Brown ", "chset2");
  49.   }
  50.   font3 = XLoadQueryFont(XtDisplay(toplevel),"iso1.20b");
  51.   if  (!font3)
  52.     printf ("Unable to load font iso1.16");
  53.   else
  54.   {
  55.   fontlist1 = XmFontListAdd(fontlist1, font3, "chset3");
  56.   part3 = XmStringCreateLtoR("Cow", "chset3");
  57.   }
  58.  
  59.   /* Combine the compound strings into one */
  60.   parts12 = XmStringConcat (part1, part2);
  61.   whole = XmStringConcat (parts12, part3);
  62.  
  63.   /* Create the Label widget */
  64.   n = 0;
  65.   XtSetArg (args[n], XmNfontList, fontlist1); n++;
  66.   XtSetArg (args[n], XmNlabelString, whole); n++;
  67.   XtSetArg (args[n], XmNx, 10); n++;
  68.   XtSetArg (args[n], XmNy, 10); n++;
  69.   Label1 = XmCreateLabel(BBoard1, "Label1", args, n);
  70.   XtManageChild(Label1);
  71.  
  72.   /* Free the memory used by the compound string parts */
  73.   XmStringFree (part1);
  74.   XmStringFree (part2);
  75.   XmStringFree (part3);
  76.   XmStringFree (parts12);
  77.   XmStringFree (whole);
  78.   XmFontListFree (fontlist1); 
  79.  
  80.   /* Realize widgets and loop */
  81.   XtRealizeWidget(toplevel);
  82.   XtAppMainLoop(app_context);
  83. }
  84.