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 / customtile.c < prev    next >
C/C++ Source or Header  |  1992-08-18  |  3KB  |  101 lines

  1. #include <Xm/PushB.h>
  2. #include <Xm/BulletinB.h>
  3. #include "bitmaps/backgnd.nu"
  4. #include "bitmaps/border.test"
  5.  
  6. Pixmap  custompx, borderpx;
  7. Widget  toplevel;
  8.  
  9. static XtArgVal GetPixel(colorstr)
  10. char *colorstr;
  11. {
  12.    XrmValue from, to;
  13.  
  14.    from.size = strlen(colorstr) +1;
  15.    if (from.size < sizeof(String)) from.size = sizeof(String);
  16.    from.addr = colorstr;
  17.    to.addr = NULL;
  18.    XtConvert(toplevel, XmRString, &from, XmRPixel, &to);
  19.  
  20.    return ((XtArgVal) *((XtArgVal *) to.addr));
  21. }
  22.  
  23. /***********************************************************************
  24.  ***                             MAIN                                ***
  25.  ***********************************************************************/
  26. void main(argc, argv)
  27.   unsigned      int argc;
  28.   char        **argv;
  29. {
  30.    Widget       bboard, pbutton;
  31.    Arg          args[10];
  32.    int          n;
  33.    char        *text = "Push Me";
  34.    XmString     label_text;
  35.    Display     *display;
  36.    XtAppContext app_context;
  37.      
  38. /*
  39.  * Initialize the toplevel shell widget
  40.  */
  41.    toplevel = XtAppInitialize(&app_context, "Customtile", NULL, 0, &argc, argv,
  42.                               NULL, args, 0);
  43.  
  44. /*
  45.  * Get the display ID for the bitmap to pixmap conversion
  46.  */
  47.   display = XtDisplay (toplevel);
  48.  
  49.   custompx = XCreatePixmapFromBitmapData(display, 
  50.       DefaultRootWindow(display),
  51.       backgnd_bits, backgnd_width, backgnd_height,
  52.       GetPixel("red"),
  53.       GetPixel("white"),
  54.       DefaultDepth(display,DefaultScreen(display)));
  55.  
  56.   borderpx = XCreatePixmapFromBitmapData(display, 
  57.       DefaultRootWindow(display),
  58.       border_bits, border_width, border_height,
  59.       GetPixel("light blue"),
  60.       GetPixel("midnight blue"),
  61.       DefaultDepth(display,DefaultScreen(display)));
  62.  
  63. /*
  64.  * Create the bulletin board Widget
  65.  */
  66.   n = 0;
  67.   XtSetArg (args[n], XmNbackgroundPixmap, custompx); n++;
  68.   bboard = XmCreateBulletinBoard (toplevel, "bboard", args, n);
  69.   XtManageChild(bboard);
  70.  
  71. /*
  72.  * Set up compound string 
  73.  */
  74.    label_text = XmStringCreateLtoR(text, XmFONTLIST_DEFAULT_TAG);
  75.    
  76. /*
  77.  * Create the pushbutton.
  78.  */
  79.    n = 0;
  80.    XtSetArg(args[n], XmNlabelString, label_text); n++;
  81.    XtSetArg (args[n], XmNborderPixmap, borderpx); n++;
  82.    XtSetArg (args[n], XmNborderWidth, 5); n++;
  83.    pbutton = XmCreatePushButton(bboard, "pbutton", args, n);
  84.    XtManageChild(pbutton);
  85.  
  86. /*
  87.  * Free the compound string memory
  88.  */
  89.    XmStringFree(label_text);
  90.  
  91. /*
  92.  * Realize the toplevel widget, which displays all children
  93.  */ 
  94.    XtRealizeWidget(toplevel);
  95.  
  96. /*
  97.  * Go into a loop and wait for input
  98.  */
  99.    XtAppMainLoop(app_context);
  100. }
  101.