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

  1. /*
  2.  * Copyright 1989, 1992 O'Reilly and Associates, Inc.
  3.  * See ../Copyright for complete rights and liability information.
  4.  */
  5.  
  6. /*
  7.  * xgetstring.c - simple program to put up a banner on the display
  8.  *                Demonstrates querying a compound string.
  9.  */
  10.  
  11. #include <stdio.h>
  12. /*
  13.  * Header files required for all Toolkit programs
  14.  */
  15. #include <X11/Intrinsic.h>     /* Intrinsics definitions */
  16. #include <Xm/Xm.h>    /* Standard Motif definitions */
  17.  
  18. /*
  19.  * Public header file for widgets we actually use in this file.
  20.  */
  21. #include <Xm/PushB.h>     /* Motif PushButton Widget */
  22.  
  23. main(argc, argv)
  24. int argc;
  25. char **argv;
  26. {
  27.     XtAppContext app_context;
  28.     Widget topLevel, hello;
  29.     String string;
  30.     XmString text;
  31.  
  32.     /*
  33.      * Register the default language procedure
  34.      */
  35.     XtSetLanguageProc(NULL, (XtLanguageProc)NULL, NULL);
  36.  
  37.     topLevel = XtVaAppInitialize(
  38.             &app_context,       /* Application context */
  39.             "XHello",         /* Application class */
  40.             NULL, 0,            /* command line option list */
  41.             &argc, argv,        /* command line args */
  42.             NULL,               /* for missing app-defaults file */
  43.             NULL);              /* terminate varargs list */
  44.  
  45.     hello = XtVaCreateManagedWidget(
  46.         "hello",            /* arbitrary widget name */
  47.          xmPushButtonWidgetClass,    /* widget class from PushButton.h */
  48.          topLevel,            /* parent widget */
  49.              NULL);                     /* terminate varargs list */
  50.  
  51.     XtVaGetValues(hello,
  52.           XmNlabelString, &text,
  53.           NULL);
  54.  
  55.     (void) XmStringGetLtoR(text, XmFONTLIST_DEFAULT_TAG, &string);
  56.     printf("The string set in the app-defaults file is: %s\n", string);
  57.     XtFree(string);
  58.     XmStringFree(text);
  59.  
  60.     /*
  61.      *  Create windows for widgets and map them.
  62.      */
  63.     XtRealizeWidget(topLevel);
  64.     
  65.     /*
  66.      *  Loop for events.
  67.      */
  68.     XtAppMainLoop(app_context);
  69.   }
  70.  
  71.