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

  1. #include <Xm/ToggleB.h>
  2. #include <Xm/BulletinB.h>
  3.  
  4. Widget    toplevel;
  5.  
  6. static XtArgVal GetPixel(colorstr)
  7. char *colorstr;
  8. {
  9.    XrmValue from, to;
  10.  
  11.    from.size = strlen(colorstr) +1;
  12.    if (from.size < sizeof(String)) from.size = sizeof(String);
  13.    from.addr = colorstr;
  14.    to.addr = NULL;
  15.    XtConvert(toplevel, XmRString, &from, XmRPixel, &to);
  16.  
  17.    return ((XtArgVal) *((XtArgVal *) to.addr));
  18. }
  19.  
  20. /***********************************************************************
  21.  ***                             MAIN                                ***
  22.  ***********************************************************************/
  23. void main(argc, argv)
  24.   unsigned int argc;
  25.   char **argv;
  26. {
  27.    Widget bboard, tbutton;
  28.    Arg args[10];
  29.    int n;
  30.    char *text = "Push Me";
  31.    XmString label_text;
  32.    Pixel foregnd, backgnd;
  33.    XtAppContext app_context;
  34.      
  35. /*
  36.  * Initialize the toplevel shell widget
  37.  */
  38.    toplevel = XtAppInitialize(&app_context, "Tiling", NULL, 0, &argc, argv,
  39.    NULL, args, 0);
  40. /*
  41.  * Create the bulletin board widget
  42.  */
  43.  
  44.    foregnd = GetPixel ("light blue");
  45.    backgnd = GetPixel ("sky blue");
  46.    n = 0;
  47.    XtSetArg(args[n], XmNbackgroundPixmap, XmGetPixmap(XtScreen
  48.      (toplevel),"slant_right", foregnd, backgnd)); n++;
  49.    bboard = XmCreateBulletinBoard (toplevel, "bboard", args, n);
  50.    XtManageChild(bboard);
  51.  
  52. /*
  53.  * Set up compound string 
  54.  */
  55.    label_text = XmStringCreateLtoR(text, XmFONTLIST_DEFAULT_TAG);
  56.    
  57. /*
  58.  * Create the pushbutton.
  59.  */
  60.    foregnd = GetPixel ("light blue");
  61.    backgnd = GetPixel ("sky blue");
  62.    n = 0;
  63.    XtSetArg(args[n], XmNbackgroundPixmap, XmGetPixmap(XtScreen
  64.      (toplevel),"vertical", foregnd, backgnd)); n++;
  65.    XtSetArg(args[n], XmNlabelString, label_text); n++;
  66.    tbutton = XmCreateToggleButton(bboard, "tbutton", args, n);
  67.    XtManageChild(tbutton);
  68.    XmStringFree (label_text);
  69.  
  70. /*
  71.  * Realize the toplevel widget, which displays all children
  72.  */ 
  73.    XtRealizeWidget(toplevel);
  74.  
  75. /*
  76.  * Go into a loop and wait for input
  77.  */
  78.    XtAppMainLoop(app_context);
  79. }
  80.