home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Usenet 1994 October
/
usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso
/
x
/
volume10
/
xchrom
/
part01
/
xchrom.c
< prev
next >
Wrap
C/C++ Source or Header
|
1990-12-07
|
3KB
|
118 lines
/*
* xchrom.c - program which uses the Xchrom widget.
* Copyright (c) Olaf Heimburger 1990
* Last edited: Tue Nov 6 10:58:40 1990 by olafh (Olaf Heimburger) on GECKO
*/
#include <stdio.h>
#include <X11/Intrinsic.h>
#include <X11/Shell.h>
#include "Xchrom.h"
#include "xchrom.xbm"
#include "xchrom_mask.xbm"
#include "patchlevel.h"
#ifdef ICCCM_COMP
#include <X11/Xmu/Atoms.h>
#endif
#define ever (;;)
#define NAME "CHROMACHRON"
static char *version = "version 1";
static XrmOptionDescRec opTable[] = {
{"-startoffset", ".Xchrom.startOffset", XrmoptionSepArg, (caddr_t)NULL},
{"-maskoffset", ".Xchrom.maskOffset", XrmoptionSepArg, (caddr_t)NULL},
{"-timeoffset", ".Xchrom.timeOffset", XrmoptionSepArg, (caddr_t)NULL},
};
main (argc, argv)
int argc;
char *argv[];
{
Widget topLevel, clockW;
Arg args[2];
Pixmap iconPixmap = None, iconMaskPixmap = None;
char *defTitle = NULL, *defIconName = NULL;
int i;
#ifdef ICCCM_COMP
Atom wmDeleteWindow;
XEvent event;
#endif
topLevel = XtInitialize (argv[0], "XChrom", opTable, XtNumber (opTable),
&argc, argv);
for (i = 1; i < argc; ++i) {
if (strcmp (argv[i], "-v") == 0) {
printf ("%s, %s.%d \n", argv[0], version, PATCHLEVEL);
}
}
/*
* check title and icon name and set default name, if necessary
*/
XtSetArg (args[0], XtNtitle, &defTitle);
XtSetArg (args[1], XtNiconName, &defIconName);
XtGetValues (topLevel, args, XtNumber (args));
if (strcmp (argv[0], defTitle) == 0) {
XtSetArg (args[0], XtNtitle, NAME);
XtSetValues (topLevel, &args[0], 1);
}
if (strcmp (argv[0], defIconName) == 0) {
XtSetArg (args[0], XtNiconName, NAME);
XtSetValues (topLevel, &args[0], 1);
}
/*
* set minimum width and height
*/
XtSetArg (args[0], XtNminWidth, MINWIDTH);
XtSetArg (args[1], XtNminHeight, MINHEIGHT);
XtSetValues (topLevel, args, XtNumber (args));
clockW = XtCreateManagedWidget (argv[0], xchromWidgetClass, topLevel,
NULL, 0);
/*
* set the icon and icon mask bits
*/
XtSetArg (args[0], XtNiconPixmap, &iconPixmap);
XtSetArg (args[1], XtNiconMask, &iconMaskPixmap);
XtGetValues (topLevel, args, XtNumber (args));
if (iconPixmap == None) {
args[0].value =
(XtArgVal) XCreateBitmapFromData (XtDisplay (topLevel),
(XtScreen (topLevel))->root,
xchrom_bits, xchrom_width,
xchrom_height);
XtSetValues (topLevel, &args[0], 1);
}
if (iconMaskPixmap == None) {
args[1].value =
(XtArgVal) XCreateBitmapFromData (XtDisplay (topLevel),
(XtScreen (topLevel))->root,
xchrom_mask_bits,
xchrom_mask_width,
xchrom_mask_height);
XtSetValues (topLevel, &args[1], 1);
}
XtRealizeWidget (topLevel);
#ifdef ICCCM_COMP
/*
* for ICCCM compatibilty
*/
wmDeleteWindow =
XmuInternAtom (XtDisplay (topLevel), XmuMakeAtom ("WM_DELETE_WINDOW"));
(void) XSetWMProtocols (XtDisplay (topLevel), XtWindow (topLevel),
&wmDeleteWindow, 1);
for ever {
XtNextEvent (&event);
if (event.type == ClientMessage
&& event.xclient.data.l[0] == wmDeleteWindow) {
XtDestroyWidget (topLevel);
exit(1);
} else {
XtDispatchEvent (&event);
}
}
#else
XtMainLoop ();
#endif
}