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
/
fonts.c
< prev
next >
Wrap
C/C++ Source or Header
|
1992-08-19
|
3KB
|
99 lines
/**---------------------------------------------------------------------
***
*** file: fonts.c
***
*** project: Motif Widgets example programs
***
*** description: This program creates a PushButton widget and
*** shows how fonts can be set programmatically.
***
***-------------------------------------------------------------------*/
/* include files */
#include <stdio.h>
#include <Xm/PushB.h>
#include <Xm/BulletinB.h>
/* functions defined in this program */
void main();
void activateCB(); /* Callback for the PushButton */
/* global variables */
XmString s1;
XmFontList fontlist1;
/*-------------------------------------------------------------
** main - main logic for demo1 program
*/
void main (argc,argv)
unsigned int argc;
char **argv;
{
Widget toplevel; /* Shell widget */
Widget bboard; /* BulletinBoard widget */
Widget button; /* PushButton widget */
Arg args[10]; /* arg list */
register int n; /* arg count */
XFontStruct *font1;
char *word1="Push Me";
Display *dpy;
XtAppContext app_context;
/* initialize toolkit */
toplevel = XtAppInitialize (&app_context, "Fonts", NULL, 0, &argc, argv,
NULL, args, 0);
/* Create a BulletinBoard widget to place the pushbutton in */
n = 0;
bboard = XmCreateBulletinBoard (toplevel, "bboard", args, n);
/* Manage the BulletinBoard widget */
XtManageChild (bboard);
/* Get the display ID and set up the font */
dpy=XtDisplay(toplevel);
font1 = XLoadQueryFont(dpy,"courB14");
fontlist1 = XmFontListCreate(font1,"chset1");
/* Create a compound string for the label */
s1=XmStringCreateLtoR(word1,"chset1");
/* Set up arglist */
n = 0;
XtSetArg(args[n], XmNlabelString, s1); n++;
XtSetArg(args[n], XmNfontList, fontlist1); n++;
/* Create button */
button = XtCreateManagedWidget ("button", xmPushButtonWidgetClass,
bboard, args, n);
/* Add callback */
XtAddCallback (button, XmNactivateCallback, activateCB, NULL);
/* Realize widgets */
XtRealizeWidget (toplevel);
/* Process events */
XtAppMainLoop (app_context);
}
/*-------------------------------------------------------------
** activateCB - callback for button
*/
void activateCB (w, client_data, call_data)
Widget w; /* widget id */
XtPointer client_data; /* data from application */
XtPointer call_data; /* data from widget class */
{
/* print message, free compound string memory, and terminate program */
printf ("PushButton selected.\n");
XmFontListFree(fontlist1);
XmStringFree(s1);
exit (0);
}