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 >
Wrap
C/C++ Source or Header
|
1992-08-18
|
3KB
|
101 lines
#include <Xm/PushB.h>
#include <Xm/BulletinB.h>
#include "bitmaps/backgnd.nu"
#include "bitmaps/border.test"
Pixmap custompx, borderpx;
Widget toplevel;
static XtArgVal GetPixel(colorstr)
char *colorstr;
{
XrmValue from, to;
from.size = strlen(colorstr) +1;
if (from.size < sizeof(String)) from.size = sizeof(String);
from.addr = colorstr;
to.addr = NULL;
XtConvert(toplevel, XmRString, &from, XmRPixel, &to);
return ((XtArgVal) *((XtArgVal *) to.addr));
}
/***********************************************************************
*** MAIN ***
***********************************************************************/
void main(argc, argv)
unsigned int argc;
char **argv;
{
Widget bboard, pbutton;
Arg args[10];
int n;
char *text = "Push Me";
XmString label_text;
Display *display;
XtAppContext app_context;
/*
* Initialize the toplevel shell widget
*/
toplevel = XtAppInitialize(&app_context, "Customtile", NULL, 0, &argc, argv,
NULL, args, 0);
/*
* Get the display ID for the bitmap to pixmap conversion
*/
display = XtDisplay (toplevel);
custompx = XCreatePixmapFromBitmapData(display,
DefaultRootWindow(display),
backgnd_bits, backgnd_width, backgnd_height,
GetPixel("red"),
GetPixel("white"),
DefaultDepth(display,DefaultScreen(display)));
borderpx = XCreatePixmapFromBitmapData(display,
DefaultRootWindow(display),
border_bits, border_width, border_height,
GetPixel("light blue"),
GetPixel("midnight blue"),
DefaultDepth(display,DefaultScreen(display)));
/*
* Create the bulletin board Widget
*/
n = 0;
XtSetArg (args[n], XmNbackgroundPixmap, custompx); n++;
bboard = XmCreateBulletinBoard (toplevel, "bboard", args, n);
XtManageChild(bboard);
/*
* Set up compound string
*/
label_text = XmStringCreateLtoR(text, XmFONTLIST_DEFAULT_TAG);
/*
* Create the pushbutton.
*/
n = 0;
XtSetArg(args[n], XmNlabelString, label_text); n++;
XtSetArg (args[n], XmNborderPixmap, borderpx); n++;
XtSetArg (args[n], XmNborderWidth, 5); n++;
pbutton = XmCreatePushButton(bboard, "pbutton", args, n);
XtManageChild(pbutton);
/*
* Free the compound string memory
*/
XmStringFree(label_text);
/*
* Realize the toplevel widget, which displays all children
*/
XtRealizeWidget(toplevel);
/*
* Go into a loop and wait for input
*/
XtAppMainLoop(app_context);
}