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 / textfield.c < prev    next >
C/C++ Source or Header  |  1992-08-27  |  2KB  |  74 lines

  1. #include <Xm/BulletinB.h>
  2. #include <Xm/Label.h>
  3. #include <Xm/TextF.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,
  41.                              argv, NULL, args, 0);
  42.   
  43.  
  44.   /* Create bulletin board widget */
  45.   n = 0;
  46.   XtSetArg (args[n], XmNallowShellResize, True); n++;
  47.   BBoard1 = XmCreateBulletinBoard(toplevel, "BBoard1", args, n);
  48.   XtManageChild(BBoard1);
  49.  
  50.   newfont = XLoadQueryFont(XtDisplay(toplevel),"8x13");
  51.   newfontlist = XmFontListCreate(newfont, XmFONTLIST_DEFAULT_TAG);
  52.  
  53.   /* Create a compound string for the label and the label itself */
  54.   label_string = XmStringCreate("Text Field Widget", XmFONTLIST_DEFAULT_TAG); 
  55.   n = 0;
  56.   XtSetArg(args[n], XmNlabelString,label_string); n++;
  57.   Label1 = XmCreateLabel(BBoard1, "Label1", args, n);
  58.   XtManageChild(Label1);
  59.   XmStringFree (label_string);
  60.  
  61.   /* Text field widget */
  62.   n = 0;
  63.   XtSetArg(args[n], XmNy, 30); n++;
  64.   XtSetArg(args[n], XmNcolumns, 25); n++;
  65.   XtSetArg(args[n], XmNvalue, new_string1); n++;
  66.   XtSetArg(args[n], XmNfontList, newfontlist); n++;
  67.   Text1 = (Widget) XmCreateTextField(BBoard1, "Text1", args, n);
  68.   XtManageChild(Text1);
  69.  
  70. /* Realize widgets and loop */
  71.   XtRealizeWidget(toplevel);
  72.   XtAppMainLoop(app_context);
  73. }
  74.