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 / scrolledtext.c < prev    next >
C/C++ Source or Header  |  1992-08-25  |  2KB  |  78 lines

  1. #include <Xm/BulletinB.h>
  2. #include <Xm/Label.h>
  3. #include <Xm/Text.h>
  4.  
  5. /*  Global Variables  */
  6. Display  *display;
  7.  
  8. char new_string1[] = "\
  9. As I was going to St. Ives\n\
  10. I met a man with seven wives\n\
  11. Each wife had seven sacks,\n\
  12. Each sack had seven cats,\n\
  13. Each cat had seven kits\n\
  14. Kits, cats, sacks, and wives,\n\
  15. How many were going to St. Ives?\n\
  16. \n\
  17. I don't know but...\n\
  18. Jack Sprat could eat no fat\n\
  19. His wife could eat no lean\n\
  20. And so between them both\n\
  21. They licked the platter clean";
  22.  
  23. void main(argc, argv)
  24. int argc;
  25. char **argv;
  26. {
  27.   Widget toplevel;
  28.   Widget BBoard1;
  29.   Widget Text1;
  30.   Widget Label1;
  31.   Arg args[10];
  32.   int n;
  33.   XFontStruct  *newfont;
  34.   XmFontList    newfontlist;
  35.   XmString      label_string;
  36.   Display      *display;
  37.   XtAppContext  app_context;
  38.  
  39.   /* Initialize toolkit */
  40.   toplevel = XtAppInitialize(&app_context, "Textdemo", NULL, 0, &argc, argv, NULL, args,
  41.   0);
  42.  
  43.   /* Create bulletin board widget */
  44.   n = 0;
  45.   XtSetArg (args[n], XmNallowShellResize, True); n++;
  46.   BBoard1 = XmCreateBulletinBoard(toplevel, "BBoard1", args, n);
  47.   XtManageChild(BBoard1);
  48.  
  49.   newfont = XLoadQueryFont(XtDisplay(toplevel),"8x13");
  50.   newfontlist = XmFontListCreate(newfont, XmFONTLIST_DEFAULT_TAG);
  51.  
  52.   /* Create a compound string for the label and the label */
  53.   label_string = XmStringCreate("Scrolled Text Widget", XmFONTLIST_DEFAULT_TAG);
  54.   n = 0;
  55.   XtSetArg(args[n], XmNlabelString, label_string); n++;
  56.   Label1 = XmCreateLabel(BBoard1, "Label1", args, n);
  57.   XtManageChild(Label1);
  58.   XmStringFree (label_string);
  59.  
  60.   /* Scrolled text widget */
  61.   n = 0;
  62.   XtSetArg(args[n], XmNy, 30); n++;
  63.   XtSetArg(args[n], XmNcolumns, 25); n++;
  64.   XtSetArg(args[n], XmNrows, 10); n++;
  65.   XtSetArg(args[n], XmNscrollVertical, True); n++;
  66.   XtSetArg(args[n], XmNscrollHorizontal, True); n++;
  67.   XtSetArg(args[n], XmNeditMode, XmMULTI_LINE_EDIT); n++;
  68.   XtSetArg(args[n], XmNvalue, new_string1); n++;
  69.   XtSetArg(args[n], XmNfontList, newfontlist); n++;
  70.   Text1 = XmCreateScrolledText(BBoard1, "Text1", args, n);
  71.   XtManageChild(Text1);
  72.   XmFontListFree (newfontlist);
  73.  
  74. /* Realize widgets and loop */
  75.   XtRealizeWidget(toplevel);
  76.   XtAppMainLoop(app_context);
  77. }
  78.