home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / World_Of_Computer_Software-02-385-Vol-1of3.iso / m / motifpg2.zip / ch10 / xpixmap.c < prev   
C/C++ Source or Header  |  1992-07-09  |  2KB  |  94 lines

  1. /*
  2.  * Copyright 1989, 1992 O'Reilly and Associates, Inc.
  3.  * See ../Copyright for complete rights and liability information.
  4.  */
  5.  
  6.  
  7. /*
  8.  * xpixmap.c - simple program to test invoking a converter directly
  9.  */
  10.  
  11. #include <X11/IntrinsicP.h>    /* temporary, until we find out how
  12.                  * to register a type converter without
  13.                  * referencing the core structure */
  14.  
  15. /*
  16.  * Include files required for all Toolkit programs
  17.  */
  18. #include <X11/Intrinsic.h>    /* Intrinsics Definitions */
  19. #include <X11/StringDefs.h>    /* Standard Name-String definitions */
  20.  
  21. /*
  22.  * Public include file for widgets we actually use in this file.
  23.  */
  24. #include <Xm/Label.h>        /* Motif Label Widget */
  25.  
  26. /*
  27.  * Include file for Xmu converters
  28.  */
  29. #include <X11/Xmu/Converters.h>
  30.  
  31. #define OURPIXMAPNAME "xlogo64"
  32.  
  33. main(argc, argv)
  34. int argc;
  35. char **argv;
  36. {
  37.     XtAppContext app_context;
  38.     Widget topLevel, hello;
  39.     XrmValue from, to;
  40.     Pixmap pixmap;
  41.     void XmuCvtStringToBitmap();
  42.     Boolean success;
  43.  
  44.     static XtConvertArgRec screenConvertArg[] = {
  45.       {
  46.     XtBaseOffset, 
  47.     (XtPointer) XtOffset(Widget, core.screen), 
  48.     sizeof(Screen *)
  49.     }
  50.     };
  51.     
  52.     XtSetLanguageProc(NULL, (XtLanguageProc)NULL, NULL);
  53.  
  54.     topLevel = XtVaAppInitialize(
  55.         &app_context,       /* Application context */
  56.         "XHello",           /* Application class */
  57.         NULL, 0,            /* command line option list */
  58.         &argc, argv,        /* command line args */
  59.         NULL,               /* for missing app-defaults file */
  60.         NULL);              /* terminate varargs list */
  61.  
  62.     XtAppAddConverter(app_context, XmRString, XmRBitmap, XmuCvtStringToBitmap,
  63.               screenConvertArg, XtNumber(screenConvertArg));
  64.  
  65.     from.addr = OURPIXMAPNAME;
  66.     from.size = strlen(OURPIXMAPNAME);
  67.  
  68.     success = XtConvertAndStore(topLevel, XmRString, &from, XmRBitmap, &to);
  69.  
  70.     if (!success)
  71.       exit(1);
  72.     
  73.     pixmap = *(Pixmap *) to.addr;
  74.  
  75.  
  76.     hello = XtVaCreateManagedWidget(
  77.     "hello",        /* arbitrary widget name */
  78.     xmLabelWidgetClass,    /* widget class from Label.h */
  79.     topLevel,        /* parent widget*/
  80.     XmNlabelType, XmPIXMAP,
  81.         XmNlabelPixmap, pixmap,
  82.     NULL);
  83.  
  84.     /*
  85.      *  Create windows for widgets and map them.
  86.      */
  87.     XtRealizeWidget(topLevel);
  88.     
  89.     /*
  90.      *  Loop for events.
  91.      */
  92.     XtAppMainLoop(app_context);
  93. }
  94.