1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231
|
/*
* Motif
*
* Copyright (c) 1987-2012, The Open Group. All rights reserved.
*
* These libraries and programs are free software; you can
* redistribute them and/or modify them under the terms of the GNU
* Lesser General Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at your option)
* any later version.
*
* These libraries and programs are distributed in the hope that
* they will be useful, but WITHOUT ANY WARRANTY; without even the
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with these librararies and programs; if not, write
* to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
* Floor, Boston, MA 02110-1301 USA
*/
/*
* HISTORY
*/
#ifdef REV_INFO
#ifndef lint
static char rcsid[] = "$XConsortium: MessageBox1.c /main/8 1995/07/13 18:58:39 drk $"
#endif
#endif
/*
* (c) Copyright 1987, 1988, 1989 HEWLETT-PACKARD COMPANY */
#include <testlib.h>
#include "warning"
#ifndef PROGNAME
#define PROGNAME "MsgBox2"
#endif
/* Global Variables */
Widget RowColumn1;
Widget MessageBox1;
Widget MessageBox2;
Widget MessageBox3;
Widget MessageBox4;
Widget MessageBox5;
Widget MessageBox6;
Pixmap warnmap;
void HelpCB();
void FocusCB();
void main(argc, argv)
int argc;
char **argv;
{
Boolean trace = False;
register int n;
Arg args[MAX_ARGS];
XmString tcs1;
XmString tcs2;
CommonTestInit(argc, argv);
n = 0;
XtSetArg(args[n], XmNwidth, 400); n++;
XtSetArg(args[n], XmNheight, 300); n++;
XtSetValues(Shell1, args, n);
XtRealizeWidget(Shell1);
n = 0;
XtSetArg(args[n], XmNentryBorder, 1); n++;
RowColumn1 = XmCreateRowColumn(Shell1, "RowColumn1", args, n);
/* XtManageChild(RowColumn1); */
n = 0;
MessageBox1 = XmCreateMessageBox(RowColumn1, "MessageBox", args, n);
XtManageChild(MessageBox1);
XtAddCallback (MessageBox1, XmNfocusCallback, FocusCB, NULL);
n = 0;
XtSetArg(args[n], XmNdialogType, XmDIALOG_ERROR); n++;
MessageBox2 = XmCreateMessageBox(RowColumn1, "ErrorDialog", args, n);
XtManageChild(MessageBox2);
XtAddCallback (MessageBox2, XmNfocusCallback, FocusCB, NULL);
n = 0;
XtSetArg(args[n], XmNdialogType, XmDIALOG_QUESTION); n++;
MessageBox3 = XmCreateMessageBox(RowColumn1, "QuestionDialog", args, n);
XtManageChild(MessageBox3);
XtAddCallback (MessageBox3, XmNfocusCallback, FocusCB, NULL);
n = 0;
XtSetArg(args[n], XmNdialogType, XmDIALOG_INFORMATION); n++;
MessageBox4 = XmCreateMessageBox(RowColumn1, "InformationDialog", args, n);
XtManageChild(MessageBox4);
XtAddCallback (MessageBox4, XmNfocusCallback, FocusCB, NULL);
n = 0;
XtSetArg(args[n], XmNdialogType, XmDIALOG_WARNING); n++;
MessageBox5 = XmCreateMessageBox(RowColumn1, "WarningDialog", args, n);
XtManageChild(MessageBox5);
XtAddCallback (MessageBox5, XmNfocusCallback, FocusCB, NULL);
n = 0;
XtSetArg(args[n], XmNdialogType, XmDIALOG_WORKING); n++;
MessageBox6 = XmCreateMessageBox(RowColumn1, "WorkingDialog", args, n);
XtManageChild(MessageBox6);
XtAddCallback (MessageBox6, XmNfocusCallback, FocusCB, NULL);
/* Reset values for the warning messagebox. 1st build the pixmap */
warnmap = XCreatePixmapFromBitmapData(display,
DefaultRootWindow(display),
warning_bits,warning_width,warning_height,
BlackPixel(display,DefaultScreen(display)),
WhitePixel(display,DefaultScreen(display)),
DefaultDepth(display,DefaultScreen(display)));
n = 0;
tcs1 = XmStringLtoRCreate("Warning!! File Exists!\nOK to OverWrite?",
XmSTRING_DEFAULT_CHARSET);
XtSetArg(args[n], XmNmessageString, tcs1); n++;
XtSetArg(args[n], XmNsymbolPixmap, warnmap); n++;
XtSetArg(args[n], XmNmessageAlignment, XmALIGNMENT_END); n++;
tcs2 = XmStringLtoRCreate("Not OK", XmSTRING_DEFAULT_CHARSET);
XtSetArg(args[n], XmNcancelLabelString, tcs2); n++;
XtSetValues(MessageBox5, args, n);
XmStringFree(tcs1);
XmStringFree(tcs2);
/* Reset messages for each other message boxes */
n = 0;
tcs1 = XmStringLtoRCreate("For your information",
XmSTRING_DEFAULT_CHARSET);
XtSetArg(args[n], XmNmessageString, tcs1); n++;
tcs2 = XmStringLtoRCreate("Boring", XmSTRING_DEFAULT_CHARSET);
XtSetArg(args[n], XmNcancelLabelString, tcs2); n++;
XtSetValues(MessageBox4,args,n);
XmStringFree(tcs1);
XmStringFree(tcs2);
n = 0;
tcs1 = XmStringLtoRCreate("This is a Question?",
XmSTRING_DEFAULT_CHARSET);
XtSetArg(args[n], XmNmessageString, tcs1); n++;
tcs2 = XmStringLtoRCreate("No Answer", XmSTRING_DEFAULT_CHARSET);
XtSetArg(args[n], XmNcancelLabelString, tcs2); n++;
XtSetValues(MessageBox3,args,n);
XmStringFree(tcs1);
XmStringFree(tcs2);
n = 0;
tcs1 = XmStringLtoRCreate("This is a Message.",
XmSTRING_DEFAULT_CHARSET);
XtSetArg(args[n], XmNmessageString, tcs1); n++;
XtSetValues(MessageBox1,args,n);
XmStringFree(tcs1);
n = 0;
tcs1 = XmStringLtoRCreate("You made an error!",
XmSTRING_DEFAULT_CHARSET);
XtSetArg(args[n], XmNmessageString, tcs1); n++;
tcs2 = XmStringLtoRCreate("Re-do", XmSTRING_DEFAULT_CHARSET);
XtSetArg(args[n], XmNcancelLabelString, tcs2); n++;
XtSetValues(MessageBox2,args,n);
XmStringFree(tcs1);
XmStringFree(tcs2);
n = 0;
tcs1 = XmStringLtoRCreate("Working Dialog.",
XmSTRING_DEFAULT_CHARSET);
XtSetArg(args[n], XmNmessageString, tcs1); n++;
tcs2 = XmStringLtoRCreate("Go Home", XmSTRING_DEFAULT_CHARSET);
XtSetArg(args[n], XmNcancelLabelString, tcs2); n++;
XtSetValues(MessageBox6,args,n);
XmStringFree(tcs1);
XmStringFree(tcs2);
/* add the help callback to each one */
XtAddCallback(MessageBox1,XmNhelpCallback, HelpCB, NULL);
XtAddCallback(MessageBox2,XmNhelpCallback, HelpCB, NULL);
XtAddCallback(MessageBox3,XmNhelpCallback, HelpCB, NULL);
XtAddCallback(MessageBox4,XmNhelpCallback, HelpCB, NULL);
XtAddCallback(MessageBox5,XmNhelpCallback, HelpCB, NULL);
XtAddCallback(MessageBox6,XmNhelpCallback, HelpCB, NULL);
XtManageChild(RowColumn1);
CommonPause();
CommonPause();
CommonPause();
CommonPause();
XtAppMainLoop(app_context);
}
void FocusCB (widget, client_data, call_data)
Widget widget;
XtPointer client_data, call_data;
{
printf ("Focus has arrived in %s\n", XtName(widget));
fflush (stdout);
}
void HelpCB(widget, client_data, call_data)
Widget widget;
XtPointer client_data;
XtPointer call_data;
{
printf ("Help callback called from %s\n", XtName(widget));
fflush (stdout);
}
|