/* * @OPENGROUP_COPYRIGHT@ * COPYRIGHT NOTICE * Copyright (c) 1990, 1991, 1992, 1993 Open Software Foundation, Inc. * Copyright (c) 1996, 1997, 1998, 1999, 2000 The Open Group * ALL RIGHTS RESERVED (MOTIF). See the file named COPYRIGHT.MOTIF for * the full copyright text. * * This software is subject to an open license. It may only be * used on, with or for operating systems which are themselves open * source systems. You must contact The Open Group for a license * allowing distribution and sublicensing of this software on, with, * or for operating systems which are not Open Source programs. * * See http://www.opengroup.org/openmotif/license for full * details of the license agreement. Any use, reproduction, or * distribution of the program constitutes recipient's acceptance of * this agreement. * * EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM IS * PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY * WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY * OR FITNESS FOR A PARTICULAR PURPOSE * * EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER RECIPIENT * NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT, * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN * ANY WAY OUT OF THE USE OR DISTRIBUTION OF THE PROGRAM OR THE * EXERCISE OF ANY RIGHTS GRANTED HEREUNDER, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGES. */ /* * HISTORY */ #ifdef REV_INFO #ifndef lint static char rcsid[] = "$XConsortium: MessageDia1.c /main/8 1995/07/13 19:02:20 drk $" #endif #endif /* * (c) Copyright 1987, 1988, 1989 HEWLETT-PACKARD COMPANY */ #include #include #include #include #include #include #include "MessageDia1.h" XmMessageBoxWidget mbox; /* MessageBox widget */ Widget shell; /* Dialog Shell */ static int symSet = False; static XmString str1 = NULL; static XmString str2 = NULL; static XmString str3 = NULL; static XmString str4 = NULL; static Pixmap hourPix = (Pixmap)0; static Pixmap tinaPix = (Pixmap)0; static Pixmap CreatePixmap (); static char hourBits[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0xff, 0xff, 0x07, 0x40, 0x00, 0x00, 0x02, 0x80, 0x00, 0x00, 0x01, 0x00, 0x03, 0xc0, 0x00, 0x00, 0x0e, 0x70, 0x00, 0x00, 0xfc, 0x3f, 0x00, 0x00, 0xf8, 0x1f, 0x00, 0x00, 0xf0, 0x0f, 0x00, 0x00, 0xe0, 0x0f, 0x00, 0x00, 0xe0, 0x0f, 0x00, 0x00, 0xe0, 0x0f, 0x00, 0x00, 0xe0, 0x0f, 0x00, 0x00, 0xe0, 0x0f, 0x00, 0x00, 0xf0, 0x0f, 0x00, 0x00, 0xe8, 0x1f, 0x00, 0x00, 0xe4, 0x2f, 0x00, 0x00, 0xf2, 0x5f, 0x00, 0x00, 0xf9, 0x9f, 0x00, 0x80, 0xfd, 0x3f, 0x01, 0xc0, 0xff, 0xff, 0x03, 0xe0, 0xff, 0xff, 0x07, 0xe0, 0xff, 0xff, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; static char tinaBits[] = { 0xfc, 0x7e, 0x40, 0x20, 0x90, 0x00, 0x07, 0x80, 0x23, 0x00, 0x00, 0xc6, 0xc1, 0x41, 0x98, 0xb8, 0x01, 0x07, 0x66, 0x00, 0x15, 0x9f, 0x03, 0x47, 0x8c, 0xc6, 0xdc, 0x7b, 0xcc, 0x00, 0xb0, 0x71, 0x0e, 0x4d, 0x06, 0x66, 0x73, 0x8e, 0x8f, 0x01, 0x18, 0xc4, 0x39, 0x4b, 0x02, 0x23, 0x0c, 0x04, 0x1e, 0x03, 0x0c, 0x08, 0xc7, 0xef, 0x08, 0x30, 0x06, 0x07, 0x1c, 0x02, 0x06, 0x30, 0x18, 0xae, 0xc8, 0x98, 0x3f, 0x78, 0x20, 0x06, 0x02, 0x20, 0x60, 0xa0, 0xc4, 0x1d, 0xc0, 0xff, 0x41, 0x04, 0xfa, 0x63, 0x80, 0xa1, 0xa4, 0x3d, 0x00, 0x84, 0xbf, 0x04, 0x0f, 0x06, 0xfc, 0xa1, 0x34, 0x6b, 0x01, 0x1c, 0xc9, 0x05, 0x06, 0xc7, 0x06, 0xbe, 0x11, 0x1e, 0x43, 0x30, 0x91, 0x05, 0xc3, 0x61, 0x02, 0x30, 0x1b, 0x30, 0xcc, 0x20, 0x11, 0x00, 0xc1, 0x3c, 0x03, 0x20, 0x0a, 0x00, 0xe8, 0x60, 0x21, 0x00, 0x61, 0x1b, 0xc1, 0x63, 0x08, 0xf0, 0xc6, 0xc7, 0x21, 0x03, 0xf8, 0x08, 0xe1, 0xcf, 0x0a, 0xfc, 0x4d, 0x99, 0x43, 0x07, 0x3c, 0x0c, 0xf1, 0x9f, 0x0b, 0xfc, 0x5b, 0x81, 0x47, 0x02, 0x16, 0x04, 0x31, 0x1c, 0x0b, 0x1f, 0x17, 0x89, 0x4d, 0x06, 0x1a, 0x04, 0x31, 0x38, 0x02, 0x07, 0x56, 0x89, 0x49, 0x04, 0x0b, 0x04, 0xb1, 0x72, 0x82, 0xa1, 0x54, 0x9a, 0x49, 0x04, 0x1d, 0x66, 0x50, 0xe7, 0xc2, 0xf0, 0x54, 0x9a, 0x58, 0x04, 0x0d, 0x62, 0xc1, 0x1f, 0x44, 0xfc, 0x51, 0x90, 0x90, 0x04, 0x86, 0x63, 0xe0, 0x74, 0x04, 0xef, 0x31, 0x1a, 0x91, 0x00, 0x02, 0xe2, 0xc1, 0xfd, 0x84, 0xf9, 0x30, 0x0a, 0x91, 0x00, 0x82, 0xa9, 0xc0, 0xb9, 0x84, 0xf9, 0x31, 0x16, 0x81, 0x00, 0x42, 0xa9, 0xdb, 0x7f, 0x0c, 0xff, 0x1c, 0x16, 0x11, 0x00, 0x02, 0x28, 0x0b, 0x07, 0x08, 0x60, 0x1c, 0x02, 0x91, 0x00, 0x46, 0x29, 0x0e, 0x00, 0x00, 0x00, 0x10, 0x16, 0x11, 0x02, 0x06, 0x29, 0x04, 0x00, 0x00, 0x00, 0x10, 0x16, 0x91, 0x06, 0xa6, 0x2a, 0x04, 0x00, 0x00, 0x00, 0x18, 0x24, 0x91, 0x04, 0x86, 0x2a, 0x04, 0x00, 0x00, 0x00, 0x18, 0x27, 0x93, 0x04, 0x96, 0x4a, 0x04, 0x00, 0x00, 0x00, 0x04, 0x02, 0x91, 0x04, 0x86, 0x4a, 0x0c, 0x00, 0x00, 0x00, 0x1e, 0x23, 0x93, 0x04, 0x56, 0x88, 0x08, 0x00, 0x00, 0x00, 0x90, 0x21, 0x93, 0x04, 0x52, 0x0a, 0x09, 0x80, 0x01, 0x00, 0xd0, 0x21, 0x95, 0x04, 0x57, 0x0a, 0x0f, 0x80, 0x27, 0x00, 0xd8, 0x20, 0x9d, 0x04, 0x5d, 0x08, 0x1c, 0x80, 0x67, 0x00, 0xe4, 0x01, 0x85, 0x04, 0x79, 0x8a, 0x3f, 0x00, 0x00, 0x00, 0xf4, 0x11, 0x85, 0x06, 0x39, 0x08, 0x7d, 0x00, 0x00, 0x18, 0xb7, 0x10, 0x81, 0x03, 0x29, 0x12, 0xcb, 0x00, 0x7e, 0x30, 0x28, 0x00, 0x85, 0x03, 0x29, 0x10, 0xbe, 0x81, 0xff, 0x27, 0x0c, 0x10, 0x85, 0x03, 0x29, 0x32, 0xfa, 0xc1, 0xff, 0x27, 0x94, 0x11, 0x85, 0x03, 0x28, 0x20, 0x6c, 0xe1, 0xff, 0x07, 0x0c, 0x01, 0x85, 0x01, 0x28, 0x62, 0x5c, 0xe3, 0x8f, 0x03, 0x4e, 0x91, 0x80, 0x05, 0x39, 0x40, 0xf4, 0xc2, 0xff, 0x00, 0x9f, 0x91, 0x84, 0x05, 0x31, 0xc6, 0xe8, 0x07, 0x7f, 0x80, 0xcd, 0x00, 0xc4, 0x04, 0x31, 0x06, 0xc9, 0x0e, 0x00, 0xc0, 0x48, 0x88, 0xe0, 0x04, 0x79, 0x04, 0xdb, 0x12, 0x00, 0x30, 0x0c, 0xc8, 0xe4, 0x04, 0x6d, 0x06, 0xb6, 0x23, 0x00, 0x18, 0x1c, 0xc0, 0x84, 0x04, 0x25, 0x0c, 0xff, 0xc2, 0x00, 0x4e, 0x06, 0xb0, 0x80, 0x04, 0x3f, 0x8a, 0xb3, 0x83, 0xff, 0xc3, 0x03, 0x91, 0x84, 0x04, 0x2e, 0xd8, 0x0f, 0x3f, 0x00, 0x00, 0x5f, 0x83, 0x84, 0x04, 0x2a, 0x70, 0xfd, 0x7f, 0x00, 0x00, 0xc8, 0xc0, 0x84, 0x04, 0x4b, 0xe2, 0x2f, 0x01, 0x00, 0x08, 0x58, 0x60, 0x80, 0x04, 0x5b, 0x82, 0xff, 0x01, 0x00, 0x08, 0xd0, 0xa0, 0x84, 0x04, 0x72, 0x80, 0xe5, 0x00, 0x00, 0x08, 0xd2, 0x20, 0x44, 0x04, 0xca, 0x02, 0xff, 0x00, 0x00, 0x08, 0xde, 0xa0, 0x44, 0x04, 0x82, 0x02, 0x6d, 0x00, 0x00, 0x08, 0xf6, 0xb0, 0x40, 0x02, 0x82, 0x07, 0x3f, 0x00, 0x00, 0x08, 0x44, 0x58, 0x44, 0x02, 0x93, 0x3f, 0x1f, 0x00, 0x00, 0x30, 0x88, 0x4f, 0x44, 0x03, 0x83, 0x23, 0x3e, 0x00, 0x00, 0x00, 0x18, 0x60, 0xe0, 0x07, 0xe3, 0x0f, 0xfe, 0x00, 0x00, 0x00, 0x70, 0x70, 0xe4, 0x07, 0xc7, 0x1b, 0xfe, 0x01, 0x00, 0x00, 0xe0, 0x3c, 0xe4, 0x07, 0xc7, 0xe3, 0xfe, 0x1f, 0x00, 0x00, 0xff, 0x1f, 0xfc, 0x07, 0xc7, 0x03, 0xf8, 0x33, 0x00, 0xc0, 0xf0, 0x07, 0xff, 0x07, 0x87, 0x02, 0xfc, 0x43, 0x00, 0x60, 0xf0, 0xff, 0xff, 0x07, 0x8f, 0x06, 0xbe, 0x87, 0x00, 0x30, 0xf8, 0xff, 0xff, 0x07, 0x8f, 0x14, 0x9c, 0x8f, 0x00, 0x00, 0xfc, 0xff, 0xff, 0x07, 0x9f, 0x8d, 0x8a, 0x0f, 0x00, 0x00, 0xfe, 0xff, 0xff, 0x07, 0xbf, 0x0b, 0x80, 0x1f, 0x00, 0x00, 0xff, 0xff, 0xff, 0x07, 0x7f, 0x3a, 0x80, 0x3f, 0x00, 0x80, 0xff, 0xff, 0xff, 0x07, 0xff, 0x20, 0xc0, 0x3f, 0x00, 0x80, 0xff, 0xff, 0xff, 0x07, 0xff, 0x01, 0xe0, 0x7f, 0x00, 0xc0, 0xff, 0xff, 0xff, 0x07, 0xff, 0x0f, 0xf8, 0xff, 0x40, 0xe0, 0xff, 0xff, 0xff, 0x07, 0xff, 0xff, 0xff, 0xff, 0x40, 0xf0, 0xff, 0xff, 0xff, 0x07, 0xff, 0xff, 0xff, 0xff, 0x41, 0xf0, 0xff, 0xff, 0xff, 0x07}; /* callbacks */ static void OkCB(); static XtCallbackRec ok_cb[] = { { OkCB, NULL}, { NULL, NULL} }; static void CancelCB(); static XtCallbackRec cancel_cb[] = { { CancelCB, NULL}, { NULL, NULL} }; static void HelpCB(); static XtCallbackRec help_cb[] = { { HelpCB, NULL}, { NULL, NULL} }; /*------------------------------------------------------------- ** OkCB - callback for ok button */ static void OkCB (w, client_data, call_data) Widget w; /* widget id */ XtPointer client_data; /* data from application */ XtPointer call_data; /* data from widget class */ { Arg args[10]; register int n; if (symSet) { n=0; XtSetArg (args[n], XmNokLabelString, str1); n++; XtSetValues (w, args, n); symSet = False; } else { n=0; XtSetArg (args[n], XmNokLabelString, str2); n++; XtSetValues (w, args, n); symSet = True; } } /*------------------------------------------------------------- ** CancelCB - callback for cancel button */ static void CancelCB (w, client_data, call_data) Widget w; /* widget id */ XtPointer client_data; /* data from application */ XtPointer call_data; /* data from widget class */ { Arg args[10]; register int n; static Pixmap pix=(Pixmap)0; if (symSet) { n=0; XtSetArg (args[n], XmNsymbolPixmap, hourPix); n++; XtSetArg (args[n], XmNdialogType, XmDIALOG_ERROR); n++; XtSetValues (w, args, n); } else { n=0; XtSetArg (args[n], XmNdialogType, XmDIALOG_ERROR); n++; XtSetValues (w, args, n); } } /*------------------------------------------------------------- ** HelpCB - callback for help button */ static void HelpCB (w, client_data, call_data) Widget w; /* widget id */ XtPointer client_data; /* data from application */ XtPointer call_data; /* data from widget class */ { Arg args[10]; register int n; if (symSet) { n=0; XtSetArg (args[n], XmNsymbolPixmap, tinaPix); n++; XtSetArg (args[n], XmNdialogType, XmDIALOG_QUESTION); n++; XtSetValues (w, args, n); } else { n=0; XtSetArg (args[n], XmNdialogType, XmDIALOG_QUESTION); n++; XtSetValues (w, args, n); } } /*#### main ####*/ void main (argc,argv) unsigned int argc; char **argv; { Arg args[10]; /* arg list */ register int n; /* arg count */ /* initialize toolkit */ CommonTestInit(argc, argv); n = 0; XtSetArg (args[n], XmNwidth, 10); n++; XtSetArg (args[n], XmNheight, 10); n++; XtSetValues(Shell1, args, n); /* create the pixmaps */ hourPix = CreatePixmap (XtScreen(Shell1), hourBits, 32, 32, BlackPixelOfScreen(XtScreen(Shell1)), WhitePixelOfScreen(XtScreen(Shell1))); /* create message dialog */ str1 = XmStringCreate ("NoSymSet", XmSTRING_DEFAULT_CHARSET); str2 = XmStringCreate ("SetSymbol", XmSTRING_DEFAULT_CHARSET); str3 = XmStringCreate ("error", XmSTRING_DEFAULT_CHARSET); str4 = XmStringCreate ("question", XmSTRING_DEFAULT_CHARSET); n = 0; XtSetArg (args[n], XmNokCallback, ok_cb); n++; XtSetArg (args[n], XmNcancelCallback, cancel_cb); n++; XtSetArg (args[n], XmNhelpCallback, help_cb); n++; XtSetArg (args[n], XmNokLabelString, str1); n++; XtSetArg (args[n], XmNcancelLabelString, str3); n++; XtSetArg (args[n], XmNhelpLabelString, str4); n++; XtSetArg (args[n], XmNsymbolPixmap, hourPix); n++; XtSetArg (args[n], XmNautoUnmanage, False); n++; XtSetArg (args[n], XmNminimizeButtons, False); n++; symSet = False; mbox = (XmMessageBoxWidget)XmCreateMessageDialog (Shell1, "mbox", args, n); tinaPix = CreatePixmap (XtScreen(Shell1), tinaBits, 75, 75, mbox->manager.foreground, mbox->core.background_pixel); XtRealizeWidget (Shell1); XtManageChild ((Widget) mbox); CommonPause(); /* process events */ XtAppMainLoop(app_context); } /*********************************************************************** * * CreatePixmap - This routine will return a pixmap from the output * of the bitmap editor. The output pixmap will be * the depth of the screen. This is so that label can * write it using its current foreground and background. * ***********************************************************************/ static Pixmap CreatePixmap (screen, bitmap_bits, bitmap_height, bitmap_width, foreground_pixel, background_pixel) Screen *screen; unsigned short *bitmap_bits; int bitmap_height, bitmap_width; Pixel foreground_pixel, background_pixel; { register Display *display = DisplayOfScreen (screen); XImage image; Pixmap pixmap; GC gc; XGCValues gcValues; image.height = bitmap_height; /* dimensions */ image.width = bitmap_width; image.format = XYBitmap; /* assumed input is bit-map */ image.depth = 1; /* hence, depth of 1 */ image.data = (char*) bitmap_bits; /* where the bits are */ image.xoffset = 0; /* leading pixels to skip ? */ image.byte_order = LSBFirst; /* magic numbers, describing */ image.bitmap_pad = 8; /* data format of bit map */ image.bitmap_bit_order = LSBFirst; image.bitmap_unit = 8; image.bytes_per_line = (bitmap_width + 7) / 8; image.obdata = NULL; /* get a chunk of off-screen, display on root screen */ /* 1 bit deep, this is still just bit data, not color pixel data */ pixmap = XCreatePixmap (display, RootWindowOfScreen (screen), image.width, image.height, (unsigned) DefaultDepthOfScreen(screen)); if (!pixmap) return (pixmap); /* When putting a XYPixmap type image, the foreground and */ /* and background of the gc should not be used, but I'll */ /* leave this in here anyway. */ gcValues.foreground = foreground_pixel; gcValues.background = background_pixel; /* build a gc to use when drawing into the pixmap */ gc = XCreateGC (display, pixmap, GCForeground | GCBackground, &gcValues); if (! gc) return ((Pixmap) NULL); /* put bits into the pixmap */ XPutImage (display, pixmap, gc, &image, 0, 0, 0, 0, image.width, image.height); XFreeGC (display, gc); return (pixmap); }