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 / seldlog.c < prev    next >
C/C++ Source or Header  |  1992-08-25  |  4KB  |  122 lines

  1.  
  2. /*  include files  */
  3.  
  4. #include <stdio.h>
  5. #include <Xm/PushB.h>
  6. #include <Xm/BulletinB.h>
  7. #include <Xm/SelectioB.h>
  8. #include <Xm/PushB.h>
  9.  
  10. /*  Functions defined in this program  */
  11.  
  12. void main();
  13. void activateCB(); /* Callback for the pushbutton */
  14.  
  15. /*  Global variables  */
  16.  
  17. Widget    toplevel;    /*  Shell widget         */
  18.  
  19.  
  20. /*-------------------------------------------------------------
  21. **  main - Main logic for seldlog
  22. */
  23. void main (argc,argv)
  24. unsigned int argc;
  25. char **argv;
  26. {
  27.   Widget       bboard;      /*  Bulletin board widget */
  28.   Widget       button;      /*  Pushbutton widget    */
  29.   Arg          args[10];    /*  arg list             */
  30.   register     int n;       /*  arg count            */
  31.   XtAppContext app_context; /*  application context  */
  32.   XmString  btn_text;       /* button label pointer for compound string */
  33.  
  34. /*  Initialize the toolkit, create application context, open display, 
  35.     and create a toplevel shell */
  36.   toplevel = XtAppInitialize (&app_context, "Seldlog", NULL, 0, &argc,
  37.                               argv, NULL, args, 0);
  38.  
  39. /*  Create a bulletin board widget in which to place the pushbutton */
  40.   n = 0;
  41.   bboard = XmCreateBulletinBoard (toplevel, "bboard", args, n);
  42.  
  43. /*  Manage the bulletin board widget */
  44.   XtManageChild (bboard);
  45.  
  46. /*  Create a compound string for the button text  */
  47.   btn_text = XmStringCreateLtoR("Create Selection Dialog", XmFONTLIST_DEFAULT_TAG);
  48.  
  49. /*  Set up an arglist for the pushbutton */
  50.   n = 0;
  51.   XtSetArg (args[n], XmNlabelString, btn_text);  n++;
  52.  
  53. /*  Create the push button */
  54.   button = XtCreateManagedWidget ("button", xmPushButtonWidgetClass, bboard,
  55.   args, n); 
  56.  
  57. /*  Free the compound string memory */
  58.   XmStringFree (btn_text);
  59.  
  60. /*  Add a callback  */
  61.   XtAddCallback (button, XmNactivateCallback, activateCB, NULL);
  62.  
  63. /*  Realize widgets  */
  64.   XtRealizeWidget (toplevel);
  65.  
  66. /*  Process events  */
  67.   XtAppMainLoop (app_context);
  68. }
  69.  
  70.  
  71. /*-------------------------------------------------------------
  72. **  activateCB - callback for button
  73. */
  74. void activateCB (w, client_data, call_data) 
  75.   Widget   w;            /*  widget id              */
  76.   XtPointer   client_data;  /*  data from application  */
  77.   XtPointer   call_data;    /*  data from widget class */
  78. {
  79.   Arg          args[10];     /*  arg list             */
  80.   register     int n;        /*  arg count            */
  81.   Widget       sdlog;        /*  selection dialog     */
  82.   Widget       xtra_button1; /*  extra button         */
  83.   Widget       xtra_button2; /*  extra button         */
  84.  
  85.   static char         *char_list_items[7] = {
  86.     "XmDialogShell",
  87.     "XmBulletinBoard",
  88.     "XmCommand",
  89.     "XmFileSelectionBox",
  90.     "XmForm",
  91.     "XmMessageBox",
  92.     "XmSelectionBox"};
  93.   XmString     cstring_list_items[7];
  94.  
  95. /* Create the array of compound strings from the character array. */
  96.   for (n = 0; n < 7; n++)
  97.     cstring_list_items[n] = (XmString) XmStringCreateLtoR(char_list_items[n],
  98.         XmFONTLIST_DEFAULT_TAG);
  99.  
  100. /*  Create the file selection box */
  101.   n = 0;
  102.   XtSetArg(args[n], XmNlistItems, cstring_list_items); n++;
  103.   XtSetArg(args[n], XmNlistItemCount, 7); n++;
  104.   sdlog = XmCreateSelectionDialog (toplevel, "sdlog", args, n); 
  105.   
  106. /*  Manage the selectionbox widget */
  107.   XtManageChild (sdlog);
  108.  
  109. /* Add the extra pushbuttons.  We need two: the first is
  110.    the work area widget (which we'll leave unmanaged), and the
  111.    second is the "real" pushbutton. 
  112.   n = 0;
  113.   xtra_button1 = XmCreatePushButton(sdlog, "xtra", args, n);
  114.  
  115.   n = 0;
  116.   xtra_button2 = XmCreatePushButton(sdlog, "xtra", args, n); */
  117.  
  118. /*  Manage only the second pushbutton; it appears next to OK 
  119.   XtManageChild(xtra_button2); */
  120. }
  121.  
  122.