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 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441
|
/*
* 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: DiaShell5.c /main/7 1995/07/13 19:20:15 drk $"
#endif
#endif
/****************************************
* Automatic test program generation *
* Version 1.4 *
* Thu May 18 07:49:47 1989 *
****************************************/
#include "DiaShell3.h"
#include <X11/ShellP.h>
VendorShellWidget DialogShell1;
Widget BulletinBoard1,
PushButton1,
PushButton2;
Widget Scale;
/* forward declarations */
void Quit();
static XtCallbackProc QuitCB();
/* callback procedures */
static XtCallbackProc PostPrimaryModalDialog (w, client_data, call_data)
Widget w;
caddr_t client_data, call_data;
{
Widget parent, Dialog1, spawnButton;
int n;
Arg args[10];
XmString tcs;
int delay;
parent = (Widget) client_data;
/* get the posting delay from the Scale*/
n = 0;
XtSetArg (args[n], XmNvalue, &delay); n++;
XtGetValues (Scale, args, n);
n = 0;
/* message box resources */
XtSetArg (args[n], XmNmessageString,
XmStringCreateSimple ("While this box is up, you should not be able to use its parent")); n++;
XtSetArg (args[n], XmNautoUnmanage, True); n++;
XtSetArg (args[n], XmNhelpLabelString, XmStringCreateSimple ("Spawn Dialog Child")); n++;
/* dialog shell resources */
XtSetArg (args[n], XmNtitle, "Primary Application Modal Dialog"); n++;
/* XtSetArg (args[n], XmNmwmInpuMode, XmDIALOG_PRIMARY_APPLICATION_MODAL);
n++; */
XtSetArg (args[n], XmNdialogStyle, XmDIALOG_PRIMARY_APPLICATION_MODAL);
n++;
Dialog1 = XmCreateMessageDialog(parent, "Dialog1", args, n);
/* make HELP button spawn a child */
spawnButton = XmMessageBoxGetChild (Dialog1, XmDIALOG_HELP_BUTTON);
XtAddCallback (spawnButton, XmNactivateCallback, PostPrimaryModalDialog, Dialog1);
if (delay) sleep (delay);
XtManageChild (Dialog1);
}
static XtCallbackProc PostFullAppModalDialog (w, client_data, call_data)
Widget w;
caddr_t client_data, call_data;
{
Widget parent, Dialog2;
int n;
Arg args[10];
int delay;
parent = (Widget) client_data;
/* get the posting delay from the Scale*/
n = 0;
XtSetArg (args[n], XmNvalue, &delay); n++;
XtGetValues (Scale, args, n);
n = 0;
/* message box resources */
XtSetArg (args[n], XmNmessageString,
XmStringCreateSimple ("While this box is up, you should not be able to use either Shell1 or Shell2 nor any other dialog box."
)); n++;
XtSetArg (args[n], XmNautoUnmanage, True); n++;
/* dialog shell resources */
XtSetArg (args[n], XmNtitle, "Full Application Modal Dialog"); n++;
/* XtSetArg (args[n], XmNmwmInpuMode, XmDIALOG_PRIMARY_APPLICATION_MODAL);
n++; */
XtSetArg (args[n], XmNdialogStyle, XmDIALOG_FULL_APPLICATION_MODAL);
n++;
Dialog2 = XmCreateMessageDialog(parent, "Dialog1", args, n);
if (delay) sleep (delay);
XtManageChild (Dialog2);
}
static XtCallbackProc PostSystemModalDialog (w, client_data, call_data)
Widget w;
caddr_t client_data, call_data;
{
Widget parent, Dialog3;
int n;
Arg args[10];
int delay;
parent = (Widget) client_data;
/* get the posting delay from the Scale*/
n = 0;
XtSetArg (args[n], XmNvalue, &delay); n++;
XtGetValues (Scale, args, n);
n = 0;
/* message box resources */
XtSetArg (args[n], XmNmessageString, XmStringCreateSimple ("While this box is up, you should not be able to use any other application nor any other part of this client.")); n++;
XtSetArg (args[n], XmNautoUnmanage, True); n++;
/* dialog shell resources */
XtSetArg (args[n], XmNtitle, "Full Application Modal Dialog"); n++;
/* XtSetArg (args[n], XmNmwmInpuMode, XmDIALOG_PRIMARY_APPLICATION_MODAL);
n++; */
XtSetArg (args[n], XmNdialogStyle, XmDIALOG_SYSTEM_MODAL);
n++;
Dialog3 = XmCreateMessageDialog(parent, "Dialog1", args, n);
if (delay) sleep (delay);
XtManageChild (Dialog3);
}
void main(argc, argv)
int argc;
char **argv;
{
Boolean trace = False;
register int n;
Arg args[MAX_ARGS];
XmString tcs;
Widget Shell2;
Widget BB1, BB2;
Widget DB, DB2, exitButton;
Widget test1, test1a, test2, test3;
signal(SIGHUP, Quit);
signal(SIGINT, Quit);
signal(SIGQUIT, Quit);
XtToolkitInitialize();
app_context = XtCreateApplicationContext();
display = XtOpenDisplay(app_context, NULL, argv[0], "XMclient",
NULL, 0, &argc, argv);
if (display == NULL) {
fprintf(stderr, "%s: Can't open display\n", argv[0]);
exit(1);
}
GetOptions(argc, argv, &trace);
n = 0;
XtSetArg(args[n], XmNallowShellResize, True); n++;
XtSetArg(args[n], XmNtitle, "Shell 1"); n++;
Shell1 = XtAppCreateShell(argv[0], NULL, applicationShellWidgetClass,
display, args, n);
n = 0;
XtSetArg(args[n], XmNmappedWhenManaged, True); n++;
XtSetArg(args[n], XmNtitle, "Shell 2"); n++;
Shell2 = XtCreatePopupShell("Shell 2", topLevelShellWidgetClass, Shell1,
args, n);
/* Shell 1 children */
n = 0;
BB1 = XmCreateBulletinBoard (Shell1, "BB1", args, n);
XtManageChild (BB1);
n = 0;
XtSetArg (args[n], XmNx, 300); n++;
XtSetArg (args[n], XmNy, 50); n++;
XtSetArg (args[n], XmNlabelString,
XmStringCreateSimple ("Default Button")); n++;
DB = XmCreatePushButton (BB1, "DB", args, n);
XtManageChild (DB);
n = 0;
XtSetArg (args[n], XmNdefaultButton, DB); n++;
XtSetValues (BB1, args, n);
n = 0;
XtSetArg (args[n], XmNx, 300); n++;
XtSetArg (args[n], XmNy, 10); n++;
exitButton = XmCreatePushButtonGadget (BB1, "Exit", args, n);
XtManageChild (exitButton);
XtAddCallback (exitButton, XmNactivateCallback, Quit, NULL);
n = 0;
XtSetArg(args[n], XmNx, 12); n++;
XtSetArg(args[n], XmNy, 20); n++;
XtSetArg(args[n], XmNvalue, 0); n++;
XtSetArg(args[n], XmNtitleString,
XmStringCreateSimple ("Posting Delay")); n++;
XtSetArg(args[n], XmNmaximum, 120); n++;
XtSetArg(args[n], XmNminimum, 0); n++;
XtSetArg(args[n], XmNshowValue, True); n++;
XtSetArg(args[n], XmNprocessingDirection, XmMAX_ON_RIGHT); n++;
XtSetArg(args[n], XmNorientation, XmHORIZONTAL); n++;
Scale = XmCreateScale (BB1, "Scale", args, n);
XtManageChild (Scale);
n = 0;
XtSetArg (args[n], XmNx, 10); n++;
XtSetArg (args[n], XmNy, 100); n++;
XtSetArg (args[n], XmNlabelString,
XmStringCreateSimple ("Create Primary Modal from Shell2")); n++;
test1 = XmCreatePushButton (BB1, "test1", args, n);
XtManageChild (test1);
XtAddCallback (test1, XmNactivateCallback, PostPrimaryModalDialog, Shell2);
n = 0;
XtSetArg (args[n], XmNx, 10); n++;
XtSetArg (args[n], XmNy, 150); n++;
XtSetArg (args[n], XmNlabelString,
XmStringCreateSimple ("Create Primary Modal from Shell1")); n++;
test1a = XmCreatePushButton (BB1, "test1a", args, n);
XtManageChild (test1a);
XtAddCallback (test1a, XmNactivateCallback, PostPrimaryModalDialog, Shell1);
n = 0;
XtSetArg (args[n], XmNx, 10); n++;
XtSetArg (args[n], XmNy, 200); n++;
XtSetArg (args[n], XmNlabelString,
XmStringCreateSimple ("Create Full App Modal Dialog")); n++;
test2 = XmCreatePushButton (BB1, "test2", args, n);
XtManageChild (test2);
XtAddCallback (test2, XmNactivateCallback, PostFullAppModalDialog, Shell1);
n = 0;
XtSetArg (args[n], XmNx, 10); n++;
XtSetArg (args[n], XmNy, 250); n++;
XtSetArg (args[n], XmNlabelString,
XmStringCreateSimple ("Create System Modal Dialog")); n++;
test3 = XmCreatePushButton (BB1, "test3", args, n);
XtManageChild (test3);
XtAddCallback (test3, XmNactivateCallback, PostSystemModalDialog, Shell2);
/* Shell 2 children */
n = 0;
BB2 = XmCreateBulletinBoard (Shell2, "BB2", args, n);
XtManageChild (BB2);
n = 0;
XtSetArg (args[n], XmNx, 200); n++;
XtSetArg (args[n], XmNy, 50); n++;
DB2 = XmCreatePushButtonGadget (BB2, "DB2", args, n);
XtManageChild (DB2);
n = 0;
XtSetArg (args[n], XmNdefaultButton, DB2); n++;
XtSetValues (BB2, args, n);
XtRealizeWidget(Shell1);
XtRealizeWidget(Shell2);
XtPopup(Shell2, XtGrabNone);
XtAppMainLoop(app_context);
}
static void GetOptions(argc, argv, trace)
int argc;
char **argv;
Boolean *trace;
{
register int i;
for (i = 1; i < argc; i++) {
if (argv[i][0] == '-' && argv[i][1] == 'v')
*trace = True;
else {
fprintf(stderr, "\nusage: %s [-v]\n", PROGNAME);
fprintf(stderr, " The -v option enables trace output.\n\n");
exit(1);
}
}
}
static void Quit()
{
printf("Begin exiting ... please standby ... \n");
fflush(stdout);
exit(0);
}
static void Pause()
{
ContinuePopup = CreateContinuePopup();
XtPopup(ContinuePopup, XtGrabNone);
wait = True;
while (wait)
FlushEvents();
Pause_cnt++;
}
static Widget CreateContinuePopup()
{
Widget popup;
Widget rowcol;
Widget message;
Widget exit_button, continue_button;
Arg args[MAX_ARGS];
register int n;
XmString message_field, continue_field, exit_field;
static XtTranslations tm_parsed, btn_parsed;
static char tm[] =
"#override \n\
<Btn3Down>:MenuPopup(Next_event) \n\
<Btn3Up>:MenuPopdown(Next_event)";
static char btn_tm[] =
"#override\n\
:<Key>p:MenuPopdown() \n\
:<Key>P:MenuPopdown(Next_event) \n\
:<Btn1Down>:Noop() \n\
:<Btn1Up>:Noop()";
tm_parsed = XtParseTranslationTable(tm);
XtOverrideTranslations(Shell1, tm_parsed);
btn_parsed = XtParseTranslationTable(btn_tm);
/* create popup shell */
n = 0;
XtSetArg(args[n], XtNgeometry, "+500+0"); n++;
popup = XtCreatePopupShell("Next_event", topLevelShellWidgetClass,
Shell1, args, n);
/* create a frame for the pushbutton */
n = 0;
XtSetArg(args[n], XmNmarginWidth, 12); n++;
XtSetArg(args[n], XmNmarginHeight, 12); n++;
rowcol = XmCreateRowColumn(popup, "frame", args, n);
XtManageChild(rowcol);
/* create a Message Box and Control Continue and Exit */
n = 0;
message_field = XmStringCreateLtoR(Pause_events[Pause_cnt], XmSTRING_DEFAULT_CHARSET);
continue_field = XmStringCreateLtoR("Continue", XmSTRING_DEFAULT_CHARSET);
exit_field = XmStringCreateLtoR("Exit", XmSTRING_DEFAULT_CHARSET);
XtSetArg(args[n], XmNtranslations, btn_parsed); n++;
XtSetArg(args[n], XmNmessageString, message_field); n++;
XtSetArg(args[n], XmNokLabelString, continue_field); n++;
XtSetArg(args[n], XmNcancelLabelString, exit_field); n++;
message = XmCreateMessageBox(rowcol, "msgbox", args, n);
XmStringFree(continue_field);
XmStringFree(message_field);
XmStringFree(exit_field);
XtManageChild(message);
continue_button = XmMessageBoxGetChild(message, XmDIALOG_OK_BUTTON);
exit_button = XmMessageBoxGetChild(message, XmDIALOG_CANCEL_BUTTON);
XtAddCallback(continue_button, XmNactivateCallback, ContinueCB, popup);
XtAddCallback(exit_button, XmNactivateCallback, QuitCB, popup);
return(popup);
}
static void FlushEvents()
{
XEvent event;
while (XtAppPending(app_context)) {
XtAppNextEvent(app_context, &event);
XtDispatchEvent(&event);
}
}
static XtCallbackProc ContinueCB(w, client_data, call_data)
Widget w;
caddr_t client_data;
caddr_t call_data;
{
wait = False;
XtPopdown((Widget)client_data);
}
static XtCallbackProc QuitCB(w, client_data, call_data)
Widget w;
caddr_t client_data;
caddr_t call_data;
{
printf("Exiting...Please Standby...\n");
exit(0);
}
|